Skip to content

Share a U(N,K) table for CWRS encode and decode - #266

Merged
thomas-vilte merged 1 commit into
pion:mainfrom
thomas-vilte:celt-cwrs-table
Nov 17, 2026
Merged

thomas-vilte merged 1 commit into
pion:mainfrom
thomas-vilte:celt-cwrs-table

Conversation

@thomas-vilte

Copy link
Copy Markdown
Member

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

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.
@thomas-vilte
thomas-vilte requested a review from JoTurk November 17, 2026 22:41
@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.88%. Comparing base (ef9d4fe) to head (17562c8).

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     
Flag Coverage Δ
go 95.88% <100.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@thomas-vilte
thomas-vilte merged commit fe19d36 into pion:main Nov 17, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants