testvectors

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 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 provides utilities for parsing and validating against official RFC 8251 Opus test vectors.

The package implements: - opus_demo .bit file parser (proprietary framing format) - Quality metric computation for decoder compliance - Test infrastructure for RFC 8251 validation

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. This is useful for test vector processing reports.

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 represents a decoded opus_demo packet with metadata. The opus_demo format stores packets with their range coder final state for verification purposes.

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

Returns all packets in the bitstream, or an error if the format is invalid.

func ReadBitstreamFile

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

ReadBitstreamFile reads and parses an opus_demo .bit file from disk. This is a convenience function that combines os.ReadFile with ParseOpusDemoBitstream.

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