Repository navigation
Share a U(N,K) table for CWRS encode and decode - #266
Merged
Merged
Conversation
Build 16 rows of U(N,K) once and use them to encode and decode PVQ codewords instead of building and rewinding a recurrence row on every call. Codebooks outside the table keep the old path, with a small per-encoder row cache when encoding. Packets and decoded PCM don't change.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #266 +/- ##
==========================================
- Coverage 95.93% 95.88% -0.05%
==========================================
Files 67 68 +1
Lines 10536 10654 +118
==========================================
+ Hits 10108 10216 +108
- Misses 428 438 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
JoTurk
approved these changes
Nov 17, 2026
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.
Description
Encoding and decoding a PVQ codeword built a U(N,K) recurrence row and then rewound it coefficient by coefficient. Every codebook CELT uses in practice has a small minimum dimension, so I build 16 rows of U(N,K) up to N=208 once at init (13 KB) and both directions become table lookups, following libopus icwrs/cwrsi. Codebooks outside the table, or whose size doesn't fit in 32 bits, still go through the old code, with a small per-encoder row cache when encoding.
Packets and decoded PCM don't change (72 encoder configurations over 12 music tracks, 196 decoder cases). On those tracks the encoder is 4–10% faster and the decoder 8–14%.
The tests compare the table with the recurrence and the new encode/decode with the old code for every supported codebook, including invalid vectors and the fallback.
Reference issue
N/A