get_limits(s, &range, &xmin, &ymin, &xmax, &ymax, s->f_code);
get_limits(s, &range, &xmin, &ymin, &xmax, &ymax);
void ff_estimate_p_frame_motion(MpegEncContext * s,                                int mb_x, int mb_y){    uint8_t *pix, *ppix;    int sum, varc, vard, mx, my, range, dmin, xx, yy;    int xmin, ymin, xmax, ymax;    int rel_xmin, rel_ymin, rel_xmax, rel_ymax;    int pred_x=0, pred_y=0;    int P[10][2];    const int shift= 1+s->quarter_sample;    int mb_type=0;    uint8_t *ref_picture= s->last_picture.data[0];    Picture * const pic= &s->current_picture;    uint16_t * const mv_penalty= s->me.mv_penalty[s->f_code] + MAX_MV;        assert(s->quarter_sample==0 || s->quarter_sample==1);    s->me.penalty_factor    = get_penalty_factor(s, s->avctx->me_cmp);    s->me.sub_penalty_factor= get_penalty_factor(s, s->avctx->me_sub_cmp);    s->me.mb_penalty_factor = get_penalty_factor(s, s->avctx->mb_cmp);    get_limits(s, &range, &xmin, &ymin, &xmax, &ymax, s->f_code);    rel_xmin= xmin - mb_x*16;    rel_xmax= xmax - mb_x*16;    rel_ymin= ymin - mb_y*16;    rel_ymax= ymax - mb_y*16;    s->me.skip=0;    switch(s->me_method) {    case ME_ZERO:    default:	no_motion_search(s, &mx, &my);        mx-= mb_x*16;        my-= mb_y*16;        dmin = 0;        break;    case ME_FULL:	dmin = full_motion_search(s, &mx, &my, range, xmin, ymin, xmax, ymax, ref_picture);        mx-= mb_x*16;        my-= mb_y*16;        break;    case ME_LOG:	dmin = log_motion_search(s, &mx, &my, range / 2, xmin, ymin, xmax, ymax, ref_picture);        mx-= mb_x*16;        my-= mb_y*16;        break;    case ME_PHODS:	dmin = phods_motion_search(s, &mx, &my, range / 2, xmin, ymin, xmax, ymax, ref_picture);        mx-= mb_x*16;        my-= mb_y*16;        break;    case ME_X1:    case ME_EPZS:       {            const int mot_stride = s->block_wrap[0];            const int mot_xy = s->block_index[0];            P_LEFT[0]       = s->motion_val[mot_xy - 1][0];            P_LEFT[1]       = s->motion_val[mot_xy - 1][1];            if(P_LEFT[0]       > (rel_xmax<<shift)) P_LEFT[0]       = (rel_xmax<<shift);            if(mb_y) {                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 + 2][0];                P_TOPRIGHT[1] = s->motion_val[mot_xy - mot_stride + 2][1];                if(P_TOP[1]      > (rel_ymax<<shift)) P_TOP[1]     = (rel_ymax<<shift);                if(P_TOPRIGHT[0] < (rel_xmin<<shift)) P_TOPRIGHT[0]= (rel_xmin<<shift);                if(P_TOPRIGHT[1] > (rel_ymax<<shift)) P_TOPRIGHT[1]= (rel_ymax<<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_x = P_MEDIAN[0];                    pred_y = P_MEDIAN[1];                }else { /* mpeg1 at least */                    pred_x= P_LEFT[0];                    pred_y= P_LEFT[1];                }            }else{                pred_x= P_LEFT[0];                pred_y= P_LEFT[1];            }        }        dmin = s->me.motion_search[0](s, 0, &mx, &my, P, pred_x, pred_y, rel_xmin, rel_ymin, rel_xmax, rel_ymax,                                       &s->last_picture, s->p_mv_table, (1<<16)>>shift, mv_penalty);         break;    }    /* intra / predictive decision */    xx = mb_x * 16;    yy = mb_y * 16;    pix = s->new_picture.data[0] + (yy * s->linesize) + xx;    /* At this point (mx,my) are full-pell and the relative displacement */    ppix = ref_picture + ((yy+my) * s->linesize) + (xx+mx);        sum = s->dsp.pix_sum(pix, s->linesize);        varc = (s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500 + 128)>>8;    vard = (s->dsp.sse[0](NULL, pix, ppix, s->linesize)+128)>>8;//printf("%d %d %d %X %X %X\n", s->mb_width, mb_x, mb_y,(int)s, (int)s->mb_var, (int)s->mc_mb_var); fflush(stdout);    pic->mb_var   [s->mb_width * mb_y + mb_x] = varc;    pic->mc_mb_var[s->mb_width * mb_y + mb_x] = vard;    pic->mb_mean  [s->mb_width * mb_y + mb_x] = (sum+128)>>8;//    pic->mb_cmp_score[s->mb_width * mb_y + mb_x] = dmin;     pic->mb_var_sum    += varc;    pic->mc_mb_var_sum += vard;//printf("E%d %d %d %X %X %X\n", s->mb_width, mb_x, mb_y,(int)s, (int)s->mb_var, (int)s->mc_mb_var); fflush(stdout);    #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(s->flags&CODEC_FLAG_HQ){        if (vard <= 64 || vard < varc)            s->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc);        else            s->scene_change_score+= s->qscale;        if (vard*2 + 200 > varc)            mb_type|= MB_TYPE_INTRA;        if (varc*2 + 200 > vard){            mb_type|= MB_TYPE_INTER;            s->me.sub_motion_search(s, &mx, &my, dmin, rel_xmin, rel_ymin, rel_xmax, rel_ymax,				   pred_x, pred_y, &s->last_picture, 0, 0, mv_penalty);        }else{            mx <<=shift;            my <<=shift;        }        if((s->flags&CODEC_FLAG_4MV)           && !s->me.skip && varc>50 && vard>10){            h263_mv4_search(s, rel_xmin, rel_ymin, rel_xmax, rel_ymax, mx, my, shift);            mb_type|=MB_TYPE_INTER4V;            set_p_mv_tables(s, mx, my, 0);        }else            set_p_mv_tables(s, mx, my, 1);    }else{        mb_type= MB_TYPE_INTER;        dmin= s->me.sub_motion_search(s, &mx, &my, dmin, rel_xmin, rel_ymin, rel_xmax, rel_ymax,                                    pred_x, pred_y, &s->last_picture, 0, 0, mv_penalty);                if(s->avctx->me_sub_cmp != s->avctx->mb_cmp && !s->me.skip)            dmin= s->me.get_mb_score(s, mx, my, pred_x, pred_y, &s->last_picture, mv_penalty);        if((s->flags&CODEC_FLAG_4MV)           && !s->me.skip && varc>50 && vard>10){            int dmin4= h263_mv4_search(s, rel_xmin, rel_ymin, rel_xmax, rel_ymax, mx, my, shift);            if(dmin4 < dmin){                mb_type= MB_TYPE_INTER4V;                dmin=dmin4;            }        }        pic->mb_cmp_score[s->mb_width * mb_y + mb_x] = dmin;         set_p_mv_tables(s, mx, my, mb_type!=MB_TYPE_INTER4V);                if (vard <= 64 || vard < varc) {            s->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc);        }else{            s->scene_change_score+= s->qscale;        }    }    s->mb_type[mb_y*s->mb_width + mb_x]= mb_type;}