libavcodec/h264.c:3167: error: Buffer Overrun L1
  Offset: [3, 21] (⇐ [2, 20] + 1) Size: 2 by call to `fill_filter_caches_inter`.

libavcodec/h264.c:3167:9: Call
3165.     fill_filter_caches_inter(h, s, mb_type, top_xy, left_xy, top_type, left_type, mb_xy, 0);
3166.     if(h->list_count == 2)
3167.         fill_filter_caches_inter(h, s, mb_type, top_xy, left_xy, top_type, left_type, mb_xy, 1);
              ^
3168. 
3169.     nnz = h->non_zero_count[mb_xy];

libavcodec/h264.c:3018:1: <Offset trace>
3016. }
3017. 
3018. static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncContext * const s, int mb_type, int top_xy,
      ^
3019.                                                       int left_xy[LEFT_MBS], int top_type, int left_type[LEFT_MBS], int mb_xy, int list)
3020. {

libavcodec/h264.c:3018:1: Parameter `list`
  3016. }
  3017. 
  3018. static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncContext * const s, int mb_type, int top_xy,
        ^
  3019.                                                       int left_xy[LEFT_MBS], int top_type, int left_type[LEFT_MBS], int mb_xy, int list)
  3020. {

libavcodec/h264.c:3018:1: <Length trace>
3016. }
3017. 
3018. static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncContext * const s, int mb_type, int top_xy,
      ^
3019.                                                       int left_xy[LEFT_MBS], int top_type, int left_type[LEFT_MBS], int mb_xy, int list)
3020. {

libavcodec/h264.c:3018:1: Parameter `h->ref2frm[*][*]`
  3016. }
  3017. 
  3018. static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncContext * const s, int mb_type, int top_xy,
        ^
  3019.                                                       int left_xy[LEFT_MBS], int top_type, int left_type[LEFT_MBS], int mb_xy, int list)
  3020. {

libavcodec/h264.c:3028:13: Assignment
  3026.             const int b_xy= h->mb2b_xy[top_xy] + 3*b_stride;
  3027.             const int b8_xy= 4*top_xy + 2;
  3028.             int (*ref2frm)[64] = h->ref2frm[ h->slice_table[top_xy]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2);
                    ^
  3029.             AV_COPY128(mv_dst - 1*8, s->current_picture.f.motion_val[list][b_xy + 0]);
  3030.             ref_cache[0 - 1*8]=

libavcodec/h264.c:3031:33: Array access: Offset: [3, 21] (⇐ [2, 20] + 1) Size: 2 by call to `fill_filter_caches_inter` 
  3029.             AV_COPY128(mv_dst - 1*8, s->current_picture.f.motion_val[list][b_xy + 0]);
  3030.             ref_cache[0 - 1*8]=
  3031.             ref_cache[1 - 1*8]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 0]];
                                        ^
  3032.             ref_cache[2 - 1*8]=
  3033.             ref_cache[3 - 1*8]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 1]];

