Expand description
Opus packet frame-packing parser (RFC 6716 §3.2).
The TOC byte (§3.1, decoded by crate::toc::OpusTocByte) determines
how the rest of the packet is sliced into compressed Opus frames:
- Code 0 (§3.2.2) — one frame, the remaining
N - 1bytes. - Code 1 (§3.2.3) — two equal-size frames;
(N - 1)MUST be even (requirement R3), each frame is(N - 1) / 2bytes. - Code 2 (§3.2.4) — two frames; a one- or two-byte §3.2.1 length sequence gives the size of the first frame, the rest is the second frame (requirement R4).
- Code 3 (§3.2.5) — a signalled frame count
Mplus optional Opus padding and, for VBR,M - 1per-frame length sequences. The final frame consumes whatever remains before the trailing padding.
This module performs the §3.2 layer only. It returns the compressed-frame byte slices (borrowed from the input buffer) so the SILK / CELT decoders can be wired up against them in a subsequent round. Length zero is a legal §3.2.1 result (DTX / lost frame); such frames appear as empty slices in the returned list.
Structs§
- Opus
Packet - A fully-parsed Opus packet: TOC byte plus the per-frame slices recovered by walking the §3.2 frame-packing layer.
Constants§
- MAX_
FRAMES_ PER_ PACKET - Maximum number of frames a code-3 packet may signal. RFC 6716 §3.2.5: “M MUST NOT be zero, and the audio duration contained within a packet MUST NOT exceed 120 ms [R5]. This limits the maximum frame count for any frame size to 48 (for 2.5 ms frames)”.
- MAX_
FRAME_ BYTES - Maximum compressed frame length permitted by the §3.2.1 two-byte length encoding. RFC 6716 §3.2.1: “The maximum representable length is 255 * 4 + 255 = 1275 bytes.” Requirement R2 forbids any individual frame from exceeding this.