implement adaptive bit reservoir and PE-driven rate control - #184
Open
nschimme wants to merge 1 commit into
Open
implement adaptive bit reservoir and PE-driven rate control#184nschimme wants to merge 1 commit into
nschimme wants to merge 1 commit into
Conversation
Introduces an adaptive bit reservoir and Perceptual Entropy (PE) driven rate control architecture to improve audio quality on transient-heavy content and optimize bitrate accuracy across ABR modes. Key changes: - Add fast subblock energy PE calculation (`PsyCalcPE`) to detect transient frames without transcendental math overhead. - Maintain persistent bit reservoir state (`bitReservoir`) capped according to ISO/IEC 14496-3 payload limits. - Implement PE-gated reservoir draws for high-entropy frames and bit replenishment for simple frames. - Stabilize quality feedback using proportional reservoir error correction, dynamic damping, and slew-rate clamping [0.80, 1.20]. - Refine initial quality seeding with sample-rate aware scaling for rapid ABR convergence on short audio clips.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces an adaptive bit reservoir and dynamic rate control system to deliver significantly improved ABR targeting and overall bitrate accuracy.
Why?
The existing rate control relies solely on a static dampener, leading to three major issues in dynamic or non-standard encoding scenarios:
This PR introduces an ISO-compliant adaptive bit reservoir paired with closed-loop feedback control to address these issues:
Kp = 0.08) and dynamic damping to eliminate target drift.Key Changes & Algorithm Choices
blockswitch.c): Approximates Perceptual Entropy (PE) using pre-computed subblock high-pass energies scaled by1.0e-8fwhile gating reservoir draws (PE > 10.0 * channels) to properly fund transient attacks.frame.c): Caps capacity atmin(2 * desbits, 6144 * channels - desbits)and restricts single-frame draws (desbits / 2for <=24 kbps;desbitsfor higher) to prevent low-bitrate reservoir exhaustion.frame.c): Stabilizes quality using proportional reservoir error correction (Kp = 0.08), fill-dependent dynamic damping (0.60->0.85), a0.5%update deadband, and[0.80, 1.20]quality scale factor clamping.frame.c): Scales initial quality seeds by44100 / sampleRateto achieve rapid 1–2 frame ABR convergence on short audio clips across all sample rates.Empirical CI Benchmarks
.text: -0.38%,.rodata: +0.77%Benchmark: https://github.com/nschimme/faac/actions/runs/33309978924