int ff_msmpeg4_pred_dc(MpegEncContext *s, int n,

                       int16_t **dc_val_ptr, int *dir_ptr)

{

    int a, b, c, wrap, pred, scale;

    int16_t *dc_val;



    /* find prediction */

    if (n < 4) {

        scale = s->y_dc_scale;

    } else {

        scale = s->c_dc_scale;

    }



    wrap = s->block_wrap[n];

    dc_val= s->dc_val[0] + s->block_index[n];



    /* B C

     * A X

     */

    a = dc_val[ - 1];

    b = dc_val[ - 1 - wrap];

    c = dc_val[ - wrap];



    if(s->first_slice_line && (n&2)==0 && s->msmpeg4_version<4){

        b=c=1024;

    }



    /* XXX: the following solution consumes divisions, but it does not

       necessitate to modify mpegvideo.c. The problem comes from the

       fact they decided to store the quantized DC (which would lead

       to problems if Q could vary !) */

#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE

    __asm__ volatile(

        "movl %3, %%eax         \n\t"

        "shrl $1, %%eax         \n\t"

        "addl %%eax, %2         \n\t"

        "addl %%eax, %1         \n\t"

        "addl %0, %%eax         \n\t"

        "mull %4                \n\t"

        "movl %%edx, %0         \n\t"

        "movl %1, %%eax         \n\t"

        "mull %4                \n\t"

        "movl %%edx, %1         \n\t"

        "movl %2, %%eax         \n\t"

        "mull %4                \n\t"

        "movl %%edx, %2         \n\t"

        : "+b" (a), "+c" (b), "+D" (c)

        : "g" (scale), "S" (ff_inverse[scale])

        : "%eax", "%edx"

    );

#else

    /* Divisions are costly everywhere; optimize the most common case. */

    if (scale == 8) {

        a = (a + (8 >> 1)) / 8;

        b = (b + (8 >> 1)) / 8;

        c = (c + (8 >> 1)) / 8;

    } else {

        a = FASTDIV((a + (scale >> 1)), scale);

        b = FASTDIV((b + (scale >> 1)), scale);

        c = FASTDIV((c + (scale >> 1)), scale);

    }

#endif

    /* XXX: WARNING: they did not choose the same test as MPEG4. This

       is very important ! */

    if(s->msmpeg4_version>3){

        if(s->inter_intra_pred){

            uint8_t *dest;

            int wrap;



            if(n==1){

                pred=a;

                *dir_ptr = 0;

            }else if(n==2){

                pred=c;

                *dir_ptr = 1;

            }else if(n==3){

                if (abs(a - b) < abs(b - c)) {

                    pred = c;

                    *dir_ptr = 1;

                } else {

                    pred = a;

                    *dir_ptr = 0;

                }

            }else{

                if(n<4){

                    wrap= s->linesize;

                    dest= s->current_picture.f.data[0] + (((n >> 1) + 2*s->mb_y) * 8*  wrap ) + ((n & 1) + 2*s->mb_x) * 8;

                }else{

                    wrap= s->uvlinesize;

                    dest= s->current_picture.f.data[n - 3] + (s->mb_y * 8 * wrap) + s->mb_x * 8;

                }

                if(s->mb_x==0) a= (1024 + (scale>>1))/scale;

                else           a= get_dc(dest-8, wrap, scale*8);

                if(s->mb_y==0) c= (1024 + (scale>>1))/scale;

                else           c= get_dc(dest-8*wrap, wrap, scale*8);



                if (s->h263_aic_dir==0) {

                    pred= a;

                    *dir_ptr = 0;

                }else if (s->h263_aic_dir==1) {

                    if(n==0){

                        pred= c;

                        *dir_ptr = 1;

                    }else{

                        pred= a;

                        *dir_ptr = 0;

                    }

                }else if (s->h263_aic_dir==2) {

                    if(n==0){

                        pred= a;

                        *dir_ptr = 0;

                    }else{

                        pred= c;

                        *dir_ptr = 1;

                    }

                } else {

                    pred= c;

                    *dir_ptr = 1;

                }

            }

        }else{

            if (abs(a - b) < abs(b - c)) {

                pred = c;

                *dir_ptr = 1;

            } else {

                pred = a;

                *dir_ptr = 0;

            }

        }

    }else{

        if (abs(a - b) <= abs(b - c)) {

            pred = c;

            *dir_ptr = 1;

        } else {

            pred = a;

            *dir_ptr = 0;

        }

    }



    /* update predictor */

    *dc_val_ptr = &dc_val[0];

    return pred;

}

int ff_msmpeg4_pred_dc(MpegEncContext *s, int n,

                       int16_t **dc_val_ptr, int *dir_ptr)

{

    int a, b, c, wrap, pred, scale;

    int16_t *dc_val;



    

    if (n < 4) {

        scale = s->y_dc_scale;

    } else {

        scale = s->c_dc_scale;

    }



    wrap = s->block_wrap[n];

    dc_val= s->dc_val[0] + s->block_index[n];



    





    a = dc_val[ - 1];

    b = dc_val[ - 1 - wrap];

    c = dc_val[ - wrap];



    if(s->first_slice_line && (n&2)==0 && s->msmpeg4_version<4){

        b=c=1024;

    }



    







#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE

    __asm__ volatile(

        "movl %3, %%eax         \n\t"

        "shrl $1, %%eax         \n\t"

        "addl %%eax, %2         \n\t"

        "addl %%eax, %1         \n\t"

        "addl %0, %%eax         \n\t"

        "mull %4                \n\t"

        "movl %%edx, %0         \n\t"

        "movl %1, %%eax         \n\t"

        "mull %4                \n\t"

        "movl %%edx, %1         \n\t"

        "movl %2, %%eax         \n\t"

        "mull %4                \n\t"

        "movl %%edx, %2         \n\t"

        : "+b" (a), "+c" (b), "+D" (c)

        : "g" (scale), "S" (ff_inverse[scale])

        : "%eax", "%edx"

    );

#else

    

    if (scale == 8) {

        a = (a + (8 >> 1)) / 8;

        b = (b + (8 >> 1)) / 8;

        c = (c + (8 >> 1)) / 8;

    } else {

        a = FASTDIV((a + (scale >> 1)), scale);

        b = FASTDIV((b + (scale >> 1)), scale);

        c = FASTDIV((c + (scale >> 1)), scale);

    }

#endif

    



    if(s->msmpeg4_version>3){

        if(s->inter_intra_pred){

            uint8_t *dest;

            int wrap;



            if(n==1){

                pred=a;

                *dir_ptr = 0;

            }else if(n==2){

                pred=c;

                *dir_ptr = 1;

            }else if(n==3){

                if (abs(a - b) < abs(b - c)) {

                    pred = c;

                    *dir_ptr = 1;

                } else {

                    pred = a;

                    *dir_ptr = 0;

                }

            }else{

                if(n<4){

                    wrap= s->linesize;

                    dest= s->current_picture.f.data[0] + (((n >> 1) + 2*s->mb_y) * 8*  wrap ) + ((n & 1) + 2*s->mb_x) * 8;

                }else{

                    wrap= s->uvlinesize;

                    dest= s->current_picture.f.data[n - 3] + (s->mb_y * 8 * wrap) + s->mb_x * 8;

                }

                if(s->mb_x==0) a= (1024 + (scale>>1))/scale;

                else           a= get_dc(dest-8, wrap, scale*8);

                if(s->mb_y==0) c= (1024 + (scale>>1))/scale;

                else           c= get_dc(dest-8*wrap, wrap, scale*8);



                if (s->h263_aic_dir==0) {

                    pred= a;

                    *dir_ptr = 0;

                }else if (s->h263_aic_dir==1) {

                    if(n==0){

                        pred= c;

                        *dir_ptr = 1;

                    }else{

                        pred= a;

                        *dir_ptr = 0;

                    }

                }else if (s->h263_aic_dir==2) {

                    if(n==0){

                        pred= a;

                        *dir_ptr = 0;

                    }else{

                        pred= c;

                        *dir_ptr = 1;

                    }

                } else {

                    pred= c;

                    *dir_ptr = 1;

                }

            }

        }else{

            if (abs(a - b) < abs(b - c)) {

                pred = c;

                *dir_ptr = 1;

            } else {

                pred = a;

                *dir_ptr = 0;

            }

        }

    }else{

        if (abs(a - b) <= abs(b - c)) {

            pred = c;

            *dir_ptr = 1;

        } else {

            pred = a;

            *dir_ptr = 0;

        }

    }



    

    *dc_val_ptr = &dc_val[0];

    return pred;

}

                    dest= s->current_picture.f.data[0] + (((n >> 1) + 2*s->mb_y) * 8*  wrap ) + ((n & 1) + 2*s->mb_x) * 8;                     dest= s->current_picture.f.data[n - 3] + (s->mb_y * 8 * wrap) + s->mb_x * 8;
