static void sbr_env_estimate(float (*e_curr)[48], float X_high[64][40][2],

                             SpectralBandReplication *sbr, SBRData *ch_data)

{

    int e, i, m;



    if (sbr->bs_interpol_freq) {

        for (e = 0; e < ch_data->bs_num_env; e++) {

            const float recip_env_size = 0.5f / (ch_data->t_env[e + 1] - ch_data->t_env[e]);

            int ilb = ch_data->t_env[e]     * 2 + ENVELOPE_ADJUSTMENT_OFFSET;

            int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;



            for (m = 0; m < sbr->m[1]; m++) {

                float sum = 0.0f;



                for (i = ilb; i < iub; i++) {

                    sum += X_high[m + sbr->kx[1]][i][0] * X_high[m + sbr->kx[1]][i][0] +

                           X_high[m + sbr->kx[1]][i][1] * X_high[m + sbr->kx[1]][i][1];

                }

                e_curr[e][m] = sum * recip_env_size;

            }

        }

    } else {

        int k, p;



        for (e = 0; e < ch_data->bs_num_env; e++) {

            const int env_size = 2 * (ch_data->t_env[e + 1] - ch_data->t_env[e]);

            int ilb = ch_data->t_env[e]     * 2 + ENVELOPE_ADJUSTMENT_OFFSET;

            int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;

            const uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow;



            for (p = 0; p < sbr->n[ch_data->bs_freq_res[e + 1]]; p++) {

                float sum = 0.0f;

                const int den = env_size * (table[p + 1] - table[p]);



                for (k = table[p]; k < table[p + 1]; k++) {

                    for (i = ilb; i < iub; i++) {

                        sum += X_high[k][i][0] * X_high[k][i][0] +

                               X_high[k][i][1] * X_high[k][i][1];

                    }

                }

                sum /= den;

                for (k = table[p]; k < table[p + 1]; k++) {

                    e_curr[e][k - sbr->kx[1]] = sum;

                }

            }

        }

    }

}

static void sbr_env_estimate(float (*e_curr)[48], float X_high[64][40][2],

                             SpectralBandReplication *sbr, SBRData *ch_data)

{

    int e, i, m;



    if (sbr->bs_interpol_freq) {

        for (e = 0; e < ch_data->bs_num_env; e++) {

            const float recip_env_size = 0.5f / (ch_data->t_env[e + 1] - ch_data->t_env[e]);

            int ilb = ch_data->t_env[e]     * 2 + ENVELOPE_ADJUSTMENT_OFFSET;

            int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;



            for (m = 0; m < sbr->m[1]; m++) {

                float sum = 0.0f;



                for (i = ilb; i < iub; i++) {

                    sum += X_high[m + sbr->kx[1]][i][0] * X_high[m + sbr->kx[1]][i][0] +

                           X_high[m + sbr->kx[1]][i][1] * X_high[m + sbr->kx[1]][i][1];

                }

                e_curr[e][m] = sum * recip_env_size;

            }

        }

    } else {

        int k, p;



        for (e = 0; e < ch_data->bs_num_env; e++) {

            const int env_size = 2 * (ch_data->t_env[e + 1] - ch_data->t_env[e]);

            int ilb = ch_data->t_env[e]     * 2 + ENVELOPE_ADJUSTMENT_OFFSET;

            int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;

            const uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow;



            for (p = 0; p < sbr->n[ch_data->bs_freq_res[e + 1]]; p++) {

                float sum = 0.0f;

                const int den = env_size * (table[p + 1] - table[p]);



                for (k = table[p]; k < table[p + 1]; k++) {

                    for (i = ilb; i < iub; i++) {

                        sum += X_high[k][i][0] * X_high[k][i][0] +

                               X_high[k][i][1] * X_high[k][i][1];

                    }

                }

                sum /= den;

                for (k = table[p]; k < table[p + 1]; k++) {

                    e_curr[e][k - sbr->kx[1]] = sum;

                }

            }

        }

    }

}

static void FUNC_0(float (*VAR_0)[48], float VAR_1[64][40][2],

                             SpectralBandReplication *VAR_2, SBRData *VAR_3)

