[FFmpeg-devel] [PATCH v3 2/2] avformat: deprecated av_get_frame_filename() and av_get_frame_filename2()
Filip Mašić
shoutplenty at gmail.com
Mon Sep 23 13:18:09 EEST 2024
---
doc/APIchanges | 3 ++-
libavfilter/vf_signature.c | 4 ++--
libavformat/avformat.h | 22 ++++++++++++++++++----
libavformat/img2dec.c | 10 +++++-----
libavformat/segment.c | 4 ++--
libavformat/utils.c | 2 +-
libavformat/version_major.h | 2 +-
libavformat/webm_chunk.c | 4 ++--
8 files changed, 33 insertions(+), 18 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 9f091f5ec5..cbab71a408 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -3,7 +3,8 @@ The last version increases of all libraries were on 2024-03-07
API changes, most recent first:
2024-09-xx - xxxxxxxxxx - lavf 61.7.100 - avformat.h
- Add av_get_frame_filename3()
+ Deprecate av_get_frame_filename(), av_get_frame_filename2(),
+ and replace them with av_get_frame_filename3().
2024-09-18 - xxxxxxxxxx - lavc 61.17.100 - packet.h
Add AV_PKT_DATA_LCEVC.
diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c
index f419522ac6..37f3ff227e 100644
--- a/libavfilter/vf_signature.c
+++ b/libavfilter/vf_signature.c
@@ -562,7 +562,7 @@ static int export(AVFilterContext *ctx, StreamContext *sc, int input)
if (sic->nb_inputs > 1) {
/* error already handled */
- av_assert0(av_get_frame_filename(filename, sizeof(filename), sic->filename, input) == 0);
+ av_assert0(av_get_frame_filename3(filename, sizeof(filename), sic->filename, input, 0) == 0);
} else {
if (av_strlcpy(filename, sic->filename, sizeof(filename)) >= sizeof(filename))
return AVERROR(EINVAL);
@@ -673,7 +673,7 @@ static av_cold int init(AVFilterContext *ctx)
}
/* check filename */
- if (sic->nb_inputs > 1 && strlen(sic->filename) > 0 && av_get_frame_filename(tmp, sizeof(tmp), sic->filename, 0) == -1) {
+ if (sic->nb_inputs > 1 && strlen(sic->filename) > 0 && av_get_frame_filename3(tmp, sizeof(tmp), sic->filename, 0, 0) == -1) {
av_log(ctx, AV_LOG_ERROR, "The filename must contain %%d or %%0nd, if you have more than one input.\n");
return AVERROR(EINVAL);
}
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 1bc0e716dc..a407faecec 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2940,11 +2940,25 @@ void av_dump_format(AVFormatContext *ic,
int av_get_frame_filename3(char *buf, int buf_size,
const char *path, int64_t number, int flags);
-int av_get_frame_filename2(char *buf, int buf_size,
- const char *path, int number, int flags);
+#if FF_API_AV_GET_FRAME_FILENAME2
+ /**
+ * Like av_get_frame_filename3() but requires int-type number
+ *
+ * @deprecated use av_get_frame_filename3() with same arguments
+ */
+ attribute_deprecated
+ int av_get_frame_filename2(char *buf, int buf_size,
+ const char *path, int number, int flags);
-int av_get_frame_filename(char *buf, int buf_size,
- const char *path, int number);
+ /**
+ * Like av_get_frame_filename3() but requires int-type number and doesn't accept flags
+ *
+ * @deprecated use av_get_frame_filename3() with flags=0
+ */
+ attribute_deprecated
+ int av_get_frame_filename(char *buf, int buf_size,
+ const char *path, int number);
+#endif
/**
* Check whether filename actually is a numbered sequence generator.
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 3389fa818e..df376ac612 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -122,7 +122,7 @@ static int find_image_range(AVIOContext *pb, int *pfirst_index, int *plast_index
/* find the first image */
for (first_index = start_index; first_index < start_index + start_index_range; first_index++) {
- if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0) {
+ if (av_get_frame_filename3(buf, sizeof(buf), path, first_index, 0) < 0) {
*pfirst_index =
*plast_index = 1;
if (pb || avio_check(buf, AVIO_FLAG_READ) > 0)
@@ -144,8 +144,8 @@ static int find_image_range(AVIOContext *pb, int *pfirst_index, int *plast_index
range1 = 1;
else
range1 = 2 * range;
- if (av_get_frame_filename(buf, sizeof(buf), path,
- last_index + range1) < 0)
+ if (av_get_frame_filename3(buf, sizeof(buf), path,
+ last_index + range1, 0) < 0)
goto fail;
if (avio_check(buf, AVIO_FLAG_READ) <= 0)
break;
@@ -434,9 +434,9 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
filename = s->globstate.gl_pathv[s->img_number];
#endif
} else {
- if (av_get_frame_filename(filename_bytes, sizeof(filename_bytes),
+ if (av_get_frame_filename3(filename_bytes, sizeof(filename_bytes),
s->path,
- s->img_number) < 0 && s->img_number > 1)
+ s->img_number, 0) < 0 && s->img_number > 1)
return AVERROR(EIO);
}
for (i = 0; i < 3; i++) {
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 65323ec678..b366f94c43 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -205,8 +205,8 @@ static int set_segment_filename(AVFormatContext *s)
av_log(oc, AV_LOG_ERROR, "Could not get segment filename with strftime\n");
return AVERROR(EINVAL);
}
- } else if (av_get_frame_filename(buf, sizeof(buf),
- s->url, seg->segment_idx) < 0) {
+ } else if (av_get_frame_filename3(buf, sizeof(buf),
+ s->url, seg->segment_idx, 0) < 0) {
av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", s->url);
return AVERROR(EINVAL);
}
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 0a7ed1a013..39e8d53e8a 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -116,7 +116,7 @@ int av_filename_number_test(const char *filename)
{
char buf[1024];
return filename &&
- (av_get_frame_filename(buf, sizeof(buf), filename, 1) >= 0);
+ (av_get_frame_filename3(buf, sizeof(buf), filename, 1, 0) >= 0);
}
/**********************************************************/
diff --git a/libavformat/version_major.h b/libavformat/version_major.h
index 7a9b06703d..d2bd8b5162 100644
--- a/libavformat/version_major.h
+++ b/libavformat/version_major.h
@@ -45,7 +45,7 @@
#define FF_API_LAVF_SHORTEST (LIBAVFORMAT_VERSION_MAJOR < 62)
#define FF_API_ALLOW_FLUSH (LIBAVFORMAT_VERSION_MAJOR < 62)
#define FF_API_AVSTREAM_SIDE_DATA (LIBAVFORMAT_VERSION_MAJOR < 62)
-
+#define FF_API_AV_GET_FRAME_FILENAME2 (LIBAVFORMAT_VERSION_MAJOR < 62)
#define FF_API_GET_DUR_ESTIMATE_METHOD (LIBAVFORMAT_VERSION_MAJOR < 62)
#define FF_API_INTERNAL_TIMING (LIBAVFORMAT_VERSION_MAJOR < 62)
diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c
index 255b8697c5..aa6572e69f 100644
--- a/libavformat/webm_chunk.c
+++ b/libavformat/webm_chunk.c
@@ -139,8 +139,8 @@ static int get_chunk_filename(AVFormatContext *s, char filename[MAX_FILENAME_SIZ
if (!filename) {
return AVERROR(EINVAL);
}
- if (av_get_frame_filename(filename, MAX_FILENAME_SIZE,
- s->url, wc->chunk_index - 1) < 0) {
+ if (av_get_frame_filename3(filename, MAX_FILENAME_SIZE,
+ s->url, wc->chunk_index - 1, 0) < 0) {
av_log(s, AV_LOG_ERROR, "Invalid chunk filename template '%s'\n", s->url);
return AVERROR(EINVAL);
}
--
2.46.0.windows.1
More information about the ffmpeg-devel
mailing list