[FFmpeg-devel] [PATCH] decode at least 4 H.264 frames in av_find_stream_info

Michael Niedermayer michaelni
Sun Jun 27 04:43:56 CEST 2010


On Sun, Jun 27, 2010 at 04:31:41AM +0200, Michael Niedermayer wrote:
> On Thu, Jun 24, 2010 at 05:44:20PM -0700, Baptiste Coudurier wrote:
> > Hi guys,
> >
> > $subject.
> >
> > This will permit the decoder to compute has_b_frames correctly when 
> > b-pyramid is present. 4 is typically the minimum needed, though maybe we 
> > should decode more based on has_b_frames. Any opinion ?
> 
> Finally found an old patch by myself doing this
> I think its a bit more readable
> if it works feel free to apply mine (assuming that thing still applies and
> works)

ehm, the patch:

Index: libavformat/utils.c
===================================================================
--- libavformat/utils.c	(revision 18646)
+++ libavformat/utils.c	(working copy)
@@ -1820,6 +1820,12 @@
 #endif
 }
 
+/*we need to find has_b_frames approximatly, the parser is not yet able to do it*/
+static int has_decode_delay_been_guessed(AVCodecContext *enc)
+{
+    return enc->codec_id != CODEC_ID_H264 || enc->frame_number >= 4 + enc->has_b_frames;
+}
+
 static int has_codec_parameters(AVCodecContext *enc)
 {
     int val;
@@ -2130,7 +2136,7 @@
            decompress the frame. We try to avoid that in most cases as
            it takes longer and uses more memory. For MPEG-4, we need to
            decompress for QuickTime. */
-        if (!has_codec_parameters(st->codec) /*&&
+        if (!has_codec_parameters(st->codec) || !has_decode_delay_been_guessed(st->codec) /*&&
             (st->codec->codec_id == CODEC_ID_FLV1 ||
              st->codec->codec_id == CODEC_ID_H264 ||
              st->codec->codec_id == CODEC_ID_H263 ||

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.
-------------- 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/20100627/041370c8/attachment.pgp>



More information about the ffmpeg-devel mailing list