static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,

                                       ALSChannelData **cd, int *reverted,

                                       unsigned int offset, int c)

{

    ALSChannelData *ch = cd[c];

    unsigned int   dep = 0;

    unsigned int channels = ctx->avctx->channels;



    if (reverted[c])

        return 0;



    reverted[c] = 1;



    while (dep < channels && !ch[dep].stop_flag) {

        revert_channel_correlation(ctx, bd, cd, reverted, offset,

                                   ch[dep].master_channel);



        dep++;

    }



    if (dep == channels) {

        av_log(ctx->avctx, AV_LOG_WARNING, "Invalid channel correlation!\n");

        return AVERROR_INVALIDDATA;

    }



    bd->const_block = ctx->const_block + c;

    bd->shift_lsbs  = ctx->shift_lsbs + c;

    bd->opt_order   = ctx->opt_order + c;

    bd->store_prev_samples = ctx->store_prev_samples + c;

    bd->use_ltp     = ctx->use_ltp + c;

    bd->ltp_lag     = ctx->ltp_lag + c;

    bd->ltp_gain    = ctx->ltp_gain[c];

    bd->lpc_cof     = ctx->lpc_cof[c];

    bd->quant_cof   = ctx->quant_cof[c];

    bd->raw_samples = ctx->raw_samples[c] + offset;



    dep = 0;

    while (!ch[dep].stop_flag) {

        unsigned int smp;

        unsigned int begin = 1;

        unsigned int end   = bd->block_length - 1;

        int64_t y;

        int32_t *master = ctx->raw_samples[ch[dep].master_channel] + offset;



        if (ch[dep].time_diff_flag) {

            int t = ch[dep].time_diff_index;



            if (ch[dep].time_diff_sign) {

                t      = -t;

                begin -= t;

            } else {

                end   -= t;

            }



            for (smp = begin; smp < end; smp++) {

                y  = (1 << 6) +

                     MUL64(ch[dep].weighting[0], master[smp - 1    ]) +

                     MUL64(ch[dep].weighting[1], master[smp        ]) +

                     MUL64(ch[dep].weighting[2], master[smp + 1    ]) +

                     MUL64(ch[dep].weighting[3], master[smp - 1 + t]) +

                     MUL64(ch[dep].weighting[4], master[smp     + t]) +

                     MUL64(ch[dep].weighting[5], master[smp + 1 + t]);



                bd->raw_samples[smp] += y >> 7;

            }

        } else {

            for (smp = begin; smp < end; smp++) {

                y  = (1 << 6) +

                     MUL64(ch[dep].weighting[0], master[smp - 1]) +

                     MUL64(ch[dep].weighting[1], master[smp    ]) +

                     MUL64(ch[dep].weighting[2], master[smp + 1]);



                bd->raw_samples[smp] += y >> 7;

            }

        }



        dep++;

    }



    return 0;

}

static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,

                                       ALSChannelData **cd, int *reverted,

                                       unsigned int offset, int c)

