static int get_transform_coeffs(AC3DecodeContext * ctx)

{

    int i;

    ac3_audio_block *ab = &ctx->audio_block;

    float *samples = ctx->samples;

    int got_cplchan = 0;

    int dithflag = 0;



    samples += (ctx->bsi.flags & AC3_BSI_LFEON) ? 256 : 0;

    for (i = 0; i < ctx->bsi.nfchans; i++) {

        if ((ab->flags & AC3_AB_CPLINU) && (ab->chincpl & (1 << i)))

            dithflag = 0; /* don't generate dither until channels are decoupled */

        else

            dithflag = ab->dithflag & (1 << i);

        /* transform coefficients for individual channel */

        if (_get_transform_coeffs(ab->dexps[i], ab->bap[i], ab->chcoeffs[i], samples + (i * 256),

                    0, ab->endmant[i], dithflag, &ctx->gb, &ctx->state))

            return -1;

        /* tranform coefficients for coupling channels */

        if ((ab->flags & AC3_AB_CPLINU) && (ab->chincpl & (1 << i)) && !got_cplchan) {

            if (_get_transform_coeffs(ab->dcplexps, ab->cplbap, 1.0f, ab->cplcoeffs,

                        ab->cplstrtmant, ab->cplendmant, 0, &ctx->gb, &ctx->state))

                return -1;

            got_cplchan = 1;

        }

    }

    if (ctx->bsi.flags & AC3_BSI_LFEON)

        if (_get_transform_coeffs(ab->lfeexps, ab->lfebap, 1.0f, samples - 256, 0, 7, 0, &ctx->gb, &ctx->state))

                return -1;



    /* uncouple the channels from the coupling channel */

    if (ab->flags & AC3_AB_CPLINU)

        if (uncouple_channels(ctx))

            return -1;



    return 0;

}

static int get_transform_coeffs(AC3DecodeContext * ctx)

{

    int i;

    ac3_audio_block *ab = &ctx->audio_block;

    float *samples = ctx->samples;

    int got_cplchan = 0;

    int dithflag = 0;



    samples += (ctx->bsi.flags & AC3_BSI_LFEON) ? 256 : 0;

    for (i = 0; i < ctx->bsi.nfchans; i++) {

        if ((ab->flags & AC3_AB_CPLINU) && (ab->chincpl & (1 << i)))

            dithflag = 0; 

        else

            dithflag = ab->dithflag & (1 << i);

        

        if (_get_transform_coeffs(ab->dexps[i], ab->bap[i], ab->chcoeffs[i], samples + (i * 256),

                    0, ab->endmant[i], dithflag, &ctx->gb, &ctx->state))

            return -1;

        

        if ((ab->flags & AC3_AB_CPLINU) && (ab->chincpl & (1 << i)) && !got_cplchan) {

            if (_get_transform_coeffs(ab->dcplexps, ab->cplbap, 1.0f, ab->cplcoeffs,

                        ab->cplstrtmant, ab->cplendmant, 0, &ctx->gb, &ctx->state))

                return -1;

            got_cplchan = 1;

        }

    }

    if (ctx->bsi.flags & AC3_BSI_LFEON)

        if (_get_transform_coeffs(ab->lfeexps, ab->lfebap, 1.0f, samples - 256, 0, 7, 0, &ctx->gb, &ctx->state))

                return -1;



    

    if (ab->flags & AC3_AB_CPLINU)

        if (uncouple_channels(ctx))

            return -1;



    return 0;

}

static int FUNC_0(AC3DecodeContext * VAR_0)

{

    int VAR_1;

    ac3_audio_block *ab = &VAR_0->audio_block;

    float *VAR_2 = VAR_0->VAR_2;

    int VAR_3 = 0;

    int VAR_4 = 0;



    VAR_2 += (VAR_0->bsi.flags & AC3_BSI_LFEON) ? 256 : 0;

    for (VAR_1 = 0; VAR_1 < VAR_0->bsi.nfchans; VAR_1++) {

        if ((ab->flags & AC3_AB_CPLINU) && (ab->chincpl & (1 << VAR_1)))

            VAR_4 = 0; 

        else

            VAR_4 = ab->VAR_4 & (1 << VAR_1);

        

        if (_get_transform_coeffs(ab->dexps[VAR_1], ab->bap[VAR_1], ab->chcoeffs[VAR_1], VAR_2 + (VAR_1 * 256),

                    0, ab->endmant[VAR_1], VAR_4, &VAR_0->gb, &VAR_0->state))

            return -1;

        

        if ((ab->flags & AC3_AB_CPLINU) && (ab->chincpl & (1 << VAR_1)) && !VAR_3) {

            if (_get_transform_coeffs(ab->dcplexps, ab->cplbap, 1.0f, ab->cplcoeffs,

                        ab->cplstrtmant, ab->cplendmant, 0, &VAR_0->gb, &VAR_0->state))

                return -1;

            VAR_3 = 1;

        }

    }

    if (VAR_0->bsi.flags & AC3_BSI_LFEON)

        if (_get_transform_coeffs(ab->lfeexps, ab->lfebap, 1.0f, VAR_2 - 256, 0, 7, 0, &VAR_0->gb, &VAR_0->state))

                return -1;



    

    if (ab->flags & AC3_AB_CPLINU)

        if (uncouple_channels(VAR_0))

            return -1;



    return 0;

}

static int FUNC_0(AC3DecodeContext * VAR_0)
{ int VAR_1; ac3_audio_block *ab = &VAR_0->audio_block; float *VAR_2 = VAR_0->VAR_2; int VAR_3 = 0; int VAR_4 = 0; VAR_2 += (VAR_0->bsi.flags & AC3_BSI_LFEON) ? 256 : 0; for (VAR_1 = 0; VAR_1 < VAR_0->bsi.nfchans; VAR_1++) { if ((ab->flags & AC3_AB_CPLINU) && (ab->chincpl & (1 << VAR_1)))
VAR_4 = 0; else
VAR_4 = ab->VAR_4 & (1 << VAR_1); if (_get_transform_coeffs(ab->dexps[VAR_1], ab->bap[VAR_1], ab->chcoeffs[VAR_1], VAR_2 + (VAR_1 * 256),
0, ab->endmant[VAR_1], VAR_4, &VAR_0->gb, &VAR_0->state))
return -1; if ((ab->flags & AC3_AB_CPLINU) && (ab->chincpl & (1 << VAR_1)) && !VAR_3) { if (_get_transform_coeffs(ab->dcplexps, ab->cplbap, 1.0f, ab->cplcoeffs,
ab->cplstrtmant, ab->cplendmant, 0, &VAR_0->gb, &VAR_0->state))
return -1; VAR_3 = 1; } } if (VAR_0->bsi.flags & AC3_BSI_LFEON)
if (_get_transform_coeffs(ab->lfeexps, ab->lfebap, 1.0f, VAR_2 - 256, 0, 7, 0, &VAR_0->gb, &VAR_0->state))
return -1; if (ab->flags & AC3_AB_CPLINU)
if (uncouple_channels(VAR_0))
return -1; return 0; }