Skip to content

Add stereo mid/side encoding#126

Open
thomas-vilte wants to merge 2 commits into
pion:mainfrom
thomas-vilte:feat/opus-stereo-mid-side
Open

Add stereo mid/side encoding#126
thomas-vilte wants to merge 2 commits into
pion:mainfrom
thomas-vilte:feat/opus-stereo-mid-side

Conversation

@thomas-vilte

Copy link
Copy Markdown
Contributor

Description

Adds stereo encoding to the CELT layer. WithChannels(2) now produces valid stereo packets end-to-end: the public API deinterleaves the input, analysis runs per-channel, and quantAllBandsStereo handles mid/side coupling — mirroring the decoder's existing quantBand stereo path.

The theta encoder implements the same three probability models as decodeBandTheta (stereo-large with p0=3 at extremes, uniform, triangular). The stereo path uses midGain=1, level=0 for recursive calls, and nil lowband for the side channel — matching what the decoder expects. A FinalRange comparison test between encoder and decoder catches any range coder divergence after a stereo frame.

Intensity stereo and the dual-stereo L1 decision are left for follow-up PRs. For now, intensity=maxBands (disabled) and mid/side coupling is always used.

Reference issue

Fixes #...

@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.08696% with 77 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.77%. Comparing base (7dc8324) to head (ac16983).

Files with missing lines Patch % Lines
internal/celt/encode_bands.go 73.48% 58 Missing and 12 partials ⚠️
internal/celt/encoder.go 76.47% 2 Missing and 2 partials ⚠️
internal/celt/analysis.go 92.30% 1 Missing and 1 partial ⚠️
encoder.go 93.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #126      +/-   ##
==========================================
+ Coverage   82.88%   83.77%   +0.89%     
==========================================
  Files          29       29              
  Lines        6110     6398     +288     
==========================================
+ Hits         5064     5360     +296     
+ Misses        811      801      -10     
- Partials      235      237       +2     
Flag Coverage Δ
go 83.77% <76.08%> (+0.89%) ⬆️

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.

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.

1 participant