[FFmpeg-cvslog] avformat/utils: Move creation-time functions to mux_utils

Andreas Rheinhardt git at videolan.org
Tue May 10 09:35:03 EEST 2022


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri May  6 16:40:53 2022 +0200| [d78838414b8362a7aa7c27abacee1f6ca036199c] | committer: Andreas Rheinhardt

avformat/utils: Move creation-time functions to mux_utils

Only used by muxers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d78838414b8362a7aa7c27abacee1f6ca036199c
---

 libavformat/apetag.c    |  2 +-
 libavformat/asfenc.c    |  1 +
 libavformat/cafenc.c    |  1 +
 libavformat/dvenc.c     |  3 +--
 libavformat/id3v2enc.c  |  1 +
 libavformat/internal.h  | 20 --------------------
 libavformat/lrcenc.c    |  1 +
 libavformat/mux.h       | 20 ++++++++++++++++++++
 libavformat/mux_utils.c | 31 +++++++++++++++++++++++++++++++
 libavformat/nutenc.c    |  1 +
 libavformat/smjpegenc.c |  1 +
 libavformat/utils.c     | 27 ---------------------------
 libavformat/wtvenc.c    |  2 +-
 13 files changed, 60 insertions(+), 51 deletions(-)

diff --git a/libavformat/apetag.c b/libavformat/apetag.c
index 6f82fbe202..cc6becc182 100644
--- a/libavformat/apetag.c
+++ b/libavformat/apetag.c
@@ -22,12 +22,12 @@
 
 #include <inttypes.h>
 
-#include "libavutil/intreadwrite.h"
 #include "libavutil/dict.h"
 #include "avformat.h"
 #include "avio_internal.h"
 #include "apetag.h"
 #include "internal.h"
+#include "mux.h"
 
 #define APE_TAG_FLAG_CONTAINS_HEADER  (1U << 31)
 #define APE_TAG_FLAG_LACKS_FOOTER     (1 << 30)
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 5b34f98a2b..e1563b1da6 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -29,6 +29,7 @@
 #include "avlanguage.h"
 #include "avio_internal.h"
 #include "internal.h"
+#include "mux.h"
 #include "riff.h"
 #include "asf.h"
 
diff --git a/libavformat/cafenc.c b/libavformat/cafenc.c
index 396e946ceb..fedb430b17 100644
--- a/libavformat/cafenc.c
+++ b/libavformat/cafenc.c
@@ -23,6 +23,7 @@
 #include "caf.h"
 #include "isom.h"
 #include "avio_internal.h"
+#include "mux.h"
 #include "libavutil/intfloat.h"
 #include "libavutil/dict.h"
 
diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
index 23b99062c7..1917c00694 100644
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -31,15 +31,14 @@
 
 #include "libavutil/time_internal.h"
 #include "avformat.h"
-#include "internal.h"
 #include "libavcodec/dv_profile.h"
 #include "libavcodec/dv.h"
 #include "dv.h"
+#include "mux.h"
 #include "libavutil/avassert.h"
 #include "libavutil/fifo.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/opt.h"
 #include "libavutil/timecode.h"
 
 #define MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32-bit audio
diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2enc.c
index 5d821ea4db..515d2efd7d 100644
--- a/libavformat/id3v2enc.c
+++ b/libavformat/id3v2enc.c
@@ -28,6 +28,7 @@
 #include "avio.h"
 #include "avio_internal.h"
 #include "id3v2.h"
+#include "mux.h"
 
 static void id3v2_put_size(AVIOContext *pb, int size)
 {
diff --git a/libavformat/internal.h b/libavformat/internal.h
index da9abde637..03b9bb8e37 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -881,26 +881,6 @@ void ff_format_io_close_default(AVFormatContext *s, AVIOContext *pb);
  */
 int ff_is_http_proto(const char *filename);
 
-/**
- * Parse creation_time in AVFormatContext metadata if exists and warn if the
- * parsing fails.
- *
- * @param s AVFormatContext
- * @param timestamp parsed timestamp in microseconds, only set on successful parsing
- * @param return_seconds set this to get the number of seconds in timestamp instead of microseconds
- * @return 1 if OK, 0 if the metadata was not present, AVERROR(EINVAL) on parse error
- */
-int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int return_seconds);
-
-/**
- * Standardize creation_time metadata in AVFormatContext to an ISO-8601
- * timestamp string.
- *
- * @param s AVFormatContext
- * @return <0 on error
- */
-int ff_standardize_creation_time(AVFormatContext *s);
-
 struct AVBPrint;
 /**
  * Finalize buf into extradata and set its size appropriately.
diff --git a/libavformat/lrcenc.c b/libavformat/lrcenc.c
index 5703a95180..cdf94e6cd2 100644
--- a/libavformat/lrcenc.c
+++ b/libavformat/lrcenc.c
@@ -27,6 +27,7 @@
 #include "internal.h"
 #include "lrc.h"
 #include "metadata.h"
+#include "mux.h"
 #include "version.h"
 #include "libavutil/dict.h"
 #include "libavutil/log.h"
diff --git a/libavformat/mux.h b/libavformat/mux.h
index c220738942..246101f0c8 100644
--- a/libavformat/mux.h
+++ b/libavformat/mux.h
@@ -103,4 +103,24 @@ enum AVWriteUncodedFrameFlags {
  */
 int ff_format_shift_data(AVFormatContext *s, int64_t read_start, int shift_size);
 
