libavcodec/vc1_block.c:1424: error: Buffer Overrun L2
  Offset: [0, 63] Size: 2.

libavcodec/vc1_block.c:1423:30: <Offset trace>
1421.                     v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
1422.                     if (v->rangeredfrm)
1423.                         for (j = 0; j < 64; j++)
                                   ^
1424.                             s->block[i][j] <<= 1;
1425.                     s->idsp.put_signed_pixels_clamped(s->block[i],

libavcodec/vc1_block.c:1423:30: Assignment
1421.                     v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
1422.                     if (v->rangeredfrm)
1423.                         for (j = 0; j < 64; j++)
                                   ^
1424.                             s->block[i][j] <<= 1;
1425.                     s->idsp.put_signed_pixels_clamped(s->block[i],

libavcodec/vc1_block.c:1417:21: <Length trace>
1415.                         v->c_avail = v->mb_type[0][s->block_index[i] - 1];
1416. 
1417.                     vc1_decode_intra_block(v, s->block[i], i, val, mquant,
                          ^
1418.                                            (i & 4) ? v->codingset2 : v->codingset);
1419.                     if ((i > 3) && (s->avctx->flags & CODEC_FLAG_GRAY))

libavcodec/vc1_block.c:1417:21: Call
1415.                         v->c_avail = v->mb_type[0][s->block_index[i] - 1];
1416. 
1417.                     vc1_decode_intra_block(v, s->block[i], i, val, mquant,
                          ^
1418.                                            (i & 4) ? v->codingset2 : v->codingset);
1419.                     if ((i > 3) && (s->avctx->flags & CODEC_FLAG_GRAY))

libavcodec/vc1_block.c:967:1: Parameter `*block`
  965.  * @param codingset set of VLC to decode data
  966.  */
  967. static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n,
       ^
  968.                                   int coded, int mquant, int codingset)
  969. {

libavcodec/vc1_block.c:1424:29: Array access: Offset: [0, 63] Size: 2
1422.                     if (v->rangeredfrm)
1423.                         for (j = 0; j < 64; j++)
1424.                             s->block[i][j] <<= 1;
                                  ^
1425.                     s->idsp.put_signed_pixels_clamped(s->block[i],
1426.                                                       s->dest[dst_idx] + off,

static int vc1_decode_p_mb(VC1Context *v)
{
    MpegEncContext *s = &v->s;
    GetBitContext *gb = &s->gb;
    int i, j;
    int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
    int cbp;
    int mqdiff, mquant;
    int ttmb = v->ttfrm;
    int mb_has_coeffs = 1;
    int dmv_x, dmv_y;
    int index, index1;
    int val, sign;
    int first_block = 1;
    int dst_idx, off;
    int skipped, fourmv;
    int block_cbp = 0, pat, block_tt = 0, block_intra = 0;
    mquant = v->pq;
    if (v->mv_type_is_raw)
        fourmv = get_bits1(gb);
    else
        fourmv = v->mv_type_mb_plane[mb_pos];
    if (v->skip_is_raw)
        skipped = get_bits1(gb);
    else
        skipped = v->s.mbskip_table[mb_pos];
    if (!fourmv) {
        if (!skipped) {
            GET_MVDATA(dmv_x, dmv_y);
            if (s->mb_intra) {
                s->current_picture.motion_val[1][s->block_index[0]][0] = 0;
                s->current_picture.motion_val[1][s->block_index[0]][1] = 0;
            }
            s->current_picture.mb_type[mb_pos] = s->mb_intra ? MB_TYPE_INTRA : MB_TYPE_16x16;
            ff_vc1_pred_mv(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0], 0, 0);
            if (s->mb_intra && !mb_has_coeffs) {
                GET_MQUANT();
                s->ac_pred = get_bits1(gb);
                cbp        = 0;
            } else if (mb_has_coeffs) {
                if (s->mb_intra)
                    s->ac_pred = get_bits1(gb);
                cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
                GET_MQUANT();
            } else {
                mquant = v->pq;
                cbp    = 0;
            }
            s->current_picture.qscale_table[mb_pos] = mquant;
            if (!v->ttmbf && !s->mb_intra && mb_has_coeffs)
                ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table,
                                VC1_TTMB_VLC_BITS, 2);
            if (!s->mb_intra) ff_vc1_mc_1mv(v, 0);
            dst_idx = 0;
            for (i = 0; i < 6; i++) {
                s->dc_val[0][s->block_index[i]] = 0;
                dst_idx += i >> 2;
                val = ((cbp >> (5 - i)) & 1);
                off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
                v->mb_type[0][s->block_index[i]] = s->mb_intra;
                if (s->mb_intra) {
                    v->a_avail = v->c_avail = 0;
                    if (i == 2 || i == 3 || !s->first_slice_line)
                        v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
                    if (i == 1 || i == 3 || s->mb_x)
                        v->c_avail = v->mb_type[0][s->block_index[i] - 1];
                    vc1_decode_intra_block(v, s->block[i], i, val, mquant,
                                           (i & 4) ? v->codingset2 : v->codingset);
                    if ((i > 3) && (s->avctx->flags & CODEC_FLAG_GRAY))
                        continue;
                    v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
                    if (v->rangeredfrm)
                        for (j = 0; j < 64; j++)
                            s->block[i][j] <<= 1;
                    s->idsp.put_signed_pixels_clamped(s->block[i],
                                                      s->dest[dst_idx] + off,
                                                      i & 4 ? s->uvlinesize
                                                            : s->linesize);
                    if (v->pq >= 9 && v->overlap) {
                        if (v->c_avail)
                            v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
                        if (v->a_avail)
                            v->vc1dsp.vc1_v_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
                    }
                    block_cbp   |= 0xF << (i << 2);
                    block_intra |= 1 << i;
                } else if (val) {
                    pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block,
                                             s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize,
                                             (i & 4) && (s->avctx->flags & CODEC_FLAG_GRAY), &block_tt);
                    block_cbp |= pat << (i << 2);
                    if (!v->ttmbf && ttmb < 8)
                        ttmb = -1;
                    first_block = 0;
                }
            }
        } else {
            s->mb_intra = 0;
            for (i = 0; i < 6; i++) {
                v->mb_type[0][s->block_index[i]] = 0;
                s->dc_val[0][s->block_index[i]]  = 0;
            }
            s->current_picture.mb_type[mb_pos]      = MB_TYPE_SKIP;
            s->current_picture.qscale_table[mb_pos] = 0;
            ff_vc1_pred_mv(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0], 0, 0);
            ff_vc1_mc_1mv(v, 0);
        }
    } else {
        if (!skipped  ) {
            int intra_count = 0, coded_inter = 0;
            int is_intra[6], is_coded[6];
            cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
            for (i = 0; i < 6; i++) {
                val = ((cbp >> (5 - i)) & 1);
                s->dc_val[0][s->block_index[i]] = 0;
                s->mb_intra                     = 0;
                if (i < 4) {
                    dmv_x = dmv_y = 0;
                    s->mb_intra   = 0;
                    mb_has_coeffs = 0;
                    if (val) {
                        GET_MVDATA(dmv_x, dmv_y);
                    }
                    ff_vc1_pred_mv(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0], 0, 0);
                    if (!s->mb_intra)
                        ff_vc1_mc_4mv_luma(v, i, 0, 0);
                    intra_count += s->mb_intra;
                    is_intra[i]  = s->mb_intra;
                    is_coded[i]  = mb_has_coeffs;
                }
                if (i & 4) {
                    is_intra[i] = (intra_count >= 3);
                    is_coded[i] = val;
                }
                if (i == 4)
                    ff_vc1_mc_4mv_chroma(v, 0);
                v->mb_type[0][s->block_index[i]] = is_intra[i];
                if (!coded_inter)
                    coded_inter = !is_intra[i] & is_coded[i];
            }
            dst_idx = 0;
            if (!intra_count && !coded_inter)
                goto end;
            GET_MQUANT();
            s->current_picture.qscale_table[mb_pos] = mquant;
            {
                int intrapred = 0;
                for (i = 0; i < 6; i++)
                    if (is_intra[i]) {
                        if (((!s->first_slice_line || (i == 2 || i == 3)) && v->mb_type[0][s->block_index[i] - s->block_wrap[i]])
                            || ((s->mb_x || (i == 1 || i == 3)) && v->mb_type[0][s->block_index[i] - 1])) {
                            intrapred = 1;
                            break;
                        }
                    }
                if (intrapred)
                    s->ac_pred = get_bits1(gb);
                else
                    s->ac_pred = 0;
            }
            if (!v->ttmbf && coded_inter)
                ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
            for (i = 0; i < 6; i++) {
                dst_idx    += i >> 2;
                off         = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
                s->mb_intra = is_intra[i];
                if (is_intra[i]) {
                    v->a_avail = v->c_avail = 0;
                    if (i == 2 || i == 3 || !s->first_slice_line)
                        v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
                    if (i == 1 || i == 3 || s->mb_x)
                        v->c_avail = v->mb_type[0][s->block_index[i] - 1];
                    vc1_decode_intra_block(v, s->block[i], i, is_coded[i], mquant,
                                           (i & 4) ? v->codingset2 : v->codingset);
                    if ((i > 3) && (s->avctx->flags & CODEC_FLAG_GRAY))
                        continue;
                    v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
                    if (v->rangeredfrm)
                        for (j = 0; j < 64; j++)
                            s->block[i][j] <<= 1;
                    s->idsp.put_signed_pixels_clamped(s->block[i],
                                                      s->dest[dst_idx] + off,
                                                      (i & 4) ? s->uvlinesize
                                                              : s->linesize);
                    if (v->pq >= 9 && v->overlap) {
                        if (v->c_avail)
                            v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
                        if (v->a_avail)
                            v->vc1dsp.vc1_v_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
                    }
                    block_cbp   |= 0xF << (i << 2);
                    block_intra |= 1 << i;
                } else if (is_coded[i]) {
                    pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
                                             first_block, s->dest[dst_idx] + off,
                                             (i & 4) ? s->uvlinesize : s->linesize,
                                             (i & 4) && (s->avctx->flags & CODEC_FLAG_GRAY),
                                             &block_tt);
                    block_cbp |= pat << (i << 2);
                    if (!v->ttmbf && ttmb < 8)
                        ttmb = -1;
                    first_block = 0;
                }
            }
        } else {
            s->mb_intra                               = 0;
            s->current_picture.qscale_table[mb_pos] = 0;
            for (i = 0; i < 6; i++) {
                v->mb_type[0][s->block_index[i]] = 0;
                s->dc_val[0][s->block_index[i]]  = 0;
            }
            for (i = 0; i < 4; i++) {
                ff_vc1_pred_mv(v, i, 0, 0, 0, v->range_x, v->range_y, v->mb_type[0], 0, 0);
                ff_vc1_mc_4mv_luma(v, i, 0, 0);
            }
            ff_vc1_mc_4mv_chroma(v, 0);
            s->current_picture.qscale_table[mb_pos] = 0;
        }
    }
