libopustest

package
v0.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: BSD-3-Clause Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (

	// CELTAlgQuantModeQuant drives FIXED_POINT alg_quant with a real ec_enc.
	CELTAlgQuantModeQuant = uint32(0)
	// CELTAlgQuantModeUnquant drives FIXED_POINT alg_unquant with a real ec_dec.
	CELTAlgQuantModeUnquant = uint32(1)
)
View Source
const (

	// CELTAllocAnalysisModeTFAnalysis selects the FIXED_POINT tf_analysis kernel.
	CELTAllocAnalysisModeTFAnalysis = uint32(0)
	// CELTAllocAnalysisModeTFEncode selects the FIXED_POINT tf_encode kernel.
	CELTAllocAnalysisModeTFEncode = uint32(1)
	// CELTAllocAnalysisModeAllocTrim selects the FIXED_POINT alloc_trim_analysis kernel.
	CELTAllocAnalysisModeAllocTrim = uint32(2)
)
View Source
const (

	// CELTAntiCollapseModeRenormalise selects the FIXED_POINT
	// renormalise_vector kernel.
	CELTAntiCollapseModeRenormalise = uint32(0)
	// CELTAntiCollapseModeAntiCollapse selects the FIXED_POINT anti_collapse
	// kernel.
	CELTAntiCollapseModeAntiCollapse = uint32(1)
)
View Source
const (

	// CELTDecodeModeEnergy selects the FIXED_POINT energy unquantizers
	// (unquant_coarse_energy + unquant_fine_energy + unquant_energy_finalise).
	CELTDecodeModeEnergy = uint32(0)
	// CELTDecodeModeDecode selects the full FIXED_POINT celt_decode_with_ec.
	CELTDecodeModeDecode = uint32(1)
	// CELTDecodeModeDecodeSeq decodes a sequence of packets through one
	// FIXED_POINT decoder (cross-frame state + downsample output path).
	CELTDecodeModeDecodeSeq = uint32(2)
)
View Source
const (

	// CELTEncodeModeEncode selects the full FIXED_POINT celt_encode_with_ec,
	// dumping the produced packet bytes.
	CELTEncodeModeEncode = uint32(0)
	// CELTEncodeModeFrontend selects the inline FIXED_POINT encode front-end
	// (celt_preemphasis + compute_mdcts + compute_band_energies +
	// normalise_bands), dumping freq, bandE and the normalised X.
	CELTEncodeModeFrontend = uint32(1)
	// CELTEncodeModeEncodeSeq encodes N consecutive frames on a single encoder
	// (VBR/CVBR/CBR), dumping every produced packet so cross-frame state can be
	// validated.
	CELTEncodeModeEncodeSeq = uint32(2)
	// CELTEncodeModeEncodeExt runs one celt_encode_with_ec frame with the LFE
	// and/or energy_mask controls applied, dumping the produced packet bytes.
	CELTEncodeModeEncodeExt = uint32(3)
)
View Source
const (

	// CELTFixedMathModeSqrt selects the FIXED_POINT celt_sqrt kernel.
	CELTFixedMathModeSqrt = uint32(0)
	// CELTFixedMathModeSqrt32 selects the FIXED_POINT celt_sqrt32 kernel.
	CELTFixedMathModeSqrt32 = uint32(1)
	// CELTFixedMathModeRsqrtNorm32 selects the FIXED_POINT celt_rsqrt_norm32 kernel.
	CELTFixedMathModeRsqrtNorm32 = uint32(2)
	// CELTFixedMathModeComputeBandEnergies selects the FIXED_POINT
	// compute_band_energies kernel (array-shaped oracle).
	CELTFixedMathModeComputeBandEnergies = uint32(3)
	// CELTFixedMathModeNormaliseBands selects the FIXED_POINT normalise_bands
	// kernel (array-shaped oracle).
	CELTFixedMathModeNormaliseBands = uint32(4)
	// CELTFixedMathModeRcp selects the FIXED_POINT celt_rcp kernel.
	CELTFixedMathModeRcp = uint32(5)
	// CELTFixedMathModeRcpNorm16 selects the FIXED_POINT celt_rcp_norm16 kernel.
	CELTFixedMathModeRcpNorm16 = uint32(6)
	// CELTFixedMathModeRcpNorm32 selects the FIXED_POINT celt_rcp_norm32 kernel.
	CELTFixedMathModeRcpNorm32 = uint32(7)
	// CELTFixedMathModeCosNorm selects the FIXED_POINT celt_cos_norm kernel.
	CELTFixedMathModeCosNorm = uint32(8)
	// CELTFixedMathModeCosNorm32 selects the FIXED_POINT celt_cos_norm32 kernel.
	CELTFixedMathModeCosNorm32 = uint32(9)
	// CELTFixedMathModeFracDiv32Q29 selects the FIXED_POINT frac_div32_q29
	// kernel (two int32 inputs per record).
	CELTFixedMathModeFracDiv32Q29 = uint32(10)
	// CELTFixedMathModeFracDiv32 selects the FIXED_POINT frac_div32 kernel
	// (two int32 inputs per record).
	CELTFixedMathModeFracDiv32 = uint32(11)
)
View Source
const (
	CELTMathModeLog2               = uint32(0)
	CELTMathModeExp2               = uint32(1)
	CELTMathModeFracMul16          = uint32(2)
	CELTMathModeBitexactCos        = uint32(3)
	CELTMathModeBitexactLog2Tan    = uint32(4)
	CELTMathModeISqrt32            = uint32(5)
	CELTMathModeUdiv               = uint32(6)
	CELTMathModeSudiv              = uint32(7)
	CELTMathModeLog2TanTheta       = uint32(8)
	CELTMathModeAtanNorm           = uint32(9)
	CELTMathModeAtan2pNorm         = uint32(10)
	CELTMathModeCosNorm2           = uint32(11)
	CELTMathModeStereoIthetaQ30    = uint32(12)
	CELTMathModeLog                = uint32(13)
	CELTMathModeSin                = uint32(14)
	CELTMathModeBitexactThetaPair  = uint32(15)
	CELTMathModeDynallocImportance = uint32(16)
)
View Source
const (

	// CELTMDCTModeForward selects the FIXED_POINT clt_mdct_forward_c transform.
	CELTMDCTModeForward = uint32(0)
	// CELTMDCTModeBackward selects the FIXED_POINT clt_mdct_backward_c transform.
	CELTMDCTModeBackward = uint32(1)
)
View Source
const (

	// CELTTransientModeAnalysis selects the FIXED_POINT transient_analysis
	// kernel.
	CELTTransientModeAnalysis = uint32(0)
	// CELTTransientModePatch selects the FIXED_POINT patch_transient_decision
	// kernel.
	CELTTransientModePatch = uint32(1)
)
View Source
const (
	CTLOpSet     = 0
	CTLOpGet     = 1
	CTLOpProcess = 2
	CTLOpReset   = 3
)

CTL sequence opcodes. Values are in the libopus argument domain.

View Source
const (

	// DecodeDiffFormatFloat32 selects opus_decode_float (PCM is float32 LE).
	DecodeDiffFormatFloat32 = uint32(0)
	// DecodeDiffFormatInt16 selects opus_decode (PCM is int16 LE).
	DecodeDiffFormatInt16 = uint32(1)
	// DecodeDiffFormatInt24 selects opus_decode24 (PCM is int32 LE, 24-bit).
	DecodeDiffFormatInt24 = uint32(2)
)
View Source
const (
	DNNKernelSGEMV             = uint32(0)
	DNNKernelCGEMV8x4          = uint32(1)
	DNNKernelLinearCGEMV8x4    = uint32(2)
	DNNKernelLinearSparseSGEMV = uint32(3)
	DNNKernelConv2D3x3         = uint32(4)
)
View Source
const (
	EncodeDiffForceModeAuto     = 0
	EncodeDiffForceModeSILKOnly = 1000
	EncodeDiffForceModeHybrid   = 1001
	EncodeDiffForceModeCELTOnly = 1002
)

EncodeDiff force-mode codes (opus_private.h MODE_* consumed by OPUS_SET_FORCE_MODE). Zero leaves the mode auto.

View Source
const (
	EncodeDiffBandwidthAuto          = 0
	EncodeDiffBandwidthNarrowband    = 1101
	EncodeDiffBandwidthMediumband    = 1102
	EncodeDiffBandwidthWideband      = 1103
	EncodeDiffBandwidthSuperwideband = 1104
	EncodeDiffBandwidthFullband      = 1105
)

EncodeDiff bandwidth codes (OPUS_BANDWIDTH_*). Zero leaves the bandwidth unset (encoder auto-selects).

View Source
const (
	EncodeDiffSignalAuto  = uint32(0xFFFFFC18) // OPUS_AUTO = -1000
	EncodeDiffSignalVoice = uint32(3001)
	EncodeDiffSignalMusic = uint32(3002)
)

EncodeDiff signal codes (OPUS_SIGNAL_*). OPUS_AUTO (-1000) is the two's complement uint32.

View Source
const (
	EncodeDiffApplicationVoIP         = 2048
	EncodeDiffApplicationAudio        = 2049
	EncodeDiffApplicationRestrictedLD = 2051
)

EncodeDiff application codes (OPUS_APPLICATION_*).

View Source
const (
	FloatQuantModeFloat2Int16        = uint32(0)
	FloatQuantModeOSCEOutputScale    = uint32(1)
	FloatQuantModeFARGANSynthInt     = uint32(2)
	FloatQuantModeCELTRaw32767Round  = uint32(3)
	FloatQuantModeCELTDispatch       = uint32(4)
	FloatQuantModeSILKFloat2Short    = uint32(5)
	FloatQuantModeSILKFloat2IntScale = uint32(6)
	FloatQuantModeSILKShort2Float    = uint32(7)
	FloatQuantModeFloat2Int24        = uint32(8)
)
View Source
const (

	// KissFFTModeBfly2 selects the FIXED_POINT kf_bfly2 radix-2 butterfly.
	KissFFTModeBfly2 = uint32(0)
	// KissFFTModeBfly4 selects the FIXED_POINT kf_bfly4 radix-4 butterfly.
	KissFFTModeBfly4 = uint32(1)
	// KissFFTModeBfly3 selects the FIXED_POINT kf_bfly3 radix-3 butterfly.
	KissFFTModeBfly3 = uint32(2)
	// KissFFTModeBfly5 selects the FIXED_POINT kf_bfly5 radix-5 butterfly.
	KissFFTModeBfly5 = uint32(3)
	// KissFFTModeFFT selects the full forward opus_fft_c transform.
	KissFFTModeFFT = uint32(4)
	// KissFFTModeIFFT selects the full inverse opus_ifft_c transform.
	KissFFTModeIFFT = uint32(5)
)
View Source
const (
	MultistreamDecodeFormatFloat32 uint32 = iota
	MultistreamDecodeFormatInt16
	MultistreamDecodeFormatInt24
)
View Source
const (
	OpusForceModeAuto     = 0
	OpusForceModeSILKOnly = 1000
	OpusForceModeHybrid   = 1001
	OpusForceModeCELTOnly = 1002
)

Forced coding mode codes for OpusEncodeFixedParams.ForceMode. They mirror the libopus opus_private.h MODE_* constants consumed by OPUS_SET_FORCE_MODE.

View Source
const (
	OpusApplicationVoIP               = 2048
	OpusApplicationAudio              = 2049
	OpusApplicationRestrictedLowDelay = 2051
)
View Source
const (
	OpusBandwidthAuto          = 0
	OpusBandwidthNarrowband    = 1101
	OpusBandwidthMediumband    = 1102
	OpusBandwidthWideband      = 1103
	OpusBandwidthSuperwideband = 1104
	OpusBandwidthFullband      = 1105
)

Bandwidth codes for OpusEncodeFixedParams.Bandwidth. They mirror the libopus OPUS_BANDWIDTH_* constants consumed by OPUS_SET_BANDWIDTH. Zero leaves the bandwidth unset (encoder auto-selects).

View Source
const (
	OpusEnergyMaskUnchanged uint32 = iota
	OpusEnergyMaskSet
	OpusEnergyMaskClear
)

Per-frame CELT energy-mask actions for OpusEncodeFixedMixedFrame. An unchanged action preserves the encoder's current control value; Clear asks libopus to apply the control with a nil mask pointer.

View Source
const (
	OpusVBRUnchanged uint32 = iota
	OpusVBREnable
	OpusVBRDisable
)

Per-frame Opus VBR control actions for OpusEncodeFixedMixedFrame. An unchanged action preserves the current encoder control.

View Source
const (

	// QEXTDecode96kFormatFloat32 selects opus_decode_float output.
	QEXTDecode96kFormatFloat32 = uint32(0)
	// QEXTDecode96kFormatInt16 selects opus_decode output.
	QEXTDecode96kFormatInt16 = uint32(1)
	// QEXTDecode96kFormatInt24 selects opus_decode24 output.
	QEXTDecode96kFormatInt24 = uint32(2)
)
View Source
const (

	// CELTEnergyEncodeModeQuant drives quant_coarse_energy + quant_fine_energy +
	// quant_energy_finalise.
	CELTEnergyEncodeModeQuant = uint32(0)
)
View Source
const (

	// CELTPVQModeSearch selects the FIXED_POINT op_pvq_search_c kernel.
	CELTPVQModeSearch = uint32(0)
)
View Source
const (

	// CELTQuantEnergyModeAmp2Log2 selects the FIXED_POINT amp2Log2 kernel.
	CELTQuantEnergyModeAmp2Log2 = uint32(0)
)
View Source
const (

	// CELTSynthesisDecodeBufferSize mirrors DECODE_BUFFER_SIZE
	// (DEC_PITCH_BUF_SIZE) in celt/celt_decoder.c. The synthesis writes into a
	// per-channel decode_mem buffer of size CELTSynthesisDecodeBufferSize+overlap.
	CELTSynthesisDecodeBufferSize = 2048
)

Variables

This section is empty.

Functions

func BuildCHelper

func BuildCHelper(cfg CHelperConfig) (string, error)

func BuildDNNCHelper added in v0.2.0

func BuildDNNCHelper(root string, cfg CHelperConfig) (string, error)

BuildDNNCHelper builds a public C oracle against the optional DNN features and instruction lane selected by the current Go build. Its caller supplies the usual helper source options but no libopus archive or reference selector.

func BuildDREDHelper

func BuildDREDHelper(root, sourceFile, outputBase string, includeInternal bool) (string, error)

func BuildDREDWeightsFileHelper added in v0.2.0

func BuildDREDWeightsFileHelper(root, sourceFile, outputBase string, includeInternal bool) (string, error)

BuildDREDWeightsFileHelper builds a DNN-feature reference with USE_WEIGHTS_FILE defined for both libopus and the helper. It lets sequence oracles load the same runtime model blob at the same point as the Go decoder.

func BuildOSCEHelper

func BuildOSCEHelper(root, sourceFile, outputBase string, includeInternal bool) (string, error)

func BuildPublicAPIHelper added in v0.2.0

func BuildPublicAPIHelper(cfg CHelperConfig) (string, error)

BuildPublicAPIHelper builds an oracle helper against the public codec configuration selected by the current Go build, including its optional feature and instruction lane.

The caller supplies ordinary helper sources, flags, and non-archive link inputs. Reference selectors and libopus archives are selected here so a public API comparison cannot silently pair QEXT or fixed-point Go code with a different C build.

func CTLSequenceHelperPath

func CTLSequenceHelperPath() (string, error)

CTLSequenceHelperPath returns the built CTL-sequence oracle path (building it on first use) so callers can detect availability before running the sweep.

func CustomFixedQEXTRefPath added in v0.2.0

func CustomFixedQEXTRefPath(elem ...string) string

CustomFixedQEXTRefPath returns the CUSTOM_MODES + FIXED_POINT + ENABLE_QEXT reference tree paired with the current Go instruction lane.

func CustomFixedRefPath added in v0.2.0

func CustomFixedRefPath(elem ...string) string

CustomFixedRefPath returns the CUSTOM_MODES + FIXED_POINT reference tree paired with the current Go instruction lane.

func CustomQEXTRefPath added in v0.2.0

func CustomQEXTRefPath(elem ...string) string

CustomQEXTRefPath returns the CUSTOM_MODES + ENABLE_QEXT reference tree paired with the current Go instruction lane.

func CustomRefPath

func CustomRefPath(elem ...string) string

CustomRefPath returns a path under the pinned custom-modes (--enable-custom-modes) libopus reference tree. Its config.h defines CUSTOM_MODES and the Opus Custom API, so C oracle helpers built against it can call opus_custom_mode_create / opus_custom_encoder_create / opus_custom_decoder_create. Scalar Go builds use the matching custom-scalar tree.

func CustomScalarRefPath

func CustomScalarRefPath(elem ...string) string

CustomScalarRefPath returns a path under the scalar custom-modes libopus reference tree (--enable-custom-modes on the generic-C kernels, built with --disable-asm --disable-rtcd --disable-intrinsics). It is the bit-reproducible Opus Custom oracle for the scalar Go celt/custom parity gate.

func DNNKernelOraclePath added in v0.2.0

func DNNKernelOraclePath() (string, error)

DNNKernelOraclePath returns the selected kernel helper so native test runs can retain its linked machine code alongside the numerical oracle evidence.

func DREDQEXTRefPath added in v0.2.0

func DREDQEXTRefPath(elem ...string) string

DREDQEXTRefPath returns the ENABLE_DRED + ENABLE_DEEP_PLC + ENABLE_QEXT reference tree paired with the current Go scalar or SIMD instruction lane.

func DecodeDiffHelperPath

func DecodeDiffHelperPath() (string, error)

DecodeDiffHelperPath builds (once) and returns the differential decode oracle binary path.

func EncodeDiffHelperPath

func EncodeDiffHelperPath() (string, error)

EncodeDiffHelperPath returns the encode-diff oracle for the active public codec configuration, building it on first use before a test sweep.

func EnsureDREDBuild

func EnsureDREDBuild(repoRoot string) (sourceDir, buildDir string, err error)

func EnsureOSCEBuild

func EnsureOSCEBuild(repoRoot string) (sourceDir, buildDir string, err error)

func FixedQEXTRefPath added in v0.2.0

func FixedQEXTRefPath(elem ...string) string

FixedQEXTRefPath returns a FIXED_POINT + ENABLE_QEXT tree paired with the current Go build's scalar or SIMD instruction lane.

func FixedRefPath

func FixedRefPath(elem ...string) string

FixedRefPath returns a FIXED_POINT tree paired with the current Go build.

func HelperUnavailable

func HelperUnavailable(t testing.TB, label string, err error)

func NativeX86PitchXCorrMetadataValid added in v0.2.0

func NativeX86PitchXCorrMetadataValid(arch, cpu, dispatch, presumed uint32) bool

NativeX86PitchXCorrMetadataValid checks the AVX2/FMA pitch oracle's C-side CPU and dispatch evidence. RTCD-selected paths require arch 4 or later; compile-time-presumed paths are proven by their emitted dispatch mask and still require the actual CPU feature check.

func NativeX86SILKInnerProductMetadataValid added in v0.2.0

func NativeX86SILKInnerProductMetadataValid(arch, implementation, presumed uint32, wantAVX2 bool) bool

NativeX86SILKInnerProductMetadataValid checks that libopus selected the expected SILK inner-product implementation. A compile-time AVX2 selection may report arch zero, while RTCD selection requires arch four or later.

func OracleEnabled

func OracleEnabled() bool

func ProbeCELTAlgQuant

func ProbeCELTAlgQuant(x []int32, k, spread, b int, gain int32, bufBytes int) (collapseMask uint32, bytes []byte, resynth []int32, err error)

ProbeCELTAlgQuant runs the FIXED_POINT alg_quant kernel against the real libopus reference. X is the celt_norm (int32) input vector of length N; gain is the opus_val32 (int32) resynthesis gain. resynth is forced on, so X is reconstructed in place. It returns the anti-collapse mask, the finalised range-coder bytes, and the resynthesised X of length N.

func ProbeCELTAlgUnquant

func ProbeCELTAlgUnquant(n, k, spread, b int, gain int32, bytes []byte) (collapseMask uint32, x []int32, err error)

ProbeCELTAlgUnquant runs the FIXED_POINT alg_unquant kernel against the real libopus reference, decoding from the supplied range-coder bytes. It returns the anti-collapse mask and the decoded celt_norm X of length n.

func ProbeCELTAntiCollapse

func ProbeCELTAntiCollapse(in CELTAntiCollapseInput) ([]int32, error)

ProbeCELTAntiCollapse runs the FIXED_POINT anti_collapse kernel against the real libopus reference and returns the modified X vector.

func ProbeCELTExp2DBFixedQEXT added in v0.2.0

func ProbeCELTExp2DBFixedQEXT(values []int32) (frac, whole []int32, err error)

ProbeCELTExp2DBFixedQEXT returns the Q28 exp2_db fractional polynomial and Q16 full exponentiation from the selected FIXED_POINT+ENABLE_QEXT archive.

func ProbeCELTFixedAmp2Log2

func ProbeCELTFixedAmp2Log2(bandE []int32, nbEBands, effEnd, end, C int) ([]int32, error)

ProbeCELTFixedAmp2Log2 runs the FIXED_POINT amp2Log2 kernel against the real libopus reference, returning the resulting log2 band energies (channel-major, Q24, length C*nbEBands). bandE is the channel-major Q12 band amplitude array of length C*nbEBands.

func ProbeCELTFixedComputeBandEnergies

func ProbeCELTFixedComputeBandEnergies(eBands, logN []int16, x []int32, nbEBands, shortMdctSize, end, C, LM int) ([]int32, error)

ProbeCELTFixedComputeBandEnergies runs the FIXED_POINT compute_band_energies kernel against the real libopus reference, returning the resulting band energies (channel-major, length C*nbEBands). The x slice is the channel-major frequency-domain signal of length C*(shortMdctSize<<LM).

func ProbeCELTFixedDecode

func ProbeCELTFixedDecode(packet []byte, channels, frameSize, start, end int) ([]int16, error)

ProbeCELTFixedDecode runs the full FIXED_POINT celt_decode_with_ec on a CELT packet using the static 48000/960 mode, returning interleaved int16 PCM of length channels*frameSize.

func ProbeCELTFixedDecodeSeq

func ProbeCELTFixedDecodeSeq(packets [][]byte, channels, frameSize, start, end, samplingRate int) ([][]int16, error)

ProbeCELTFixedDecodeSeq creates ONE FIXED_POINT libopus CELT decoder at the given output samplingRate (48000/24000/16000/12000/8000) and decodes the supplied sequence of CELT packets in order through it, returning one int16 PCM slice per packet. frameSize is the 48k-core per-channel sample count; each returned frame has channels*(frameSize/downsample) interleaved samples, where downsample = resampling_factor(samplingRate). This exercises the cross-frame decode_mem/post-filter/energy-prediction carry and the downsample output path.

func ProbeCELTFixedDenormaliseBands

func ProbeCELTFixedDenormaliseBands(eBands []int16, bandLogE, x []int32, nbEBands, shortMdctSize, start, end, M, downsample int, silence bool) ([]int32, error)

ProbeCELTFixedDenormaliseBands runs the FIXED_POINT denormalise_bands kernel against the real libopus reference, returning the de-normalised synthesis spectrum freq of length N = M*shortMdctSize.

eBands    mode band boundaries (m->eBands), length >= end+1
bandLogE  per-band quantized log energy (celt_glog), length >= end
x         normalized coefficients (celt_norm), length M*eBands[end]

func ProbeCELTFixedEncode

func ProbeCELTFixedEncode(pcm []int16, channels, frameSize, start, end, bitrate, complexity, nbCompressedBytes int) ([]byte, error)

ProbeCELTFixedEncode runs the full FIXED_POINT celt_encode_with_ec on the static 48000/960 mode for the supplied interleaved int16 PCM (channels*frameSize samples) at the given CBR target, returning the produced CELT packet bytes. This is the end-goal reference for the integer encoder.

func ProbeCELTFixedEncodeExt

func ProbeCELTFixedEncodeExt(pcm []int16, channels, frameSize, start, end, bitrate, complexity, nbCompressedBytes int,
	vbr, constrainedVBR, lfe bool, mask []int32) ([]byte, error)

ProbeCELTFixedEncodeExt runs the full FIXED_POINT celt_encode_with_ec on the static 48000/960 mode with the LFE and/or energy_mask controls applied, returning the produced CELT packet bytes. mask, when non-nil, holds channels*nbEBands celt_glog (Q24, channel-major) values passed via OPUS_SET_ENERGY_MASK.

func ProbeCELTFixedEncodeRate

func ProbeCELTFixedEncodeRate(pcm []int16, channels, frameSize, start, end, bitrate, complexity, nbCompressedBytes, sampleRate int,
	vbr, constrainedVBR, lfe bool, mask []int32) ([]byte, error)

ProbeCELTFixedEncodeRate runs the full FIXED_POINT celt_encode_with_ec for a CELT encoder created at the given API sampleRate (48000/24000/16000/12000/ 8000). The CELT mode is always 48000/960; sampleRate sets st->upsample via celt_encoder_init, so the supplied frameSize and pcm are at the API rate (frameSize*upsample == the 48 kHz core N). Other arguments match ProbeCELTFixedEncodeExt.

func ProbeCELTFixedEncodeSeq

func ProbeCELTFixedEncodeSeq(pcm []int16, channels, frameSize, start, end, bitrate, complexity int,
	vbr, constrainedVBR bool, maxBytes, nframes int) ([][]byte, error)

ProbeCELTFixedEncodeSeq creates one FIXED_POINT CELT encoder, configures it for the given VBR/constrained-VBR/CBR mode and bitrate, and encodes nframes consecutive frames of interleaved int16 PCM (channels*frameSize*nframes samples) in sequence. It returns the produced packet bytes for each frame so cross-frame state (VBR reservoir/drift, energy histories, spec_avg, consec_transient, prefilter_mem) can be validated. maxBytes is the per-frame output buffer size (the VBR/CBR cap).

func ProbeCELTFixedEnergyUnquant

func ProbeCELTFixedEnergyUnquant(p CELTEnergyUnquantParams) ([]int32, error)

ProbeCELTFixedEnergyUnquant runs unquant_coarse_energy, unquant_fine_energy and unquant_energy_finalise on the supplied coded bytes against the real libopus FIXED_POINT reference, returning the resulting oldEBands (channel-major, Q24, length Channels*NbEBands).

func ProbeCELTFixedMathPairs

func ProbeCELTFixedMathPairs(mode uint32, a, b []int32) ([]uint32, error)

ProbeCELTFixedMathPairs runs a two-input FIXED_POINT celt math kernel (the frac_div32 family) over a list of (a, b) pairs, returning one int32-as-uint32 output per pair. The header record count is the number of pairs; each record consumes two int32 inputs.

func ProbeCELTFixedMathWords

func ProbeCELTFixedMathWords(mode uint32, words []uint32) ([]uint32, error)

ProbeCELTFixedMathWords runs the FIXED_POINT celt math oracle for the given mode over a list of int32-as-uint32 inputs, returning the int32-as-uint32 outputs produced by libopus.

func ProbeCELTFixedNormaliseBands

func ProbeCELTFixedNormaliseBands(eBands []int16, bandE, freq []int32, nbEBands, shortMdctSize, end, C, M int) ([]int32, error)

ProbeCELTFixedNormaliseBands runs the FIXED_POINT normalise_bands kernel against the real libopus reference, returning the normalised celt_norm output (channel-major, length C*N where N = M*shortMdctSize). The freq slice is the channel-major frequency-domain signal of the same length and bandE holds the per-band amplitudes (channel-major, length C*nbEBands).

func ProbeCELTFixedPLC

func ProbeCELTFixedPLC(packet []byte, channels, frameSize, start, end, numLost int) ([]int16, error)

ProbeCELTFixedPLC primes a FIXED_POINT libopus CELTDecoder with one prior-good CELT packet (static 48000/960 mode), then runs numLost consecutive lost frames through the celt_decode_with_ec PLC path (data==NULL), returning the concealed int16 PCM frame-major: numLost blocks of channels*frameSize samples.

func ProbeCELTFixedPLCRecovery

func ProbeCELTFixedPLCRecovery(prime, good []byte, channels, frameSize, start, end, numLost int) ([]int16, error)

ProbeCELTFixedPLCRecovery primes a FIXED_POINT libopus CELTDecoder with one prior-good CELT packet (static 48000/960 mode), runs numLost consecutive lost frames through the celt_decode_with_ec PLC path (data==NULL), then decodes the good recovery packet (entered with loss_duration!=0) and returns the recovered good-frame int16 PCM (channels*frameSize samples).

func ProbeCELTFixedQEXTComb added in v0.2.0

func ProbeCELTFixedQEXTComb(p CELTFixedQEXTCombParams) ([]int32, error)

ProbeCELTFixedQEXTComb evaluates one distinct-source/destination comb filter call against the selected FIXED_POINT + ENABLE_QEXT libopus archive.

func ProbeCELTMDCT

func ProbeCELTMDCT(mode uint32, p CELTMDCTParams, in []int32) ([]int32, error)

ProbeCELTMDCT drives the real libopus clt_mdct_forward_c (forward) or clt_mdct_backward_c (backward) against a reconstructed FIXED_POINT (non-QEXT) mdct_lookup for the given parameters, returning the int32 output buffer.

For the forward transform in holds N reals and the output is the post-rotated spectrum of stride*(N2-1)+1 reals (N2 = (N>>shift)>>1). For the backward transform in holds stride*(N2-1)+1 frequency reals and the output is the N time-domain reals after windowing/mirroring.

func ProbeCELTMath

func ProbeCELTMath(mode uint32, samples []float32) ([]float32, error)

func ProbeCELTMathWords

func ProbeCELTMathWords(mode uint32, count int, words []uint32) ([]uint32, error)

func ProbeCELTPVQSearch

func ProbeCELTPVQSearch(x []int32, k int) (yy int32, iy []int32, err error)

ProbeCELTPVQSearch runs the FIXED_POINT op_pvq_search_c kernel against the real libopus reference. X is the celt_norm (int32) input vector of length N; the kernel modifies its own copy internally. It returns yy (the squared norm of the codeword, sign-extended from opus_val16) and iy, the per-bin signed pulse counts of length N.

func ProbeCELTPVQSearchFloat

func ProbeCELTPVQSearchFloat(x []float32, k int) (yy float32, iy []int32, err error)

ProbeCELTPVQSearchFloat runs the FLOAT op_pvq_search_c kernel from the default (float) libopus reference. x is the celt_norm (float32) input vector; it returns yy (codeword squared norm, float32) and iy (signed pulse counts). This is the same-arch float oracle for the encoder PVQ search.

func ProbeCELTPVQSearchFloatSSE2 added in v0.2.0

func ProbeCELTPVQSearchFloatSSE2(x []float32, k int) (yy float32, iy []int32, err error)

ProbeCELTPVQSearchFloatSSE2 runs the pinned libopus x86 SSE2 PVQ kernel.

func ProbeCELTPatchTransientDecision

func ProbeCELTPatchTransientDecision(newE, oldE []int32, nbEBands, start, end, c int) (bool, error)

ProbeCELTPatchTransientDecision runs the FIXED_POINT patch_transient_decision kernel. newE and oldE hold 2*nbEBands celt_glog (Q24) band energies laid out as E[c*nbEBands+i]; libopus always allocates both channels.

func ProbeCELTRenormaliseVector

func ProbeCELTRenormaliseVector(x []int32, gain int32) ([]int32, error)

ProbeCELTRenormaliseVector runs the FIXED_POINT renormalise_vector kernel against the real libopus reference. x is the celt_norm (int32) input vector; gain is the Q31 gain. It returns the renormalised vector of the same length.

func ProbeCELTTFAnalysis

func ProbeCELTTFAnalysis(eBands []int16, length int, isTransient bool, lambda int, x []int32, n0, lm int, tfEstimate int16, tfChan int, importance []int) (tfSelect int, tfRes []int, err error)

ProbeCELTTFAnalysis runs the FIXED_POINT tf_analysis kernel. eBands holds nbEBands+1 band boundaries; X holds the normalised MDCT bins (celt_norm, channel-interleaved at N0). tfEstimate is Q14. It returns tf_select and the per-band tf_res decisions (length len).

func ProbeCELTTFEncode

func ProbeCELTTFEncode(start, end int, isTransient bool, tfRes []int, lm, tfSelect, bufSize, preBits int) (buf []byte, outTFRes []int, err error)

ProbeCELTTFEncode runs the FIXED_POINT tf_encode kernel. It encodes tfRes (and the tf_select bit) into a range coder of bufSize bytes, after consuming preBits of priming bits (each an ec_enc_bit_logp(0,1) call) to set the bit budget. It returns the finished coder buffer and the rewritten tf_res array (length end).

func ProbeCTLSequenceBatch added in v0.2.0

func ProbeCTLSequenceBatch(programs []CTLSequenceParams) ([][]CTLResult, error)

ProbeCTLSequenceBatch runs each CTL program in a fresh libopus state instance while sharing one helper process. Every program creates and destroys its own encoder or decoder, so controls and reset history do not cross boundaries.

func ProbeDNNConv2D3x3 added in v0.2.0

func ProbeDNNConv2D3x3(outChannels, inChannels, height int, weights, bias, mem, in []float32) ([]float32, error)

ProbeDNNConv2D3x3 calls the selected DRED archive's compute_conv2d with a 3x3 kernel, a bias and the tanh activation, using hstride == height. It returns the outChannels*height outputs.

func ProbeDNNKernelCGEMV8x4

func ProbeDNNKernelCGEMV8x4(rows, cols int, weights []byte, scale, x []float32) ([]float32, error)

func ProbeDNNKernelSGEMV

func ProbeDNNKernelSGEMV(rows, cols, colStride int, weights, x []float32) ([]float32, error)

func ProbeDNNKernelScalarCGEMV8x4

func ProbeDNNKernelScalarCGEMV8x4(rows, cols int, weights []byte, scale, x []float32) ([]float32, error)

func ProbeDNNLinearCGEMV8x4 added in v0.2.0

func ProbeDNNLinearCGEMV8x4(rows, cols int, idx []int32, weights []byte, scale, x, bias, subias []float32) ([]float32, error)

ProbeDNNLinearCGEMV8x4 calls the selected DRED archive's compute_linear, including its integer-matrix bias selection and optional sparse weights.

func ProbeDNNLinearSparseSGEMV added in v0.2.0

func ProbeDNNLinearSparseSGEMV(rows, cols int, idx []int32, weights, x, bias []float32) ([]float32, error)

ProbeDNNLinearSparseSGEMV calls the selected DRED archive's compute_linear with float weights and sparse block indices, including its float bias.

