static void compute_exp_strategy(AC3EncodeContext *s)

{

    int ch, blk, blk1;



    for (ch = !s->cpl_on; ch <= s->fbw_channels; ch++) {

        uint8_t *exp_strategy = s->exp_strategy[ch];

        uint8_t *exp          = s->blocks[0].exp[ch];

        int exp_diff;



        /* estimate if the exponent variation & decide if they should be

           reused in the next frame */

        exp_strategy[0] = EXP_NEW;

        exp += AC3_MAX_COEFS;

        for (blk = 1; blk < AC3_MAX_BLOCKS; blk++, exp += AC3_MAX_COEFS) {

            if ((ch == CPL_CH && (!s->blocks[blk].cpl_in_use || !s->blocks[blk-1].cpl_in_use)) ||

                (ch  > CPL_CH && (s->blocks[blk].channel_in_cpl[ch] != s->blocks[blk-1].channel_in_cpl[ch]))) {

                exp_strategy[blk] = EXP_NEW;

                continue;

            }

            exp_diff = s->dsp.sad[0](NULL, exp, exp - AC3_MAX_COEFS, 16, 16);

            exp_strategy[blk] = EXP_REUSE;

            if (ch == CPL_CH && exp_diff > (EXP_DIFF_THRESHOLD * (s->blocks[blk].end_freq[ch] - s->start_freq[ch]) / AC3_MAX_COEFS))

                exp_strategy[blk] = EXP_NEW;

            else if (ch > CPL_CH && exp_diff > EXP_DIFF_THRESHOLD)

                exp_strategy[blk] = EXP_NEW;

        }



        /* now select the encoding strategy type : if exponents are often

           recoded, we use a coarse encoding */

        blk = 0;

        while (blk < AC3_MAX_BLOCKS) {

            blk1 = blk + 1;

            while (blk1 < AC3_MAX_BLOCKS && exp_strategy[blk1] == EXP_REUSE)

                blk1++;

            switch (blk1 - blk) {

            case 1:  exp_strategy[blk] = EXP_D45; break;

            case 2:

            case 3:  exp_strategy[blk] = EXP_D25; break;

            default: exp_strategy[blk] = EXP_D15; break;

            }

            blk = blk1;

        }

    }

    if (s->lfe_on) {

        ch = s->lfe_channel;

        s->exp_strategy[ch][0] = EXP_D15;

        for (blk = 1; blk < AC3_MAX_BLOCKS; blk++)

            s->exp_strategy[ch][blk] = EXP_REUSE;

    }

}

static void compute_exp_strategy(AC3EncodeContext *s)

{

    int ch, blk, blk1;



    for (ch = !s->cpl_on; ch <= s->fbw_channels; ch++) {

        uint8_t *exp_strategy = s->exp_strategy[ch];

        uint8_t *exp          = s->blocks[0].exp[ch];

        int exp_diff;



        



        exp_strategy[0] = EXP_NEW;

        exp += AC3_MAX_COEFS;

        for (blk = 1; blk < AC3_MAX_BLOCKS; blk++, exp += AC3_MAX_COEFS) {

            if ((ch == CPL_CH && (!s->blocks[blk].cpl_in_use || !s->blocks[blk-1].cpl_in_use)) ||

                (ch  > CPL_CH && (s->blocks[blk].channel_in_cpl[ch] != s->blocks[blk-1].channel_in_cpl[ch]))) {

                exp_strategy[blk] = EXP_NEW;

                continue;

            }

            exp_diff = s->dsp.sad[0](NULL, exp, exp - AC3_MAX_COEFS, 16, 16);

            exp_strategy[blk] = EXP_REUSE;

            if (ch == CPL_CH && exp_diff > (EXP_DIFF_THRESHOLD * (s->blocks[blk].end_freq[ch] - s->start_freq[ch]) / AC3_MAX_COEFS))

                exp_strategy[blk] = EXP_NEW;

            else if (ch > CPL_CH && exp_diff > EXP_DIFF_THRESHOLD)

                exp_strategy[blk] = EXP_NEW;

        }



        



        blk = 0;

        while (blk < AC3_MAX_BLOCKS) {

            blk1 = blk + 1;

            while (blk1 < AC3_MAX_BLOCKS && exp_strategy[blk1] == EXP_REUSE)

                blk1++;

            switch (blk1 - blk) {

            case 1:  exp_strategy[blk] = EXP_D45; break;

            case 2:

            case 3:  exp_strategy[blk] = EXP_D25; break;

            default: exp_strategy[blk] = EXP_D15; break;

            }

            blk = blk1;

        }

    }

    if (s->lfe_on) {

        ch = s->lfe_channel;

        s->exp_strategy[ch][0] = EXP_D15;

        for (blk = 1; blk < AC3_MAX_BLOCKS; blk++)

            s->exp_strategy[ch][blk] = EXP_REUSE;

    }

}

static void FUNC_0(AC3EncodeContext *VAR_0)

