static void lfe_downsample(DCAEncContext *c, const int32_t *input)

{

    /* FIXME: make 128x LFE downsampling possible */

    const int lfech = lfe_index[c->channel_config];

    int i, j, lfes;

    int32_t hist[512];

    int32_t accum;

    int hist_start = 0;



    for (i = 0; i < 512; i++)

        hist[i] = c->history[i][c->channels - 1];



    for (lfes = 0; lfes < DCA_LFE_SAMPLES; lfes++) {

        /* Calculate the convolution */

        accum = 0;



        for (i = hist_start, j = 0; i < 512; i++, j++)

            accum += mul32(hist[i], lfe_fir_64i[j]);

        for (i = 0; i < hist_start; i++, j++)

            accum += mul32(hist[i], lfe_fir_64i[j]);



        c->downsampled_lfe[lfes] = accum;



        /* Copy in 64 new samples from input */

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

            hist[i + hist_start] = input[(lfes * 64 + i) * c->channels + lfech];



        hist_start = (hist_start + 64) & 511;

    }

}

static void lfe_downsample(DCAEncContext *c, const int32_t *input)

{

    

    const int lfech = lfe_index[c->channel_config];

    int i, j, lfes;

    int32_t hist[512];

    int32_t accum;

    int hist_start = 0;



    for (i = 0; i < 512; i++)

        hist[i] = c->history[i][c->channels - 1];



    for (lfes = 0; lfes < DCA_LFE_SAMPLES; lfes++) {

        

        accum = 0;



        for (i = hist_start, j = 0; i < 512; i++, j++)

            accum += mul32(hist[i], lfe_fir_64i[j]);

        for (i = 0; i < hist_start; i++, j++)

            accum += mul32(hist[i], lfe_fir_64i[j]);



        c->downsampled_lfe[lfes] = accum;



        

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

            hist[i + hist_start] = input[(lfes * 64 + i) * c->channels + lfech];



        hist_start = (hist_start + 64) & 511;

    }

}

static void FUNC_0(DCAEncContext *VAR_0, const int32_t *VAR_1)

{

    

    const int VAR_2 = lfe_index[VAR_0->channel_config];

    int VAR_3, VAR_4, VAR_5;

    int32_t hist[512];

    int32_t accum;

    int VAR_6 = 0;



    for (VAR_3 = 0; VAR_3 < 512; VAR_3++)

        hist[VAR_3] = VAR_0->history[VAR_3][VAR_0->channels - 1];



    for (VAR_5 = 0; VAR_5 < DCA_LFE_SAMPLES; VAR_5++) {

        

        accum = 0;



        for (VAR_3 = VAR_6, VAR_4 = 0; VAR_3 < 512; VAR_3++, VAR_4++)

            accum += mul32(hist[VAR_3], lfe_fir_64i[VAR_4]);

        for (VAR_3 = 0; VAR_3 < VAR_6; VAR_3++, VAR_4++)

            accum += mul32(hist[VAR_3], lfe_fir_64i[VAR_4]);



        VAR_0->downsampled_lfe[VAR_5] = accum;



        

        for (VAR_3 = 0; VAR_3 < 64; VAR_3++)

            hist[VAR_3 + VAR_6] = VAR_1[(VAR_5 * 64 + VAR_3) * VAR_0->channels + VAR_2];



        VAR_6 = (VAR_6 + 64) & 511;

    }

}

static void FUNC_0(DCAEncContext *VAR_0, const int32_t *VAR_1)
{ const int VAR_2 = lfe_index[VAR_0->channel_config]; int VAR_3, VAR_4, VAR_5; int32_t hist[512]; int32_t accum; int VAR_6 = 0; for (VAR_3 = 0; VAR_3 < 512; VAR_3++) hist[VAR_3] = VAR_0->history[VAR_3][VAR_0->channels - 1]; for (VAR_5 = 0; VAR_5 < DCA_LFE_SAMPLES; VAR_5++) { accum = 0; for (VAR_3 = VAR_6, VAR_4 = 0; VAR_3 < 512; VAR_3++, VAR_4++) accum += mul32(hist[VAR_3], lfe_fir_64i[VAR_4]); for (VAR_3 = 0; VAR_3 < VAR_6; VAR_3++, VAR_4++) accum += mul32(hist[VAR_3], lfe_fir_64i[VAR_4]); VAR_0->downsampled_lfe[VAR_5] = accum; for (VAR_3 = 0; VAR_3 < 64; VAR_3++) hist[VAR_3 + VAR_6] = VAR_1[(VAR_5 * 64 + VAR_3) * VAR_0->channels + VAR_2]; VAR_6 = (VAR_6 + 64) & 511; } }