Documentation
¶
Overview ¶
Package testutil is the shared test harness: the ffmpeg/ffprobe differential oracle, PCM comparison helpers, deterministic signal synthesis, and the SHA-256-pinned conformance-vector fetcher.
ffmpeg is a TEST ORACLE only, never a runtime dependency. Oracle-based tests self-skip when ffmpeg is not installed; setting WAXFLOW_REQUIRE_FFMPEG=1 (the dedicated CI differential job) escalates absence to a hard failure so the suite cannot silently thin out.
Index ¶
- Constants
- Variables
- func APEDecodeFile(t testing.TB, apePath string) []byte
- func APEEncodeFile(t testing.TB, wavPath, name string, level int) string
- func APETool(t testing.TB) string
- func APEVerifyFile(t testing.TB, path string)
- func DiffI32(a, b []int32) int
- func EBMLChildren(t testing.TB, buf []byte, fn func(EBMLElement))
- func EBMLFind(t testing.TB, buf []byte, id uint32) (body []byte, found bool)
- func EBMLSeekTargets(t testing.TB, seekHead []byte) []uint32
- func EBMLSegment(t testing.TB, file []byte) (body []byte, definite bool)
- func EncoderQualityGate(t testing.TB)
- func FDKEncodeADTS(t testing.TB, dir, wav string, rate, channels, kbps int, profile string) string
- func FFmpeg(t testing.TB) string
- func FFmpegAACEncodeFile(t testing.TB, wavPath string, kbps int) string
- func FFmpegDecodeF32(t testing.TB, path string) []float32
- func FFmpegDecodeF32Codec(t testing.TB, path, decoder string) []float32
- func FFmpegDecodeF32NoSIMD(t testing.TB, path string) []float32
- func FFmpegDecodeS32(t testing.TB, path string) []int32
- func FFmpegDecoder(t testing.TB, name string)
- func FFmpegEncoder(t testing.TB, name string)
- func FFmpegFDKEncodeFile(t testing.TB, dir, wav string, kbps int, profile, format string) string
- func FFmpegGenerate(t testing.TB, path string, rate, channels int, acodec string, extra ...string)
- func FFmpegGenerateDuration(t testing.TB, path string, seconds float64, rate, channels int, acodec string, ...)
- func FFmpegVorbisEncodeBitrate(t testing.TB, wavPath string, kbps int) string
- func FFmpegVorbisEncodeFile(t testing.TB, wavPath string, quality float64) string
- func FFprobe(t testing.TB) string
- func FFprobeFormatDuration(t testing.TB, path string) float64
- func Fetch(w io.Writer, dir string, vectors []Vector) error
- func FlacEncodeFile(t testing.TB, wavPath string, level int) int64
- func FlacTest(t testing.TB, path string)
- func FlacTool(t testing.TB) string
- func FloatWAVBytes(t *testing.T, rate int, chans [][]float32) []byte
- func HaveAPETool(t testing.TB) bool
- func HaveFDK(t testing.TB) bool
- func HaveFDKEncoder(t testing.TB) bool
- func HaveFFmpeg(t testing.TB) bool
- func HaveLAME(t testing.TB) bool
- func HaveLibVorbis(t testing.TB) bool
- func HaveLibVorbisDecoder(t testing.TB) bool
- func HaveWMFEnc(t testing.TB) bool
- func HotFloatChans(t *testing.T, rate, frames, overs int) [][]float32
- func Interleave(b *audio.Buffer) []int32
- func InterleaveF(b *audio.Buffer) []float32
- func IntersampleHotChans(rate, frames int) [][]float32
- func LAMEEncodeFile(t testing.TB, wavPath string, kbps int) string
- func MuxAtOffset(t testing.TB, base int64, mux func(w io.Writer)) []byte
- func Noise(f audio.Format, frames int, seed uint64) *audio.Buffer
- func ODGProxy(ref, test []float32, rate, channels int) float64
- func OggVorbisFile(id, comment, setup []byte, packets [][]byte, granules []int64, samples int64) []byte
- func OpusCompare(ref, test []float32, nchannels int) float64
- func OpusCompareTool(t testing.TB, opusCompare string, ref, test []int16, channels int) (werr, q float64)
- func OpusDemoDecode(t testing.TB, opusDemo, bitPath string, rate, channels int) []int16
- func OpusDemoEncode(t testing.TB, opusDemo string, pcm []int16, ...) [][]byte
- func OpusDemoRoundTrip(t testing.TB, opusDemo string, pcm []int16, ...) []int16
- func OpusQualityCorpus() []string
- func OpusSpeechCorpus() map[string][]string
- func OpusTools(t testing.TB) (opusDemo, opusCompare string)
- func PCM16WAVBytes(t *testing.T, rate int, chans [][]float32) []byte
- func Ramp(f audio.Format, frames int) *audio.Buffer
- func RampAtF(channel int, pos int64) float32
- func RampAtI(f audio.Format, channel int, pos int64) int32
- func Shine(t testing.TB) string
- func ShineEncodeFile(t testing.TB, wavPath string, kbps int) string
- func Sine(f audio.Format, frames int, freq, amp float64) *audio.Buffer
- func ToneChans(rate, frames int) [][]float32
- func VectorPath(t testing.TB, name string) string
- func VectorsDir() string
- func WAVData(t testing.TB, raw []byte) []byte
- func WMFEncode(t testing.TB, wav, out string, rate, channels, bitRate int)
- func WavPackEncodeFile(t testing.TB, wavPath, name string, opts ...string) string
- func WavPackTool(t testing.TB) string
- func WriteFloatWAV(t *testing.T, path string, rate int, chans [][]float32)
- func WriteOpusBitstream(path string, packets [][]byte, ranges []uint32) error
- func WriteWAV(t testing.TB, path string, f audio.Format, samps []int32)
- func WvUnpackDecodeFile(t testing.TB, path string) []byte
- func WvUnpackTool(t testing.TB) string
- func WvUnpackVerify(t testing.TB, path string)
- type BandStat
- type EBMLElement
- type FFprobeInfo
- type FFprobePacket
- type FloatDiff
- type MemWriteSeeker
- type PipeWriteSeeker
- type Vector
Constants ¶
const ( EBMLIDHeader = 0x1A45DFA3 EBMLIDSegment = 0x18538067 EBMLIDSeekHead = 0x114D9B74 EBMLIDSeek = 0x4DBB EBMLIDSeekID = 0x53AB EBMLIDInfo = 0x1549A966 EBMLIDDuration = 0x4489 EBMLIDTracks = 0x1654AE6B EBMLIDCues = 0x1C53BB6B EBMLIDCluster = 0x1F43B675 )
The element IDs these helpers name, in their on-wire form.
Variables ¶
var Vectors = []Vector{}/* 111 elements not displayed */
Vectors lists every pinned vector, fetched by `make verify-vectors` (CI-cached, never committed). The list grows with the codecs: the IETF FLAC suite is in; MP3/LAME gapless fixtures and opus_testvectors join with their decoders. Committed fixtures stay tiny and live directly under testdata/.
The FLAC entries are the complete IETF decoder testbench (ietf-wg-cellar/flac-test-files) pinned at commit aa7b0c6: the 64-file subset suite (bit-exactness gate), the uncommon set (32-bit, extreme rates and block sizes, mid-stream format changes), and the faulty set (deliberately broken files that must fail gracefully).
Functions ¶
func APEDecodeFile ¶
APEDecodeFile runs the reference decoder on a .ape and returns the WAV it writes. It is the second half of the reference-tool gate: mac -v checks a stream against its stored MD5 and frame CRCs, which says the bytes are intact, while this one says they decode to the audio we meant.
func APEEncodeFile ¶
APEEncodeFile runs the reference encoder on a WAV input at the given compression level (1000 fast to 5000 insane) and returns the .ape path. The output lands beside the input, named for the cell so one source can feed several.
func APETool ¶
APETool locates the reference `mac` console tool. No distribution packages it, so `make ape-tools` builds it from the pinned SDK source into testdata/tools, the same way the libopus tools are built. WAXFLOW_APE_TOOLS overrides the directory; tests self-skip when the binary is absent and WAXFLOW_REQUIRE_MAC=1 escalates absence to failure.
func APEVerifyFile ¶
APEVerifyFile runs the reference decoder's own verification of a stream, which checks every frame against the CRC the encoder stored.
func DiffI32 ¶
DiffI32 compares int sample slices exactly. It returns the index of the first mismatch, or -1 when equal (length mismatch counts as a mismatch at the shorter length).
func EBMLChildren ¶
func EBMLChildren(t testing.TB, buf []byte, fn func(EBMLElement))
EBMLChildren walks the elements packed in buf. The progress guarantee lives here rather than in every caller.
func EBMLSeekTargets ¶
EBMLSeekTargets returns the SeekID of every Seek entry in a SeekHead body.
func EBMLSegment ¶
EBMLSegment returns a Matroska file's Segment body and whether its size was declared rather than left unknown (the streaming form).
func EncoderQualityGate ¶
EncoderQualityGate self-skips an encoder-quality gate unless WAXFLOW_ENCODER_QUALITY=1 is set. These gates re-encode a corpus with our lossy encoders and a reference baseline and score both: minutes of work whose home is the dedicated `make encoder-quality` target and the nightly job, not the default `go test` loop. `make encoder-quality` sets the variable; without it the gates skip so a plain run stays fast.
func FDKEncodeADTS ¶
FDKEncodeADTS encodes wav with libfdk at the given bitrate and profile ("aac_he" or "aac_he_v2") into an ADTS stream in dir, through whichever libfdk route this machine has: ffmpeg's wrapper, or the WAXFLOW_FDKENC tool fed raw s16le (the same 16-bit input depth the wrapper uses). Skips (or fails under WAXFLOW_REQUIRE_FDK=1) when neither exists.
func FFmpegAACEncodeFile ¶
FFmpegAACEncodeFile encodes a WAV file to AAC-LC in M4A at the given bit rate (kbit/s) with ffmpeg's native aac encoder, the AAC quality gate's reference (docs/quality-gates.md: a realistic bar, not Apple's encoder). The native encoder ships in every ffmpeg build, so plain FFmpeg availability (and its WAXFLOW_REQUIRE_FFMPEG escalation) gates it. Decode the result with FFmpegDecodeF32 to score against the reference.
func FFmpegDecodeF32 ¶
FFmpegDecodeF32 decodes a file with ffmpeg (its default decoder) to raw interleaved little-endian float32 samples.
func FFmpegDecodeF32Codec ¶
FFmpegDecodeF32Codec decodes with a specific ffmpeg decoder (e.g. "libvorbis"). ffmpeg's default Vorbis decoder is its own native one, which is flagged experimental (trac.ffmpeg.org ticket 10571) and mis-decodes some legal coupled streams: its vectorized inverse coupling negates the angle channel on any line stored as a zero magnitude with a nonzero angle, where its own C fallback (reachable with -cpuflags 0) and the spec do not. Selecting libvorbis pins the reference decoder so a stream is tested against libvorbis itself, not ffmpeg's experimental reimplementation. Scoring OUR streams, prefer this over FFmpegDecodeF32 for exactly that reason; a gate that wants to prove what a libavcodec-based player hears should call FFmpegDecodeF32 deliberately, as TestVorbisCoupledStereo does.
func FFmpegDecodeF32NoSIMD ¶
FFmpegDecodeF32NoSIMD decodes with ffmpeg's default decoder and -cpuflags 0, which disables runtime SIMD dispatch and reaches libavcodec's plain C implementations. Paired with FFmpegDecodeF32 it separates a defect in a vectorized kernel from one in the decoder proper, which is how the Vorbis coupled-stereo defect behind F1 was pinned to ffmpeg's vectorized inverse coupling.
func FFmpegDecodeS32 ¶
FFmpegDecodeS32 decodes a file with ffmpeg to raw interleaved little-endian int32 samples. ffmpeg left-justifies narrower sources (16-bit becomes value<<16), so comparisons shift accordingly.
func FFmpegDecoder ¶
FFmpegDecoder is FFmpegEncoder for the decoder listing, which a build can carry independently of the encoder.
func FFmpegEncoder ¶
FFmpegEncoder and FFmpegDecoder gate a test on one external ffmpeg codec, skipping (or failing under WAXFLOW_REQUIRE_FFMPEG=1) when this build omits it. They are the general form of HaveLibVorbis and friends, for the fixture generators that name a codec inline; see haveCodecQuiet for why a missing codec is an ordinary state to handle rather than a broken machine.
func FFmpegFDKEncodeFile ¶
FFmpegFDKEncodeFile encodes wav with libfdk_aac at the given bitrate and profile ("aac_he" or "aac_he_v2") into dir, returning the output path. format is "m4a" or "adts". Skips (or fails under WAXFLOW_REQUIRE_FDK=1) when this build has no libfdk_aac.
func FFmpegGenerate ¶
FFmpegGenerate synthesizes a short fixture file with ffmpeg (sine source) at the given rate, channel count, and output codec, for decode differentials against an independent implementation.
func FFmpegGenerateDuration ¶
func FFmpegGenerateDuration(t testing.TB, path string, seconds float64, rate, channels int, acodec string, extra ...string)
FFmpegGenerateDuration is FFmpegGenerate with the source length spelled out, for a fixture that needs to be long enough to have interesting structure (several clusters, a seek index with entries to skip).
func FFmpegVorbisEncodeBitrate ¶
FFmpegVorbisEncodeBitrate encodes a WAV file to Ogg-Vorbis with libvorbis at a target average bit rate (kbit/s), for a bitrate-matched comparison.
func FFmpegVorbisEncodeFile ¶
FFmpegVorbisEncodeFile encodes a WAV file to Ogg-Vorbis with libvorbis at the given quality (-q:a scale, libvorbis's native VBR knob) and returns the output path. Decode it with FFmpegDecodeF32 to score against the reference. It skips (or fails under WAXFLOW_REQUIRE_FFMPEG) when libvorbis is absent.
func FFprobeFormatDuration ¶
FFprobeFormatDuration is the container-level duration ffprobe reports in seconds, or -1 when the container declares none.
It is separate from FFprobeFile rather than another field on FFprobeInfo: that type is scoped to stream fields and shared by several differential tests, where a format-level duration would be meaningless. This is the number `ffprobe -show_entries format=duration` prints, which for Matroska is the Info > Duration element read verbatim, with no CodecDelay or DiscardPadding adjustment applied.
func Fetch ¶
Fetch downloads vectors into dir, verifying each digest. Files already present with a matching digest are kept; mismatches are re-downloaded, and a mismatched download is an error. Progress goes to w.
func FlacEncodeFile ¶
FlacEncodeFile runs the reference encoder at the given level on a WAV input and returns the encoded size in bytes, the size-gate baseline.
func FlacTest ¶
FlacTest runs `flac -t` on path and fails the test if the reference decoder rejects the stream. Warnings (an unset MD5 on a streamed output, say) are tolerated; only a nonzero exit fails.
func FlacTool ¶
FlacTool returns the flac reference binary's path, skipping or failing per the policy.
func FloatWAVBytes ¶
FloatWAVBytes renders planar channels as an interleaved IEEE float32 WAV in memory, for the callers that feed a container.BytesSource and have no use for a file on disk.
func HaveAPETool ¶
HaveAPETool reports whether the reference tool is available, for a test that has something to check without it and more to check with it. It follows the same policy as APETool: WAXFLOW_REQUIRE_MAC=1 turns absence into a failure rather than a quiet loss of coverage.
func HaveFDK ¶
HaveFDK reports whether ffmpeg carries the libfdk_aac encoder, failing instead under WAXFLOW_REQUIRE_FDK=1.
func HaveFDKEncoder ¶
HaveFDKEncoder reports whether libfdk is reachable at all (through ffmpeg or the WAXFLOW_FDKENC tool), failing instead under WAXFLOW_REQUIRE_FDK=1.
func HaveFFmpeg ¶
HaveFFmpeg reports whether ffmpeg is installed, for a test that still has work to do without it and so must not take FFmpeg's blanket skip (a gate whose own in-process leg is the part that always runs, with the oracle decoders added when they are there). WAXFLOW_REQUIRE_FFMPEG=1 still escalates absence to a failure, so the dedicated differential job cannot silently thin out.
func HaveLAME ¶
HaveLAME reports whether ffmpeg carries libmp3lame. LAME is an informational reference column in the quality report, never a gate, so absence is a false, not a skip: this deliberately does not escalate under WAXFLOW_REQUIRE_FFMPEG, which is why it does not go through haveCodec.
func HaveLibVorbis ¶
HaveLibVorbis reports whether ffmpeg carries the libvorbis encoder.
func HaveLibVorbisDecoder ¶
HaveLibVorbisDecoder reports whether ffmpeg carries the libvorbis decoder, which a build can omit independently of the encoder. It is the reference Vorbis decoder the quality gates pin; ffmpeg's own native Vorbis decoder is a separate implementation reached without -c:a libvorbis.
func HaveWMFEnc ¶
HaveWMFEnc reports whether Windows' WMA encoder can be driven here.
func HotFloatChans ¶
HotFloatChans is the shared clipping fixture: ToneChans touching both exact rails (load-bearing: +1.0 must not be counted, and the rail step rings past full scale, so even overs 0 is not quiet; ToneChans is), plus overs samples per channel planted at alternating +-1.5.
func Interleave ¶
Interleave flattens a planar buffer to interleaved int32 samples, left-shifted to 32-bit like ffmpeg's s32le output, for direct comparison against FFmpegDecodeS32.
func InterleaveF ¶
InterleaveF flattens a planar float buffer to interleaved float32.
func IntersampleHotChans ¶
IntersampleHotChans is the fixture for the clip count's structural gap: a quarter-rate stereo sine phased off its crests, stored peak about 0.85, true peak 1.2. Resampling would turn the between-sample overs into stored ones and fire the count instead.
func LAMEEncodeFile ¶
LAMEEncodeFile encodes a WAV file to CBR MP3 with libmp3lame and returns the output path.
func MuxAtOffset ¶
MuxAtOffset drives mux twice: once into a writer at the start of its destination, once into one already positioned base bytes in. It returns the stream the second run wrote, so a caller can read back what an offset destination holds.
The two streams must be identical, which is the contract rather than a convenience: a muxer states stream offsets about itself, so nothing it writes may vary with where the destination started.
The two runs differ only when a back-patch takes a stream offset for a file offset, which lands base bytes early: in front of the stream, where the recognizable filler is.
func Noise ¶
Noise synthesizes seeded uniform noise spanning the full sample range, with the range extremes pinned to the first frames of every channel so clipping and sign bugs cannot hide.
func ODGProxy ¶
ODGProxy returns the ODG-proxy of a coded signal (test) against its reference, both interleaved with the given channel count and sample rate. The signals need not be pre-aligned; the encoder and codec delay are found by a correlation search.
func OggVorbisFile ¶
func OggVorbisFile(id, comment, setup []byte, packets [][]byte, granules []int64, samples int64) []byte
OggVorbisFile frames raw Vorbis packets into an Ogg-Vorbis byte stream for ffmpeg (or another decoder) to read. It is TEST-ONLY scaffolding so the Vorbis encoder can be exercised through a real container without depending on the production Ogg-Vorbis muxer (which carries the exact gapless granulepos). The granule positions here are approximate: they are enough for a decoder to produce PCM, not the exact trims a player would honor.
id/comment/setup are the three Vorbis headers; packets are the audio packets; granules[k] is the cumulative decoded sample count after packet k (the encoder stamps each packet's decoded length in Dur, so this is a running sum that carries variable block sizes correctly); samples is the true length, stamped on the final (EOS) page.
func OpusCompare ¶
OpusCompare is a Go port of libopus's opus_compare.c, the RFC 6716 section 6 conformance metric. It returns the quality percentage Q comparing a candidate decode against a reference decode; a decoder is conformant on a test vector when Q >= 0. ref and test are interleaved samples at the 48 kHz output rate on the int16 amplitude scale (roughly [-32768, 32767]); the metric's additive masking constants assume that scale, so normalized [-1,1] output must be multiplied by 32768 before calling.
Only the 48 kHz path is ported (WaxFlow always decodes Opus to 48 kHz), so downsample is 1, ybands is 21, and yfreqs equals NFREQS.
func OpusCompareTool ¶
func OpusCompareTool(t testing.TB, opusCompare string, ref, test []int16, channels int) (werr, q float64)
OpusCompareTool scores test against ref with the reference opus_compare binary (the RFC 6716 section 6 quality metric; the validated Go port OpusCompare serves the decoder conformance test) and returns the internal weighted error plus the quality score Q derived from it. Both inputs are interleaved 16-bit PCM at 48 kHz and must hold the same sample count. The weighted error is the gate unit (docs/quality-gates.md): Q-point deltas do not compare across error depths, and opus_compare prints Q only when it is positive anyway, while both the pass and fail paths report the error.
func OpusDemoDecode ¶
OpusDemoDecode decodes an opus_demo bitstream file through the reference libopus decoder and returns the interleaved 16-bit output. Decode-only opus_demo applies no pre-skip trimming: the output timeline starts at the first decoded sample, so the caller trims its encoder's declared pre-skip for sample-exact alignment.
func OpusDemoEncode ¶
func OpusDemoEncode(t testing.TB, opusDemo string, pcm []int16, rate, channels, bps, complexity int) [][]byte
OpusDemoEncode encodes raw PCM with the reference libopus encoder alone (opus_demo -e) at the given CBR bit rate and complexity, returning the raw Opus packets. The TOC byte of each packet carries libopus's mode and bandwidth decisions, which the speech gate compares against ours.
func OpusDemoRoundTrip ¶
func OpusDemoRoundTrip(t testing.TB, opusDemo string, pcm []int16, rate, channels, bps, complexity int) []int16
OpusDemoRoundTrip encodes and decodes raw PCM through the reference libopus encoder and decoder in one opus_demo run at the given CBR bit rate and complexity. Combined-mode opus_demo trims the encoder lookahead from the decoded output, so the result is sample-aligned with pcm (and shorter by the lookahead at the tail).
func OpusQualityCorpus ¶
func OpusQualityCorpus() []string
OpusQualityCorpus lists the vector names of the pinned 20-track Opus encoder-quality corpus in gate order.
func OpusSpeechCorpus ¶
OpusSpeechCorpus returns the speech-gate items: a name per speaker and the zip member paths whose decoded audio is concatenated in order.
func OpusTools ¶
OpusTools locates the reference libopus tools opus_demo and opus_compare, the robust encoder-quality oracle: opus_demo decodes bitstreams with the reference decoder at deterministic sample positions (no cross-correlation alignment), and opus_compare is the RFC 6716 section 6 metric. They are built from the pinned libopus source by `make opus-tools` into testdata/tools. WAXFLOW_OPUS_TOOLS overrides the directory; tests self-skip when the tools are absent and WAXFLOW_REQUIRE_OPUS_TOOLS=1 escalates absence to failure.
func PCM16WAVBytes ¶
PCM16WAVBytes renders planar float channels as an interleaved 16-bit PCM WAV in memory, samples rounded at full scale and clamped to the int16 range: the way a fixture enters the engine as integers, a copy path no float source can reach.
func Ramp ¶
Ramp synthesizes a per-channel counter (offset by channel) that walks the full range, making positions identifiable by value: sample i of channel c is predictable, which seek tests rely on.
func RampAtI ¶
RampAtI is the closed form of Ramp for int formats, letting tests verify any position without holding the whole signal.
func Shine ¶
Shine returns the ffmpeg path if its libshine encoder is available, skipping or failing per the policy.
The membership test is haveCodec's listing parse, not `ffmpeg -h encoder=libshine`: that command exits 0 whether or not the encoder exists (it prints "Codec 'libshine' is not recognized by FFmpeg" and succeeds), so the check it looks like it is making it does not make. This gate answered "yes" on every machine with ffmpeg for as long as it was written that way.
func ShineEncodeFile ¶
ShineEncodeFile encodes a WAV file to CBR MP3 at the given bit rate (kbit/s) with libshine and returns the output path. It is the Shine half of the baseline comparison; decode it with FFmpegDecodeF32 to score against the reference.
func Sine ¶
Sine synthesizes a full-scale-scaled sine per channel (each channel's phase offset by its index, so channel swaps are detectable).
func ToneChans ¶
ToneChans is the quiet base fixture: a 0.4 amplitude 440 Hz stereo tone, nowhere near full scale on or between samples, for the warning tests' "says nothing" halves.
func VectorPath ¶
VectorPath returns the local path of a fetched vector. Tests self-skip when it has not been fetched; WAXFLOW_REQUIRE_VECTORS=1 (CI jobs that ran `make verify-vectors` first) escalates absence to failure.
func VectorsDir ¶
func VectorsDir() string
VectorsDir returns the on-disk vector cache, testdata/vectors under the repository root (located relative to this source file).
func WMFEncode ¶
WMFEncode encodes a WAV to WMA Standard v2 with Windows' own encoder. The encoder chooses its own bit rate near the request and ignores it entirely at low sample rates, so callers read back what they actually got rather than asserting the request.
func WavPackEncodeFile ¶
WavPackEncodeFile runs the reference encoder on a WAV input with the given options (compression level, channel handling) and returns the .wv path. The output lands beside the input, named for the options so one source can feed several cells.
func WavPackTool ¶
WavPackTool returns the reference encoder's path, skipping or failing per the policy.
func WriteFloatWAV ¶
WriteFloatWAV writes planar channels as an interleaved IEEE float32 WAV.
The float domain is the point: an ffmpeg differential that measured a quantized int16 file would be comparing its filter against samples the Go side never saw, so a rounding difference would read as a detection difference. Writing float32 makes ffmpeg measure bit-identical samples to what the analyzer saw, which is what lets these differentials assert tight bounds rather than fuzzy ones.
chans must be non-empty and its channels equal length.
func WriteOpusBitstream ¶
WriteOpusBitstream writes packets in the opus_demo bitstream form: a 4-byte big-endian payload length, the 4-byte big-endian range coder final state, then the payload. ranges carries each packet's Encoder.FinalRange; opus_demo verifies the reference decoder reaches the same state on every packet and hard-fails the decode on a mismatch, so the file format itself carries a cross-implementation integrity check.
func WriteWAV ¶
WriteWAV writes interleaved int samples as a canonical PCM WAV, the input form every reference encoder here takes. 8-bit rides unsigned, as WAV requires; wider depths are little-endian signed.
func WvUnpackDecodeFile ¶
WvUnpackDecodeFile decodes a .wv with the reference decoder and returns the data chunk of the WAV it writes.
It is the strongest check available on an encoder: `wvunpack -v` says the reference accepts the stream, and this says the samples it gets back are the ones that went in. Neither our decoder nor ffmpeg's reads every header field, so a block can be wrong in a way both of them shrug off; the reference reads all of it.
func WvUnpackTool ¶
WvUnpackTool returns the reference decoder's path, skipping or failing per the policy.
func WvUnpackVerify ¶
WvUnpackVerify runs `wvunpack -v` on path, the reference decoder's own verification of a stream, and fails the test if it rejects it. It is how a fixture is confirmed well-formed before our decoder is blamed for a mismatch.
Types ¶
type BandStat ¶
type BandStat struct {
LoHz, HiHz float64 // band edges
SignalFracDB float64 // 10log10(band signal energy / total), a spectral profile
NoiseToSigDB float64 // 10log10(band noise energy / band signal energy)
}
BandStat is one bark band's diagnostic breakdown from ODGBandNMR: where the reference's energy sits and how loud the coding noise is relative to it.
func ODGBandNMR ¶
ODGBandNMR is the per-bark-band diagnostic behind ODGProxy: instead of pooling to one scalar it reports each band's share of the reference energy and the coding noise-to-signal there, so a quality deficit can be localized in frequency (floor shape vs valley noise vs HF rolloff). Alignment and framing match ODGProxy. It is a diagnostic, not a gate.
type EBMLElement ¶
EBMLElement is one parsed element: its ID and the bounds of its body within the buffer it was read from.
type FFprobeInfo ¶
type FFprobeInfo struct {
CodecName string
SampleRate int
Channels int
BitsPerSample int
BitsPerRawSample int
// Samples is duration_ts, which equals the frame count for PCM
// containers (their stream timebase is 1/rate). -1 when absent.
Samples int64
}
FFprobeInfo is the subset of ffprobe stream fields the differential tests compare against our probe.
func FFprobeFile ¶
func FFprobeFile(t testing.TB, path string) FFprobeInfo
FFprobeFile probes the first audio stream with ffprobe.
type FFprobePacket ¶
type FFprobePacket struct {
// PTS and Dur are in the stream time base (milliseconds for ASF).
PTS int64
Dur int64
Size int
}
FFprobePacket is one demuxed packet as ffprobe reports it: the container's own framing, in the stream's time base, before any decoding.
func FFprobePackets ¶
func FFprobePackets(t testing.TB, path string) []FFprobePacket
FFprobePackets lists the first audio stream's packets. It is the oracle for a demuxer whose codec has no decoder yet: packet count, sizes, and presentation times are the whole of what a demuxer produces, and ffprobe reports all three without decoding a sample.
type FloatDiff ¶
type FloatDiff struct {
N int // samples compared
RMS float64 // root mean square of the differences
MaxAbs float64 // largest absolute difference
MaxAt int // index of the largest difference
}
FloatDiff summarizes the difference between two float sample slices.
func CompareF32 ¶
CompareF32 measures a and b, which must be the same length.
type MemWriteSeeker ¶
type MemWriteSeeker struct {
Buf []byte
// contains filtered or unexported fields
}
MemWriteSeeker is an in-memory io.WriteSeeker, for exercising a muxer's back-patch path without a temp file.
func (*MemWriteSeeker) Pos ¶
func (w *MemWriteSeeker) Pos() int64
Pos reports where the writer sits, which a muxer that back-patches must leave at the end of what it wrote.
func (*MemWriteSeeker) Seek ¶
func (w *MemWriteSeeker) Seek(off int64, whence int) (int64, error)
Seek refuses a negative position, which is what a file does: a muxer that patches at a slot it never reserved gets an error at the seek rather than a panic in the next Write.
func (*MemWriteSeeker) SeekTo ¶
func (w *MemWriteSeeker) SeekTo(off int64)
SeekTo positions the writer past the start of its destination.
type PipeWriteSeeker ¶
type PipeWriteSeeker struct{ Buf []byte }
PipeWriteSeeker satisfies io.WriteSeeker the way *os.File does for a pipe: the method is there whether or not the object behind it can seek. A muxer that reads seekability off the method set takes it for a file.
type Vector ¶
type Vector struct {
// Name is the path under testdata/vectors/ once fetched.
Name string
// URL is the upstream source.
URL string
// SHA256 is the hex digest the download must match.
SHA256 string
}
Vector is one SHA-256-pinned external conformance vector. Pinning is both reproducibility and supply-chain hygiene: a changed upstream file fails loudly instead of silently changing what the suite verifies.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
vectorfetch
command
Command vectorfetch downloads the SHA-256-pinned conformance vectors into testdata/vectors.
|
Command vectorfetch downloads the SHA-256-pinned conformance vectors into testdata/vectors. |