[FFmpeg-devel] [PATCH] H.264 SEI handling vs. frame boundries

John Cox jc
Mon Mar 16 18:07:43 CET 2009


OK - here's the (one-line) patch.

Test files:




In order to test you need to have an output yuv file generator that repeats
fields as requested by the repeat_pict field on output and compare with the
base longer yuv file (not the *-norpt.yuv).  I haven't found an ffmpeg switch
for this yet.

In combination with my previous num_reorder_frames patch this leaves the only
failing conformance stream (in my stash of them) as:


I haven't investigated yet - but the output file is the right length so its not
a simple frame drop.

John Cox

>On Mon, Mar 16, 2009 at 02:57:53PM +0000, John Cox wrote:
>> Hi
>> I think there is a problem with the way SEIs in H.264 are handled when
>> splitting the input into frames.  At the moment the frame breaker in
>> h264_parser.c seems to split on a new SPS, PPS or AU delimiter.  This means
>> that if an AU goes <SEI><PPS><coded slice data> the SEI turns up in the
>> previous 'frame'. The particular case where this is a problem is where the SEI
>> contains pic_struct.  In this case the pic struct gets applied to the frame
>> before the one it is meant to be applied to s.t. the repeat_pict count is
>> attached to the wrong frame.  Changing the 
>>             if(v==7 || v==8 || v==9){
>> in h264_parser.c:ff_h264_find_frame_end to 
>>             if(v==6 || v==7 || v==8 || v==9){
>> fixes the problem - but I'm assuming there is some reason why it wasn't written
>> this way?
>hmm i suspect your suggested change is correct, can you send a patch?
>also a file to test this is welcome to verify that it does fix a bug
-------------- next part --------------
Index: h264_parser.c
--- h264_parser.c	(revision 17946)
+++ h264_parser.c	(working copy)
@@ -70,7 +70,7 @@
             else            state>>=1; //2->1, 1->0, 0->0
         }else if(state<=5){
             int v= buf[i] & 0x1F;
-            if(v==7 || v==8 || v==9){
+            if(v==6 || v==7 || v==8 || v==9){
                     goto found;

More information about the ffmpeg-devel mailing list