]> git.sesse.net Git - ffmpeg/commitdiff
avutil/timecode: add av_timecode_init_from_components
authorMarton Balint <cus@passwd.hu>
Sat, 5 Sep 2020 21:04:28 +0000 (23:04 +0200)
committerMarton Balint <cus@passwd.hu>
Thu, 3 Dec 2020 17:32:54 +0000 (18:32 +0100)
Signed-off-by: Marton Balint <cus@passwd.hu>
doc/APIchanges
libavutil/timecode.c
libavutil/timecode.h
libavutil/version.h

index bb19cbea7c4166dd77ffe3308d5999866ca3d6e5..3fb9e125253507c121aeb5a883c0b1c4ed77168a 100644 (file)
@@ -15,6 +15,9 @@ libavutil:     2017-10-21
 
 API changes, most recent first:
 
+2020-12-03 - xxxxxxxxxx - lavu 56.62.100 - timecode.h
+  Add av_timecode_init_from_components.
+
 2020-xx-xx - xxxxxxxxxx - lavc 58.114.100 - avcodec.h
   Deprecate AVCodecContext.thread_safe_callbacks. Starting with
   LIBAVCODEC_VERSION_MAJOR=60, user callbacks must always be
index 7caa6c64f584bdacc791178a61b60312be029e0a..c1fa445d31934ec947e849e1f711c572b325fb2c 100644 (file)
@@ -226,19 +226,12 @@ int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start
     return check_timecode(log_ctx, tc);
 }
 
-int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx)
+int av_timecode_init_from_components(AVTimecode *tc, AVRational rate, int flags, int hh, int mm, int ss, int ff, void *log_ctx)
 {
-    char c;
-    int hh, mm, ss, ff, ret;
-
-    if (sscanf(str, "%d:%d:%d%c%d", &hh, &mm, &ss, &c, &ff) != 5) {
-        av_log(log_ctx, AV_LOG_ERROR, "Unable to parse timecode, "
-                                      "syntax: hh:mm:ss[:;.]ff\n");
-        return AVERROR_INVALIDDATA;
-    }
+    int ret;
 
     memset(tc, 0, sizeof(*tc));
-    tc->flags = c != ':' ? AV_TIMECODE_FLAG_DROPFRAME : 0; // drop if ';', '.', ...
+    tc->flags = flags;
     tc->rate  = rate;
     tc->fps   = fps_from_frame_rate(rate);
 
@@ -253,3 +246,18 @@ int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *st
     }
     return 0;
 }
+
+int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx)
+{
+    char c;
+    int hh, mm, ss, ff, flags;
+
+    if (sscanf(str, "%d:%d:%d%c%d", &hh, &mm, &ss, &c, &ff) != 5) {
+        av_log(log_ctx, AV_LOG_ERROR, "Unable to parse timecode, "
+                                      "syntax: hh:mm:ss[:;.]ff\n");
+        return AVERROR_INVALIDDATA;
+    }
+    flags = c != ':' ? AV_TIMECODE_FLAG_DROPFRAME : 0; // drop if ';', '.', ...
+
+    return av_timecode_init_from_components(tc, rate, flags, hh, mm, ss, ff, log_ctx);
+}
index 697e61180bd5f9075a76325b062bcc6307d9bfa2..060574a17203851aee45126f7ab1e0345e2f01fb 100644 (file)
@@ -160,6 +160,23 @@ char *av_timecode_make_mpeg_tc_string(char *buf, uint32_t tc25bit);
  */
 int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx);
 
+/**
+ * Init a timecode struct from the passed timecode components.
+ *
+ * @param log_ctx     a pointer to an arbitrary struct of which the first field
+ *                    is a pointer to an AVClass struct (used for av_log)
+ * @param tc          pointer to an allocated AVTimecode
+ * @param rate        frame rate in rational form
+ * @param flags       miscellaneous flags such as drop frame, +24 hours, ...
+ *                    (see AVTimecodeFlag)
+ * @param hh          hours
+ * @param mm          minutes
+ * @param ss          seconds
+ * @param ff          frames
+ * @return            0 on success, AVERROR otherwise
+ */
+int av_timecode_init_from_components(AVTimecode *tc, AVRational rate, int flags, int hh, int mm, int ss, int ff, void *log_ctx);
+
 /**
  * Parse timecode representation (hh:mm:ss[:;.]ff).
  *
index 55a59d6c584b3ecaab3ed02b51fd130e18325eb7..9b311b5b2786f2b8ed83c33263102d179c64b528 100644 (file)
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  61
+#define LIBAVUTIL_VERSION_MINOR  62
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \