diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-07-29 22:58:17 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-07-29 23:04:49 +0200 |
commit | 7c26761b8121ed362870b2e0eb06b85431bdd7a2 (patch) | |
tree | 5e8bc55238ce090b34e5e8cd7777fc4dd5e7fb76 /libavformat/utils.c | |
parent | 72dabdfc58064fcb249f26fc7afca2221f18a832 (diff) | |
parent | fe1c1198e670242f3cf9e3e1eef27cff77f3ee23 (diff) | |
download | ffmpeg-7c26761b8121ed362870b2e0eb06b85431bdd7a2.tar.gz |
Merge commit 'fe1c1198e670242f3cf9e3e1eef27cff77f3ee23'
* commit 'fe1c1198e670242f3cf9e3e1eef27cff77f3ee23':
lavf: use dts difference instead of AVPacket.duration in find_stream_info()
avf: introduce nobuffer option
fate: make yadif tests consistent across systems
vf_hqdn3d: support 9 and 10bit colordepth
vf_hqdn3d: reduce intermediate precision
vf_hqdn3d: simplify and optimize
factor identical ff_inplace_start_frame out of two filters
vf_hqdn3d: cosmetics
avprobe/avconv: fix tentative declaration compile errors on MSVS.
Conflicts:
doc/APIchanges
ffmpeg.c
ffprobe.c
libavformat/avformat.h
libavformat/options_table.h
libavformat/utils.c
libavformat/version.h
tests/fate/filter.mak
tests/ref/fate/filter-yadif-mode0
tests/ref/fate/filter-yadif-mode1
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index eda5e28721..d1e6459def 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2557,6 +2557,8 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) for (i=0; i<ic->nb_streams; i++) { ic->streams[i]->info->last_dts = AV_NOPTS_VALUE; + ic->streams[i]->info->fps_first_dts = AV_NOPTS_VALUE; + ic->streams[i]->info->fps_last_dts = AV_NOPTS_VALUE; } count = 0; @@ -2630,13 +2632,37 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) break; } - pkt= add_to_pktbuf(&ic->packet_buffer, &pkt1, &ic->packet_buffer_end); - if ((ret = av_dup_packet(pkt)) < 0) - goto find_stream_info_err; + if (ic->flags & AVFMT_FLAG_NOBUFFER) { + pkt = &pkt1; + } else { + pkt = add_to_pktbuf(&ic->packet_buffer, &pkt1, + &ic->packet_buffer_end); + if ((ret = av_dup_packet(pkt)) < 0) + goto find_stream_info_err; + } read_size += pkt->size; st = ic->streams[pkt->stream_index]; + if (pkt->dts != AV_NOPTS_VALUE && st->codec_info_nb_frames > 1) { + /* check for non-increasing dts */ + if (st->info->fps_last_dts != AV_NOPTS_VALUE && + st->info->fps_last_dts >= pkt->dts) { + av_log(ic, AV_LOG_DEBUG, "Non-increasing DTS in stream %d: " + "packet %d with DTS %"PRId64", packet %d with DTS " + "%"PRId64"\n", st->index, st->info->fps_last_dts_idx, + st->info->fps_last_dts, st->codec_info_nb_frames, pkt->dts); + st->info->fps_first_dts = st->info->fps_last_dts = AV_NOPTS_VALUE; + } + + /* update stored dts values */ + if (st->info->fps_first_dts == AV_NOPTS_VALUE) { + st->info->fps_first_dts = pkt->dts; + st->info->fps_first_dts_idx = st->codec_info_nb_frames; + } + st->info->fps_last_dts = pkt->dts; + st->info->fps_last_dts_idx = st->codec_info_nb_frames; + } if (st->codec_info_nb_frames>1) { int64_t t=0; if (st->time_base.den > 0) @@ -2756,10 +2782,12 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) st->codec->codec_tag= tag; } - if (st->codec_info_nb_frames>2 && !st->avg_frame_rate.num && st->info->codec_info_duration) + /* estimate average framerate if not set by demuxer */ + if (st->codec_info_nb_frames>2 && !st->avg_frame_rate.num && st->info->codec_info_duration) { av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den, (st->codec_info_nb_frames-2)*(int64_t)st->time_base.den, st->info->codec_info_duration*(int64_t)st->time_base.num, 60000); + } // the check for tb_unreliable() is not completely correct, since this is not about handling // a unreliable/inexact time base, but a time base that is finer than necessary, as e.g. // ipmovie.c produces. |