69 char *comp_expr_str[4];
87 #define OFFSET(x) offsetof(LutContext, x)
88 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM
124 for (i = 0; i < 4; i++) {
131 #define YUV_FORMATS \
132 AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, \
133 AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV440P, \
134 AV_PIX_FMT_YUVA420P, \
135 AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P, \
138 #define RGB_FORMATS \
139 AV_PIX_FMT_ARGB, AV_PIX_FMT_RGBA, \
140 AV_PIX_FMT_ABGR, AV_PIX_FMT_BGRA, \
141 AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24
162 static double clip(
void *opaque,
double val)
168 return av_clip(val, minval, maxval);
182 return pow((val-minval)/(maxval-minval), gamma) * (maxval-minval)+minval;
185 static double (*
const funcs1[])(
void *, double) = {
219 min[
Y] = min[
U] = min[
V] = 16;
221 max[
U] = max[
V] = 240;
222 min[
A] = 0; max[
A] = 255;
225 min[0] = min[1] = min[2] = min[3] = 0;
226 max[0] = max[1] = max[2] = max[3] = 255;
255 "Error when parsing the expression '%s' for the component %d.\n",
264 for (val = 0; val < 256; val++) {
269 min[comp], max[comp]);
274 "Error when evaluating the expression '%s' for the value %d for the component #%d.\n",
278 s->
lut[
comp][val] = av_clip((
int)res, min[comp], max[comp]);
292 uint8_t *inrow, *outrow, *inrow0, *outrow0;
304 inrow0 = in ->
data[0];
305 outrow0 = out->
data[0];
307 for (i = 0; i < in->
height; i ++) {
310 for (j = 0; j < inlink->
w; j++) {
311 for (k = 0; k < s->
step; k++)
321 for (plane = 0; plane < 4 && in->
data[plane]; plane++) {
322 int vsub = plane == 1 || plane == 2 ? s->
vsub : 0;
323 int hsub = plane == 1 || plane == 2 ? s->
hsub : 0;
325 inrow = in ->
data[plane];
326 outrow = out->
data[plane];
328 for (i = 0; i < in->
height >> vsub; i ++) {
329 for (j = 0; j < inlink->
w>>hsub; j++)
330 outrow[j] = s->
lut[plane][inrow[j]];
354 #define DEFINE_LUT_FILTER(name_, description_, init_, options) \
355 static const AVClass name_ ## _class = { \
356 .class_name = #name_, \
357 .item_name = av_default_item_name, \
359 .version = LIBAVUTIL_VERSION_INT, \
361 AVFilter ff_vf_##name_ = { \
363 .description = NULL_IF_CONFIG_SMALL(description_), \
364 .priv_size = sizeof(LutContext), \
365 .priv_class = &name_ ## _class, \
369 .query_formats = query_formats, \
372 .outputs = outputs, \
375 #if CONFIG_LUT_FILTER
376 DEFINE_LUT_FILTER(lut,
"Compute and apply a lookup table to the RGB/YUV input video.",
init, lut_options);
378 #if CONFIG_LUTYUV_FILTER
379 DEFINE_LUT_FILTER(lutyuv,
"Compute and apply a lookup table to the YUV input video.",
init, lut_options);
381 #if CONFIG_LUTRGB_FILTER
382 DEFINE_LUT_FILTER(lutrgb,
"Compute and apply a lookup table to the RGB input video.",
init, lut_options);
385 #if CONFIG_NEGATE_FILTER
387 static const AVOption negate_options[] = {
399 for (i = 0; i < 4; i++) {