65 char *comp_expr_str[4];
83 #define OFFSET(x) offsetof(LutContext, x)
86 {
"c0",
"set component #0 expression",
OFFSET(comp_expr_str[0]),
FF_OPT_TYPE_STRING, {.str=
"val"}, CHAR_MIN, CHAR_MAX},
87 {
"c1",
"set component #1 expression",
OFFSET(comp_expr_str[1]),
FF_OPT_TYPE_STRING, {.str=
"val"}, CHAR_MIN, CHAR_MAX},
88 {
"c2",
"set component #2 expression",
OFFSET(comp_expr_str[2]),
FF_OPT_TYPE_STRING, {.str=
"val"}, CHAR_MIN, CHAR_MAX},
89 {
"c3",
"set component #3 expression",
OFFSET(comp_expr_str[3]),
FF_OPT_TYPE_STRING, {.str=
"val"}, CHAR_MIN, CHAR_MAX},
136 for (i = 0; i < 4; i++) {
143 #define YUV_FORMATS \
144 PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV420P, \
145 PIX_FMT_YUV411P, PIX_FMT_YUV410P, PIX_FMT_YUV440P, \
147 PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P, \
150 #define RGB_FORMATS \
151 PIX_FMT_ARGB, PIX_FMT_RGBA, \
152 PIX_FMT_ABGR, PIX_FMT_BGRA, \
153 PIX_FMT_RGB24, PIX_FMT_BGR24
173 static double clip(
void *opaque,
double val)
179 return av_clip(val, minval, maxval);
193 return pow((val-minval)/(maxval-minval), gamma) * (maxval-minval)+minval;
196 static double (*
const funcs1[])(
void *, double) = {
230 min[
Y] = min[
U] = min[
V] = 16;
232 max[
U] = max[
V] = 240;
233 min[
A] = 0; max[
A] = 255;
236 min[0] = min[1] = min[2] = min[3] = 0;
237 max[0] = max[1] = max[2] = max[3] = 255;
264 "Error when parsing the expression '%s' for the component %d.\n",
273 for (val = 0; val < 256; val++) {
278 min[comp], max[comp]);
283 "Error when evaluating the expression '%s' for the value %d for the component #%d.\n",
287 lut->
lut[
comp][val] = av_clip((
int)res, min[comp], max[comp]);
302 uint8_t *inrow, *outrow, *inrow0, *outrow0;
310 for (i = 0; i < h; i ++) {
313 for (j = 0; j < inlink->
w; j++) {
314 for (k = 0; k < lut->
step; k++)
324 for (plane = 0; plane < 4 && inpic->
data[plane]; plane++) {
325 int vsub = plane == 1 || plane == 2 ? lut->
vsub : 0;
326 int hsub = plane == 1 || plane == 2 ? lut->
hsub : 0;
328 inrow = inpic ->
data[plane] + (y>>vsub) * inpic ->linesize[plane];
329 outrow = outpic->
data[plane] + (y>>vsub) * outpic->
linesize[plane];
331 for (i = 0; i < h>>vsub; i ++) {
332 for (j = 0; j < inlink->
w>>hsub; j++)
333 outrow[j] = lut->
lut[plane][inrow[j]];
343 #define DEFINE_LUT_FILTER(name_, description_, init_) \
344 AVFilter avfilter_vf_##name_ = { \
346 .description = NULL_IF_CONFIG_SMALL(description_), \
347 .priv_size = sizeof(LutContext), \
351 .query_formats = query_formats, \
353 .inputs = (AVFilterPad[]) {{ .name = "default", \
354 .type = AVMEDIA_TYPE_VIDEO, \
355 .draw_slice = draw_slice, \
356 .config_props = config_props, \
357 .min_perms = AV_PERM_READ, }, \
359 .outputs = (AVFilterPad[]) {{ .name = "default", \
360 .type = AVMEDIA_TYPE_VIDEO, }, \
364 #if CONFIG_LUT_FILTER
367 #if CONFIG_LUTYUV_FILTER
370 #if CONFIG_LUTRGB_FILTER
374 #if CONFIG_NEGATE_FILTER
376 static int negate_init(
AVFilterContext *ctx,
const char *args,
void *opaque)
386 snprintf(lut_params,
sizeof(lut_params),
"c0=negval:c1=negval:c2=negval:a=%s",
389 return init(ctx, lut_params, opaque);