halfpel_motion_search(s, &mx, &my, dmin, xmin, ymin, xmax, ymax);
halfpel_motion_search(s, &mx, &my, dmin, xmin, ymin, xmax, ymax, pred_x, pred_y);
int estimate_motion(MpegEncContext * s,		    int mb_x, int mb_y,		    int *mx_ptr, int *my_ptr){    UINT8 *pix, *ppix;    int sum, varc, vard, mx, my, range, dmin, xx, yy;    int xmin, ymin, xmax, ymax;        range = 8 * (1 << (s->f_code - 1));    /* XXX: temporary kludge to avoid overflow for msmpeg4 */    if (s->out_format == FMT_H263 && !s->h263_msmpeg4)	range = range * 2;    if (s->unrestricted_mv) {        xmin = -16;        ymin = -16;        if (s->h263_plus)            range *= 2;        if(s->avctx==NULL || s->avctx->codec->id!=CODEC_ID_MPEG4){            xmax = s->mb_width*16;            ymax = s->mb_height*16;        }else {            /* XXX: dunno if this is correct but ffmpeg4 decoder wont like it otherwise 	            (cuz the drawn edge isnt large enough))*/            xmax = s->width;            ymax = s->height;        }    } else {        xmin = 0;        ymin = 0;        xmax = s->mb_width*16 - 16;        ymax = s->mb_height*16 - 16;    }    switch(s->full_search) {    case ME_ZERO:    default:	no_motion_search(s, &mx, &my);        dmin = 0;        break;    case ME_FULL:	dmin = full_motion_search(s, &mx, &my, range, xmin, ymin, xmax, ymax);        break;    case ME_LOG:	dmin = log_motion_search(s, &mx, &my, range / 2, xmin, ymin, xmax, ymax);        break;    case ME_PHODS:	dmin = phods_motion_search(s, &mx, &my, range / 2, xmin, ymin, xmax, ymax);        break;    }    emms_c();    /* intra / predictive decision */    xx = mb_x * 16;    yy = mb_y * 16;    pix = s->new_picture[0] + (yy * s->linesize) + xx;    /* At this point (mx,my) are full-pell and the absolute displacement */    ppix = s->last_picture[0] + (my * s->linesize) + mx;    sum = pix_sum(pix, s->linesize);    varc = pix_norm1(pix, s->linesize);    vard = pix_norm(pix, ppix, s->linesize);    vard = vard >> 8;    sum = sum >> 8;    varc = (varc >> 8) - (sum * sum);    s->mb_var[s->mb_width * mb_y + mb_x] = varc;    s->avg_mb_var += varc;    s->mc_mb_var += vard;     #if 0    printf("varc=%4d avg_var=%4d (sum=%4d) vard=%4d mx=%2d my=%2d\n",	   varc, s->avg_mb_var, sum, vard, mx - xx, my - yy);#endif    if (vard <= 64 || vard < varc) {        if (s->full_search != ME_ZERO) {            halfpel_motion_search(s, &mx, &my, dmin, xmin, ymin, xmax, ymax);        } else {            mx -= 16 * s->mb_x;            my -= 16 * s->mb_y;        }	*mx_ptr = mx;	*my_ptr = my;	return 0;    } else {	*mx_ptr = 0;	*my_ptr = 0;	return 1;    }}