Demuxing PCM and AC-3 Streams in VOB 0xBD
Inside a DVD Video Object (VOB) file, both Linear PCM (LPCM) and AC-3
(Dolby Digital) audio tracks share the MPEG-2
private_stream_1 identifier (0xBD). A software
demuxer distinguishes between these formats by inspecting the
DVD-specific sub-stream ID byte located at the very start of the
Packetized Elementary Stream (PES) payload, and further validates the
audio data using the format-specific header fields and external IFO
container metadata.
The Role of Stream ID 0xBD in MPEG-2 Program Streams
Standard MPEG-2 Program Stream specifications reserve stream IDs
0xC0 through 0xDF for native MPEG audio.
Because AC-3, DTS, and raw PCM are not native MPEG-1 or MPEG-2 audio
types, the DVD-Video standard encapsulates them inside the generic
private stream ID 0xBD (private_stream_1).
Since multiple tracks (such as different languages, audio formats, or sub-picture subtitles) can share this single stream ID, the DVD specification implements a secondary multiplexing layer directly within the PES packet payload.
Sub-Stream ID Identification
When a demuxer encounters a PES packet with stream ID
0xBD, it skips the standard MPEG PES header to read the
first byte of the PES packet payload. This byte is the
sub-stream ID, which identifies both the format and the
track index:
- AC-3 Audio: Sub-stream IDs range from
0x80to0x87(representing up to 8 distinct AC-3 audio streams, tracks 0 through 7). - DTS Audio: Sub-stream IDs range from
0x88to0x8F. - Linear PCM (LPCM): Sub-stream IDs range from
0xA0to0xA7(representing up to 8 distinct LPCM audio streams, tracks 0 through 7). - Sub-pictures: Sub-stream IDs range from
0x20to0x3F(up to 32 subtitle streams).
If the first byte falls between 0x80 and
0x87, the demuxer routes the payload to an AC-3 decoder or
file writer. If it falls between 0xA0 and
0xA7, the demuxer treats it as LPCM.
Payload Header Validation
After identifying the sub-stream ID byte, the demuxer examines the subsequent DVD audio header bytes to parse framing details. These bytes differ significantly between AC-3 and PCM:
AC-3 PES Payload Header
For an AC-3 stream, the 1-byte sub-stream ID is followed by a 3-byte DVD audio header:
- Byte 0: Sub-stream ID
(
0x80–0x87). - Byte 1: Number of frame headers located in this packet.
- Bytes 2–3: A 16-bit offset pointing to the start of the first access unit (the first complete AC-3 frame).
Immediately following this offset, the raw AC-3 syncword
(0x0B77) appears, allowing the demuxer to verify sync and
parse the audio frame.
LPCM PES Payload Header
For an LPCM stream, the 1-byte sub-stream ID is followed by a 6-byte DVD LPCM audio header:
- Byte 0: Sub-stream ID
(
0xA0–0xA7). - Byte 1: Number of frames.
- Bytes 2–3: First access unit pointer (offset to the first PCM audio sample block).
- Byte 4: Emphasis flag, mute flag, and frame number.
- Byte 5: Quantization word length (16, 20, or 24-bit) and audio sampling frequency (48 kHz or 96 kHz).
- Byte 6: Channel configuration and number of audio channels (e.g., mono, stereo, 5.1).
The demuxer uses these configuration flags in byte 5 and byte 6 to construct the appropriate PCM output headers (such as a standard WAV header) when demuxing raw audio samples.
Cross-Referencing IFO Metadata
While standalone VOB demuxers rely entirely on the sub-stream byte
and payload headers, complete DVD demuxing software typically queries
the associated Video Title Set Information file
(VTS_XX_0.IFO) before parsing the VOB directly.
The VTS_VOB_ATTR table inside the IFO file explicitly
maps each audio stream number to its coding standard (AC-3, LPCM, DTS,
or MPEG), sample rate, language code, and channel layout. By reading
this table first, the demuxer establishes which sub-stream IDs to expect
within 0xBD packets throughout the corresponding
VTS_XX_X.VOB files.