libavcodec/svq3.c:1038: error: Buffer Overrun L2
  Offset: [-oo, max(10, `avctx->priv_data->intra16x16_pred_mode`)] Size: 9 by call to `ff_h264_hl_decode_mb`.

libavcodec/svq3.c:914:1: Parameter `avctx->priv_data->intra16x16_pred_mode`
912. }
913. 
914. static int svq3_decode_frame(AVCodecContext *avctx,
     ^
915.                              void *data, int *data_size,
916.                              AVPacket *avpkt)

libavcodec/svq3.c:1032:33: Call
1030.                 mb_type += 4;
1031.             }
1032.             if (mb_type > 33 || svq3_decode_mb(h, mb_type)) {
                                      ^
1033.                 av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
1034.                 return -1;

libavcodec/svq3.c:430:1: Parameter `h->intra16x16_pred_mode`
  428. }
  429. 
  430. static int svq3_decode_mb(H264Context *h, unsigned int mb_type)
       ^
  431. {
  432.     int i, j, k, m, dir, mode;

libavcodec/svq3.c:1038:17: Call
1036. 
1037.             if (mb_type != 0) {
1038.                 ff_h264_hl_decode_mb (h);
                      ^
1039.             }
1040. 

libavcodec/h264.c:1355:1: Parameter `h->intra16x16_pred_mode`
  1353. }
  1354. 
  1355. void ff_h264_hl_decode_mb(H264Context *h){
        ^
  1356.     MpegEncContext * const s = &h->s;
  1357.     const int mb_xy= h->mb_xy;

libavcodec/h264.c:1362:9: Call
  1360. 
  1361.     if (is_complex)
  1362.         hl_decode_mb_complex(h);
                ^
  1363.     else hl_decode_mb_simple(h);
  1364. }

libavcodec/h264.c:1351:1: Parameter `h->intra16x16_pred_mode`
    1349.  * Process a macroblock; this handles edge cases, such as interlacing.
    1350.  */
    1351. static void av_noinline hl_decode_mb_complex(H264Context *h){
          ^
    1352.     hl_decode_mb_internal(h, 0);
    1353. }

libavcodec/h264.c:1352:5: Call
    1350.  */
    1351. static void av_noinline hl_decode_mb_complex(H264Context *h){
    1352.     hl_decode_mb_internal(h, 0);
              ^
    1353. }
    1354. 

