MPEG file format

a brief discussion

The MPEG file format is described here as long it is necessary to understand the Java implementation problems.

Ordinarily file formats are described in form of offsets. In TARGA image file format for instance the image width is placed at offset 13 and 14. In MPEG such kind of description is impossible because:
  • the information fields are counted in bits instead of bytes;
  • the existence and structure of many information fields depends on information field values before;
  • most of the information is given by variable length codes (VLC)

The DCT coefficients for instance are coded according to the table to right(extract). Where level is the DCT value an run defines how many DCT coefficients before are zero. The whole table has 112 entries.

So the MPEG standard ISO 11172 describes the MPEG file format by means of a C-like language.

code (in bits)runlevel
1101
01111
0100 02
0101 21
0010103
0011131
0011041
00011012
00011151
00010161
.................
0000000000011111271
0000000000011110281
0000000000011101291
0000000000011100301
0000000000011011311

Another important aspect is that the DC coefficients are coded as differences to the DC coefficient in last block because one can assume the average brightness to be similar for neighbouring blocks. Because of the VLC the small differences are coded by less bits than the greater absolute values.

MPEG layering


In the past most of MPEG files were MPEG video files according to ISO/IEC 11172-2. But in the last months more and more layer I MPEG files appear. This particularly because most hardware MPEG encoders produce layer I/II MPEG files which often contain video and audio data according to ISO/IEC 11172-1.

The file structure is as follows:

MPEG1_layer.png

The file consists of so called "packs" which contain "packets". The packet data are video or audio data. A Layer I MPEG stream can have up to 16 video channels and up to 32 audio channels. If you concat the packet data of one video channel byte by byte you'll get an MPEG video file according to ISO/IEC 11172-2.

This is exactly what the current MPEG decoder does. It can only deal with one video channel. The audio channels are simply skipped.


upBack to Java-inline-MPEG-Player