func ProbeEncodeDiffBatch added in v0.2.0

func ProbeEncodeDiffBatch(programs []EncodeDiffParams) ([][]EncodeDiffRecord, error)

ProbeEncodeDiffBatch runs each stateful encode sequence with a fresh libopus encoder while sharing one helper process. Each sequence retains its own encoder state across the frames in its EncodeDiffParams.

func ProbeFixedDCReject added in v0.2.0

func ProbeFixedDCReject(input []int32, mem [4]int32, fs, channels, cutoff int) ([]int32, [4]int32, error)

ProbeFixedDCReject calls the selected FIXED_POINT+ENABLE_RES24 libopus dc_reject with Q8 opus_res samples and returns all defined output and state.

func ProbeFixedHPCutoff added in v0.2.0

func ProbeFixedHPCutoff(inputFrames [][]int32, mem [4]int32, fs, channels int, cutoffs []int) ([][]int32, [][4]int32, error)

ProbeFixedHPCutoff runs sequential FIXED_POINT+ENABLE_RES24 hp_cutoff frames from src/opus_encoder.c. Each frame has a cutoff selected by the caller; the four opus_val32 state words carry between frames and are returned per frame.

func ProbeFloat2Int24 added in v0.2.0

func ProbeFloat2Int24(samples []float32) ([]int32, error)

ProbeFloat2Int24 returns libopus float2int(8388608.f*sample) results from the selected target C implementation. It preserves that target's behavior for int32 overflow, infinities, NaNs, and tie rounding.

func ProbeFloatQuant

func ProbeFloatQuant(mode uint32, samples []float32) ([]int16, error)

func ProbeFloatQuantScaledInt32

func ProbeFloatQuantScaledInt32(scale float32, samples []float32) ([]int32, error)

func ProbeGainFade added in v0.2.0

func ProbeGainFade(cases []GainFadeParams) ([][]float32, error)

ProbeGainFade runs the actual pinned static gain_fade() implementation in-place against every supplied input frame.

func ProbeOpusEncodeFixed

func ProbeOpusEncodeFixed(p OpusEncodeFixedParams) ([][]byte, error)

ProbeOpusEncodeFixed encodes the supplied int16 PCM frames through the FIXED_POINT libopus reference opus_encode() and returns the produced full Opus packets (TOC + payload). This is the top-level reference for the public fixed-point Encoder.

func ProbeSILKShort2Float

func ProbeSILKShort2Float(samples []int16) ([]float32, error)

func ProbeSoftClip

func ProbeSoftClip(n, channels int, samples, mem []float32) ([]float32, []float32, error)

ProbeSoftClip runs libopus opus_pcm_soft_clip for the provided interleaved PCM.

func PublicAPIOpusDemoPath added in v0.2.0

func PublicAPIOpusDemoPath() (string, error)

PublicAPIOpusDemoPath builds the pinned opus_demo with the same codec features and instruction lane as the public Go API. Its CLI input conversion and packet-file framing come directly from src/opus_demo.c.

func QEXTRefPath

func QEXTRefPath(elem ...string) string

QEXTRefPath returns a path under the QEXT-enabled reference tree paired with the current Go instruction lane.

func ReadPinnedSourceFileOrSkip added in v0.2.0

func ReadPinnedSourceFileOrSkip(t testing.TB, label string, elem ...string) []byte

ReadPinnedSourceFileOrSkip reads from the unsuffixed pinned source checkout. It is for source-only checks that do not consume build-specific artifacts.

func ReadRefFileOrSkip

func ReadRefFileOrSkip(t testing.TB, label string, elem ...string) []byte

ReadRefFileOrSkip reads a pinned libopus reference file. Missing references skip local tests unless GOPUS_STRICT_LIBOPUS_REF asks for hard failures.

func ReadRefPathOrSkip

func ReadRefPathOrSkip(t testing.TB, path, label string) []byte

ReadRefPathOrSkip is the path-based form of ReadRefFileOrSkip.

func RefPath

func RefPath(elem ...string) string

RefPath returns a path under the tree selected by the build-aware paired reference resolver. Invalid or conflicting overrides panic with their cause; helper constructors that return errors resolve the variant directly.

func RequireOracle

func RequireOracle(t testing.TB)

func RunHelper

func RunHelper(binPath string, input []byte) ([]byte, error)

func RunHelperArgs

func RunHelperArgs(binPath string, input []byte, args ...string) ([]byte, error)

func RunHelperArgsEnv

func RunHelperArgsEnv(binPath string, input []byte, env []string, args ...string) ([]byte, error)

func RunHelperEnv

func RunHelperEnv(binPath string, input []byte, env []string) ([]byte, error)

func SIMDRefPath

func SIMDRefPath(elem ...string) string

SIMDRefPath returns a path under the SIMD/RTCD-enabled libopus reference tree (built by `make ensure-libopus-simd`). Pair it with a Go SIMD build for build-wide comparisons, or use it for a kernel test that invokes the matching Go SIMD function directly.

func ScalarRefPath

func ScalarRefPath(elem ...string) string

ScalarRefPath returns a path under the scalar generic-C reference tree, built without assembly, RTCD, intrinsics, or compiler loop/SLP vectorization. FMA contraction stays enabled to match scalar Go arithmetic.

func StrictRefRequired

func StrictRefRequired() bool

func ValidateDNNDispatchArch added in v0.2.0

func ValidateDNNDispatchArch(arch uint32) error

ValidateDNNDispatchArch verifies that the selected x86 SIMD helper executes libopus's AVX2 DNN table slot. Other targets use their selected config and may map the architecture number differently.

Types

type CELTAllocTrimResult

type CELTAllocTrimResult struct {
	TrimIndex    int
	StereoSaving int16
}

CELTAllocTrimResult mirrors the outputs of alloc_trim_analysis.

func ProbeCELTAllocTrimAnalysis

func ProbeCELTAllocTrimAnalysis(eBands []int16, x []int32, bandLogE []int32, end, lm, c, n0 int, stereoSaving, tfEstimate int16, intensity int, surroundTrim, equivRate int32, analysisValid bool, analysisTonalitySlope float32) (CELTAllocTrimResult, error)

ProbeCELTAllocTrimAnalysis runs the FIXED_POINT alloc_trim_analysis kernel. eBands holds nbEBands+1 boundaries, X holds channel-interleaved celt_norm bins at N0, bandLogE holds 2*nbEBands celt_glog (Q24) energies. stereoSaving is the running Q8 estimate, tfEstimate is Q14, surroundTrim is Q24.

type CELTAntiCollapseInput

type CELTAntiCollapseInput struct {
	X             []int32
	CollapseMasks []byte
	LM            int
	C             int
	Size          int
	Start         int
	End           int
	LogE          []int32
	Prev1LogE     []int32
	Prev2LogE     []int32
	Pulses        []int
	EBands        []int16
	NbEBands      int
	Seed          uint32
	Encode        bool
}

CELTAntiCollapseInput bundles the anti_collapse kernel arguments. The arrays follow the libopus layout: X is C*Size celt_norm samples, collapseMasks is NbEBands*C bytes, logE/prev1logE/prev2logE are 2*NbEBands celt_glog (Q24) each (libopus always allocates both channels; the !encode && C==1 path reads the 2nd-channel slot), pulses is NbEBands ints, and eBands is NbEBands+1 entries.

type CELTBitexactThetaPair

type CELTBitexactThetaPair struct {
	Mid   int
	Side  int
	Delta int
}

func ProbeCELTBitexactThetaPairs

func ProbeCELTBitexactThetaPairs(inputs []uint32) ([]CELTBitexactThetaPair, error)

type CELTDeemphasisResult

type CELTDeemphasisResult struct {
	PCM []int32
	Mem []int32
}

CELTDeemphasisResult holds the FIXED_POINT deemphasis oracle output: the interleaved opus_res pcm buffer (length Nd*C, stride C) and the updated per-channel filter state mem.

func ProbeCELTFixedDeemphasis

func ProbeCELTFixedDeemphasis(in [][]int32, pcm []int32, coef []int16, mem []int32, N, downsample int, accum bool) (*CELTDeemphasisResult, error)

ProbeCELTFixedDeemphasis runs the FIXED_POINT celt/celt_decoder.c deemphasis kernel against the real libopus reference.

in          per-channel celt_sig synthesis input, in[c] has length N
pcm         pre-existing interleaved opus_res buffer (length Nd*C); only
            read when accum is set, but always provided to seed the buffer
coef        mode->preemph coefficients (length 4); only coef[0] is used in
            this build config
mem         per-channel filter state (length C)
N           per-channel sample count
downsample  decimation factor (1, 2, ...)
accum       whether to accumulate into pcm (ADD_RES) instead of overwriting

type CELTEnergyEncodeParams

type CELTEnergyEncodeParams struct {
	NbEBands         int
	Start            int
	End              int
	EffEnd           int
	C                int
	LM               int
	Budget           int
	NbAvailableBytes int
	ForceIntra       bool
	TwoPass          bool
	LossRate         int
	Lfe              bool
	DelayedIntra     int32
	BufSize          int
	FinaliseBits     int

	// EBands is the channel-major Q24 target log energy (length C*NbEBands).
	EBands []int32
	// OldEBands is the channel-major Q24 predictor (length C*NbEBands).
	OldEBands []int32
	// FineQuant, ExtraQuant and FinePriority are per-band (length NbEBands).
	FineQuant    []int32
	ExtraQuant   []int32
	FinePriority []int32
}

CELTEnergyEncodeParams configures a reference run of the FIXED_POINT CELT energy encoders.

type CELTEnergyEncodeResult

type CELTEnergyEncodeResult struct {
	// Bytes is the coded range-coder output.
	Bytes []byte
	// OldEBands is the reconstructed channel-major Q24 energy (length C*NbEBands).
	OldEBands []int32
	// Error is the residual channel-major Q24 error (length C*NbEBands).
	Error []int32
	// DelayedIntra is the updated distortion accumulator.
	DelayedIntra int32
}

CELTEnergyEncodeResult holds the reference output.

func ProbeCELTQuantEnergyEncode

func ProbeCELTQuantEnergyEncode(p CELTEnergyEncodeParams) (*CELTEnergyEncodeResult, error)

ProbeCELTQuantEnergyEncode drives the real libopus FIXED_POINT quant_coarse_energy, quant_fine_energy and quant_energy_finalise through a genuine ec_enc and returns the coded bytes plus the resulting state.

type CELTEnergyUnquantParams

type CELTEnergyUnquantParams struct {
	NbEBands     int
	Start        int
	End          int
	EffEnd       int
	Channels     int
	LM           int
	Intra        bool
	Coded        []byte
	FineQuant    []int32
	FinePriority []int32
	BitsLeft     int32
}

CELTEnergyUnquantParams describes a coarse+fine+finalise energy decode pass against the FIXED_POINT libopus quant_bands.c unquantizers.

type CELTFixedQ8Analysis added in v0.2.0

type CELTFixedQ8Analysis struct {
	Valid                                        bool
	Tonality, TonalitySlope, Noisiness, Activity float32
	MusicProb, MusicProbMin, MusicProbMax        float32
	Bandwidth                                    int32
	ActivityProbability, MaxPitchRatio           float32
	LeakBoost                                    [19]uint8
}

CELTFixedQ8Analysis is celt/celt.h AnalysisInfo on the selected fixed build. Every field is transmitted, including fields that the current CELT frame does not consume, so the oracle has the same state as CELT_SET_ANALYSIS.

type CELTFixedQ8EncoderState added in v0.2.0

