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

libavcodec/motion_est.c:610:9: Assignment
608.     init_mv4_ref(c);
609. 
610.     for(block=0; block<4; block++){
             ^
611.         int mx4, my4;
612.         int pred_x4, pred_y4;

libavcodec/motion_est.c:646:17: Call
644.         P_MV1[1]= my;
645. 
646.         dmin4 = epzs_motion_search4(s, &mx4, &my4, P, block, block, s->p_mv_table, (1<<16)>>shift);
                     ^
647. 
648.         dmin4= c->sub_motion_search(s, &mx4, &my4, dmin4, block, block, size, h);

libavcodec/motion_est_template.c:1168:1: Parameter `ref_index`
  1166. }
  1167. 
  1168. static int epzs_motion_search4(MpegEncContext * s,
        ^
  1169.                              int *mx_ptr, int *my_ptr, int P[10][2],
  1170.                              int src_index, int ref_index, int16_t (*last_mv)[2],

libavcodec/motion_est_template.c:1196:9: Call
  1194.     /* first line */
  1195.     if (s->first_slice_line) {
  1196.         CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
                ^
  1197.         CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
  1198.                         (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)

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 `epzs_motion_search4` 
        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 h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)\n{\n    MotionEstContext * const c= &s->me;\n    const int size= 1;\n    const int h=8;\n    int block;\n    int P[10][2];\n    int dmin_sum=0, mx4_sum=0, my4_sum=0;\n    int same=1;\n    const int stride= c->stride;\n    uint8_t *mv_penalty= c->current_mv_penalty;\n    init_mv4_ref(c);\n    for(block=0; block<4; block++){\n        int mx4, my4;\n        int pred_x4, pred_y4;\n        int dmin4;\n        static const int off[4]= {2, 1, 1, -1};\n        const int mot_stride = s->b8_stride;\n        const int mot_xy = s->block_index[block];\n        P_LEFT[0] = s->current_picture.motion_val[0][mot_xy - 1][0];\n        P_LEFT[1] = s->current_picture.motion_val[0][mot_xy - 1][1];\n        if(P_LEFT[0]       > (c->xmax<<shift)) P_LEFT[0]       = (c->xmax<<shift);\n        if (s->first_slice_line && block<2) {\n            c->pred_x= pred_x4= P_LEFT[0];\n            c->pred_y= pred_y4= P_LEFT[1];\n        } else {\n            P_TOP[0]      = s->current_picture.motion_val[0][mot_xy - mot_stride             ][0];\n            P_TOP[1]      = s->current_picture.motion_val[0][mot_xy - mot_stride             ][1];\n            P_TOPRIGHT[0] = s->current_picture.motion_val[0][mot_xy - mot_stride + off[block]][0];\n            P_TOPRIGHT[1] = s->current_picture.motion_val[0][mot_xy - mot_stride + off[block]][1];\n            if(P_TOP[1]      > (c->ymax<<shift)) P_TOP[1]     = (c->ymax<<shift);\n            if(P_TOPRIGHT[0] < (c->xmin<<shift)) P_TOPRIGHT[0]= (c->xmin<<shift);\n            if(P_TOPRIGHT[0] > (c->xmax<<shift)) P_TOPRIGHT[0]= (c->xmax<<shift);\n            if(P_TOPRIGHT[1] > (c->ymax<<shift)) P_TOPRIGHT[1]= (c->ymax<<shift);\n            P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);\n            P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);\n            c->pred_x= pred_x4 = P_MEDIAN[0];\n            c->pred_y= pred_y4 = P_MEDIAN[1];\n        }\n        P_MV1[0]= mx;\n        P_MV1[1]= my;\n        dmin4 = epzs_motion_search4(s, &mx4, &my4, P, block, block, s->p_mv_table, (1<<16)>>shift);\n        dmin4= c->sub_motion_search(s, &mx4, &my4, dmin4, block, block, size, h);\n        if(s->dsp.me_sub_cmp[0] != s->dsp.mb_cmp[0]){\n            int dxy;\n            const int offset= ((block&1) + (block>>1)*stride)*8;\n            uint8_t *dest_y = c->scratchpad + offset;\n            if(s->quarter_sample){\n                uint8_t *ref= c->ref[block][0] + (mx4>>2) + (my4>>2)*stride;\n                dxy = ((my4 & 3) << 2) | (mx4 & 3);\n                if(s->no_rounding)\n                    s->dsp.put_no_rnd_qpel_pixels_tab[1][dxy](dest_y   , ref    , stride);\n                else\n                    s->dsp.put_qpel_pixels_tab       [1][dxy](dest_y   , ref    , stride);\n            }else{\n                uint8_t *ref= c->ref[block][0] + (mx4>>1) + (my4>>1)*stride;\n                dxy = ((my4 & 1) << 1) | (mx4 & 1);\n                if(s->no_rounding)\n                    s->dsp.put_no_rnd_pixels_tab[1][dxy](dest_y    , ref    , stride, h);\n                else\n                    s->dsp.put_pixels_tab       [1][dxy](dest_y    , ref    , stride, h);\n            }\n            dmin_sum+= (mv_penalty[mx4-pred_x4] + mv_penalty[my4-pred_y4])*c->mb_penalty_factor;\n        }else\n            dmin_sum+= dmin4;\n        if(s->quarter_sample){\n            mx4_sum+= mx4/2;\n            my4_sum+= my4/2;\n        }else{\n            mx4_sum+= mx4;\n            my4_sum+= my4;\n        }\n        s->current_picture.motion_val[0][ s->block_index[block] ][0]= mx4;\n        s->current_picture.motion_val[0][ s->block_index[block] ][1]= my4;\n        if(mx4 != mx || my4 != my) same=0;\n    }\n    if(same)\n        return INT_MAX;\n    if(s->dsp.me_sub_cmp[0] != s->dsp.mb_cmp[0]){\n        dmin_sum += s->dsp.mb_cmp[0](s, s->new_picture.data[0] + s->mb_x*16 + s->mb_y*16*stride, c->scratchpad, stride, 16);\n    }\n    if(c->avctx->mb_cmp&FF_CMP_CHROMA){\n        int dxy;\n        int mx, my;\n        int offset;\n        mx= ff_h263_round_chroma(mx4_sum);\n        my= ff_h263_round_chroma(my4_sum);\n        dxy = ((my & 1) << 1) | (mx & 1);\n        offset= (s->mb_x*8 + (mx>>1)) + (s->mb_y*8 + (my>>1))*s->uvlinesize;\n        if(s->no_rounding){\n            s->dsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad    , s->last_picture.data[1] + offset, s->uvlinesize, 8);\n            s->dsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad+8  , s->last_picture.data[2] + offset, s->uvlinesize, 8);\n        }else{\n            s->dsp.put_pixels_tab       [1][dxy](c->scratchpad    , s->last_picture.data[1] + offset, s->uvlinesize, 8);\n            s->dsp.put_pixels_tab       [1][dxy](c->scratchpad+8  , s->last_picture.data[2] + offset, s->uvlinesize, 8);\n        }\n        dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.data[1] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad  , s->uvlinesize, 8);\n        dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.data[2] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad+8, s->uvlinesize, 8);\n    }\n    c->pred_x= mx;\n    c->pred_y= my;\n    switch(c->avctx->mb_cmp&0xFF){\n    case FF_CMP_RD:\n        return dmin_sum;\n    default:\n        return dmin_sum+ 11*c->mb_penalty_factor;\n    }\n}', 'static int epzs_motion_search4(MpegEncContext * s,\n                             int *mx_ptr, int *my_ptr, int P[10][2],\n                             int src_index, int ref_index, int16_t (*last_mv)[2],\n                             int ref_mv_scale)\n{\n    MotionEstContext * const c= &s->me;\n    int best[2]={0, 0};\n    int d, dmin;\n    int map_generation;\n    const int penalty_factor= c->penalty_factor;\n    const int size=1;\n    const int h=8;\n    const int ref_mv_stride= s->mb_stride;\n    const int ref_mv_xy= s->mb_x + s->mb_y *ref_mv_stride;\n    me_cmp_func cmpf, chroma_cmpf;\n    LOAD_COMMON\n    int flags= c->flags;\n    LOAD_COMMON2\n    cmpf= s->dsp.me_cmp[size];\n    chroma_cmpf= s->dsp.me_cmp[size+1];\n    map_generation= update_map_generation(c);\n    dmin = 1000000;\n    if (s->first_slice_line) {\n        CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)\n        CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,\n                        (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)\n        CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)\n    }else{\n        CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)\n        CHECK_MV(P_MEDIAN[0]>>shift, P_MEDIAN[1]>>shift)\n        CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)\n        CHECK_MV(P_TOP[0]>>shift, P_TOP[1]>>shift)\n        CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)\n        CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,\n                        (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)\n    }\n    if(dmin>64*4){\n        CHECK_CLIPPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,\n                        (last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16)\n        if(s->mb_y+1<s->end_mb_y)\n            CHECK_CLIPPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,\n                            (last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)\n    }\n    dmin= diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);\n    *mx_ptr= best[0];\n    *my_ptr= best[1];\n    return dmin;\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}']