static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncContext * const s, int mb_type, int top_xy,
                                                      int left_xy[LEFT_MBS], int top_type, int left_type[LEFT_MBS], int mb_xy, int list)
{
    int b_stride = h->b_stride;
    int16_t (*mv_dst)[2] = &h->mv_cache[list][scan8[0]];
    int8_t *ref_cache = &h->ref_cache[list][scan8[0]];
    if(IS_INTER(mb_type) || IS_DIRECT(mb_type)){
        if(USES_LIST(top_type, list)){
            const int b_xy= h->mb2b_xy[top_xy] + 3*b_stride;
            const int b8_xy= 4*top_xy + 2;
            int (*ref2frm)[64] = h->ref2frm[ h->slice_table[top_xy]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2);
            AV_COPY128(mv_dst - 1*8, s->current_picture.f.motion_val[list][b_xy + 0]);
            ref_cache[0 - 1*8]=
            ref_cache[1 - 1*8]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 0]];
            ref_cache[2 - 1*8]=
            ref_cache[3 - 1*8]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 1]];
        }else{
            AV_ZERO128(mv_dst - 1*8);
            AV_WN32A(&ref_cache[0 - 1*8], ((LIST_NOT_USED)&0xFF)*0x01010101u);
        }
        if(!IS_INTERLACED(mb_type^left_type[LTOP])){
            if(USES_LIST(left_type[LTOP], list)){
                const int b_xy= h->mb2b_xy[left_xy[LTOP]] + 3;
                const int b8_xy= 4*left_xy[LTOP] + 1;
                int (*ref2frm)[64] = h->ref2frm[ h->slice_table[left_xy[LTOP]]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2);
                AV_COPY32(mv_dst - 1 +  0, s->current_picture.f.motion_val[list][b_xy + b_stride*0]);
                AV_COPY32(mv_dst - 1 +  8, s->current_picture.f.motion_val[list][b_xy + b_stride*1]);
                AV_COPY32(mv_dst - 1 + 16, s->current_picture.f.motion_val[list][b_xy + b_stride*2]);
                AV_COPY32(mv_dst - 1 + 24, s->current_picture.f.motion_val[list][b_xy + b_stride*3]);
                ref_cache[-1 +  0]=
                ref_cache[-1 +  8]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 2*0]];
                ref_cache[-1 + 16]=
                ref_cache[-1 + 24]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 2*1]];
            }else{
                AV_ZERO32(mv_dst - 1 + 0);
                AV_ZERO32(mv_dst - 1 + 8);
                AV_ZERO32(mv_dst - 1 +16);
                AV_ZERO32(mv_dst - 1 +24);
                ref_cache[-1 +  0]=
                ref_cache[-1 +  8]=
                ref_cache[-1 + 16]=
                ref_cache[-1 + 24]= LIST_NOT_USED;
            }
        }
    }
    if(!USES_LIST(mb_type, list)){
        fill_rectangle(mv_dst, 4, 4, 8, pack16to32(0,0), 4);
        AV_WN32A(&ref_cache[0*8], ((LIST_NOT_USED)&0xFF)*0x01010101u);
        AV_WN32A(&ref_cache[1*8], ((LIST_NOT_USED)&0xFF)*0x01010101u);
        AV_WN32A(&ref_cache[2*8], ((LIST_NOT_USED)&0xFF)*0x01010101u);
        AV_WN32A(&ref_cache[3*8], ((LIST_NOT_USED)&0xFF)*0x01010101u);
        return;
    }
    {
        int8_t *ref = &s->current_picture.f.ref_index[list][4*mb_xy];
        int (*ref2frm)[64] = h->ref2frm[ h->slice_num&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2);
        uint32_t ref01 = (pack16to32(ref2frm[list][ref[0]],ref2frm[list][ref[1]])&0x00FF00FF)*0x0101;
        uint32_t ref23 = (pack16to32(ref2frm[list][ref[2]],ref2frm[list][ref[3]])&0x00FF00FF)*0x0101;
        AV_WN32A(&ref_cache[0*8], ref01);
        AV_WN32A(&ref_cache[1*8], ref01);
        AV_WN32A(&ref_cache[2*8], ref23);
        AV_WN32A(&ref_cache[3*8], ref23);
    }
    {
        int16_t (*mv_src)[2] = &s->current_picture.f.motion_val[list][4*s->mb_x + 4*s->mb_y*b_stride];
        AV_COPY128(mv_dst + 8*0, mv_src + 0*b_stride);
        AV_COPY128(mv_dst + 8*1, mv_src + 1*b_stride);
        AV_COPY128(mv_dst + 8*2, mv_src + 2*b_stride);
        AV_COPY128(mv_dst + 8*3, mv_src + 3*b_stride);
    }
}
['static int fill_filter_caches(H264Context *h, int mb_type){\n    MpegEncContext * const s = &h->s;\n    const int mb_xy= h->mb_xy;\n    int top_xy, left_xy[LEFT_MBS];\n    int top_type, left_type[LEFT_MBS];\n    uint8_t *nnz;\n    uint8_t *nnz_cache;\n    top_xy     = mb_xy  - (s->mb_stride << MB_FIELD);\n    left_xy[LBOT] = left_xy[LTOP] = mb_xy-1;\n    if(FRAME_MBAFF){\n        const int left_mb_field_flag     = IS_INTERLACED(s->current_picture.f.mb_type[mb_xy - 1]);\n        const int curr_mb_field_flag     = IS_INTERLACED(mb_type);\n        if(s->mb_y&1){\n            if (left_mb_field_flag != curr_mb_field_flag) {\n                left_xy[LTOP] -= s->mb_stride;\n            }\n        }else{\n            if(curr_mb_field_flag){\n                top_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy] >> 7) & 1) - 1);\n            }\n            if (left_mb_field_flag != curr_mb_field_flag) {\n                left_xy[LBOT] += s->mb_stride;\n            }\n        }\n    }\n    h->top_mb_xy = top_xy;\n    h->left_mb_xy[LTOP] = left_xy[LTOP];\n    h->left_mb_xy[LBOT] = left_xy[LBOT];\n    {\n        int qp_thresh = h->qp_thresh;\n        int qp = s->current_picture.f.qscale_table[mb_xy];\n        if(qp <= qp_thresh\n           && (left_xy[LTOP] < 0 || ((qp + s->current_picture.f.qscale_table[left_xy[LTOP]] + 1) >> 1) <= qp_thresh)\n           && (top_xy        < 0 || ((qp + s->current_picture.f.qscale_table[top_xy       ] + 1) >> 1) <= qp_thresh)) {\n            if(!FRAME_MBAFF)\n                return 1;\n            if ((left_xy[LTOP] < 0            || ((qp + s->current_picture.f.qscale_table[left_xy[LBOT]        ] + 1) >> 1) <= qp_thresh) &&\n                (top_xy        < s->mb_stride || ((qp + s->current_picture.f.qscale_table[top_xy - s->mb_stride] + 1) >> 1) <= qp_thresh))\n                return 1;\n        }\n    }\n    top_type        = s->current_picture.f.mb_type[top_xy];\n    left_type[LTOP] = s->current_picture.f.mb_type[left_xy[LTOP]];\n    left_type[LBOT] = s->current_picture.f.mb_type[left_xy[LBOT]];\n    if(h->deblocking_filter == 2){\n        if(h->slice_table[top_xy       ] != h->slice_num) top_type= 0;\n        if(h->slice_table[left_xy[LBOT]] != h->slice_num) left_type[LTOP]= left_type[LBOT]= 0;\n    }else{\n        if(h->slice_table[top_xy       ] == 0xFFFF) top_type= 0;\n        if(h->slice_table[left_xy[LBOT]] == 0xFFFF) left_type[LTOP]= left_type[LBOT] =0;\n    }\n    h->top_type       = top_type;\n    h->left_type[LTOP]= left_type[LTOP];\n    h->left_type[LBOT]= left_type[LBOT];\n    if(IS_INTRA(mb_type))\n        return 0;\n    fill_filter_caches_inter(h, s, mb_type, top_xy, left_xy, top_type, left_type, mb_xy, 0);\n    if(h->list_count == 2)\n        fill_filter_caches_inter(h, s, mb_type, top_xy, left_xy, top_type, left_type, mb_xy, 1);\n    nnz = h->non_zero_count[mb_xy];\n    nnz_cache = h->non_zero_count_cache;\n    AV_COPY32(&nnz_cache[4+8*1], &nnz[ 0]);\n    AV_COPY32(&nnz_cache[4+8*2], &nnz[ 4]);\n    AV_COPY32(&nnz_cache[4+8*3], &nnz[ 8]);\n    AV_COPY32(&nnz_cache[4+8*4], &nnz[12]);\n    h->cbp= h->cbp_table[mb_xy];\n    if(top_type){\n        nnz = h->non_zero_count[top_xy];\n        AV_COPY32(&nnz_cache[4+8*0], &nnz[3*4]);\n    }\n    if(left_type[LTOP]){\n        nnz = h->non_zero_count[left_xy[LTOP]];\n        nnz_cache[3+8*1]= nnz[3+0*4];\n        nnz_cache[3+8*2]= nnz[3+1*4];\n        nnz_cache[3+8*3]= nnz[3+2*4];\n        nnz_cache[3+8*4]= nnz[3+3*4];\n    }\n    if(!CABAC && h->pps.transform_8x8_mode){\n        if(IS_8x8DCT(top_type)){\n            nnz_cache[4+8*0]=\n            nnz_cache[5+8*0]= (h->cbp_table[top_xy] & 0x4000) >> 12;\n            nnz_cache[6+8*0]=\n            nnz_cache[7+8*0]= (h->cbp_table[top_xy] & 0x8000) >> 12;\n        }\n        if(IS_8x8DCT(left_type[LTOP])){\n            nnz_cache[3+8*1]=\n            nnz_cache[3+8*2]= (h->cbp_table[left_xy[LTOP]]&0x2000) >> 12;\n        }\n        if(IS_8x8DCT(left_type[LBOT])){\n            nnz_cache[3+8*3]=\n            nnz_cache[3+8*4]= (h->cbp_table[left_xy[LBOT]]&0x8000) >> 12;\n        }\n        if(IS_8x8DCT(mb_type)){\n            nnz_cache[scan8[0   ]]= nnz_cache[scan8[1   ]]=\n            nnz_cache[scan8[2   ]]= nnz_cache[scan8[3   ]]= (h->cbp & 0x1000) >> 12;\n            nnz_cache[scan8[0+ 4]]= nnz_cache[scan8[1+ 4]]=\n            nnz_cache[scan8[2+ 4]]= nnz_cache[scan8[3+ 4]]= (h->cbp & 0x2000) >> 12;\n            nnz_cache[scan8[0+ 8]]= nnz_cache[scan8[1+ 8]]=\n            nnz_cache[scan8[2+ 8]]= nnz_cache[scan8[3+ 8]]= (h->cbp & 0x4000) >> 12;\n            nnz_cache[scan8[0+12]]= nnz_cache[scan8[1+12]]=\n            nnz_cache[scan8[2+12]]= nnz_cache[scan8[3+12]]= (h->cbp & 0x8000) >> 12;\n        }\n    }\n    return 0;\n}', 'static av_always_inline void fill_filter_caches_inter(H264Context *h, MpegEncContext * const s, int mb_type, int top_xy,\n                                                      int left_xy[LEFT_MBS], int top_type, int left_type[LEFT_MBS], int mb_xy, int list)\n{\n    int b_stride = h->b_stride;\n    int16_t (*mv_dst)[2] = &h->mv_cache[list][scan8[0]];\n    int8_t *ref_cache = &h->ref_cache[list][scan8[0]];\n    if(IS_INTER(mb_type) || IS_DIRECT(mb_type)){\n        if(USES_LIST(top_type, list)){\n            const int b_xy= h->mb2b_xy[top_xy] + 3*b_stride;\n            const int b8_xy= 4*top_xy + 2;\n            int (*ref2frm)[64] = h->ref2frm[ h->slice_table[top_xy]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2);\n            AV_COPY128(mv_dst - 1*8, s->current_picture.f.motion_val[list][b_xy + 0]);\n            ref_cache[0 - 1*8]=\n            ref_cache[1 - 1*8]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 0]];\n            ref_cache[2 - 1*8]=\n            ref_cache[3 - 1*8]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 1]];\n        }else{\n            AV_ZERO128(mv_dst - 1*8);\n            AV_WN32A(&ref_cache[0 - 1*8], ((LIST_NOT_USED)&0xFF)*0x01010101u);\n        }\n        if(!IS_INTERLACED(mb_type^left_type[LTOP])){\n            if(USES_LIST(left_type[LTOP], list)){\n                const int b_xy= h->mb2b_xy[left_xy[LTOP]] + 3;\n                const int b8_xy= 4*left_xy[LTOP] + 1;\n                int (*ref2frm)[64] = h->ref2frm[ h->slice_table[left_xy[LTOP]]&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2);\n                AV_COPY32(mv_dst - 1 +  0, s->current_picture.f.motion_val[list][b_xy + b_stride*0]);\n                AV_COPY32(mv_dst - 1 +  8, s->current_picture.f.motion_val[list][b_xy + b_stride*1]);\n                AV_COPY32(mv_dst - 1 + 16, s->current_picture.f.motion_val[list][b_xy + b_stride*2]);\n                AV_COPY32(mv_dst - 1 + 24, s->current_picture.f.motion_val[list][b_xy + b_stride*3]);\n                ref_cache[-1 +  0]=\n                ref_cache[-1 +  8]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 2*0]];\n                ref_cache[-1 + 16]=\n                ref_cache[-1 + 24]= ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 2*1]];\n            }else{\n                AV_ZERO32(mv_dst - 1 + 0);\n                AV_ZERO32(mv_dst - 1 + 8);\n                AV_ZERO32(mv_dst - 1 +16);\n                AV_ZERO32(mv_dst - 1 +24);\n                ref_cache[-1 +  0]=\n                ref_cache[-1 +  8]=\n                ref_cache[-1 + 16]=\n                ref_cache[-1 + 24]= LIST_NOT_USED;\n            }\n        }\n    }\n    if(!USES_LIST(mb_type, list)){\n        fill_rectangle(mv_dst, 4, 4, 8, pack16to32(0,0), 4);\n        AV_WN32A(&ref_cache[0*8], ((LIST_NOT_USED)&0xFF)*0x01010101u);\n        AV_WN32A(&ref_cache[1*8], ((LIST_NOT_USED)&0xFF)*0x01010101u);\n        AV_WN32A(&ref_cache[2*8], ((LIST_NOT_USED)&0xFF)*0x01010101u);\n        AV_WN32A(&ref_cache[3*8], ((LIST_NOT_USED)&0xFF)*0x01010101u);\n        return;\n    }\n    {\n        int8_t *ref = &s->current_picture.f.ref_index[list][4*mb_xy];\n        int (*ref2frm)[64] = h->ref2frm[ h->slice_num&(MAX_SLICES-1) ][0] + (MB_MBAFF ? 20 : 2);\n        uint32_t ref01 = (pack16to32(ref2frm[list][ref[0]],ref2frm[list][ref[1]])&0x00FF00FF)*0x0101;\n        uint32_t ref23 = (pack16to32(ref2frm[list][ref[2]],ref2frm[list][ref[3]])&0x00FF00FF)*0x0101;\n        AV_WN32A(&ref_cache[0*8], ref01);\n        AV_WN32A(&ref_cache[1*8], ref01);\n        AV_WN32A(&ref_cache[2*8], ref23);\n        AV_WN32A(&ref_cache[3*8], ref23);\n    }\n    {\n        int16_t (*mv_src)[2] = &s->current_picture.f.motion_val[list][4*s->mb_x + 4*s->mb_y*b_stride];\n        AV_COPY128(mv_dst + 8*0, mv_src + 0*b_stride);\n        AV_COPY128(mv_dst + 8*1, mv_src + 1*b_stride);\n        AV_COPY128(mv_dst + 8*2, mv_src + 2*b_stride);\n        AV_COPY128(mv_dst + 8*3, mv_src + 3*b_stride);\n    }\n}']