{

    int VAR_4, VAR_5, VAR_6;



    if (VAR_2->bs_interpol_freq) {

        for (VAR_4 = 0; VAR_4 < VAR_3->bs_num_env; VAR_4++) {

            const float recip_env_size = 0.5f / (VAR_3->t_env[VAR_4 + 1] - VAR_3->t_env[VAR_4]);

            int ilb = VAR_3->t_env[VAR_4]     * 2 + ENVELOPE_ADJUSTMENT_OFFSET;

            int iub = VAR_3->t_env[VAR_4 + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;



            for (VAR_6 = 0; VAR_6 < VAR_2->VAR_6[1]; VAR_6++) {

                float sum = 0.0f;



                for (VAR_5 = ilb; VAR_5 < iub; VAR_5++) {

                    sum += VAR_1[VAR_6 + VAR_2->kx[1]][VAR_5][0] * VAR_1[VAR_6 + VAR_2->kx[1]][VAR_5][0] +

                           VAR_1[VAR_6 + VAR_2->kx[1]][VAR_5][1] * VAR_1[VAR_6 + VAR_2->kx[1]][VAR_5][1];

                }

                VAR_0[VAR_4][VAR_6] = sum * recip_env_size;

            }

        }

    } else {

        int VAR_7, VAR_8;



        for (VAR_4 = 0; VAR_4 < VAR_3->bs_num_env; VAR_4++) {

            const int env_size = 2 * (VAR_3->t_env[VAR_4 + 1] - VAR_3->t_env[VAR_4]);

            int ilb = VAR_3->t_env[VAR_4]     * 2 + ENVELOPE_ADJUSTMENT_OFFSET;

            int iub = VAR_3->t_env[VAR_4 + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;

            const uint16_t *table = VAR_3->bs_freq_res[VAR_4 + 1] ? VAR_2->f_tablehigh : VAR_2->f_tablelow;



            for (VAR_8 = 0; VAR_8 < VAR_2->n[VAR_3->bs_freq_res[VAR_4 + 1]]; VAR_8++) {

                float sum = 0.0f;

                const int den = env_size * (table[VAR_8 + 1] - table[VAR_8]);



                for (VAR_7 = table[VAR_8]; VAR_7 < table[VAR_8 + 1]; VAR_7++) {

                    for (VAR_5 = ilb; VAR_5 < iub; VAR_5++) {

                        sum += VAR_1[VAR_7][VAR_5][0] * VAR_1[VAR_7][VAR_5][0] +

                               VAR_1[VAR_7][VAR_5][1] * VAR_1[VAR_7][VAR_5][1];

                    }

                }

                sum /= den;

                for (VAR_7 = table[VAR_8]; VAR_7 < table[VAR_8 + 1]; VAR_7++) {

                    VAR_0[VAR_4][VAR_7 - VAR_2->kx[1]] = sum;

                }

            }

        }

    }

}

static void FUNC_0(float (*VAR_0)[48], float VAR_1[64][40][2],
SpectralBandReplication *VAR_2, SBRData *VAR_3)
{ int VAR_4, VAR_5, VAR_6; if (VAR_2->bs_interpol_freq) { for (VAR_4 = 0; VAR_4 < VAR_3->bs_num_env; VAR_4++) { const float recip_env_size = 0.5f / (VAR_3->t_env[VAR_4 + 1] - VAR_3->t_env[VAR_4]); int ilb = VAR_3->t_env[VAR_4]     * 2 + ENVELOPE_ADJUSTMENT_OFFSET; int iub = VAR_3->t_env[VAR_4 + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; for (VAR_6 = 0; VAR_6 < VAR_2->VAR_6[1]; VAR_6++) { float sum = 0.0f; for (VAR_5 = ilb; VAR_5 < iub; VAR_5++) { sum += VAR_1[VAR_6 + VAR_2->kx[1]][VAR_5][0] * VAR_1[VAR_6 + VAR_2->kx[1]][VAR_5][0] +
VAR_1[VAR_6 + VAR_2->kx[1]][VAR_5][1] * VAR_1[VAR_6 + VAR_2->kx[1]][VAR_5][1]; } VAR_0[VAR_4][VAR_6] = sum * recip_env_size; } } } else { int VAR_7, VAR_8; for (VAR_4 = 0; VAR_4 < VAR_3->bs_num_env; VAR_4++) { const int env_size = 2 * (VAR_3->t_env[VAR_4 + 1] - VAR_3->t_env[VAR_4]); int ilb = VAR_3->t_env[VAR_4]     * 2 + ENVELOPE_ADJUSTMENT_OFFSET; int iub = VAR_3->t_env[VAR_4 + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; const uint16_t *table = VAR_3->bs_freq_res[VAR_4 + 1] ? VAR_2->f_tablehigh : VAR_2->f_tablelow; for (VAR_8 = 0; VAR_8 < VAR_2->n[VAR_3->bs_freq_res[VAR_4 + 1]]; VAR_8++) { float sum = 0.0f; const int den = env_size * (table[VAR_8 + 1] - table[VAR_8]); for (VAR_7 = table[VAR_8]; VAR_7 < table[VAR_8 + 1]; VAR_7++) { for (VAR_5 = ilb; VAR_5 < iub; VAR_5++) { sum += VAR_1[VAR_7][VAR_5][0] * VAR_1[VAR_7][VAR_5][0] +
VAR_1[VAR_7][VAR_5][1] * VAR_1[VAR_7][VAR_5][1]; } } sum /= den; for (VAR_7 = table[VAR_8]; VAR_7 < table[VAR_8 + 1]; VAR_7++) { VAR_0[VAR_4][VAR_7 - VAR_2->kx[1]] = sum; } } } } }