#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
+#include "internal.h"
static const char *var_names[] = {
- "E",
- "PHI",
- "PI",
"w", ///< width of the input video
"h", ///< height of the input video
"val", ///< input value for the pixel
};
enum var_name {
- VAR_E,
- VAR_PHI,
- VAR_PI,
VAR_W,
VAR_H,
VAR_VAL,
#define OFFSET(x) offsetof(LutContext, x)
static const AVOption lut_options[] = {
- {"c0", "set component #0 expression", OFFSET(comp_expr_str[0]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
- {"c1", "set component #1 expression", OFFSET(comp_expr_str[1]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
- {"c2", "set component #2 expression", OFFSET(comp_expr_str[2]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
- {"c3", "set component #3 expression", OFFSET(comp_expr_str[3]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
- {"y", "set Y expression", OFFSET(comp_expr_str[Y]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
- {"u", "set U expression", OFFSET(comp_expr_str[U]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
- {"v", "set V expression", OFFSET(comp_expr_str[V]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
- {"r", "set R expression", OFFSET(comp_expr_str[R]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
- {"g", "set G expression", OFFSET(comp_expr_str[G]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
- {"b", "set B expression", OFFSET(comp_expr_str[B]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
- {"a", "set A expression", OFFSET(comp_expr_str[A]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
+ {"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},
+ {"c3", "set component #3 expression", OFFSET(comp_expr_str[3]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
+ {"y", "set Y expression", OFFSET(comp_expr_str[Y]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
+ {"u", "set U expression", OFFSET(comp_expr_str[U]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
+ {"v", "set V expression", OFFSET(comp_expr_str[V]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
+ {"r", "set R expression", OFFSET(comp_expr_str[R]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
+ {"g", "set G expression", OFFSET(comp_expr_str[G]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
+ {"b", "set B expression", OFFSET(comp_expr_str[B]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
+ {"a", "set A expression", OFFSET(comp_expr_str[A]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX},
{NULL},
};
int ret;
lut->class = &lut_class;
- av_opt_set_defaults2(lut, 0, 0);
-
- lut->var_values[VAR_PHI] = M_PHI;
- lut->var_values[VAR_PI] = M_PI;
- lut->var_values[VAR_E ] = M_E;
+ av_opt_set_defaults(lut);
lut->is_rgb = !strcmp(ctx->filter->name, "lutrgb");
lut->is_yuv = !strcmp(ctx->filter->name, "lutyuv");
return 0;
}
-static int pix_fmt_is_in(enum PixelFormat pix_fmt, enum PixelFormat *pix_fmts)
-{
- enum PixelFormat *p;
- for (p = pix_fmts; *p != PIX_FMT_NONE; p++) {
- if (pix_fmt == *p)
- return 1;
- }
- return 0;
-}
-
/**
* Clip value val in the minval - maxval range.
*/
min[Y] = min[U] = min[V] = 16;
max[Y] = 235;
max[U] = max[V] = 240;
+ min[A] = 0; max[A] = 255;
break;
default:
min[0] = min[1] = min[2] = min[3] = 0;
}
lut->is_yuv = lut->is_rgb = 0;
- if (pix_fmt_is_in(inlink->format, yuv_pix_fmts)) lut->is_yuv = 1;
- else if (pix_fmt_is_in(inlink->format, rgb_pix_fmts)) lut->is_rgb = 1;
+ if (ff_fmt_is_in(inlink->format, yuv_pix_fmts)) lut->is_yuv = 1;
+ else if (ff_fmt_is_in(inlink->format, rgb_pix_fmts)) lut->is_rgb = 1;
if (lut->is_rgb) {
switch (inlink->format) {
}
} else {
/* planar */
- for (plane = 0; inpic->data[plane]; plane++) {
+ for (plane = 0; plane < 4 && inpic->data[plane]; plane++) {
int vsub = plane == 1 || plane == 2 ? lut->vsub : 0;
int hsub = plane == 1 || plane == 2 ? lut->hsub : 0;
#define DEFINE_LUT_FILTER(name_, description_, init_) \
AVFilter avfilter_vf_##name_ = { \
- .name = NULL_IF_CONFIG_SMALL(#name_), \
- .description = description_, \
+ .name = #name_, \
+ .description = NULL_IF_CONFIG_SMALL(description_), \
.priv_size = sizeof(LutContext), \
\
.init = init_, \
{ .name = NULL}}, \
}
+#if CONFIG_LUT_FILTER
DEFINE_LUT_FILTER(lut, "Compute and apply a lookup table to the RGB/YUV input video.", init);
+#endif
+#if CONFIG_LUTYUV_FILTER
DEFINE_LUT_FILTER(lutyuv, "Compute and apply a lookup table to the YUV input video.", init);
+#endif
+#if CONFIG_LUTRGB_FILTER
DEFINE_LUT_FILTER(lutrgb, "Compute and apply a lookup table to the RGB input video.", init);
+#endif
#if CONFIG_NEGATE_FILTER
static int negate_init(AVFilterContext *ctx, const char *args, void *opaque)
{
LutContext *lut = ctx->priv;
- char lut_params[1024];
+ char lut_params[64];
if (args)
sscanf(args, "%d", &lut->negate_alpha);
- av_log(ctx, AV_LOG_INFO, "negate_alpha:%d\n", lut->negate_alpha);
+ av_log(ctx, AV_LOG_DEBUG, "negate_alpha:%d\n", lut->negate_alpha);
snprintf(lut_params, sizeof(lut_params), "c0=negval:c1=negval:c2=negval:a=%s",
lut->negate_alpha ? "negval" : "val");
DEFINE_LUT_FILTER(negate, "Negate input video.", negate_init);
-#endif
+#endif
\ No newline at end of file