static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int p_type){

    MotionEstContext * const c= &s->me;

    Picture *p= s->current_picture_ptr;

    int mb_xy= mb_x + mb_y*s->mb_stride;

    int xy= 2*mb_x + 2*mb_y*s->b8_stride;

    int mb_type= s->current_picture.mb_type[mb_xy];

    int flags= c->flags;

    int shift= (flags&FLAG_QPEL) + 1;

    int mask= (1<<shift)-1;

    int x, y, i;

    int d=0;

    me_cmp_func cmpf= s->dsp.sse[0];

    me_cmp_func chroma_cmpf= s->dsp.sse[1];

    

    assert(p_type==0 || !USES_LIST(mb_type, 1));

    assert(IS_INTRA(mb_type) || USES_LIST(mb_type,0) || USES_LIST(mb_type,1));

    

    if(IS_INTERLACED(mb_type)){

        int xy2= xy  + s->b8_stride;

        s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTRA;

        c->stride<<=1;

        c->uvstride<<=1;

        

        if(!(s->flags & CODEC_FLAG_INTERLACED_ME)){

            av_log(c->avctx, AV_LOG_ERROR, "Interlaced macroblock selected but interlaced motion estimation disabled\n");

            return -1;

        }



        if(USES_LIST(mb_type, 0)){

            int field_select0= p->ref_index[0][xy ];

            int field_select1= p->ref_index[0][xy2];

            assert(field_select0==0 ||field_select0==1);

            assert(field_select1==0 ||field_select1==1);

            init_interlaced_ref(s, 0);



            if(p_type){

                s->p_field_select_table[0][mb_xy]= field_select0;

                s->p_field_select_table[1][mb_xy]= field_select1;

                *(uint32_t*)s->p_field_mv_table[0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[0][xy ];

                *(uint32_t*)s->p_field_mv_table[1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[0][xy2];

                s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER_I;

            }else{

                s->b_field_select_table[0][0][mb_xy]= field_select0;

                s->b_field_select_table[0][1][mb_xy]= field_select1;

                *(uint32_t*)s->b_field_mv_table[0][0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[0][xy ];

                *(uint32_t*)s->b_field_mv_table[0][1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[0][xy2];

                s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_FORWARD_I;

            }



            x= p->motion_val[0][xy ][0]; 

            y= p->motion_val[0][xy ][1];

            d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select0, 0, cmpf, chroma_cmpf, flags);

            x= p->motion_val[0][xy2][0]; 

            y= p->motion_val[0][xy2][1];

            d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1, 1, cmpf, chroma_cmpf, flags);

        }

        if(USES_LIST(mb_type, 1)){

            int field_select0= p->ref_index[1][xy ];

            int field_select1= p->ref_index[1][xy2];

            assert(field_select0==0 ||field_select0==1);

            assert(field_select1==0 ||field_select1==1);

            init_interlaced_ref(s, 2);



            s->b_field_select_table[1][0][mb_xy]= field_select0;

            s->b_field_select_table[1][1][mb_xy]= field_select1;

            *(uint32_t*)s->b_field_mv_table[1][0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[1][xy ];

            *(uint32_t*)s->b_field_mv_table[1][1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[1][xy2];

            if(USES_LIST(mb_type, 0)){

                s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_BIDIR_I;

            }else{

                s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_BACKWARD_I;

            }



            x= p->motion_val[1][xy ][0]; 

            y= p->motion_val[1][xy ][1];

            d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select0+2, 0, cmpf, chroma_cmpf, flags);

            x= p->motion_val[1][xy2][0]; 

            y= p->motion_val[1][xy2][1];

            d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1+2, 1, cmpf, chroma_cmpf, flags);

            //FIXME bidir scores

        }

        c->stride>>=1;

        c->uvstride>>=1;

    }else if(IS_8X8(mb_type)){

        if(!(s->flags & CODEC_FLAG_4MV)){

            av_log(c->avctx, AV_LOG_ERROR, "4MV macroblock selected but 4MV encoding disabled\n");

            return -1;

        }

        cmpf= s->dsp.sse[1];

        chroma_cmpf= s->dsp.sse[1];

        init_mv4_ref(c);

        for(i=0; i<4; i++){

            xy= s->block_index[i];

            x= p->motion_val[0][xy][0]; 

            y= p->motion_val[0][xy][1];

            d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 1, 8, i, i, cmpf, chroma_cmpf, flags);

        }

        s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER4V;

    }else{

        if(USES_LIST(mb_type, 0)){

            if(p_type){

                *(uint32_t*)s->p_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy];

                s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER;

            }else if(USES_LIST(mb_type, 1)){

                *(uint32_t*)s->b_bidir_forw_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy];

                *(uint32_t*)s->b_bidir_back_mv_table[mb_xy]= *(uint32_t*)p->motion_val[1][xy];

                s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_BIDIR;

            }else{

                *(uint32_t*)s->b_forw_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy];

                s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_FORWARD;

            }

            x= p->motion_val[0][xy][0]; 

            y= p->motion_val[0][xy][1];

            d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 16, 0, 0, cmpf, chroma_cmpf, flags);

        }else if(USES_LIST(mb_type, 1)){

            *(uint32_t*)s->b_back_mv_table[mb_xy]= *(uint32_t*)p->motion_val[1][xy];

            s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_BACKWARD;

           

            x= p->motion_val[1][xy][0]; 

            y= p->motion_val[1][xy][1];

            d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 16, 2, 0, cmpf, chroma_cmpf, flags);

        }else

            s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTRA;

    }

    return d;

}

