[FFmpeg-devel] [PATCH] Estimate has_b_frames over try_decode_frame() / av_find_stream_info()

Michael Niedermayer michaelni
Sun Mar 1 04:23:57 CET 2009


Hi

patch below estimates h264 has_b_frames aka decoder delay by decoding
frames in av_find_stream_info()
I do not intent to apply this, the correct solution is to improve the
parser to estimate has_b_frames without decoding ...

Index: utils.c
===================================================================
--- utils.c	(revision 17672)
+++ utils.c	(working copy)
@@ -1844,6 +1844,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;
@@ -1881,7 +1887,7 @@
         return ret;
   }
 
-  if(!has_codec_parameters(st->codec)){
+  if(!has_codec_parameters(st->codec) || !has_decode_delay_been_guessed(st->codec)){
     switch(st->codec->codec_type) {
     case CODEC_TYPE_VIDEO:
         ret = avcodec_decode_video(st->codec, &picture,
@@ -2150,7 +2156,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

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- 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/20090301/5178a047/attachment.pgp>



More information about the ffmpeg-devel mailing list