end:
    v->cbp[s->mb_x]      = block_cbp;
    v->ttblk[s->mb_x]    = block_tt;
    v->is_intra[s->mb_x] = block_intra;
    return 0;
}
['static int vc1_decode_p_mb(VC1Context *v)\n{\n    MpegEncContext *s = &v->s;\n    GetBitContext *gb = &s->gb;\n    int i, j;\n    int mb_pos = s->mb_x + s->mb_y * s->mb_stride;\n    int cbp;\n    int mqdiff, mquant;\n    int ttmb = v->ttfrm;\n    int mb_has_coeffs = 1;\n    int dmv_x, dmv_y;\n    int index, index1;\n    int val, sign;\n    int first_block = 1;\n    int dst_idx, off;\n    int skipped, fourmv;\n    int block_cbp = 0, pat, block_tt = 0, block_intra = 0;\n    mquant = v->pq;\n    if (v->mv_type_is_raw)\n        fourmv = get_bits1(gb);\n    else\n        fourmv = v->mv_type_mb_plane[mb_pos];\n    if (v->skip_is_raw)\n        skipped = get_bits1(gb);\n    else\n        skipped = v->s.mbskip_table[mb_pos];\n    if (!fourmv) {\n        if (!skipped) {\n            GET_MVDATA(dmv_x, dmv_y);\n            if (s->mb_intra) {\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            }\n            s->current_picture.mb_type[mb_pos] = s->mb_intra ? MB_TYPE_INTRA : MB_TYPE_16x16;\n            ff_vc1_pred_mv(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0], 0, 0);\n            if (s->mb_intra && !mb_has_coeffs) {\n                GET_MQUANT();\n                s->ac_pred = get_bits1(gb);\n                cbp        = 0;\n            } else if (mb_has_coeffs) {\n                if (s->mb_intra)\n                    s->ac_pred = get_bits1(gb);\n                cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);\n                GET_MQUANT();\n            } else {\n                mquant = v->pq;\n                cbp    = 0;\n            }\n            s->current_picture.qscale_table[mb_pos] = mquant;\n            if (!v->ttmbf && !s->mb_intra && mb_has_coeffs)\n                ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table,\n                                VC1_TTMB_VLC_BITS, 2);\n            if (!s->mb_intra) ff_vc1_mc_1mv(v, 0);\n            dst_idx = 0;\n            for (i = 0; i < 6; i++) {\n                s->dc_val[0][s->block_index[i]] = 0;\n                dst_idx += i >> 2;\n                val = ((cbp >> (5 - i)) & 1);\n                off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);\n                v->mb_type[0][s->block_index[i]] = s->mb_intra;\n                if (s->mb_intra) {\n                    v->a_avail = v->c_avail = 0;\n                    if (i == 2 || i == 3 || !s->first_slice_line)\n                        v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];\n                    if (i == 1 || i == 3 || s->mb_x)\n                        v->c_avail = v->mb_type[0][s->block_index[i] - 1];\n                    vc1_decode_intra_block(v, s->block[i], i, val, mquant,\n                                           (i & 4) ? v->codingset2 : v->codingset);\n                    if ((i > 3) && (s->avctx->flags & CODEC_FLAG_GRAY))\n                        continue;\n                    v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);\n                    if (v->rangeredfrm)\n                        for (j = 0; j < 64; j++)\n                            s->block[i][j] <<= 1;\n                    s->idsp.put_signed_pixels_clamped(s->block[i],\n                                                      s->dest[dst_idx] + off,\n                                                      i & 4 ? s->uvlinesize\n                                                            : s->linesize);\n                    if (v->pq >= 9 && v->overlap) {\n                        if (v->c_avail)\n                            v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);\n                        if (v->a_avail)\n                            v->vc1dsp.vc1_v_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);\n                    }\n                    block_cbp   |= 0xF << (i << 2);\n                    block_intra |= 1 << i;\n                } else if (val) {\n                    pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block,\n                                             s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize,\n                                             (i & 4) && (s->avctx->flags & CODEC_FLAG_GRAY), &block_tt);\n                    block_cbp |= pat << (i << 2);\n                    if (!v->ttmbf && ttmb < 8)\n                        ttmb = -1;\n                    first_block = 0;\n                }\n            }\n        } else {\n            s->mb_intra = 0;\n            for (i = 0; i < 6; i++) {\n                v->mb_type[0][s->block_index[i]] = 0;\n                s->dc_val[0][s->block_index[i]]  = 0;\n            }\n            s->current_picture.mb_type[mb_pos]      = MB_TYPE_SKIP;\n            s->current_picture.qscale_table[mb_pos] = 0;\n            ff_vc1_pred_mv(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0], 0, 0);\n            ff_vc1_mc_1mv(v, 0);\n        }\n    } else {\n        if (!skipped  ) {\n            int intra_count = 0, coded_inter = 0;\n            int is_intra[6], is_coded[6];\n            cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);\n            for (i = 0; i < 6; i++) {\n                val = ((cbp >> (5 - i)) & 1);\n                s->dc_val[0][s->block_index[i]] = 0;\n                s->mb_intra                     = 0;\n                if (i < 4) {\n                    dmv_x = dmv_y = 0;\n                    s->mb_intra   = 0;\n                    mb_has_coeffs = 0;\n                    if (val) {\n                        GET_MVDATA(dmv_x, dmv_y);\n                    }\n                    ff_vc1_pred_mv(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0], 0, 0);\n                    if (!s->mb_intra)\n                        ff_vc1_mc_4mv_luma(v, i, 0, 0);\n                    intra_count += s->mb_intra;\n                    is_intra[i]  = s->mb_intra;\n                    is_coded[i]  = mb_has_coeffs;\n                }\n                if (i & 4) {\n                    is_intra[i] = (intra_count >= 3);\n                    is_coded[i] = val;\n                }\n                if (i == 4)\n                    ff_vc1_mc_4mv_chroma(v, 0);\n                v->mb_type[0][s->block_index[i]] = is_intra[i];\n                if (!coded_inter)\n                    coded_inter = !is_intra[i] & is_coded[i];\n            }\n            dst_idx = 0;\n            if (!intra_count && !coded_inter)\n                goto end;\n            GET_MQUANT();\n            s->current_picture.qscale_table[mb_pos] = mquant;\n            {\n                int intrapred = 0;\n                for (i = 0; i < 6; i++)\n                    if (is_intra[i]) {\n                        if (((!s->first_slice_line || (i == 2 || i == 3)) && v->mb_type[0][s->block_index[i] - s->block_wrap[i]])\n                            || ((s->mb_x || (i == 1 || i == 3)) && v->mb_type[0][s->block_index[i] - 1])) {\n                            intrapred = 1;\n                            break;\n                        }\n                    }\n                if (intrapred)\n                    s->ac_pred = get_bits1(gb);\n                else\n                    s->ac_pred = 0;\n            }\n            if (!v->ttmbf && coded_inter)\n                ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);\n            for (i = 0; i < 6; i++) {\n                dst_idx    += i >> 2;\n                off         = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);\n                s->mb_intra = is_intra[i];\n                if (is_intra[i]) {\n                    v->a_avail = v->c_avail = 0;\n                    if (i == 2 || i == 3 || !s->first_slice_line)\n                        v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];\n                    if (i == 1 || i == 3 || s->mb_x)\n                        v->c_avail = v->mb_type[0][s->block_index[i] - 1];\n                    vc1_decode_intra_block(v, s->block[i], i, is_coded[i], mquant,\n                                           (i & 4) ? v->codingset2 : v->codingset);\n                    if ((i > 3) && (s->avctx->flags & CODEC_FLAG_GRAY))\n                        continue;\n                    v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);\n                    if (v->rangeredfrm)\n                        for (j = 0; j < 64; j++)\n                            s->block[i][j] <<= 1;\n                    s->idsp.put_signed_pixels_clamped(s->block[i],\n                                                      s->dest[dst_idx] + off,\n                                                      (i & 4) ? s->uvlinesize\n                                                              : s->linesize);\n                    if (v->pq >= 9 && v->overlap) {\n                        if (v->c_avail)\n                            v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);\n                        if (v->a_avail)\n                            v->vc1dsp.vc1_v_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);\n                    }\n                    block_cbp   |= 0xF << (i << 2);\n                    block_intra |= 1 << i;\n                } else if (is_coded[i]) {\n                    pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,\n                                             first_block, s->dest[dst_idx] + off,\n                                             (i & 4) ? s->uvlinesize : s->linesize,\n                                             (i & 4) && (s->avctx->flags & CODEC_FLAG_GRAY),\n                                             &block_tt);\n                    block_cbp |= pat << (i << 2);\n                    if (!v->ttmbf && ttmb < 8)\n                        ttmb = -1;\n                    first_block = 0;\n                }\n            }\n        } else {\n            s->mb_intra                               = 0;\n            s->current_picture.qscale_table[mb_pos] = 0;\n            for (i = 0; i < 6; i++) {\n                v->mb_type[0][s->block_index[i]] = 0;\n                s->dc_val[0][s->block_index[i]]  = 0;\n            }\n            for (i = 0; i < 4; i++) {\n                ff_vc1_pred_mv(v, i, 0, 0, 0, v->range_x, v->range_y, v->mb_type[0], 0, 0);\n                ff_vc1_mc_4mv_luma(v, i, 0, 0);\n            }\n            ff_vc1_mc_4mv_chroma(v, 0);\n            s->current_picture.qscale_table[mb_pos] = 0;\n        }\n    }\nend:\n    v->cbp[s->mb_x]      = block_cbp;\n    v->ttblk[s->mb_x]    = block_tt;\n    v->is_intra[s->mb_x] = block_intra;\n    return 0;\n}', 'static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n,\n                                  int coded, int mquant, int codingset)\n{\n    GetBitContext *gb = &v->s.gb;\n    MpegEncContext *s = &v->s;\n    int dc_pred_dir = 0;\n    int i;\n    int16_t *dc_val;\n    int16_t *ac_val, *ac_val2;\n    int dcdiff;\n    int mb_pos = s->mb_x + s->mb_y * s->mb_stride;\n    int a_avail = v->a_avail, c_avail = v->c_avail;\n    int use_pred = s->ac_pred;\n    int scale;\n    int q1, q2 = 0;\n    s->bdsp.clear_block(block);\n    mquant = (mquant < 1) ? 0 : ((mquant > 31) ? 31 : mquant);\n    s->y_dc_scale = s->y_dc_scale_table[mquant];\n    s->c_dc_scale = s->c_dc_scale_table[mquant];\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        if (dcdiff == 119  ) {\n            if (mquant == 1)      dcdiff = get_bits(gb, 10);\n            else if (mquant == 2) dcdiff = get_bits(gb, 9);\n            else                  dcdiff = get_bits(gb, 8);\n        } else {\n            if (mquant == 1)\n                dcdiff = (dcdiff << 2) + get_bits(gb, 2) - 3;\n            else if (mquant == 2)\n                dcdiff = (dcdiff << 1) + get_bits1(gb)   - 1;\n        }\n        if (get_bits1(gb))\n            dcdiff = -dcdiff;\n    }\n    dcdiff += ff_vc1_pred_dc(&v->s, v->overlap, mquant, n, a_avail, c_avail, &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    i = 1;\n    if (!a_avail) dc_pred_dir = 1;\n    if (!c_avail) dc_pred_dir = 0;\n    if (!a_avail && !c_avail) use_pred = 0;\n    ac_val = s->ac_val[0][0] + s->block_index[n] * 16;\n    ac_val2 = ac_val;\n    scale = mquant * 2 + v->halfpq;\n    if (dc_pred_dir)\n        ac_val -= 16;\n    else\n        ac_val -= 16 * s->block_wrap[n];\n    q1 = s->current_picture.qscale_table[mb_pos];\n    if (dc_pred_dir && c_avail && mb_pos)\n        q2 = s->current_picture.qscale_table[mb_pos - 1];\n    if (!dc_pred_dir && a_avail && mb_pos >= s->mb_stride)\n        q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];\n    if ( dc_pred_dir && n == 1)\n        q2 = q1;\n    if (!dc_pred_dir && n == 2)\n        q2 = q1;\n    if (n == 3) q2 = q1;\n    if (coded) {\n        int last = 0, skip, value;\n        int k;\n        while (!last) {\n            vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);\n            i += skip;\n            if (i > 63)\n                break;\n            if (v->fcm == PROGRESSIVE)\n                block[v->zz_8x8[0][i++]] = value;\n            else {\n                if (use_pred && (v->fcm == ILACE_FRAME)) {\n                    if (!dc_pred_dir)\n                        block[v->zz_8x8[2][i++]] = value;\n                    else\n                        block[v->zz_8x8[3][i++]] = value;\n                } else {\n                    block[v->zzi_8x8[i++]] = value;\n                }\n            }\n        }\n        if (use_pred) {\n            if (q2 && q1 != q2) {\n                q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;\n                q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;\n                if (q1 < 1)\n                    return AVERROR_INVALIDDATA;\n                if (dc_pred_dir) {\n                    for (k = 1; k < 8; k++)\n                        block[k << v->left_blk_sh] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;\n                } else {\n                    for (k = 1; k < 8; k++)\n                        block[k << v->top_blk_sh] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;\n                }\n            } else {\n                if (dc_pred_dir) {\n                    for (k = 1; k < 8; k++)\n                        block[k << v->left_blk_sh] += ac_val[k];\n                } else {\n                    for (k = 1; k < 8; k++)\n                        block[k << v->top_blk_sh] += ac_val[k + 8];\n                }\n            }\n        }\n        for (k = 1; k < 8; k++) {\n            ac_val2[k    ] = block[k << v->left_blk_sh];\n            ac_val2[k + 8] = block[k << v->top_blk_sh];\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) ? -mquant : mquant;\n            }\n        if (use_pred) i = 63;\n    } else {\n        int k;\n        memset(ac_val2, 0, 16 * 2);\n        if (dc_pred_dir) {\n            if (use_pred) {\n                memcpy(ac_val2, ac_val, 8 * 2);\n                if (q2 && q1 != q2) {\n                    q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;\n                    q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;\n                    if (q1 < 1)\n                        return AVERROR_INVALIDDATA;\n                    for (k = 1; k < 8; k++)\n                        ac_val2[k] = (ac_val2[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;\n                }\n            }\n        } else {\n            if (use_pred) {\n                memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);\n                if (q2 && q1 != q2) {\n                    q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;\n                    q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;\n                    if (q1 < 1)\n                        return AVERROR_INVALIDDATA;\n                    for (k = 1; k < 8; k++)\n                        ac_val2[k + 8] = (ac_val2[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;\n                }\n            }\n        }\n        if (use_pred) {\n            if (dc_pred_dir) {\n                for (k = 1; k < 8; k++) {\n                    block[k << v->left_blk_sh] = ac_val2[k] * scale;\n                    if (!v->pquantizer && block[k << v->left_blk_sh])\n                        block[k << v->left_blk_sh] += (block[k << v->left_blk_sh] < 0) ? -mquant : mquant;\n                }\n            } else {\n                for (k = 1; k < 8; k++) {\n                    block[k << v->top_blk_sh] = ac_val2[k + 8] * scale;\n                    if (!v->pquantizer && block[k << v->top_blk_sh])\n                        block[k << v->top_blk_sh] += (block[k << v->top_blk_sh] < 0) ? -mquant : mquant;\n                }\n            }\n            i = 63;\n        }\n    }\n    s->block_last_index[n] = i;\n    return 0;\n}']