An extension adds to what the core carries without breaking decoders that know only the core: they play the core and skip the rest. An extension is found in one of two places: inside the core frame, after the audio data and before the frame’s end (the extension data of the core substream), or in an extension substream that follows the core frame.
| Extension | Sync word | What it adds | Where | Decoded here |
|---|---|---|---|---|
| XCh | 5A5A5A5A | a sixth full-bandwidth channel, the rear centre (DTS-ES discrete 6.1) | core frame (EXT_AUDIO_ID 0) | yes |
| XXCh | 47004A03 | more channels: side, rear, height and wide speakers, up to 7.1 with the core | core frame (EXT_AUDIO_ID 6) or substream | yes, one channel set |
| X96 | 1D95F262 | the upper half of a 96 kHz signal: the core is a 48 kHz signal of 32 subbands, X96 adds 32 more | core frame (EXT_AUDIO_ID 2) or substream | yes |
| XBR | 655E315E | extra bits for the core subbands: a residual that raises the bit rate and the accuracy | substream | yes |
| LBR | 0A801921 | DTS Express: a different, low bit rate codec | substream | no |
| XLL | 41A29547 | the lossless layer of DTS-HD Master Audio: the exact source, as a residual of the core or as an independent stream | substream | yes, bit for bit |
XCh
After the sync word come the size of the extension (10 bits, minus 1; at least 96 bytes) and
a 7-bit check value, 8. The extension’s end must be the end of the core frame, give or take one
byte; that distance is how a decoder tells a real XCh from a chance 5A5A5A5A. The data
then have the layout of a core frame’s audio data for one channel: an audio coding header for that
channel and the subframes. When the ES flag of the core header is set, the rear centre was also
mixed into both surround channels with a gain of 0.707 before the core was coded; the decoder
subtracts it again.
XXCh
The extension begins with a header: the sync word, the header size and its CRC, a flag for CRCs in the channel set headers, the number of bits of the speaker mask, the number of channel sets (decoded: one), the size of the channel set, and the mask of the core’s speakers. The channel set holds the number of channels (up to two), the mask of the speakers they feed, an optional downmix (a scale, which core speakers each added channel was mixed into, and the coefficients, from a table of 241 values) and then the same coding header and subframes as the core. The decoder undoes the downmix so that the core channels are as they were before it.
X96
After the sync word come the size (12 bits), a revision number (1 to 8), a CRC flag and, for an extension substream, the channel sets. For each channel it gives a resolution flag, the first coded subband and the number of subbands (32 to 64), the joint coding, and code books. The 32 upper subbands’ samples then follow, in subframes like the core’s, with a bit allocation of 1 for a subband of vector-quantised samples, 0 for a subband of noise (the decoder makes it from the scale factor with a fixed pseudo-random generator) and larger values for coded samples. The synthesis filter bank has 64 bands and produces 64 samples for each set of subband samples, so the sampling rate is doubled.
XBR
A header with the size of each channel set, a flag for transitions, and for each channel the number of subbands. For each subframe it then sends, for each subband, a bit allocation (2 to 5 bits wide), the scale factor width and the scale factors, and the sample groups coded like the core’s (block codes up to resolution 7, plain values above). The result is added to the core’s subband samples before the filter bank.
XLL: the lossless layer
XLL is what makes a DTS-HD stream Master Audio. It carries the source signal exactly: decoding it gives back every sample the encoder was given, in 16 or 24 bits, up to 192 kHz and eight channels or more. It sits in an extension substream, either beside a core (then most of its channels are the difference between the source and what the core decodes to, which is small) or alone (every channel is coded in full). A player that does not know XLL plays the core and skips it.
Where it is
An asset of an extension substream lists XLL as component 9 (or, in coding mode 1, as its only component). The asset descriptor gives the size of the XLL data, a flag for a sync position, a decoding delay in frames and the byte offset of the first XLL sync word in this substream, and a 3-bit stream identifier (a change of identifier makes the decoder drop what it holds). Each substream carries the XLL data for one frame, but the data of a frame may be longer or shorter than the substream’s share: see peak bit rate smoothing.
Frame header
An XLL frame starts with this header; a CRC-16 covers it from the field after the sync word to its end. Fields stored “minus 1” are read as the value plus 1.
| Field | Bits | Meaning |
|---|---|---|
| sync word | 32 | 0x41A29547 |
| version | 4 | minus 1; only version 1 is defined |
| header size | 8 | bytes, minus 1 |
| frame size width | 5 | the width of the next field, minus 1 |
| frame size | 1 to 32 | bytes of the whole frame, minus 1 (at most 245,760) |
| channel sets | 4 | minus 1 |
| segments | 4 | log2 of the number of segments in a frame (up to 1,024) |
| samples in a segment | 4 | log2, 2 to 512; a frame holds segments × samples samples a channel (the first band) |
| segment size width | 5 | the width of the sizes in the NAVI table and of the LSB section size, minus 1 |
| band checksums | 2 | 0 none; 1 a CRC after the MSB part of band 0; 2 also after its LSB part; 3 also in the other bands |
| MSB/LSB split | 1 | whether samples are coded as a high and a low part |
| channel mask width | 5 | bits in a channel mask, minus 1 |
| fixed LSB width | 4 | only with the split; when not 0 every channel’s low part has this width |
| reserved, padding, CRC-16 | … | to the header size |
Channel set header
One header for each channel set, each starting with its size (10 bits, bytes minus 1) and ending in a CRC-16 over the whole header. A channel set is a group of up to eight channels that are decoded together; a stream has one for 5.1 and more for layouts built up in steps (a stereo set, then the channels that make 5.1, then those that make 7.1), so that a decoder that stops early has a complete smaller mix.
| Field | Bits | Meaning |
|---|---|---|
| channels | 4 | minus 1 |
| residual mask | one a channel | 1: the channel is coded in full; 0: it is the residual of the core’s channel |
| PCM bit resolution | 5 | minus 1: the width of the source samples (1 to 24) |
| storage bit resolution | 5 | minus 1: 16 or 24; the samples are shifted up to this width |
| sampling rate | 4 | the code of the substream table, 8 kHz to 192 kHz |
| rate modifier, replacement set | 2 + 2 | both 0 for the streams that are decoded |
| primary set | 1 | one-to-one mapping only: the first set carries the base layout |
| downmix present, embedded | 1 + 1 | a matrix is sent; the encoder has already mixed the channels down in the signal |
| downmix type | 3 | primary set only: the layout the matrix makes (one to four output channels) |
| hierarchy | 1 | whether the set takes part in the chain of downmixes |
| downmix matrix | 9 each | sign and an index into a table of 241 gains; a set that is not primary also sends a scale (9 bits) for each row |
| channel mask | 1, then the mask width | which speakers the channels feed (bit n is speaker n of the speaker list); without a mask, an angle, an elevation and a distance (9, 9 and 7 bits) for each channel |
| extra bands | 1 | for rates above 96 kHz: 2 frequency bands, or 4 if set (only 2 are supported) |
Then, for each frequency band, the parameters of the prediction:
| Field | Bits | Meaning |
|---|---|---|
| decorrelation | 1 | whether channel pairs were coded as a channel and a difference |
| original order | 1 to 4 each | the position each coded channel takes after decoding |
| decorrelation coefficient | 1, then 7 signed | for each pair: the gain applied to the first channel before it is added to the second |
| adaptive predictor order | 4 each | 0 to 15 for each channel (the order cannot exceed the samples in a segment) |
| fixed predictor order | 2 each | only for a channel with adaptive order 0: how many times the samples are summed |
| reflection coefficients | 8 each, signed | for each adaptive order, an index into a table of 128 values of the 16.16 fixed-point reflection coefficients |
| embedded downmix | 1 | other bands only |
| LSB section size, LSB widths | segment size width; 4 each | with the split: the bytes of low parts at the end of every segment, and the width of each channel’s low part |
| bits discarded | 4 each | how many low bits the encoder removed (they are zero) |
The table of segment sizes (NAVI)
After the channel set headers comes a table with the size in bytes (minus 1) of each segment of band
data, in the order band, segment, channel set, and a CRC-16. It lets a decoder go to any segment, and
skip those of channel sets it does not need. The explorer shows it as the Segment sizes node of
the XLL component. (The DTS-HD file’s own NAVI chunk is a different table, of the
frames of the file; the decoder does not use it.)
A segment
A segment holds, for each channel of its set, the residuals of one stretch of samples. It begins with its coding parameters, which a segment after the first may take over from the one before with a single bit: a flag whether all channels share one set of parameters, and for each set a Rice or linear choice, an optional hybrid flag with the width of the raw codes, and the code parameters for the first samples of the frame (part A: as many samples as the channel’s predictor order, only in the first segment) and for the rest (part B). A width of 3 to 5 bits holds each parameter (wider for 24-bit storage, one bit more when there is more than one channel set or band).
- Linear code: each sample is a signed value of the given width, the sign in the
lowest bit:
(v >> 1) ^ -(v & 1); width 0 means all zeros. - Rice code: a unary number of zero bits ended by a 1 is the quotient, the next
k bits the remainder, and the value
quotient << k | remainderis mapped to a signed number in the same way. - Hybrid Rice code: a count of isolated samples and their positions (each as wide as the segment’s log2 size) come first; the isolated samples, which are too big for the Rice parameter, are linear codes of the stated width and the others are Rice codes.
The first segment of the higher band also holds the decimator history: seven samples of each channel with a shared width. The low parts, if the frame is split, end the segment.
Decoding a frame
- The headers are read and their checksums checked; the segment table gives where each segment is. A segment that cannot be read is replaced by silence and counted, and the frame is then not lossless.
- The residuals of each channel are decoded segment by segment into the frame’s samples.
- Inverse prediction. With an adaptive order n the reflection coefficients are turned into direct-form coefficients (a recursion that adds, for each new coefficient, the products of the coefficients so far with it, in 16-bit fractions), and from sample n on each sample is the coded value minus the rounded, clipped sum of the previous n samples weighted by the coefficients. The first n samples are coded as they are. With an adaptive order 0 the fixed order says how many times the running sum is taken.
- Inverse decorrelation. For each pair the first channel, multiplied by the coefficient (in eighths), is added to the second, and the channels are put in their original order.
- Low parts. Each sample is shifted up by the width of its low part and the low bits are added.
- The core. For a channel that is the residual of the core, the core’s own samples are added: the core is decoded again in integer arithmetic (a bit-exact filter bank), reduced to the source width (with the downmix scale of the next channel set undone), and added to the decoded residual. A channel with no core counterpart, or a stream with no core, has no such step.
- Downmix chain. A set marked as an embedded downmix was mixed from the channels of the sets before it. Each matrix row is applied again, ramped from the previous frame’s coefficients over the length of the frame, and subtracted, which gives back the original channels; the last scale is applied to the rest.
- Two bands. For a set above 96 kHz the two bands, each at half the rate, are merged by a fixed filter network: three one-coefficient stages and a difference, then eight stages of three filters with tabulated coefficients. The decimator history stands in for the samples before the frame, the result alternates the two bands’ samples, and the second is delayed by seven.
- The samples are shifted to the storage width (when the source was narrower) and clipped to it.
Decoding needs no memory of earlier samples: prediction and decorrelation work inside one frame, so a decoder can start at any frame that begins with a sync word. What does carry over is the downmix coefficients of the previous frame (used for the ramp), the bytes held for peak bit rate smoothing, and the core’s filter memory.
Peak bit rate smoothing
Loud passages need more bytes than the substream’s share, quiet ones fewer. The encoder fills the gaps by letting the data of a frame run on into the next substream (the asset says where the next sync word is, and how many frames the decoder must wait before it can use a buffer started elsewhere). A decoder that holds the surplus in a buffer (up to 240 KiB) decodes the frame when its bytes are all there and keeps the rest. A substream that begins inside a frame the decoder has not seen has no sync word at its start: if the previous one had XLL data, the lossy core is played for that frame, in the layout of the lossless layer, and the frame is marked not lossless.
Integrity
The stream has CRC-16 checksums on the frame header, on every channel set header and on the segment size table, and optionally one after the band data (these are not checked). It carries no checksum or hash of the decoded samples, so a decoder can prove the structure is intact but not the samples; a damaged segment decodes to wrong samples without being noticed. When a checksum fails, the XLL data of that frame is dropped and the core is heard instead. The explorer reports “verified” when every checksum it can check passes.
What the explorer does
With the option Core only off (the default) a Master Audio stream is played from its lossless
layer, in every place the core could be: the DTS viewer, dtsh and dtsl MP4
tracks, mp4a tracks of object types 0xA9 to 0xAB, Matroska A_DTS and
A_DTS/LOSSLESS tracks, and WAVE files holding DTS-HD. The viewer opens the XLL component
into the frame header, the channel set headers (with their bands), the table of segment sizes and the
segments, with the coding parameters of each. With Core only on, the lossy core is played and
every extension is ignored.
LBR and DTS:X
LBR (sync word 0A801921) is DTS Express, a low bit rate codec of its own. DTS:X (ETSI
TS 103 491) adds object-based audio in a further extension substream. The explorer finds them in the
stream and shows their size and placement; it does not decode either, so a stream with only those
has no sound, and one with a core plays the core.