libavcodec/motion_est.c:1806: error: Buffer Overrun L2
  Offset: [3, 4] (⇐ [2, 3] + 1) Size: 4 by call to `interlaced_search`.

libavcodec/motion_est.c:1806:16: Call
1804.                                  s->b_forw_mv_table[xy][0], s->b_forw_mv_table[xy][1], 0);
1805.         c->current_mv_penalty= c->mv_penalty[s->b_code] + MAX_MV;
1806.         bimin= interlaced_search(s, 2,
                     ^
1807.                                  s->b_field_mv_table[1], s->b_field_select_table[1],
1808.                                  s->b_back_mv_table[xy][0], s->b_back_mv_table[xy][1], 0);

libavcodec/motion_est.c:745:1: Parameter `ref_index`
  743. }
  744. 
  745. static int interlaced_search(MpegEncContext *s, int ref_index,
       ^
  746.                              int16_t (*mv_tables[2][2])[2], uint8_t *field_select_tables[2], int mx, int my, int user_field_select)
  747. {

libavcodec/motion_est.c:805:20: Call
  803.             P_MV1[1]= my / 2;
  804. 
  805.             dmin = epzs_motion_search2(s, &mx_i, &my_i, P, block, field_select+ref_index, mv_table, (1<<16)>>1);
                          ^
  806. 
  807.             dmin= c->sub_motion_search(s, &mx_i, &my_i, dmin, block, field_select+ref_index, size, h);

libavcodec/motion_est_template.c:1228:1: Parameter `ref_index`
    1226. 
    1227. //try to merge with above FIXME (needs PSNR test)
    1228. static int epzs_motion_search2(MpegEncContext * s,
          ^
    1229.                              int *mx_ptr, int *my_ptr, int P[10][2],
    1230.                              int src_index, int ref_index, int16_t (*last_mv)[2],

libavcodec/motion_est_template.c:1256:9: Call
    1254.     /* first line */
    1255.     if (s->first_slice_line) {
    1256.         CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
                  ^
    1257.         CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
    1258.                         (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:217:50: Array access: Offset: [3, 4] (⇐ [2, 3] + 1) Size: 4 by call to `interlaced_search` 
          215.         if(chroma){
          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);

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;
}
['void ff_estimate_b_frame_motion(MpegEncContext * s,\n                             int mb_x, int mb_y)\n{\n    MotionEstContext * const c= &s->me;\n    const int penalty_factor= c->mb_penalty_factor;\n    int fmin, bmin, dmin, fbmin, bimin, fimin;\n    int type=0;\n    const int xy = mb_y*s->mb_stride + mb_x;\n    init_ref(c, s->new_picture.data, s->last_picture.data, s->next_picture.data, 16*mb_x, 16*mb_y, 2);\n    get_limits(s, 16*mb_x, 16*mb_y);\n    c->skip=0;\n    if(s->codec_id == CODEC_ID_MPEG4 && s->next_picture.mbskip_table[xy]){\n        int score= direct_search(s, mb_x, mb_y);\n        score= ((unsigned)(score*score + 128*256))>>16;\n        c->mc_mb_var_sum_temp += score;\n        s->current_picture.mc_mb_var[mb_y*s->mb_stride + mb_x] = score;\n        s->mb_type[mb_y*s->mb_stride + mb_x]= CANDIDATE_MB_TYPE_DIRECT0;\n        return;\n    }\n    if(c->avctx->me_threshold){\n        int vard= check_input_motion(s, mb_x, mb_y, 0);\n        if((vard+128)>>8 < c->avctx->me_threshold){\n             s->current_picture.mc_mb_var[s->mb_stride * mb_y + mb_x] = (vard+128)>>8;\n            c->mc_mb_var_sum_temp += (vard+128)>>8;\n            return;\n        }\n        if((vard+128)>>8 < c->avctx->mb_threshold){\n            type= s->mb_type[mb_y*s->mb_stride + mb_x];\n            if(type == CANDIDATE_MB_TYPE_DIRECT){\n                direct_search(s, mb_x, mb_y);\n            }\n            if(type == CANDIDATE_MB_TYPE_FORWARD || type == CANDIDATE_MB_TYPE_BIDIR){\n                c->skip=0;\n                ff_estimate_motion_b(s, mb_x, mb_y, s->b_forw_mv_table, 0, s->f_code);\n            }\n            if(type == CANDIDATE_MB_TYPE_BACKWARD || type == CANDIDATE_MB_TYPE_BIDIR){\n                c->skip=0;\n                ff_estimate_motion_b(s, mb_x, mb_y, s->b_back_mv_table, 2, s->b_code);\n            }\n            if(type == CANDIDATE_MB_TYPE_FORWARD_I || type == CANDIDATE_MB_TYPE_BIDIR_I){\n                c->skip=0;\n                c->current_mv_penalty= c->mv_penalty[s->f_code] + MAX_MV;\n                interlaced_search(s, 0,\n                                        s->b_field_mv_table[0], s->b_field_select_table[0],\n                                        s->b_forw_mv_table[xy][0], s->b_forw_mv_table[xy][1], 1);\n            }\n            if(type == CANDIDATE_MB_TYPE_BACKWARD_I || type == CANDIDATE_MB_TYPE_BIDIR_I){\n                c->skip=0;\n                c->current_mv_penalty= c->mv_penalty[s->b_code] + MAX_MV;\n                interlaced_search(s, 2,\n                                        s->b_field_mv_table[1], s->b_field_select_table[1],\n                                        s->b_back_mv_table[xy][0], s->b_back_mv_table[xy][1], 1);\n            }\n            return;\n        }\n    }\n    if (s->codec_id == CODEC_ID_MPEG4)\n        dmin= direct_search(s, mb_x, mb_y);\n    else\n        dmin= INT_MAX;\n    c->skip=0;\n    fmin= ff_estimate_motion_b(s, mb_x, mb_y, s->b_forw_mv_table, 0, s->f_code) + 3*penalty_factor;\n    c->skip=0;\n    bmin= ff_estimate_motion_b(s, mb_x, mb_y, s->b_back_mv_table, 2, s->b_code) + 2*penalty_factor;\n    c->skip=0;\n    fbmin= bidir_refine(s, mb_x, mb_y) + penalty_factor;\n    if(s->flags & CODEC_FLAG_INTERLACED_ME){\n        c->skip=0;\n        c->current_mv_penalty= c->mv_penalty[s->f_code] + MAX_MV;\n        fimin= interlaced_search(s, 0,\n                                 s->b_field_mv_table[0], s->b_field_select_table[0],\n                                 s->b_forw_mv_table[xy][0], s->b_forw_mv_table[xy][1], 0);\n        c->current_mv_penalty= c->mv_penalty[s->b_code] + MAX_MV;\n        bimin= interlaced_search(s, 2,\n                                 s->b_field_mv_table[1], s->b_field_select_table[1],\n                                 s->b_back_mv_table[xy][0], s->b_back_mv_table[xy][1], 0);\n    }else\n        fimin= bimin= INT_MAX;\n    {\n        int score= fmin;\n        type = CANDIDATE_MB_TYPE_FORWARD;\n        if (dmin <= score){\n            score = dmin;\n            type = CANDIDATE_MB_TYPE_DIRECT;\n        }\n        if(bmin<score){\n            score=bmin;\n            type= CANDIDATE_MB_TYPE_BACKWARD;\n        }\n        if(fbmin<score){\n            score=fbmin;\n            type= CANDIDATE_MB_TYPE_BIDIR;\n        }\n        if(fimin<score){\n            score=fimin;\n            type= CANDIDATE_MB_TYPE_FORWARD_I;\n        }\n        if(bimin<score){\n            score=bimin;\n            type= CANDIDATE_MB_TYPE_BACKWARD_I;\n        }\n        score= ((unsigned)(score*score + 128*256))>>16;\n        c->mc_mb_var_sum_temp += score;\n        s->current_picture.mc_mb_var[mb_y*s->mb_stride + mb_x] = score;\n    }\n    if(c->avctx->mb_decision > FF_MB_DECISION_SIMPLE){\n        type= CANDIDATE_MB_TYPE_FORWARD | CANDIDATE_MB_TYPE_BACKWARD | CANDIDATE_MB_TYPE_BIDIR | CANDIDATE_MB_TYPE_DIRECT;\n        if(fimin < INT_MAX)\n            type |= CANDIDATE_MB_TYPE_FORWARD_I;\n        if(bimin < INT_MAX)\n            type |= CANDIDATE_MB_TYPE_BACKWARD_I;\n        if(fimin < INT_MAX && bimin < INT_MAX){\n            type |= CANDIDATE_MB_TYPE_BIDIR_I;\n        }\n        if(dmin>256*256*16) type&= ~CANDIDATE_MB_TYPE_DIRECT;\n        if(s->codec_id == CODEC_ID_MPEG4 && type&CANDIDATE_MB_TYPE_DIRECT && s->flags&CODEC_FLAG_MV0 && *(uint32_t*)s->b_direct_mv_table[xy])\n            type |= CANDIDATE_MB_TYPE_DIRECT0;\n#if 0\n        if(s->out_format == FMT_MPEG1)\n            type |= CANDIDATE_MB_TYPE_INTRA;\n#endif\n    }\n    s->mb_type[mb_y*s->mb_stride + mb_x]= type;\n}', 'static int interlaced_search(MpegEncContext *s, int ref_index,\n                             int16_t (*mv_tables[2][2])[2], uint8_t *field_select_tables[2], int mx, int my, int user_field_select)\n{\n    MotionEstContext * const c= &s->me;\n    const int size=0;\n    const int h=8;\n    int block;\n    int P[10][2];\n    uint8_t * const mv_penalty= c->current_mv_penalty;\n    int same=1;\n    const int stride= 2*s->linesize;\n    int dmin_sum= 0;\n    const int mot_stride= s->mb_stride;\n    const int xy= s->mb_x + s->mb_y*mot_stride;\n    c->ymin>>=1;\n    c->ymax>>=1;\n    c->stride<<=1;\n    c->uvstride<<=1;\n    init_interlaced_ref(s, ref_index);\n    for(block=0; block<2; block++){\n        int field_select;\n        int best_dmin= INT_MAX;\n        int best_field= -1;\n        for(field_select=0; field_select<2; field_select++){\n            int dmin, mx_i, my_i;\n            int16_t (*mv_table)[2]= mv_tables[block][field_select];\n            if(user_field_select){\n                assert(field_select==0 || field_select==1);\n                assert(field_select_tables[block][xy]==0 || field_select_tables[block][xy]==1);\n                if(field_select_tables[block][xy] != field_select)\n                    continue;\n            }\n            P_LEFT[0] = mv_table[xy - 1][0];\n            P_LEFT[1] = mv_table[xy - 1][1];\n            if(P_LEFT[0]       > (c->xmax<<1)) P_LEFT[0]       = (c->xmax<<1);\n            c->pred_x= P_LEFT[0];\n            c->pred_y= P_LEFT[1];\n            if(!s->first_slice_line){\n                P_TOP[0]      = mv_table[xy - mot_stride][0];\n                P_TOP[1]      = mv_table[xy - mot_stride][1];\n                P_TOPRIGHT[0] = mv_table[xy - mot_stride + 1][0];\n                P_TOPRIGHT[1] = mv_table[xy - mot_stride + 1][1];\n                if(P_TOP[1]      > (c->ymax<<1)) P_TOP[1]     = (c->ymax<<1);\n                if(P_TOPRIGHT[0] < (c->xmin<<1)) P_TOPRIGHT[0]= (c->xmin<<1);\n                if(P_TOPRIGHT[0] > (c->xmax<<1)) P_TOPRIGHT[0]= (c->xmax<<1);\n                if(P_TOPRIGHT[1] > (c->ymax<<1)) P_TOPRIGHT[1]= (c->ymax<<1);\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            }\n            P_MV1[0]= mx;\n            P_MV1[1]= my / 2;\n            dmin = epzs_motion_search2(s, &mx_i, &my_i, P, block, field_select+ref_index, mv_table, (1<<16)>>1);\n            dmin= c->sub_motion_search(s, &mx_i, &my_i, dmin, block, field_select+ref_index, size, h);\n            mv_table[xy][0]= mx_i;\n            mv_table[xy][1]= my_i;\n            if(s->dsp.me_sub_cmp[0] != s->dsp.mb_cmp[0]){\n                int dxy;\n                uint8_t *ref= c->ref[field_select+ref_index][0] + (mx_i>>1) + (my_i>>1)*stride;\n                dxy = ((my_i & 1) << 1) | (mx_i & 1);\n                if(s->no_rounding){\n                    s->dsp.put_no_rnd_pixels_tab[size][dxy](c->scratchpad, ref    , stride, h);\n                }else{\n                    s->dsp.put_pixels_tab       [size][dxy](c->scratchpad, ref    , stride, h);\n                }\n                dmin= s->dsp.mb_cmp[size](s, c->src[block][0], c->scratchpad, stride, h);\n                dmin+= (mv_penalty[mx_i-c->pred_x] + mv_penalty[my_i-c->pred_y] + 1)*c->mb_penalty_factor;\n            }else\n                dmin+= c->mb_penalty_factor;\n            dmin += field_select != block;\n            if(dmin < best_dmin){\n                best_dmin= dmin;\n                best_field= field_select;\n            }\n        }\n        {\n            int16_t (*mv_table)[2]= mv_tables[block][best_field];\n            if(mv_table[xy][0] != mx) same=0;\n            if(mv_table[xy][1]&1) same=0;\n            if(mv_table[xy][1]*2 != my) same=0;\n            if(best_field != block) same=0;\n        }\n        field_select_tables[block][xy]= best_field;\n        dmin_sum += best_dmin;\n    }\n    c->ymin<<=1;\n    c->ymax<<=1;\n    c->stride>>=1;\n    c->uvstride>>=1;\n    if(same)\n        return INT_MAX;\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_search2(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=0;\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}']