avformat: Add a flag to mark muxers that allow (non strict) monotone timestamps.
authorJames Zern <jzern@google.com>
Thu, 26 May 2011 18:19:04 +0000 (20:19 +0200)
committerJustin Ruggles <justin.ruggles@gmail.com>
Sun, 20 May 2012 23:50:32 +0000 (19:50 -0400)
Signed-off-by: Justin Ruggles <justin.ruggles@gmail.com>
doc/APIchanges
libavformat/avformat.h
libavformat/flvenc.c
libavformat/framecrcenc.c
libavformat/matroskaenc.c
libavformat/md5enc.c
libavformat/smjpegenc.c
libavformat/swfenc.c
libavformat/utils.c
libavformat/version.h
libavformat/wav.c

index dac87ee..18105c5 100644 (file)
@@ -13,6 +13,10 @@ libavutil:     2011-04-18
 
 API changes, most recent first:
 
+2012-05-xx - xxxxxxx - lavf 54.3.0
+  Add AVFMT_TS_NONSTRICT format flag to indicate that a muxer supports
+  non-increasing monotone timestamps.
+
 2012-05-15 - lavfi 2.17.0
   Add support for audio filters
   ac71230/a2cd9be - add video/audio buffer sink in a new installed
index 33e9098..040e35e 100644 (file)
@@ -351,6 +351,9 @@ typedef struct AVProbeData {
 #define AVFMT_NOGENSEARCH   0x4000 /**< Format does not allow to fallback to generic search */
 #define AVFMT_NO_BYTE_SEEK  0x8000 /**< Format does not allow seeking by bytes */
 #define AVFMT_ALLOW_FLUSH  0x10000 /**< Format allows flushing. If not set, the muxer will not receive a NULL packet in the write_packet function. */
+#define AVFMT_TS_NONSTRICT 0x20000 /**< Format does not require strictly
+                                        increasing timestamps, but they must
+                                        still be monotonic */
 
 /**
  * @addtogroup lavf_encoding
@@ -373,7 +376,8 @@ typedef struct AVOutputFormat {
     /**
      * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE,
      * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS,
-     * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH
+     * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH,
+     * AVFMT_TS_NONSTRICT
      */
     int flags;
 
index 19169ad..3a51aaa 100644 (file)
@@ -488,5 +488,6 @@ AVOutputFormat ff_flv_muxer = {
     .codec_tag      = (const AVCodecTag* const []){
         flv_video_codec_ids, flv_audio_codec_ids, 0
     },
-    .flags          = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
+    .flags          = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS |
+                      AVFMT_TS_NONSTRICT,
 };
index d1148f9..36dfd29 100644 (file)
@@ -43,5 +43,5 @@ AVOutputFormat ff_framecrc_muxer = {
     .video_codec       = CODEC_ID_RAWVIDEO,
     .write_header      = ff_framehash_write_header,
     .write_packet      = framecrc_write_packet,
-    .flags             = AVFMT_VARIABLE_FPS,
+    .flags             = AVFMT_VARIABLE_FPS | AVFMT_TS_NONSTRICT,
 };
index 9334b52..61a91d7 100644 (file)
@@ -1305,7 +1305,8 @@ AVOutputFormat ff_matroska_muxer = {
     .write_header      = mkv_write_header,
     .write_packet      = mkv_write_packet,
     .write_trailer     = mkv_write_trailer,
-    .flags             = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
+    .flags             = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS |
+                         AVFMT_TS_NONSTRICT,
     .codec_tag         = (const AVCodecTag* const []){
          ff_codec_bmp_tags, ff_codec_wav_tags, 0
     },
@@ -1326,7 +1327,8 @@ AVOutputFormat ff_webm_muxer = {
     .write_header      = mkv_write_header,
     .write_packet      = mkv_write_packet,
     .write_trailer     = mkv_write_trailer,
-    .flags             = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
+    .flags             = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS |
+                         AVFMT_TS_NONSTRICT,
 };
 #endif
 
@@ -1346,7 +1348,7 @@ AVOutputFormat ff_matroska_audio_muxer = {
     .write_header      = mkv_write_header,
     .write_packet      = mkv_write_packet,
     .write_trailer     = mkv_write_trailer,
-    .flags             = AVFMT_GLOBALHEADER,
+    .flags             = AVFMT_GLOBALHEADER | AVFMT_TS_NONSTRICT,
     .codec_tag         = (const AVCodecTag* const []){ ff_codec_wav_tags, 0 },
 };
 #endif
index 3fd5450..4e8db3c 100644 (file)
@@ -106,6 +106,6 @@ AVOutputFormat ff_framemd5_muxer = {
     .video_codec       = CODEC_ID_RAWVIDEO,
     .write_header      = ff_framehash_write_header,
     .write_packet      = framemd5_write_packet,
-    .flags             = AVFMT_VARIABLE_FPS,
+    .flags             = AVFMT_VARIABLE_FPS | AVFMT_TS_NONSTRICT,
 };
 #endif
index 45ba20b..e27b895 100644 (file)
@@ -144,6 +144,6 @@ AVOutputFormat ff_smjpeg_muxer = {
     .write_header   = smjpeg_write_header,
     .write_packet   = smjpeg_write_packet,
     .write_trailer  = smjpeg_write_trailer,
-    .flags          = AVFMT_GLOBALHEADER,
+    .flags          = AVFMT_GLOBALHEADER | AVFMT_TS_NONSTRICT,
     .codec_tag      = (const AVCodecTag *const []){ ff_codec_smjpeg_video_tags, ff_codec_smjpeg_audio_tags, 0 },
 };
index 82ec7ff..fb0fdc5 100644 (file)
@@ -513,6 +513,7 @@ AVOutputFormat ff_swf_muxer = {
     .write_header      = swf_write_header,
     .write_packet      = swf_write_packet,
     .write_trailer     = swf_write_trailer,
+    .flags             = AVFMT_TS_NONSTRICT,
 };
 #endif
 #if CONFIG_AVM2_MUXER
@@ -526,5 +527,6 @@ AVOutputFormat ff_avm2_muxer = {
     .write_header      = swf_write_header,
     .write_packet      = swf_write_packet,
     .write_trailer     = swf_write_trailer,
+    .flags             = AVFMT_TS_NONSTRICT,
 };
 #endif
index e8430b2..4387521 100644 (file)
@@ -2962,7 +2962,9 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt){
         pkt->dts= st->pts_buffer[0];
     }
 
-    if(st->cur_dts && st->cur_dts != AV_NOPTS_VALUE && st->cur_dts >= pkt->dts){
+    if (st->cur_dts && st->cur_dts != AV_NOPTS_VALUE &&
+        ((!(s->oformat->flags & AVFMT_TS_NONSTRICT) &&
+          st->cur_dts >= pkt->dts) || st->cur_dts > pkt->dts)) {
         av_log(s, AV_LOG_ERROR,
                "Application provided invalid, non monotonically increasing dts to muxer in stream %d: %"PRId64" >= %"PRId64"\n",
                st->index, st->cur_dts, pkt->dts);
index 91ddfd2..7bd0b8e 100644 (file)
@@ -30,7 +30,7 @@
 #include "libavutil/avutil.h"
 
 #define LIBAVFORMAT_VERSION_MAJOR 54
-#define LIBAVFORMAT_VERSION_MINOR  2
+#define LIBAVFORMAT_VERSION_MINOR  3
 #define LIBAVFORMAT_VERSION_MICRO  0
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
index 85849c1..c01121f 100644 (file)
@@ -216,6 +216,7 @@ AVOutputFormat ff_wav_muxer = {
     .write_header      = wav_write_header,
     .write_packet      = wav_write_packet,
     .write_trailer     = wav_write_trailer,
+    .flags             = AVFMT_TS_NONSTRICT,
     .codec_tag         = (const AVCodecTag* const []){ ff_codec_wav_tags, 0 },
     .priv_class        = &wav_muxer_class,
 };