Documentation
¶
Index ¶
- Constants
- func BandwidthForRate(sampleRate int) (int, error)
- func GenerateTOC(channels int, frameSize int) (byte, error)
- func GenerateTOCExt(mode, bandwidth, channels int, frameSizeSamples int) (byte, error)
- func ParseTOC(toc byte) (config int, stereo bool, countCode int)
- func ParseTOCConfig(config int) (mode, bandwidth, frameSize int)
Constants ¶
const ( ModeSILKOnly = 0 ModeHybrid = 1 ModeCELTOnly = 2 )
Opus Mode types for TOC generation
const ( BandwidthNarrowband = 0 // NB: 8kHz BandwidthMediumband = 1 // MB: 12kHz BandwidthWideband = 2 // WB: 16kHz BandwidthSuperwideband = 3 // SWB: 24kHz BandwidthFullband = 4 // FB: 48kHz )
Opus bandwidth types for TOC generation
const ( FrameSize2_5ms = 120 FrameSize5ms = 240 FrameSize10ms = 480 FrameSize20ms = 960 FrameSize40ms = 1920 FrameSize60ms = 2880 )
Frame Duration codes (RFC 6716 Section 3.1) These are frame sizes in samples at 48kHz.
const ( ConfigCELT_Mono_20ms = 20 ConfigCELT_Stereo_20ms = 22 )
Legacy config constants (kept for backward compatibility in tests).
Variables ¶
This section is empty.
Functions ¶
func BandwidthForRate ¶
BandwidthForRate returns the Opus bandwidth for a given sample rate.
func GenerateTOC ¶
GenerateTOC creates a TOC byte for CELT-only fullband mode. This is the legacy interface. For multi-rate support, the encoder uses GenerateTOCExt internally and this function remains for backward compatibility.
frameSize is in samples at 48kHz. Only 960 (20ms) is supported by this function.
func GenerateTOCExt ¶
GenerateTOCExt creates a TOC byte for any supported mode/bandwidth/frame-size combination.
RFC 6716 Table 2 defines 32 configurations (0-31):
Configs 0- 3: SILK-only NB (10/20/40/60ms) Configs 4- 7: SILK-only MB (10/20/40/60ms) Configs 8-11: SILK-only WB (10/20/40/60ms) Configs 12-13: Hybrid SWB (10/20ms) Configs 14-15: Hybrid FB (10/20ms) Configs 16-19: CELT-only NB (2.5/5/10/20ms) Configs 20-23: CELT-only WB (2.5/5/10/20ms) Configs 24-27: CELT-only SWB (2.5/5/10/20ms) Configs 28-31: CELT-only FB (2.5/5/10/20ms)
func ParseTOC ¶
ParseTOC parses the Table Of Contents (TOC) byte. Returns configuration ID (0-31), stereo flag, and frame count code (0-3). RFC 6716 Section 3.1: TOC Byte: | config (5 bits) | s (1 bit) | c (2 bits) |
func ParseTOCConfig ¶
ParseTOCConfig extracts mode, bandwidth, and frame duration from a config number. Returns mode (SILK/Hybrid/CELT), bandwidth, and frame size in samples at 48kHz.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package celt implements the CELT (Constrained Energy Lapped Transform) codec.
|
Package celt implements the CELT (Constrained Energy Lapped Transform) codec. |
|
Package cgoref is the libopus CGO reference wrapper.
|
Package cgoref is the libopus CGO reference wrapper. |
|
Package dsp provides digital signal processing utilities for the Opus codec.
|
Package dsp provides digital signal processing utilities for the Opus codec. |
|
Package entcode provides entropy coding (range coding) for Opus, bit-exact with the range coder in libopus 1.3.1 (celt/entcode.c, celt/entenc.c, celt/entdec.c).
|
Package entcode provides entropy coding (range coding) for Opus, bit-exact with the range coder in libopus 1.3.1 (celt/entcode.c, celt/entenc.c, celt/entdec.c). |
|
Package resampler provides high-quality sample rate conversion for Opus.
|
Package resampler provides high-quality sample rate conversion for Opus. |
|
Package silk implements the SILK speech codec for Opus.
|
Package silk implements the SILK speech codec for Opus. |
|
Package testing provides verification and comparison tools for Opus library development.
|
Package testing provides verification and comparison tools for Opus library development. |