summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2012-08-09 17:48:03 +0200
committerStefano Sabatini <stefasab@gmail.com>2012-08-18 10:04:25 +0200
commita77436abad9e68a35cf1cf493f4c3a1dfb6f4c6c (patch)
treebfdc99acb3c8b62933f4d697af8aeea6bf432ba4 /libavfilter
parent8e2cf68d091ad59749aab085c2c08091ddbeea76 (diff)
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.
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_lut.c99
1 files changed, 73 insertions, 26 deletions
diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c
index 3fd8d42bcd..1afd7b77fa 100644
--- a/libavfilter/vf_lut.c
+++ b/libavfilter/vf_lut.c
@@ -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