if(P_LAST_RIGHT[0] < (rel_xmin4<<shift)) P_LAST_RIGHT[0] = (rel_xmin4<<shift); if(P_LAST_BOTTOM[1]< (rel_ymin4<<shift)) P_LAST_BOTTOM[1]= (rel_ymin4<<shift);
static inline int mv4_search(MpegEncContext *s, int xmin, int ymin, int xmax, int ymax, int mx, int my, int shift){    int block;    int P[10][2];    uint8_t *ref_picture= s->last_picture.data[0];    int dmin_sum=0;    uint16_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV;    for(block=0; block<4; block++){        int mx4, my4;        int pred_x4, pred_y4;        int dmin4;        static const int off[4]= {2, 1, 1, -1};        const int mot_stride = s->block_wrap[0];        const int mot_xy = s->block_index[block];//        const int block_x= (block&1);//        const int block_y= (block>>1);#if 1 // this saves us a bit of cliping work and shouldnt affect compression in a negative way        const int rel_xmin4= xmin;        const int rel_xmax4= xmax;        const int rel_ymin4= ymin;        const int rel_ymax4= ymax;#else        const int rel_xmin4= xmin - block_x*8;        const int rel_xmax4= xmax - block_x*8 + 8;        const int rel_ymin4= ymin - block_y*8;        const int rel_ymax4= ymax - block_y*8 + 8;#endif        P_LAST[0] = s->motion_val[mot_xy    ][0];        P_LAST[1] = s->motion_val[mot_xy    ][1];        P_LEFT[0] = s->motion_val[mot_xy - 1][0];        P_LEFT[1] = s->motion_val[mot_xy - 1][1];        P_LAST_RIGHT[0] = s->motion_val[mot_xy + 1][0];        P_LAST_RIGHT[1] = s->motion_val[mot_xy + 1][1];        P_LAST_BOTTOM[0]= s->motion_val[mot_xy + 1*mot_stride][0];        P_LAST_BOTTOM[1]= s->motion_val[mot_xy + 1*mot_stride][1];        if(P_LEFT[0]       > (rel_xmax4<<shift)) P_LEFT[0]       = (rel_xmax4<<shift);        if(P_LAST_RIGHT[0] < (rel_xmin4<<shift)) P_LAST_RIGHT[0] = (rel_xmin4<<shift);        if(P_LAST_BOTTOM[1]< (rel_ymin4<<shift)) P_LAST_BOTTOM[1]= (rel_ymin4<<shift);        /* special case for first line */        if ((s->mb_y == 0 || s->first_slice_line) && block<2) {            pred_x4= P_LEFT[0];            pred_y4= P_LEFT[1];        } else {            P_TOP[0]      = s->motion_val[mot_xy - mot_stride             ][0];            P_TOP[1]      = s->motion_val[mot_xy - mot_stride             ][1];            P_TOPRIGHT[0] = s->motion_val[mot_xy - mot_stride + off[block]][0];            P_TOPRIGHT[1] = s->motion_val[mot_xy - mot_stride + off[block]][1];            if(P_TOP[1]      > (rel_ymax4<<shift)) P_TOP[1]     = (rel_ymax4<<shift);            if(P_TOPRIGHT[0] < (rel_xmin4<<shift)) P_TOPRIGHT[0]= (rel_xmin4<<shift);            if(P_TOPRIGHT[0] > (rel_xmax4<<shift)) P_TOPRIGHT[0]= (rel_xmax4<<shift);            if(P_TOPRIGHT[1] > (rel_ymax4<<shift)) P_TOPRIGHT[1]= (rel_ymax4<<shift);                P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);            P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);            if(s->out_format == FMT_H263){                pred_x4 = P_MEDIAN[0];                pred_y4 = P_MEDIAN[1];            }else { /* mpeg1 at least */                pred_x4= P_LEFT[0];                pred_y4= P_LEFT[1];            }        }        P_MV1[0]= mx;        P_MV1[1]= my;        dmin4 = s->me.motion_search[1](s, block, &mx4, &my4, P, pred_x4, pred_y4, rel_xmin4, rel_ymin4, rel_xmax4, rel_ymax4,                                        &s->last_picture, mv_penalty);        dmin4= s->me.sub_motion_search(s, &mx4, &my4, dmin4, rel_xmin4, rel_ymin4, rel_xmax4, rel_ymax4, 					  pred_x4, pred_y4, &s->last_picture, block, 1, mv_penalty);         s->motion_val[ s->block_index[block] ][0]= mx4;        s->motion_val[ s->block_index[block] ][1]= my4;        dmin_sum+= dmin4;    }    return dmin_sum;}