summaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-11-07 22:59:00 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-11-07 23:09:30 +0100
commit66e49ff3b923c6feee8e6e3d73ae3c76708aa5f2 (patch)
tree5bb39ad7b744235495831856d4c1d5aa4635c3d0 /libavformat
parented736890d6a71606e1833a9707da52322f4e046e (diff)
parent1384df641994bf3d6cb51084290aa94752737bae (diff)
downloadffmpeg-streaming-66e49ff3b923c6feee8e6e3d73ae3c76708aa5f2.zip
ffmpeg-streaming-66e49ff3b923c6feee8e6e3d73ae3c76708aa5f2.tar.gz
Merge commit '1384df641994bf3d6cb51084290aa94752737bae'
* commit '1384df641994bf3d6cb51084290aa94752737bae': lavf: Add an option for avoiding negative timestamps Conflicts: libavformat/avformat.h libavformat/mux.c libavformat/options_table.h libavformat/version.h See: 3ba0dab76ac32f0c9f50c916a73bc64e43c1fdf9 See: a89c01253190b9eb9de8e28a3252423bf7732511 Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/avformat.h23
-rw-r--r--libavformat/mux.c6
-rw-r--r--libavformat/options_table.h10
-rw-r--r--libavformat/version.h2
4 files changed, 22 insertions, 19 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index f21a1d6..3733549 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1475,6 +1475,18 @@ typedef struct AVFormatContext {
*/
int max_ts_probe;
+ /**
+ * Avoid negative timestamps during muxing.
+ * Any value of the AVFMT_AVOID_NEG_TS_* constants.
+ * Note, this only works when using av_interleaved_write_frame. (interleave_packet_per_dts is in use)
+ * - muxing: Set by user
+ * - demuxing: unused
+ */
+ int avoid_negative_ts;
+#define AVFMT_AVOID_NEG_TS_AUTO -1 ///< Enabled when required by target format
+#define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 ///< Shift timestamps so they are non negative
+#define AVFMT_AVOID_NEG_TS_MAKE_ZERO 2 ///< Shift timestamps so that they start at 0
+
/**
* Transport stream id.
@@ -1515,17 +1527,6 @@ typedef struct AVFormatContext {
int use_wallclock_as_timestamps;
/**
- * Avoid negative timestamps during muxing.
- * 0 -> allow negative timestamps
- * 1 -> avoid negative timestamps
- * -1 -> choose automatically (default)
- * Note, this only works when interleave_packet_per_dts is in use.
- * - encoding: Set by user via AVOptions (NO direct access)
- * - decoding: unused
- */
- int avoid_negative_ts;
-
- /**
* avio flags, used to force AVIO_FLAG_DIRECT.
* - encoding: unused
* - decoding: Set by user via AVOptions (NO direct access)
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 6c77f3b..8c3360a 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -419,10 +419,11 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options)
return ret;
if (s->avoid_negative_ts < 0) {
+ av_assert2(s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO);
if (s->oformat->flags & (AVFMT_TS_NEGATIVE | AVFMT_NOTIMESTAMPS)) {
s->avoid_negative_ts = 0;
} else
- s->avoid_negative_ts = 1;
+ s->avoid_negative_ts = AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE;
}
return 0;
@@ -556,7 +557,8 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
AVStream *st = s->streams[pkt->stream_index];
int64_t offset = st->mux_ts_offset;
- if ((pkt->dts < 0 || s->avoid_negative_ts == 2) && pkt->dts != AV_NOPTS_VALUE && !s->offset) {
+ if (!s->offset && pkt->dts != AV_NOPTS_VALUE &&
+ (pkt->dts < 0 || s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO)) {
s->offset = -pkt->dts;
s->offset_timebase = st->time_base;
}
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index 5ac3fba..40f1e0a 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -78,11 +78,6 @@ static const AVOption avformat_options[] = {
{"compliant", "consider all spec non compliancies as errors", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_COMPLIANT }, INT_MIN, INT_MAX, D, "err_detect"},
{"aggressive", "consider things that a sane encoder shouldn't do as an error", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_AGGRESSIVE }, INT_MIN, INT_MAX, D, "err_detect"},
{"use_wallclock_as_timestamps", "use wallclock as timestamps", OFFSET(use_wallclock_as_timestamps), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX-1, D},
-{"avoid_negative_ts", "shift timestamps so they start at 0", OFFSET(avoid_negative_ts), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, E, "avoid_negative_ts"},
-{"auto", "enabled when required by target format", 0, AV_OPT_TYPE_CONST, {.i64 = -1 }, INT_MIN, INT_MAX, E, "avoid_negative_ts"},
-{"disabled", "do not change timestamps", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, INT_MIN, INT_MAX, E, "avoid_negative_ts"},
-{"make_zero", "shift timestamps so they start at 0", 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, INT_MIN, INT_MAX, E, "avoid_negative_ts"},
-{"make_non_negative", "shift timestamps so they are non negative", 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, INT_MIN, INT_MAX, E, "avoid_negative_ts"},
{"skip_initial_bytes", "set number of bytes to skip before reading header and frames", OFFSET(skip_initial_bytes), AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX-1, D},
{"correct_ts_overflow", "correct single timestamp overflows", OFFSET(correct_ts_overflow), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, D},
{"flush_packets", "enable flushing of the I/O context after each packet", OFFSET(flush_packets), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E},
@@ -96,6 +91,11 @@ static const AVOption avformat_options[] = {
{"unofficial", "allow unofficial extensions", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_UNOFFICIAL }, INT_MIN, INT_MAX, D|E, "strict"},
{"experimental", "allow non-standardized experimental variants", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_EXPERIMENTAL }, INT_MIN, INT_MAX, D|E, "strict"},
{"max_ts_probe", "maximum number of packets to read while waiting for the first timestamp", OFFSET(max_ts_probe), AV_OPT_TYPE_INT, { .i64 = 50 }, 0, INT_MAX, D },
+{"avoid_negative_ts", "shift timestamps so they start at 0", OFFSET(avoid_negative_ts), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, E, "avoid_negative_ts"},
+{"auto", "enabled when required by target format", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_AVOID_NEG_TS_AUTO }, INT_MIN, INT_MAX, E, "avoid_negative_ts"},
+{"disabled", "do not change timestamps", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, INT_MIN, INT_MAX, E, "avoid_negative_ts"},
+{"make_non_negative", "shift timestamps so they are non negative", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE }, INT_MIN, INT_MAX, E, "avoid_negative_ts"},
+{"make_zero", "shift timestamps so they start at 0", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_AVOID_NEG_TS_MAKE_ZERO }, INT_MIN, INT_MAX, E, "avoid_negative_ts"},
{"dump_separator", "set information dump field separator", OFFSET(dump_separator), AV_OPT_TYPE_STRING, {.str = ", "}, CHAR_MIN, CHAR_MAX, D|E},
{"codec_whitelist", "List of decoders that are allowed to be used", OFFSET(codec_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, CHAR_MAX, D },
{"format_whitelist", "List of demuxers that are allowed to be used", OFFSET(format_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, CHAR_MAX, D },
diff --git a/libavformat/version.h b/libavformat/version.h
index 008f350..1368f23 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
#define LIBAVFORMAT_VERSION_MAJOR 56
#define LIBAVFORMAT_VERSION_MINOR 12
-#define LIBAVFORMAT_VERSION_MICRO 101
+#define LIBAVFORMAT_VERSION_MICRO 102
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
OpenPOWER on IntegriCloud