Program End Code in Multiplexed VOB Streams

This article examines the function of the Program End Code (PEC) within multiplexed DVD Video Object (VOB) streams. It details what the code represents at the binary level, its role in signaling stream termination to demultiplexers, how it facilitates decoder buffer flushing, and its importance in maintaining seamless transitions between consecutive media segments without causing playback errors or system freezes.

What Is the Program End Code?

The Program End Code (PEC) is a standardized 32-bit start code specified in the MPEG-2 systems standard (ISO/IEC 13818-1). Represented in hexadecimal as 0x000001B9, this marker is placed at the very end of an MPEG-2 Program Stream, which serves as the underlying format for DVD VOB files. In a multiplexed VOB stream containing interleaved video, audio, sub-picture, and navigation packets, the PEC acts as the definitive end-of-file boundary for the stream parser.

Core Functions of the Program End Code

1. Explicit Stream Termination

Multiplexed streams consist of packs and packets that do not inherently contain global duration metadata readable at the packet layer. When a multiplexer closes a VOB stream, it appends the PEC to explicitly inform the demultiplexer that no further packs follow. This prevents the parser from waiting indefinitely for subsequent data chunks or reading past the intended stream boundary into trailing null padding or unallocated sectors.

2. Decoder Buffer Flushing

MPEG-2 playback relies on discrete elementary stream buffers for video (Video Buffering Verifier, or VBV) and audio. Decoders buffer data to account for decoding delays and packet jitter. When the parser encounters the Program End Code:

3. System Time Clock (STC) and Synchronization Reset

VOB files rely on System Clock References (SCR) and Presentation Time Stamps (PTS) to maintain lip-sync and pacing. The presence of a Program End Code notifies the playback engine that the continuous time base for that specific program stream has finished. This enables the DVD player’s system parser to reset the internal System Time Clock (STC) or prepare for a time base discontinuity before initializing the next cell, program chain (PGC), or VOB unit (VOBU).

4. Prevention of Decoder Hangs

Without a clean termination marker, software parsers and standalone DVD player chipsets may interpret the abrupt end of data as a transmission error, packet drop, or stream corruption. The PEC provides a deterministic end state, preventing the playback hardware from hanging, throwing read timeout errors, or improperly releasing memory allocated to the stream demultiplexer.