Skip to content

internal/rangecoding: add range encoder#112

Merged
thomas-vilte merged 1 commit into
pion:mainfrom
thomas-vilte:feat/opus-encoder
May 18, 2026
Merged

internal/rangecoding: add range encoder#112
thomas-vilte merged 1 commit into
pion:mainfrom
thomas-vilte:feat/opus-encoder

Conversation

@thomas-vilte
Copy link
Copy Markdown
Contributor

Description

Implements the range encoder defined in RFC 6716 Section 5.1.

This is the symmetric counterpart to the existing Decoder. It maintains
the four-tuple state (val, rng, rem, ext) described in the RFC and
implements carry propagation via the rem/extBytes buffer.

All operations are verified via round-trip tests against the existing
decoder. The RFC 5.1 invariant — that encoder.FinalRange() must equal
decoder.FinalRange() after the same symbol sequence — is explicitly
tested.

Reference issue

Related to #34

@Sean-Der
Copy link
Copy Markdown
Member

@thomas-vilte phenomenal PR!

Would you mind squashing/update your PR message to be just like your GitHub PR?

Are you planning on working on a full encoder. Very excited to see what you build :) I am here to support you in any way you need!

@thomas-vilte
Copy link
Copy Markdown
Contributor Author

yes. The plan is to implement a full celt encoder, the range encoder is the first building block once it's merged I'll start on the encoder core. Would love your input on the overall approach before diving in :D

@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 88.82682% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.96%. Comparing base (67f6be3) to head (61c517a).

Files with missing lines Patch % Lines
internal/rangecoding/encoder.go 88.82% 11 Missing and 9 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #112      +/-   ##
==========================================
+ Coverage   82.73%   82.96%   +0.23%     
==========================================
  Files          21       22       +1     
  Lines        4518     4697     +179     
==========================================
+ Hits         3738     3897     +159     
- Misses        598      609      +11     
- Partials      182      191       +9     
Flag Coverage Δ
go 82.96% <88.82%> (+0.23%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@Sean-Der
Copy link
Copy Markdown
Member

Amazing!

join the discord and would love to chat about it. You should also just say hi to everyone love to have people building great stuff in community

I don’t have anything in particular. My goal is to keep to code as readable as possible. SILK decoder was hand written, trying to keep matching it.

After this is done would love to build a server side AEC. Make it easier for people doing voice AI

@Sean-Der
Copy link
Copy Markdown
Member

Also added you to pion org! When CI passes you can merge your code. Excited to work together

@thomas-vilte thomas-vilte merged commit de54ba8 into pion:main May 18, 2026
19 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