{

    int VAR_1, VAR_2, VAR_3;



    for (VAR_1 = !VAR_0->cpl_on; VAR_1 <= VAR_0->fbw_channels; VAR_1++) {

        uint8_t *exp_strategy = VAR_0->exp_strategy[VAR_1];

        uint8_t *exp          = VAR_0->blocks[0].exp[VAR_1];

        int exp_diff;



        



        exp_strategy[0] = EXP_NEW;

        exp += AC3_MAX_COEFS;

        for (VAR_2 = 1; VAR_2 < AC3_MAX_BLOCKS; VAR_2++, exp += AC3_MAX_COEFS) {

            if ((VAR_1 == CPL_CH && (!VAR_0->blocks[VAR_2].cpl_in_use || !VAR_0->blocks[VAR_2-1].cpl_in_use)) ||

                (VAR_1  > CPL_CH && (VAR_0->blocks[VAR_2].channel_in_cpl[VAR_1] != VAR_0->blocks[VAR_2-1].channel_in_cpl[VAR_1]))) {

                exp_strategy[VAR_2] = EXP_NEW;

                continue;

            }

            exp_diff = VAR_0->dsp.sad[0](NULL, exp, exp - AC3_MAX_COEFS, 16, 16);

            exp_strategy[VAR_2] = EXP_REUSE;

            if (VAR_1 == CPL_CH && exp_diff > (EXP_DIFF_THRESHOLD * (VAR_0->blocks[VAR_2].end_freq[VAR_1] - VAR_0->start_freq[VAR_1]) / AC3_MAX_COEFS))

                exp_strategy[VAR_2] = EXP_NEW;

            else if (VAR_1 > CPL_CH && exp_diff > EXP_DIFF_THRESHOLD)

                exp_strategy[VAR_2] = EXP_NEW;

        }



        



        VAR_2 = 0;

        while (VAR_2 < AC3_MAX_BLOCKS) {

            VAR_3 = VAR_2 + 1;

            while (VAR_3 < AC3_MAX_BLOCKS && exp_strategy[VAR_3] == EXP_REUSE)

                VAR_3++;

            switch (VAR_3 - VAR_2) {

            case 1:  exp_strategy[VAR_2] = EXP_D45; break;

            case 2:

            case 3:  exp_strategy[VAR_2] = EXP_D25; break;

            default: exp_strategy[VAR_2] = EXP_D15; break;

            }

            VAR_2 = VAR_3;

        }

    }

    if (VAR_0->lfe_on) {

        VAR_1 = VAR_0->lfe_channel;

        VAR_0->exp_strategy[VAR_1][0] = EXP_D15;

        for (VAR_2 = 1; VAR_2 < AC3_MAX_BLOCKS; VAR_2++)

            VAR_0->exp_strategy[VAR_1][VAR_2] = EXP_REUSE;

    }

}

static void FUNC_0(AC3EncodeContext *VAR_0)
{ int VAR_1, VAR_2, VAR_3; for (VAR_1 = !VAR_0->cpl_on; VAR_1 <= VAR_0->fbw_channels; VAR_1++) { uint8_t *exp_strategy = VAR_0->exp_strategy[VAR_1]; uint8_t *exp          = VAR_0->blocks[0].exp[VAR_1]; int exp_diff; exp_strategy[0] = EXP_NEW; exp += AC3_MAX_COEFS; for (VAR_2 = 1; VAR_2 < AC3_MAX_BLOCKS; VAR_2++, exp += AC3_MAX_COEFS) { if ((VAR_1 == CPL_CH && (!VAR_0->blocks[VAR_2].cpl_in_use || !VAR_0->blocks[VAR_2-1].cpl_in_use)) ||
(VAR_1  > CPL_CH && (VAR_0->blocks[VAR_2].channel_in_cpl[VAR_1] != VAR_0->blocks[VAR_2-1].channel_in_cpl[VAR_1]))) { exp_strategy[VAR_2] = EXP_NEW; continue; } exp_diff = VAR_0->dsp.sad[0](NULL, exp, exp - AC3_MAX_COEFS, 16, 16); exp_strategy[VAR_2] = EXP_REUSE; if (VAR_1 == CPL_CH && exp_diff > (EXP_DIFF_THRESHOLD * (VAR_0->blocks[VAR_2].end_freq[VAR_1] - VAR_0->start_freq[VAR_1]) / AC3_MAX_COEFS))
exp_strategy[VAR_2] = EXP_NEW; else if (VAR_1 > CPL_CH && exp_diff > EXP_DIFF_THRESHOLD)
exp_strategy[VAR_2] = EXP_NEW; } VAR_2 = 0; while (VAR_2 < AC3_MAX_BLOCKS) { VAR_3 = VAR_2 + 1; while (VAR_3 < AC3_MAX_BLOCKS && exp_strategy[VAR_3] == EXP_REUSE)
VAR_3++; switch (VAR_3 - VAR_2) { case 1:  exp_strategy[VAR_2] = EXP_D45; break; case 2:
case 3:  exp_strategy[VAR_2] = EXP_D25; break; default: exp_strategy[VAR_2] = EXP_D15; break; } VAR_2 = VAR_3; } } if (VAR_0->lfe_on) { VAR_1 = VAR_0->lfe_channel; VAR_0->exp_strategy[VAR_1][0] = EXP_D15; for (VAR_2 = 1; VAR_2 < AC3_MAX_BLOCKS; VAR_2++) VAR_0->exp_strategy[VAR_1][VAR_2] = EXP_REUSE; } }