|The decoder should include following features:
- It can decode MPEG2 video elementary bit-stream, up to main profile at main level;
- In order to test MPEG2 bitstream in DVD content, the decoder would be able to parse MPEG2 system bit-stream (like VOB data in DVD), and extract video data and decode it;
- The MPEG2 bit-stream data can be from a file, or from network. To handle both the both cases and be more general, the MPEG2 decoder should be able to accept MPEG2 bit-stream stored in a buffer, which will be passed to the decoder. The file reading part should be handled in application level, and the buffer should be big enough to hold bitstream for at least one frame.
- The decoded image will be sent back to the caller in YUV raw format after every frame is decoded. It is up to the caller (application) to decide how to handle the decoded image, whether to display, to store to a file, or to trans-code to other format.
- For most cases, the MPEG2 bitstream data are very big, we cannot read in all the data into a buffer (the memory) before decode. A shared buffer between application (who keeps reading data from file and put into the buffer) and MPEG2 decoder (who continuously consumes the data inside the buffer) should be established.
- One MPEG2 sequence contains many GOP (Group of pictures), and one GOP contains many frames (I-frame, P-frame and B-frames). However, in most cases, we do not know the boundary inside the bitstream. In other word, given certain length of bit-stream data, we do not know how many frames it contains, (unless we go through to parse the frame start header, which need two pass process). This means putting data into the shared buffer from application, and data consuming from decoder are “synchronized”. Some time, after application put in certain data, decoder takes long time (many frames) to consume, while sometimes, application may need to put in data after decoder decode every frame.
- A ring buffer structure can be used as the shared buffer. The buffer will be filled up by the application, before calling the decoder for the first time. Then, every time before calling decoding next frame, check how many data left in the buffer, if the buffer is half empty, start to fill in new data.
Download the package: mpeg2dec.zip
Package includes: MPEG2 decoder filter library, demo program source code with project files (for Windows) and make file (for Linux), example MPEG2 video clip and test script batch file.