type CELTFixedQ8EncoderState struct {
	RNG                       uint32
	SpreadDecision            int32
	DelayedIntra              int32
	TonalAverage              int32
	LastCodedBands            int32
	HFAverage                 int32
	TapsetDecision            int32
	PrefilterPeriod           int32
	PrefilterGain             int32
	PrefilterTapset           int32
	ConsecTransient           int32
	VBRReservoir              int32
	VBRDrift                  int32
	VBROffset                 int32
	VBRCount                  int32
	OverlapMax                int32
	StereoSaving              int32
	Intensity                 int32
	SpecAvg                   int32
	ForceIntra                int32
	DisablePrefilter          int32
	SilkSignalType            int32
	SilkOffset                int32
	AnalysisValid             int32
	AnalysisBandwidth         int32
	AnalysisActivityBits      uint32
	AnalysisTonalityBits      uint32
	AnalysisSlopeBits         uint32
	AnalysisMaxPitchRatioBits uint32
	AnalysisLeakBoost         [19]uint8
	EnergyMask                []int32
	PreemphMemE               []int32
	InMem                     []int32
	PrefilterMem              []int32
	OldBandE                  []int32
	OldLogE                   []int32
	OldLogE2                  []int32
	EnergyError               []int32
	QEXTOldBandE              []int32
}

CELTFixedQ8EncoderState is the explicit logical state read from the selected C CELT encoder after one raw Q8 frame. Scalar fields precede the arrays in the trace stream; the helper never hashes struct padding or pointers.

type CELTFixedQ8Frame added in v0.2.0

type CELTFixedQ8Frame struct {
	PCM      []int32
	MaxBytes int
	// StreamChannels and Bitrate optionally update the matching CELT controls
	// immediately before this frame. Zero keeps the previous value. These
	// controls let raw-Q8 traces reproduce the outer encoder's automatic
	// mono/stereo decision and per-frame bitrate changes.
	StreamChannels int32
	Bitrate        int32
	Analysis       CELTFixedQ8Analysis
	EnergyMask     []int32
	PrefixUniform  []uint32
	ResetBefore    bool
	SetPrediction  bool
	Prediction     int32
	SilkSignalType int32
	SilkOffset     int32
}

type CELTFixedQ8Params added in v0.2.0

type CELTFixedQ8Params struct {
	SampleRate, Channels, StreamChannels, FrameSize, Start, End int
	Bitrate, Complexity, LSBDepth                               int
	VBR, ConstrainedVBR, LFE                                    bool
	QEXTEnabled                                                 bool
	Frames                                                      []CELTFixedQ8Frame
}

type CELTFixedQ8Record added in v0.2.0

type CELTFixedQ8Record struct {
	Packet     []byte
	FinalRange uint32
}

func ProbeCELTFixedQEXTQ8 added in v0.2.0

func ProbeCELTFixedQEXTQ8(p CELTFixedQ8Params) ([]CELTFixedQ8Record, error)

ProbeCELTFixedQEXTQ8 runs the same fixed Q8 CELT encode helper against the independently built FIXED_POINT + ENABLE_QEXT reference archive.

func ProbeCELTFixedRawQ8 added in v0.2.0

func ProbeCELTFixedRawQ8(p CELTFixedQ8Params) ([]CELTFixedQ8Record, error)

type CELTFixedQ8StateRecord added in v0.2.0

type CELTFixedQ8StateRecord struct {
	CELTFixedQ8Record
	State CELTFixedQ8EncoderState
}

CELTFixedQ8StateRecord combines a raw CELT packet with the exact logical C encoder state after that frame.

func ProbeCELTFixedQEXTQ8State added in v0.2.0

func ProbeCELTFixedQEXTQ8State(p CELTFixedQ8Params) ([]CELTFixedQ8StateRecord, error)

ProbeCELTFixedQEXTQ8State encodes the same raw Q8 frames as ProbeCELTFixedQEXTQ8 and also returns explicit C encoder state after each frame.

type CELTFixedQEXTCombParams added in v0.2.0

type CELTFixedQEXTCombParams struct {
	Y, X               []int32
	YOffset, XOffset   int
	N, T0, T1, Overlap int
	G0, G1             int16
	Tapset0, Tapset1   int
	Window             []int32
}

CELTFixedQEXTCombParams describes a separated-buffer CELT comb filter call with the Q31 coefficient window used by ENABLE_QEXT.

type CELTFrontendResult

type CELTFrontendResult struct {
	// Freq is the interleaved post-MDCT signal (celt_sig), length C*N.
	Freq []int32
	// BandE is the per-band energy (celt_ener), channel-major, length C*nbEBands.
	BandE []int32
	// X is the normalised bands (celt_norm), interleaved, length C*N.
	X []int32
}

CELTFrontendResult holds the intermediate front-end signals produced by the FIXED_POINT encode front-end just before quant_all_bands.

func ProbeCELTFixedEncodeFrontend

func ProbeCELTFixedEncodeFrontend(pcm []int16, channels, frameSize, start, end int, isTransient bool) (*CELTFrontendResult, error)

ProbeCELTFixedEncodeFrontend runs the inline FIXED_POINT encode front-end on the static 48000/960 mode for the supplied interleaved int16 PCM (channels*frameSize samples). isTransient selects the transient MDCT striping (shortBlocks==M) vs the normal long-block path. It returns the resulting freq, bandE and normalised X exactly as celt_encode_with_ec would compute them on a fresh encoder's first frame.

func ProbeCELTFixedEncodeFrontendRate

func ProbeCELTFixedEncodeFrontendRate(pcm []int16, channels, frameSize, start, end, upsample int, isTransient bool) (*CELTFrontendResult, error)

ProbeCELTFixedEncodeFrontendRate runs the FIXED_POINT encode front-end with an explicit upsample factor (1/2/3/4/6). frameSize is the API-rate per-channel count; the 48 kHz core is frameSize*upsample. The front-end zero-stuffs the input and applies the spectral upsample scaling, matching celt_encode_with_ec.

type CELTMDCTKFFT

type CELTMDCTKFFT struct {
	Nfft       int
	Scale      int32
	ScaleShift int32
	Shift      int32
	Factors    [16]int16
	Bitrev     []int16
	Twiddles   [][2]int16
}

CELTMDCTKFFT mirrors one sub-FFT state of the static 48000/960 mode->mdct.

type CELTMDCTParams

type CELTMDCTParams struct {
	N        int
	MaxShift int
	Shift    int
	Overlap  int
	Stride   int
	Window   []int16
}

CELTMDCTParams describes one MDCT oracle invocation: the full MDCT length n and the lookup's maxshift used to build the kfft/trig tables, plus the per-call shift/overlap/stride and the int16 Q15 window (overlap entries).

type CELTMDCTTables

type CELTMDCTTables struct {
	N        int
	MaxShift int
	Trig     []int16
	Window   []int16
	EBands   []int16
	Preemph0 int32
	KFFT     []CELTMDCTKFFT
}

CELTMDCTTables holds the dumped static 48000/960 mode->mdct tables plus the mode window, band layout and preemphasis coefficient.

func ProbeCELTFixedMDCTTables

func ProbeCELTFixedMDCTTables() (*CELTMDCTTables, error)

ProbeCELTFixedMDCTTables dumps the libopus FIXED_POINT static 48000/960 custom mode's mode->mdct lookup (the exact tables celt_decode_with_ec uses).

type CELTPrefilterParams

type CELTPrefilterParams struct {
	CC, N            int
	Complexity       int
	LossRate         int
	NbAvailableBytes int
	PrefilterPeriod  int
	PrefilterTapset  int
	Enabled          bool
	Hybrid           bool
	Tell             int
	TotalBits        int
	PrefilterGain    int16
	TFEstimate       int16
	ToneFreq         int16
	Toneishness      int32
	AnalysisValid    bool
	MaxPitchRatio    float32
}

CELTPrefilterParams mirrors the CELTEncoder state and per-frame inputs that the run_prefilter value-producing block consumes.

type CELTPrefilterResult

type CELTPrefilterResult struct {
	PitchIndex int
	Gain       int16
	QG         int
	PFOn       bool
	Tapset     int
	Bytes      []byte
}

CELTPrefilterResult holds the FIXED_POINT run_prefilter decision values and the emitted post-filter parameter bytes.

func ProbeCELTPrefilter

func ProbeCELTPrefilter(pre [][]int32, p CELTPrefilterParams) (CELTPrefilterResult, error)

ProbeCELTPrefilter runs the FIXED_POINT run_prefilter value-producing block against the real libopus reference. pre holds the assembled per-channel analysis buffers (each COMBFILTER_MAXPERIOD+N int32 samples); pre[1] is used only when p.CC==2.

type CELTQuantAllBandsEncodeParams

type CELTQuantAllBandsEncodeParams struct {
	Channels    int
	LM          int
	Start       int
	End         int
	ShortBlocks int
	Spread      int
	DualStereo  int
	Intensity   int
	TotalBits   int32
	Balance     int32
	CodedBands  int
	Complexity  int
	DisableInv  bool
	Seed        uint32
	NbEBands    int
	Nbytes      int
	Pulses      []int32
	TfRes       []int32
	BandE       []int32 // channels*NbEBands, channel-major (per-band, then +nbEBands)
	X           []int32 // channels*N, channel-major
}

CELTQuantAllBandsEncodeParams describes a quant_all_bands encode pass against the FIXED_POINT libopus bands.c reference. A fresh range encoder is created over an Nbytes-sized buffer; the normalized X (and stereo Y), band energies, allocation and tf inputs are supplied directly so the comparison is decoupled from the surrounding encoder state. X is channel-major with stride N.

type CELTQuantAllBandsEncodeResult

type CELTQuantAllBandsEncodeResult struct {
	N         int
	Channels  int
	Seed      uint32
	BytesUsed int
	Coded     []byte
	X         []int32
	Collapse  []byte
}

CELTQuantAllBandsEncodeResult holds the reference quant_all_bands encode output: the coded byte buffer (full storage, raw bits included), the number of forward range-coder bytes used, the post-encode normalized X buffer (channel-major, stride N), the per-band collapse masks, the channel sample count N and the threaded LCG seed.

func ProbeCELTFixedQuantAllBandsEncode

func ProbeCELTFixedQuantAllBandsEncode(p CELTQuantAllBandsEncodeParams) (*CELTQuantAllBandsEncodeResult, error)

ProbeCELTFixedQuantAllBandsEncode runs the real FIXED_POINT libopus quant_all_bands encode pass over the supplied inputs and returns the coded bytes, post-encode X[] and collapse masks. In a QEXT build, the selected combined reference receives an empty side coder and zero extra-band budget.

type CELTQuantAllBandsParams

type CELTQuantAllBandsParams struct {
	Channels      int
	LM            int
	Start         int
	End           int
	ShortBlocks   int
	Spread        int
	DualStereo    int
	Intensity     int
	TotalBits     int32
	Balance       int32
	CodedBands    int
	DisableInv    bool
	Seed          uint32
	NbEBands      int
	Pulses        []int32
	TfRes         []int32
	Coded         []byte
	QEXTCoded     []byte
	QEXTTotalBits int32
	QEXTPulses    []int32
	QEXTCaps      []int32
}

CELTQuantAllBandsParams describes a quant_all_bands decode pass against the FIXED_POINT libopus bands.c reference. The range decoder is initialized fresh over Coded; the energy/allocation/tf inputs are supplied directly so the comparison is decoupled from surrounding decoder state.

type CELTQuantAllBandsResult

type CELTQuantAllBandsResult struct {
	N                                 int
	Channels                          int
	Seed                              uint32
	MainRange, MainVal                uint32
	MainTell, MainTellFrac, MainError uint32
	ExtRange, ExtVal                  uint32
	ExtTell, ExtTellFrac, ExtError    uint32
	X                                 []int32
	Collapse                          []byte
}

