static void reverse_dc_prediction(Vp3DecodeContext *s,

                                  int first_fragment,

                                  int fragment_width,

                                  int fragment_height)

{



#define PUL 8

#define PU 4

#define PUR 2

#define PL 1



    int x, y;

    int i = first_fragment;



    int predicted_dc;



    /* DC values for the left, up-left, up, and up-right fragments */

    int vl, vul, vu, vur;



    /* indexes for the left, up-left, up, and up-right fragments */

    int l, ul, u, ur;



    /*

     * The 6 fields mean:

     *   0: up-left multiplier

     *   1: up multiplier

     *   2: up-right multiplier

     *   3: left multiplier

     */

    static const int predictor_transform[16][4] = {

        {  0,  0,  0,  0},

        {  0,  0,  0,128},        // PL

        {  0,  0,128,  0},        // PUR

        {  0,  0, 53, 75},        // PUR|PL

        {  0,128,  0,  0},        // PU

        {  0, 64,  0, 64},        // PU|PL

        {  0,128,  0,  0},        // PU|PUR

        {  0,  0, 53, 75},        // PU|PUR|PL

        {128,  0,  0,  0},        // PUL

        {  0,  0,  0,128},        // PUL|PL

        { 64,  0, 64,  0},        // PUL|PUR

        {  0,  0, 53, 75},        // PUL|PUR|PL

        {  0,128,  0,  0},        // PUL|PU

       {-104,116,  0,116},        // PUL|PU|PL

        { 24, 80, 24,  0},        // PUL|PU|PUR

       {-104,116,  0,116}         // PUL|PU|PUR|PL

    };



    /* This table shows which types of blocks can use other blocks for

     * prediction. For example, INTRA is the only mode in this table to

     * have a frame number of 0. That means INTRA blocks can only predict

     * from other INTRA blocks. There are 2 golden frame coding types;

     * blocks encoding in these modes can only predict from other blocks

     * that were encoded with these 1 of these 2 modes. */

    static const unsigned char compatible_frame[8] = {

        1,    /* MODE_INTER_NO_MV */

        0,    /* MODE_INTRA */

        1,    /* MODE_INTER_PLUS_MV */

        1,    /* MODE_INTER_LAST_MV */

        1,    /* MODE_INTER_PRIOR_MV */

        2,    /* MODE_USING_GOLDEN */

        2,    /* MODE_GOLDEN_MV */

        1     /* MODE_INTER_FOUR_MV */

    };

    int current_frame_type;



    /* there is a last DC predictor for each of the 3 frame types */

    short last_dc[3];



    int transform = 0;



    vul = vu = vur = vl = 0;

    last_dc[0] = last_dc[1] = last_dc[2] = 0;



    /* for each fragment row... */

    for (y = 0; y < fragment_height; y++) {



        /* for each fragment in a row... */

        for (x = 0; x < fragment_width; x++, i++) {



            /* reverse prediction if this block was coded */

            if (s->all_fragments[i].coding_method != MODE_COPY) {



                current_frame_type =

                    compatible_frame[s->all_fragments[i].coding_method];



                transform= 0;

                if(x){

                    l= i-1;

                    vl = DC_COEFF(l);

                    if(FRAME_CODED(l) && COMPATIBLE_FRAME(l))

                        transform |= PL;

                }

                if(y){

                    u= i-fragment_width;

                    vu = DC_COEFF(u);

                    if(FRAME_CODED(u) && COMPATIBLE_FRAME(u))

                        transform |= PU;

                    if(x){

                        ul= i-fragment_width-1;

                        vul = DC_COEFF(ul);

                        if(FRAME_CODED(ul) && COMPATIBLE_FRAME(ul))

                            transform |= PUL;

                    }

                    if(x + 1 < fragment_width){

                        ur= i-fragment_width+1;

                        vur = DC_COEFF(ur);

                        if(FRAME_CODED(ur) && COMPATIBLE_FRAME(ur))

                            transform |= PUR;

                    }

                }



                if (transform == 0) {



                    /* if there were no fragments to predict from, use last

                     * DC saved */

                    predicted_dc = last_dc[current_frame_type];

                } else {



                    /* apply the appropriate predictor transform */

                    predicted_dc =

                        (predictor_transform[transform][0] * vul) +

                        (predictor_transform[transform][1] * vu) +

                        (predictor_transform[transform][2] * vur) +

                        (predictor_transform[transform][3] * vl);



                    predicted_dc /= 128;



                    /* check for outranging on the [ul u l] and

                     * [ul u ur l] predictors */

                    if ((transform == 13) || (transform == 15)) {

                        if (FFABS(predicted_dc - vu) > 128)

                            predicted_dc = vu;

                        else if (FFABS(predicted_dc - vl) > 128)

                            predicted_dc = vl;

                        else if (FFABS(predicted_dc - vul) > 128)

                            predicted_dc = vul;

                    }

                }



                /* at long last, apply the predictor */

                if(s->coeffs[i].index){

                    *s->next_coeff= s->coeffs[i];

                    s->coeffs[i].index=0;

                    s->coeffs[i].coeff=0;

                    s->coeffs[i].next= s->next_coeff++;

                }

                s->coeffs[i].coeff += predicted_dc;

                /* save the DC */

                last_dc[current_frame_type] = DC_COEFF(i);

                if(DC_COEFF(i) && !(s->coeff_counts[i]&127)){

                    s->coeff_counts[i]= 129;

//                    s->all_fragments[i].next_coeff= s->next_coeff;

                    s->coeffs[i].next= s->next_coeff;

                    (s->next_coeff++)->next=NULL;

                }

            }

        }

    }

}

static void reverse_dc_prediction(Vp3DecodeContext *s,

                                  int first_fragment,

                                  int fragment_width,

                                  int fragment_height)

{



#define PUL 8

#define PU 4

#define PUR 2

#define PL 1



    int x, y;

    int i = first_fragment;



    int predicted_dc;



    

    int vl, vul, vu, vur;



    

    int l, ul, u, ur;



    













    static const int predictor_transform[16][4] = {

        {  0,  0,  0,  0},

        {  0,  0,  0,128},        

        {  0,  0,128,  0},        

        {  0,  0, 53, 75},        |PL

        {  0,128,  0,  0},        

        {  0, 64,  0, 64},        |PL

        {  0,128,  0,  0},        |PUR

        {  0,  0, 53, 75},        |PUR|PL

        {128,  0,  0,  0},        L

        {  0,  0,  0,128},        L|PL

        { 64,  0, 64,  0},        L|PUR

        {  0,  0, 53, 75},        L|PUR|PL

        {  0,128,  0,  0},        L|PU

       {-104,116,  0,116},        L|PU|PL

        { 24, 80, 24,  0},        L|PU|PUR

       {-104,116,  0,116}         L|PU|PUR|PL

    };



    











    static const unsigned char compatible_frame[8] = {

        1,    

        0,    

        1,    

        1,    

        1,    

        2,    

        2,    

        1     

    };

    int current_frame_type;



    

    short last_dc[3];



    int transform = 0;



    vul = vu = vur = vl = 0;

    last_dc[0] = last_dc[1] = last_dc[2] = 0;



    

    for (y = 0; y < fragment_height; y++) {



        

        for (x = 0; x < fragment_width; x++, i++) {



            

            if (s->all_fragments[i].coding_method != MODE_COPY) {



                current_frame_type =

                    compatible_frame[s->all_fragments[i].coding_method];



                transform= 0;

                if(x){

                    l= i-1;

                    vl = DC_COEFF(l);

                    if(FRAME_CODED(l) && COMPATIBLE_FRAME(l))

                        transform |= PL;

                }

                if(y){

                    u= i-fragment_width;

                    vu = DC_COEFF(u);

                    if(FRAME_CODED(u) && COMPATIBLE_FRAME(u))

                        transform |= PU;

                    if(x){

                        ul= i-fragment_width-1;

                        vul = DC_COEFF(ul);

                        if(FRAME_CODED(ul) && COMPATIBLE_FRAME(ul))

                            transform |= PUL;

                    }

                    if(x + 1 < fragment_width){

                        ur= i-fragment_width+1;

                        vur = DC_COEFF(ur);

                        if(FRAME_CODED(ur) && COMPATIBLE_FRAME(ur))

                            transform |= PUR;

                    }

                }



                if (transform == 0) {



                    



                    predicted_dc = last_dc[current_frame_type];

                } else {



                    

                    predicted_dc =

                        (predictor_transform[transform][0] * vul) +

                        (predictor_transform[transform][1] * vu) +

                        (predictor_transform[transform][2] * vur) +

                        (predictor_transform[transform][3] * vl);



                    predicted_dc /= 128;



                    



                    if ((transform == 13) || (transform == 15)) {

                        if (FFABS(predicted_dc - vu) > 128)

                            predicted_dc = vu;

                        else if (FFABS(predicted_dc - vl) > 128)

                            predicted_dc = vl;

                        else if (FFABS(predicted_dc - vul) > 128)

                            predicted_dc = vul;

                    }

                }



                

                if(s->coeffs[i].index){

                    *s->next_coeff= s->coeffs[i];

                    s->coeffs[i].index=0;

                    s->coeffs[i].coeff=0;

                    s->coeffs[i].next= s->next_coeff++;

                }

                s->coeffs[i].coeff += predicted_dc;

                

                last_dc[current_frame_type] = DC_COEFF(i);

                if(DC_COEFF(i) && !(s->coeff_counts[i]&127)){

                    s->coeff_counts[i]= 129;



                    s->coeffs[i].next= s->next_coeff;

                    (s->next_coeff++)->next=NULL;

                }

            }

        }

    }

}

