static inline void halfpel_motion_search4(MpegEncContext * s,

				  int *mx_ptr, int *my_ptr, int dmin,

				  int xmin, int ymin, int xmax, int ymax,

                                  int pred_x, int pred_y, int block_x, int block_y,

                                  uint8_t *ref_picture)

{

    UINT16 *mv_penalty= s->mv_penalty[s->f_code] + MAX_MV; // f_code of the prev frame

    const int quant= s->qscale;

    int pen_x, pen_y;

    int mx, my, mx1, my1, d, xx, yy, dminh;

    UINT8 *pix, *ptr;



    xx = 8 * block_x;

    yy = 8 * block_y;

    pix =  s->new_picture[0] + (yy * s->linesize) + xx;

    

    mx = *mx_ptr;

    my = *my_ptr;

    ptr = ref_picture + ((yy+my) * s->linesize) + xx + mx;



    dminh = dmin;



    if (mx > xmin && mx < xmax && 

        my > ymin && my < ymax) {



        mx= mx1= 2*mx;

        my= my1= 2*my;

        if(dmin < Z_THRESHOLD && mx==0 && my==0){

            *mx_ptr = 0;

            *my_ptr = 0;

            return;

        }

        

        pen_x= pred_x + mx;

        pen_y= pred_y + my;



        ptr-= s->linesize;

        CHECK_HALF_MV4(xy2, -1, -1)

        CHECK_HALF_MV4(y2 ,  0, -1)

        CHECK_HALF_MV4(xy2, +1, -1)

        

        ptr+= s->linesize;

        CHECK_HALF_MV4(x2 , -1,  0)

        CHECK_HALF_MV4(x2 , +1,  0)

        CHECK_HALF_MV4(xy2, -1, +1)

        CHECK_HALF_MV4(y2 ,  0, +1)

        CHECK_HALF_MV4(xy2, +1, +1)



    }else{

        mx*=2;

        my*=2;

    }



    *mx_ptr = mx;

    *my_ptr = my;

}

static inline void halfpel_motion_search4(MpegEncContext * s,

				  int *mx_ptr, int *my_ptr, int dmin,

				  int xmin, int ymin, int xmax, int ymax,

                                  int pred_x, int pred_y, int block_x, int block_y,

                                  uint8_t *ref_picture)

{

    UINT16 *mv_penalty= s->mv_penalty[s->f_code] + MAX_MV; 

    const int quant= s->qscale;

    int pen_x, pen_y;

    int mx, my, mx1, my1, d, xx, yy, dminh;

    UINT8 *pix, *ptr;



    xx = 8 * block_x;

    yy = 8 * block_y;

    pix =  s->new_picture[0] + (yy * s->linesize) + xx;

    

    mx = *mx_ptr;

    my = *my_ptr;

    ptr = ref_picture + ((yy+my) * s->linesize) + xx + mx;



    dminh = dmin;



    if (mx > xmin && mx < xmax && 

        my > ymin && my < ymax) {



        mx= mx1= 2*mx;

        my= my1= 2*my;

        if(dmin < Z_THRESHOLD && mx==0 && my==0){

            *mx_ptr = 0;

            *my_ptr = 0;

            return;

        }

        

        pen_x= pred_x + mx;

        pen_y= pred_y + my;



        ptr-= s->linesize;

        CHECK_HALF_MV4(xy2, -1, -1)

        CHECK_HALF_MV4(y2 ,  0, -1)

        CHECK_HALF_MV4(xy2, +1, -1)

        

        ptr+= s->linesize;

        CHECK_HALF_MV4(x2 , -1,  0)

        CHECK_HALF_MV4(x2 , +1,  0)

        CHECK_HALF_MV4(xy2, -1, +1)

        CHECK_HALF_MV4(y2 ,  0, +1)

        CHECK_HALF_MV4(xy2, +1, +1)



    }else{

        mx*=2;

        my*=2;

    }



    *mx_ptr = mx;

    *my_ptr = my;

}

static inline void FUNC_0(MpegEncContext * VAR_0,

				  int *VAR_1, int *VAR_2, int VAR_3,

				  int VAR_4, int VAR_5, int VAR_6, int VAR_7,

                                  int VAR_8, int VAR_9, int VAR_10, int VAR_11,

                                  uint8_t *VAR_12)

