Documentation
¶
Overview ¶
Package truehd parses framed TrueHD (FBA) access units and reconstructs channel-based PCM for the supported restart syntax and layouts.
The parser and decoder are adapted from truehdd's Apache-2.0 truehd crate. See UPSTREAM.md for the pinned source and LICENSE and NOTICE for attribution.
Index ¶
Constants ¶
const (
// MaxAccessUnitSize follows from the 12-bit length in 16-bit words.
MaxAccessUnitSize = 2 * 0xfff
)
Variables ¶
var ( ErrMalformed = errors.New("malformed TrueHD access unit") ErrUnsupported = errors.New("unsupported TrueHD syntax") )
Functions ¶
func AccessUnitSize ¶
AccessUnitSize reads the length from the first two bytes. The caller must gather that many bytes before passing the unit to Parser.Parse.
Types ¶
type AccessUnit ¶
type AccessUnit struct {
Format Format
MajorSync bool
InputTiming uint16
Substreams [maxSubstreams]Substream
Auxiliary []byte
}
AccessUnit holds validated framing and borrowed slices of one input unit. Substreams beyond Format.SubstreamCount are empty.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder reconstructs the highest channel-based presentation of an FBA stream, including the channel-based presentation in Atmos streams. It reconstructs restart syntax A and B. Its zero value starts at a major sync.
type Format ¶
type Format struct {
SampleRate int
SamplesPerAccessUnit int
SubstreamCount int
SixChannelAssignment uint8
EightChannelAssignment uint16
PresentationMasks [maxSubstreams]uint8
}
Format is the stream configuration established by the most recent major sync. PresentationMasks lists the substreams needed for each presentation. The highest set bit names the substream that completes the presentation.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser carries the configuration from one access unit to the next. Its zero value expects an access unit starting with a major sync.
type RestartHeader ¶
type RestartHeader struct {
SyncWord uint16
OutputTiming uint16
MinChannel uint8
MaxChannel uint8
MaxMatrixChannel uint8
DitherShift uint8
DitherSeed uint32
MaxShift uint8
MaxLSBs uint8
MaxBits uint8
ErrorProtection bool
LosslessCheck uint8
HiResOutputTiming bool
ChannelAssignment [16]uint8
BlockHeaderBit int
}
RestartHeader records the channel and sample coding parameters in a substream's restart. ChannelAssignment maps matrix channels to output channels. BlockHeaderBit is relative to the substream payload.