Introduction
DTS Coherent Acoustics, usually just DTS, is a lossy multichannel audio codec from DTS, Inc.
It carries up to 5.1 channels in its core at sampling rates from 8 to 48 kHz, and DTS-HD
extensions add more channels, rates up to 192 kHz and higher bit rates, and a lossless layer
(DTS-HD Master Audio). It was used on DVD-Video, in cinemas, on CD (DTS Audio CDs), on Blu-ray
and in game and film files. A .dts file is the raw stream; .cpt is
the extension some CD rippers give it; .dtshd and .dtsma hold a
DTS-HD stream in a container of chunks. The codec is specified in ETSI TS 102 114.
Structure
A bare stream has no header of its own: core frames, one after another. Each starts with a 32-bit sync word. The stream may also carry extension substreams, which begin with a different sync word and sit after the core frame they belong to. Because DTS was stored on 16-bit audio media, a stream is found in four byte forms, told apart by the sync word.
0Core frame sync word 7FFE8001, header, audio data, optional dataFSIZE + 1 bytes…Extension substream (DTS-HD only) sync word 64582025, header, assetsoptional, after a core frame…Core frame the next onerepeated
| Sync word | Bytes in the file | Form |
|---|---|---|
| 7FFE8001 | 7F FE 80 01 | 16-bit words, big-endian: the form the standard writes |
| FE7F0180 | FE 7F 01 80 | 16-bit words, little-endian: each pair of bytes swapped (WAV files, CD rips) |
| 1FFFE800 | 1F FF E8 00 | 14-bit words, big-endian: each 16-bit word holds 14 bits (DTS Audio CDs, S/PDIF) |
| FF1F00E8 | FF 1F 00 E8 | 14-bit words, little-endian |
| 64582025 | 64 58 20 25 | an extension substream, big-endian 16-bit |
| 58642520 | 58 64 25 20 | an extension substream, little-endian 16-bit |
The reference pages cover the parts of the stream:
- Core frame – the frame header field by field, the audio coding header and the sizes
- Audio data – subframes, subband samples, quantisation, prediction, the LFE channel
- Extensions – XCh, XXCh, X96, XBR, XLL and LBR
- DTS-HD files – the DTSHDHDR container and the extension substream header
Decoding DTS
The explorer decodes DTS wherever it is stored. A bare .dts, .cpt or
.dtshd file is read and played by its own viewer, which shows every frame, the
fields of the frame header and of the audio coding header, the extension substreams and the
waveform. Inside other files the sound is decoded in a WAVE
file (format codes 0x0008, 0x0190 and 0x2001 with the frames
in the data chunk; a 16-bit stereo PCM file whose samples are IEC 61937 bursts, the “DTS WAV”;
and the IEC 61937 DTS and DTS-HD subformat GUIDs), in an MP4 file
(the dtsc, dtsh and dtsl sample entries with their ddts box, and
mp4a entries of object type 0xA9, 0xAA and 0xAB) and in a Matroska
file (A_DTS and A_DTS/LOSSLESS). A DTS-HD Master Audio stream is played from its lossless
layer in all of them; the viewer for bare files has the option Core only to play the lossy core.
What is decoded
- The core: every channel arrangement of the header (1 to 5 primary channels and the LFE channel), 8, 11.025, 12, 16, 22.05, 24, 32, 44.1 and 48 kHz, 16, 20 and 24-bit sources, frames of 256 to 4,096 samples, joint intensity coding, sum and difference channels, subband prediction, high-frequency VQ, transient modes and both LFE decimation factors. The output is 24-bit; the decoder can round it to 16 or 20 bits.
- XCh (the sixth, rear centre, full-bandwidth channel of DTS-ES), including the downmix the ES mastering flag says was added to the surround channels.
- XXCh (more channels, 7.1 and others, in DTS-HD High Resolution) with the downmix it undoes.
- X96 (the 96 kHz extension, DTS 96/24): the 64-band synthesis filter bank and the high-band data, so a 96 kHz stream is played at 96 kHz.
- XBR (extended bit rate): the residual subband data added to the core.
- XLL (the lossless layer of DTS-HD Master Audio), bit for bit: 16 and 24-bit samples up to 192 kHz and eight channels, with or without a core, with several channel sets, downmix chains, two frequency bands, peak bit rate smoothing and the loss of a frame concealed with the core. The output keeps the stream’s width (16 or 24 bits). How it is coded.
- A DTS-HD file’s STRMDATA chunk, a core with its extension substream in one packet, and a stream with only extension substreams that carry a core.
- Output as 1 to 8 channels in WAVE channel order, or mixed down to stereo or mono.
How it works
The decoder is a port of libdcadec, written to follow its arithmetic exactly: everything up to the filter bank is integer arithmetic with the same rounding and saturation, and the filter bank uses double-precision arithmetic in the same order, so its output is the library’s output sample for sample. For each frame it does the following.
- Reads the frame header and the audio coding header (clause 5.3), and the optional time stamp and auxiliary data; looks for the extension data by its sync word.
- For each subframe reads the side information (prediction modes, bit allocation, transient positions, scale factors, joint-intensity scale factors) and then the subband samples: Huffman codes, block codes or plain two’s-complement values for each subband and sample group, and 10-bit vector-quantised blocks for the high-frequency subbands.
- Scales each sample by its quantiser step and scale factor, adds the prediction of the four previous samples of the same subband where the header says so, and copies the joint-intensity subbands from their source channel.
- Adds the extensions: the sixth channel (XCh), more channels (XXCh), the residual of the core subbands (XBR) and the 32 upper subbands of a 96 kHz stream (X96).
- For Master Audio, decodes the lossless layer instead: it reads the channel sets, decodes the residuals, undoes the prediction and decorrelation, adds the integer decode of the core to the channels that are residuals, undoes the downmix chain, merges the frequency bands and clips to the storage width. The core is then filtered in integer arithmetic, which is what the residual was made against.
- Runs the 32-band (or 64-band, for X96) polyphase synthesis filter bank over each channel’s subband samples, interpolates the LFE channel from its decimated samples (64 or 128 times) with a polyphase filter, undoes the sum and difference coding and the embedded downmix, and clips to 24 bits.
The filter memory and the prediction history carry from frame to frame, so the sound is sequential: the viewer’s waveform keeps a copy of that state every few seconds to play and draw from any position without decoding from the start. For the lossless layer that state is the peak bit rate buffer, the downmix coefficients of the last frame and the core’s filters.
Tables
The tables are the ones of the standard’s annexes: the Huffman code books for the bit
allocation, scale factors, transient modes and every quantiser, the scale-factor and step-size
tables, the 4,096 prediction coefficient sets, the 1,024 vectors of the high-frequency VQ, the
joint-intensity scales, the downmix coefficients and the filter-bank and LFE coefficients (512,
512, 1,024, 256 and 256 values). They are in shared/audio/dts-tables.js (58,335
numbers), converted from the library’s C source by a script and checked by a second one that
compiles the C and compares every number.
Conformance
DTS has no public bit-exact test vectors, so the decoder is compared with libdcadec compiled from source, sample for sample, on real streams: the FFmpeg FATE suite (core, XCh, X96, XBR, XXCh, and the same combinations, in DTS-HD files), a DTS-ES stream, and streams made with FFmpeg’s encoder in every channel layout it offers (mono, stereo, 4.0, 5.0, 5.1), at 8, 11.025, 12, 16, 22.05, 24, 32, 44.1 and 48 kHz, with and without prediction. Every sample of every channel is identical, for the core alone and for the core with all its extensions. The same holds for the lossless layer: the nine Master Audio streams of the suite (5.1, 6.1 and 7.1, 48, 96 and 192 kHz, 16 and 24 bits, with and without a core, with up to three channel sets) decode to the library’s output sample for sample, and so do copies of them with the sync word, a header, the segment table or the substream header damaged, where the library’s lenient mode decides what is heard.
Not described
These pages follow the stream as the decoder reads it. The explorer decodes the core and the XCh, XXCh, X96, XBR and XLL extensions; the rest of DTS-HD is read and listed but not heard.
Known, not yet covered
- Viewer: the integrity check of the lossless layer (the CRC-16 checksums of the frame headers, channel set headers and segment size tables) reads only the first 500 extension substreams; the Integrity row says so, with the number of substreams, when a stream has more.
- Viewer: DTS Express (LBR) and DTS:X (UHD, ETSI TS 103 491) are not decoded; a stream with only those has no sound, and one with a core plays the core.
- Viewer: XLL streams that use replacement sets, a sampling frequency modifier, more than one primary channel set, channel sets of different widths or rates, or more than two frequency bands are refused (the core is played in their place). The channel to speaker mapping coefficients of a stream without a one-to-one mapping are read and not used. The optional checksums after the band data are not checked: no stream in the test suite has them.
- Viewer: a lossless stream has no checksum of its samples, so “verified” means that every header and segment table checksum passed, not that the samples were compared with the source.
- Viewer: the downmix to stereo and mono is a plain one (centre and surrounds at −3 dB, LFE left out, scaled so that nothing clips). The downmix coefficients embedded in the auxiliary data, the metadata that selects them, the dynamic range coefficients and the dialogue normalisation values are read as fields but not applied.
- Viewer: every audio asset of an extension substream is read and listed, but only the first is decoded (no stream with several assets was available to test the reading). Only one XXCh channel set is read.
- Viewer: the frame sizes of 14-bit streams follow libdcadec’s rule (whole words); a 14-bit stream is decoded when its frames are a whole number of such words, as the ones on DTS Audio CDs are.
- Reference: the layout of the three bytes that start the DTS-HD
AUPR-HDRchunk and of theNAVI,CORESSMDandEXTSS_MDchunks is not published in the sources used; they are shown as bytes.
Unknown
- Viewer: the extension substream header is shown field by field (sync word, size fields, static fields, asset sizes, each asset descriptor with its bit resolution, sample rate, channels, speaker masks and component sizes, the reserved bits and the CRC-16, which is checked). A few codes are shown as numbers because the sources used do not give their meaning: the frame duration codes other than 0, the mixing metadata adjustment level, the asset type descriptor, the representation type, the peak bit rate buffer size and the sync distances. The four low bits of the component mask (set in every sample, with no size after them), the reserved components, the auxiliary coding mode and the coefficient tables of the mixing metadata and speaker remapping are shown as labelled ranges (“Unparsed” or a count of bits), not decoded.
Also used for
- DTS-HD Master Audio – DTS-HD stream in a DTSHDHDR chunk container: core frames and extension substreams.
- DTS-HD audio – DTS-HD stream in a DTSHDHDR chunk container: core frames and extension substreams.
Links
Software
- VLC media player – free player for almost any audio or video file, including DTS and DTS-HD (Windows, macOS, Linux, mobile)
- FFmpeg – command-line tool that decodes DTS (core and extensions) and encodes the core (Windows, macOS, Linux)
Developers
Reference
- ETSI TS 102 114 – DTS Coherent Acoustics: core and extensions