libavcodec/motion_est.c:981: error: Buffer Overrun L2
  Offset: [2, 5] (⇐ [0, 3] + 2) Size: 4 by call to `cmp`.

libavcodec/motion_est.c:977:13: Assignment
975.         chroma_cmpf= s->dsp.sse[1];
976.         init_mv4_ref(c);
977.         for(i=0; i<4; i++){
                 ^
978.             xy= s->block_index[i];
979.             x= p->f.motion_val[0][xy][0];

libavcodec/motion_est.c:981:17: Call
979.             x= p->f.motion_val[0][xy][0];
980.             y= p->f.motion_val[0][xy][1];
981.             d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 1, 8, i, i, cmpf, chroma_cmpf, flags);
                     ^
982.         }
983.         s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER4V;

libavcodec/motion_est.c:254:1: Parameter `ref_index`
  252.     against a proposed motion-compensated prediction of that block
  253.  */
  254. static av_always_inline int cmp(MpegEncContext *s, const int x, const int y, const int subx, const int suby,
       ^
  255.                       const int size, const int h, int ref_index, int src_index,
  256.                       me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags){

libavcodec/motion_est.c:260:16: Call
  258.        && av_builtin_constant_p(subx) && av_builtin_constant_p(suby)
  259.        && flags==0 && h==16 && size==0 && subx==0 && suby==0){
  260.         return cmp_simple(s,x,y,ref_index,src_index, cmp_func, chroma_cmp_func);
                      ^
  261.     }else if(av_builtin_constant_p(subx) && av_builtin_constant_p(suby)
  262.        && subx==0 && suby==0){

libavcodec/motion_est.c:225:1: Parameter `ref_index`
    223. }
    224. 
    225. static int cmp_simple(MpegEncContext *s, const int x, const int y,
         ^
    226.                       int ref_index, int src_index,
    227.                       me_cmp_func cmp_func, me_cmp_func chroma_cmp_func){

libavcodec/motion_est.c:228:12: Call
    226.                       int ref_index, int src_index,
    227.                       me_cmp_func cmp_func, me_cmp_func chroma_cmp_func){
    228.     return cmp_inline(s,x,y,0,0,0,16,ref_index,src_index, cmp_func, chroma_cmp_func, 0, 0);
                    ^
    229. }
    230. 