{

    ALSChannelData *ch = cd[c];

    unsigned int   dep = 0;

    unsigned int channels = ctx->avctx->channels;



    if (reverted[c])

        return 0;



    reverted[c] = 1;



    while (dep < channels && !ch[dep].stop_flag) {

        revert_channel_correlation(ctx, bd, cd, reverted, offset,

                                   ch[dep].master_channel);



        dep++;

    }



    if (dep == channels) {

        av_log(ctx->avctx, AV_LOG_WARNING, "Invalid channel correlation!\n");

        return AVERROR_INVALIDDATA;

    }



    bd->const_block = ctx->const_block + c;

    bd->shift_lsbs  = ctx->shift_lsbs + c;

    bd->opt_order   = ctx->opt_order + c;

    bd->store_prev_samples = ctx->store_prev_samples + c;

    bd->use_ltp     = ctx->use_ltp + c;

    bd->ltp_lag     = ctx->ltp_lag + c;

    bd->ltp_gain    = ctx->ltp_gain[c];

    bd->lpc_cof     = ctx->lpc_cof[c];

    bd->quant_cof   = ctx->quant_cof[c];

    bd->raw_samples = ctx->raw_samples[c] + offset;



    dep = 0;

    while (!ch[dep].stop_flag) {

        unsigned int smp;

        unsigned int begin = 1;

        unsigned int end   = bd->block_length - 1;

        int64_t y;

        int32_t *master = ctx->raw_samples[ch[dep].master_channel] + offset;



        if (ch[dep].time_diff_flag) {

            int t = ch[dep].time_diff_index;



            if (ch[dep].time_diff_sign) {

                t      = -t;

                begin -= t;

            } else {

                end   -= t;

            }



            for (smp = begin; smp < end; smp++) {

                y  = (1 << 6) +

                     MUL64(ch[dep].weighting[0], master[smp - 1    ]) +

                     MUL64(ch[dep].weighting[1], master[smp        ]) +

                     MUL64(ch[dep].weighting[2], master[smp + 1    ]) +

                     MUL64(ch[dep].weighting[3], master[smp - 1 + t]) +

                     MUL64(ch[dep].weighting[4], master[smp     + t]) +

                     MUL64(ch[dep].weighting[5], master[smp + 1 + t]);



                bd->raw_samples[smp] += y >> 7;

            }

        } else {

            for (smp = begin; smp < end; smp++) {

                y  = (1 << 6) +

                     MUL64(ch[dep].weighting[0], master[smp - 1]) +

                     MUL64(ch[dep].weighting[1], master[smp    ]) +

                     MUL64(ch[dep].weighting[2], master[smp + 1]);



                bd->raw_samples[smp] += y >> 7;

            }

        }



        dep++;

    }



    return 0;

}

static int FUNC_0(ALSDecContext *VAR_0, ALSBlockData *VAR_1,

                                       ALSChannelData **VAR_2, int *VAR_3,

                                       unsigned int VAR_4, int VAR_5)

{

    ALSChannelData *ch = VAR_2[VAR_5];

    unsigned int   VAR_6 = 0;

    unsigned int VAR_7 = VAR_0->avctx->VAR_7;



    if (VAR_3[VAR_5])

        return 0;



    VAR_3[VAR_5] = 1;



    while (VAR_6 < VAR_7 && !ch[VAR_6].stop_flag) {

        FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,

                                   ch[VAR_6].master_channel);



        VAR_6++;

    }



    if (VAR_6 == VAR_7) {

        av_log(VAR_0->avctx, AV_LOG_WARNING, "Invalid channel correlation!\n");

        return AVERROR_INVALIDDATA;

    }



    VAR_1->const_block = VAR_0->const_block + VAR_5;

    VAR_1->shift_lsbs  = VAR_0->shift_lsbs + VAR_5;

    VAR_1->opt_order   = VAR_0->opt_order + VAR_5;

    VAR_1->store_prev_samples = VAR_0->store_prev_samples + VAR_5;

    VAR_1->use_ltp     = VAR_0->use_ltp + VAR_5;

    VAR_1->ltp_lag     = VAR_0->ltp_lag + VAR_5;

    VAR_1->ltp_gain    = VAR_0->ltp_gain[VAR_5];

    VAR_1->lpc_cof     = VAR_0->lpc_cof[VAR_5];

    VAR_1->quant_cof   = VAR_0->quant_cof[VAR_5];

    VAR_1->raw_samples = VAR_0->raw_samples[VAR_5] + VAR_4;



    VAR_6 = 0;

    while (!ch[VAR_6].stop_flag) {

        unsigned int VAR_8;

        unsigned int VAR_9 = 1;

        unsigned int VAR_10   = VAR_1->block_length - 1;

        int64_t y;

        int32_t *master = VAR_0->raw_samples[ch[VAR_6].master_channel] + VAR_4;



        if (ch[VAR_6].time_diff_flag) {

            int VAR_11 = ch[VAR_6].time_diff_index;



            if (ch[VAR_6].time_diff_sign) {

                VAR_11      = -VAR_11;

                VAR_9 -= VAR_11;

            } else {

                VAR_10   -= VAR_11;

            }



            for (VAR_8 = VAR_9; VAR_8 < VAR_10; VAR_8++) {

                y  = (1 << 6) +

                     MUL64(ch[VAR_6].weighting[0], master[VAR_8 - 1    ]) +

                     MUL64(ch[VAR_6].weighting[1], master[VAR_8        ]) +

                     MUL64(ch[VAR_6].weighting[2], master[VAR_8 + 1    ]) +

                     MUL64(ch[VAR_6].weighting[3], master[VAR_8 - 1 + VAR_11]) +

                     MUL64(ch[VAR_6].weighting[4], master[VAR_8     + VAR_11]) +

                     MUL64(ch[VAR_6].weighting[5], master[VAR_8 + 1 + VAR_11]);



                VAR_1->raw_samples[VAR_8] += y >> 7;

            }

        } else {

            for (VAR_8 = VAR_9; VAR_8 < VAR_10; VAR_8++) {

                y  = (1 << 6) +

                     MUL64(ch[VAR_6].weighting[0], master[VAR_8 - 1]) +

                     MUL64(ch[VAR_6].weighting[1], master[VAR_8    ]) +

                     MUL64(ch[VAR_6].weighting[2], master[VAR_8 + 1]);



                VAR_1->raw_samples[VAR_8] += y >> 7;

            }

        }



        VAR_6++;

    }



    return 0;

}