static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int p_type){

    MotionEstContext * const c= &s->me;

    Picture *p= s->current_picture_ptr;

    int mb_xy= mb_x + mb_y*s->mb_stride;

    int xy= 2*mb_x + 2*mb_y*s->b8_stride;

    int mb_type= s->current_picture.mb_type[mb_xy];

    int flags= c->flags;

    int shift= (flags&FLAG_QPEL) + 1;

    int mask= (1<<shift)-1;

    int x, y, i;

    int d=0;

    me_cmp_func cmpf= s->dsp.sse[0];

    me_cmp_func chroma_cmpf= s->dsp.sse[1];

    

    assert(p_type==0 || !USES_LIST(mb_type, 1));

    assert(IS_INTRA(mb_type) || USES_LIST(mb_type,0) || USES_LIST(mb_type,1));

    

    if(IS_INTERLACED(mb_type)){

        int xy2= xy  + s->b8_stride;

        s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTRA;

        c->stride<<=1;

        c->uvstride<<=1;

        

        if(!(s->flags & CODEC_FLAG_INTERLACED_ME)){

            av_log(c->avctx, AV_LOG_ERROR, "Interlaced macroblock selected but interlaced motion estimation disabled\n");

            return -1;

        }



        if(USES_LIST(mb_type, 0)){

            int field_select0= p->ref_index[0][xy ];

            int field_select1= p->ref_index[0][xy2];

            assert(field_select0==0 ||field_select0==1);

            assert(field_select1==0 ||field_select1==1);

            init_interlaced_ref(s, 0);



            if(p_type){

                s->p_field_select_table[0][mb_xy]= field_select0;

                s->p_field_select_table[1][mb_xy]= field_select1;

                *(uint32_t*)s->p_field_mv_table[0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[0][xy ];

                *(uint32_t*)s->p_field_mv_table[1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[0][xy2];

                s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER_I;

            }else{

                s->b_field_select_table[0][0][mb_xy]= field_select0;

                s->b_field_select_table[0][1][mb_xy]= field_select1;

                *(uint32_t*)s->b_field_mv_table[0][0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[0][xy ];

                *(uint32_t*)s->b_field_mv_table[0][1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[0][xy2];

                s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_FORWARD_I;

            }



            x= p->motion_val[0][xy ][0]; 

            y= p->motion_val[0][xy ][1];

            d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select0, 0, cmpf, chroma_cmpf, flags);

            x= p->motion_val[0][xy2][0]; 

            y= p->motion_val[0][xy2][1];

            d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1, 1, cmpf, chroma_cmpf, flags);

        }

        if(USES_LIST(mb_type, 1)){

            int field_select0= p->ref_index[1][xy ];

            int field_select1= p->ref_index[1][xy2];

            assert(field_select0==0 ||field_select0==1);

            assert(field_select1==0 ||field_select1==1);

            init_interlaced_ref(s, 2);



            s->b_field_select_table[1][0][mb_xy]= field_select0;

            s->b_field_select_table[1][1][mb_xy]= field_select1;

            *(uint32_t*)s->b_field_mv_table[1][0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[1][xy ];

            *(uint32_t*)s->b_field_mv_table[1][1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[1][xy2];

            if(USES_LIST(mb_type, 0)){

                s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_BIDIR_I;

            }else{

                s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_BACKWARD_I;

            }



            x= p->motion_val[1][xy ][0]; 

            y= p->motion_val[1][xy ][1];

            d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select0+2, 0, cmpf, chroma_cmpf, flags);

            x= p->motion_val[1][xy2][0]; 

            y= p->motion_val[1][xy2][1];

            d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1+2, 1, cmpf, chroma_cmpf, flags);

            

        }

        c->stride>>=1;

        c->uvstride>>=1;

    }else if(IS_8X8(mb_type)){

        if(!(s->flags & CODEC_FLAG_4MV)){

            av_log(c->avctx, AV_LOG_ERROR, "4MV macroblock selected but 4MV encoding disabled\n");

            return -1;

        }

        cmpf= s->dsp.sse[1];

        chroma_cmpf= s->dsp.sse[1];

        init_mv4_ref(c);

        for(i=0; i<4; i++){

            xy= s->block_index[i];

            x= p->motion_val[0][xy][0]; 

            y= p->motion_val[0][xy][1];

            d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 1, 8, i, i, cmpf, chroma_cmpf, flags);

        }

        s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER4V;

    }else{

        if(USES_LIST(mb_type, 0)){

            if(p_type){

                *(uint32_t*)s->p_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy];

                s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER;

            }else if(USES_LIST(mb_type, 1)){

                *(uint32_t*)s->b_bidir_forw_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy];

                *(uint32_t*)s->b_bidir_back_mv_table[mb_xy]= *(uint32_t*)p->motion_val[1][xy];

                s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_BIDIR;

            }else{

                *(uint32_t*)s->b_forw_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy];

                s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_FORWARD;

            }

            x= p->motion_val[0][xy][0]; 

            y= p->motion_val[0][xy][1];

            d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 16, 0, 0, cmpf, chroma_cmpf, flags);

        }else if(USES_LIST(mb_type, 1)){

            *(uint32_t*)s->b_back_mv_table[mb_xy]= *(uint32_t*)p->motion_val[1][xy];

            s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_BACKWARD;

           

            x= p->motion_val[1][xy][0]; 

            y= p->motion_val[1][xy][1];

            d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 16, 2, 0, cmpf, chroma_cmpf, flags);

        }else

            s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTRA;

    }

    return d;

}