{

    UINT16 *mv_penalty= VAR_0->mv_penalty[VAR_0->f_code] + MAX_MV; 

    const int VAR_13= VAR_0->qscale;

    int VAR_14, VAR_15;

    int VAR_16, VAR_17, VAR_18, VAR_19, VAR_20, VAR_21, VAR_22, VAR_23;

    UINT8 *pix, *ptr;



    VAR_21 = 8 * VAR_10;

    VAR_22 = 8 * VAR_11;

    pix =  VAR_0->new_picture[0] + (VAR_22 * VAR_0->linesize) + VAR_21;

    

    VAR_16 = *VAR_1;

    VAR_17 = *VAR_2;

    ptr = VAR_12 + ((VAR_22+VAR_17) * VAR_0->linesize) + VAR_21 + VAR_16;



    VAR_23 = VAR_3;



    if (VAR_16 > VAR_4 && VAR_16 < VAR_6 && 

        VAR_17 > VAR_5 && VAR_17 < VAR_7) {



        VAR_16= VAR_18= 2*VAR_16;

        VAR_17= VAR_19= 2*VAR_17;

        if(VAR_3 < Z_THRESHOLD && VAR_16==0 && VAR_17==0){

            *VAR_1 = 0;

            *VAR_2 = 0;

            return;

        }

        

        VAR_14= VAR_8 + VAR_16;

        VAR_15= VAR_9 + VAR_17;



        ptr-= VAR_0->linesize;

        CHECK_HALF_MV4(xy2, -1, -1)

        CHECK_HALF_MV4(y2 ,  0, -1)

        CHECK_HALF_MV4(xy2, +1, -1)

        

        ptr+= VAR_0->linesize;

        CHECK_HALF_MV4(x2 , -1,  0)

        CHECK_HALF_MV4(x2 , +1,  0)

        CHECK_HALF_MV4(xy2, -1, +1)

        CHECK_HALF_MV4(y2 ,  0, +1)

        CHECK_HALF_MV4(xy2, +1, +1)



    }else{

        VAR_16*=2;

        VAR_17*=2;

    }



    *VAR_1 = VAR_16;

    *VAR_2 = VAR_17;

}

static inline void FUNC_0(MpegEncContext * VAR_0,
int *VAR_1, int *VAR_2, int VAR_3,
int VAR_4, int VAR_5, int VAR_6, int VAR_7,
int VAR_8, int VAR_9, int VAR_10, int VAR_11,
uint8_t *VAR_12)
{ UINT16 *mv_penalty= VAR_0->mv_penalty[VAR_0->f_code] + MAX_MV; const int VAR_13= VAR_0->qscale; int VAR_14, VAR_15; int VAR_16, VAR_17, VAR_18, VAR_19, VAR_20, VAR_21, VAR_22, VAR_23; UINT8 *pix, *ptr; VAR_21 = 8 * VAR_10; VAR_22 = 8 * VAR_11; pix =  VAR_0->new_picture[0] + (VAR_22 * VAR_0->linesize) + VAR_21; VAR_16 = *VAR_1; VAR_17 = *VAR_2; ptr = VAR_12 + ((VAR_22+VAR_17) * VAR_0->linesize) + VAR_21 + VAR_16; VAR_23 = VAR_3; if (VAR_16 > VAR_4 && VAR_16 < VAR_6 &&
VAR_17 > VAR_5 && VAR_17 < VAR_7) { VAR_16= VAR_18= 2*VAR_16; VAR_17= VAR_19= 2*VAR_17; if(VAR_3 < Z_THRESHOLD && VAR_16==0 && VAR_17==0){ *VAR_1 = 0; *VAR_2 = 0; return; } VAR_14= VAR_8 + VAR_16; VAR_15= VAR_9 + VAR_17; ptr-= VAR_0->linesize; CHECK_HALF_MV4(xy2, -1, -1)
CHECK_HALF_MV4(y2 ,  0, -1)
CHECK_HALF_MV4(xy2, +1, -1)
ptr+= VAR_0->linesize; CHECK_HALF_MV4(x2 , -1,  0)
CHECK_HALF_MV4(x2 , +1,  0)
CHECK_HALF_MV4(xy2, -1, +1)
CHECK_HALF_MV4(y2 ,  0, +1)
CHECK_HALF_MV4(xy2, +1, +1)
}else{ VAR_16*=2; VAR_17*=2; } *VAR_1 = VAR_16; *VAR_2 = VAR_17; }