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

libavcodec/vc1dec.c:4257:36: <Offset trace>
4255.             if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;
4256.             v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
4257.             if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1;
                                         ^
4258.             off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
4259.             off += v->cur_field_type ? ((i & 4) ? s->current_picture_ptr->f.linesize[1] : s->current_picture_ptr->f.linesize[0]) : 0;

libavcodec/vc1dec.c:4257:36: Assignment
4255.             if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;
4256.             v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
4257.             if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1;
                                         ^
4258.             off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
4259.             off += v->cur_field_type ? ((i & 4) ? s->current_picture_ptr->f.linesize[1] : s->current_picture_ptr->f.linesize[0]) : 0;

libavcodec/vc1dec.c:4254:13: <Length trace>
4252.                 v->c_avail = v->mb_type[0][s->block_index[i] - 1];
4253. 
4254.             vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i&4)?v->codingset2:v->codingset);
                  ^
4255.             if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;
4256.             v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);

libavcodec/vc1dec.c:4254:13: Call
4252.                 v->c_avail = v->mb_type[0][s->block_index[i] - 1];
4253. 
4254.             vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i&4)?v->codingset2:v->codingset);
                  ^
4255.             if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;
4256.             v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);

libavcodec/vc1dec.c:2998:1: Parameter `*block`
  2996.  * @param codingset set of VLC to decode data
  2997.  */
  2998. static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int coded, int mquant, int codingset)
        ^
  2999. {
  3000.     GetBitContext *gb = &v->s.gb;

libavcodec/vc1dec.c:4257:56: Array access: Offset: [0, 63] Size: 2
4255.             if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;
4256.             v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
4257.             if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1;
                                                             ^
4258.             off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
4259.             off += v->cur_field_type ? ((i & 4) ? s->current_picture_ptr->f.linesize[1] : s->current_picture_ptr->f.linesize[0]) : 0;

static void vc1_decode_b_mb_intfi(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 = 0;
    int mqdiff, mquant;
    int ttmb = v->ttfrm;
    int mb_has_coeffs = 0;
    int val;
    int first_block = 1;
    int dst_idx, off;
    int fwd;
    int dmv_x[2], dmv_y[2], pred_flag[2];
    int bmvtype = BMV_TYPE_BACKWARD;
    int idx_mbmode, interpmvp;
    mquant = v->pq;
    s->mb_intra = 0;
    idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_IF_MBMODE_VLC_BITS, 2);
    if (idx_mbmode <= 1) {
        s->mb_intra = v->is_intra[s->mb_x] = 1;
        s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0;
        s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0;
        s->current_picture.f.mb_type[mb_pos + v->mb_off] = MB_TYPE_INTRA;
        GET_MQUANT();
        s->current_picture.f.qscale_table[mb_pos] = mquant;
        s->y_dc_scale = s->y_dc_scale_table[mquant];
        s->c_dc_scale = s->c_dc_scale_table[mquant];
        v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
        mb_has_coeffs = idx_mbmode & 1;
        if (mb_has_coeffs)
            cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_ICBPCY_VLC_BITS, 2);
        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);
            v->mb_type[0][s->block_index[i]] = 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->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;
            off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
            off += v->cur_field_type ? ((i & 4) ? s->current_picture_ptr->f.linesize[1] : s->current_picture_ptr->f.linesize[0]) : 0;
            s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize);
        }
    } else {
        s->mb_intra = v->is_intra[s->mb_x] = 0;
        s->current_picture.f.mb_type[mb_pos + v->mb_off] = MB_TYPE_16x16;
        for (i = 0; i < 6; i++) v->mb_type[0][s->block_index[i]] = 0;
        if (v->fmb_is_raw)
            fwd = v->forward_mb_plane[mb_pos] = get_bits1(gb);
        else
            fwd = v->forward_mb_plane[mb_pos];
        if (idx_mbmode <= 5) {
            dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
            pred_flag[0] = pred_flag[1] = 0;
            if (fwd)
                bmvtype = BMV_TYPE_FORWARD;
            else {
                bmvtype = decode012(gb);
                switch(bmvtype) {
                case 0:
                    bmvtype = BMV_TYPE_BACKWARD;
                    break;
                case 1:
                    bmvtype = BMV_TYPE_DIRECT;
                    break;
                case 2:
                    bmvtype = BMV_TYPE_INTERPOLATED;
                    interpmvp = get_bits1(gb);
                }
            }
            v->bmvtype = bmvtype;
            if (bmvtype != BMV_TYPE_DIRECT && idx_mbmode & 1) {
                get_mvdata_interlaced(v, &dmv_x[bmvtype == BMV_TYPE_BACKWARD], &dmv_y[bmvtype == BMV_TYPE_BACKWARD], &pred_flag[bmvtype == BMV_TYPE_BACKWARD]);
            }
            if (bmvtype == BMV_TYPE_INTERPOLATED && interpmvp) {
                get_mvdata_interlaced(v, &dmv_x[1], &dmv_y[1], &pred_flag[1]);
            }
            if (bmvtype == BMV_TYPE_DIRECT) {
                dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
                dmv_x[1] = dmv_y[1] = pred_flag[0] = 0;
            }
            vc1_pred_b_mv_intfi(v, 0, dmv_x, dmv_y, 1, pred_flag);
            vc1_b_mc(v, dmv_x, dmv_y, (bmvtype == BMV_TYPE_DIRECT), bmvtype);
            mb_has_coeffs = !(idx_mbmode & 2);
        } else {
            if (fwd)
                bmvtype = BMV_TYPE_FORWARD;
            v->bmvtype = bmvtype;
            v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
            for (i=0; i<6; i++) {
                if (i < 4) {
                    dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
                    dmv_x[1] = dmv_y[1] = pred_flag[1] = 0;
                    val = ((v->fourmvbp >> (3 - i)) & 1);
                    if(val) {
                        get_mvdata_interlaced(v, &dmv_x[bmvtype == BMV_TYPE_BACKWARD], &dmv_y[bmvtype == BMV_TYPE_BACKWARD], &pred_flag[bmvtype == BMV_TYPE_BACKWARD]);
                    }
                    vc1_pred_b_mv_intfi(v, i, dmv_x, dmv_y, 0, pred_flag);
                    vc1_mc_4mv_luma(v, i, bmvtype == BMV_TYPE_BACKWARD);
                } else if (i == 4)
                    vc1_mc_4mv_chroma(v, bmvtype == BMV_TYPE_BACKWARD);
            }
            mb_has_coeffs = idx_mbmode & 1;
        }
        if (mb_has_coeffs)
            cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
        if (cbp) {
            GET_MQUANT();
        }
        s->current_picture.f.qscale_table[mb_pos] = mquant;
        if (!v->ttmbf && cbp) {
            ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
        }
        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;
            if (v->cur_field_type)
                off += (i & 4) ? s->current_picture_ptr->f.linesize[1] : s->current_picture_ptr->f.linesize[0];
            if(val) {
                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->flags & CODEC_FLAG_GRAY), NULL);
                if(!v->ttmbf && ttmb < 8)
                    ttmb = -1;
                first_block = 0;
            }
        }
    }
}
['static void vc1_decode_b_mb_intfi(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 = 0;\n    int mqdiff, mquant;\n    int ttmb = v->ttfrm;\n    int mb_has_coeffs = 0;\n    int val;\n    int first_block = 1;\n    int dst_idx, off;\n    int fwd;\n    int dmv_x[2], dmv_y[2], pred_flag[2];\n    int bmvtype = BMV_TYPE_BACKWARD;\n    int idx_mbmode, interpmvp;\n    mquant = v->pq;\n    s->mb_intra = 0;\n    idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_IF_MBMODE_VLC_BITS, 2);\n    if (idx_mbmode <= 1) {\n        s->mb_intra = v->is_intra[s->mb_x] = 1;\n        s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0;\n        s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0;\n        s->current_picture.f.mb_type[mb_pos + v->mb_off] = MB_TYPE_INTRA;\n        GET_MQUANT();\n        s->current_picture.f.qscale_table[mb_pos] = mquant;\n        s->y_dc_scale = s->y_dc_scale_table[mquant];\n        s->c_dc_scale = s->c_dc_scale_table[mquant];\n        v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);\n        mb_has_coeffs = idx_mbmode & 1;\n        if (mb_has_coeffs)\n            cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_ICBPCY_VLC_BITS, 2);\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            v->mb_type[0][s->block_index[i]] = 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, (i&4)?v->codingset2:v->codingset);\n            if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;\n            v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);\n            if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1;\n            off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);\n            off += v->cur_field_type ? ((i & 4) ? s->current_picture_ptr->f.linesize[1] : s->current_picture_ptr->f.linesize[0]) : 0;\n            s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize);\n        }\n    } else {\n        s->mb_intra = v->is_intra[s->mb_x] = 0;\n        s->current_picture.f.mb_type[mb_pos + v->mb_off] = MB_TYPE_16x16;\n        for (i = 0; i < 6; i++) v->mb_type[0][s->block_index[i]] = 0;\n        if (v->fmb_is_raw)\n            fwd = v->forward_mb_plane[mb_pos] = get_bits1(gb);\n        else\n            fwd = v->forward_mb_plane[mb_pos];\n        if (idx_mbmode <= 5) {\n            dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;\n            pred_flag[0] = pred_flag[1] = 0;\n            if (fwd)\n                bmvtype = BMV_TYPE_FORWARD;\n            else {\n                bmvtype = decode012(gb);\n                switch(bmvtype) {\n                case 0:\n                    bmvtype = BMV_TYPE_BACKWARD;\n                    break;\n                case 1:\n                    bmvtype = BMV_TYPE_DIRECT;\n                    break;\n                case 2:\n                    bmvtype = BMV_TYPE_INTERPOLATED;\n                    interpmvp = get_bits1(gb);\n                }\n            }\n            v->bmvtype = bmvtype;\n            if (bmvtype != BMV_TYPE_DIRECT && idx_mbmode & 1) {\n                get_mvdata_interlaced(v, &dmv_x[bmvtype == BMV_TYPE_BACKWARD], &dmv_y[bmvtype == BMV_TYPE_BACKWARD], &pred_flag[bmvtype == BMV_TYPE_BACKWARD]);\n            }\n            if (bmvtype == BMV_TYPE_INTERPOLATED && interpmvp) {\n                get_mvdata_interlaced(v, &dmv_x[1], &dmv_y[1], &pred_flag[1]);\n            }\n            if (bmvtype == BMV_TYPE_DIRECT) {\n                dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;\n                dmv_x[1] = dmv_y[1] = pred_flag[0] = 0;\n            }\n            vc1_pred_b_mv_intfi(v, 0, dmv_x, dmv_y, 1, pred_flag);\n            vc1_b_mc(v, dmv_x, dmv_y, (bmvtype == BMV_TYPE_DIRECT), bmvtype);\n            mb_has_coeffs = !(idx_mbmode & 2);\n        } else {\n            if (fwd)\n                bmvtype = BMV_TYPE_FORWARD;\n            v->bmvtype = bmvtype;\n            v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);\n            for (i=0; i<6; i++) {\n                if (i < 4) {\n                    dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;\n                    dmv_x[1] = dmv_y[1] = pred_flag[1] = 0;\n                    val = ((v->fourmvbp >> (3 - i)) & 1);\n                    if(val) {\n                        get_mvdata_interlaced(v, &dmv_x[bmvtype == BMV_TYPE_BACKWARD], &dmv_y[bmvtype == BMV_TYPE_BACKWARD], &pred_flag[bmvtype == BMV_TYPE_BACKWARD]);\n                    }\n                    vc1_pred_b_mv_intfi(v, i, dmv_x, dmv_y, 0, pred_flag);\n                    vc1_mc_4mv_luma(v, i, bmvtype == BMV_TYPE_BACKWARD);\n                } else if (i == 4)\n                    vc1_mc_4mv_chroma(v, bmvtype == BMV_TYPE_BACKWARD);\n            }\n            mb_has_coeffs = idx_mbmode & 1;\n        }\n        if (mb_has_coeffs)\n            cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);\n        if (cbp) {\n            GET_MQUANT();\n        }\n        s->current_picture.f.qscale_table[mb_pos] = mquant;\n        if (!v->ttmbf && cbp) {\n            ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);\n        }\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            if (v->cur_field_type)\n                off += (i & 4) ? s->current_picture_ptr->f.linesize[1] : s->current_picture_ptr->f.linesize[0];\n            if(val) {\n                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->flags & CODEC_FLAG_GRAY), NULL);\n                if(!v->ttmbf && ttmb < 8)\n                    ttmb = -1;\n                first_block = 0;\n            }\n        }\n    }\n}', 'static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int 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->dsp.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    {\n        if (dcdiff == 119  )\n        {\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        }\n        else\n        {\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 += 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.f.qscale_table[mb_pos];\n    if(dc_pred_dir && c_avail && mb_pos) q2 = s->current_picture.f.qscale_table[mb_pos - 1];\n    if(!dc_pred_dir && a_avail && mb_pos >= s->mb_stride) q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride];\n    if(dc_pred_dir && n==1) q2 = q1;\n    if(!dc_pred_dir && n==2) 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 == 0)\n                block[v->zz_8x8[0][i++]] = value;\n            else {\n                if(use_pred && (v->fcm == 1)) {\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(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                    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                    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}']