mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-06 07:40:00 +08:00
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.
This commit is contained in:
@ -939,21 +939,6 @@ int ff_default_query_formats(AVFilterContext *ctx)
|
|||||||
|
|
||||||
/* internal functions for parsing audio format arguments */
|
/* 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)
|
int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx)
|
||||||
{
|
{
|
||||||
char *tail;
|
char *tail;
|
||||||
|
@ -35,17 +35,6 @@ int ff_fmt_is_regular_yuv(enum AVPixelFormat fmt);
|
|||||||
|
|
||||||
/* Functions to parse audio format arguments */
|
/* 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.
|
* Parse a sample rate.
|
||||||
*
|
*
|
||||||
|
@ -86,6 +86,21 @@ static av_cold int invert_formats(AVFilterFormats **fmts,
|
|||||||
return 0;
|
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)
|
static av_cold int init(AVFilterContext *ctx)
|
||||||
{
|
{
|
||||||
FormatContext *s = ctx->priv;
|
FormatContext *s = ctx->priv;
|
||||||
@ -96,7 +111,7 @@ static av_cold int init(AVFilterContext *ctx)
|
|||||||
sep = strchr(cur, '|');
|
sep = strchr(cur, '|');
|
||||||
if (sep && *sep)
|
if (sep && *sep)
|
||||||
*sep++ = 0;
|
*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)
|
(ret = ff_add_format(&s->formats, pix_fmt)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user