[FFmpeg-cvslog] avutil/dict: Unavpriv avpriv_dict_set_timestamp()
Andreas Rheinhardt
git at videolan.org
Fri Mar 28 19:46:02 EET 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sat Mar 15 22:10:44 2025 +0100| [c389d9ac788a529331722f6b3f13c5894114a28c] | committer: James Almer
avutil/dict: Unavpriv avpriv_dict_set_timestamp()
And move it to lavf, its only user.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
Signed-off-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c389d9ac788a529331722f6b3f13c5894114a28c
---
libavformat/flvdec.c | 3 +--
libavformat/ifv.c | 3 +--
libavformat/internal.h | 11 +++++++++++
libavformat/matroskadec.c | 3 +--
libavformat/mov.c | 3 +--
libavformat/mux_utils.c | 3 +--
libavformat/mxfdec.c | 3 +--
libavformat/utils.c | 19 +++++++++++++++++++
libavutil/dict.c | 18 ------------------
libavutil/dict_internal.h | 37 -------------------------------------
10 files changed, 36 insertions(+), 67 deletions(-)
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index c51f64a588..b90ed34b1c 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -28,7 +28,6 @@
#include "libavutil/avstring.h"
#include "libavutil/channel_layout.h"
#include "libavutil/dict.h"
-#include "libavutil/dict_internal.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/internal.h"
@@ -826,7 +825,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream,
) {
// timezone is ignored, since there is no easy way to offset the UTC
// timestamp into the specified timezone
- avpriv_dict_set_timestamp(&s->metadata, key, 1000 * (int64_t)date.milliseconds);
+ ff_dict_set_timestamp(&s->metadata, key, 1000 * (int64_t)date.milliseconds);
}
}
diff --git a/libavformat/ifv.c b/libavformat/ifv.c
index 0cfd2763a9..f0263ed3b4 100644
--- a/libavformat/ifv.c
+++ b/libavformat/ifv.c
@@ -21,7 +21,6 @@
*/
#include "libavutil/channel_layout.h"
-#include "libavutil/dict_internal.h"
#include "avformat.h"
#include "demux.h"
#include "internal.h"
@@ -96,7 +95,7 @@ static int parse_header(AVFormatContext *s)
uint32_t vid_magic;
avio_skip(s->pb, 0x34);
- avpriv_dict_set_timestamp(&s->metadata, "creation_time", avio_rl32(s->pb) * 1000000LL);
+ ff_dict_set_timestamp(&s->metadata, "creation_time", avio_rl32(s->pb) * 1000000LL);
avio_skip(s->pb, 0x24);
ifv->width = avio_rl16(s->pb);
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 500c310b88..fe428d85eb 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -640,4 +640,15 @@ int ff_match_url_ext(const char *url, const char *extensions);
int ff_get_frame_filename(char *buf, int buf_size, const char *path,
int64_t number, int flags);
+/**
+ * Set a dictionary value to an ISO-8601 compliant timestamp string.
+ *
+ * @param dict pointer to a pointer to a dictionary struct. If *dict is NULL
+ * a dictionary struct is allocated and put in *dict.
+ * @param key metadata key
+ * @param timestamp unix timestamp in microseconds
+ * @return <0 on error
+ */
+int ff_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp);
+
#endif /* AVFORMAT_INTERNAL_H */
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index efa3e44c85..d4b7ae112c 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -38,7 +38,6 @@
#include "libavutil/base64.h"
#include "libavutil/bprint.h"
#include "libavutil/dict.h"
-#include "libavutil/dict_internal.h"
#include "libavutil/display.h"
#include "libavutil/hdr_dynamic_metadata.h"
#include "libavutil/intfloat.h"
@@ -2137,7 +2136,7 @@ static int matroska_aac_sri(int samplerate)
static void matroska_metadata_creation_time(AVDictionary **metadata, int64_t date_utc)
{
/* Convert to seconds and adjust by number of seconds between 2001-01-01 and Epoch */
- avpriv_dict_set_timestamp(metadata, "creation_time", date_utc / 1000 + 978307200000000LL);
+ ff_dict_set_timestamp(metadata, "creation_time", date_utc / 1000 + 978307200000000LL);
}
static int matroska_parse_flac(AVFormatContext *s,
diff --git a/libavformat/mov.c b/libavformat/mov.c
index bf526db67a..452690090c 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -32,7 +32,6 @@
#include "libavutil/attributes.h"
#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
-#include "libavutil/dict_internal.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat.h"
@@ -1858,7 +1857,7 @@ static void mov_metadata_creation_time(MOVContext *c, AVIOContext *pb, AVDiction
return;
}
- avpriv_dict_set_timestamp(metadata, "creation_time", time * 1000000);
+ ff_dict_set_timestamp(metadata, "creation_time", time * 1000000);
}
}
diff --git a/libavformat/mux_utils.c b/libavformat/mux_utils.c
index ed1242a6a2..86d333dbe7 100644
--- a/libavformat/mux_utils.c
+++ b/libavformat/mux_utils.c
@@ -20,7 +20,6 @@
*/
#include "libavutil/dict.h"
-#include "libavutil/dict_internal.h"
#include "libavutil/internal.h"
#include "libavutil/log.h"
#include "libavutil/mem.h"
@@ -157,6 +156,6 @@ int ff_standardize_creation_time(AVFormatContext *s)
int64_t timestamp;
int ret = ff_parse_creation_time_metadata(s, ×tamp, 0);
if (ret == 1)
- return avpriv_dict_set_timestamp(&s->metadata, "creation_time", timestamp);
+ return ff_dict_set_timestamp(&s->metadata, "creation_time", timestamp);
return ret;
}
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 3b87063c3f..1978b2cec5 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -56,7 +56,6 @@
#include "libavcodec/defs.h"
#include "libavcodec/internal.h"
#include "libavutil/channel_layout.h"
-#include "libavutil/dict_internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/parseutils.h"
#include "libavutil/timecode.h"
@@ -3207,7 +3206,7 @@ static int64_t mxf_timestamp_to_int64(uint64_t timestamp)
#define SET_TS_METADATA(pb, name, var, str) do { \
var = avio_rb64(pb); \
- if (var && (ret = avpriv_dict_set_timestamp(&s->metadata, name, mxf_timestamp_to_int64(var))) < 0) \
+ if (var && (ret = ff_dict_set_timestamp(&s->metadata, name, mxf_timestamp_to_int64(var))) < 0) \
return ret; \
} while (0)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index e892e8bde7..eee7b9e0e3 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -20,14 +20,17 @@
*/
#include <stdint.h>
+#include <time.h>
#include "config.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
+#include "libavutil/dict.h"
#include "libavutil/internal.h"
#include "libavutil/mem.h"
#include "libavutil/time.h"
+#include "libavutil/time_internal.h"
#include "libavcodec/internal.h"
@@ -596,3 +599,19 @@ int ff_bprint_to_codecpar_extradata(AVCodecParameters *par, struct AVBPrint *buf
par->extradata_size = buf->len;
return 0;
}
+
+int ff_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp)
+{
+ time_t seconds = timestamp / 1000000;
+ struct tm *ptm, tmbuf;
+ ptm = gmtime_r(&seconds, &tmbuf);
+ if (ptm) {
+ char buf[32];
+ if (!strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", ptm))
+ return AVERROR_EXTERNAL;
+ av_strlcatf(buf, sizeof(buf), ".%06dZ", (int)(timestamp % 1000000));
+ return av_dict_set(dict, key, buf, 0);
+ } else {
+ return AVERROR_EXTERNAL;
+ }
+}
diff --git a/libavutil/dict.c b/libavutil/dict.c
index 6fb09399ba..a5fa2d3bfa 100644
--- a/libavutil/dict.c
+++ b/libavutil/dict.c
@@ -25,10 +25,8 @@
#include "avassert.h"
#include "avstring.h"
#include "dict.h"
-#include "dict_internal.h"
#include "error.h"
#include "mem.h"
-#include "time_internal.h"
#include "bprint.h"
struct AVDictionary {
@@ -274,19 +272,3 @@ int av_dict_get_string(const AVDictionary *m, char **buffer,
}
return av_bprint_finalize(&bprint, buffer);
}
-
-int avpriv_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp)
-{
- time_t seconds = timestamp / 1000000;
- struct tm *ptm, tmbuf;
- ptm = gmtime_r(&seconds, &tmbuf);
- if (ptm) {
- char buf[32];
- if (!strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", ptm))
- return AVERROR_EXTERNAL;
- av_strlcatf(buf, sizeof(buf), ".%06dZ", (int)(timestamp % 1000000));
- return av_dict_set(dict, key, buf, 0);
- } else {
- return AVERROR_EXTERNAL;
- }
-}
diff --git a/libavutil/dict_internal.h b/libavutil/dict_internal.h
deleted file mode 100644
index 6d5b0dc2b0..0000000000
--- a/libavutil/dict_internal.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVUTIL_DICT_INTERNAL_H
-#define AVUTIL_DICT_INTERNAL_H
-
-#include <stdint.h>
-
-#include "dict.h"
-
-/**
- * Set a dictionary value to an ISO-8601 compliant timestamp string.
- *
- * @param dict pointer to a pointer to a dictionary struct. If *dict is NULL
- * a dictionary struct is allocated and put in *dict.
- * @param key metadata key
- * @param timestamp unix timestamp in microseconds
- * @return <0 on error
- */
-int avpriv_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp);
-
-#endif /* AVUTIL_DICT_INTERNAL_H */
More information about the ffmpeg-cvslog
mailing list