static av_cold int allocate_buffers(AVCodecContext *avctx)

{

    int blk, ch;

    AC3EncodeContext *s = avctx->priv_data;

    int channels = s->channels + 1; /* includes coupling channel */



    FF_ALLOC_OR_GOTO(avctx, s->planar_samples, s->channels * sizeof(*s->planar_samples),

                     alloc_fail);

    for (ch = 0; ch < s->channels; ch++) {

        FF_ALLOCZ_OR_GOTO(avctx, s->planar_samples[ch],

                          (AC3_FRAME_SIZE+AC3_BLOCK_SIZE) * sizeof(**s->planar_samples),

                          alloc_fail);

    }

    FF_ALLOC_OR_GOTO(avctx, s->bap_buffer,  AC3_MAX_BLOCKS * channels *

                     AC3_MAX_COEFS * sizeof(*s->bap_buffer),  alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->bap1_buffer, AC3_MAX_BLOCKS * channels *

                     AC3_MAX_COEFS * sizeof(*s->bap1_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->mdct_coef_buffer, AC3_MAX_BLOCKS * channels *

                     AC3_MAX_COEFS * sizeof(*s->mdct_coef_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->exp_buffer, AC3_MAX_BLOCKS * channels *

                     AC3_MAX_COEFS * sizeof(*s->exp_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->grouped_exp_buffer, AC3_MAX_BLOCKS * channels *

                     128 * sizeof(*s->grouped_exp_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->psd_buffer, AC3_MAX_BLOCKS * channels *

                     AC3_MAX_COEFS * sizeof(*s->psd_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->band_psd_buffer, AC3_MAX_BLOCKS * channels *

                     64 * sizeof(*s->band_psd_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->mask_buffer, AC3_MAX_BLOCKS * channels *

                     64 * sizeof(*s->mask_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->qmant_buffer, AC3_MAX_BLOCKS * channels *

                     AC3_MAX_COEFS * sizeof(*s->qmant_buffer), alloc_fail);

    if (s->cpl_enabled) {

        FF_ALLOC_OR_GOTO(avctx, s->cpl_coord_exp_buffer, AC3_MAX_BLOCKS * channels *

                         16 * sizeof(*s->cpl_coord_exp_buffer), alloc_fail);

        FF_ALLOC_OR_GOTO(avctx, s->cpl_coord_mant_buffer, AC3_MAX_BLOCKS * channels *

                         16 * sizeof(*s->cpl_coord_mant_buffer), alloc_fail);

    }

    for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {

        AC3Block *block = &s->blocks[blk];

        FF_ALLOC_OR_GOTO(avctx, block->bap, channels * sizeof(*block->bap),

                         alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->mdct_coef, channels * sizeof(*block->mdct_coef),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->exp, channels * sizeof(*block->exp),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->grouped_exp, channels * sizeof(*block->grouped_exp),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->psd, channels * sizeof(*block->psd),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->band_psd, channels * sizeof(*block->band_psd),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->mask, channels * sizeof(*block->mask),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->qmant, channels * sizeof(*block->qmant),

                          alloc_fail);

        if (s->cpl_enabled) {

            FF_ALLOCZ_OR_GOTO(avctx, block->cpl_coord_exp, channels * sizeof(*block->cpl_coord_exp),

                              alloc_fail);

            FF_ALLOCZ_OR_GOTO(avctx, block->cpl_coord_mant, channels * sizeof(*block->cpl_coord_mant),

                              alloc_fail);

        }



        for (ch = 0; ch < channels; ch++) {

            /* arrangement: block, channel, coeff */

            block->bap[ch]         = &s->bap_buffer        [AC3_MAX_COEFS * (blk * channels + ch)];

            block->grouped_exp[ch] = &s->grouped_exp_buffer[128           * (blk * channels + ch)];

            block->psd[ch]         = &s->psd_buffer        [AC3_MAX_COEFS * (blk * channels + ch)];

            block->band_psd[ch]    = &s->band_psd_buffer   [64            * (blk * channels + ch)];

            block->mask[ch]        = &s->mask_buffer       [64            * (blk * channels + ch)];

            block->qmant[ch]       = &s->qmant_buffer      [AC3_MAX_COEFS * (blk * channels + ch)];

            if (s->cpl_enabled) {

                block->cpl_coord_exp[ch]  = &s->cpl_coord_exp_buffer [16  * (blk * channels + ch)];

                block->cpl_coord_mant[ch] = &s->cpl_coord_mant_buffer[16  * (blk * channels + ch)];

            }



            /* arrangement: channel, block, coeff */

            block->exp[ch]         = &s->exp_buffer        [AC3_MAX_COEFS * (AC3_MAX_BLOCKS * ch + blk)];

            block->mdct_coef[ch]   = &s->mdct_coef_buffer  [AC3_MAX_COEFS * (AC3_MAX_BLOCKS * ch + blk)];

        }

    }



    if (CONFIG_AC3ENC_FLOAT) {

        FF_ALLOC_OR_GOTO(avctx, s->fixed_coef_buffer, AC3_MAX_BLOCKS * channels *

                         AC3_MAX_COEFS * sizeof(*s->fixed_coef_buffer), alloc_fail);

        for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {

            AC3Block *block = &s->blocks[blk];

            FF_ALLOCZ_OR_GOTO(avctx, block->fixed_coef, channels *

                              sizeof(*block->fixed_coef), alloc_fail);

            for (ch = 0; ch < channels; ch++)

                block->fixed_coef[ch] = &s->fixed_coef_buffer[AC3_MAX_COEFS * (AC3_MAX_BLOCKS * ch + blk)];

        }

    } else {

        for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {

            AC3Block *block = &s->blocks[blk];

            FF_ALLOCZ_OR_GOTO(avctx, block->fixed_coef, channels *

                              sizeof(*block->fixed_coef), alloc_fail);

            for (ch = 0; ch < channels; ch++)

                block->fixed_coef[ch] = (int32_t *)block->mdct_coef[ch];

        }

    }



    return 0;

alloc_fail:

    return AVERROR(ENOMEM);

}

static av_cold int allocate_buffers(AVCodecContext *avctx)

{

    int blk, ch;

    AC3EncodeContext *s = avctx->priv_data;

    int channels = s->channels + 1; 



    FF_ALLOC_OR_GOTO(avctx, s->planar_samples, s->channels * sizeof(*s->planar_samples),

                     alloc_fail);

    for (ch = 0; ch < s->channels; ch++) {

        FF_ALLOCZ_OR_GOTO(avctx, s->planar_samples[ch],

                          (AC3_FRAME_SIZE+AC3_BLOCK_SIZE) * sizeof(**s->planar_samples),

                          alloc_fail);

    }

    FF_ALLOC_OR_GOTO(avctx, s->bap_buffer,  AC3_MAX_BLOCKS * channels *

                     AC3_MAX_COEFS * sizeof(*s->bap_buffer),  alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->bap1_buffer, AC3_MAX_BLOCKS * channels *

                     AC3_MAX_COEFS * sizeof(*s->bap1_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->mdct_coef_buffer, AC3_MAX_BLOCKS * channels *

                     AC3_MAX_COEFS * sizeof(*s->mdct_coef_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->exp_buffer, AC3_MAX_BLOCKS * channels *

                     AC3_MAX_COEFS * sizeof(*s->exp_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->grouped_exp_buffer, AC3_MAX_BLOCKS * channels *

                     128 * sizeof(*s->grouped_exp_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->psd_buffer, AC3_MAX_BLOCKS * channels *

                     AC3_MAX_COEFS * sizeof(*s->psd_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->band_psd_buffer, AC3_MAX_BLOCKS * channels *

                     64 * sizeof(*s->band_psd_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->mask_buffer, AC3_MAX_BLOCKS * channels *

                     64 * sizeof(*s->mask_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->qmant_buffer, AC3_MAX_BLOCKS * channels *

                     AC3_MAX_COEFS * sizeof(*s->qmant_buffer), alloc_fail);

    if (s->cpl_enabled) {

        FF_ALLOC_OR_GOTO(avctx, s->cpl_coord_exp_buffer, AC3_MAX_BLOCKS * channels *

                         16 * sizeof(*s->cpl_coord_exp_buffer), alloc_fail);

        FF_ALLOC_OR_GOTO(avctx, s->cpl_coord_mant_buffer, AC3_MAX_BLOCKS * channels *

                         16 * sizeof(*s->cpl_coord_mant_buffer), alloc_fail);

    }

    for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {

        AC3Block *block = &s->blocks[blk];

        FF_ALLOC_OR_GOTO(avctx, block->bap, channels * sizeof(*block->bap),

                         alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->mdct_coef, channels * sizeof(*block->mdct_coef),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->exp, channels * sizeof(*block->exp),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->grouped_exp, channels * sizeof(*block->grouped_exp),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->psd, channels * sizeof(*block->psd),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->band_psd, channels * sizeof(*block->band_psd),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->mask, channels * sizeof(*block->mask),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->qmant, channels * sizeof(*block->qmant),

                          alloc_fail);

        if (s->cpl_enabled) {

            FF_ALLOCZ_OR_GOTO(avctx, block->cpl_coord_exp, channels * sizeof(*block->cpl_coord_exp),

                              alloc_fail);

            FF_ALLOCZ_OR_GOTO(avctx, block->cpl_coord_mant, channels * sizeof(*block->cpl_coord_mant),

                              alloc_fail);

        }



        for (ch = 0; ch < channels; ch++) {

            

            block->bap[ch]         = &s->bap_buffer        [AC3_MAX_COEFS * (blk * channels + ch)];

            block->grouped_exp[ch] = &s->grouped_exp_buffer[128           * (blk * channels + ch)];

            block->psd[ch]         = &s->psd_buffer        [AC3_MAX_COEFS * (blk * channels + ch)];

            block->band_psd[ch]    = &s->band_psd_buffer   [64            * (blk * channels + ch)];

            block->mask[ch]        = &s->mask_buffer       [64            * (blk * channels + ch)];

            block->qmant[ch]       = &s->qmant_buffer      [AC3_MAX_COEFS * (blk * channels + ch)];

            if (s->cpl_enabled) {

                block->cpl_coord_exp[ch]  = &s->cpl_coord_exp_buffer [16  * (blk * channels + ch)];

                block->cpl_coord_mant[ch] = &s->cpl_coord_mant_buffer[16  * (blk * channels + ch)];

            }



            

            block->exp[ch]         = &s->exp_buffer        [AC3_MAX_COEFS * (AC3_MAX_BLOCKS * ch + blk)];

            block->mdct_coef[ch]   = &s->mdct_coef_buffer  [AC3_MAX_COEFS * (AC3_MAX_BLOCKS * ch + blk)];

        }

    }



    if (CONFIG_AC3ENC_FLOAT) {

        FF_ALLOC_OR_GOTO(avctx, s->fixed_coef_buffer, AC3_MAX_BLOCKS * channels *

                         AC3_MAX_COEFS * sizeof(*s->fixed_coef_buffer), alloc_fail);

        for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {

            AC3Block *block = &s->blocks[blk];

            FF_ALLOCZ_OR_GOTO(avctx, block->fixed_coef, channels *

                              sizeof(*block->fixed_coef), alloc_fail);

            for (ch = 0; ch < channels; ch++)

                block->fixed_coef[ch] = &s->fixed_coef_buffer[AC3_MAX_COEFS * (AC3_MAX_BLOCKS * ch + blk)];

        }

    } else {

        for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {

            AC3Block *block = &s->blocks[blk];

            FF_ALLOCZ_OR_GOTO(avctx, block->fixed_coef, channels *

                              sizeof(*block->fixed_coef), alloc_fail);

            for (ch = 0; ch < channels; ch++)

                block->fixed_coef[ch] = (int32_t *)block->mdct_coef[ch];

        }

    }



    return 0;

alloc_fail:

    return AVERROR(ENOMEM);

}

    FF_ALLOC_OR_GOTO(avctx, s->mdct_coef_buffer, AC3_MAX_BLOCKS * channels *                      AC3_MAX_COEFS * sizeof(*s->mdct_coef_buffer), alloc_fail);         FF_ALLOC_OR_GOTO(avctx, s->fixed_coef_buffer, AC3_MAX_BLOCKS * channels *                          AC3_MAX_COEFS * sizeof(*s->fixed_coef_buffer), alloc_fail);
static av_cold int FUNC_0(AVCodecContext *avctx)

{

    int VAR_0, VAR_1;

    AC3EncodeContext *s = avctx->priv_data;

    int VAR_2 = s->VAR_2 + 1; 



    FF_ALLOC_OR_GOTO(avctx, s->planar_samples, s->VAR_2 * sizeof(*s->planar_samples),

                     alloc_fail);

    for (VAR_1 = 0; VAR_1 < s->VAR_2; VAR_1++) {

        FF_ALLOCZ_OR_GOTO(avctx, s->planar_samples[VAR_1],

                          (AC3_FRAME_SIZE+AC3_BLOCK_SIZE) * sizeof(**s->planar_samples),

                          alloc_fail);

    }

    FF_ALLOC_OR_GOTO(avctx, s->bap_buffer,  AC3_MAX_BLOCKS * VAR_2 *

                     AC3_MAX_COEFS * sizeof(*s->bap_buffer),  alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->bap1_buffer, AC3_MAX_BLOCKS * VAR_2 *

                     AC3_MAX_COEFS * sizeof(*s->bap1_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->mdct_coef_buffer, AC3_MAX_BLOCKS * VAR_2 *

                     AC3_MAX_COEFS * sizeof(*s->mdct_coef_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->exp_buffer, AC3_MAX_BLOCKS * VAR_2 *

                     AC3_MAX_COEFS * sizeof(*s->exp_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->grouped_exp_buffer, AC3_MAX_BLOCKS * VAR_2 *

                     128 * sizeof(*s->grouped_exp_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->psd_buffer, AC3_MAX_BLOCKS * VAR_2 *

                     AC3_MAX_COEFS * sizeof(*s->psd_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->band_psd_buffer, AC3_MAX_BLOCKS * VAR_2 *

                     64 * sizeof(*s->band_psd_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->mask_buffer, AC3_MAX_BLOCKS * VAR_2 *

                     64 * sizeof(*s->mask_buffer), alloc_fail);

    FF_ALLOC_OR_GOTO(avctx, s->qmant_buffer, AC3_MAX_BLOCKS * VAR_2 *

                     AC3_MAX_COEFS * sizeof(*s->qmant_buffer), alloc_fail);

    if (s->cpl_enabled) {

        FF_ALLOC_OR_GOTO(avctx, s->cpl_coord_exp_buffer, AC3_MAX_BLOCKS * VAR_2 *

                         16 * sizeof(*s->cpl_coord_exp_buffer), alloc_fail);

        FF_ALLOC_OR_GOTO(avctx, s->cpl_coord_mant_buffer, AC3_MAX_BLOCKS * VAR_2 *

                         16 * sizeof(*s->cpl_coord_mant_buffer), alloc_fail);

    }

    for (VAR_0 = 0; VAR_0 < AC3_MAX_BLOCKS; VAR_0++) {

        AC3Block *block = &s->blocks[VAR_0];

        FF_ALLOC_OR_GOTO(avctx, block->bap, VAR_2 * sizeof(*block->bap),

                         alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->mdct_coef, VAR_2 * sizeof(*block->mdct_coef),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->exp, VAR_2 * sizeof(*block->exp),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->grouped_exp, VAR_2 * sizeof(*block->grouped_exp),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->psd, VAR_2 * sizeof(*block->psd),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->band_psd, VAR_2 * sizeof(*block->band_psd),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->mask, VAR_2 * sizeof(*block->mask),

                          alloc_fail);

        FF_ALLOCZ_OR_GOTO(avctx, block->qmant, VAR_2 * sizeof(*block->qmant),

                          alloc_fail);

        if (s->cpl_enabled) {

            FF_ALLOCZ_OR_GOTO(avctx, block->cpl_coord_exp, VAR_2 * sizeof(*block->cpl_coord_exp),

                              alloc_fail);

            FF_ALLOCZ_OR_GOTO(avctx, block->cpl_coord_mant, VAR_2 * sizeof(*block->cpl_coord_mant),

                              alloc_fail);

        }



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

            

            block->bap[VAR_1]         = &s->bap_buffer        [AC3_MAX_COEFS * (VAR_0 * VAR_2 + VAR_1)];

            block->grouped_exp[VAR_1] = &s->grouped_exp_buffer[128           * (VAR_0 * VAR_2 + VAR_1)];

            block->psd[VAR_1]         = &s->psd_buffer        [AC3_MAX_COEFS * (VAR_0 * VAR_2 + VAR_1)];

            block->band_psd[VAR_1]    = &s->band_psd_buffer   [64            * (VAR_0 * VAR_2 + VAR_1)];

            block->mask[VAR_1]        = &s->mask_buffer       [64            * (VAR_0 * VAR_2 + VAR_1)];

            block->qmant[VAR_1]       = &s->qmant_buffer      [AC3_MAX_COEFS * (VAR_0 * VAR_2 + VAR_1)];

            if (s->cpl_enabled) {

                block->cpl_coord_exp[VAR_1]  = &s->cpl_coord_exp_buffer [16  * (VAR_0 * VAR_2 + VAR_1)];

                block->cpl_coord_mant[VAR_1] = &s->cpl_coord_mant_buffer[16  * (VAR_0 * VAR_2 + VAR_1)];

            }



            

            block->exp[VAR_1]         = &s->exp_buffer        [AC3_MAX_COEFS * (AC3_MAX_BLOCKS * VAR_1 + VAR_0)];

            block->mdct_coef[VAR_1]   = &s->mdct_coef_buffer  [AC3_MAX_COEFS * (AC3_MAX_BLOCKS * VAR_1 + VAR_0)];

        }

    }



    if (CONFIG_AC3ENC_FLOAT) {

        FF_ALLOC_OR_GOTO(avctx, s->fixed_coef_buffer, AC3_MAX_BLOCKS * VAR_2 *

                         AC3_MAX_COEFS * sizeof(*s->fixed_coef_buffer), alloc_fail);

        for (VAR_0 = 0; VAR_0 < AC3_MAX_BLOCKS; VAR_0++) {

            AC3Block *block = &s->blocks[VAR_0];

            FF_ALLOCZ_OR_GOTO(avctx, block->fixed_coef, VAR_2 *

                              sizeof(*block->fixed_coef), alloc_fail);

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

                block->fixed_coef[VAR_1] = &s->fixed_coef_buffer[AC3_MAX_COEFS * (AC3_MAX_BLOCKS * VAR_1 + VAR_0)];

        }

    } else {

        for (VAR_0 = 0; VAR_0 < AC3_MAX_BLOCKS; VAR_0++) {

            AC3Block *block = &s->blocks[VAR_0];

            FF_ALLOCZ_OR_GOTO(avctx, block->fixed_coef, VAR_2 *

                              sizeof(*block->fixed_coef), alloc_fail);

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

                block->fixed_coef[VAR_1] = (int32_t *)block->mdct_coef[VAR_1];

        }

    }



    return 0;

alloc_fail:

    return AVERROR(ENOMEM);

}

static av_cold int FUNC_0(AVCodecContext *avctx)
{ int VAR_0, VAR_1; AC3EncodeContext *s = avctx->priv_data; int VAR_2 = s->VAR_2 + 1; FF_ALLOC_OR_GOTO(avctx, s->planar_samples, s->VAR_2 * sizeof(*s->planar_samples),
alloc_fail); for (VAR_1 = 0; VAR_1 < s->VAR_2; VAR_1++) { FF_ALLOCZ_OR_GOTO(avctx, s->planar_samples[VAR_1],
(AC3_FRAME_SIZE+AC3_BLOCK_SIZE) * sizeof(**s->planar_samples),
alloc_fail); } FF_ALLOC_OR_GOTO(avctx, s->bap_buffer,  AC3_MAX_BLOCKS * VAR_2 *
AC3_MAX_COEFS * sizeof(*s->bap_buffer),  alloc_fail); FF_ALLOC_OR_GOTO(avctx, s->bap1_buffer, AC3_MAX_BLOCKS * VAR_2 *
AC3_MAX_COEFS * sizeof(*s->bap1_buffer), alloc_fail); FF_ALLOC_OR_GOTO(avctx, s->mdct_coef_buffer, AC3_MAX_BLOCKS * VAR_2 *
AC3_MAX_COEFS * sizeof(*s->mdct_coef_buffer), alloc_fail); FF_ALLOC_OR_GOTO(avctx, s->exp_buffer, AC3_MAX_BLOCKS * VAR_2 *
AC3_MAX_COEFS * sizeof(*s->exp_buffer), alloc_fail); FF_ALLOC_OR_GOTO(avctx, s->grouped_exp_buffer, AC3_MAX_BLOCKS * VAR_2 *
128 * sizeof(*s->grouped_exp_buffer), alloc_fail); FF_ALLOC_OR_GOTO(avctx, s->psd_buffer, AC3_MAX_BLOCKS * VAR_2 *
AC3_MAX_COEFS * sizeof(*s->psd_buffer), alloc_fail); FF_ALLOC_OR_GOTO(avctx, s->band_psd_buffer, AC3_MAX_BLOCKS * VAR_2 *
64 * sizeof(*s->band_psd_buffer), alloc_fail); FF_ALLOC_OR_GOTO(avctx, s->mask_buffer, AC3_MAX_BLOCKS * VAR_2 *
64 * sizeof(*s->mask_buffer), alloc_fail); FF_ALLOC_OR_GOTO(avctx, s->qmant_buffer, AC3_MAX_BLOCKS * VAR_2 *
AC3_MAX_COEFS * sizeof(*s->qmant_buffer), alloc_fail); if (s->cpl_enabled) { FF_ALLOC_OR_GOTO(avctx, s->cpl_coord_exp_buffer, AC3_MAX_BLOCKS * VAR_2 *
16 * sizeof(*s->cpl_coord_exp_buffer), alloc_fail); FF_ALLOC_OR_GOTO(avctx, s->cpl_coord_mant_buffer, AC3_MAX_BLOCKS * VAR_2 *
16 * sizeof(*s->cpl_coord_mant_buffer), alloc_fail); } for (VAR_0 = 0; VAR_0 < AC3_MAX_BLOCKS; VAR_0++) { AC3Block *block = &s->blocks[VAR_0]; FF_ALLOC_OR_GOTO(avctx, block->bap, VAR_2 * sizeof(*block->bap),
alloc_fail); FF_ALLOCZ_OR_GOTO(avctx, block->mdct_coef, VAR_2 * sizeof(*block->mdct_coef),
alloc_fail); FF_ALLOCZ_OR_GOTO(avctx, block->exp, VAR_2 * sizeof(*block->exp),
alloc_fail); FF_ALLOCZ_OR_GOTO(avctx, block->grouped_exp, VAR_2 * sizeof(*block->grouped_exp),
alloc_fail); FF_ALLOCZ_OR_GOTO(avctx, block->psd, VAR_2 * sizeof(*block->psd),
alloc_fail); FF_ALLOCZ_OR_GOTO(avctx, block->band_psd, VAR_2 * sizeof(*block->band_psd),
alloc_fail); FF_ALLOCZ_OR_GOTO(avctx, block->mask, VAR_2 * sizeof(*block->mask),
alloc_fail); FF_ALLOCZ_OR_GOTO(avctx, block->qmant, VAR_2 * sizeof(*block->qmant),
alloc_fail); if (s->cpl_enabled) { FF_ALLOCZ_OR_GOTO(avctx, block->cpl_coord_exp, VAR_2 * sizeof(*block->cpl_coord_exp),
alloc_fail); FF_ALLOCZ_OR_GOTO(avctx, block->cpl_coord_mant, VAR_2 * sizeof(*block->cpl_coord_mant),
alloc_fail); } for (VAR_1 = 0; VAR_1 < VAR_2; VAR_1++) { block->bap[VAR_1]         = &s->bap_buffer        [AC3_MAX_COEFS * (VAR_0 * VAR_2 + VAR_1)]; block->grouped_exp[VAR_1] = &s->grouped_exp_buffer[128           * (VAR_0 * VAR_2 + VAR_1)]; block->psd[VAR_1]         = &s->psd_buffer        [AC3_MAX_COEFS * (VAR_0 * VAR_2 + VAR_1)]; block->band_psd[VAR_1]    = &s->band_psd_buffer   [64            * (VAR_0 * VAR_2 + VAR_1)]; block->mask[VAR_1]        = &s->mask_buffer       [64            * (VAR_0 * VAR_2 + VAR_1)]; block->qmant[VAR_1]       = &s->qmant_buffer      [AC3_MAX_COEFS * (VAR_0 * VAR_2 + VAR_1)]; if (s->cpl_enabled) { block->cpl_coord_exp[VAR_1]  = &s->cpl_coord_exp_buffer [16  * (VAR_0 * VAR_2 + VAR_1)]; block->cpl_coord_mant[VAR_1] = &s->cpl_coord_mant_buffer[16  * (VAR_0 * VAR_2 + VAR_1)]; } block->exp[VAR_1]         = &s->exp_buffer        [AC3_MAX_COEFS * (AC3_MAX_BLOCKS * VAR_1 + VAR_0)]; block->mdct_coef[VAR_1]   = &s->mdct_coef_buffer  [AC3_MAX_COEFS * (AC3_MAX_BLOCKS * VAR_1 + VAR_0)]; } } if (CONFIG_AC3ENC_FLOAT) { FF_ALLOC_OR_GOTO(avctx, s->fixed_coef_buffer, AC3_MAX_BLOCKS * VAR_2 *
AC3_MAX_COEFS * sizeof(*s->fixed_coef_buffer), alloc_fail); for (VAR_0 = 0; VAR_0 < AC3_MAX_BLOCKS; VAR_0++) { AC3Block *block = &s->blocks[VAR_0]; FF_ALLOCZ_OR_GOTO(avctx, block->fixed_coef, VAR_2 *
sizeof(*block->fixed_coef), alloc_fail); for (VAR_1 = 0; VAR_1 < VAR_2; VAR_1++) block->fixed_coef[VAR_1] = &s->fixed_coef_buffer[AC3_MAX_COEFS * (AC3_MAX_BLOCKS * VAR_1 + VAR_0)]; } } else { for (VAR_0 = 0; VAR_0 < AC3_MAX_BLOCKS; VAR_0++) { AC3Block *block = &s->blocks[VAR_0]; FF_ALLOCZ_OR_GOTO(avctx, block->fixed_coef, VAR_2 *
sizeof(*block->fixed_coef), alloc_fail); for (VAR_1 = 0; VAR_1 < VAR_2; VAR_1++) block->fixed_coef[VAR_1] = (int32_t *)block->mdct_coef[VAR_1]; } } return 0; alloc_fail:
return AVERROR(ENOMEM); }