CELTQuantAllBandsResult holds the reference quant_all_bands decode output: the normalized celt_norm X buffer (channel-major, channel stride N), the per-band collapse masks (channels*NbEBands), the channel sample count N and the threaded LCG seed.

func ProbeCELTFixedQuantAllBands

func ProbeCELTFixedQuantAllBands(p CELTQuantAllBandsParams) (*CELTQuantAllBandsResult, error)

ProbeCELTFixedQuantAllBands runs the build-selected FIXED_POINT libopus quant_all_bands implementation over the supplied inputs and returns the resulting normalized X[] (channels*N) plus collapse masks.

func ProbeCELTFixedQuantAllBandsQ15 added in v0.2.0

func ProbeCELTFixedQuantAllBandsQ15(p CELTQuantAllBandsParams) (*CELTQuantAllBandsResult, error)

ProbeCELTFixedQuantAllBandsQ15 runs the non-QEXT FIXED_POINT Q15 kernel. It selects a fixed-only archive when the caller binary also compiles the separate QEXT coefficient-domain implementation.

type CELTStereoIthetaCase

type CELTStereoIthetaCase struct {
	Stereo bool
	X      []float32
	Y      []float32
}

type CELTStereoIthetaOracle added in v0.2.0

type CELTStereoIthetaOracle struct {
	Values       []uint32
	SelectedArch uint32
	RTCDEnabled  bool
	PresumeNEON  bool
}

func ProbeCELTStereoIthetaQ30

func ProbeCELTStereoIthetaQ30(cases []CELTStereoIthetaCase) (CELTStereoIthetaOracle, error)

type CELTSynthesisParams

type CELTSynthesisParams struct {
	FrameSize   int // shortMdctSize<<LM (120/240/480/960 for LM 0..3)
	C           int // coded channels (1 or 2)
	CC          int // output channels (1 or 2)
	LM          int
	Downsample  int
	Start       int
	EffEnd      int
	IsTransient bool
	Silence     bool
}

CELTSynthesisParams describes a single celt_synthesis call against the FIXED_POINT reference using the static 48000 mode.

type CELTSynthesisResult

type CELTSynthesisResult struct {
	NbEBands int
	Overlap  int
	EBands   []int16
	Window   []int16
	ChanLen  int
	// DecodeMem is the per-channel decode_mem after synthesis, channel-major:
	// DecodeMem[c*ChanLen : (c+1)*ChanLen].
	DecodeMem []int32
}

CELTSynthesisResult holds the libopus celt_synthesis output: the mode bands and window used (so the Go side can reuse the exact reference values) and the resulting per-channel decode_mem buffers (each ChanLen samples).

func ProbeCELTFixedSynthesis

func ProbeCELTFixedSynthesis(p CELTSynthesisParams, x, oldBandE, decodeMem []int32) (*CELTSynthesisResult, error)

ProbeCELTFixedSynthesis runs the FIXED_POINT celt_synthesis on the supplied coefficients, band energies and per-channel decode_mem state, returning the reference mode bands/window and the resulting decode_mem buffers.

x         de-normalised input coefficients (celt_norm), length C*N
oldBandE  per-band quantized log energy (celt_glog), length C*nbEBands
decodeMem per-channel input decode_mem (celt_sig), channel-major, length
          CC*(CELTSynthesisDecodeBufferSize+overlap)

type CELTTransientResult

type CELTTransientResult struct {
	IsTransient   bool
	TFEstimate    int16
	TFChan        int
	WeakTransient bool
}

CELTTransientResult mirrors the outputs of transient_analysis.

func ProbeCELTTransientAnalysis

func ProbeCELTTransientAnalysis(in []int32, length, c int, allowWeakTransients bool, toneFreq int16, toneishness int32) (CELTTransientResult, error)

ProbeCELTTransientAnalysis runs the FIXED_POINT transient_analysis kernel against the real libopus reference. in holds C*length celt_sig (int32) time-domain samples laid out as in[c*length+i]. toneFreq is Q13 and toneishness is Q29.

type CHelperConfig

type CHelperConfig struct {
	Label              string
	OutputBase         string
	SourceFile         string
	ProbeRelPath       string
	CFlags             []string
	RefIncludes        []string
	QEXTRef            bool
	FixedRef           bool
	FixedQEXTRef       bool
	DREDQEXTRef        bool
	CustomRef          bool
	CustomQEXTRef      bool
	CustomFixedRef     bool
	CustomFixedQEXTRef bool
	// SIMDRef links the SIMD/RTCD-enabled libopus tree (opus-1.6.1-simd). Pair it
	// with a Go SIMD build or with a test that invokes the matching Go SIMD kernel.
	SIMDRef bool
	// ForceScalarRef compiles every RefSource (and the helper itself) against the
	// explicit scalar reference, with vectorization disabled and scalar kernel
	// headers selected instead of RTCD dispatch tables. Helpers that
	// compile a hand-picked subset of libopus .c files (no libopus.a link) and
	// reach silk_inner_product_FLP / silk_VQ_WMat_EC (or other x86-dispatched
	// kernels) need this: otherwise the default RTCD/intrinsics config routes
	// them through SILK_*_IMPL tables defined only in silk/x86/x86_silk_map.c +
	// the AVX2/SSE impls, which are not in the subset and fail to link on amd64
	// and Windows. Normal FMA contraction remains enabled.
	ForceScalarRef bool
	IncludeDirs    []string
	RefSources     []string
	Sources        []string
	Libs           []string
	LDFlags        []string
	DeadStrip      bool
}

type CTLOp

type CTLOp struct {
	Op      int
	Request int32
	Arg     int32
}

CTLOp is one step in a CTL behavioral program. Request is the libopus request code (e.g. OPUS_SET_BITRATE_REQUEST); Arg is the SET argument (ignored for GET / PROCESS / RESET).

type CTLResult

type CTLResult struct {
	Ret       int32
	Value     int32
	HaveValue bool
	// Packet contains the encoded packet for OP_PROCESS when CapturePackets is
	// enabled on the sequence. Other operations and decoder processes return nil.
	Packet []byte
}

CTLResult is the oracle outcome of one CTLOp: the CTL/process return code, the GET value (only meaningful when HaveValue), and whether a value was produced.

func ProbeCTLSequence

func ProbeCTLSequence(p CTLSequenceParams) ([]CTLResult, error)

ProbeCTLSequence drives one libopus encoder or decoder through the program in p.Ops and returns one CTLResult per op. This is the behavioral oracle for the public gopus typed CTL setters/getters.

type CTLSequenceParams

type CTLSequenceParams struct {
	IsDecoder   bool
	SampleRate  int
	Channels    int
	Application int // libopus OPUS_APPLICATION_* (encoder only)
	FrameSize   int // per-channel samples per OP_PROCESS frame (0 => 960)
	// FeedPacket is the exact Opus packet the decoder OP_PROCESS decodes. The
	// same bytes must be decoded by gopus so decode-derived GETs are comparable.
	// Ignored for the encoder.
	FeedPacket []byte
	// CapturePackets asks the helper to return packet bytes for encoder OP_PROCESS
	// operations. It adds per-operation packet data to the oracle wire response.
	CapturePackets bool
	Ops            []CTLOp
}

CTLSequenceParams configures one oracle run against a single encoder or decoder driven through the supplied program.

type DecodeDiffCase

type DecodeDiffCase struct {
	Packet           []byte // nil/empty → NULL packet (PLC path)
	Format           uint32 // DecodeDiffFormat*
	FrameSize        uint32 // PCM capacity in samples/channel; zero selects 5760 by default.
	LiteralFrameSize bool   // Preserve FrameSize literally in ProbeDecodeSequence, including zero.
	DecodeFEC        bool
}

DecodeDiffCase is one packet to decode through the libopus oracle.

type DecodeDiffResult

type DecodeDiffResult struct {
	// Code is the raw opus_decode* return value: negative libopus error, or the
	// positive decoded sample count per channel on success.
	Code int32
	// FinalRange is populated by the stateful version-3/4 oracle.
	FinalRange uint32
	// PCM holds the raw decoded sample bytes on success (Code > 0), little-endian
	// in the requested Format. Empty when Code <= 0.
	PCM []byte
}

DecodeDiffResult is the libopus oracle output for one DecodeDiffCase.

func ProbeDecodeDiff

func ProbeDecodeDiff(sampleRate, channels int, cases []DecodeDiffCase) ([]DecodeDiffResult, error)

ProbeDecodeDiff decodes every case through a fresh libopus decoder at the given sampleRate/channels and returns the per-case return code and decoded PCM.

All cases share sampleRate/channels but have independent decoder state. Use ProbeDecodeSequence when later calls depend on earlier packets.

func ProbeDecodeSequence added in v0.2.0

func ProbeDecodeSequence(sampleRate, channels int, cases []DecodeDiffCase) ([]DecodeDiffResult, error)

ProbeDecodeSequence retains one C decoder across all calls, including errors, and returns each status, final range, and successful PCM output. Cases with LiteralFrameSize use the version-4 wire protocol to pass frame_size=0 exactly.

func (DecodeDiffResult) Float32

func (r DecodeDiffResult) Float32() []float32

Float32 decodes r.PCM as little-endian float32 samples.

func (DecodeDiffResult) Int16

func (r DecodeDiffResult) Int16() []int16

Int16 decodes r.PCM as little-endian int16 samples.

func (DecodeDiffResult) Int24

func (r DecodeDiffResult) Int24() []int32

Int24 decodes r.PCM as little-endian int32 (right-justified 24-bit) samples.

type EncodeDiffParams

type EncodeDiffParams struct {
	SampleRate         int
	Channels           int
	Application        int
	ForceMode          int
	Bandwidth          int
	MaxBandwidth       int
	Bitrate            int
	Complexity         int
	Signal             uint32
	VBR                bool
	VBRConstraint      bool
	ForceChannels      int
	InbandFEC          int
	PacketLoss         int
	DTX                bool
	LSBDepth           int
	PredictionDisabled bool
	PhaseInvDisabled   bool
	FrameSize          int // per-channel samples at SampleRate
	FrameCount         int
	// PCM is interleaved float32, length FrameSize*Channels*FrameCount.
	PCM []float32
}

EncodeDiffParams configures the opus_encode_float input API oracle. The C codec uses the same fixed/float, feature and instruction configuration as Go. One encoder is driven statefully across all frames without a reset.

type EncodeDiffRecord

type EncodeDiffRecord struct {
	Ret        int
	FinalRange uint32
	Packet     []byte
}

EncodeDiffRecord is one frame's oracle result: opus_encode_float's return code Ret (>0 packet len, 1 = DTX/CELT-silence TOC-only, 0 = DTX no-output, <0 error), the post-encode final range, and the produced packet bytes (nil when Ret<=0).

func ProbeEncodeDiff

func ProbeEncodeDiff(p EncodeDiffParams) ([]EncodeDiffRecord, error)

ProbeEncodeDiff passes float PCM to libopus opus_encode_float and returns per-frame records. BuildPublicAPIHelper pairs the C codec with the current Go build; float input does not imply a floating-point codec implementation.

type GainFadeParams added in v0.2.0

type GainFadeParams struct {
	SampleRate int
	Channels   int
	G1         float32
	G2         float32
	Samples    []float32
}

GainFadeParams describes one in-place call to libopus's gain_fade().

type HelperCache

type HelperCache struct {
	// contains filtered or unexported fields
}

HelperCache caches a lazily built helper binary path for oracle tests.

func (*HelperCache) CHelperPath

func (c *HelperCache) CHelperPath(cfg CHelperConfig) (string, error)

CHelperPath returns the cached path for a C oracle helper built from cfg.

func (*HelperCache) Path

func (c *HelperCache) Path(build func() (string, error)) (string, error)