static inline int FUNC_0(MpegEncContext * VAR_0, int VAR_1, int VAR_2, int VAR_3){

    MotionEstContext * const c= &VAR_0->me;

    Picture *p= VAR_0->current_picture_ptr;

    int VAR_4= VAR_1 + VAR_2*VAR_0->mb_stride;

    int VAR_5= 2*VAR_1 + 2*VAR_2*VAR_0->b8_stride;

    int VAR_6= VAR_0->current_picture.VAR_6[VAR_4];

    int VAR_7= c->VAR_7;

    int VAR_8= (VAR_7&FLAG_QPEL) + 1;

    int VAR_9= (1<<VAR_8)-1;

    int VAR_10, VAR_11, VAR_12;

    int VAR_13=0;

    me_cmp_func cmpf= VAR_0->dsp.sse[0];

    me_cmp_func chroma_cmpf= VAR_0->dsp.sse[1];

    

    assert(VAR_3==0 || !USES_LIST(VAR_6, 1));

    assert(IS_INTRA(VAR_6) || USES_LIST(VAR_6,0) || USES_LIST(VAR_6,1));

    

    if(IS_INTERLACED(VAR_6)){

        int VAR_14= VAR_5  + VAR_0->b8_stride;

        VAR_0->VAR_6[VAR_4]=CANDIDATE_MB_TYPE_INTRA;

        c->stride<<=1;

        c->uvstride<<=1;

        

        if(!(VAR_0->VAR_7 & CODEC_FLAG_INTERLACED_ME)){

            av_log(c->avctx, AV_LOG_ERROR, "Interlaced macroblock selected but interlaced motion estimation disabled\n");

            return -1;

        }



        if(USES_LIST(VAR_6, 0)){

            int VAR_17= p->ref_index[0][VAR_5 ];

            int VAR_17= p->ref_index[0][VAR_14];

            assert(VAR_17==0 ||VAR_17==1);

            assert(VAR_17==0 ||VAR_17==1);

            init_interlaced_ref(VAR_0, 0);



            if(VAR_3){

                VAR_0->p_field_select_table[0][VAR_4]= VAR_17;

                VAR_0->p_field_select_table[1][VAR_4]= VAR_17;

                *(uint32_t*)VAR_0->p_field_mv_table[0][VAR_17][VAR_4]= *(uint32_t*)p->motion_val[0][VAR_5 ];

                *(uint32_t*)VAR_0->p_field_mv_table[1][VAR_17][VAR_4]= *(uint32_t*)p->motion_val[0][VAR_14];

                VAR_0->VAR_6[VAR_4]=CANDIDATE_MB_TYPE_INTER_I;

            }else{

                VAR_0->b_field_select_table[0][0][VAR_4]= VAR_17;

                VAR_0->b_field_select_table[0][1][VAR_4]= VAR_17;

                *(uint32_t*)VAR_0->b_field_mv_table[0][0][VAR_17][VAR_4]= *(uint32_t*)p->motion_val[0][VAR_5 ];

                *(uint32_t*)VAR_0->b_field_mv_table[0][1][VAR_17][VAR_4]= *(uint32_t*)p->motion_val[0][VAR_14];

                VAR_0->VAR_6[VAR_4]= CANDIDATE_MB_TYPE_FORWARD_I;

            }



            VAR_10= p->motion_val[0][VAR_5 ][0]; 

            VAR_11= p->motion_val[0][VAR_5 ][1];

            VAR_13 = cmp(VAR_0, VAR_10>>VAR_8, VAR_11>>VAR_8, VAR_10&VAR_9, VAR_11&VAR_9, 0, 8, VAR_17, 0, cmpf, chroma_cmpf, VAR_7);

            VAR_10= p->motion_val[0][VAR_14][0]; 

            VAR_11= p->motion_val[0][VAR_14][1];

            VAR_13+= cmp(VAR_0, VAR_10>>VAR_8, VAR_11>>VAR_8, VAR_10&VAR_9, VAR_11&VAR_9, 0, 8, VAR_17, 1, cmpf, chroma_cmpf, VAR_7);

        }

        if(USES_LIST(VAR_6, 1)){

            int VAR_17= p->ref_index[1][VAR_5 ];

            int VAR_17= p->ref_index[1][VAR_14];

            assert(VAR_17==0 ||VAR_17==1);

            assert(VAR_17==0 ||VAR_17==1);

            init_interlaced_ref(VAR_0, 2);



            VAR_0->b_field_select_table[1][0][VAR_4]= VAR_17;

            VAR_0->b_field_select_table[1][1][VAR_4]= VAR_17;

            *(uint32_t*)VAR_0->b_field_mv_table[1][0][VAR_17][VAR_4]= *(uint32_t*)p->motion_val[1][VAR_5 ];

            *(uint32_t*)VAR_0->b_field_mv_table[1][1][VAR_17][VAR_4]= *(uint32_t*)p->motion_val[1][VAR_14];

            if(USES_LIST(VAR_6, 0)){

                VAR_0->VAR_6[VAR_4]= CANDIDATE_MB_TYPE_BIDIR_I;

            }else{

                VAR_0->VAR_6[VAR_4]= CANDIDATE_MB_TYPE_BACKWARD_I;

            }



            VAR_10= p->motion_val[1][VAR_5 ][0]; 

            VAR_11= p->motion_val[1][VAR_5 ][1];

            VAR_13 = cmp(VAR_0, VAR_10>>VAR_8, VAR_11>>VAR_8, VAR_10&VAR_9, VAR_11&VAR_9, 0, 8, VAR_17+2, 0, cmpf, chroma_cmpf, VAR_7);

            VAR_10= p->motion_val[1][VAR_14][0]; 

            VAR_11= p->motion_val[1][VAR_14][1];

            VAR_13+= cmp(VAR_0, VAR_10>>VAR_8, VAR_11>>VAR_8, VAR_10&VAR_9, VAR_11&VAR_9, 0, 8, VAR_17+2, 1, cmpf, chroma_cmpf, VAR_7);

            

        }

        c->stride>>=1;

        c->uvstride>>=1;

    }else if(IS_8X8(VAR_6)){

        if(!(VAR_0->VAR_7 & CODEC_FLAG_4MV)){

            av_log(c->avctx, AV_LOG_ERROR, "4MV macroblock selected but 4MV encoding disabled\n");

            return -1;

        }

        cmpf= VAR_0->dsp.sse[1];

        chroma_cmpf= VAR_0->dsp.sse[1];

        init_mv4_ref(c);

        for(VAR_12=0; VAR_12<4; VAR_12++){

            VAR_5= VAR_0->block_index[VAR_12];

            VAR_10= p->motion_val[0][VAR_5][0]; 

            VAR_11= p->motion_val[0][VAR_5][1];

            VAR_13+= cmp(VAR_0, VAR_10>>VAR_8, VAR_11>>VAR_8, VAR_10&VAR_9, VAR_11&VAR_9, 1, 8, VAR_12, VAR_12, cmpf, chroma_cmpf, VAR_7);

        }

        VAR_0->VAR_6[VAR_4]=CANDIDATE_MB_TYPE_INTER4V;

    }else{

        if(USES_LIST(VAR_6, 0)){

            if(VAR_3){

                *(uint32_t*)VAR_0->p_mv_table[VAR_4]= *(uint32_t*)p->motion_val[0][VAR_5];

                VAR_0->VAR_6[VAR_4]=CANDIDATE_MB_TYPE_INTER;

            }else if(USES_LIST(VAR_6, 1)){

                *(uint32_t*)VAR_0->b_bidir_forw_mv_table[VAR_4]= *(uint32_t*)p->motion_val[0][VAR_5];

                *(uint32_t*)VAR_0->b_bidir_back_mv_table[VAR_4]= *(uint32_t*)p->motion_val[1][VAR_5];

                VAR_0->VAR_6[VAR_4]=CANDIDATE_MB_TYPE_BIDIR;

            }else{

                *(uint32_t*)VAR_0->b_forw_mv_table[VAR_4]= *(uint32_t*)p->motion_val[0][VAR_5];

                VAR_0->VAR_6[VAR_4]=CANDIDATE_MB_TYPE_FORWARD;

            }

            VAR_10= p->motion_val[0][VAR_5][0]; 

            VAR_11= p->motion_val[0][VAR_5][1];

            VAR_13 = cmp(VAR_0, VAR_10>>VAR_8, VAR_11>>VAR_8, VAR_10&VAR_9, VAR_11&VAR_9, 0, 16, 0, 0, cmpf, chroma_cmpf, VAR_7);

        }else if(USES_LIST(VAR_6, 1)){

            *(uint32_t*)VAR_0->b_back_mv_table[VAR_4]= *(uint32_t*)p->motion_val[1][VAR_5];

            VAR_0->VAR_6[VAR_4]=CANDIDATE_MB_TYPE_BACKWARD;

           

            VAR_10= p->motion_val[1][VAR_5][0]; 

            VAR_11= p->motion_val[1][VAR_5][1];

            VAR_13 = cmp(VAR_0, VAR_10>>VAR_8, VAR_11>>VAR_8, VAR_10&VAR_9, VAR_11&VAR_9, 0, 16, 2, 0, cmpf, chroma_cmpf, VAR_7);

        }else

            VAR_0->VAR_6[VAR_4]=CANDIDATE_MB_TYPE_INTRA;

    }

    return VAR_13;

}

