static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)

{

    int start = 0, w, w2, g;

    const float lambda = s->lambda;

    const float freq_mult = avctx->sample_rate/(1024.0f/sce->ics.num_windows)/2.0f;

    const float spread_threshold = NOISE_SPREAD_THRESHOLD*(lambda/120.f);

    const float thr_mult = NOISE_LAMBDA_NUMERATOR/lambda;



    for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {

        start = 0;

        for (g = 0;  g < sce->ics.num_swb; g++) {

            if (start*freq_mult > NOISE_LOW_LIMIT*(lambda/170.0f)) {

                float energy = 0.0f, threshold = 0.0f, spread = 0.0f;

                for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {

                    FFPsyBand *band = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g];

                    energy += band->energy;

                    threshold += band->threshold;

                    spread += band->spread;

                }

                if (spread > spread_threshold*sce->ics.group_len[w] &&

                    ((sce->zeroes[w*16+g] && energy >= threshold) ||

                    energy < threshold*thr_mult*sce->ics.group_len[w])) {

                    sce->band_type[w*16+g] = NOISE_BT;

                    sce->pns_ener[w*16+g] = energy / sce->ics.group_len[w];

                    sce->zeroes[w*16+g] = 0;

                }

            }

            start += sce->ics.swb_sizes[g];

        }

    }

}

static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)

{

    int start = 0, w, w2, g;

    const float lambda = s->lambda;

    const float freq_mult = avctx->sample_rate/(1024.0f/sce->ics.num_windows)/2.0f;

    const float spread_threshold = NOISE_SPREAD_THRESHOLD*(lambda/120.f);

    const float thr_mult = NOISE_LAMBDA_NUMERATOR/lambda;



    for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {

        start = 0;

        for (g = 0;  g < sce->ics.num_swb; g++) {

            if (start*freq_mult > NOISE_LOW_LIMIT*(lambda/170.0f)) {

                float energy = 0.0f, threshold = 0.0f, spread = 0.0f;

                for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {

                    FFPsyBand *band = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g];

                    energy += band->energy;

                    threshold += band->threshold;

                    spread += band->spread;

                }

                if (spread > spread_threshold*sce->ics.group_len[w] &&

                    ((sce->zeroes[w*16+g] && energy >= threshold) ||

                    energy < threshold*thr_mult*sce->ics.group_len[w])) {

                    sce->band_type[w*16+g] = NOISE_BT;

                    sce->pns_ener[w*16+g] = energy / sce->ics.group_len[w];

                    sce->zeroes[w*16+g] = 0;

                }

            }

            start += sce->ics.swb_sizes[g];

        }

    }

}

static void FUNC_0(AACEncContext *VAR_0, AVCodecContext *VAR_1, SingleChannelElement *VAR_2)

{

    int VAR_3 = 0, VAR_4, VAR_5, VAR_6;

    const float VAR_7 = VAR_0->VAR_7;

    const float VAR_8 = VAR_1->sample_rate/(1024.0f/VAR_2->ics.num_windows)/2.0f;

    const float VAR_9 = NOISE_SPREAD_THRESHOLD*(VAR_7/120.f);

    const float VAR_10 = NOISE_LAMBDA_NUMERATOR/VAR_7;



    for (VAR_4 = 0; VAR_4 < VAR_2->ics.num_windows; VAR_4 += VAR_2->ics.group_len[VAR_4]) {

        VAR_3 = 0;

        for (VAR_6 = 0;  VAR_6 < VAR_2->ics.num_swb; VAR_6++) {

            if (VAR_3*VAR_8 > NOISE_LOW_LIMIT*(VAR_7/170.0f)) {

                float energy = 0.0f, threshold = 0.0f, spread = 0.0f;

                for (VAR_5 = 0; VAR_5 < VAR_2->ics.group_len[VAR_4]; VAR_5++) {

                    FFPsyBand *band = &VAR_0->psy.ch[VAR_0->cur_channel+0].psy_bands[(VAR_4+VAR_5)*16+VAR_6];

                    energy += band->energy;

                    threshold += band->threshold;

                    spread += band->spread;

                }

                if (spread > VAR_9*VAR_2->ics.group_len[VAR_4] &&

                    ((VAR_2->zeroes[VAR_4*16+VAR_6] && energy >= threshold) ||

                    energy < threshold*VAR_10*VAR_2->ics.group_len[VAR_4])) {

                    VAR_2->band_type[VAR_4*16+VAR_6] = NOISE_BT;

                    VAR_2->pns_ener[VAR_4*16+VAR_6] = energy / VAR_2->ics.group_len[VAR_4];

                    VAR_2->zeroes[VAR_4*16+VAR_6] = 0;

                }

            }

            VAR_3 += VAR_2->ics.swb_sizes[VAR_6];

        }

    }

}

static void FUNC_0(AACEncContext *VAR_0, AVCodecContext *VAR_1, SingleChannelElement *VAR_2)
{ int VAR_3 = 0, VAR_4, VAR_5, VAR_6; const float VAR_7 = VAR_0->VAR_7; const float VAR_8 = VAR_1->sample_rate/(1024.0f/VAR_2->ics.num_windows)/2.0f; const float VAR_9 = NOISE_SPREAD_THRESHOLD*(VAR_7/120.f); const float VAR_10 = NOISE_LAMBDA_NUMERATOR/VAR_7; for (VAR_4 = 0; VAR_4 < VAR_2->ics.num_windows; VAR_4 += VAR_2->ics.group_len[VAR_4]) { VAR_3 = 0; for (VAR_6 = 0;  VAR_6 < VAR_2->ics.num_swb; VAR_6++) { if (VAR_3*VAR_8 > NOISE_LOW_LIMIT*(VAR_7/170.0f)) { float energy = 0.0f, threshold = 0.0f, spread = 0.0f; for (VAR_5 = 0; VAR_5 < VAR_2->ics.group_len[VAR_4]; VAR_5++) { FFPsyBand *band = &VAR_0->psy.ch[VAR_0->cur_channel+0].psy_bands[(VAR_4+VAR_5)*16+VAR_6]; energy += band->energy; threshold += band->threshold; spread += band->spread; } if (spread > VAR_9*VAR_2->ics.group_len[VAR_4] &&
((VAR_2->zeroes[VAR_4*16+VAR_6] && energy >= threshold) ||
energy < threshold*VAR_10*VAR_2->ics.group_len[VAR_4])) { VAR_2->band_type[VAR_4*16+VAR_6] = NOISE_BT; VAR_2->pns_ener[VAR_4*16+VAR_6] = energy / VAR_2->ics.group_len[VAR_4]; VAR_2->zeroes[VAR_4*16+VAR_6] = 0; } } VAR_3 += VAR_2->ics.swb_sizes[VAR_6]; } } }