static int sad_hpel_motion_search(MpegEncContext * s,

                                  int *mx_ptr, int *my_ptr, int dmin,

                                  int src_index, int ref_index,

                                  int size, int h)

{

    MotionEstContext * const c= &s->me;

    const int penalty_factor= c->sub_penalty_factor;

    int mx, my, dminh;

    uint8_t *pix, *ptr;

    int stride= c->stride;

    LOAD_COMMON



    av_assert2(c->sub_flags == 0);



    if(c->skip){

        *mx_ptr = 0;

        *my_ptr = 0;

        return dmin;

    }



    pix = c->src[src_index][0];



    mx = *mx_ptr;

    my = *my_ptr;

    ptr = c->ref[ref_index][0] + (my * stride) + mx;



    dminh = dmin;



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

        my > ymin && my < ymax) {

        int dx=0, dy=0;

        int d, pen_x, pen_y;

        const int index= (my<<ME_MAP_SHIFT) + mx;

        const int t= score_map[(index-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)];

        const int l= score_map[(index- 1               )&(ME_MAP_SIZE-1)];

        const int r= score_map[(index+ 1               )&(ME_MAP_SIZE-1)];

        const int b= score_map[(index+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)];

        mx<<=1;

        my<<=1;





        pen_x= pred_x + mx;

        pen_y= pred_y + my;



        ptr-= stride;

        if(t<=b){

            CHECK_SAD_HALF_MV(y2 , 0, -1)

            if(l<=r){

                CHECK_SAD_HALF_MV(xy2, -1, -1)

                if(t+r<=b+l){

                    CHECK_SAD_HALF_MV(xy2, +1, -1)

                    ptr+= stride;

                }else{

                    ptr+= stride;

                    CHECK_SAD_HALF_MV(xy2, -1, +1)

                }

                CHECK_SAD_HALF_MV(x2 , -1,  0)

            }else{

                CHECK_SAD_HALF_MV(xy2, +1, -1)

                if(t+l<=b+r){

                    CHECK_SAD_HALF_MV(xy2, -1, -1)

                    ptr+= stride;

                }else{

                    ptr+= stride;

                    CHECK_SAD_HALF_MV(xy2, +1, +1)

                }

                CHECK_SAD_HALF_MV(x2 , +1,  0)

            }

        }else{

            if(l<=r){

                if(t+l<=b+r){

                    CHECK_SAD_HALF_MV(xy2, -1, -1)

                    ptr+= stride;

                }else{

                    ptr+= stride;

                    CHECK_SAD_HALF_MV(xy2, +1, +1)

                }

                CHECK_SAD_HALF_MV(x2 , -1,  0)

                CHECK_SAD_HALF_MV(xy2, -1, +1)

            }else{

                if(t+r<=b+l){

                    CHECK_SAD_HALF_MV(xy2, +1, -1)

                    ptr+= stride;

                }else{

                    ptr+= stride;

                    CHECK_SAD_HALF_MV(xy2, -1, +1)

                }

                CHECK_SAD_HALF_MV(x2 , +1,  0)

                CHECK_SAD_HALF_MV(xy2, +1, +1)

            }

            CHECK_SAD_HALF_MV(y2 ,  0, +1)

        }

        mx+=dx;

        my+=dy;



    }else{

        mx<<=1;

        my<<=1;

    }



    *mx_ptr = mx;

    *my_ptr = my;

    return dminh;

}

static int sad_hpel_motion_search(MpegEncContext * s,

                                  int *mx_ptr, int *my_ptr, int dmin,

                                  int src_index, int ref_index,

                                  int size, int h)

