The MP4 Multiplexor filter at gdcl.co.uk/mpeg4 has been updated with support for the XVID mpeg-4 video encoder.
The multiplexor filter queues samples at its inputs so that the interleaving can be managed correctly. This requires an allocator at each input that provides a significant number of samples. If the allocator chosen by the source pin does not provide enough buffers, the multiplexor creates a private allocator and copies all buffers to this allocator on Receive.
For this private allocator, older versions of the filter used a pool of fixed size buffers, where the size was determined by the cbSize field reported by the source pin’s allocator. The XVID mpeg-4 video encoder reports an output buffer size of 12MB. When the multiplexor tried to allocate a large number of 12MB buffers, it would often fail to allocate the memory, and this error was compounded by an error-handling bug that resulted in a silent failure to capture any video.
In any case, the fixed-size buffer pool is inefficient with compressed video, where each frame is in a separate buffer but the size of each frame varies considerably. I’ve implemented a new allocator that uses a single pool of memory, with IMediaSample objects created dynamically, and locked ranges used to manage the refcounts. As well as fixing this particular problem, this new allocator will be a useful sample class for those wishing to use variable length buffers in DirectShow filters.
9th January 2012