void ff_fix_long_p_mvs(MpegEncContext * s)

{

    const int f_code= s->f_code;

    int y;

    UINT8 * fcode_tab= s->fcode_tab;



    /* clip / convert to intra 16x16 type MVs */

    for(y=0; y<s->mb_height; y++){

        int x;

        int xy= (y+1)* (s->mb_width+2)+1;

        int i= y*s->mb_width;

        for(x=0; x<s->mb_width; x++){

            if(s->mb_type[i]&MB_TYPE_INTER){

                if(   fcode_tab[s->p_mv_table[xy][0] + MAX_MV] > f_code

                   || fcode_tab[s->p_mv_table[xy][0] + MAX_MV] == 0

                   || fcode_tab[s->p_mv_table[xy][1] + MAX_MV] > f_code

                   || fcode_tab[s->p_mv_table[xy][1] + MAX_MV] == 0 ){

                    s->mb_type[i] &= ~MB_TYPE_INTER;

                    s->mb_type[i] |= MB_TYPE_INTRA;

                    s->p_mv_table[xy][0] = 0;

                    s->p_mv_table[xy][1] = 0;

                }

            }

            xy++;

            i++;

        }

    }



    if(s->flags&CODEC_FLAG_4MV){

        const int wrap= 2+ s->mb_width*2;



        /* clip / convert to intra 8x8 type MVs */

        for(y=0; y<s->mb_height; y++){

            int xy= (y*2 + 1)*wrap + 1;

            int i= y*s->mb_width;

            int x;



            for(x=0; x<s->mb_width; x++){

                if(s->mb_type[i]&MB_TYPE_INTER4V){

                    int block;

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

                        int off= (block& 1) + (block>>1)*wrap;

                        int mx= s->motion_val[ xy + off ][0];

                        int my= s->motion_val[ xy + off ][1];



                        if(   fcode_tab[mx + MAX_MV] > f_code

                           || fcode_tab[mx + MAX_MV] == 0

                           || fcode_tab[my + MAX_MV] > f_code

                           || fcode_tab[my + MAX_MV] == 0 ){

                            s->mb_type[i] &= ~MB_TYPE_INTER4V;

                            s->mb_type[i] |= MB_TYPE_INTRA;

                        }

                    }

                    xy+=2;

                    i++;

                }

            }

        }

    }

}

void ff_fix_long_p_mvs(MpegEncContext * s)

{

    const int f_code= s->f_code;

    int y;

    UINT8 * fcode_tab= s->fcode_tab;



    

    for(y=0; y<s->mb_height; y++){

        int x;

        int xy= (y+1)* (s->mb_width+2)+1;

        int i= y*s->mb_width;

        for(x=0; x<s->mb_width; x++){

            if(s->mb_type[i]&MB_TYPE_INTER){

                if(   fcode_tab[s->p_mv_table[xy][0] + MAX_MV] > f_code

                   || fcode_tab[s->p_mv_table[xy][0] + MAX_MV] == 0

                   || fcode_tab[s->p_mv_table[xy][1] + MAX_MV] > f_code

                   || fcode_tab[s->p_mv_table[xy][1] + MAX_MV] == 0 ){

                    s->mb_type[i] &= ~MB_TYPE_INTER;

                    s->mb_type[i] |= MB_TYPE_INTRA;

                    s->p_mv_table[xy][0] = 0;

                    s->p_mv_table[xy][1] = 0;

                }

            }

            xy++;

            i++;

        }

    }



    if(s->flags&CODEC_FLAG_4MV){

        const int wrap= 2+ s->mb_width*2;



        

        for(y=0; y<s->mb_height; y++){

            int xy= (y*2 + 1)*wrap + 1;

            int i= y*s->mb_width;

            int x;



            for(x=0; x<s->mb_width; x++){

                if(s->mb_type[i]&MB_TYPE_INTER4V){

                    int block;

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

                        int off= (block& 1) + (block>>1)*wrap;

                        int mx= s->motion_val[ xy + off ][0];

                        int my= s->motion_val[ xy + off ][1];



                        if(   fcode_tab[mx + MAX_MV] > f_code

                           || fcode_tab[mx + MAX_MV] == 0

                           || fcode_tab[my + MAX_MV] > f_code

                           || fcode_tab[my + MAX_MV] == 0 ){

                            s->mb_type[i] &= ~MB_TYPE_INTER4V;

                            s->mb_type[i] |= MB_TYPE_INTRA;

                        }

                    }

                    xy+=2;

                    i++;

                }

            }

        }

    }

}

void FUNC_0(MpegEncContext * VAR_0)

