aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-08-15 22:00:50 +0200
committerAnton Khirnov <anton@khirnov.net>2024-08-19 21:45:25 +0200
commitf4bfdf789335e690dd92c9ee85974c338429103a (patch)
tree75811022759791ef0f97dee7fcd30f1df0063cc5
parent1afe42852b25c6bf74f1f5b5f6d6dfa42da02434 (diff)
downloadffmpeg-f4bfdf789335e690dd92c9ee85974c338429103a.tar.gz
lavfi: move ff_parse_pixel_format() to vf_format, its only caller
The only thing this function does beyond calling av_get_pix_fmt() is falling back onto parsing the argument as a number. No other filters should need to do this.
-rw-r--r--libavfilter/formats.c15
-rw-r--r--libavfilter/internal.h11
-rw-r--r--libavfilter/vf_format.c17
3 files changed, 16 insertions, 27 deletions
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 15099ac545..18f7b89104 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -939,21 +939,6 @@ int ff_default_query_formats(AVFilterContext *ctx)
/* internal functions for parsing audio format arguments */
-int ff_parse_pixel_format(enum AVPixelFormat *ret, const char *arg, void *log_ctx)
-{
- char *tail;
- int pix_fmt = av_get_pix_fmt(arg);
- if (pix_fmt == AV_PIX_FMT_NONE) {
- pix_fmt = strtol(arg, &tail, 0);
- if (*tail || !av_pix_fmt_desc_get(pix_fmt)) {
- av_log(log_ctx, AV_LOG_ERROR, "Invalid pixel format '%s'\n", arg);
- return AVERROR(EINVAL);
- }
- }
- *ret = pix_fmt;
- return 0;
-}
-
int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx)
{
char *tail;
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index 4938612593..343bc0b330 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -36,17 +36,6 @@ int ff_fmt_is_regular_yuv(enum AVPixelFormat fmt);
/* Functions to parse audio format arguments */
/**
- * Parse a pixel format.
- *
- * @param ret pixel format pointer to where the value should be written
- * @param arg string to parse
- * @param log_ctx log context
- * @return >= 0 in case of success, a negative AVERROR code on error
- */
-av_warn_unused_result
-int ff_parse_pixel_format(enum AVPixelFormat *ret, const char *arg, void *log_ctx);
-
-/**
* Parse a sample rate.
*
* @param ret unsigned integer pointer to where the value should be written
diff --git a/libavfilter/vf_format.c b/libavfilter/vf_format.c
index 2b88b10f65..83deff7190 100644
--- a/libavfilter/vf_format.c
+++ b/libavfilter/vf_format.c
@@ -86,6 +86,21 @@ static av_cold int invert_formats(AVFilterFormats **fmts,
return 0;
}
+static int parse_pixel_format(enum AVPixelFormat *ret, const char *arg, void *log_ctx)
+{
+ char *tail;
+ int pix_fmt = av_get_pix_fmt(arg);
+ if (pix_fmt == AV_PIX_FMT_NONE) {
+ pix_fmt = strtol(arg, &tail, 0);
+ if (*tail || !av_pix_fmt_desc_get(pix_fmt)) {
+ av_log(log_ctx, AV_LOG_ERROR, "Invalid pixel format '%s'\n", arg);
+ return AVERROR(EINVAL);
+ }
+ }
+ *ret = pix_fmt;
+ return 0;
+}
+
static av_cold int init(AVFilterContext *ctx)
{
FormatContext *s = ctx->priv;
@@ -96,7 +111,7 @@ static av_cold int init(AVFilterContext *ctx)
sep = strchr(cur, '|');
if (sep && *sep)
*sep++ = 0;
- if ((ret = ff_parse_pixel_format(&pix_fmt, cur, ctx)) < 0 ||
+ if ((ret = parse_pixel_format(&pix_fmt, cur, ctx)) < 0 ||
(ret = ff_add_format(&s->formats, pix_fmt)) < 0)
return ret;
}