1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2026-10-24 02:09:03 +03:00

avcodec/aaccoder: widen PNS candidacy to near-masked bands

Bands whose energy sits between threshold/4 and 2x threshold are
deletion candidates for the trellis: coded, they round to silence under
pressure, and an audible hole is worse than energy-matched noise. Let
them qualify for PNS with a relaxed uniformity requirement, so the
noise substitution keeps the texture the allocator was about to delete.
This commit is contained in:
Lynne
2026-07-17 14:19:15 +08:00
parent 646f2796c8
commit abe157fbf2

View File

@@ -664,10 +664,20 @@ static void mark_pns(AACEncContext *s, AVCodecContext *avctx, SingleChannelEleme
* 3. on short window groups, all windows have similar energy (variations in energy would be destroyed by PNS)
*/
sce->pns_ener[w*16+g] = sfb_energy;
if (sfb_energy < threshold*sqrtf(1.5f/freq_boost) || spread < spread_threshold || min_energy < pns_transient_energy_r * max_energy) {
sce->can_pns[w*16+g] = 0;
} else {
sce->can_pns[w*16+g] = 1;
{
/* near-mask PNS class (E in [thr/4, 2*thr]): deletion
* candidates go to noise, not silence (AAC_PNSHOLE) */
int near = sfb_energy < 2.0f * threshold &&
sfb_energy > threshold * 0.25f;
if (near) {
/* deletion candidate: noise beats the ~silent rendition */
sce->can_pns[w*16+g] = spread >= spread_threshold &&
min_energy >= 0.2f * max_energy;
} else if (sfb_energy < threshold*sqrtf(1.5f/freq_boost) || spread < spread_threshold || min_energy < pns_transient_energy_r * max_energy) {
sce->can_pns[w*16+g] = 0;
} else {
sce->can_pns[w*16+g] = 1;
}
}
}
}