testvectors

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: 9 Imported by: 1 module, 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

Overview

Package testvectors parses opus_demo bitstreams and supports quality checks against the RFC 8251 Opus test vectors.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTruncatedHeader indicates insufficient data for packet header.
	ErrTruncatedHeader = errors.New("testvectors: truncated packet header (need 8 bytes)")

	// ErrTruncatedPacket indicates packet data shorter than header specified.
	ErrTruncatedPacket = errors.New("testvectors: truncated packet data")

	// ErrEmptyFile indicates the file contains no packets.
	ErrEmptyFile = errors.New("testvectors: empty file (no packets)")
)

Errors returned by the parser.

View Source
var (
	QualityBarNearExact = qualitycompare.QualityBarNearExact
	QualityBarRFC       = qualitycompare.QualityBarRFC
)

Trusted quality bars.

View Source
var (
	CompareDecodedFloat32                     = qualitycompare.CompareDecodedFloat32
	ComputeOpusCompareQuality                 = qualitycompare.ComputeOpusCompareQuality
	ComputeOpusCompareQualityFloat32          = qualitycompare.ComputeOpusCompareQualityFloat32
	ComputeOpusCompareQualityFloat32WithDelay = qualitycompare.ComputeOpusCompareQualityFloat32WithDelay
	QualityBarForMode                         = qualitycompare.QualityBarForMode
	AssertQuality                             = qualitycompare.AssertQuality
)

Comparator and opus_compare entry points.

Functions

This section is empty.

Types

type BitstreamInfo

type BitstreamInfo struct {
	PacketCount int  // Number of packets in the bitstream
	TotalBytes  int  // Total bytes of packet data (excluding headers)
	FirstTOC    byte // TOC byte of first packet (for mode detection)
	Duration    int  // Estimated duration in samples at 48kHz
}

BitstreamInfo contains summary information about a parsed bitstream.

func GetBitstreamInfo

func GetBitstreamInfo(packets []Packet) BitstreamInfo

GetBitstreamInfo returns summary information about a parsed bitstream. Duration assumes one frame per packet and a constant frame duration taken from the first packet's TOC. It is not a full packet-duration calculation.

type Packet

type Packet struct {
	// Data is the raw Opus packet data (including TOC byte).
	Data []byte

	// FinalRange is the range coder final state from encoding.
	// This can be used to verify range decoder state matches after decoding.
	FinalRange uint32
}

Packet contains an encoded Opus packet and its recorded encoder final range.

func ParseOpusDemoBitstream

func ParseOpusDemoBitstream(data []byte) ([]Packet, error)

ParseOpusDemoBitstream reads opus_demo .bit file format from a byte slice.

The format per packet is (big-endian, network byte order):

  • uint32_be: packet_length (4 bytes)
  • uint32_be: enc_final_range (4 bytes, range coder verification)
  • byte[packet_length]: opus_packet_data

Packet payloads are copied from data. Empty input returns a nil slice and nil error. Framing errors return an error without partial results; payloads are not validated as Opus packets.

func ReadBitstreamFile

func ReadBitstreamFile(filename string) ([]Packet, error)

ReadBitstreamFile reads an opus_demo .bit file, caching the result by filename. Each call returns its own Packet slice, but Data slices share cached storage and must not be modified. After a successful load is cached, subsequent calls do not observe file changes. Read or parse failures are not cached.

type QualityBar

type QualityBar = qualitycompare.QualityBar

QualityBar is a trusted parity threshold.

type QualityComparison

type QualityComparison = qualitycompare.QualityComparison

QualityComparison is the result of a trusted opus_compare-based comparison.

Jump to

Keyboard shortcuts

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