dolby

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, MIT Imports: 7 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 dolby decodes AC-3 and single-program E-AC-3 packets to planar PCM.

Index

Constants

View Source
const (
	// BlockLength is the samples per channel of an audio block.
	BlockLength = 256
	// FrameLength is the samples per channel of an AC-3 syncframe, its six
	// audio blocks, and so of an MP4 sample of AC-3.
	FrameLength = 6 * BlockLength
	// MaxChannels is the stride of the core PCM scratch buffer.
	MaxChannels = 6
)
View Source
const (
	Left = iota
	Right
	Center
	LFE
	LeftSurround
	RightSurround
)

Speaker lanes in the interleaved core scratch buffer.

View Source
const (
	ModeDualMono = 0 // 1+1: two independent mono channels, Ch1 and Ch2
	ModeMono     = 1 // 1/0: C
	ModeStereo   = 2 // 2/0: L, R
	Mode30       = 3 // 3/0: L, C, R
	Mode21       = 4 // 2/1: L, R, S
	Mode31       = 5 // 3/1: L, C, R, S
	Mode22       = 6 // 2/2: L, R, Ls, Rs
	Mode32       = 7 // 3/2: L, C, R, Ls, Rs
)

Audio coding modes, the acmod of a stream: its full-bandwidth channels, as the front ones / the surround ones.

Variables

View Source
var (
	// ErrFormat is wrapped by the errors of data that is not AC-3, or is
	// corrupt.
	ErrFormat = errors.New("ac3: invalid data")
	// ErrBufferTooSmall is returned by Decode for room for less than the
	// frames of the data.
	ErrBufferTooSmall = errors.New("ac3: buffer too small")
)
View Source
var ErrUnsupported = errors.ErrUnsupported

ErrUnsupported identifies a valid feature outside the decoder's capability.

Functions

This section is empty.

Types

type Decoder

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

Decoder maintains overlap and dither state for one AC-3 or E-AC-3 track. Its output is borrowed until the next Decode call. Use it in one goroutine.

func NewDecoder

func NewDecoder(packet []byte, enhanced bool) (*Decoder, error)

NewDecoder determines the format from the leading program in packet. Pass that packet to Decode to obtain its PCM.

func (*Decoder) Decode

func (d *Decoder) Decode(packet []byte) (audio.Buffer[float32], error)

Decode decodes every syncframe in one packet. A decode error is terminal because future packets depend on the overlap and dither state.

func (*Decoder) PCMFormat

func (d *Decoder) PCMFormat() audio.Format

PCMFormat reports the sample rate and order of the active speaker planes.

Jump to

Keyboard shortcuts

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