Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #93 +/- ##
==========================================
+ Coverage 79.02% 80.46% +1.44%
==========================================
Files 8 13 +5
Lines 1535 1966 +431
==========================================
+ Hits 1213 1582 +369
- Misses 276 329 +53
- Partials 46 55 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
469fda8 to
210651f
Compare
210651f to
ac1c253
Compare
There was a problem hiding this comment.
Pull request overview
Ports the RFC 6716 decoder-side SILK output resampler into Go and updates the Opus decoder to produce PCM at a caller-configured output sample rate and channel count (instead of the previous naive upsample-by-repetition path).
Changes:
- Add
internal/resample/silkimplementing the SILK decoder resampler (delay handling + per-ratio FIR/IIR paths) with fixture-based tests. - Update
Decoderto accept a configured output format (NewDecoderWithOutput/Init) and resample SILK output accordingly. - Add
DecodeToInt16/DecodeToFloat32helpers and adjust PCM conversion rounding/clamping behavior.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
decoder.go |
Stores requested output format, resamples SILK output to requested rate/channels, adds decode helpers. |
errors.go |
Adds new public decoder validation/buffer errors. |
decoder_test.go |
Adds tests for new constructor and decode helper behavior. |
packet_test.go |
Updates empty-packet decode test for expanded return values. |
internal/resample/silk/resampler.go |
Core resampler state, init, delay management, and float/int conversions. |
internal/resample/silk/up2_hq.go |
2x HQ upsampling path. |
internal/resample/silk/iir_fir.go |
IIR/FIR upsample/interpolation path. |
internal/resample/silk/down_fir.go |
Downsample FIR path. |
internal/resample/silk/ar2.go |
AR2 helper used by downsampling. |
internal/resample/silk/fixed.go |
Fixed-point math helpers used by resampler. |
internal/resample/silk/rom.go |
Resampler coefficient ROM tables. |
internal/resample/silk/resampler_test.go |
Impulse fixtures, chunking equivalence, and round-trip error bounds. |
internal/bitdepth/bitdepth.go |
Adjusts float32→int16 quantization (round/clamp). |
internal/bitdepth/bitdepth_test.go |
Updates expected byte output for new quantization. |
internal/resample/resample.go |
Removes old naive repetition-based resampler implementation. |
internal/resample/resample_test.go |
Removes tests for the deleted naive resampler. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
This ports the decoder-side SILK output resampler from the RFC reference implementation into a dedicated Go subpackage and wires the Opus decoder to resample SILK output directly to the caller's requested output rate.
The branch removes the old naive sample-repetition path and replaces it with the RFC-style decoder resampler state, delay handling, and per-ratio FIR/IIR paths.
Public API
This PR updates the public decoder API so callers can request a specific output sample rate and channel count instead of relying on the old fixed behavior:
NewDecoderWithOutput(sampleRate, channels)(*Decoder).Init(sampleRate, channels)to validate and store the requested output formatDecodeToInt16andDecodeToFloat32helpers that return samples-per-channelDecode/DecodeFloat32use the configured output format before converting to the public PCM buffersThat aligns the exposed API with the output rates exercised by the RFC conformance flow: 8, 12, 16, 24, or 48 kHz, mono or stereo.
RFC Alignment
Where possible, this follows the RFC/reference implementation directly:
Relevant references:
Implementation Notes
internal/resample/silkas a Go port of the RFC SILK decoder resamplerDecoderso mono/stereo SILK output can be resampled without reinitializing every packetValidation
go test ./...go test -race ./...golangci-lint run, but the tool currently fails in this environment before analysis withcontext loading failed: no go files to analyze