static void convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[2][64],

                           const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra)

{

    int qscale;

    int shift=0;



    for(qscale=qmin; qscale<=qmax; qscale++){

        int i;

        if (dsp->fdct == ff_jpeg_fdct_islow 

#ifdef FAAN_POSTSCALE

            || dsp->fdct == ff_faandct

#endif

            ) {

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

                const int j= dsp->idct_permutation[i];

                /* 16 <= qscale * quant_matrix[i] <= 7905 */

                /* 19952         <= aanscales[i] * qscale * quant_matrix[i]           <= 249205026 */

                /* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */

                /* 3444240       >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */

                

                qmat[qscale][i] = (int)((uint64_t_C(1) << QMAT_SHIFT) / 

                                (qscale * quant_matrix[j]));

            }

        } else if (dsp->fdct == fdct_ifast

#ifndef FAAN_POSTSCALE

                   || dsp->fdct == ff_faandct

#endif

                   ) {

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

                const int j= dsp->idct_permutation[i];

                /* 16 <= qscale * quant_matrix[i] <= 7905 */

                /* 19952         <= aanscales[i] * qscale * quant_matrix[i]           <= 249205026 */

                /* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */

                /* 3444240       >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */

                

                qmat[qscale][i] = (int)((uint64_t_C(1) << (QMAT_SHIFT + 14)) / 

                                (aanscales[i] * qscale * quant_matrix[j]));

            }

        } else {

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

                const int j= dsp->idct_permutation[i];

                /* We can safely suppose that 16 <= quant_matrix[i] <= 255

                   So 16           <= qscale * quant_matrix[i]             <= 7905

                   so (1<<19) / 16 >= (1<<19) / (qscale * quant_matrix[i]) >= (1<<19) / 7905

                   so 32768        >= (1<<19) / (qscale * quant_matrix[i]) >= 67

                */

                qmat[qscale][i] = (int)((uint64_t_C(1) << QMAT_SHIFT) / (qscale * quant_matrix[j]));

//                qmat  [qscale][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[i]);

                qmat16[qscale][0][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[j]);



                if(qmat16[qscale][0][i]==0 || qmat16[qscale][0][i]==128*256) qmat16[qscale][0][i]=128*256-1;

                qmat16[qscale][1][i]= ROUNDED_DIV(bias<<(16-QUANT_BIAS_SHIFT), qmat16[qscale][0][i]);

            }

        }

        

        for(i=intra; i<64; i++){

            while(((8191LL * qmat[qscale][i]) >> shift) > INT_MAX){ 

                shift++;

            }

        }

    }

    if(shift){

        av_log(NULL, AV_LOG_INFO, "Warning, QMAT_SHIFT is larger then %d, overflows possible\n", QMAT_SHIFT - shift);

    }

}

static void convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[2][64],

                           const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra)

