[FFmpeg-devel] [PATCH] ffmpeg.c: keep small last frame size

Michael Niedermayer michaelni
Sat Jul 19 17:27:17 CEST 2008

On Sat, Jul 19, 2008 at 11:18:14AM -0400, Justin Ruggles wrote:
> Michael Niedermayer wrote:
> > On Sat, Jul 19, 2008 at 10:08:22AM -0400, Justin Ruggles wrote:
> >> Hi,
> >>
> >> I noticed what I think is an error in a patch I submitted 2 years ago.
> >> When the audio codec has CODEC_CAP_SMALL_LAST_FRAME, the original frame
> >> size is being restored after the final encode.  I don't think this is
> >> right, and would likely mess up the calculation of the final packet
> >> duration.
> > 
> > encoder -> packet fifo -> muxer
> > 
> > 1. encoder encodes last frame (#100)
> > 2. muxer takes frame #59 of the fifo and uses frame_size for something
> > 
> > no, i do not think your patch is correct
> Oh, I see. I didn't consider the packet buffering...
> So would a correct fix would be to set the packet duration at the
> user-level for the final small packet since the generic audio duration
> calculation assumes a fixed frame size?  Or does it not matter that the
> packet duration is wrong?

The first step to correctness is to never set frame_size to more than a
single value in the lifetime of a codec instance. The current code is
not thread safe at all ...

The second step is to make encoders output AVPackets, that way they can
trivially not only specify timestamps and keyframe flags (no more
context->coded_frame->keyframe tricks ..) but also AVPacke.duration
nice, simple, direct and thread safe as it is exactly the AVPackets
that would be in the FIFO ...


Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080719/d2fe6735/attachment.pgp>

More information about the ffmpeg-devel mailing list