[FFmpeg-devel] Two problems with MPEG2 decoder

Joseph Artsimovich joseph at mirriad.com
Tue Feb 26 15:16:34 CET 2013


I uploaded a sample here: http://rghost.net/44123751
It's XDCAM HD 422 (a variant of MPEG2) in a .mov container. It was cut 
from a larger file we received from a client. I don't know which 
software generated it (the vendor fourcc in the original is filled with 
zeros), but it's something from broadcasting environment.

The file plays fine in Apple's QuickTime player using a demo version of 
CalibratedQ XD Decode plugin.
FFMpeg on the other hand has 2 issues with it:

1. Artifacts in the bottom area and errors on the console:
[mpeg2video @ 0x1e55140] end mismatch left=299 60E2
[mpeg2video @ 0x1e55140] Warning MVs not available
I can get rid of both artifacts and errors if I force the value of 
is_d10 variable to 1 in mpeg_decode_slice() in mpeg12.c
That's obviously a hack, as this format is not D10.

2. One of the frames fails to decode.
The frame in question is frame 16 (counting from 0, ignoring the edit 
list and 2 initial B-frames that can't be decoded as the stream is open 
If you use ffmpeg to convert the file to another format:
ffmpeg -i segment.mov -an -vcodec qtrle out.mov
You'll get a duplicated frame in positions 16 and 17.
Now, it turns out the frame that fails to decode has a redundant (and 
probably invalid) second picture header in MPEG2 stream. That is, the 
frame is encoded as a single picture, yet it has 2 picture headers. If I 
modify the code to ignore the second picture header, like this:
         case PICTURE_START_CODE:
+            if (picture_start_code_seen) {
+               break;
+            } else {
+               picture_start_code_seen = 1;
+            }
[in decode_chunks() in mpeg12.c; variable initialization not shown]
Then the frame in question decodes fine.
The code above is again just a hack, as a frame can be encoded with more 
than one pictures.

I hope someone can figure out the proper solutions to these 2 problems.

Joseph Artsimovich
Senior C++ Applications Developer
MirriAd Ltd

More information about the ffmpeg-devel mailing list