static void FUNC_0(Vp3DecodeContext *VAR_0,

                                  int VAR_1,

                                  int VAR_2,

                                  int VAR_3)

{



#define PUL 8

#define PU 4

#define PUR 2

#define PL 1



    int VAR_4, VAR_5;

    int VAR_6 = VAR_1;



    int VAR_7;



    

    int VAR_8, VAR_9, VAR_10, VAR_11;



    

    int VAR_12, VAR_13, VAR_14, VAR_15;



    













    static const int VAR_16[16][4] = {

        {  0,  0,  0,  0},

        {  0,  0,  0,128},        

        {  0,  0,128,  0},        

        {  0,  0, 53, 75},        |PL

        {  0,128,  0,  0},        

        {  0, 64,  0, 64},        |PL

        {  0,128,  0,  0},        |PUR

        {  0,  0, 53, 75},        |PUR|PL

        {128,  0,  0,  0},        L

        {  0,  0,  0,128},        L|PL

        { 64,  0, 64,  0},        L|PUR

        {  0,  0, 53, 75},        L|PUR|PL

        {  0,128,  0,  0},        L|PU

       {-104,116,  0,116},        L|PU|PL

        { 24, 80, 24,  0},        L|PU|PUR

       {-104,116,  0,116}         L|PU|PUR|PL

    };



    











    static const unsigned char VAR_17[8] = {

        1,    

        0,    

        1,    

        1,    

        1,    

        2,    

        2,    

        1     

    };

    int VAR_18;



    

    short VAR_19[3];



    int VAR_20 = 0;



    VAR_9 = VAR_10 = VAR_11 = VAR_8 = 0;

    VAR_19[0] = VAR_19[1] = VAR_19[2] = 0;



    

    for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) {



        

        for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++, VAR_6++) {



            

            if (VAR_0->all_fragments[VAR_6].coding_method != MODE_COPY) {



                VAR_18 =

                    VAR_17[VAR_0->all_fragments[VAR_6].coding_method];



                VAR_20= 0;

                if(VAR_4){

                    VAR_12= VAR_6-1;

                    VAR_8 = DC_COEFF(VAR_12);

                    if(FRAME_CODED(VAR_12) && COMPATIBLE_FRAME(VAR_12))

                        VAR_20 |= PL;

                }

                if(VAR_5){

                    VAR_14= VAR_6-VAR_2;

                    VAR_10 = DC_COEFF(VAR_14);

                    if(FRAME_CODED(VAR_14) && COMPATIBLE_FRAME(VAR_14))

                        VAR_20 |= PU;

                    if(VAR_4){

                        VAR_13= VAR_6-VAR_2-1;

                        VAR_9 = DC_COEFF(VAR_13);

                        if(FRAME_CODED(VAR_13) && COMPATIBLE_FRAME(VAR_13))

                            VAR_20 |= PUL;

                    }

                    if(VAR_4 + 1 < VAR_2){

                        VAR_15= VAR_6-VAR_2+1;

                        VAR_11 = DC_COEFF(VAR_15);

                        if(FRAME_CODED(VAR_15) && COMPATIBLE_FRAME(VAR_15))

                            VAR_20 |= PUR;

                    }

                }



                if (VAR_20 == 0) {



                    



                    VAR_7 = VAR_19[VAR_18];

                } else {



                    

                    VAR_7 =

                        (VAR_16[VAR_20][0] * VAR_9) +

                        (VAR_16[VAR_20][1] * VAR_10) +

                        (VAR_16[VAR_20][2] * VAR_11) +

                        (VAR_16[VAR_20][3] * VAR_8);



                    VAR_7 /= 128;



                    



                    if ((VAR_20 == 13) || (VAR_20 == 15)) {

                        if (FFABS(VAR_7 - VAR_10) > 128)

                            VAR_7 = VAR_10;

                        else if (FFABS(VAR_7 - VAR_8) > 128)

                            VAR_7 = VAR_8;

                        else if (FFABS(VAR_7 - VAR_9) > 128)

                            VAR_7 = VAR_9;

                    }

                }



                

                if(VAR_0->coeffs[VAR_6].index){

                    *VAR_0->next_coeff= VAR_0->coeffs[VAR_6];

                    VAR_0->coeffs[VAR_6].index=0;

                    VAR_0->coeffs[VAR_6].coeff=0;

                    VAR_0->coeffs[VAR_6].next= VAR_0->next_coeff++;

                }

                VAR_0->coeffs[VAR_6].coeff += VAR_7;

                

                VAR_19[VAR_18] = DC_COEFF(VAR_6);

                if(DC_COEFF(VAR_6) && !(VAR_0->coeff_counts[VAR_6]&127)){

                    VAR_0->coeff_counts[VAR_6]= 129;



                    VAR_0->coeffs[VAR_6].next= VAR_0->next_coeff;

                    (VAR_0->next_coeff++)->next=NULL;

                }

            }

        }

    }

}

