[FFmpeg-devel] [PATCH] Enable PAFF decoding

Neil Brown neilb
Thu Oct 11 02:43:55 CEST 2007


On Wednesday October 10, heydowns at borg.com wrote:
> On Wed, 10 Oct 2007, Neil Brown wrote:
> [...]
> > 3 issues:
> > 
> > 1/ The first few frames are in the wrong order.
> > 
> > The first 3 field-pairs in my files are:
> >   I+P  (poc 0 and 1)
> >   B+B  (poc -4 and -3)
> >   B+B  (poc -2 and -1)
> > 
> > I'm getting the first pair out first, then the second decodes
> > imperfectly.  I haven't figured out why yet.  The same thing doesn't
> > happen when you cross an IDR frame, so there must be something
> > "special" about the very start.
> 
> Do your files start with IDR?
> 

Yes.
 ./ffplay -debug 256 00002.mts 2> /tmp/trace

Yields

FFplay version SVN-r10700, Copyright (c) 2003-2007 Fabrice Bellard, et al.
  configuration: --enable-gpl
  libavutil version: 49.5.0
  libavcodec version: 51.45.0
  libavformat version: 51.14.0
  built on Oct 10 2007 17:03:09, gcc: 4.2.1 (Debian 4.2.1-6)
[h264 @ 0xa638a0]NAL 9 at 4/69 length 1
[h264 @ 0xa638a0]NAL 7 at 10/69 length 50
[h264 @ 0xa638a0]NAL 8 at 65/69 length 3
[h264 @ 0xa638a0]NAL 9 at 4/126719 length 1
[h264 @ 0xa638a0]NAL 7 at 10/126719 length 50
[h264 @ 0xa638a0]NAL 8 at 65/126719 length 3
[h264 @ 0xa638a0]NAL 6 at 73/126719 length 16
[h264 @ 0xa638a0]NAL 6 at 94/126719 length 104
[h264 @ 0xa638a0]NAL 6 at 210/126719 length 25
[h264 @ 0xa638a0]NAL 6 at 240/126719 length 12
[h264 @ 0xa638a0]NAL 6 at 258/126719 length 4
[h264 @ 0xa638a0]NAL 5 at 267/126719 length 126451
[h264 @ 0xa638a0]NAL 9 at 4/69 length 1
[h264 @ 0xa638a0]NAL 7 at 10/69 length 50
[h264 @ 0xa638a0]NAL 8 at 65/69 length 3
[h264 @ 0xa638a0]NAL 9 at 4/71692 length 1
[h264 @ 0xa638a0]NAL 8 at 10/71692 length 3
[h264 @ 0xa638a0]NAL 6 at 18/71692 length 12
[h264 @ 0xa638a0]NAL 1 at 36/71692 length 71655
....

The "NAL 5" is - I believe - the first field and is IDR.

I looked a bit more deeply, and seems that the first decoded frame is
being output twice.  It is output as the first presented frame, and
then again at the proper place in the presentation order (though now
everything is offset by one frame).  Looking at the code in
decode_frame, the first frame will always be output, which is clearly
wrong.  But it's not clear to me how best to fix it.  Maybe this?

It still leaves the first (presented) frame badly decoded though.
There is a "double-vision" effect, as though the second field is being
decoded with reference to the first (decoded) frame instead of the
first field in the same frame.... does that make sense?

NeilBrown

Index: libavcodec/h264.c
===================================================================
--- libavcodec/h264.c	(revision 10700)
+++ libavcodec/h264.c	(working copy)
@@ -7818,6 +7818,9 @@
                     h->delayed_pic[i] = h->delayed_pic[i+1];
             }
 
+	    if (prev == NULL && pics <= h->sps.num_reorder_frames)
+		prev = out;
+
             if(prev == out)
                 *data_size = 0;
             else




More information about the ffmpeg-devel mailing list