adts

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT, Apache-2.0, MIT Imports: 2 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

Overview

Package adts builds and parses Audio Data Transport Stream headers.

Index

Constants

View Source
const (
	// HeaderSize is the size of an ADTS header without a CRC.
	HeaderSize = 7
	// CRCSize is the size of the optional CRC that follows the header when
	// protection_absent is zero (one raw data block per frame).
	CRCSize = 2
	// MaxFrameLength is the largest value representable by adts_frame_length.
	MaxFrameLength = 1<<13 - 1
	// VariableBitRateBufferFullness marks a variable-rate stream.
	VariableBitRateBufferFullness = 0x7ff
)

Variables

View Source
var (
	// ErrShortHeader reports input shorter than one CRC-free ADTS header.
	ErrShortHeader = errors.New("ADTS header is shorter than 7 bytes")
	// ErrSyncWord reports a missing 12-bit ADTS syncword.
	ErrSyncWord = errors.New("invalid ADTS syncword")
)

Functions

func Build

func Build(h Header) ([]byte, error)

Build serializes a CRC-free ADTS fixed_header() and variable_header() — ISO/IEC 13818-7 section 6.2.1. protection_absent is always one.

Types

type Header struct {
	// MPEGID is zero for MPEG-4 and one for MPEG-2.
	MPEGID uint8
	// Profile is the two-bit ADTS profile value; AAC-LC is 1 (AOT minus one).
	Profile                uint8
	SamplingFrequencyIndex uint8
	ChannelConfiguration   uint8
	FrameLength            int
	BufferFullness         uint16
	NumRawDataBlocks       uint8
	// CRCPresent mirrors protection_absent == 0: a 16-bit CRC follows the
	// header. Build always emits CRC-free headers.
	CRCPresent bool
}

Header holds the fixed and variable fields of a seven-byte ADTS header. Field widths and meanings follow ISO/IEC 13818-7 section 6.2.1.

func Parse

func Parse(buf []byte) (Header, error)

Parse reads an ADTS fixed_header() and variable_header() — ISO/IEC 13818-7 section 6.2.1.

func (Header) PayloadOffset

func (h Header) PayloadOffset() int

PayloadOffset returns the offset of the raw data blocks within the frame: the header plus the optional CRC.

Jump to

Keyboard shortcuts

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