Releases: darui3018823/opus
v1.2.0
Pure Go implementation of the Opus audio codec (RFC 6716 / RFC 8251). This is a
backward-compatible additive release over v1.1.1.
Public API expansion
- Multistream encoder/decoder APIs.
- Surround with standard channel mappings.
- Projection / Ambisonics (mapping families 2 and 3).
- Ogg Opus container (single logical stream).
- Packet extensions (RFC 8251 padding/extension parsing and generation).
- Repacketizer and packet padding helpers; packet-inspection helpers.
- 24-bit PCM (
Encode24/Decode24) and float32 encode/decode. - CELT phase-inversion controls; production codec controls, getters, and a
libopus-defaults profile; automatic/maximum bitrate; broadened voice-mode rate
policy.
In-band FEC (LBRR)
- SILK-only and hybrid in-band FEC encode and decode for mono and stereo
(SetInbandFEC+ non-zero packet-loss percentage).DecodeFECreconstructs
lost frames from the redundant copy; missing/inactive slots fall back to PLC.
SILK encoder quality
- Proper
silk_find_LPC_FLP-path NLSF target (Burg LPC + A2NLSF), active NLSF
interpolation, and voiced/unvoiced delayed-decision (trellis) NSQ. - Fixed a low-F0 first-frame pitch misdetection (16 kHz speech-harmonic peak
overshoot). On the AB scoreboard the encoder now matches or beats libopus on
all 15 sampled cells (8/12/16 kHz Γ silence/unvoiced/steady/harmonic/onset).
Decoder
- RFC 8251 official vector suite at 12/12 PASS; verified against libopus 1.6.1
via the opusref reference tests.
Hardening
- Expanded opusref interoperability CI, parser fuzz targets, PLC/FEC separation,
and assorted defensive fixes (PLC pitch-history update at 16 kHz, packet
padding overflow guard, content-hint reapply on encoder Reset).
Full changelog: v1.1.1...v1.2.0
v1.1.1
v1.1.1 β Codec correctness and API polish
What's fixed
- Fixed mono decoders handling stereo CELT/hybrid packets by decoding stereo payloads with stereo CELT state before downmixing.
- Enforced the Opus 120 ms packet-duration limit on encode and decode paths.
- Rejected unsupported encoder frame sizes instead of silently padding or trimming non-20 ms multiples.
- Returned
ErrBufferTooSmallfromDecodeinstead of silently truncating output after advancing decoder state. - Made
GetLastPacketDurationreport the actual decoded packet duration. - Fixed mono SILK multi-frame LBRR side-symbol consumption to keep the range decoder aligned.
- Reset CELT final-range folding seed and hardened low-budget transient fallback.
- Fixed raw-only entropy
EncodeBitsflush behavior.
API additions since v1.1.0
- Added Encoder getters for bitrate, complexity, VBR state, and application mode.
- Exposed
SetSignalType/SignalTypeso callers can provide voice/music hints.
Validation
go test ./...go vet ./...
Upgrade: go get github.com/darui3018823/opus@v1.1.1
v1.1.0
v1.1.0 β Full CELT Encoder Quality Pipeline
What's new
Encoder β full CELT quality pipeline (Phase 1+2)
v1.0.0 shipped a working but basic CELT encoder. v1.1.0 completes the quality
pipeline: the encoder now produces standard Opus packets that libopus 1.6.1
decodes correctly, with SNR competitive with a full-featured codec at 64 kbps.
Signal quality
| Signal | SNR (64 kbps) |
|---|---|
| 440 Hz sine | ~48 dB |
| 1 kHz sine | ~47 dB |
| 4 kHz sine | ~39 dB |
| 1 kHz stereo | ~43 dB |
New encoder features
- Signal-driven bandwidth detection β per-frame FFT power analysis selects NB/WB/SWB/FB automatically; asymmetric hysteresis prevents flapping. Manual override via
SetBandwidth/SetMaxBandwidth. - Application-coupled bandwidth β
ApplicationVOIPprefers narrower tiers for voice;ApplicationAudiouses music defaults. - Transient detection + short-block MDCT β time-domain HPF masking (
transientAnalysis) switches to 8Γ120-sample short blocks to limit pre-echo.patchTransientDecisionis a complementary band-energy fallback for onsets the time-domain detector misses. - tf_analysis β per-band transform-resolution RDO via 2-pass Viterbi.
- dynalloc / alloc_trim / spread β masking-follower dynamic allocation boost, spectral-tilt trim, spreading decision with recursive hysteresis.
- Stereo decisions β
stereoAnalysis(dual vs joint M/S), intensity stereo with hysteresis. - Anti-collapse β consecutive-transient bit prevents spectral collapse.
- VBR / CVBR rate control β
SetVBR(true)/SetVBRConstraint(true). - Multi-frame packetization β 20/40/60 ms packets (RFC 6716 Β§3.2 codes 0β3) including code-3 padding.
SetPacketPaddingfor explicit padding. - Silence detection + DTX β near-silent frames emit 2β3 byte packets;
SetDTXenables discontinuous transmission.
New public API
func (e *Encoder) SetVBRConstraint(constrained bool) // true = CVBR
func (e *Encoder) SetBandwidth(bw Bandwidth) // Auto/NB/WB/SWB/FB
func (e *Encoder) SetMaxBandwidth(bw Bandwidth)
func (e *Encoder) Bandwidth() Bandwidth
func (e *Encoder) SetDTX(dtx bool)
func (e *Encoder) SetPacketPadding(n int)
const BandwidthAuto Bandwidth = ... // plus BandwidthNB/WB/SWB/FBDecoder β unchanged
The decoder continues to pass all 12 official RFC 8251 test vectors (RMSE < 0.001) and matches the libopus 1.6.1 reference.
Not yet implemented: SILK encoder, hybrid (SILK+CELT) encoder, FEC/PLC encode. The encoder is not bit-exact with libopus.
Upgrade: go get github.com/darui3018823/opus@v1.1.0
v1.0.0
v1.0.0 β Initial Release
Pure Go implementation of the Opus audio codec (RFC 6716), with no runtime CGO dependency.
Features
- Encoder: Accepts 8/12/16/24/48 kHz mono/stereo input; resamples to 48 kHz; emits CELT-only fullband 20 ms packets
- Decoder: Full CELT, SILK, and hybrid (SILK+CELT) packet decoding
- Hybrid SILK+CELT reconstruction (time-domain sum)
- Hybrid SILKβCELT redundancy / crossfade
- RFC 6716 Β§3.2.5 code-3 multi-byte padding support
- RFC 8251 official test vectors: 12/12 PASS (all RMSE < 0.001)
- Entropy coder: Range encoder/decoder (
internal/entcode) - DSP utilities: FFT, MDCT/IMDCT, windowing (
internal/dsp) - Resampler: Opus-rate sample rate conversion (
internal/resampler) - CI: GitHub Actions matrix (amd64 + arm64), race detector, benchmarks, fuzz targets
Package
go get github.com/darui3018823/opus@v1.0.0