static void init_dequant4_coeff_table(H264Context *h){

    int i,j,q,x;

    const int transpose = (h->h264dsp.h264_idct_add != ff_h264_idct_add_c); //FIXME ugly

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

        h->dequant4_coeff[i] = h->dequant4_buffer[i];

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

            if(!memcmp(h->pps.scaling_matrix4[j], h->pps.scaling_matrix4[i], 16*sizeof(uint8_t))){

                h->dequant4_coeff[i] = h->dequant4_buffer[j];

                break;

            }

        }

        if(j<i)

            continue;



        for(q=0; q<52; q++){

            int shift = div6[q] + 2;

            int idx = rem6[q];

            for(x=0; x<16; x++)

                h->dequant4_coeff[i][q][transpose ? (x>>2)|((x<<2)&0xF) : x] =

                    ((uint32_t)dequant4_coeff_init[idx][(x&1) + ((x>>2)&1)] *

                    h->pps.scaling_matrix4[i][x]) << shift;

        }

    }

}

static void init_dequant4_coeff_table(H264Context *h){

    int i,j,q,x;

    const int transpose = (h->h264dsp.h264_idct_add != ff_h264_idct_add_c); 

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

        h->dequant4_coeff[i] = h->dequant4_buffer[i];

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

            if(!memcmp(h->pps.scaling_matrix4[j], h->pps.scaling_matrix4[i], 16*sizeof(uint8_t))){

                h->dequant4_coeff[i] = h->dequant4_buffer[j];

                break;

            }

        }

        if(j<i)

            continue;



        for(q=0; q<52; q++){

            int shift = div6[q] + 2;

            int idx = rem6[q];

            for(x=0; x<16; x++)

                h->dequant4_coeff[i][q][transpose ? (x>>2)|((x<<2)&0xF) : x] =

                    ((uint32_t)dequant4_coeff_init[idx][(x&1) + ((x>>2)&1)] *

                    h->pps.scaling_matrix4[i][x]) << shift;

        }

    }

}

static void FUNC_0(H264Context *VAR_0){

    int VAR_1,VAR_2,VAR_3,VAR_4;

    const int VAR_5 = (VAR_0->h264dsp.h264_idct_add != ff_h264_idct_add_c); 

    for(VAR_1=0; VAR_1<6; VAR_1++ ){

        VAR_0->dequant4_coeff[VAR_1] = VAR_0->dequant4_buffer[VAR_1];

        for(VAR_2=0; VAR_2<VAR_1; VAR_2++){

            if(!memcmp(VAR_0->pps.scaling_matrix4[VAR_2], VAR_0->pps.scaling_matrix4[VAR_1], 16*sizeof(uint8_t))){

                VAR_0->dequant4_coeff[VAR_1] = VAR_0->dequant4_buffer[VAR_2];

                break;

            }

        }

        if(VAR_2<VAR_1)

            continue;



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

            int VAR_6 = div6[VAR_3] + 2;

            int VAR_7 = rem6[VAR_3];

            for(VAR_4=0; VAR_4<16; VAR_4++)

                VAR_0->dequant4_coeff[VAR_1][VAR_3][VAR_5 ? (VAR_4>>2)|((VAR_4<<2)&0xF) : VAR_4] =

                    ((uint32_t)dequant4_coeff_init[VAR_7][(VAR_4&1) + ((VAR_4>>2)&1)] *

                    VAR_0->pps.scaling_matrix4[VAR_1][VAR_4]) << VAR_6;

        }

    }

}

static void FUNC_0(H264Context *VAR_0){ int VAR_1,VAR_2,VAR_3,VAR_4; const int VAR_5 = (VAR_0->h264dsp.h264_idct_add != ff_h264_idct_add_c); for(VAR_1=0; VAR_1<6; VAR_1++ ){ VAR_0->dequant4_coeff[VAR_1] = VAR_0->dequant4_buffer[VAR_1]; for(VAR_2=0; VAR_2<VAR_1; VAR_2++){ if(!memcmp(VAR_0->pps.scaling_matrix4[VAR_2], VAR_0->pps.scaling_matrix4[VAR_1], 16*sizeof(uint8_t))){ VAR_0->dequant4_coeff[VAR_1] = VAR_0->dequant4_buffer[VAR_2]; break; } } if(VAR_2<VAR_1)
continue; for(VAR_3=0; VAR_3<52; VAR_3++){ int VAR_6 = div6[VAR_3] + 2; int VAR_7 = rem6[VAR_3]; for(VAR_4=0; VAR_4<16; VAR_4++) VAR_0->dequant4_coeff[VAR_1][VAR_3][VAR_5 ? (VAR_4>>2)|((VAR_4<<2)&0xF) : VAR_4] =
((uint32_t)dequant4_coeff_init[VAR_7][(VAR_4&1) + ((VAR_4>>2)&1)] *
VAR_0->pps.scaling_matrix4[VAR_1][VAR_4]) << VAR_6; } } }