{

    int qscale;

    int shift=0;



    for(qscale=qmin; qscale<=qmax; qscale++){

        int i;

        if (dsp->fdct == ff_jpeg_fdct_islow 

#ifdef FAAN_POSTSCALE

            || dsp->fdct == ff_faandct

#endif

            ) {

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

                const int j= dsp->idct_permutation[i];

                

                

                

                

                

                qmat[qscale][i] = (int)((uint64_t_C(1) << QMAT_SHIFT) / 

                                (qscale * quant_matrix[j]));

            }

        } else if (dsp->fdct == fdct_ifast

#ifndef FAAN_POSTSCALE

                   || dsp->fdct == ff_faandct

#endif

                   ) {

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

                const int j= dsp->idct_permutation[i];

                

                

                

                

                

                qmat[qscale][i] = (int)((uint64_t_C(1) << (QMAT_SHIFT + 14)) / 

                                (aanscales[i] * qscale * quant_matrix[j]));

            }

        } else {

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

                const int j= dsp->idct_permutation[i];

                









                qmat[qscale][i] = (int)((uint64_t_C(1) << QMAT_SHIFT) / (qscale * quant_matrix[j]));



                qmat16[qscale][0][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[j]);



                if(qmat16[qscale][0][i]==0 || qmat16[qscale][0][i]==128*256) qmat16[qscale][0][i]=128*256-1;

                qmat16[qscale][1][i]= ROUNDED_DIV(bias<<(16-QUANT_BIAS_SHIFT), qmat16[qscale][0][i]);

            }

        }

        

        for(i=intra; i<64; i++){

            while(((8191LL * qmat[qscale][i]) >> shift) > INT_MAX){ 

                shift++;

            }

        }

    }

    if(shift){

        av_log(NULL, AV_LOG_INFO, "Warning, QMAT_SHIFT is larger then %d, overflows possible\n", QMAT_SHIFT - shift);

    }

}

            while(((8191LL * qmat[qscale][i]) >> shift) > INT_MAX){ 
static void FUNC_0(DSPContext *VAR_0, int (*VAR_1)[64], VAR_2 (*qmat16)[2][64],

                           const VAR_2 *VAR_3, int VAR_4, int VAR_5, int VAR_6, int VAR_7)

{

    int VAR_8;

    int VAR_9=0;



    for(VAR_8=VAR_5; VAR_8<=VAR_6; VAR_8++){

        int VAR_10;

        if (VAR_0->fdct == ff_jpeg_fdct_islow 

#ifdef FAAN_POSTSCALE

            || VAR_0->fdct == ff_faandct

#endif

            ) {

            for(VAR_10=0;VAR_10<64;VAR_10++) {

                const int VAR_12= VAR_0->idct_permutation[VAR_10];

                

                

                

                

                

                VAR_1[VAR_8][VAR_10] = (int)((uint64_t_C(1) << QMAT_SHIFT) / 

                                (VAR_8 * VAR_3[VAR_12]));

            }

        } else if (VAR_0->fdct == fdct_ifast

#ifndef FAAN_POSTSCALE

                   || VAR_0->fdct == ff_faandct

#endif

                   ) {

            for(VAR_10=0;VAR_10<64;VAR_10++) {

                const int VAR_12= VAR_0->idct_permutation[VAR_10];

                

                

                

                

                

                VAR_1[VAR_8][VAR_10] = (int)((uint64_t_C(1) << (QMAT_SHIFT + 14)) / 

                                (aanscales[VAR_10] * VAR_8 * VAR_3[VAR_12]));

            }

        } else {

            for(VAR_10=0;VAR_10<64;VAR_10++) {

                const int VAR_12= VAR_0->idct_permutation[VAR_10];

                









                VAR_1[VAR_8][VAR_10] = (int)((uint64_t_C(1) << QMAT_SHIFT) / (VAR_8 * VAR_3[VAR_12]));



                qmat16[VAR_8][0][VAR_10] = (1 << QMAT_SHIFT_MMX) / (VAR_8 * VAR_3[VAR_12]);



                if(qmat16[VAR_8][0][VAR_10]==0 || qmat16[VAR_8][0][VAR_10]==128*256) qmat16[VAR_8][0][VAR_10]=128*256-1;

                qmat16[VAR_8][1][VAR_10]= ROUNDED_DIV(VAR_4<<(16-QUANT_BIAS_SHIFT), qmat16[VAR_8][0][VAR_10]);

            }

        }

        

        for(VAR_10=VAR_7; VAR_10<64; VAR_10++){

            while(((8191LL * VAR_1[VAR_8][VAR_10]) >> VAR_9) > INT_MAX){ 

                VAR_9++;

            }

        }

    }

    if(VAR_9){

        av_log(NULL, AV_LOG_INFO, "Warning, QMAT_SHIFT is larger then %d, overflows possible\n", QMAT_SHIFT - VAR_9);

    }

}

static void FUNC_0(DSPContext *VAR_0, int (*VAR_1)[64], VAR_2 (*qmat16)[2][64],
const VAR_2 *VAR_3, int VAR_4, int VAR_5, int VAR_6, int VAR_7)
{ int VAR_8; int VAR_9=0; for(VAR_8=VAR_5; VAR_8<=VAR_6; VAR_8++){ int VAR_10; if (VAR_0->fdct == ff_jpeg_fdct_islow
#ifdef FAAN_POSTSCALE
|| VAR_0->fdct == ff_faandct
#endif
) { for(VAR_10=0;VAR_10<64;VAR_10++) { const int VAR_12= VAR_0->idct_permutation[VAR_10]; VAR_1[VAR_8][VAR_10] = (int)((uint64_t_C(1) << QMAT_SHIFT) /
(VAR_8 * VAR_3[VAR_12])); } } else if (VAR_0->fdct == fdct_ifast #ifndef FAAN_POSTSCALE
|| VAR_0->fdct == ff_faandct
#endif
) { for(VAR_10=0;VAR_10<64;VAR_10++) { const int VAR_12= VAR_0->idct_permutation[VAR_10]; VAR_1[VAR_8][VAR_10] = (int)((uint64_t_C(1) << (QMAT_SHIFT + 14)) /
(aanscales[VAR_10] * VAR_8 * VAR_3[VAR_12])); } } else { for(VAR_10=0;VAR_10<64;VAR_10++) { const int VAR_12= VAR_0->idct_permutation[VAR_10]; VAR_1[VAR_8][VAR_10] = (int)((uint64_t_C(1) << QMAT_SHIFT) / (VAR_8 * VAR_3[VAR_12])); qmat16[VAR_8][0][VAR_10] = (1 << QMAT_SHIFT_MMX) / (VAR_8 * VAR_3[VAR_12]); if(qmat16[VAR_8][0][VAR_10]==0 || qmat16[VAR_8][0][VAR_10]==128*256) qmat16[VAR_8][0][VAR_10]=128*256-1; qmat16[VAR_8][1][VAR_10]= ROUNDED_DIV(VAR_4<<(16-QUANT_BIAS_SHIFT), qmat16[VAR_8][0][VAR_10]); } } for(VAR_10=VAR_7; VAR_10<64; VAR_10++){ while(((8191LL * VAR_1[VAR_8][VAR_10]) >> VAR_9) > INT_MAX){ VAR_9++; } } } if(VAR_9){ av_log(NULL, AV_LOG_INFO, "Warning, QMAT_SHIFT is larger then %d, overflows possible\n", QMAT_SHIFT - VAR_9); } }