Lines Matching refs:pe
114 float pe; ///< perceptual entropy
160 } pe;
327 pctx->pe.min = 8.0f * AAC_BLOCK_SIZE_LONG * bandwidth / (ctx->avctx->sample_rate * 2.0f);
328 pctx->pe.max = 12.0f * AAC_BLOCK_SIZE_LONG * bandwidth / (ctx->avctx->sample_rate * 2.0f);
494 static int calc_bit_demand(AacPsyContext *ctx, float pe, int bits, int size,
508 clipped_pe = av_clipf(pe, ctx->pe.min, ctx->pe.max);
519 bit_factor = 1.0f - bit_save + ((bit_spend - bit_save) / (ctx->pe.max - ctx->pe.min)) * (clipped_pe - ctx->pe.min);
520 /* NOTE: The reference encoder attempts to center pe max/min around the current pe.
521 * Here we do that by slowly forgetting pe.min when pe stays in a range that makes
524 ctx->pe.max = FFMAX(pe, ctx->pe.max);
525 forgetful_min_pe = ((ctx->pe.min * PSY_PE_FORGET_SLOPE)
526 + FFMAX(ctx->pe.min, pe * (pe / ctx->pe.max))) / (PSY_PE_FORGET_SLOPE + 1);
527 ctx->pe.min = FFMIN(pe, forgetful_min_pe);
539 float pe, a;
541 band->pe = 0.0f;
546 pe = a - log2f(band->thr);
548 if (pe < PSY_3GPP_C1) {
549 pe = pe * PSY_3GPP_C3 + PSY_3GPP_C2;
553 band->pe = pe * band->nz_lines;
557 return band->pe;
560 static float calc_reduction_3gpp(float a, float desired_pe, float pe,
568 thr_avg = exp2f((a - pe) / (4.0f * active_lines));
660 float pe = pctx->chan_bitrate > 32000 ? 0.0f : FFMAX(50.0f, 100.0f - pctx->chan_bitrate * 100.0f / 32000.0f);
696 pe += calc_pe_3gpp(band);
709 ctx->ch[channel].entropy = pe;
714 desired_pe = pe * (ctx->avctx->global_quality ? ctx->avctx->global_quality : 120) / (2 * 2.5f * 120.0f);
724 pctx->pe.max = FFMAX(pe, pctx->pe.max);
725 pctx->pe.min = FFMIN(pe, pctx->pe.min);
727 desired_bits = calc_bit_demand(pctx, pe, ctx->bitres.bits, ctx->bitres.size, wi->num_windows == 8);
735 desired_pe *= av_clipf(pctx->pe.previous / PSY_3GPP_BITS_TO_PE(ctx->bitres.bits),
738 pctx->pe.previous = PSY_3GPP_BITS_TO_PE(desired_bits);
741 if (desired_pe < pe) {
744 reduction = calc_reduction_3gpp(a, desired_pe, pe, active_lines);
745 pe = 0.0f;
753 pe += calc_pe_3gpp(band);
768 pe_no_ah += band->pe;
774 desired_pe_no_ah = FFMAX(desired_pe - (pe - pe_no_ah), 0.0f);
778 pe = 0.0f;
785 pe += calc_pe_3gpp(band);
793 delta_pe = desired_pe - pe;
798 if (pe < 1.15f * desired_pe) {
819 while (pe > desired_pe && g--) {
825 pe += band->active_lines * 1.5f - band->pe;
841 psy_band->bits = PSY_3GPP_PE_TO_BITS(band->pe);