libavcodec/motion_est.c:179:1: <Length trace>
177. }
178. 
179. static av_always_inline int cmp_inline(MpegEncContext *s, const int x, const int y, const int subx, const int suby,
     ^
180.                       const int size, const int h, int ref_index, int src_index,
181.                       me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, int qpel, int chroma){

libavcodec/motion_est.c:179:1: Parameter `ref_index`
      177. }
      178. 
      179. static av_always_inline int cmp_inline(MpegEncContext *s, const int x, const int y, const int subx, const int suby,
           ^
      180.                       const int size, const int h, int ref_index, int src_index,
      181.                       me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, int qpel, int chroma){

libavcodec/motion_est.c:188:5: Assignment
      186.     const int hx= subx + (x<<(1+qpel));
      187.     const int hy= suby + (y<<(1+qpel));
      188.     uint8_t * const * const ref= c->ref[ref_index];
               ^
      189.     uint8_t * const * const src= c->src[src_index];
      190.     int d;

libavcodec/motion_est.c:218:50: Array access: Offset: [2, 5] (⇐ [0, 3] + 2) Size: 4 by call to `cmp` 
      216.             uint8_t * const uvtemp= c->temp + 16*stride;
      217.             c->hpel_put[size+1][uvdxy](uvtemp  , ref[1] + (x>>1) + (y>>1)*uvstride, uvstride, h>>1);
      218.             c->hpel_put[size+1][uvdxy](uvtemp+8, ref[2] + (x>>1) + (y>>1)*uvstride, uvstride, h>>1);
                                                            ^
      219.             d += chroma_cmp_func(s, uvtemp  , src[1], uvstride, h>>1);
      220.             d += chroma_cmp_func(s, uvtemp+8, src[2], uvstride, h>>1);

static av_always_inline int cmp_inline(MpegEncContext *s, const int x, const int y, const int subx, const int suby,
                      const int size, const int h, int ref_index, int src_index,
                      me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, int qpel, int chroma){
    MotionEstContext * const c= &s->me;
    const int stride= c->stride;
    const int uvstride= c->uvstride;
    const int dxy= subx + (suby<<(1+qpel));
    const int hx= subx + (x<<(1+qpel));
    const int hy= suby + (y<<(1+qpel));
    uint8_t * const * const ref= c->ref[ref_index];
    uint8_t * const * const src= c->src[src_index];
    int d;
        int uvdxy;
        if(dxy){
            if(qpel){
                c->qpel_put[size][dxy](c->temp, ref[0] + x + y*stride, stride);
                if(chroma){
                    int cx= hx/2;
                    int cy= hy/2;
                    cx= (cx>>1)|(cx&1);
                    cy= (cy>>1)|(cy&1);
                    uvdxy= (cx&1) + 2*(cy&1);
                }
            }else{
                c->hpel_put[size][dxy](c->temp, ref[0] + x + y*stride, stride, h);
                if(chroma)
                    uvdxy= dxy | (x&1) | (2*(y&1));
            }
            d = cmp_func(s, c->temp, src[0], stride, h);
        }else{
            d = cmp_func(s, src[0], ref[0] + x + y*stride, stride, h);
            if(chroma)
                uvdxy= (x&1) + 2*(y&1);
        }
        if(chroma){
            uint8_t * const uvtemp= c->temp + 16*stride;
            c->hpel_put[size+1][uvdxy](uvtemp  , ref[1] + (x>>1) + (y>>1)*uvstride, uvstride, h>>1);
            c->hpel_put[size+1][uvdxy](uvtemp+8, ref[2] + (x>>1) + (y>>1)*uvstride, uvstride, h>>1);
            d += chroma_cmp_func(s, uvtemp  , src[1], uvstride, h>>1);
            d += chroma_cmp_func(s, uvtemp+8, src[2], uvstride, h>>1);
        }
    return d;
}
['static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int p_type){\n    MotionEstContext * const c= &s->me;\n    Picture *p= s->current_picture_ptr;\n    int mb_xy= mb_x + mb_y*s->mb_stride;\n    int xy= 2*mb_x + 2*mb_y*s->b8_stride;\n    int mb_type= s->current_picture.f.mb_type[mb_xy];\n    int flags= c->flags;\n    int shift= (flags&FLAG_QPEL) + 1;\n    int mask= (1<<shift)-1;\n    int x, y, i;\n    int d=0;\n    me_cmp_func cmpf= s->dsp.sse[0];\n    me_cmp_func chroma_cmpf= s->dsp.sse[1];\n    if(p_type && USES_LIST(mb_type, 1)){\n        av_log(c->avctx, AV_LOG_ERROR, "backward motion vector in P frame\\n");\n        return INT_MAX/2;\n    }\n    assert(IS_INTRA(mb_type) || USES_LIST(mb_type,0) || USES_LIST(mb_type,1));\n    for(i=0; i<4; i++){\n        int xy= s->block_index[i];\n        clip_input_mv(s, p->f.motion_val[0][xy], !!IS_INTERLACED(mb_type));\n        clip_input_mv(s, p->f.motion_val[1][xy], !!IS_INTERLACED(mb_type));\n    }\n    if(IS_INTERLACED(mb_type)){\n        int xy2= xy  + s->b8_stride;\n        s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTRA;\n        c->stride<<=1;\n        c->uvstride<<=1;\n        if(!(s->flags & CODEC_FLAG_INTERLACED_ME)){\n            av_log(c->avctx, AV_LOG_ERROR, "Interlaced macroblock selected but interlaced motion estimation disabled\\n");\n            return INT_MAX/2;\n        }\n        if(USES_LIST(mb_type, 0)){\n            int field_select0= p->f.ref_index[0][4*mb_xy  ];\n            int field_select1= p->f.ref_index[0][4*mb_xy+2];\n            assert(field_select0==0 ||field_select0==1);\n            assert(field_select1==0 ||field_select1==1);\n            init_interlaced_ref(s, 0);\n            if(p_type){\n                s->p_field_select_table[0][mb_xy]= field_select0;\n                s->p_field_select_table[1][mb_xy]= field_select1;\n                *(uint32_t*)s->p_field_mv_table[0][field_select0][mb_xy] = *(uint32_t*)p->f.motion_val[0][xy ];\n                *(uint32_t*)s->p_field_mv_table[1][field_select1][mb_xy] = *(uint32_t*)p->f.motion_val[0][xy2];\n                s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER_I;\n            }else{\n                s->b_field_select_table[0][0][mb_xy]= field_select0;\n                s->b_field_select_table[0][1][mb_xy]= field_select1;\n                *(uint32_t*)s->b_field_mv_table[0][0][field_select0][mb_xy] = *(uint32_t*)p->f.motion_val[0][xy ];\n                *(uint32_t*)s->b_field_mv_table[0][1][field_select1][mb_xy] = *(uint32_t*)p->f.motion_val[0][xy2];\n                s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_FORWARD_I;\n            }\n            x = p->f.motion_val[0][xy ][0];\n            y = p->f.motion_val[0][xy ][1];\n            d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select0, 0, cmpf, chroma_cmpf, flags);\n            x = p->f.motion_val[0][xy2][0];\n            y = p->f.motion_val[0][xy2][1];\n            d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1, 1, cmpf, chroma_cmpf, flags);\n        }\n        if(USES_LIST(mb_type, 1)){\n            int field_select0 = p->f.ref_index[1][4 * mb_xy    ];\n            int field_select1 = p->f.ref_index[1][4 * mb_xy + 2];\n            assert(field_select0==0 ||field_select0==1);\n            assert(field_select1==0 ||field_select1==1);\n            init_interlaced_ref(s, 2);\n            s->b_field_select_table[1][0][mb_xy]= field_select0;\n            s->b_field_select_table[1][1][mb_xy]= field_select1;\n            *(uint32_t*)s->b_field_mv_table[1][0][field_select0][mb_xy] = *(uint32_t*)p->f.motion_val[1][xy ];\n            *(uint32_t*)s->b_field_mv_table[1][1][field_select1][mb_xy] = *(uint32_t*)p->f.motion_val[1][xy2];\n            if(USES_LIST(mb_type, 0)){\n                s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_BIDIR_I;\n            }else{\n                s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_BACKWARD_I;\n            }\n            x = p->f.motion_val[1][xy ][0];\n            y = p->f.motion_val[1][xy ][1];\n            d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select0+2, 0, cmpf, chroma_cmpf, flags);\n            x = p->f.motion_val[1][xy2][0];\n            y = p->f.motion_val[1][xy2][1];\n            d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1+2, 1, cmpf, chroma_cmpf, flags);\n        }\n        c->stride>>=1;\n        c->uvstride>>=1;\n    }else if(IS_8X8(mb_type)){\n        if(!(s->flags & CODEC_FLAG_4MV)){\n            av_log(c->avctx, AV_LOG_ERROR, "4MV macroblock selected but 4MV encoding disabled\\n");\n            return INT_MAX/2;\n        }\n        cmpf= s->dsp.sse[1];\n        chroma_cmpf= s->dsp.sse[1];\n        init_mv4_ref(c);\n        for(i=0; i<4; i++){\n            xy= s->block_index[i];\n            x= p->f.motion_val[0][xy][0];\n            y= p->f.motion_val[0][xy][1];\n            d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 1, 8, i, i, cmpf, chroma_cmpf, flags);\n        }\n        s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER4V;\n    }else{\n        if(USES_LIST(mb_type, 0)){\n            if(p_type){\n                *(uint32_t*)s->p_mv_table[mb_xy] = *(uint32_t*)p->f.motion_val[0][xy];\n                s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER;\n            }else if(USES_LIST(mb_type, 1)){\n                *(uint32_t*)s->b_bidir_forw_mv_table[mb_xy] = *(uint32_t*)p->f.motion_val[0][xy];\n                *(uint32_t*)s->b_bidir_back_mv_table[mb_xy] = *(uint32_t*)p->f.motion_val[1][xy];\n                s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_BIDIR;\n            }else{\n                *(uint32_t*)s->b_forw_mv_table[mb_xy] = *(uint32_t*)p->f.motion_val[0][xy];\n                s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_FORWARD;\n            }\n            x = p->f.motion_val[0][xy][0];\n            y = p->f.motion_val[0][xy][1];\n            d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 16, 0, 0, cmpf, chroma_cmpf, flags);\n        }else if(USES_LIST(mb_type, 1)){\n            *(uint32_t*)s->b_back_mv_table[mb_xy] = *(uint32_t*)p->f.motion_val[1][xy];\n            s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_BACKWARD;\n            x = p->f.motion_val[1][xy][0];\n            y = p->f.motion_val[1][xy][1];\n            d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 16, 2, 0, cmpf, chroma_cmpf, flags);\n        }else\n            s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTRA;\n    }\n    return d;\n}', 'static av_always_inline int cmp(MpegEncContext *s, const int x, const int y, const int subx, const int suby,\n                      const int size, const int h, int ref_index, int src_index,\n                      me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, const int flags){\n    if(av_builtin_constant_p(flags) && av_builtin_constant_p(h) && av_builtin_constant_p(size)\n       && av_builtin_constant_p(subx) && av_builtin_constant_p(suby)\n       && flags==0 && h==16 && size==0 && subx==0 && suby==0){\n        return cmp_simple(s,x,y,ref_index,src_index, cmp_func, chroma_cmp_func);\n    }else if(av_builtin_constant_p(subx) && av_builtin_constant_p(suby)\n       && subx==0 && suby==0){\n        return cmp_fpel_internal(s,x,y,size,h,ref_index,src_index, cmp_func, chroma_cmp_func,flags);\n    }else{\n        return cmp_internal(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, flags);\n    }\n}', 'static int cmp_simple(MpegEncContext *s, const int x, const int y,\n                      int ref_index, int src_index,\n                      me_cmp_func cmp_func, me_cmp_func chroma_cmp_func){\n    return cmp_inline(s,x,y,0,0,0,16,ref_index,src_index, cmp_func, chroma_cmp_func, 0, 0);\n}', 'static av_always_inline int cmp_inline(MpegEncContext *s, const int x, const int y, const int subx, const int suby,\n                      const int size, const int h, int ref_index, int src_index,\n                      me_cmp_func cmp_func, me_cmp_func chroma_cmp_func, int qpel, int chroma){\n    MotionEstContext * const c= &s->me;\n    const int stride= c->stride;\n    const int uvstride= c->uvstride;\n    const int dxy= subx + (suby<<(1+qpel));\n    const int hx= subx + (x<<(1+qpel));\n    const int hy= suby + (y<<(1+qpel));\n    uint8_t * const * const ref= c->ref[ref_index];\n    uint8_t * const * const src= c->src[src_index];\n    int d;\n        int uvdxy;\n        if(dxy){\n            if(qpel){\n                c->qpel_put[size][dxy](c->temp, ref[0] + x + y*stride, stride);\n                if(chroma){\n                    int cx= hx/2;\n                    int cy= hy/2;\n                    cx= (cx>>1)|(cx&1);\n                    cy= (cy>>1)|(cy&1);\n                    uvdxy= (cx&1) + 2*(cy&1);\n                }\n            }else{\n                c->hpel_put[size][dxy](c->temp, ref[0] + x + y*stride, stride, h);\n                if(chroma)\n                    uvdxy= dxy | (x&1) | (2*(y&1));\n            }\n            d = cmp_func(s, c->temp, src[0], stride, h);\n        }else{\n            d = cmp_func(s, src[0], ref[0] + x + y*stride, stride, h);\n            if(chroma)\n                uvdxy= (x&1) + 2*(y&1);\n        }\n        if(chroma){\n            uint8_t * const uvtemp= c->temp + 16*stride;\n            c->hpel_put[size+1][uvdxy](uvtemp  , ref[1] + (x>>1) + (y>>1)*uvstride, uvstride, h>>1);\n            c->hpel_put[size+1][uvdxy](uvtemp+8, ref[2] + (x>>1) + (y>>1)*uvstride, uvstride, h>>1);\n            d += chroma_cmp_func(s, uvtemp  , src[1], uvstride, h>>1);\n            d += chroma_cmp_func(s, uvtemp+8, src[2], uvstride, h>>1);\n        }\n    return d;\n}']