mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
lavfi/lut: duplicate class definitions for each lut variant filter
This is due to the design of components iteration through AVClass child_class_next() callback, which requires that two components cannot share the same class.
This commit is contained in:
parent
8e2cf68d09
commit
a77436abad
@ -77,7 +77,7 @@ typedef struct {
|
||||
|
||||
#define OFFSET(x) offsetof(LutContext, x)
|
||||
|
||||
static const AVOption lut_options[] = {
|
||||
static const AVOption options[] = {
|
||||
{"c0", "set component #0 expression", OFFSET(comp_expr_str[0]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
|
||||
{"c1", "set component #1 expression", OFFSET(comp_expr_str[1]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
|
||||
{"c2", "set component #2 expression", OFFSET(comp_expr_str[2]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
|
||||
@ -92,24 +92,6 @@ static const AVOption lut_options[] = {
|
||||
{NULL},
|
||||
};
|
||||
|
||||
AVFILTER_DEFINE_CLASS(lut);
|
||||
|
||||
static int init(AVFilterContext *ctx, const char *args)
|
||||
{
|
||||
LutContext *lut = ctx->priv;
|
||||
int ret;
|
||||
|
||||
lut->class = &lut_class;
|
||||
av_opt_set_defaults(lut);
|
||||
|
||||
lut->is_rgb = !strcmp(ctx->filter->name, "lutrgb");
|
||||
lut->is_yuv = !strcmp(ctx->filter->name, "lutyuv");
|
||||
if (args && (ret = av_set_options_string(lut, args, "=", ":")) < 0)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static av_cold void uninit(AVFilterContext *ctx)
|
||||
{
|
||||
LutContext *lut = ctx->priv;
|
||||
@ -349,32 +331,94 @@ static const AVFilterPad outputs[] = {
|
||||
.type = AVMEDIA_TYPE_VIDEO, },
|
||||
{ .name = NULL}
|
||||
};
|
||||
#define DEFINE_LUT_FILTER(name_, description_, init_) \
|
||||
#define DEFINE_LUT_FILTER(name_, description_) \
|
||||
AVFilter avfilter_vf_##name_ = { \
|
||||
.name = #name_, \
|
||||
.description = NULL_IF_CONFIG_SMALL(description_), \
|
||||
.priv_size = sizeof(LutContext), \
|
||||
\
|
||||
.init = init_, \
|
||||
.init = name_##_init, \
|
||||
.uninit = uninit, \
|
||||
.query_formats = query_formats, \
|
||||
\
|
||||
.inputs = inputs, \
|
||||
.outputs = outputs, \
|
||||
.priv_class = &name_##_class, \
|
||||
}
|
||||
|
||||
#if CONFIG_LUT_FILTER
|
||||
DEFINE_LUT_FILTER(lut, "Compute and apply a lookup table to the RGB/YUV input video.", init);
|
||||
|
||||
#define lut_options options
|
||||
AVFILTER_DEFINE_CLASS(lut);
|
||||
|
||||
static int lut_init(AVFilterContext *ctx, const char *args)
|
||||
{
|
||||
LutContext *lut = ctx->priv;
|
||||
int ret;
|
||||
|
||||
lut->class = &lut_class;
|
||||
av_opt_set_defaults(lut);
|
||||
|
||||
if (args && (ret = av_set_options_string(lut, args, "=", ":")) < 0)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_LUT_FILTER(lut, "Compute and apply a lookup table to the RGB/YUV input video.");
|
||||
#endif
|
||||
|
||||
#if CONFIG_LUTYUV_FILTER
|
||||
DEFINE_LUT_FILTER(lutyuv, "Compute and apply a lookup table to the YUV input video.", init);
|
||||
|
||||
#define lutyuv_options options
|
||||
AVFILTER_DEFINE_CLASS(lutyuv);
|
||||
|
||||
static int lutyuv_init(AVFilterContext *ctx, const char *args)
|
||||
{
|
||||
LutContext *lut = ctx->priv;
|
||||
int ret;
|
||||
|
||||
lut->class = &lutyuv_class;
|
||||
lut->is_yuv = 1;
|
||||
av_opt_set_defaults(lut);
|
||||
|
||||
if (args && (ret = av_set_options_string(lut, args, "=", ":")) < 0)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_LUT_FILTER(lutyuv, "Compute and apply a lookup table to the YUV input video.");
|
||||
#endif
|
||||
|
||||
#if CONFIG_LUTRGB_FILTER
|
||||
DEFINE_LUT_FILTER(lutrgb, "Compute and apply a lookup table to the RGB input video.", init);
|
||||
|
||||
#define lutrgb_options options
|
||||
AVFILTER_DEFINE_CLASS(lutrgb);
|
||||
|
||||
static int lutrgb_init(AVFilterContext *ctx, const char *args)
|
||||
{
|
||||
LutContext *lut = ctx->priv;
|
||||
int ret;
|
||||
|
||||
lut->class = &lutrgb_class;
|
||||
lut->is_rgb = 1;
|
||||
av_opt_set_defaults(lut);
|
||||
|
||||
if (args && (ret = av_set_options_string(lut, args, "=", ":")) < 0)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_LUT_FILTER(lutrgb, "Compute and apply a lookup table to the RGB input video.");
|
||||
#endif
|
||||
|
||||
#if CONFIG_NEGATE_FILTER
|
||||
|
||||
#define negate_options options
|
||||
AVFILTER_DEFINE_CLASS(negate);
|
||||
|
||||
static int negate_init(AVFilterContext *ctx, const char *args)
|
||||
{
|
||||
LutContext *lut = ctx->priv;
|
||||
@ -388,9 +432,12 @@ static int negate_init(AVFilterContext *ctx, const char *args)
|
||||
snprintf(lut_params, sizeof(lut_params), "c0=negval:c1=negval:c2=negval:a=%s",
|
||||
lut->negate_alpha ? "negval" : "val");
|
||||
|
||||
return init(ctx, lut_params);
|
||||
lut->class = &negate_class;
|
||||
av_opt_set_defaults(lut);
|
||||
|
||||
return av_set_options_string(lut, lut_params, "=", ":");
|
||||
}
|
||||
|
||||
DEFINE_LUT_FILTER(negate, "Negate input video.", negate_init);
|
||||
DEFINE_LUT_FILTER(negate, "Negate input video.");
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user