Path returns the cached helper path, building it on the first call.

type KissFFTComplex

type KissFFTComplex struct {
	R int32
	I int32
}

KissFFTComplex is a complex sample with int32 real/imaginary parts matching the FIXED_POINT (non-QEXT) libopus kiss_fft_cpx.

func ProbeKissFFTBfly2

func ProbeKissFFTBfly2(samples []KissFFTComplex) ([]KissFFTComplex, error)

ProbeKissFFTBfly2 runs the FIXED_POINT kf_bfly2 butterfly over the given samples (which must be a multiple of 8 in length: 8 complex samples per group) and returns the in-place transformed result produced by libopus.

type KissFFTFullResult

type KissFFTFullResult struct {
	ScaleShift int
	Scale      int16
	Shift      int
	Factors    [2 * maxFactors]int16
	Bitrev     []int16
	Twiddles   []KissFFTTwiddle
	Samples    []KissFFTComplex
}

KissFFTFullResult holds the libopus full-FFT oracle output: the exact state the library built for nfft (scale_shift/scale/shift, factors, bitrev table, twiddle table) plus the transformed samples, so the Go side can validate both its state constructor and its transform bit-for-bit.

func ProbeKissFFTFull

func ProbeKissFFTFull(mode uint32, samples []KissFFTComplex) (KissFFTFullResult, error)

ProbeKissFFTFull runs the real (non-static) library opus_fft_c (forward) or opus_ifft_c (inverse) over the given nfft samples against a standalone opus_fft_alloc state, returning the state tables and the transformed samples.

type KissFFTRadixResult

type KissFFTRadixResult struct {
	Twiddles []KissFFTTwiddle
	Samples  []KissFFTComplex
}

KissFFTRadixResult holds the libopus radix-3/4/5 butterfly oracle output: the twiddle table it generated for the requested nfft (so the Go side can consume identical Q15 twiddles) and the in-place transformed samples.

func ProbeKissFFTBflyRadix

func ProbeKissFFTBflyRadix(mode, nfft uint32, fstride, m, n, mm int, samples []KissFFTComplex) (KissFFTRadixResult, error)

ProbeKissFFTBflyRadix runs one of the FIXED_POINT radix-3/4/5 butterflies (selected by mode) over the given samples. The oracle rebuilds the twiddle table for nfft exactly as compute_twiddles() does, applies the static kernel body with the supplied fstride/m/N/mm strides, and returns both the twiddle table and the transformed samples.

type KissFFTTwiddle

type KissFFTTwiddle struct {
	R int16
	I int16
}

KissFFTTwiddle is a complex twiddle factor with int16 Q15 real/imaginary parts matching the FIXED_POINT (non-QEXT) libopus kiss_twiddle_cpx.

type MultistreamDecodeCase added in v0.2.0

type MultistreamDecodeCase struct {
	SampleRate uint32
	GainQ8     int32
	Format     uint32
	Family     uint32
	Channels   uint32
	Streams    uint32
	Coupled    uint32
	FrameSize  uint32
	Mapping    []byte
	Demixing   []byte
	Packet     []byte
}

MultistreamDecodeCase is one independent public multistream or projection decode request. ProbeMultistreamDecodeFresh creates a new C decoder for each.

type MultistreamDecodeResult added in v0.2.0

type MultistreamDecodeResult struct {
	Code       int32
	FinalRange uint32
	PCM        []byte
}

MultistreamDecodeResult contains the raw decoder return code, final range, and PCM bytes. PCM is the public API's little-endian float32, int16, or int24-in-int32 output.

func ProbeMultistreamDecodeFresh added in v0.2.0

func ProbeMultistreamDecodeFresh(cases []MultistreamDecodeCase) ([]MultistreamDecodeResult, error)

ProbeMultistreamDecodeFresh batches independent public decoder requests into one helper process while creating and destroying a C decoder for every case. Decode failures are returned as negative Code values; framing/build/run failures remain errors. Results preserve request order, and PCM slices retain the shared helper-output backing buffer.

type OpusEncodeFixedMixedFrame added in v0.2.0

type OpusEncodeFixedMixedFrame struct {
	Format      uint32 // 0=opus_encode, 1=opus_encode_float, 2=opus_encode24
	ShortPCM    []int16
	FloatPCM    []float32
	PCM24       []int32
	ResetBefore bool
	VBRAction   uint32 // OpusVBRUnchanged, OpusVBREnable, or OpusVBRDisable.
	// Nonzero per-frame values override the global controls using libopus
	// MODE_* and OPUS_BANDWIDTH_* values, respectively.
	ForceMode int
	Bandwidth int
	// EnergyMaskAction is one of OpusEnergyMaskUnchanged, OpusEnergyMaskSet, or
	// OpusEnergyMaskClear. Set supplies channels*21 Q24 celt_glog values.
	EnergyMaskAction uint32
	EnergyMask       []int32
}

OpusEncodeFixedMixedFrame selects one public input API on a persistent selected fixed-point OpusEncoder. Exactly one PCM field is used per frame.

type OpusEncodeFixedParams

type OpusEncodeFixedParams struct {
	SampleRate int
	Channels   int
	// Application selects the libopus encoder application. Zero selects Audio.
	Application int
	// MaxPacketBytes is the caller's whole-packet output capacity. Zero uses 4000.
	MaxPacketBytes int
	ForceMode      int
	Bandwidth      int
	Bitrate        int
	Complexity     int
	VBR            bool
	VBRConstraint  bool
	// ForceChannels pins the coded channel count via OPUS_SET_FORCE_CHANNELS
	// (1 or 2). Zero leaves it auto, letting opus_encode pick mono/stereo per
	// frame from its own stereo-width analysis.
	ForceChannels int
	// LSBDepth sets OPUS_SET_LSB_DEPTH before encoding. Zero retains the C default.
	LSBDepth int
	// ExpertFrameDuration sets OPUS_SET_EXPERT_FRAME_DURATION before encoding.
	// Zero keeps OPUS_FRAMESIZE_ARG.
	ExpertFrameDuration int
	// LFE sets OPUS_SET_LFE before any frame is encoded.
	LFE        bool
	FrameSize  int // per-channel samples at SampleRate
	FrameCount int
	// PCM is the interleaved int16 input for all frames,
	// length FrameSize*Channels*FrameCount.
	PCM []int16
	// ResetBefore requests OPUS_RESET_STATE before the corresponding frame.
	// A nil slice means no resets.
	ResetBefore []bool
}

OpusEncodeFixedParams configures a top-level FIXED_POINT opus_encode probe. The reference encoder is created via opus_encoder_create(SampleRate, Channels, OPUS_APPLICATION_AUDIO) and driven through the int16 opus_encode API, so the whole resampler/SILK/CELT integer chain runs exactly as the public fixed-point encoder does. ForceMode (when non-zero) pins SILK/Hybrid/CELT via OPUS_SET_FORCE_MODE; Bandwidth (when non-zero) pins the bandwidth via OPUS_SET_BANDWIDTH + OPUS_SET_MAX_BANDWIDTH.

type OpusEncodeFixedRecord added in v0.2.0

type OpusEncodeFixedRecord struct {
	Status     int32
	Packet     []byte
	FinalRange uint32
}

OpusEncodeFixedRecord is one opus_encode call, including an empty or failed call, its complete packet, and OPUS_GET_FINAL_RANGE after successful encode.

func ProbeOpusEncodeFixedMixedRecords added in v0.2.0

func ProbeOpusEncodeFixedMixedRecords(p OpusEncodeFixedParams, frames []OpusEncodeFixedMixedFrame) ([]OpusEncodeFixedRecord, error)

ProbeOpusEncodeFixedMixedRecords alternates the three public input APIs on one selected FIXED_POINT+ENABLE_RES24 C encoder and returns every call.

func ProbeOpusEncodeFixedQEXTMixedRecords added in v0.2.0

func ProbeOpusEncodeFixedQEXTMixedRecords(p OpusEncodeFixedParams, frames []OpusEncodeFixedMixedFrame) ([]OpusEncodeFixedRecord, error)

ProbeOpusEncodeFixedQEXTMixedRecords runs the public mixed-input probe against the selected FIXED_POINT + ENABLE_QEXT libopus archive. Its C helper enables QEXT through OPUS_SET_QEXT(1) before any input frame is encoded.

func ProbeOpusEncodeFixedQEXTRuntimeOffMixedRecords added in v0.2.0

func ProbeOpusEncodeFixedQEXTRuntimeOffMixedRecords(p OpusEncodeFixedParams, frames []OpusEncodeFixedMixedFrame) ([]OpusEncodeFixedRecord, error)

ProbeOpusEncodeFixedQEXTRuntimeOffMixedRecords runs the fixed public encoder against the paired ENABLE_QEXT archive without setting OPUS_SET_QEXT. This covers the combined build's default runtime-off path with matching Q31 CELT tables and transforms.

func ProbeOpusEncodeFixedRecords added in v0.2.0

func ProbeOpusEncodeFixedRecords(p OpusEncodeFixedParams) ([]OpusEncodeFixedRecord, error)

ProbeOpusEncodeFixedRecords drives the selected FIXED_POINT+ENABLE_RES24 reference with identical signed-16 input and public output capacity. The result preserves one record per call, including DTX or error records.

func ProbeOpusEncodeFloatBuildMixedRecords added in v0.2.0

func ProbeOpusEncodeFloatBuildMixedRecords(p OpusEncodeFixedParams, frames []OpusEncodeFixedMixedFrame) ([]OpusEncodeFixedRecord, error)

ProbeOpusEncodeFloatBuildMixedRecords exercises all public input APIs on one selected float-build C encoder, including their distinct LSB-depth policy.

func ProbeOpusEncodeFloatBuildShortRecords added in v0.2.0

func ProbeOpusEncodeFloatBuildShortRecords(p OpusEncodeFixedParams) ([]OpusEncodeFixedRecord, error)

ProbeOpusEncodeFloatBuildShortRecords calls opus_encode(int16*) in the selected non-fixed C build, preserving the short callback's LSB-depth rule.

func ProbeOpusEncodeFloatQEXTRuntimeOffMixedRecords added in v0.2.0

func ProbeOpusEncodeFloatQEXTRuntimeOffMixedRecords(p OpusEncodeFixedParams, frames []OpusEncodeFixedMixedFrame) ([]OpusEncodeFixedRecord, error)

ProbeOpusEncodeFloatQEXTRuntimeOffMixedRecords compares the ordinary float build against ENABLE_QEXT with OPUS_SET_QEXT left disabled.

type OraclePayload

type OraclePayload struct {
	// contains filtered or unexported fields
}

func NewOraclePayload

func NewOraclePayload(inputMagic string, header ...uint32) *OraclePayload

func NewOraclePayloadVersion

func NewOraclePayloadVersion(inputMagic string, version uint32, header ...uint32) *OraclePayload

func (*OraclePayload) Bytes

func (p *OraclePayload) Bytes() []byte

func (*OraclePayload) Float32

func (p *OraclePayload) Float32(v float32)

func (*OraclePayload) Float32s

func (p *OraclePayload) Float32s(values ...float32)

func (*OraclePayload) I16

func (p *OraclePayload) I16(v int16)

func (*OraclePayload) I32

func (p *OraclePayload) I32(v int32)

func (*OraclePayload) I32s

func (p *OraclePayload) I32s(values ...int32)

func (*OraclePayload) Magic

func (p *OraclePayload) Magic(magic string)

func (*OraclePayload) Raw

func (p *OraclePayload) Raw(data []byte)

func (*OraclePayload) U16

func (p *OraclePayload) U16(v uint16)

func (*OraclePayload) U32

func (p *OraclePayload) U32(v uint32)

func (*OraclePayload) U32s