{

    MotionEstContext * const c= &s->me;

    const int penalty_factor= c->sub_penalty_factor;

    int mx, my, dminh;

    uint8_t *pix, *ptr;

    int stride= c->stride;

    LOAD_COMMON



    av_assert2(c->sub_flags == 0);



    if(c->skip){

        *mx_ptr = 0;

        *my_ptr = 0;

        return dmin;

    }



    pix = c->src[src_index][0];



    mx = *mx_ptr;

    my = *my_ptr;

    ptr = c->ref[ref_index][0] + (my * stride) + mx;



    dminh = dmin;



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

        my > ymin && my < ymax) {

        int dx=0, dy=0;

        int d, pen_x, pen_y;

        const int index= (my<<ME_MAP_SHIFT) + mx;

        const int t= score_map[(index-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)];

        const int l= score_map[(index- 1               )&(ME_MAP_SIZE-1)];

        const int r= score_map[(index+ 1               )&(ME_MAP_SIZE-1)];

        const int b= score_map[(index+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)];

        mx<<=1;

        my<<=1;





        pen_x= pred_x + mx;

        pen_y= pred_y + my;



        ptr-= stride;

        if(t<=b){

            CHECK_SAD_HALF_MV(y2 , 0, -1)

            if(l<=r){

                CHECK_SAD_HALF_MV(xy2, -1, -1)

                if(t+r<=b+l){

                    CHECK_SAD_HALF_MV(xy2, +1, -1)

                    ptr+= stride;

                }else{

                    ptr+= stride;

                    CHECK_SAD_HALF_MV(xy2, -1, +1)

                }

                CHECK_SAD_HALF_MV(x2 , -1,  0)

            }else{

                CHECK_SAD_HALF_MV(xy2, +1, -1)

                if(t+l<=b+r){

                    CHECK_SAD_HALF_MV(xy2, -1, -1)

                    ptr+= stride;

                }else{

                    ptr+= stride;

                    CHECK_SAD_HALF_MV(xy2, +1, +1)

                }

                CHECK_SAD_HALF_MV(x2 , +1,  0)

            }

        }else{

            if(l<=r){

                if(t+l<=b+r){

                    CHECK_SAD_HALF_MV(xy2, -1, -1)

                    ptr+= stride;

                }else{

                    ptr+= stride;

                    CHECK_SAD_HALF_MV(xy2, +1, +1)

                }

                CHECK_SAD_HALF_MV(x2 , -1,  0)

                CHECK_SAD_HALF_MV(xy2, -1, +1)

            }else{

                if(t+r<=b+l){

                    CHECK_SAD_HALF_MV(xy2, +1, -1)

                    ptr+= stride;

                }else{

                    ptr+= stride;

                    CHECK_SAD_HALF_MV(xy2, -1, +1)

                }

                CHECK_SAD_HALF_MV(x2 , +1,  0)

                CHECK_SAD_HALF_MV(xy2, +1, +1)

            }

            CHECK_SAD_HALF_MV(y2 ,  0, +1)

        }

        mx+=dx;

        my+=dy;



    }else{

        mx<<=1;

        my<<=1;

    }



    *mx_ptr = mx;

    *my_ptr = my;

    return dminh;

}

static int 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)

{

    MotionEstContext * const c= &VAR_0->me;

    const int VAR_8= c->sub_penalty_factor;

    int VAR_9, VAR_10, VAR_11;

    uint8_t *pix, *ptr;

    int VAR_12= c->VAR_12;

    LOAD_COMMON



    av_assert2(c->sub_flags == 0);



    if(c->skip){

        *VAR_1 = 0;

        *VAR_2 = 0;

        return VAR_3;

    }



    pix = c->src[VAR_4][0];



    VAR_9 = *VAR_1;

    VAR_10 = *VAR_2;

    ptr = c->ref[VAR_5][0] + (VAR_10 * VAR_12) + VAR_9;



    VAR_11 = VAR_3;



    if (VAR_9 > xmin && VAR_9 < xmax &&

        VAR_10 > ymin && VAR_10 < ymax) {

        int VAR_13=0, VAR_14=0;

        int VAR_15, VAR_16, VAR_17;

        const int VAR_18= (VAR_10<<ME_MAP_SHIFT) + VAR_9;

        const int VAR_19= score_map[(VAR_18-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)];

        const int VAR_20= score_map[(VAR_18- 1               )&(ME_MAP_SIZE-1)];

        const int VAR_21= score_map[(VAR_18+ 1               )&(ME_MAP_SIZE-1)];

        const int VAR_22= score_map[(VAR_18+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)];

        VAR_9<<=1;

        VAR_10<<=1;





        VAR_16= pred_x + VAR_9;

        VAR_17= pred_y + VAR_10;



        ptr-= VAR_12;

        if(VAR_19<=VAR_22){

            CHECK_SAD_HALF_MV(y2 , 0, -1)

            if(VAR_20<=VAR_21){

                CHECK_SAD_HALF_MV(xy2, -1, -1)

                if(VAR_19+VAR_21<=VAR_22+VAR_20){

                    CHECK_SAD_HALF_MV(xy2, +1, -1)

                    ptr+= VAR_12;

                }else{

                    ptr+= VAR_12;

                    CHECK_SAD_HALF_MV(xy2, -1, +1)

                }

                CHECK_SAD_HALF_MV(x2 , -1,  0)

            }else{

                CHECK_SAD_HALF_MV(xy2, +1, -1)

                if(VAR_19+VAR_20<=VAR_22+VAR_21){

                    CHECK_SAD_HALF_MV(xy2, -1, -1)

                    ptr+= VAR_12;

                }else{

                    ptr+= VAR_12;

                    CHECK_SAD_HALF_MV(xy2, +1, +1)

                }

                CHECK_SAD_HALF_MV(x2 , +1,  0)

            }

        }else{

            if(VAR_20<=VAR_21){

                if(VAR_19+VAR_20<=VAR_22+VAR_21){

                    CHECK_SAD_HALF_MV(xy2, -1, -1)

                    ptr+= VAR_12;

                }else{

                    ptr+= VAR_12;

                    CHECK_SAD_HALF_MV(xy2, +1, +1)

                }

                CHECK_SAD_HALF_MV(x2 , -1,  0)

                CHECK_SAD_HALF_MV(xy2, -1, +1)

            }else{

                if(VAR_19+VAR_21<=VAR_22+VAR_20){

                    CHECK_SAD_HALF_MV(xy2, +1, -1)

                    ptr+= VAR_12;

                }else{

                    ptr+= VAR_12;

                    CHECK_SAD_HALF_MV(xy2, -1, +1)

                }

                CHECK_SAD_HALF_MV(x2 , +1,  0)

                CHECK_SAD_HALF_MV(xy2, +1, +1)

            }

            CHECK_SAD_HALF_MV(y2 ,  0, +1)

        }

        VAR_9+=VAR_13;

        VAR_10+=VAR_14;



    }else{

        VAR_9<<=1;

        VAR_10<<=1;

    }



    *VAR_1 = VAR_9;

    *VAR_2 = VAR_10;

    return VAR_11;

}

static int 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)
{ MotionEstContext * const c= &VAR_0->me; const int VAR_8= c->sub_penalty_factor; int VAR_9, VAR_10, VAR_11; uint8_t *pix, *ptr; int VAR_12= c->VAR_12; LOAD_COMMON
av_assert2(c->sub_flags == 0); if(c->skip){ *VAR_1 = 0; *VAR_2 = 0; return VAR_3; } pix = c->src[VAR_4][0]; VAR_9 = *VAR_1; VAR_10 = *VAR_2; ptr = c->ref[VAR_5][0] + (VAR_10 * VAR_12) + VAR_9; VAR_11 = VAR_3; if (VAR_9 > xmin && VAR_9 < xmax &&
VAR_10 > ymin && VAR_10 < ymax) { int VAR_13=0, VAR_14=0; int VAR_15, VAR_16, VAR_17; const int VAR_18= (VAR_10<<ME_MAP_SHIFT) + VAR_9; const int VAR_19= score_map[(VAR_18-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)]; const int VAR_20= score_map[(VAR_18- 1               )&(ME_MAP_SIZE-1)]; const int VAR_21= score_map[(VAR_18+ 1               )&(ME_MAP_SIZE-1)]; const int VAR_22= score_map[(VAR_18+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)]; VAR_9<<=1; VAR_10<<=1; VAR_16= pred_x + VAR_9; VAR_17= pred_y + VAR_10; ptr-= VAR_12; if(VAR_19<=VAR_22){ CHECK_SAD_HALF_MV(y2 , 0, -1)
if(VAR_20<=VAR_21){ CHECK_SAD_HALF_MV(xy2, -1, -1)
if(VAR_19+VAR_21<=VAR_22+VAR_20){ CHECK_SAD_HALF_MV(xy2, +1, -1)
ptr+= VAR_12; }else{ ptr+= VAR_12; CHECK_SAD_HALF_MV(xy2, -1, +1)
} CHECK_SAD_HALF_MV(x2 , -1,  0)
}else{ CHECK_SAD_HALF_MV(xy2, +1, -1)
if(VAR_19+VAR_20<=VAR_22+VAR_21){ CHECK_SAD_HALF_MV(xy2, -1, -1)
ptr+= VAR_12; }else{ ptr+= VAR_12; CHECK_SAD_HALF_MV(xy2, +1, +1)
} CHECK_SAD_HALF_MV(x2 , +1,  0)
} }else{ if(VAR_20<=VAR_21){ if(VAR_19+VAR_20<=VAR_22+VAR_21){ CHECK_SAD_HALF_MV(xy2, -1, -1)
ptr+= VAR_12; }else{ ptr+= VAR_12; CHECK_SAD_HALF_MV(xy2, +1, +1)
} CHECK_SAD_HALF_MV(x2 , -1,  0)
CHECK_SAD_HALF_MV(xy2, -1, +1)
}else{ if(VAR_19+VAR_21<=VAR_22+VAR_20){ CHECK_SAD_HALF_MV(xy2, +1, -1)
ptr+= VAR_12; }else{ ptr+= VAR_12; CHECK_SAD_HALF_MV(xy2, -1, +1)
} CHECK_SAD_HALF_MV(x2 , +1,  0)
CHECK_SAD_HALF_MV(xy2, +1, +1)
} CHECK_SAD_HALF_MV(y2 ,  0, +1)
} VAR_9+=VAR_13; VAR_10+=VAR_14; }else{ VAR_9<<=1; VAR_10<<=1; } *VAR_1 = VAR_9; *VAR_2 = VAR_10; return VAR_11; }