+/**
+ * Parse creation_time in AVFormatContext metadata if exists and warn if the
+ * parsing fails.
+ *
+ * @param s AVFormatContext
+ * @param timestamp parsed timestamp in microseconds, only set on successful parsing
+ * @param return_seconds set this to get the number of seconds in timestamp instead of microseconds
+ * @return 1 if OK, 0 if the metadata was not present, AVERROR(EINVAL) on parse error
+ */
+int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int return_seconds);
+
+/**
+ * Standardize creation_time metadata in AVFormatContext to an ISO-8601
+ * timestamp string.
+ *
+ * @param s AVFormatContext
+ * @return <0 on error
+ */
+int ff_standardize_creation_time(AVFormatContext *s);
+
 #endif /* AVFORMAT_MUX_H */
diff --git a/libavformat/mux_utils.c b/libavformat/mux_utils.c
index 7b79ffd1fb..df264fc6a0 100644
--- a/libavformat/mux_utils.c
+++ b/libavformat/mux_utils.c
@@ -19,6 +19,11 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/dict.h"
+#include "libavutil/internal.h"
+#include "libavutil/log.h"
+#include "libavutil/mem.h"
+#include "libavutil/parseutils.h"
 #include "avformat.h"
 #include "avio.h"
 #include "internal.h"
@@ -79,3 +84,29 @@ end:
     av_free(buf);
     return ret;
 }
+
+int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int return_seconds)
+{
+    AVDictionaryEntry *entry;
+    int64_t parsed_timestamp;
+    int ret;
+    if ((entry = av_dict_get(s->metadata, "creation_time", NULL, 0))) {
+        if ((ret = av_parse_time(&parsed_timestamp, entry->value, 0)) >= 0) {
+            *timestamp = return_seconds ? parsed_timestamp / 1000000 : parsed_timestamp;
+            return 1;
+        } else {
+            av_log(s, AV_LOG_WARNING, "Failed to parse creation_time %s\n", entry->value);
+            return ret;
+        }
+    }
+    return 0;
+}
+
+int ff_standardize_creation_time(AVFormatContext *s)
+{
+    int64_t timestamp;
+    int ret = ff_parse_creation_time_metadata(s, &timestamp, 0);
+    if (ret == 1)
+        return avpriv_dict_set_timestamp(&s->metadata, "creation_time", timestamp);
+    return ret;
+}
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index 0cea1fabb3..1afdeeb8ab 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -30,6 +30,7 @@
 #include "libavutil/opt.h"
 #include "libavcodec/bytestream.h"
 #include "libavcodec/mpegaudiodata.h"
+#include "mux.h"
 #include "nut.h"
 #include "internal.h"
 #include "avio_internal.h"
diff --git a/libavformat/smjpegenc.c b/libavformat/smjpegenc.c
index 8b40c09329..888ece2f7c 100644
--- a/libavformat/smjpegenc.c
+++ b/libavformat/smjpegenc.c
@@ -26,6 +26,7 @@
 
 #include "avformat.h"
 #include "internal.h"
+#include "mux.h"
 #include "smjpeg.h"
 
 typedef struct SMJPEGMuxContext {
diff --git a/libavformat/utils.c b/libavformat/utils.c
index cc5507a19e..a695f19b03 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -29,7 +29,6 @@
 #include "libavutil/dict.h"
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
-#include "libavutil/parseutils.h"
 #include "libavutil/pixfmt.h"
 #include "libavutil/thread.h"
 #include "libavutil/time.h"
@@ -1689,32 +1688,6 @@ int ff_is_http_proto(const char *filename) {
     return proto ? (!av_strcasecmp(proto, "http") || !av_strcasecmp(proto, "https")) : 0;
 }
 
-int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int return_seconds)
-{
-    AVDictionaryEntry *entry;
-    int64_t parsed_timestamp;
-    int ret;
-    if ((entry = av_dict_get(s->metadata, "creation_time", NULL, 0))) {
-        if ((ret = av_parse_time(&parsed_timestamp, entry->value, 0)) >= 0) {
-            *timestamp = return_seconds ? parsed_timestamp / 1000000 : parsed_timestamp;
-            return 1;
-        } else {
-            av_log(s, AV_LOG_WARNING, "Failed to parse creation_time %s\n", entry->value);
-            return ret;
-        }
-    }
-    return 0;
-}
-
-int ff_standardize_creation_time(AVFormatContext *s)
-{
-    int64_t timestamp;
-    int ret = ff_parse_creation_time_metadata(s, &timestamp, 0);
-    if (ret == 1)
-        return avpriv_dict_set_timestamp(&s->metadata, "creation_time", timestamp);
-    return ret;
-}
-
 int ff_bprint_to_codecpar_extradata(AVCodecParameters *par, struct AVBPrint *buf)
 {
     int ret;
diff --git a/libavformat/wtvenc.c b/libavformat/wtvenc.c
index 9c67a6d3e8..7e28b2082e 100644
--- a/libavformat/wtvenc.c
+++ b/libavformat/wtvenc.c
@@ -25,12 +25,12 @@
  * @author Zhentan Feng <spyfeng at gmail dot com>
  */
 
-#include "libavutil/intreadwrite.h"
 #include "libavutil/avassert.h"
 #include "avformat.h"
 #include "avio_internal.h"
 #include "internal.h"
 #include "mpegts.h"
+#include "mux.h"
 #include "wtv.h"
 
 #define WTV_BIGSECTOR_SIZE (1 << WTV_BIGSECTOR_BITS)



More information about the ffmpeg-cvslog mailing list