int FUNC_0(MpegEncContext *VAR_0, int VAR_1,

                       int16_t **VAR_2, int *VAR_3)

{

    int VAR_4, VAR_5, VAR_6, VAR_10, VAR_8, VAR_9;

    int16_t *dc_val;



    

    if (VAR_1 < 4) {

        VAR_9 = VAR_0->y_dc_scale;

    } else {

        VAR_9 = VAR_0->c_dc_scale;

    }



    VAR_10 = VAR_0->block_wrap[VAR_1];

    dc_val= VAR_0->dc_val[0] + VAR_0->block_index[VAR_1];



    





    VAR_4 = dc_val[ - 1];

    VAR_5 = dc_val[ - 1 - VAR_10];

    VAR_6 = dc_val[ - VAR_10];



    if(VAR_0->first_slice_line && (VAR_1&2)==0 && VAR_0->msmpeg4_version<4){

        VAR_5=VAR_6=1024;

    }



    







#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE

    __asm__ volatile(

        "movl %3, %%eax         \VAR_1\t"

        "shrl $1, %%eax         \VAR_1\t"

        "addl %%eax, %2         \VAR_1\t"

        "addl %%eax, %1         \VAR_1\t"

        "addl %0, %%eax         \VAR_1\t"

        "mull %4                \VAR_1\t"

        "movl %%edx, %0         \VAR_1\t"

        "movl %1, %%eax         \VAR_1\t"

        "mull %4                \VAR_1\t"

        "movl %%edx, %1         \VAR_1\t"

        "movl %2, %%eax         \VAR_1\t"

        "mull %4                \VAR_1\t"

        "movl %%edx, %2         \VAR_1\t"

        : "+VAR_5" (VAR_4), "+VAR_6" (VAR_5), "+D" (VAR_6)

        : "g" (VAR_9), "S" (ff_inverse[VAR_9])

        : "%eax", "%edx"

    );

#else

    

    if (VAR_9 == 8) {

        VAR_4 = (VAR_4 + (8 >> 1)) / 8;

        VAR_5 = (VAR_5 + (8 >> 1)) / 8;

        VAR_6 = (VAR_6 + (8 >> 1)) / 8;

    } else {

        VAR_4 = FASTDIV((VAR_4 + (VAR_9 >> 1)), VAR_9);

        VAR_5 = FASTDIV((VAR_5 + (VAR_9 >> 1)), VAR_9);

        VAR_6 = FASTDIV((VAR_6 + (VAR_9 >> 1)), VAR_9);

    }

#endif

    



    if(VAR_0->msmpeg4_version>3){

        if(VAR_0->inter_intra_pred){

            uint8_t *dest;

            int VAR_10;



            if(VAR_1==1){

                VAR_8=VAR_4;

                *VAR_3 = 0;

            }else if(VAR_1==2){

                VAR_8=VAR_6;

                *VAR_3 = 1;

            }else if(VAR_1==3){

                if (abs(VAR_4 - VAR_5) < abs(VAR_5 - VAR_6)) {

                    VAR_8 = VAR_6;

                    *VAR_3 = 1;

                } else {

                    VAR_8 = VAR_4;

                    *VAR_3 = 0;

                }

            }else{

                if(VAR_1<4){

                    VAR_10= VAR_0->linesize;

                    dest= VAR_0->current_picture.f.data[0] + (((VAR_1 >> 1) + 2*VAR_0->mb_y) * 8*  VAR_10 ) + ((VAR_1 & 1) + 2*VAR_0->mb_x) * 8;

                }else{

                    VAR_10= VAR_0->uvlinesize;

                    dest= VAR_0->current_picture.f.data[VAR_1 - 3] + (VAR_0->mb_y * 8 * VAR_10) + VAR_0->mb_x * 8;

                }

                if(VAR_0->mb_x==0) VAR_4= (1024 + (VAR_9>>1))/VAR_9;

                else           VAR_4= get_dc(dest-8, VAR_10, VAR_9*8);

                if(VAR_0->mb_y==0) VAR_6= (1024 + (VAR_9>>1))/VAR_9;

                else           VAR_6= get_dc(dest-8*VAR_10, VAR_10, VAR_9*8);



                if (VAR_0->h263_aic_dir==0) {

                    VAR_8= VAR_4;

                    *VAR_3 = 0;

                }else if (VAR_0->h263_aic_dir==1) {

                    if(VAR_1==0){

                        VAR_8= VAR_6;

                        *VAR_3 = 1;

                    }else{

                        VAR_8= VAR_4;

                        *VAR_3 = 0;

                    }

                }else if (VAR_0->h263_aic_dir==2) {

                    if(VAR_1==0){

                        VAR_8= VAR_4;

                        *VAR_3 = 0;

                    }else{

                        VAR_8= VAR_6;

                        *VAR_3 = 1;

                    }

                } else {

                    VAR_8= VAR_6;

                    *VAR_3 = 1;

                }

            }

        }else{

            if (abs(VAR_4 - VAR_5) < abs(VAR_5 - VAR_6)) {

                VAR_8 = VAR_6;

                *VAR_3 = 1;

            } else {

                VAR_8 = VAR_4;

                *VAR_3 = 0;

            }

        }

    }else{

        if (abs(VAR_4 - VAR_5) <= abs(VAR_5 - VAR_6)) {

            VAR_8 = VAR_6;

            *VAR_3 = 1;

        } else {

            VAR_8 = VAR_4;

            *VAR_3 = 0;

        }

    }



    

    *VAR_2 = &dc_val[0];

    return VAR_8;

}