static int FUNC_0(ALSDecContext *VAR_0, ALSBlockData *VAR_1,
ALSChannelData **VAR_2, int *VAR_3,
unsigned int VAR_4, int VAR_5)
{ ALSChannelData *ch = VAR_2[VAR_5]; unsigned int   VAR_6 = 0; unsigned int VAR_7 = VAR_0->avctx->VAR_7; if (VAR_3[VAR_5])
return 0; VAR_3[VAR_5] = 1; while (VAR_6 < VAR_7 && !ch[VAR_6].stop_flag) { FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4,
ch[VAR_6].master_channel); VAR_6++; } if (VAR_6 == VAR_7) { av_log(VAR_0->avctx, AV_LOG_WARNING, "Invalid channel correlation!\n"); return AVERROR_INVALIDDATA; } VAR_1->const_block = VAR_0->const_block + VAR_5; VAR_1->shift_lsbs  = VAR_0->shift_lsbs + VAR_5; VAR_1->opt_order   = VAR_0->opt_order + VAR_5; VAR_1->store_prev_samples = VAR_0->store_prev_samples + VAR_5; VAR_1->use_ltp     = VAR_0->use_ltp + VAR_5; VAR_1->ltp_lag     = VAR_0->ltp_lag + VAR_5; VAR_1->ltp_gain    = VAR_0->ltp_gain[VAR_5]; VAR_1->lpc_cof     = VAR_0->lpc_cof[VAR_5]; VAR_1->quant_cof   = VAR_0->quant_cof[VAR_5]; VAR_1->raw_samples = VAR_0->raw_samples[VAR_5] + VAR_4; VAR_6 = 0; while (!ch[VAR_6].stop_flag) { unsigned int VAR_8; unsigned int VAR_9 = 1; unsigned int VAR_10   = VAR_1->block_length - 1; int64_t y; int32_t *master = VAR_0->raw_samples[ch[VAR_6].master_channel] + VAR_4; if (ch[VAR_6].time_diff_flag) { int VAR_11 = ch[VAR_6].time_diff_index; if (ch[VAR_6].time_diff_sign) { VAR_11      = -VAR_11; VAR_9 -= VAR_11; } else { VAR_10   -= VAR_11; } for (VAR_8 = VAR_9; VAR_8 < VAR_10; VAR_8++) { y  = (1 << 6) +
MUL64(ch[VAR_6].weighting[0], master[VAR_8 - 1    ]) +
MUL64(ch[VAR_6].weighting[1], master[VAR_8        ]) +
MUL64(ch[VAR_6].weighting[2], master[VAR_8 + 1    ]) +
MUL64(ch[VAR_6].weighting[3], master[VAR_8 - 1 + VAR_11]) +
MUL64(ch[VAR_6].weighting[4], master[VAR_8     + VAR_11]) +
MUL64(ch[VAR_6].weighting[5], master[VAR_8 + 1 + VAR_11]); VAR_1->raw_samples[VAR_8] += y >> 7; } } else { for (VAR_8 = VAR_9; VAR_8 < VAR_10; VAR_8++) { y  = (1 << 6) +
MUL64(ch[VAR_6].weighting[0], master[VAR_8 - 1]) +
MUL64(ch[VAR_6].weighting[1], master[VAR_8    ]) +
MUL64(ch[VAR_6].weighting[2], master[VAR_8 + 1]); VAR_1->raw_samples[VAR_8] += y >> 7; } } VAR_6++; } return 0; }