static void vc1_decode_i_blocks(VC1Context *v)
{
    int k, j;
    MpegEncContext *s = &v->s;
    int cbp, val;
    uint8_t *coded_val;
    int mb_pos;
    switch(v->y_ac_table_index){
    case 0:
        v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
        break;
    case 1:
        v->codingset = CS_HIGH_MOT_INTRA;
        break;
    case 2:
        v->codingset = CS_MID_RATE_INTRA;
        break;
    }
    switch(v->c_ac_table_index){
    case 0:
        v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
        break;
    case 1:
        v->codingset2 = CS_HIGH_MOT_INTER;
        break;
    case 2:
        v->codingset2 = CS_MID_RATE_INTER;
        break;
    }
    s->y_dc_scale = s->y_dc_scale_table[v->pq];
    s->c_dc_scale = s->c_dc_scale_table[v->pq];
    s->mb_x = s->mb_y = 0;
    s->mb_intra = 1;
    s->first_slice_line = 1;
    for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {
        for(s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++) {
            ff_init_block_index(s);
            ff_update_block_index(s);
            s->dsp.clear_blocks(s->block[0]);
            mb_pos = s->mb_x + s->mb_y * s->mb_width;
            s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA;
            s->current_picture.qscale_table[mb_pos] = v->pq;
            s->current_picture.motion_val[1][s->block_index[0]][0] = 0;
            s->current_picture.motion_val[1][s->block_index[0]][1] = 0;
            cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
            v->s.ac_pred = get_bits1(&v->s.gb);
            for(k = 0; k < 6; k++) {
                val = ((cbp >> (5 - k)) & 1);
                if (k < 4) {
                    int pred = vc1_coded_block_pred(&v->s, k, &coded_val);
                    val = val ^ pred;
                    *coded_val = val;
                }
                cbp |= val << (5 - k);
                vc1_decode_i_block(v, s->block[k], k, val, (k<4)? v->codingset : v->codingset2);
                s->dsp.vc1_inv_trans_8x8(s->block[k]);
                if(v->pq >= 9 && v->overlap) {
                    for(j = 0; j < 64; j++) s->block[k][j] += 128;
                }
            }
            vc1_put_block(v, s->block);
            if(v->pq >= 9 && v->overlap) {
                if(s->mb_x) {
                    s->dsp.vc1_h_overlap(s->dest[0], s->linesize);
                    s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize, s->linesize);
                    if(!(s->flags & CODEC_FLAG_GRAY)) {
                        s->dsp.vc1_h_overlap(s->dest[1], s->uvlinesize);
                        s->dsp.vc1_h_overlap(s->dest[2], s->uvlinesize);
                    }
                }
                s->dsp.vc1_h_overlap(s->dest[0] + 8, s->linesize);
                s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize);
                if(!s->first_slice_line) {
                    s->dsp.vc1_v_overlap(s->dest[0], s->linesize);
                    s->dsp.vc1_v_overlap(s->dest[0] + 8, s->linesize);
                    if(!(s->flags & CODEC_FLAG_GRAY)) {
                        s->dsp.vc1_v_overlap(s->dest[1], s->uvlinesize);
                        s->dsp.vc1_v_overlap(s->dest[2], s->uvlinesize);
                    }
                }
                s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize, s->linesize);
                s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize);
            }
            if(get_bits_count(&s->gb) > v->bits) {
                ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
                av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n", get_bits_count(&s->gb), v->bits);
                return;
            }
        }
        ff_draw_horiz_band(s, s->mb_y * 16, 16);
        s->first_slice_line = 0;
    }
    ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END));
}
['static void vc1_decode_i_blocks(VC1Context *v)\n{\n    int k, j;\n    MpegEncContext *s = &v->s;\n    int cbp, val;\n    uint8_t *coded_val;\n    int mb_pos;\n    switch(v->y_ac_table_index){\n    case 0:\n        v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;\n        break;\n    case 1:\n        v->codingset = CS_HIGH_MOT_INTRA;\n        break;\n    case 2:\n        v->codingset = CS_MID_RATE_INTRA;\n        break;\n    }\n    switch(v->c_ac_table_index){\n    case 0:\n        v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;\n        break;\n    case 1:\n        v->codingset2 = CS_HIGH_MOT_INTER;\n        break;\n    case 2:\n        v->codingset2 = CS_MID_RATE_INTER;\n        break;\n    }\n    s->y_dc_scale = s->y_dc_scale_table[v->pq];\n    s->c_dc_scale = s->c_dc_scale_table[v->pq];\n    s->mb_x = s->mb_y = 0;\n    s->mb_intra = 1;\n    s->first_slice_line = 1;\n    for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {\n        for(s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++) {\n            ff_init_block_index(s);\n            ff_update_block_index(s);\n            s->dsp.clear_blocks(s->block[0]);\n            mb_pos = s->mb_x + s->mb_y * s->mb_width;\n            s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA;\n            s->current_picture.qscale_table[mb_pos] = v->pq;\n            s->current_picture.motion_val[1][s->block_index[0]][0] = 0;\n            s->current_picture.motion_val[1][s->block_index[0]][1] = 0;\n            cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);\n            v->s.ac_pred = get_bits1(&v->s.gb);\n            for(k = 0; k < 6; k++) {\n                val = ((cbp >> (5 - k)) & 1);\n                if (k < 4) {\n                    int pred = vc1_coded_block_pred(&v->s, k, &coded_val);\n                    val = val ^ pred;\n                    *coded_val = val;\n                }\n                cbp |= val << (5 - k);\n                vc1_decode_i_block(v, s->block[k], k, val, (k<4)? v->codingset : v->codingset2);\n                s->dsp.vc1_inv_trans_8x8(s->block[k]);\n                if(v->pq >= 9 && v->overlap) {\n                    for(j = 0; j < 64; j++) s->block[k][j] += 128;\n                }\n            }\n            vc1_put_block(v, s->block);\n            if(v->pq >= 9 && v->overlap) {\n                if(s->mb_x) {\n                    s->dsp.vc1_h_overlap(s->dest[0], s->linesize);\n                    s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize, s->linesize);\n                    if(!(s->flags & CODEC_FLAG_GRAY)) {\n                        s->dsp.vc1_h_overlap(s->dest[1], s->uvlinesize);\n                        s->dsp.vc1_h_overlap(s->dest[2], s->uvlinesize);\n                    }\n                }\n                s->dsp.vc1_h_overlap(s->dest[0] + 8, s->linesize);\n                s->dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize);\n                if(!s->first_slice_line) {\n                    s->dsp.vc1_v_overlap(s->dest[0], s->linesize);\n                    s->dsp.vc1_v_overlap(s->dest[0] + 8, s->linesize);\n                    if(!(s->flags & CODEC_FLAG_GRAY)) {\n                        s->dsp.vc1_v_overlap(s->dest[1], s->uvlinesize);\n                        s->dsp.vc1_v_overlap(s->dest[2], s->uvlinesize);\n                    }\n                }\n                s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize, s->linesize);\n                s->dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize);\n            }\n            if(get_bits_count(&s->gb) > v->bits) {\n                ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));\n                av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\\n", get_bits_count(&s->gb), v->bits);\n                return;\n            }\n        }\n        ff_draw_horiz_band(s, s->mb_y * 16, 16);\n        s->first_slice_line = 0;\n    }\n    ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END));\n}', 'static int vc1_decode_i_block(VC1Context *v, DCTELEM block[64], int n, int coded, int codingset)\n{\n    GetBitContext *gb = &v->s.gb;\n    MpegEncContext *s = &v->s;\n    int dc_pred_dir = 0;\n    int run_diff, i;\n    int16_t *dc_val;\n    int16_t *ac_val, *ac_val2;\n    int dcdiff;\n    if (n < 4) {\n        dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);\n    } else {\n        dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);\n    }\n    if (dcdiff < 0){\n        av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\\n");\n        return -1;\n    }\n    if (dcdiff)\n    {\n        if (dcdiff == 119  )\n        {\n            if (v->pq == 1) dcdiff = get_bits(gb, 10);\n            else if (v->pq == 2) dcdiff = get_bits(gb, 9);\n            else dcdiff = get_bits(gb, 8);\n        }\n        else\n        {\n            if (v->pq == 1)\n                dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3;\n            else if (v->pq == 2)\n                dcdiff = (dcdiff<<1) + get_bits1(gb)   - 1;\n        }\n        if (get_bits1(gb))\n            dcdiff = -dcdiff;\n    }\n    dcdiff += vc1_i_pred_dc(&v->s, v->overlap, v->pq, n, &dc_val, &dc_pred_dir);\n    *dc_val = dcdiff;\n    if (n < 4) {\n        block[0] = dcdiff * s->y_dc_scale;\n    } else {\n        block[0] = dcdiff * s->c_dc_scale;\n    }\n    run_diff = 0;\n    i = 0;\n    if (!coded) {\n        goto not_coded;\n    }\n    i = 1;\n    {\n        int last = 0, skip, value;\n        const int8_t *zz_table;\n        int scale;\n        int k;\n        scale = v->pq * 2 + v->halfpq;\n        if(v->s.ac_pred) {\n            if(!dc_pred_dir)\n                zz_table = ff_vc1_horizontal_zz;\n            else\n                zz_table = ff_vc1_vertical_zz;\n        } else\n            zz_table = ff_vc1_normal_zz;\n        ac_val = s->ac_val[0][0] + s->block_index[n] * 16;\n        ac_val2 = ac_val;\n        if(dc_pred_dir)\n            ac_val -= 16;\n        else\n            ac_val -= 16 * s->block_wrap[n];\n        while (!last) {\n            vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);\n            i += skip;\n            if(i > 63)\n                break;\n            block[zz_table[i++]] = value;\n        }\n        if(s->ac_pred) {\n            if(dc_pred_dir) {\n                for(k = 1; k < 8; k++)\n                    block[k << 3] += ac_val[k];\n            } else {\n                for(k = 1; k < 8; k++)\n                    block[k] += ac_val[k + 8];\n            }\n        }\n        for(k = 1; k < 8; k++) {\n            ac_val2[k] = block[k << 3];\n            ac_val2[k + 8] = block[k];\n        }\n        for(k = 1; k < 64; k++)\n            if(block[k]) {\n                block[k] *= scale;\n                if(!v->pquantizer)\n                    block[k] += (block[k] < 0) ? -v->pq : v->pq;\n            }\n        if(s->ac_pred) i = 63;\n    }\nnot_coded:\n    if(!coded) {\n        int k, scale;\n        ac_val = s->ac_val[0][0] + s->block_index[n] * 16;\n        ac_val2 = ac_val;\n        scale = v->pq * 2 + v->halfpq;\n        memset(ac_val2, 0, 16 * 2);\n        if(dc_pred_dir) {\n            ac_val -= 16;\n            if(s->ac_pred)\n                memcpy(ac_val2, ac_val, 8 * 2);\n        } else {\n            ac_val -= 16 * s->block_wrap[n];\n            if(s->ac_pred)\n                memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);\n        }\n        if(s->ac_pred) {\n            if(dc_pred_dir) {\n                for(k = 1; k < 8; k++) {\n                    block[k << 3] = ac_val[k] * scale;\n                    if(!v->pquantizer && block[k << 3])\n                        block[k << 3] += (block[k << 3] < 0) ? -v->pq : v->pq;\n                }\n            } else {\n                for(k = 1; k < 8; k++) {\n                    block[k] = ac_val[k + 8] * scale;\n                    if(!v->pquantizer && block[k])\n                        block[k] += (block[k] < 0) ? -v->pq : v->pq;\n                }\n            }\n            i = 63;\n        }\n    }\n    s->block_last_index[n] = i;\n    return 0;\n}']