static inline int FUNC_0(MpegEncContext * VAR_0, int VAR_1, int VAR_2, int VAR_3){ MotionEstContext * const c= &VAR_0->me; Picture *p= VAR_0->current_picture_ptr; int VAR_4= VAR_1 + VAR_2*VAR_0->mb_stride; int VAR_5= 2*VAR_1 + 2*VAR_2*VAR_0->b8_stride; int VAR_6= VAR_0->current_picture.VAR_6[VAR_4]; int VAR_7= c->VAR_7; int VAR_8= (VAR_7&FLAG_QPEL) + 1; int VAR_9= (1<<VAR_8)-1; int VAR_10, VAR_11, VAR_12; int VAR_13=0; me_cmp_func cmpf= VAR_0->dsp.sse[0]; me_cmp_func chroma_cmpf= VAR_0->dsp.sse[1]; assert(VAR_3==0 || !USES_LIST(VAR_6, 1)); assert(IS_INTRA(VAR_6) || USES_LIST(VAR_6,0) || USES_LIST(VAR_6,1)); if(IS_INTERLACED(VAR_6)){ int VAR_14= VAR_5  + VAR_0->b8_stride; VAR_0->VAR_6[VAR_4]=CANDIDATE_MB_TYPE_INTRA; c->stride<<=1; c->uvstride<<=1; if(!(VAR_0->VAR_7 & CODEC_FLAG_INTERLACED_ME)){ av_log(c->avctx, AV_LOG_ERROR, "Interlaced macroblock selected but interlaced motion estimation disabled\n"); return -1; } if(USES_LIST(VAR_6, 0)){ int VAR_17= p->ref_index[0][VAR_5 ]; int VAR_17= p->ref_index[0][VAR_14]; assert(VAR_17==0 ||VAR_17==1); assert(VAR_17==0 ||VAR_17==1); init_interlaced_ref(VAR_0, 0); if(VAR_3){ VAR_0->p_field_select_table[0][VAR_4]= VAR_17; VAR_0->p_field_select_table[1][VAR_4]= VAR_17; *(uint32_t*)VAR_0->p_field_mv_table[0][VAR_17][VAR_4]= *(uint32_t*)p->motion_val[0][VAR_5 ]; *(uint32_t*)VAR_0->p_field_mv_table[1][VAR_17][VAR_4]= *(uint32_t*)p->motion_val[0][VAR_14]; VAR_0->VAR_6[VAR_4]=CANDIDATE_MB_TYPE_INTER_I; }else{ VAR_0->b_field_select_table[0][0][VAR_4]= VAR_17; VAR_0->b_field_select_table[0][1][VAR_4]= VAR_17; *(uint32_t*)VAR_0->b_field_mv_table[0][0][VAR_17][VAR_4]= *(uint32_t*)p->motion_val[0][VAR_5 ]; *(uint32_t*)VAR_0->b_field_mv_table[0][1][VAR_17][VAR_4]= *(uint32_t*)p->motion_val[0][VAR_14]; VAR_0->VAR_6[VAR_4]= CANDIDATE_MB_TYPE_FORWARD_I; } VAR_10= p->motion_val[0][VAR_5 ][0]; VAR_11= p->motion_val[0][VAR_5 ][1]; VAR_13 = cmp(VAR_0, VAR_10>>VAR_8, VAR_11>>VAR_8, VAR_10&VAR_9, VAR_11&VAR_9, 0, 8, VAR_17, 0, cmpf, chroma_cmpf, VAR_7); VAR_10= p->motion_val[0][VAR_14][0]; VAR_11= p->motion_val[0][VAR_14][1]; VAR_13+= cmp(VAR_0, VAR_10>>VAR_8, VAR_11>>VAR_8, VAR_10&VAR_9, VAR_11&VAR_9, 0, 8, VAR_17, 1, cmpf, chroma_cmpf, VAR_7); } if(USES_LIST(VAR_6, 1)){ int VAR_17= p->ref_index[1][VAR_5 ]; int VAR_17= p->ref_index[1][VAR_14]; assert(VAR_17==0 ||VAR_17==1); assert(VAR_17==0 ||VAR_17==1); init_interlaced_ref(VAR_0, 2); VAR_0->b_field_select_table[1][0][VAR_4]= VAR_17; VAR_0->b_field_select_table[1][1][VAR_4]= VAR_17; *(uint32_t*)VAR_0->b_field_mv_table[1][0][VAR_17][VAR_4]= *(uint32_t*)p->motion_val[1][VAR_5 ]; *(uint32_t*)VAR_0->b_field_mv_table[1][1][VAR_17][VAR_4]= *(uint32_t*)p->motion_val[1][VAR_14]; if(USES_LIST(VAR_6, 0)){ VAR_0->VAR_6[VAR_4]= CANDIDATE_MB_TYPE_BIDIR_I; }else{ VAR_0->VAR_6[VAR_4]= CANDIDATE_MB_TYPE_BACKWARD_I; } VAR_10= p->motion_val[1][VAR_5 ][0]; VAR_11= p->motion_val[1][VAR_5 ][1]; VAR_13 = cmp(VAR_0, VAR_10>>VAR_8, VAR_11>>VAR_8, VAR_10&VAR_9, VAR_11&VAR_9, 0, 8, VAR_17+2, 0, cmpf, chroma_cmpf, VAR_7); VAR_10= p->motion_val[1][VAR_14][0]; VAR_11= p->motion_val[1][VAR_14][1]; VAR_13+= cmp(VAR_0, VAR_10>>VAR_8, VAR_11>>VAR_8, VAR_10&VAR_9, VAR_11&VAR_9, 0, 8, VAR_17+2, 1, cmpf, chroma_cmpf, VAR_7); } c->stride>>=1; c->uvstride>>=1; }else if(IS_8X8(VAR_6)){ if(!(VAR_0->VAR_7 & CODEC_FLAG_4MV)){ av_log(c->avctx, AV_LOG_ERROR, "4MV macroblock selected but 4MV encoding disabled\n"); return -1; } cmpf= VAR_0->dsp.sse[1]; chroma_cmpf= VAR_0->dsp.sse[1]; init_mv4_ref(c); for(VAR_12=0; VAR_12<4; VAR_12++){ VAR_5= VAR_0->block_index[VAR_12]; VAR_10= p->motion_val[0][VAR_5][0]; VAR_11= p->motion_val[0][VAR_5][1]; VAR_13+= cmp(VAR_0, VAR_10>>VAR_8, VAR_11>>VAR_8, VAR_10&VAR_9, VAR_11&VAR_9, 1, 8, VAR_12, VAR_12, cmpf, chroma_cmpf, VAR_7); } VAR_0->VAR_6[VAR_4]=CANDIDATE_MB_TYPE_INTER4V; }else{ if(USES_LIST(VAR_6, 0)){ if(VAR_3){ *(uint32_t*)VAR_0->p_mv_table[VAR_4]= *(uint32_t*)p->motion_val[0][VAR_5]; VAR_0->VAR_6[VAR_4]=CANDIDATE_MB_TYPE_INTER; }else if(USES_LIST(VAR_6, 1)){ *(uint32_t*)VAR_0->b_bidir_forw_mv_table[VAR_4]= *(uint32_t*)p->motion_val[0][VAR_5]; *(uint32_t*)VAR_0->b_bidir_back_mv_table[VAR_4]= *(uint32_t*)p->motion_val[1][VAR_5]; VAR_0->VAR_6[VAR_4]=CANDIDATE_MB_TYPE_BIDIR; }else{ *(uint32_t*)VAR_0->b_forw_mv_table[VAR_4]= *(uint32_t*)p->motion_val[0][VAR_5]; VAR_0->VAR_6[VAR_4]=CANDIDATE_MB_TYPE_FORWARD; } VAR_10= p->motion_val[0][VAR_5][0]; VAR_11= p->motion_val[0][VAR_5][1]; VAR_13 = cmp(VAR_0, VAR_10>>VAR_8, VAR_11>>VAR_8, VAR_10&VAR_9, VAR_11&VAR_9, 0, 16, 0, 0, cmpf, chroma_cmpf, VAR_7); }else if(USES_LIST(VAR_6, 1)){ *(uint32_t*)VAR_0->b_back_mv_table[VAR_4]= *(uint32_t*)p->motion_val[1][VAR_5]; VAR_0->VAR_6[VAR_4]=CANDIDATE_MB_TYPE_BACKWARD; VAR_10= p->motion_val[1][VAR_5][0]; VAR_11= p->motion_val[1][VAR_5][1]; VAR_13 = cmp(VAR_0, VAR_10>>VAR_8, VAR_11>>VAR_8, VAR_10&VAR_9, VAR_11&VAR_9, 0, 16, 2, 0, cmpf, chroma_cmpf, VAR_7); }else VAR_0->VAR_6[VAR_4]=CANDIDATE_MB_TYPE_INTRA; } return VAR_13; }