summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-07-29 22:58:17 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-07-29 23:04:49 +0200
commit7c26761b8121ed362870b2e0eb06b85431bdd7a2 (patch)
tree5e8bc55238ce090b34e5e8cd7777fc4dd5e7fb76 /libavformat
parent72dabdfc58064fcb249f26fc7afca2221f18a832 (diff)
parentfe1c1198e670242f3cf9e3e1eef27cff77f3ee23 (diff)
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')
-rw-r--r--libavformat/avformat.h10
-rw-r--r--libavformat/options_table.h1
-rw-r--r--libavformat/utils.c36
-rw-r--r--libavformat/version.h2
4 files changed, 44 insertions, 5 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index e54e8a191d..19a11fc627 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -741,6 +741,15 @@ typedef struct AVStream {
int64_t codec_info_duration;
int nb_decoded_frames;
int found_decoder;
+
+ /**
+ * Those are used for average framerate estimation.
+ */
+ int64_t fps_first_dts;
+ int fps_first_dts_idx;
+ int64_t fps_last_dts;
+ int fps_last_dts_idx;
+
} *info;
int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
@@ -948,6 +957,7 @@ typedef struct AVFormatContext {
#define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS
#define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container
#define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled
+#define AVFMT_FLAG_NOBUFFER 0x0040 ///< Do not buffer frames when possible
#define AVFMT_FLAG_CUSTOM_IO 0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it.
#define AVFMT_FLAG_DISCARD_CORRUPT 0x0100 ///< Discard frames marked corrupted
#define AVFMT_FLAG_MP4A_LATM 0x8000 ///< Enable RTP MP4A-LATM payload
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index fddf1a3cb1..9bc0329c00 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -47,6 +47,7 @@ static const AVOption options[]={
{"sortdts", "try to interleave outputted packets by dts", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_SORT_DTS }, INT_MIN, INT_MAX, D, "fflags"},
{"keepside", "dont merge side data", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_KEEP_SIDE_DATA }, INT_MIN, INT_MAX, D, "fflags"},
{"latm", "enable RTP MP4A-LATM payload", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_MP4A_LATM }, INT_MIN, INT_MAX, E, "fflags"},
+{"nobuffer", "reduce the latency introduced by optional buffering", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOBUFFER }, 0, INT_MAX, D, "fflags"},
{"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT, {.dbl = 5*AV_TIME_BASE }, 0, INT_MAX, D},
{"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 0, 0, D},
{"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), AV_OPT_TYPE_INT, {.dbl = 1<<20 }, 0, INT_MAX, D},
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.
diff --git a/libavformat/version.h b/libavformat/version.h
index 4e4b0f67ab..d7841f743c 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,7 +30,7 @@
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 54
-#define LIBAVFORMAT_VERSION_MINOR 21
+#define LIBAVFORMAT_VERSION_MINOR 22
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \