changeset 6227:78ee17447ff3 libavformat

In av_find_stream_info, decode at least 4 h.264 frames to be able to guess delay.
author bcoudurier
date Sat, 03 Jul 2010 03:07:33 +0000
parents 7b81ef3e7d99
children 322e7096671d
files utils.c
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/utils.c	Fri Jul 02 23:39:02 2010 +0000
+++ b/utils.c	Sat Jul 03 03:07:33 2010 +0000
@@ -2019,6 +2019,12 @@
     return enc->codec_id != CODEC_ID_NONE && val != 0;
 }
 
+static int has_decode_delay_been_guessed(AVStream *st)
+{
+    return st->codec->codec_id != CODEC_ID_H264 ||
+        st->codec_info_nb_frames >= 4 + st->codec->has_b_frames;
+}
+
 static int try_decode_frame(AVStream *st, AVPacket *avpkt)
 {
     int16_t *samples;
@@ -2035,7 +2041,7 @@
             return ret;
     }
 
-    if(!has_codec_parameters(st->codec)){
+    if(!has_codec_parameters(st->codec) || !has_decode_delay_been_guessed(st)){
         switch(st->codec->codec_type) {
         case AVMEDIA_TYPE_VIDEO:
             avcodec_get_frame_defaults(&picture);
@@ -2317,7 +2323,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))
             try_decode_frame(st, pkt);
 
         count++;