Repository navigation
opus-pure 0.2.0
Reading an .opus file back now returns exactly the audio that was encoded, and writing one puts exactly that audio in. Both halves of the documented round trip were wrong before, in ways that were silent.
Fixed
The documented decode recipe dropped the end-trim. README, crate docs and examples/decode.rs applied the pre-skip but not RFC 7845 §4.4, leaving up to a frame of padding past the end of the audio on any file carrying one — which every opusenc file does. Inaudible on a clip played once; an audible gap at every seam of a loop.
The documented encode recipe lost the tail. It padded only to the frame boundary, so the encoder's algorithmic delay was never flushed and the last few milliseconds of every clip stayed inside the encoder. write_packet_with_duration, which states the end-trim, appeared in no example.
Cross-checked against ffmpeg, which implements the same trimming independently and decodes the output to the same sample count.
Added
Trim— applies the pre-skip (§4.2) and end-trim (§4.4) to decoded PCM. Both are a few lines every consumer of the container would otherwise write, and both fail silently when written wrong.OpusHead::decoder— a decoder carrying the header's channel count and output gain. The gain is the one that fails silently: the file plays at the wrong level with no other symptom.OggOpusWriter::granule— the granule position reached, so declaring an end-trim is a subtraction rather than a derivation that assumes uniform packet durations.MAX_PACKET_SAMPLES— decode-buffer size, the companion toMAX_PACKET_BYTES.OggPacket::new— construct one without muxing a stream, so code that consumes packets is testable.OpusMSDecoder::streams/streams_mut— mirroring the encoder. Without them a surround stream's declared output gain could not be applied at all, which RFC 7845 §5.1 asks a player to do whatever the mapping family.
Purely additive: nothing was removed or changed from the 0.1.0 public surface.
Notes
The Ogg reader still has no seek. It documents rewinding for playback loops, and the README says why a seek without §4.2 pre-roll would be worse than none.
Full changelog: v0.1.0...v0.2.0