libavcodec/h264.c:1101:1: <Offset trace>
1099. }
1100. 
1101. static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple){
      ^
1102.     MpegEncContext * const s = &h->s;
1103.     const int mb_x= s->mb_x;

libavcodec/h264.c:1101:1: Parameter `h->intra16x16_pred_mode`
      1099. }
      1100. 
      1101. static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple){
            ^
      1102.     MpegEncContext * const s = &h->s;
      1103.     const int mb_x= s->mb_x;

libavcodec/h264.c:1101:1: <Length trace>
1099. }
1100. 
1101. static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple){
      ^
1102.     MpegEncContext * const s = &h->s;
1103.     const int mb_x= s->mb_x;

libavcodec/h264.c:1101:1: Parameter `h->hpc.pred16x16[*]`
      1099. }
      1100. 
      1101. static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple){
            ^
      1102.     MpegEncContext * const s = &h->s;
      1103.     const int mb_x= s->mb_x;

libavcodec/h264.c:1247:17: Array access: Offset: [-oo, max(10, avctx->priv_data->intra16x16_pred_mode)] Size: 9 by call to `ff_h264_hl_decode_mb` 
      1245.                 }
      1246.             }else{
      1247.                 h->hpc.pred16x16[ h->intra16x16_pred_mode ](dest_y , linesize);
                            ^
      1248.                 if(is_h264){
      1249.                     if(!transform_bypass)

static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple){
    MpegEncContext * const s = &h->s;
    const int mb_x= s->mb_x;
    const int mb_y= s->mb_y;
    const int mb_xy= h->mb_xy;
    const int mb_type= s->current_picture.mb_type[mb_xy];
    uint8_t  *dest_y, *dest_cb, *dest_cr;
    int linesize, uvlinesize  ;
    int i;
    int *block_offset = &h->block_offset[0];
    const int transform_bypass = !simple && (s->qscale == 0 && h->sps.transform_bypass);
    const int is_h264 = !CONFIG_SVQ3_DECODER || simple || s->codec_id == CODEC_ID_H264;
    void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride);
    void (*idct_dc_add)(uint8_t *dst, DCTELEM *block, int stride);
    dest_y  = s->current_picture.data[0] + (mb_x + mb_y * s->linesize  ) * 16;
    dest_cb = s->current_picture.data[1] + (mb_x + mb_y * s->uvlinesize) * 8;
    dest_cr = s->current_picture.data[2] + (mb_x + mb_y * s->uvlinesize) * 8;
    s->dsp.prefetch(dest_y + (s->mb_x&3)*4*s->linesize + 64, s->linesize, 4);
    s->dsp.prefetch(dest_cb + (s->mb_x&7)*s->uvlinesize + 64, dest_cr - dest_cb, 2);
    h->list_counts[mb_xy]= h->list_count;
    if (!simple && MB_FIELD) {
        linesize   = h->mb_linesize   = s->linesize * 2;
        uvlinesize = h->mb_uvlinesize = s->uvlinesize * 2;
        block_offset = &h->block_offset[24];
        if(mb_y&1){
            dest_y -= s->linesize*15;
            dest_cb-= s->uvlinesize*7;
            dest_cr-= s->uvlinesize*7;
        }
        if(FRAME_MBAFF) {
            int list;
            for(list=0; list<h->list_count; list++){
                if(!USES_LIST(mb_type, list))
                    continue;
                if(IS_16X16(mb_type)){
                    int8_t *ref = &h->ref_cache[list][scan8[0]];
                    fill_rectangle(ref, 4, 4, 8, (16+*ref)^(s->mb_y&1), 1);
                }else{
                    for(i=0; i<16; i+=4){
                        int ref = h->ref_cache[list][scan8[i]];
                        if(ref >= 0)
                            fill_rectangle(&h->ref_cache[list][scan8[i]], 2, 2, 8, (16+ref)^(s->mb_y&1), 1);
                    }
                }
            }
        }
    } else {
        linesize   = h->mb_linesize   = s->linesize;
        uvlinesize = h->mb_uvlinesize = s->uvlinesize;
    }
    if (!simple && IS_INTRA_PCM(mb_type)) {
        for (i=0; i<16; i++) {
            memcpy(dest_y + i*  linesize, h->mb       + i*8, 16);
        }
        for (i=0; i<8; i++) {
            memcpy(dest_cb+ i*uvlinesize, h->mb + 128 + i*4,  8);
            memcpy(dest_cr+ i*uvlinesize, h->mb + 160 + i*4,  8);
        }
    } else {
        if(IS_INTRA(mb_type)){
            if(h->deblocking_filter)
                xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 1, simple);
            if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
                h->hpc.pred8x8[ h->chroma_pred_mode ](dest_cb, uvlinesize);
                h->hpc.pred8x8[ h->chroma_pred_mode ](dest_cr, uvlinesize);
            }
            if(IS_INTRA4x4(mb_type)){
                if(simple || !s->encoding){
                    if(IS_8x8DCT(mb_type)){
                        if(transform_bypass){
                            idct_dc_add =
                            idct_add    = s->dsp.add_pixels8;
                        }else{
                            idct_dc_add = h->h264dsp.h264_idct8_dc_add;
                            idct_add    = h->h264dsp.h264_idct8_add;
                        }
                        for(i=0; i<16; i+=4){
                            uint8_t * const ptr= dest_y + block_offset[i];
                            const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ];
                            if(transform_bypass && h->sps.profile_idc==244 && dir<=1){
                                h->hpc.pred8x8l_add[dir](ptr, h->mb + i*16, linesize);
                            }else{
                                const int nnz = h->non_zero_count_cache[ scan8[i] ];
                                h->hpc.pred8x8l[ dir ](ptr, (h->topleft_samples_available<<i)&0x8000,
                                                            (h->topright_samples_available<<i)&0x4000, linesize);
                                if(nnz){
                                    if(nnz == 1 && h->mb[i*16])
                                        idct_dc_add(ptr, h->mb + i*16, linesize);
                                    else
                                        idct_add   (ptr, h->mb + i*16, linesize);
                                }
                            }
                        }
                    }else{
                        if(transform_bypass){
                            idct_dc_add =
                            idct_add    = s->dsp.add_pixels4;
                        }else{
                            idct_dc_add = h->h264dsp.h264_idct_dc_add;
                            idct_add    = h->h264dsp.h264_idct_add;
                        }
                        for(i=0; i<16; i++){
                            uint8_t * const ptr= dest_y + block_offset[i];
                            const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ];
                            if(transform_bypass && h->sps.profile_idc==244 && dir<=1){
                                h->hpc.pred4x4_add[dir](ptr, h->mb + i*16, linesize);
                            }else{
                                uint8_t *topright;
                                int nnz, tr;
                                if(dir == DIAG_DOWN_LEFT_PRED || dir == VERT_LEFT_PRED){
                                    const int topright_avail= (h->topright_samples_available<<i)&0x8000;
                                    assert(mb_y || linesize <= block_offset[i]);
                                    if(!topright_avail){
                                        tr= ptr[3 - linesize]*0x01010101;
                                        topright= (uint8_t*) &tr;
                                    }else
                                        topright= ptr + 4 - linesize;
                                }else
                                    topright= NULL;
                                h->hpc.pred4x4[ dir ](ptr, topright, linesize);
                                nnz = h->non_zero_count_cache[ scan8[i] ];
                                if(nnz){
                                    if(is_h264){
                                        if(nnz == 1 && h->mb[i*16])
                                            idct_dc_add(ptr, h->mb + i*16, linesize);
                                        else
                                            idct_add   (ptr, h->mb + i*16, linesize);
                                    }else
                                        ff_svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, 0);
                                }
                            }
                        }
                    }
                }
            }else{
                h->hpc.pred16x16[ h->intra16x16_pred_mode ](dest_y , linesize);
                if(is_h264){
                    if(!transform_bypass)
                        h264_luma_dc_dequant_idct_c(h->mb, s->qscale, h->dequant4_coeff[0][s->qscale][0]);
                }else
                    ff_svq3_luma_dc_dequant_idct_c(h->mb, s->qscale);
            }
            if(h->deblocking_filter)
                xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0, simple);
        }else if(is_h264){
            hl_motion(h, dest_y, dest_cb, dest_cr,
                      s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab,
                      s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab,
                      h->h264dsp.weight_h264_pixels_tab, h->h264dsp.biweight_h264_pixels_tab);
        }
        if(!IS_INTRA4x4(mb_type)){
            if(is_h264){
                if(IS_INTRA16x16(mb_type)){
                    if(transform_bypass){
                        if(h->sps.profile_idc==244 && (h->intra16x16_pred_mode==VERT_PRED8x8 || h->intra16x16_pred_mode==HOR_PRED8x8)){
                            h->hpc.pred16x16_add[h->intra16x16_pred_mode](dest_y, block_offset, h->mb, linesize);
                        }else{
                            for(i=0; i<16; i++){
                                if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16])
                                    s->dsp.add_pixels4(dest_y + block_offset[i], h->mb + i*16, linesize);
                            }
                        }
                    }else{
                         h->h264dsp.h264_idct_add16intra(dest_y, block_offset, h->mb, linesize, h->non_zero_count_cache);
                    }
                }else if(h->cbp&15){
                    if(transform_bypass){
                        const int di = IS_8x8DCT(mb_type) ? 4 : 1;
                        idct_add= IS_8x8DCT(mb_type) ? s->dsp.add_pixels8 : s->dsp.add_pixels4;
                        for(i=0; i<16; i+=di){
                            if(h->non_zero_count_cache[ scan8[i] ]){
                                idct_add(dest_y + block_offset[i], h->mb + i*16, linesize);
                            }
                        }
                    }else{
                        if(IS_8x8DCT(mb_type)){
                            h->h264dsp.h264_idct8_add4(dest_y, block_offset, h->mb, linesize, h->non_zero_count_cache);
                        }else{
                            h->h264dsp.h264_idct_add16(dest_y, block_offset, h->mb, linesize, h->non_zero_count_cache);
                        }
                    }
                }
            }else{
                for(i=0; i<16; i++){
                    if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){
                        uint8_t * const ptr= dest_y + block_offset[i];
                        ff_svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, IS_INTRA(mb_type) ? 1 : 0);
                    }
                }
            }
        }
        if((simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)) && (h->cbp&0x30)){
            uint8_t *dest[2] = {dest_cb, dest_cr};
            if(transform_bypass){
                if(IS_INTRA(mb_type) && h->sps.profile_idc==244 && (h->chroma_pred_mode==VERT_PRED8x8 || h->chroma_pred_mode==HOR_PRED8x8)){
                    h->hpc.pred8x8_add[h->chroma_pred_mode](dest[0], block_offset + 16, h->mb + 16*16, uvlinesize);
                    h->hpc.pred8x8_add[h->chroma_pred_mode](dest[1], block_offset + 20, h->mb + 20*16, uvlinesize);
                }else{
                    idct_add = s->dsp.add_pixels4;
                    for(i=16; i<16+8; i++){
                        if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16])
                            idct_add   (dest[(i&4)>>2] + block_offset[i], h->mb + i*16, uvlinesize);
                    }
                }
            }else{
                chroma_dc_dequant_idct_c(h->mb + 16*16, h->chroma_qp[0], h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]);
                chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->chroma_qp[1], h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]);
                if(is_h264){
                    h->h264dsp.h264_idct_add8(dest, block_offset,
                                              h->mb, uvlinesize,
                                              h->non_zero_count_cache);
                }else{
                    for(i=16; i<16+8; i++){
                        if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){
                            uint8_t * const ptr= dest[(i&4)>>2] + block_offset[i];
                            ff_svq3_add_idct_c(ptr, h->mb + i*16, uvlinesize, ff_h264_chroma_qp[s->qscale + 12] - 12, 2);
                        }
                    }
                }
            }
        }
    }
    if(h->cbp || IS_INTRA(mb_type))
        s->dsp.clear_blocks(h->mb);
}
['static int svq3_decode_frame(AVCodecContext *avctx,\n                             void *data, int *data_size,\n                             AVPacket *avpkt)\n{\n    const uint8_t *buf = avpkt->data;\n    int buf_size = avpkt->size;\n    MpegEncContext *const s = avctx->priv_data;\n    H264Context *const h = avctx->priv_data;\n    int m, mb_type;\n    if (buf_size == 0) {\n        if (s->next_picture_ptr && !s->low_delay) {\n            *(AVFrame *) data = *(AVFrame *) &s->next_picture;\n            s->next_picture_ptr = NULL;\n            *data_size = sizeof(AVFrame);\n        }\n        return 0;\n    }\n    init_get_bits (&s->gb, buf, 8*buf_size);\n    s->mb_x = s->mb_y = h->mb_xy = 0;\n    if (svq3_decode_slice_header(h))\n        return -1;\n    s->pict_type = h->slice_type;\n    s->picture_number = h->slice_num;\n    if (avctx->debug&FF_DEBUG_PICT_INFO){\n        av_log(h->s.avctx, AV_LOG_DEBUG, "%c hpel:%d, tpel:%d aqp:%d qp:%d, slice_num:%02X\\n",\n               av_get_pict_type_char(s->pict_type), h->halfpel_flag, h->thirdpel_flag,\n               s->adaptive_quant, s->qscale, h->slice_num);\n    }\n    s->current_picture.pict_type = s->pict_type;\n    s->current_picture.key_frame = (s->pict_type == FF_I_TYPE);\n    if (s->last_picture_ptr == NULL && s->pict_type == FF_B_TYPE)\n        return 0;\n    if (avctx->hurry_up && s->pict_type == FF_B_TYPE)\n        return 0;\n    if (avctx->hurry_up >= 5)\n        return 0;\n    if (  (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == FF_B_TYPE)\n        ||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != FF_I_TYPE)\n        || avctx->skip_frame >= AVDISCARD_ALL)\n        return 0;\n    if (s->next_p_frame_damaged) {\n        if (s->pict_type == FF_B_TYPE)\n            return 0;\n        else\n            s->next_p_frame_damaged = 0;\n    }\n    if (ff_h264_frame_start(h) < 0)\n        return -1;\n    if (s->pict_type == FF_B_TYPE) {\n        h->frame_num_offset = (h->slice_num - h->prev_frame_num);\n        if (h->frame_num_offset < 0) {\n            h->frame_num_offset += 256;\n        }\n        if (h->frame_num_offset == 0 || h->frame_num_offset >= h->prev_frame_num_offset) {\n            av_log(h->s.avctx, AV_LOG_ERROR, "error in B-frame picture id\\n");\n            return -1;\n        }\n    } else {\n        h->prev_frame_num = h->frame_num;\n        h->frame_num = h->slice_num;\n        h->prev_frame_num_offset = (h->frame_num - h->prev_frame_num);\n        if (h->prev_frame_num_offset < 0) {\n            h->prev_frame_num_offset += 256;\n        }\n    }\n    for (m = 0; m < 2; m++){\n        int i;\n        for (i = 0; i < 4; i++){\n            int j;\n            for (j = -1; j < 4; j++)\n                h->ref_cache[m][scan8[0] + 8*i + j]= 1;\n            if (i < 3)\n                h->ref_cache[m][scan8[0] + 8*i + j]= PART_NOT_AVAILABLE;\n        }\n    }\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            h->mb_xy = s->mb_x + s->mb_y*s->mb_stride;\n            if ( (get_bits_count(&s->gb) + 7) >= s->gb.size_in_bits &&\n                ((get_bits_count(&s->gb) & 7) == 0 || show_bits(&s->gb, (-get_bits_count(&s->gb) & 7)) == 0)) {\n                skip_bits(&s->gb, h->next_slice_index - get_bits_count(&s->gb));\n                s->gb.size_in_bits = 8*buf_size;\n                if (svq3_decode_slice_header(h))\n                    return -1;\n            }\n            mb_type = svq3_get_ue_golomb(&s->gb);\n            if (s->pict_type == FF_I_TYPE) {\n                mb_type += 8;\n            } else if (s->pict_type == FF_B_TYPE && mb_type >= 4) {\n                mb_type += 4;\n            }\n            if (mb_type > 33 || svq3_decode_mb(h, mb_type)) {\n                av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d\\n", s->mb_x, s->mb_y);\n                return -1;\n            }\n            if (mb_type != 0) {\n                ff_h264_hl_decode_mb (h);\n            }\n            if (s->pict_type != FF_B_TYPE && !s->low_delay) {\n                s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride] =\n                    (s->pict_type == FF_P_TYPE && mb_type < 8) ? (mb_type - 1) : -1;\n            }\n        }\n        ff_draw_horiz_band(s, 16*s->mb_y, 16);\n    }\n    MPV_frame_end(s);\n    if (s->pict_type == FF_B_TYPE || s->low_delay) {\n        *(AVFrame *) data = *(AVFrame *) &s->current_picture;\n    } else {\n        *(AVFrame *) data = *(AVFrame *) &s->last_picture;\n    }\n    if (s->last_picture_ptr || s->low_delay) {\n        *data_size = sizeof(AVFrame);\n    }\n    return buf_size;\n}', 'static int svq3_decode_mb(H264Context *h, unsigned int mb_type)\n{\n    int i, j, k, m, dir, mode;\n    int cbp = 0;\n    uint32_t vlc;\n    int8_t *top, *left;\n    MpegEncContext *const s = (MpegEncContext *) h;\n    const int mb_xy = h->mb_xy;\n    const int b_xy  = 4*s->mb_x + 4*s->mb_y*h->b_stride;\n    h->top_samples_available      = (s->mb_y == 0) ? 0x33FF : 0xFFFF;\n    h->left_samples_available     = (s->mb_x == 0) ? 0x5F5F : 0xFFFF;\n    h->topright_samples_available = 0xFFFF;\n    if (mb_type == 0) {\n        if (s->pict_type == FF_P_TYPE || s->next_picture.mb_type[mb_xy] == -1) {\n            svq3_mc_dir_part(s, 16*s->mb_x, 16*s->mb_y, 16, 16, 0, 0, 0, 0, 0, 0);\n            if (s->pict_type == FF_B_TYPE) {\n                svq3_mc_dir_part(s, 16*s->mb_x, 16*s->mb_y, 16, 16, 0, 0, 0, 0, 1, 1);\n            }\n            mb_type = MB_TYPE_SKIP;\n        } else {\n            mb_type = FFMIN(s->next_picture.mb_type[mb_xy], 6);\n            if (svq3_mc_dir(h, mb_type, PREDICT_MODE, 0, 0) < 0)\n                return -1;\n            if (svq3_mc_dir(h, mb_type, PREDICT_MODE, 1, 1) < 0)\n                return -1;\n            mb_type = MB_TYPE_16x16;\n        }\n    } else if (mb_type < 8) {\n        if (h->thirdpel_flag && h->halfpel_flag == !get_bits1 (&s->gb)) {\n            mode = THIRDPEL_MODE;\n        } else if (h->halfpel_flag && h->thirdpel_flag == !get_bits1 (&s->gb)) {\n            mode = HALFPEL_MODE;\n        } else {\n            mode = FULLPEL_MODE;\n        }\n        for (m = 0; m < 2; m++) {\n            if (s->mb_x > 0 && h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1]+6] != -1) {\n                for (i = 0; i < 4; i++) {\n                    *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - 1 + i*h->b_stride];\n                }\n            } else {\n                for (i = 0; i < 4; i++) {\n                    *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = 0;\n                }\n            }\n            if (s->mb_y > 0) {\n                memcpy(h->mv_cache[m][scan8[0] - 1*8], s->current_picture.motion_val[m][b_xy - h->b_stride], 4*2*sizeof(int16_t));\n                memset(&h->ref_cache[m][scan8[0] - 1*8], (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1, 4);\n                if (s->mb_x < (s->mb_width - 1)) {\n                    *(uint32_t *) h->mv_cache[m][scan8[0] + 4 - 1*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - h->b_stride + 4];\n                    h->ref_cache[m][scan8[0] + 4 - 1*8] =\n                        (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride + 1]+6] == -1 ||\n                         h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride    ]  ] == -1) ? PART_NOT_AVAILABLE : 1;\n                }else\n                    h->ref_cache[m][scan8[0] + 4 - 1*8] = PART_NOT_AVAILABLE;\n                if (s->mb_x > 0) {\n                    *(uint32_t *) h->mv_cache[m][scan8[0] - 1 - 1*8] = *(uint32_t *) s->current_picture.motion_val[m][b_xy - h->b_stride - 1];\n                    h->ref_cache[m][scan8[0] - 1 - 1*8] = (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride - 1]+3] == -1) ? PART_NOT_AVAILABLE : 1;\n                }else\n                    h->ref_cache[m][scan8[0] - 1 - 1*8] = PART_NOT_AVAILABLE;\n            }else\n                memset(&h->ref_cache[m][scan8[0] - 1*8 - 1], PART_NOT_AVAILABLE, 8);\n            if (s->pict_type != FF_B_TYPE)\n                break;\n        }\n        if (s->pict_type == FF_P_TYPE) {\n            if (svq3_mc_dir(h, (mb_type - 1), mode, 0, 0) < 0)\n                return -1;\n        } else {\n            if (mb_type != 2) {\n                if (svq3_mc_dir(h, 0, mode, 0, 0) < 0)\n                    return -1;\n            } else {\n                for (i = 0; i < 4; i++) {\n                    memset(s->current_picture.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));\n                }\n            }\n            if (mb_type != 1) {\n                if (svq3_mc_dir(h, 0, mode, 1, (mb_type == 3)) < 0)\n                    return -1;\n            } else {\n                for (i = 0; i < 4; i++) {\n                    memset(s->current_picture.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));\n                }\n            }\n        }\n        mb_type = MB_TYPE_16x16;\n    } else if (mb_type == 8 || mb_type == 33) {\n        memset(h->intra4x4_pred_mode_cache, -1, 8*5*sizeof(int8_t));\n        if (mb_type == 8) {\n            if (s->mb_x > 0) {\n                for (i = 0; i < 4; i++) {\n                    h->intra4x4_pred_mode_cache[scan8[0] - 1 + i*8] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1]+6-i];\n                }\n                if (h->intra4x4_pred_mode_cache[scan8[0] - 1] == -1) {\n                    h->left_samples_available = 0x5F5F;\n                }\n            }\n            if (s->mb_y > 0) {\n                h->intra4x4_pred_mode_cache[4+8*0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]+0];\n                h->intra4x4_pred_mode_cache[5+8*0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]+1];\n                h->intra4x4_pred_mode_cache[6+8*0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]+2];\n                h->intra4x4_pred_mode_cache[7+8*0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]+3];\n                if (h->intra4x4_pred_mode_cache[4+8*0] == -1) {\n                    h->top_samples_available = 0x33FF;\n                }\n            }\n            for (i = 0; i < 16; i+=2) {\n                vlc = svq3_get_ue_golomb(&s->gb);\n                if (vlc >= 25){\n                    av_log(h->s.avctx, AV_LOG_ERROR, "luma prediction:%d\\n", vlc);\n                    return -1;\n                }\n                left    = &h->intra4x4_pred_mode_cache[scan8[i] - 1];\n                top     = &h->intra4x4_pred_mode_cache[scan8[i] - 8];\n                left[1] = svq3_pred_1[top[0] + 1][left[0] + 1][svq3_pred_0[vlc][0]];\n                left[2] = svq3_pred_1[top[1] + 1][left[1] + 1][svq3_pred_0[vlc][1]];\n                if (left[1] == -1 || left[2] == -1){\n                    av_log(h->s.avctx, AV_LOG_ERROR, "weird prediction\\n");\n                    return -1;\n                }\n            }\n        } else {\n            for (i = 0; i < 4; i++) {\n                memset(&h->intra4x4_pred_mode_cache[scan8[0] + 8*i], DC_PRED, 4);\n            }\n        }\n        ff_h264_write_back_intra_pred_mode(h);\n        if (mb_type == 8) {\n            ff_h264_check_intra4x4_pred_mode(h);\n            h->top_samples_available  = (s->mb_y == 0) ? 0x33FF : 0xFFFF;\n            h->left_samples_available = (s->mb_x == 0) ? 0x5F5F : 0xFFFF;\n        } else {\n            for (i = 0; i < 4; i++) {\n                memset(&h->intra4x4_pred_mode_cache[scan8[0] + 8*i], DC_128_PRED, 4);\n            }\n            h->top_samples_available  = 0x33FF;\n            h->left_samples_available = 0x5F5F;\n        }\n        mb_type = MB_TYPE_INTRA4x4;\n    } else {\n        dir = i_mb_type_info[mb_type - 8].pred_mode;\n        dir = (dir >> 1) ^ 3*(dir & 1) ^ 1;\n        if ((h->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h, dir)) == -1){\n            av_log(h->s.avctx, AV_LOG_ERROR, "check_intra_pred_mode = -1\\n");\n            return -1;\n        }\n        cbp = i_mb_type_info[mb_type - 8].cbp;\n        mb_type = MB_TYPE_INTRA16x16;\n    }\n    if (!IS_INTER(mb_type) && s->pict_type != FF_I_TYPE) {\n        for (i = 0; i < 4; i++) {\n            memset(s->current_picture.motion_val[0][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));\n        }\n        if (s->pict_type == FF_B_TYPE) {\n            for (i = 0; i < 4; i++) {\n                memset(s->current_picture.motion_val[1][b_xy + i*h->b_stride], 0, 4*2*sizeof(int16_t));\n            }\n        }\n    }\n    if (!IS_INTRA4x4(mb_type)) {\n        memset(h->intra4x4_pred_mode+h->mb2br_xy[mb_xy], DC_PRED, 8);\n    }\n    if (!IS_SKIP(mb_type) || s->pict_type == FF_B_TYPE) {\n        memset(h->non_zero_count_cache + 8, 0, 4*9*sizeof(uint8_t));\n        s->dsp.clear_blocks(h->mb);\n    }\n    if (!IS_INTRA16x16(mb_type) && (!IS_SKIP(mb_type) || s->pict_type == FF_B_TYPE)) {\n        if ((vlc = svq3_get_ue_golomb(&s->gb)) >= 48){\n            av_log(h->s.avctx, AV_LOG_ERROR, "cbp_vlc=%d\\n", vlc);\n            return -1;\n        }\n        cbp = IS_INTRA(mb_type) ? golomb_to_intra4x4_cbp[vlc] : golomb_to_inter_cbp[vlc];\n    }\n    if (IS_INTRA16x16(mb_type) || (s->pict_type != FF_I_TYPE && s->adaptive_quant && cbp)) {\n        s->qscale += svq3_get_se_golomb(&s->gb);\n        if (s->qscale > 31){\n            av_log(h->s.avctx, AV_LOG_ERROR, "qscale:%d\\n", s->qscale);\n            return -1;\n        }\n    }\n    if (IS_INTRA16x16(mb_type)) {\n        if (svq3_decode_block(&s->gb, h->mb, 0, 0)){\n            av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding intra luma dc\\n");\n            return -1;\n        }\n    }\n    if (cbp) {\n        const int index = IS_INTRA16x16(mb_type) ? 1 : 0;\n        const int type = ((s->qscale < 24 && IS_INTRA4x4(mb_type)) ? 2 : 1);\n        for (i = 0; i < 4; i++) {\n            if ((cbp & (1 << i))) {\n                for (j = 0; j < 4; j++) {\n                    k = index ? ((j&1) + 2*(i&1) + 2*(j&2) + 4*(i&2)) : (4*i + j);\n                    h->non_zero_count_cache[ scan8[k] ] = 1;\n                    if (svq3_decode_block(&s->gb, &h->mb[16*k], index, type)){\n                        av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding block\\n");\n                        return -1;\n                    }\n                }\n            }\n        }\n        if ((cbp & 0x30)) {\n            for (i = 0; i < 2; ++i) {\n              if (svq3_decode_block(&s->gb, &h->mb[16*(16 + 4*i)], 0, 3)){\n                av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding chroma dc block\\n");\n                return -1;\n              }\n            }\n            if ((cbp & 0x20)) {\n                for (i = 0; i < 8; i++) {\n                    h->non_zero_count_cache[ scan8[16+i] ] = 1;\n                    if (svq3_decode_block(&s->gb, &h->mb[16*(16 + i)], 1, 1)){\n                        av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding chroma ac block\\n");\n                        return -1;\n                    }\n                }\n            }\n        }\n    }\n    h->cbp= cbp;\n    s->current_picture.mb_type[mb_xy] = mb_type;\n    if (IS_INTRA(mb_type)) {\n        h->chroma_pred_mode = ff_h264_check_intra_pred_mode(h, DC_PRED8x8);\n    }\n    return 0;\n}', 'void ff_h264_hl_decode_mb(H264Context *h){\n    MpegEncContext * const s = &h->s;\n    const int mb_xy= h->mb_xy;\n    const int mb_type= s->current_picture.mb_type[mb_xy];\n    int is_complex = CONFIG_SMALL || h->is_complex || IS_INTRA_PCM(mb_type) || s->qscale == 0;\n    if (is_complex)\n        hl_decode_mb_complex(h);\n    else hl_decode_mb_simple(h);\n}', 'static void av_noinline hl_decode_mb_complex(H264Context *h){\n    hl_decode_mb_internal(h, 0);\n}', 'static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple){\n    MpegEncContext * const s = &h->s;\n    const int mb_x= s->mb_x;\n    const int mb_y= s->mb_y;\n    const int mb_xy= h->mb_xy;\n    const int mb_type= s->current_picture.mb_type[mb_xy];\n    uint8_t  *dest_y, *dest_cb, *dest_cr;\n    int linesize, uvlinesize  ;\n    int i;\n    int *block_offset = &h->block_offset[0];\n    const int transform_bypass = !simple && (s->qscale == 0 && h->sps.transform_bypass);\n    const int is_h264 = !CONFIG_SVQ3_DECODER || simple || s->codec_id == CODEC_ID_H264;\n    void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride);\n    void (*idct_dc_add)(uint8_t *dst, DCTELEM *block, int stride);\n    dest_y  = s->current_picture.data[0] + (mb_x + mb_y * s->linesize  ) * 16;\n    dest_cb = s->current_picture.data[1] + (mb_x + mb_y * s->uvlinesize) * 8;\n    dest_cr = s->current_picture.data[2] + (mb_x + mb_y * s->uvlinesize) * 8;\n    s->dsp.prefetch(dest_y + (s->mb_x&3)*4*s->linesize + 64, s->linesize, 4);\n    s->dsp.prefetch(dest_cb + (s->mb_x&7)*s->uvlinesize + 64, dest_cr - dest_cb, 2);\n    h->list_counts[mb_xy]= h->list_count;\n    if (!simple && MB_FIELD) {\n        linesize   = h->mb_linesize   = s->linesize * 2;\n        uvlinesize = h->mb_uvlinesize = s->uvlinesize * 2;\n        block_offset = &h->block_offset[24];\n        if(mb_y&1){\n            dest_y -= s->linesize*15;\n            dest_cb-= s->uvlinesize*7;\n            dest_cr-= s->uvlinesize*7;\n        }\n        if(FRAME_MBAFF) {\n            int list;\n            for(list=0; list<h->list_count; list++){\n                if(!USES_LIST(mb_type, list))\n                    continue;\n                if(IS_16X16(mb_type)){\n                    int8_t *ref = &h->ref_cache[list][scan8[0]];\n                    fill_rectangle(ref, 4, 4, 8, (16+*ref)^(s->mb_y&1), 1);\n                }else{\n                    for(i=0; i<16; i+=4){\n                        int ref = h->ref_cache[list][scan8[i]];\n                        if(ref >= 0)\n                            fill_rectangle(&h->ref_cache[list][scan8[i]], 2, 2, 8, (16+ref)^(s->mb_y&1), 1);\n                    }\n                }\n            }\n        }\n    } else {\n        linesize   = h->mb_linesize   = s->linesize;\n        uvlinesize = h->mb_uvlinesize = s->uvlinesize;\n    }\n    if (!simple && IS_INTRA_PCM(mb_type)) {\n        for (i=0; i<16; i++) {\n            memcpy(dest_y + i*  linesize, h->mb       + i*8, 16);\n        }\n        for (i=0; i<8; i++) {\n            memcpy(dest_cb+ i*uvlinesize, h->mb + 128 + i*4,  8);\n            memcpy(dest_cr+ i*uvlinesize, h->mb + 160 + i*4,  8);\n        }\n    } else {\n        if(IS_INTRA(mb_type)){\n            if(h->deblocking_filter)\n                xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 1, simple);\n            if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){\n                h->hpc.pred8x8[ h->chroma_pred_mode ](dest_cb, uvlinesize);\n                h->hpc.pred8x8[ h->chroma_pred_mode ](dest_cr, uvlinesize);\n            }\n            if(IS_INTRA4x4(mb_type)){\n                if(simple || !s->encoding){\n                    if(IS_8x8DCT(mb_type)){\n                        if(transform_bypass){\n                            idct_dc_add =\n                            idct_add    = s->dsp.add_pixels8;\n                        }else{\n                            idct_dc_add = h->h264dsp.h264_idct8_dc_add;\n                            idct_add    = h->h264dsp.h264_idct8_add;\n                        }\n                        for(i=0; i<16; i+=4){\n                            uint8_t * const ptr= dest_y + block_offset[i];\n                            const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ];\n                            if(transform_bypass && h->sps.profile_idc==244 && dir<=1){\n                                h->hpc.pred8x8l_add[dir](ptr, h->mb + i*16, linesize);\n                            }else{\n                                const int nnz = h->non_zero_count_cache[ scan8[i] ];\n                                h->hpc.pred8x8l[ dir ](ptr, (h->topleft_samples_available<<i)&0x8000,\n                                                            (h->topright_samples_available<<i)&0x4000, linesize);\n                                if(nnz){\n                                    if(nnz == 1 && h->mb[i*16])\n                                        idct_dc_add(ptr, h->mb + i*16, linesize);\n                                    else\n                                        idct_add   (ptr, h->mb + i*16, linesize);\n                                }\n                            }\n                        }\n                    }else{\n                        if(transform_bypass){\n                            idct_dc_add =\n                            idct_add    = s->dsp.add_pixels4;\n                        }else{\n                            idct_dc_add = h->h264dsp.h264_idct_dc_add;\n                            idct_add    = h->h264dsp.h264_idct_add;\n                        }\n                        for(i=0; i<16; i++){\n                            uint8_t * const ptr= dest_y + block_offset[i];\n                            const int dir= h->intra4x4_pred_mode_cache[ scan8[i] ];\n                            if(transform_bypass && h->sps.profile_idc==244 && dir<=1){\n                                h->hpc.pred4x4_add[dir](ptr, h->mb + i*16, linesize);\n                            }else{\n                                uint8_t *topright;\n                                int nnz, tr;\n                                if(dir == DIAG_DOWN_LEFT_PRED || dir == VERT_LEFT_PRED){\n                                    const int topright_avail= (h->topright_samples_available<<i)&0x8000;\n                                    assert(mb_y || linesize <= block_offset[i]);\n                                    if(!topright_avail){\n                                        tr= ptr[3 - linesize]*0x01010101;\n                                        topright= (uint8_t*) &tr;\n                                    }else\n                                        topright= ptr + 4 - linesize;\n                                }else\n                                    topright= NULL;\n                                h->hpc.pred4x4[ dir ](ptr, topright, linesize);\n                                nnz = h->non_zero_count_cache[ scan8[i] ];\n                                if(nnz){\n                                    if(is_h264){\n                                        if(nnz == 1 && h->mb[i*16])\n                                            idct_dc_add(ptr, h->mb + i*16, linesize);\n                                        else\n                                            idct_add   (ptr, h->mb + i*16, linesize);\n                                    }else\n                                        ff_svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, 0);\n                                }\n                            }\n                        }\n                    }\n                }\n            }else{\n                h->hpc.pred16x16[ h->intra16x16_pred_mode ](dest_y , linesize);\n                if(is_h264){\n                    if(!transform_bypass)\n                        h264_luma_dc_dequant_idct_c(h->mb, s->qscale, h->dequant4_coeff[0][s->qscale][0]);\n                }else\n                    ff_svq3_luma_dc_dequant_idct_c(h->mb, s->qscale);\n            }\n            if(h->deblocking_filter)\n                xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0, simple);\n        }else if(is_h264){\n            hl_motion(h, dest_y, dest_cb, dest_cr,\n                      s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab,\n                      s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab,\n                      h->h264dsp.weight_h264_pixels_tab, h->h264dsp.biweight_h264_pixels_tab);\n        }\n        if(!IS_INTRA4x4(mb_type)){\n            if(is_h264){\n                if(IS_INTRA16x16(mb_type)){\n                    if(transform_bypass){\n                        if(h->sps.profile_idc==244 && (h->intra16x16_pred_mode==VERT_PRED8x8 || h->intra16x16_pred_mode==HOR_PRED8x8)){\n                            h->hpc.pred16x16_add[h->intra16x16_pred_mode](dest_y, block_offset, h->mb, linesize);\n                        }else{\n                            for(i=0; i<16; i++){\n                                if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16])\n                                    s->dsp.add_pixels4(dest_y + block_offset[i], h->mb + i*16, linesize);\n                            }\n                        }\n                    }else{\n                         h->h264dsp.h264_idct_add16intra(dest_y, block_offset, h->mb, linesize, h->non_zero_count_cache);\n                    }\n                }else if(h->cbp&15){\n                    if(transform_bypass){\n                        const int di = IS_8x8DCT(mb_type) ? 4 : 1;\n                        idct_add= IS_8x8DCT(mb_type) ? s->dsp.add_pixels8 : s->dsp.add_pixels4;\n                        for(i=0; i<16; i+=di){\n                            if(h->non_zero_count_cache[ scan8[i] ]){\n                                idct_add(dest_y + block_offset[i], h->mb + i*16, linesize);\n                            }\n                        }\n                    }else{\n                        if(IS_8x8DCT(mb_type)){\n                            h->h264dsp.h264_idct8_add4(dest_y, block_offset, h->mb, linesize, h->non_zero_count_cache);\n                        }else{\n                            h->h264dsp.h264_idct_add16(dest_y, block_offset, h->mb, linesize, h->non_zero_count_cache);\n                        }\n                    }\n                }\n            }else{\n                for(i=0; i<16; i++){\n                    if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){\n                        uint8_t * const ptr= dest_y + block_offset[i];\n                        ff_svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, IS_INTRA(mb_type) ? 1 : 0);\n                    }\n                }\n            }\n        }\n        if((simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)) && (h->cbp&0x30)){\n            uint8_t *dest[2] = {dest_cb, dest_cr};\n            if(transform_bypass){\n                if(IS_INTRA(mb_type) && h->sps.profile_idc==244 && (h->chroma_pred_mode==VERT_PRED8x8 || h->chroma_pred_mode==HOR_PRED8x8)){\n                    h->hpc.pred8x8_add[h->chroma_pred_mode](dest[0], block_offset + 16, h->mb + 16*16, uvlinesize);\n                    h->hpc.pred8x8_add[h->chroma_pred_mode](dest[1], block_offset + 20, h->mb + 20*16, uvlinesize);\n                }else{\n                    idct_add = s->dsp.add_pixels4;\n                    for(i=16; i<16+8; i++){\n                        if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16])\n                            idct_add   (dest[(i&4)>>2] + block_offset[i], h->mb + i*16, uvlinesize);\n                    }\n                }\n            }else{\n                chroma_dc_dequant_idct_c(h->mb + 16*16, h->chroma_qp[0], h->dequant4_coeff[IS_INTRA(mb_type) ? 1:4][h->chroma_qp[0]][0]);\n                chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->chroma_qp[1], h->dequant4_coeff[IS_INTRA(mb_type) ? 2:5][h->chroma_qp[1]][0]);\n                if(is_h264){\n                    h->h264dsp.h264_idct_add8(dest, block_offset,\n                                              h->mb, uvlinesize,\n                                              h->non_zero_count_cache);\n                }else{\n                    for(i=16; i<16+8; i++){\n                        if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){\n                            uint8_t * const ptr= dest[(i&4)>>2] + block_offset[i];\n                            ff_svq3_add_idct_c(ptr, h->mb + i*16, uvlinesize, ff_h264_chroma_qp[s->qscale + 12] - 12, 2);\n                        }\n                    }\n                }\n            }\n        }\n    }\n    if(h->cbp || IS_INTRA(mb_type))\n        s->dsp.clear_blocks(h->mb);\n}']