[FFmpeg-devel] [PATCH] Fix return value for incomplete H264 frame packets

Laurent Aimar fenrir
Mon Aug 23 20:05:56 CEST 2010


On Mon, Aug 23, 2010 at 06:50:38PM +0200, Reimar D?ffinger wrote:
> On Mon, Aug 23, 2010 at 04:51:09PM +0200, Laurent Aimar wrote:
> > > Laurent Aimar:
> > > >  Unless I misunderstood the current code, avcodec will consume the first
> > > > field, properly decode it and return no pictures and no errors. If so, it
> > > > seems the right behavior to me.
> > > 
> > > You understood it correctly. The question is if it should be a task of the
> > > decoder to call for more data.
> >  The current code already does it. It consumes all bytes and return no pictures.
> > Obviously, more data are needed to have a frame ready.
> 
> Not really, it could be e.g. due to decoder delay.
 well, receiving a field is the same kind of issue: you need the following
pictures to output a frame.

> I suggested to make it return an error, because for the
> FFmpeg API passing such an incomplete frame to the decoder
> actually is an error.
 Well, the h264 standard defines an access unit as a picture, being a
frame or a field. So, IMHO, returning an error would be the wrong move,
forcing to 'merge' fields into frames before giving them to avcodec for
.mp4 or .mkv for example.

 Besides, h264 allows a greater flexibility to the way fields are ordered, and
so merging fields into frames is not always possibles. For examples, you can do:

top    I0 P2 P4 | I0 B2 B4
bottom B1 B3 P5 | B1 B3 P5

which gives in coding order:
I0 P2 B1 P4 B3 P5 | I0 P5 B1 B2 B3 B4

-- 
fenrir




More information about the ffmpeg-devel mailing list