func (p *OraclePayload) U32s(values ...uint32)

type OracleReader

type OracleReader struct {
	// contains filtered or unexported fields
}

func NewOracleReader

func NewOracleReader(label, outputMagic string, data []byte) (*OracleReader, error)

func NewOracleReaderMagicVersion

func NewOracleReaderMagicVersion(label, outputMagic string, data []byte) (*OracleReader, uint32, error)

func NewOracleReaderVersion

func NewOracleReaderVersion(label, outputMagic string, data []byte) (*OracleReader, uint32, error)

func RunOracle

func RunOracle(binPath string, input []byte, label, outputMagic string) (*OracleReader, error)

func RunOracleEnv

func RunOracleEnv(binPath string, input []byte, label, outputMagic string, env []string) (*OracleReader, error)

func RunOracleVersion

func RunOracleVersion(binPath string, input []byte, label, outputMagic string, wantVersion uint32) (*OracleReader, error)

func RunOracleVersionEnv

func RunOracleVersionEnv(binPath string, input []byte, label, outputMagic string, wantVersion uint32, env []string) (*OracleReader, error)

func (*OracleReader) Bytes

func (r *OracleReader) Bytes(n int) []byte

func (*OracleReader) Count

func (r *OracleReader) Count(want int) int

func (*OracleReader) Err

func (r *OracleReader) Err() error

func (*OracleReader) ExpectConsumed

func (r *OracleReader) ExpectConsumed() error

func (*OracleReader) ExpectRemaining

func (r *OracleReader) ExpectRemaining(n int)

func (*OracleReader) Float32

func (r *OracleReader) Float32() float32

func (*OracleReader) Float64

func (r *OracleReader) Float64() float64

func (*OracleReader) I16

func (r *OracleReader) I16() int16

func (*OracleReader) I32

func (r *OracleReader) I32() int32

func (*OracleReader) Remaining

func (r *OracleReader) Remaining() int

func (*OracleReader) U16

func (r *OracleReader) U16() uint16

func (*OracleReader) U32

func (r *OracleReader) U32() uint32

func (*OracleReader) U64

func (r *OracleReader) U64() uint64

type PublicAPIReferenceIdentity added in v0.2.0

type PublicAPIReferenceIdentity struct {
	ArchivePath string
	BuildDir    string
	SourceDir   string
	Variant     libopustooling.LibopusReferenceVariant
	DNN         bool
	DRED        bool
	OSCE        bool
	QEXT        bool
	Custom      bool
}

PublicAPIReferenceIdentity records the archive selected for the current public Go build. DNN archives use their feature stamp and feature fields; other archives use the standard libopustooling variant stamp.

func ResolvePublicAPIReferenceIdentity added in v0.2.0

func ResolvePublicAPIReferenceIdentity() (PublicAPIReferenceIdentity, error)

ResolvePublicAPIReferenceIdentity selects the same archive as BuildPublicAPIHelper, ensures DNN archives exist, and validates the selected archive's source, feature, and instruction identity before returning it.

func (PublicAPIReferenceIdentity) Validate added in v0.2.0

func (identity PublicAPIReferenceIdentity) Validate() error

Validate checks the selected archive's stamped source, feature, and ISA identity before a caller uses it as parity evidence.

type QEXT96kAutoFrame added in v0.2.0

type QEXT96kAutoFrame struct {
	Bitrate int
	PCM     []float32
}

type QEXT96kAutoRecord added in v0.2.0

type QEXT96kAutoRecord struct {
	Status        int32
	Packet        []byte
	FinalRange    uint32
	CELTCalls     uint32
	CELTFrameSize uint32
	CELTStream    uint32
	CELTBitrate   int32
	CELTLSBDepth  int32
	CELTMaxBytes  uint32
	CELTInput     []float32
	CELTState     []uint32
	PitchBuffer   []float32
	PitchSearch   int32
	RemoveInput   int32
	RemoveOutput  int32
	RemoveGain    uint32
}

func ProbeQEXT96kAutoChannels added in v0.2.0

func ProbeQEXT96kAutoChannels(frameSize, maxPacketBytes, complexity, lsbDepth int, qext bool, frames []QEXT96kAutoFrame) ([]QEXT96kAutoRecord, error)

ProbeQEXT96kAutoChannels runs the selected float + ENABLE_QEXT public encoder with OPUS_APPLICATION_AUDIO and per-frame bitrate updates.

func ProbeQEXT96kAutoChannelsState added in v0.2.0

func ProbeQEXT96kAutoChannelsState(frameSize, maxPacketBytes, complexity, lsbDepth int, qext bool, frames []QEXT96kAutoFrame) ([]QEXT96kAutoRecord, error)

type QEXTDecode96kParams

type QEXTDecode96kParams struct {
	SampleFormat             uint32 // QEXTDecode96kFormat* (float32/int16/int24)
	Channels                 int
	SampleRate               int      // API rate for selected fixed-QEXT probes
	PhaseInversionDisabled   bool     // explicit control for version-5 selected fixed-QEXT probes
	IgnoreExtensions         bool     // OPUS_SET_IGNORE_EXTENSIONS for selected fixed-QEXT probes
	MaxFrameSize             int      // per-channel API-rate sample capacity passed to opus_decode
	GainQ8                   int32    // decoder output gain for version-2 probes; zero for version 1
	PacketFormats            []uint32 // per-packet int16/int24 formats for mixed-format probes
	DecodeFEC                []bool   // per-packet decode_fec flag for version-8 sequence probes
	IgnoreExtensionsByPacket []bool   // per-packet OPUS_SET_IGNORE_EXTENSIONS for version-9 probes
	Packets                  [][]byte // Opus packets to decode in sequence through one decoder
}

QEXTDecode96kParams configures a QEXT full-packet decode probe. Selected fixed-reference probes use SampleRate as the API rate: ENABLE_QEXT uses the native 96 kHz CELT geometry at 96 kHz and the 48 kHz geometry with API-rate downsampling for rates through 48 kHz.

type QEXTDecode96kResult

type QEXTDecode96kResult struct {
	PCM         []float32
	Int16       []int16
	Int24       []int32
	MixedInt32  []int32 // mixed-format output; int16 samples are sign-extended
	FinalRanges []uint32
	Status      []int32 // per-packet decode status for fixed-QEXT sequence probes
}

QEXTDecode96kResult holds decoded interleaved PCM and per-packet final ranges. For float32 output PCM is populated; Int16/Int24 carry the integer formats. Exactly one of the three is non-nil depending on SampleFormat.

func ProbeQEXTDecode96k

func ProbeQEXTDecode96k(p QEXTDecode96kParams) (QEXTDecode96kResult, error)

ProbeQEXTDecode96k decodes the supplied Opus packets through the QEXT-enabled libopus reference at Fs=96000 and returns the native 96 kHz PCM (interleaved) plus the per-packet OPUS_GET_FINAL_RANGE values.

func ProbeQEXTDecode96kFixed added in v0.2.0

func ProbeQEXTDecode96kFixed(p QEXTDecode96kParams) (QEXTDecode96kResult, error)

ProbeQEXTDecode96kFixed decodes packets through the selected FIXED_POINT+ENABLE_QEXT libopus reference. Version 2 adds an explicit output gain control while retaining the version-1 packet and result layout.

func ProbeQEXTDecode96kFixedMixed added in v0.2.0

func ProbeQEXTDecode96kFixedMixed(p QEXTDecode96kParams) (QEXTDecode96kResult, error)

ProbeQEXTDecode96kFixedMixed uses the selected FIXED_POINT+ENABLE_QEXT archive for the same mixed opus_decode/opus_decode24 sequence.

func ProbeQEXTDecode96kMixed added in v0.2.0

func ProbeQEXTDecode96kMixed(p QEXTDecode96kParams) (QEXTDecode96kResult, error)

ProbeQEXTDecode96kMixed decodes packets through one persistent QEXT-enabled decoder while alternating opus_decode and opus_decode24. MixedInt32 stores both formats as int32 values, sign-extending opus_decode output.

func ProbeQEXTDecodeFECSequence added in v0.2.0

func ProbeQEXTDecodeFECSequence(p QEXTDecode96kParams) (QEXTDecode96kResult, error)

ProbeQEXTDecodeFECSequence decodes a persistent float-QEXT sequence with an explicit decode_fec flag for each packet. Protocol v8 records decode status for rejected packets while continuing with the same C decoder.

func ProbeQEXTDecodeFixed added in v0.2.0

func ProbeQEXTDecodeFixed(p QEXTDecode96kParams) (QEXTDecode96kResult, error)

ProbeQEXTDecodeFixed decodes a received sequence through the selected FIXED_POINT+ENABLE_QEXT reference. Protocol v5 carries the API sample rate and phase-inversion control explicitly; v7 adds the extension-ignore control.

func ProbeQEXTDecodeFixedFECSequence added in v0.2.0

func ProbeQEXTDecodeFixedFECSequence(p QEXTDecode96kParams) (QEXTDecode96kResult, error)

ProbeQEXTDecodeFixedFECSequence decodes a persistent selected fixed-QEXT sequence with an explicit decode_fec flag for each packet. Protocol v8 also records each public decode status so callers can verify recovery behavior.

func ProbeQEXTDecodeFixedPerPacketIgnore added in v0.2.0

func ProbeQEXTDecodeFixedPerPacketIgnore(p QEXTDecode96kParams) (QEXTDecode96kResult, error)

ProbeQEXTDecodeFixedPerPacketIgnore decodes a persistent fixed-QEXT sequence while selecting OPUS_SET_IGNORE_EXTENSIONS separately for each packet.

func ProbeQEXTDecodeFixedSequence added in v0.2.0

func ProbeQEXTDecodeFixedSequence(p QEXTDecode96kParams) (QEXTDecode96kResult, error)

ProbeQEXTDecodeFixedSequence decodes a persistent fixed-QEXT sequence while recording errors and continuing with the same C decoder. Failed packets add no PCM; Status records their negative opus_decode result.

func ProbeQEXTDecodePublic added in v0.2.0

func ProbeQEXTDecodePublic(p QEXTDecode96kParams) (QEXTDecode96kResult, error)

ProbeQEXTDecodePublic decodes a sequence through the public libopus configuration selected by the current Go build. It carries the API sample rate and decoder controls needed to compare public QEXT decode paths below and at 96 kHz.

type QEXTEncode96kParams

type QEXTEncode96kParams struct {
	Channels      int
	FrameSize     int // per-channel samples at 96 kHz
	Bitrate       int
	Complexity    int
	VBR           bool
	VBRConstraint bool
	MaxPacketSize int
	// PCM is the interleaved native 96 kHz float input for all frames,
	// length FrameSize*Channels*FrameCount.
	PCM        []float32
	FrameCount int
}

QEXTEncode96kParams configures a native 96 kHz QEXT full-packet encode probe. The reference encoder is created with opus_encoder_create(96000, channels, OPUS_APPLICATION_RESTRICTED_LOWDELAY) plus OPUS_SET_QEXT(1) and CELT-only / fullband forcing, so it runs the native 96 kHz CELT mode and the >20 kHz extension-band encode chain.

type QEXTEncode96kResult

type QEXTEncode96kResult struct {
	Packets     [][]byte
	FinalRanges []uint32
}

QEXTEncode96kResult holds the produced native 96 kHz QEXT Opus packets and the per-frame final range from the reference encoder.

func ProbeQEXTEncode96k

func ProbeQEXTEncode96k(p QEXTEncode96kParams) (QEXTEncode96kResult, error)

ProbeQEXTEncode96k encodes the supplied native 96 kHz float PCM frames through the QEXT-enabled libopus reference at Fs=96000 and returns the produced Opus packets plus the per-frame OPUS_GET_FINAL_RANGE values.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL