Improved PCM support in MP4 Multiplexor

I’ve changed the uncompressed audio support in my MP4 Multiplexor filter at gdcl.co.uk/mpeg4 to provide better compatibility with Quicktime.

The MP4 format does not provide good support for uncompressed PCM audio. Quicktime stores PCM in MP4 files using an old format, dating from before the file format was modified to support compressed audio. My MP4 Demultiplexor has support for playback of these old index formats. With this update, I’ve added support for creating these types to the multiplexor.

In the normal MP4 index, blocks of audio are indexed. The sample size, sample duration and sample-to-chunk tables (stsz, stts, stsc) all contain one entry for each block of audio. For this case, the MP4 multiplexor creates one index entry for each IMediaSample object that arrives at the input.

For uncompressed audio, the unit of indexing is the audio sample. So for 16-bit stereo, the sample size is 4 bytes. The sample-to-chunk table (stsc) reports how many (4-byte) samples are in each chunk. The sample duration table (stts) reports the duration of each sample, but since the scale is always set to the sampling frequency, the duration is always 1. The sample size table (stsz), for some unexplained reason, reports the size of each sample as a count of samples (huh?), so every entry is 1.

There are a few other changes when PCM audio is stored and the old index format is used:

15th February 2013