int FUNC_0(MpegEncContext *VAR_0, int VAR_1,
int16_t **VAR_2, int *VAR_3)
{ int VAR_4, VAR_5, VAR_6, VAR_10, VAR_8, VAR_9; int16_t *dc_val; if (VAR_1 < 4) { VAR_9 = VAR_0->y_dc_scale; } else { VAR_9 = VAR_0->c_dc_scale; } VAR_10 = VAR_0->block_wrap[VAR_1]; dc_val= VAR_0->dc_val[0] + VAR_0->block_index[VAR_1]; VAR_4 = dc_val[ - 1]; VAR_5 = dc_val[ - 1 - VAR_10]; VAR_6 = dc_val[ - VAR_10]; if(VAR_0->first_slice_line && (VAR_1&2)==0 && VAR_0->msmpeg4_version<4){ VAR_5=VAR_6=1024; } #if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE
__asm__ volatile(
"movl %3, %%eax         \VAR_1\t"
"shrl $1, %%eax         \VAR_1\t"
"addl %%eax, %2         \VAR_1\t"
"addl %%eax, %1         \VAR_1\t"
"addl %0, %%eax         \VAR_1\t"
"mull %4                \VAR_1\t"
"movl %%edx, %0         \VAR_1\t"
"movl %1, %%eax         \VAR_1\t"
"mull %4                \VAR_1\t"
"movl %%edx, %1         \VAR_1\t"
"movl %2, %%eax         \VAR_1\t"
"mull %4                \VAR_1\t"
"movl %%edx, %2         \VAR_1\t"
: "+VAR_5" (VAR_4), "+VAR_6" (VAR_5), "+D" (VAR_6)
: "g" (VAR_9), "S" (ff_inverse[VAR_9])
: "%eax", "%edx"
); #else
if (VAR_9 == 8) { VAR_4 = (VAR_4 + (8 >> 1)) / 8; VAR_5 = (VAR_5 + (8 >> 1)) / 8; VAR_6 = (VAR_6 + (8 >> 1)) / 8; } else { VAR_4 = FASTDIV((VAR_4 + (VAR_9 >> 1)), VAR_9); VAR_5 = FASTDIV((VAR_5 + (VAR_9 >> 1)), VAR_9); VAR_6 = FASTDIV((VAR_6 + (VAR_9 >> 1)), VAR_9); } #endif
if(VAR_0->msmpeg4_version>3){ if(VAR_0->inter_intra_pred){ uint8_t *dest; int VAR_10; if(VAR_1==1){ VAR_8=VAR_4; *VAR_3 = 0; }else if(VAR_1==2){ VAR_8=VAR_6; *VAR_3 = 1; }else if(VAR_1==3){ if (abs(VAR_4 - VAR_5) < abs(VAR_5 - VAR_6)) { VAR_8 = VAR_6; *VAR_3 = 1; } else { VAR_8 = VAR_4; *VAR_3 = 0; } }else{ if(VAR_1<4){ VAR_10= VAR_0->linesize; dest= VAR_0->current_picture.f.data[0] + (((VAR_1 >> 1) + 2*VAR_0->mb_y) * 8*  VAR_10 ) + ((VAR_1 & 1) + 2*VAR_0->mb_x) * 8; }else{ VAR_10= VAR_0->uvlinesize; dest= VAR_0->current_picture.f.data[VAR_1 - 3] + (VAR_0->mb_y * 8 * VAR_10) + VAR_0->mb_x * 8; } if(VAR_0->mb_x==0) VAR_4= (1024 + (VAR_9>>1))/VAR_9; else           VAR_4= get_dc(dest-8, VAR_10, VAR_9*8); if(VAR_0->mb_y==0) VAR_6= (1024 + (VAR_9>>1))/VAR_9; else           VAR_6= get_dc(dest-8*VAR_10, VAR_10, VAR_9*8); if (VAR_0->h263_aic_dir==0) { VAR_8= VAR_4; *VAR_3 = 0; }else if (VAR_0->h263_aic_dir==1) { if(VAR_1==0){ VAR_8= VAR_6; *VAR_3 = 1; }else{ VAR_8= VAR_4; *VAR_3 = 0; } }else if (VAR_0->h263_aic_dir==2) { if(VAR_1==0){ VAR_8= VAR_4; *VAR_3 = 0; }else{ VAR_8= VAR_6; *VAR_3 = 1; } } else { VAR_8= VAR_6; *VAR_3 = 1; } } }else{ if (abs(VAR_4 - VAR_5) < abs(VAR_5 - VAR_6)) { VAR_8 = VAR_6; *VAR_3 = 1; } else { VAR_8 = VAR_4; *VAR_3 = 0; } } }else{ if (abs(VAR_4 - VAR_5) <= abs(VAR_5 - VAR_6)) { VAR_8 = VAR_6; *VAR_3 = 1; } else { VAR_8 = VAR_4; *VAR_3 = 0; } } *VAR_2 = &dc_val[0]; return VAR_8; }