{

    const int VAR_1= VAR_0->VAR_1;

    int VAR_2;

    UINT8 * fcode_tab= VAR_0->fcode_tab;



    

    for(VAR_2=0; VAR_2<VAR_0->mb_height; VAR_2++){

        int x;

        int xy= (VAR_2+1)* (VAR_0->mb_width+2)+1;

        int i= VAR_2*VAR_0->mb_width;

        for(x=0; x<VAR_0->mb_width; x++){

            if(VAR_0->mb_type[i]&MB_TYPE_INTER){

                if(   fcode_tab[VAR_0->p_mv_table[xy][0] + MAX_MV] > VAR_1

                   || fcode_tab[VAR_0->p_mv_table[xy][0] + MAX_MV] == 0

                   || fcode_tab[VAR_0->p_mv_table[xy][1] + MAX_MV] > VAR_1

                   || fcode_tab[VAR_0->p_mv_table[xy][1] + MAX_MV] == 0 ){

                    VAR_0->mb_type[i] &= ~MB_TYPE_INTER;

                    VAR_0->mb_type[i] |= MB_TYPE_INTRA;

                    VAR_0->p_mv_table[xy][0] = 0;

                    VAR_0->p_mv_table[xy][1] = 0;

                }

            }

            xy++;

            i++;

        }

    }



    if(VAR_0->flags&CODEC_FLAG_4MV){

        const int VAR_3= 2+ VAR_0->mb_width*2;



        

        for(VAR_2=0; VAR_2<VAR_0->mb_height; VAR_2++){

            int xy= (VAR_2*2 + 1)*VAR_3 + 1;

            int i= VAR_2*VAR_0->mb_width;

            int x;



            for(x=0; x<VAR_0->mb_width; x++){

                if(VAR_0->mb_type[i]&MB_TYPE_INTER4V){

                    int block;

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

                        int off= (block& 1) + (block>>1)*VAR_3;

                        int mx= VAR_0->motion_val[ xy + off ][0];

                        int my= VAR_0->motion_val[ xy + off ][1];



                        if(   fcode_tab[mx + MAX_MV] > VAR_1

                           || fcode_tab[mx + MAX_MV] == 0

                           || fcode_tab[my + MAX_MV] > VAR_1

                           || fcode_tab[my + MAX_MV] == 0 ){

                            VAR_0->mb_type[i] &= ~MB_TYPE_INTER4V;

                            VAR_0->mb_type[i] |= MB_TYPE_INTRA;

                        }

                    }

                    xy+=2;

                    i++;

                }

            }

        }

    }

}

void FUNC_0(MpegEncContext * VAR_0)
{ const int VAR_1= VAR_0->VAR_1; int VAR_2; UINT8 * fcode_tab= VAR_0->fcode_tab; for(VAR_2=0; VAR_2<VAR_0->mb_height; VAR_2++){ int x; int xy= (VAR_2+1)* (VAR_0->mb_width+2)+1; int i= VAR_2*VAR_0->mb_width; for(x=0; x<VAR_0->mb_width; x++){ if(VAR_0->mb_type[i]&MB_TYPE_INTER){ if(   fcode_tab[VAR_0->p_mv_table[xy][0] + MAX_MV] > VAR_1
|| fcode_tab[VAR_0->p_mv_table[xy][0] + MAX_MV] == 0
|| fcode_tab[VAR_0->p_mv_table[xy][1] + MAX_MV] > VAR_1
|| fcode_tab[VAR_0->p_mv_table[xy][1] + MAX_MV] == 0 ){ VAR_0->mb_type[i] &= ~MB_TYPE_INTER; VAR_0->mb_type[i] |= MB_TYPE_INTRA; VAR_0->p_mv_table[xy][0] = 0; VAR_0->p_mv_table[xy][1] = 0; } } xy++; i++; } } if(VAR_0->flags&CODEC_FLAG_4MV){ const int VAR_3= 2+ VAR_0->mb_width*2; for(VAR_2=0; VAR_2<VAR_0->mb_height; VAR_2++){ int xy= (VAR_2*2 + 1)*VAR_3 + 1; int i= VAR_2*VAR_0->mb_width; int x; for(x=0; x<VAR_0->mb_width; x++){ if(VAR_0->mb_type[i]&MB_TYPE_INTER4V){ int block; for(block=0; block<4; block++){ int off= (block& 1) + (block>>1)*VAR_3; int mx= VAR_0->motion_val[ xy + off ][0]; int my= VAR_0->motion_val[ xy + off ][1]; if(   fcode_tab[mx + MAX_MV] > VAR_1
|| fcode_tab[mx + MAX_MV] == 0
|| fcode_tab[my + MAX_MV] > VAR_1
|| fcode_tab[my + MAX_MV] == 0 ){ VAR_0->mb_type[i] &= ~MB_TYPE_INTER4V; VAR_0->mb_type[i] |= MB_TYPE_INTRA; } } xy+=2; i++; } } } } }