static void FUNC_0(Vp3DecodeContext *VAR_0,
int VAR_1,
int VAR_2,
int VAR_3)
{ #define PUL 8
#define PU 4
#define PUR 2
#define PL 1
int VAR_4, VAR_5; int VAR_6 = VAR_1; int VAR_7; int VAR_8, VAR_9, VAR_10, VAR_11; int VAR_12, VAR_13, VAR_14, VAR_15; static const int VAR_16[16][4] = { {  0,  0,  0,  0}, {  0,  0,  0,128}, {  0,  0,128,  0}, {  0,  0, 53, 75},        |PL {  0,128,  0,  0}, {  0, 64,  0, 64},        |PL {  0,128,  0,  0},        |PUR {  0,  0, 53, 75},        |PUR|PL {128,  0,  0,  0},        L {  0,  0,  0,128},        L|PL { 64,  0, 64,  0},        L|PUR {  0,  0, 53, 75},        L|PUR|PL {  0,128,  0,  0},        L|PU {-104,116,  0,116},        L|PU|PL { 24, 80, 24,  0},        L|PU|PUR {-104,116,  0,116}         L|PU|PUR|PL }; static const unsigned char VAR_17[8] = { 1,
0,
1,
1,
1,
2,
2,
1
}; int VAR_18; short VAR_19[3]; int VAR_20 = 0; VAR_9 = VAR_10 = VAR_11 = VAR_8 = 0; VAR_19[0] = VAR_19[1] = VAR_19[2] = 0; for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) { for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++, VAR_6++) { if (VAR_0->all_fragments[VAR_6].coding_method != MODE_COPY) { VAR_18 =
VAR_17[VAR_0->all_fragments[VAR_6].coding_method]; VAR_20= 0; if(VAR_4){ VAR_12= VAR_6-1; VAR_8 = DC_COEFF(VAR_12); if(FRAME_CODED(VAR_12) && COMPATIBLE_FRAME(VAR_12))
VAR_20 |= PL; } if(VAR_5){ VAR_14= VAR_6-VAR_2; VAR_10 = DC_COEFF(VAR_14); if(FRAME_CODED(VAR_14) && COMPATIBLE_FRAME(VAR_14))
VAR_20 |= PU; if(VAR_4){ VAR_13= VAR_6-VAR_2-1; VAR_9 = DC_COEFF(VAR_13); if(FRAME_CODED(VAR_13) && COMPATIBLE_FRAME(VAR_13))
VAR_20 |= PUL; } if(VAR_4 + 1 < VAR_2){ VAR_15= VAR_6-VAR_2+1; VAR_11 = DC_COEFF(VAR_15); if(FRAME_CODED(VAR_15) && COMPATIBLE_FRAME(VAR_15))
VAR_20 |= PUR; } } if (VAR_20 == 0) { VAR_7 = VAR_19[VAR_18]; } else { VAR_7 =
(VAR_16[VAR_20][0] * VAR_9) +
(VAR_16[VAR_20][1] * VAR_10) +
(VAR_16[VAR_20][2] * VAR_11) +
(VAR_16[VAR_20][3] * VAR_8); VAR_7 /= 128; if ((VAR_20 == 13) || (VAR_20 == 15)) { if (FFABS(VAR_7 - VAR_10) > 128)
VAR_7 = VAR_10; else if (FFABS(VAR_7 - VAR_8) > 128)
VAR_7 = VAR_8; else if (FFABS(VAR_7 - VAR_9) > 128)
VAR_7 = VAR_9; } } if(VAR_0->coeffs[VAR_6].index){ *VAR_0->next_coeff= VAR_0->coeffs[VAR_6]; VAR_0->coeffs[VAR_6].index=0; VAR_0->coeffs[VAR_6].coeff=0; VAR_0->coeffs[VAR_6].next= VAR_0->next_coeff++; } VAR_0->coeffs[VAR_6].coeff += VAR_7; VAR_19[VAR_18] = DC_COEFF(VAR_6); if(DC_COEFF(VAR_6) && !(VAR_0->coeff_counts[VAR_6]&127)){ VAR_0->coeff_counts[VAR_6]= 129; VAR_0->coeffs[VAR_6].next= VAR_0->next_coeff; (VAR_0->next_coeff++)->next=NULL; } } } } }