[FFmpeg-devel] [PATCH v2 3/6] avformat/avformat: Add AVFMT_AVOID_NEG_TS_DISABLED

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Jan 19 23:29:37 EET 2022


And also don't use explicit constants in the movenc test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavformat/avformat.h      | 1 +
 libavformat/mux.c           | 2 +-
 libavformat/options_table.h | 2 +-
 libavformat/tests/movenc.c  | 4 ++--
 libavformat/webm_chunk.c    | 2 +-
 5 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 6ce367e854..cd253fb28e 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1533,6 +1533,7 @@ typedef struct AVFormatContext {
      */
     int avoid_negative_ts;
 #define AVFMT_AVOID_NEG_TS_AUTO             -1 ///< Enabled when required by target format
+#define AVFMT_AVOID_NEG_TS_DISABLED          0 ///< Do not shift timestamps even when they are negative.
 #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
 
diff --git a/libavformat/mux.c b/libavformat/mux.c
index e34fd88f05..a1917878a5 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -421,7 +421,7 @@ static int init_pts(AVFormatContext *s)
     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;
+            s->avoid_negative_ts = AVFMT_AVOID_NEG_TS_DISABLED;
         } else
             s->avoid_negative_ts = AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE;
     }
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index 62c5bb40a3..86d836cfeb 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -95,7 +95,7 @@ static const AVOption avformat_options[] = {
 {"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"},
+{"disabled",          "do not change timestamps",                  0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_AVOID_NEG_TS_DISABLED },          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 = ", "}, 0, 0, D|E},
diff --git a/libavformat/tests/movenc.c b/libavformat/tests/movenc.c
index 2af72f11c7..ddcb053bf2 100644
--- a/libavformat/tests/movenc.c
+++ b/libavformat/tests/movenc.c
@@ -455,7 +455,7 @@ int main(int argc, char **argv)
     init_count_warnings();
     init_out("empty-moov-no-elst-no-adjust");
     av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0);
-    av_dict_set(&opts, "avoid_negative_ts", "0", 0);
+    av_dict_set(&opts, "avoid_negative_ts", "disabled", 0);
     init(1, 0);
     mux_gops(2);
     finish();
@@ -578,7 +578,7 @@ int main(int argc, char **argv)
     // one before.
     av_dict_set(&opts, "movflags", "frag_custom+empty_moov+dash+frag_discont", 0);
     av_dict_set(&opts, "fragment_index", "2", 0);
-    av_dict_set(&opts, "avoid_negative_ts", "0", 0);
+    av_dict_set(&opts, "avoid_negative_ts", "disabled", 0);
     av_dict_set(&opts, "use_editlist", "0", 0);
     init(0, 0);
     skip_gops(1);
diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c
index 24390e8e74..9348e6680a 100644
--- a/libavformat/webm_chunk.c
+++ b/libavformat/webm_chunk.c
@@ -127,7 +127,7 @@ fail:
     s->avoid_negative_ts  = oc->avoid_negative_ts;
     ffformatcontext(s)->avoid_negative_ts_use_pts =
         ffformatcontext(oc)->avoid_negative_ts_use_pts;
-    oc->avoid_negative_ts = 0;
+    oc->avoid_negative_ts = AVFMT_AVOID_NEG_TS_DISABLED;
 
     return 0;
 }
-- 
2.32.0



More information about the ffmpeg-devel mailing list