aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-08-12 13:43:03 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-08-12 13:43:03 +0200
commitd0bf3bf1ffaf810d8e0737847666a9b86ea5929f (patch)
treebc4e81051e590e5d33b401b6488ce381a37c6151 /libavformat/utils.c
parent6fd7bf7b03c068d0f91de03bdd9b4e91695680eb (diff)
parentbdefe22b8e8c5c1cbcb20595b8eedc052aa8e6e9 (diff)
downloadffmpeg-d0bf3bf1ffaf810d8e0737847666a9b86ea5929f.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: lavf: Detect discontinuities in timestamps for framerate/analyzeduration calculation lavf: Initialize the stream info timestamps in avformat_new_stream id3v2: Match PIC mimetype/format case-insensitively configure: Rename check_asm() to more fitting check_inline_asm() fate: Only test enabled filters avresample: De-doxygenize some comments where Doxygen is not appropriate rtmp: split chunk_size var into in_chunk_size and out_chunk_size rtmp: Factorize the code by adding find_tracked_method Conflicts: configure Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 454271700f..55826bea53 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2657,6 +2657,19 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
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;
}
+ /* check for a discontinuity in dts - if the difference in dts
+ * is more than 1000 times the average packet duration in the sequence,
+ * we treat it as a discontinuity */
+ if (st->info->fps_last_dts != AV_NOPTS_VALUE &&
+ st->info->fps_last_dts_idx > st->info->fps_first_dts_idx &&
+ (pkt->dts - st->info->fps_last_dts) / 1000 >
+ (st->info->fps_last_dts - st->info->fps_first_dts) / (st->info->fps_last_dts_idx - st->info->fps_first_dts_idx)) {
+ av_log(ic, AV_LOG_WARNING, "DTS discontinuity 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) {
@@ -3103,6 +3116,12 @@ AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c)
st->sample_aspect_ratio = (AVRational){0,1};
+#if FF_API_R_FRAME_RATE
+ st->info->last_dts = AV_NOPTS_VALUE;
+#endif
+ st->info->fps_first_dts = AV_NOPTS_VALUE;
+ st->info->fps_last_dts = AV_NOPTS_VALUE;
+
s->streams[s->nb_streams++] = st;
return st;
}