*px_ptr= pred_x = P_left[0]; *py_ptr= pred_y = P_left[1]; CHECK_MV(pred_x>>shift, pred_y>>shift)
CHECK_MV(P[1][0]>>shift, P[1][1]>>shift) }else{ CHECK_MV(P[4][0]>>shift, P[4][1]>>shift)
static int epzs_motion_search(MpegEncContext * s,                             int *mx_ptr, int *my_ptr,                             int *px_ptr, int *py_ptr,                             int xmin, int ymin, int xmax, int ymax){    INT16 P_left[2], P_top[2], P_topright[2], P_last[2];    static const int off[4]= {2, 1, 1, -1};    int best[2]={0, 0};    int d, dmin;     UINT8 *new_pic, *old_pic;    const int pic_stride= s->linesize;    const int pic_xy= (s->mb_y*pic_stride + s->mb_x)*16;    const int mot_stride = s->block_wrap[0];    const int mot_xy = s->block_index[0];    UINT16 *mv_penalty= s->mv_penalty[s->f_code] + MAX_MV; // f_code of the prev frame    int quant= s->qscale; // qscale of the prev frame    int pred_x, pred_y;    const int shift= 1+s->quarter_sample;    new_pic = s->new_picture[0] + pic_xy;    old_pic = s->last_picture[0] + pic_xy;    xmin-=s->mb_x*16;    xmax-=s->mb_x*16;    ymin-=s->mb_y*16;    ymax-=s->mb_y*16;        dmin = pix_abs16x16(new_pic, old_pic, pic_stride, 16);    if(dmin<Z_THRESHOLD){        *mx_ptr= 0;        *my_ptr= 0;//printf("Z");        return dmin;    }    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];    if(P_left[0] > (xmax<<shift)) P_left[0]= (xmax<<shift);    /* special case for first line */    if ((s->mb_y == 0 || s->first_slice_line || s->first_gob_line)) {        *px_ptr= pred_x = P_left[0];        *py_ptr= pred_y = P_left[1];        CHECK_MV(pred_x>>shift, pred_y>>shift)        if(dmin<Z_THRESHOLD){            *mx_ptr= pred_x>>shift;            *my_ptr= pred_y>>shift;//printf("M");            return dmin;        }    } 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[0]    ][0];        P_topright[1] = s->motion_val[mot_xy - mot_stride + off[0]    ][1];        if(P_top     [1] > (ymax<<shift)) P_top     [1]= (ymax<<shift);        if(P_topright[0] < (xmin<<shift)) P_topright[0]= (xmin<<shift);        if(P_topright[1] > (ymax<<shift)) P_topright[1]= (ymax<<shift);        *px_ptr= pred_x = mid_pred(P_left[0], P_top[0], P_topright[0]);        *py_ptr= pred_y = mid_pred(P_left[1], P_top[1], P_topright[1]);                CHECK_MV(pred_x>>shift, pred_y>>shift)        if(dmin<Z_THRESHOLD){            *mx_ptr= pred_x>>shift;            *my_ptr= pred_y>>shift;//printf("M");            return dmin;        }        CHECK_MV(P_left    [0]>>shift, P_left    [1]>>shift)        CHECK_MV(P_top     [0]>>shift, P_top     [1]>>shift)        CHECK_MV(P_topright[0]>>shift, P_topright[1]>>shift)        CHECK_MV(P_last    [0]>>shift, P_last    [1]>>shift)    }    dmin= small_diamond_search(s, best, dmin, new_pic, old_pic, pic_stride,                                pred_x, pred_y, mv_penalty, quant, xmin, ymin, xmax, ymax, shift);    *mx_ptr= best[0];    *my_ptr= best[1];//    printf("%d %d %d \n", best[0], best[1], dmin);    return dmin;}