aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2010-07-03 03:07:33 +0000
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2010-07-03 03:07:33 +0000
commitae447836af5cc66031e48a2df13713365cd3be7c (patch)
treeb68b8b736b8422cb509525d97473a075e7295908
parentb06855f18a79d45b5ca212be89d84df3ee130cf7 (diff)
downloadffmpeg-ae447836af5cc66031e48a2df13713365cd3be7c.tar.gz
In av_find_stream_info, decode at least 4 h.264 frames to be able to guess delay.
Originally committed as revision 24014 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavformat/utils.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 97085dd402..050429118d 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2019,6 +2019,12 @@ static int has_codec_parameters(AVCodecContext *enc)
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 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt)
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 @@ int av_find_stream_info(AVFormatContext *ic)
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++;