FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vf_curves.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Clément Bœsch
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/opt.h"
22 #include "libavutil/bprint.h"
23 #include "libavutil/eval.h"
24 #include "libavutil/file.h"
25 #include "libavutil/intreadwrite.h"
26 #include "libavutil/avassert.h"
27 #include "libavutil/pixdesc.h"
28 #include "avfilter.h"
29 #include "drawutils.h"
30 #include "formats.h"
31 #include "internal.h"
32 #include "video.h"
33 
34 #define R 0
35 #define G 1
36 #define B 2
37 #define A 3
38 
39 struct keypoint {
40  double x, y;
41  struct keypoint *next;
42 };
43 
44 #define NB_COMP 3
45 
46 enum preset {
59 };
60 
61 typedef struct CurvesContext {
62  const AVClass *class;
63  int preset;
66  uint16_t *graph[NB_COMP + 1];
67  int lut_size;
68  char *psfile;
70  int step;
72  int is_16bit;
73  int depth;
74 
75  int (*filter_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
77 
78 typedef struct ThreadData {
79  AVFrame *in, *out;
80 } ThreadData;
81 
82 #define OFFSET(x) offsetof(CurvesContext, x)
83 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
84 static const AVOption curves_options[] = {
85  { "preset", "select a color curves preset", OFFSET(preset), AV_OPT_TYPE_INT, {.i64=PRESET_NONE}, PRESET_NONE, NB_PRESETS-1, FLAGS, "preset_name" },
86  { "none", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_NONE}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
87  { "color_negative", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_COLOR_NEGATIVE}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
88  { "cross_process", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_CROSS_PROCESS}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
89  { "darker", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_DARKER}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
90  { "increase_contrast", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_INCREASE_CONTRAST}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
91  { "lighter", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_LIGHTER}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
92  { "linear_contrast", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_LINEAR_CONTRAST}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
93  { "medium_contrast", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_MEDIUM_CONTRAST}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
94  { "negative", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_NEGATIVE}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
95  { "strong_contrast", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_STRONG_CONTRAST}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
96  { "vintage", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_VINTAGE}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
97  { "master","set master points coordinates",OFFSET(comp_points_str[NB_COMP]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
98  { "m", "set master points coordinates",OFFSET(comp_points_str[NB_COMP]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
99  { "red", "set red points coordinates", OFFSET(comp_points_str[0]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
100  { "r", "set red points coordinates", OFFSET(comp_points_str[0]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
101  { "green", "set green points coordinates", OFFSET(comp_points_str[1]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
102  { "g", "set green points coordinates", OFFSET(comp_points_str[1]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
103  { "blue", "set blue points coordinates", OFFSET(comp_points_str[2]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
104  { "b", "set blue points coordinates", OFFSET(comp_points_str[2]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
105  { "all", "set points coordinates for all components", OFFSET(comp_points_str_all), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
106  { "psfile", "set Photoshop curves file name", OFFSET(psfile), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
107  { "plot", "save Gnuplot script of the curves in specified file", OFFSET(plot_filename), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
108  { NULL }
109 };
110 
111 AVFILTER_DEFINE_CLASS(curves);
112 
113 static const struct {
114  const char *r;
115  const char *g;
116  const char *b;
117  const char *master;
118 } curves_presets[] = {
120  "0.129/1 0.466/0.498 0.725/0",
121  "0.109/1 0.301/0.498 0.517/0",
122  "0.098/1 0.235/0.498 0.423/0",
123  },
125  "0/0 0.25/0.156 0.501/0.501 0.686/0.745 1/1",
126  "0/0 0.25/0.188 0.38/0.501 0.745/0.815 1/0.815",
127  "0/0 0.231/0.094 0.709/0.874 1/1",
128  },
129  [PRESET_DARKER] = { .master = "0/0 0.5/0.4 1/1" },
130  [PRESET_INCREASE_CONTRAST] = { .master = "0/0 0.149/0.066 0.831/0.905 0.905/0.98 1/1" },
131  [PRESET_LIGHTER] = { .master = "0/0 0.4/0.5 1/1" },
132  [PRESET_LINEAR_CONTRAST] = { .master = "0/0 0.305/0.286 0.694/0.713 1/1" },
133  [PRESET_MEDIUM_CONTRAST] = { .master = "0/0 0.286/0.219 0.639/0.643 1/1" },
134  [PRESET_NEGATIVE] = { .master = "0/1 1/0" },
135  [PRESET_STRONG_CONTRAST] = { .master = "0/0 0.301/0.196 0.592/0.6 0.686/0.737 1/1" },
136  [PRESET_VINTAGE] = {
137  "0/0.11 0.42/0.51 1/0.95",
138  "0/0 0.50/0.48 1/1",
139  "0/0.22 0.49/0.44 1/0.8",
140  }
141 };
142 
143 static struct keypoint *make_point(double x, double y, struct keypoint *next)
144 {
145  struct keypoint *point = av_mallocz(sizeof(*point));
146 
147  if (!point)
148  return NULL;
149  point->x = x;
150  point->y = y;
151  point->next = next;
152  return point;
153 }
154 
155 static int parse_points_str(AVFilterContext *ctx, struct keypoint **points, const char *s,
156  int lut_size)
157 {
158  char *p = (char *)s; // strtod won't alter the string
159  struct keypoint *last = NULL;
160  const int scale = lut_size - 1;
161 
162  /* construct a linked list based on the key points string */
163  while (p && *p) {
164  struct keypoint *point = make_point(0, 0, NULL);
165  if (!point)
166  return AVERROR(ENOMEM);
167  point->x = av_strtod(p, &p); if (p && *p) p++;
168  point->y = av_strtod(p, &p); if (p && *p) p++;
169  if (point->x < 0 || point->x > 1 || point->y < 0 || point->y > 1) {
170  av_log(ctx, AV_LOG_ERROR, "Invalid key point coordinates (%f;%f), "
171  "x and y must be in the [0;1] range.\n", point->x, point->y);
172  return AVERROR(EINVAL);
173  }
174  if (!*points)
175  *points = point;
176  if (last) {
177  if ((int)(last->x * scale) >= (int)(point->x * scale)) {
178  av_log(ctx, AV_LOG_ERROR, "Key point coordinates (%f;%f) "
179  "and (%f;%f) are too close from each other or not "
180  "strictly increasing on the x-axis\n",
181  last->x, last->y, point->x, point->y);
182  return AVERROR(EINVAL);
183  }
184  last->next = point;
185  }
186  last = point;
187  }
188 
189  if (*points && !(*points)->next) {
190  av_log(ctx, AV_LOG_WARNING, "Only one point (at (%f;%f)) is defined, "
191  "this is unlikely to behave as you expect. You probably want"
192  "at least 2 points.",
193  (*points)->x, (*points)->y);
194  }
195 
196  return 0;
197 }
198 
199 static int get_nb_points(const struct keypoint *d)
200 {
201  int n = 0;
202  while (d) {
203  n++;
204  d = d->next;
205  }
206  return n;
207 }
208 
209 /**
210  * Natural cubic spline interpolation
211  * Finding curves using Cubic Splines notes by Steven Rauch and John Stockie.
212  * @see http://people.math.sfu.ca/~stockie/teaching/macm316/notes/splines.pdf
213  */
214 
215 #define CLIP(v) (nbits == 8 ? av_clip_uint8(v) : av_clip_uintp2_c(v, nbits))
216 
217 static inline int interpolate(void *log_ctx, uint16_t *y,
218  const struct keypoint *points, int nbits)
219 {
220  int i, ret = 0;
221  const struct keypoint *point = points;
222  double xprev = 0;
223  const int lut_size = 1<<nbits;
224  const int scale = lut_size - 1;
225 
226  double (*matrix)[3];
227  double *h, *r;
228  const int n = get_nb_points(points); // number of splines
229 
230  if (n == 0) {
231  for (i = 0; i < lut_size; i++)
232  y[i] = i;
233  return 0;
234  }
235 
236  if (n == 1) {
237  for (i = 0; i < lut_size; i++)
238  y[i] = CLIP(point->y * scale);
239  return 0;
240  }
241 
242  matrix = av_calloc(n, sizeof(*matrix));
243  h = av_malloc((n - 1) * sizeof(*h));
244  r = av_calloc(n, sizeof(*r));
245 
246  if (!matrix || !h || !r) {
247  ret = AVERROR(ENOMEM);
248  goto end;
249  }
250 
251  /* h(i) = x(i+1) - x(i) */
252  i = -1;
253  for (point = points; point; point = point->next) {
254  if (i != -1)
255  h[i] = point->x - xprev;
256  xprev = point->x;
257  i++;
258  }
259 
260  /* right-side of the polynomials, will be modified to contains the solution */
261  point = points;
262  for (i = 1; i < n - 1; i++) {
263  const double yp = point->y;
264  const double yc = point->next->y;
265  const double yn = point->next->next->y;
266  r[i] = 6 * ((yn-yc)/h[i] - (yc-yp)/h[i-1]);
267  point = point->next;
268  }
269 
270 #define BD 0 /* sub diagonal (below main) */
271 #define MD 1 /* main diagonal (center) */
272 #define AD 2 /* sup diagonal (above main) */
273 
274  /* left side of the polynomials into a tridiagonal matrix. */
275  matrix[0][MD] = matrix[n - 1][MD] = 1;
276  for (i = 1; i < n - 1; i++) {
277  matrix[i][BD] = h[i-1];
278  matrix[i][MD] = 2 * (h[i-1] + h[i]);
279  matrix[i][AD] = h[i];
280  }
281 
282  /* tridiagonal solving of the linear system */
283  for (i = 1; i < n; i++) {
284  const double den = matrix[i][MD] - matrix[i][BD] * matrix[i-1][AD];
285  const double k = den ? 1./den : 1.;
286  matrix[i][AD] *= k;
287  r[i] = (r[i] - matrix[i][BD] * r[i - 1]) * k;
288  }
289  for (i = n - 2; i >= 0; i--)
290  r[i] = r[i] - matrix[i][AD] * r[i + 1];
291 
292  point = points;
293 
294  /* left padding */
295  for (i = 0; i < (int)(point->x * scale); i++)
296  y[i] = CLIP(point->y * scale);
297 
298  /* compute the graph with x=[x0..xN] */
299  i = 0;
300  av_assert0(point->next); // always at least 2 key points
301  while (point->next) {
302  const double yc = point->y;
303  const double yn = point->next->y;
304 
305  const double a = yc;
306  const double b = (yn-yc)/h[i] - h[i]*r[i]/2. - h[i]*(r[i+1]-r[i])/6.;
307  const double c = r[i] / 2.;
308  const double d = (r[i+1] - r[i]) / (6.*h[i]);
309 
310  int x;
311  const int x_start = point->x * scale;
312  const int x_end = point->next->x * scale;
313 
314  av_assert0(x_start >= 0 && x_start < lut_size &&
315  x_end >= 0 && x_end < lut_size);
316 
317  for (x = x_start; x <= x_end; x++) {
318  const double xx = (x - x_start) * 1./scale;
319  const double yy = a + b*xx + c*xx*xx + d*xx*xx*xx;
320  y[x] = CLIP(yy * scale);
321  av_log(log_ctx, AV_LOG_DEBUG, "f(%f)=%f -> y[%d]=%d\n", xx, yy, x, y[x]);
322  }
323 
324  point = point->next;
325  i++;
326  }
327 
328  /* right padding */
329  for (i = (int)(point->x * scale); i < lut_size; i++)
330  y[i] = CLIP(point->y * scale);
331 
332 end:
333  av_free(matrix);
334  av_free(h);
335  av_free(r);
336  return ret;
337 }
338 
339 #define DECLARE_INTERPOLATE_FUNC(nbits) \
340 static int interpolate##nbits(void *log_ctx, uint16_t *y, \
341  const struct keypoint *points) \
342 { \
343  return interpolate(log_ctx, y, points, nbits); \
344 }
345 
352 
353 static int parse_psfile(AVFilterContext *ctx, const char *fname)
354 {
355  CurvesContext *curves = ctx->priv;
356  uint8_t *buf;
357  size_t size;
358  int i, ret, av_unused(version), nb_curves;
359  AVBPrint ptstr;
360  static const int comp_ids[] = {3, 0, 1, 2};
361 
363 
364  ret = av_file_map(fname, &buf, &size, 0, NULL);
365  if (ret < 0)
366  return ret;
367 
368 #define READ16(dst) do { \
369  if (size < 2) { \
370  ret = AVERROR_INVALIDDATA; \
371  goto end; \
372  } \
373  dst = AV_RB16(buf); \
374  buf += 2; \
375  size -= 2; \
376 } while (0)
377 
378  READ16(version);
379  READ16(nb_curves);
380  for (i = 0; i < FFMIN(nb_curves, FF_ARRAY_ELEMS(comp_ids)); i++) {
381  int nb_points, n;
382  av_bprint_clear(&ptstr);
383  READ16(nb_points);
384  for (n = 0; n < nb_points; n++) {
385  int y, x;
386  READ16(y);
387  READ16(x);
388  av_bprintf(&ptstr, "%f/%f ", x / 255., y / 255.);
389  }
390  if (*ptstr.str) {
391  char **pts = &curves->comp_points_str[comp_ids[i]];
392  if (!*pts) {
393  *pts = av_strdup(ptstr.str);
394  av_log(ctx, AV_LOG_DEBUG, "curves %d (intid=%d) [%d points]: [%s]\n",
395  i, comp_ids[i], nb_points, *pts);
396  if (!*pts) {
397  ret = AVERROR(ENOMEM);
398  goto end;
399  }
400  }
401  }
402  }
403 end:
404  av_bprint_finalize(&ptstr, NULL);
405  av_file_unmap(buf, size);
406  return ret;
407 }
408 
409 static int dump_curves(const char *fname, uint16_t *graph[NB_COMP + 1],
410  struct keypoint *comp_points[NB_COMP + 1],
411  int lut_size)
412 {
413  int i;
414  AVBPrint buf;
415  const double scale = 1. / (lut_size - 1);
416  static const char * const colors[] = { "red", "green", "blue", "#404040", };
417  FILE *f = av_fopen_utf8(fname, "w");
418 
419  av_assert0(FF_ARRAY_ELEMS(colors) == NB_COMP + 1);
420 
421  if (!f) {
422  int ret = AVERROR(errno);
423  av_log(NULL, AV_LOG_ERROR, "Cannot open file '%s' for writing: %s\n",
424  fname, av_err2str(ret));
425  return ret;
426  }
427 
429 
430  av_bprintf(&buf, "set xtics 0.1\n");
431  av_bprintf(&buf, "set ytics 0.1\n");
432  av_bprintf(&buf, "set size square\n");
433  av_bprintf(&buf, "set grid\n");
434 
435  for (i = 0; i < FF_ARRAY_ELEMS(colors); i++) {
436  av_bprintf(&buf, "%s'-' using 1:2 with lines lc '%s' title ''",
437  i ? ", " : "plot ", colors[i]);
438  if (comp_points[i])
439  av_bprintf(&buf, ", '-' using 1:2 with points pointtype 3 lc '%s' title ''",
440  colors[i]);
441  }
442  av_bprintf(&buf, "\n");
443 
444  for (i = 0; i < FF_ARRAY_ELEMS(colors); i++) {
445  int x;
446 
447  /* plot generated values */
448  for (x = 0; x < lut_size; x++)
449  av_bprintf(&buf, "%f %f\n", x * scale, graph[i][x] * scale);
450  av_bprintf(&buf, "e\n");
451 
452  /* plot user knots */
453  if (comp_points[i]) {
454  const struct keypoint *point = comp_points[i];
455 
456  while (point) {
457  av_bprintf(&buf, "%f %f\n", point->x, point->y);
458  point = point->next;
459  }
460  av_bprintf(&buf, "e\n");
461  }
462  }
463 
464  fwrite(buf.str, 1, buf.len, f);
465  fclose(f);
466  av_bprint_finalize(&buf, NULL);
467  return 0;
468 }
469 
471 {
472  int i, ret;
473  CurvesContext *curves = ctx->priv;
474  char **pts = curves->comp_points_str;
475  const char *allp = curves->comp_points_str_all;
476 
477  //if (!allp && curves->preset != PRESET_NONE && curves_presets[curves->preset].all)
478  // allp = curves_presets[curves->preset].all;
479 
480  if (allp) {
481  for (i = 0; i < NB_COMP; i++) {
482  if (!pts[i])
483  pts[i] = av_strdup(allp);
484  if (!pts[i])
485  return AVERROR(ENOMEM);
486  }
487  }
488 
489  if (curves->psfile) {
490  ret = parse_psfile(ctx, curves->psfile);
491  if (ret < 0)
492  return ret;
493  }
494 
495  if (curves->preset != PRESET_NONE) {
496 #define SET_COMP_IF_NOT_SET(n, name) do { \
497  if (!pts[n] && curves_presets[curves->preset].name) { \
498  pts[n] = av_strdup(curves_presets[curves->preset].name); \
499  if (!pts[n]) \
500  return AVERROR(ENOMEM); \
501  } \
502 } while (0)
507  }
508 
509  return 0;
510 }
511 
513 {
514  static const enum AVPixelFormat pix_fmts[] = {
529  };
530  AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
531  if (!fmts_list)
532  return AVERROR(ENOMEM);
533  return ff_set_common_formats(ctx, fmts_list);
534 }
535 
536 static int filter_slice_packed(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
537 {
538  int x, y;
539  const CurvesContext *curves = ctx->priv;
540  const ThreadData *td = arg;
541  const AVFrame *in = td->in;
542  const AVFrame *out = td->out;
543  const int direct = out == in;
544  const int step = curves->step;
545  const uint8_t r = curves->rgba_map[R];
546  const uint8_t g = curves->rgba_map[G];
547  const uint8_t b = curves->rgba_map[B];
548  const uint8_t a = curves->rgba_map[A];
549  const int slice_start = (in->height * jobnr ) / nb_jobs;
550  const int slice_end = (in->height * (jobnr+1)) / nb_jobs;
551 
552  if (curves->is_16bit) {
553  for (y = slice_start; y < slice_end; y++) {
554  uint16_t *dstp = ( uint16_t *)(out->data[0] + y * out->linesize[0]);
555  const uint16_t *srcp = (const uint16_t *)(in ->data[0] + y * in->linesize[0]);
556 
557  for (x = 0; x < in->width * step; x += step) {
558  dstp[x + r] = curves->graph[R][srcp[x + r]];
559  dstp[x + g] = curves->graph[G][srcp[x + g]];
560  dstp[x + b] = curves->graph[B][srcp[x + b]];
561  if (!direct && step == 4)
562  dstp[x + a] = srcp[x + a];
563  }
564  }
565  } else {
566  uint8_t *dst = out->data[0] + slice_start * out->linesize[0];
567  const uint8_t *src = in->data[0] + slice_start * in->linesize[0];
568 
569  for (y = slice_start; y < slice_end; y++) {
570  for (x = 0; x < in->width * step; x += step) {
571  dst[x + r] = curves->graph[R][src[x + r]];
572  dst[x + g] = curves->graph[G][src[x + g]];
573  dst[x + b] = curves->graph[B][src[x + b]];
574  if (!direct && step == 4)
575  dst[x + a] = src[x + a];
576  }
577  dst += out->linesize[0];
578  src += in ->linesize[0];
579  }
580  }
581  return 0;
582 }
583 
584 static int filter_slice_planar(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
585 {
586  int x, y;
587  const CurvesContext *curves = ctx->priv;
588  const ThreadData *td = arg;
589  const AVFrame *in = td->in;
590  const AVFrame *out = td->out;
591  const int direct = out == in;
592  const int step = curves->step;
593  const uint8_t r = curves->rgba_map[R];
594  const uint8_t g = curves->rgba_map[G];
595  const uint8_t b = curves->rgba_map[B];
596  const uint8_t a = curves->rgba_map[A];
597  const int slice_start = (in->height * jobnr ) / nb_jobs;
598  const int slice_end = (in->height * (jobnr+1)) / nb_jobs;
599 
600  if (curves->is_16bit) {
601  for (y = slice_start; y < slice_end; y++) {
602  uint16_t *dstrp = ( uint16_t *)(out->data[r] + y * out->linesize[r]);
603  uint16_t *dstgp = ( uint16_t *)(out->data[g] + y * out->linesize[g]);
604  uint16_t *dstbp = ( uint16_t *)(out->data[b] + y * out->linesize[b]);
605  uint16_t *dstap = ( uint16_t *)(out->data[a] + y * out->linesize[a]);
606  const uint16_t *srcrp = (const uint16_t *)(in ->data[r] + y * in->linesize[r]);
607  const uint16_t *srcgp = (const uint16_t *)(in ->data[g] + y * in->linesize[g]);
608  const uint16_t *srcbp = (const uint16_t *)(in ->data[b] + y * in->linesize[b]);
609  const uint16_t *srcap = (const uint16_t *)(in ->data[a] + y * in->linesize[a]);
610 
611  for (x = 0; x < in->width; x++) {
612  dstrp[x] = curves->graph[R][srcrp[x]];
613  dstgp[x] = curves->graph[G][srcgp[x]];
614  dstbp[x] = curves->graph[B][srcbp[x]];
615  if (!direct && step == 4)
616  dstap[x] = srcap[x];
617  }
618  }
619  } else {
620  uint8_t *dstr = out->data[r] + slice_start * out->linesize[r];
621  uint8_t *dstg = out->data[g] + slice_start * out->linesize[g];
622  uint8_t *dstb = out->data[b] + slice_start * out->linesize[b];
623  uint8_t *dsta = out->data[a] + slice_start * out->linesize[a];
624  const uint8_t *srcr = in->data[r] + slice_start * in->linesize[r];
625  const uint8_t *srcg = in->data[g] + slice_start * in->linesize[g];
626  const uint8_t *srcb = in->data[b] + slice_start * in->linesize[b];
627  const uint8_t *srca = in->data[a] + slice_start * in->linesize[a];
628 
629  for (y = slice_start; y < slice_end; y++) {
630  for (x = 0; x < in->width; x++) {
631  dstr[x] = curves->graph[R][srcr[x]];
632  dstg[x] = curves->graph[G][srcg[x]];
633  dstb[x] = curves->graph[B][srcb[x]];
634  if (!direct && step == 4)
635  dsta[x] = srca[x];
636  }
637  dstr += out->linesize[r];
638  dstg += out->linesize[g];
639  dstb += out->linesize[b];
640  dsta += out->linesize[a];
641  srcr += in ->linesize[r];
642  srcg += in ->linesize[g];
643  srcb += in ->linesize[b];
644  srca += in ->linesize[a];
645  }
646  }
647  return 0;
648 }
649 
650 static int config_input(AVFilterLink *inlink)
651 {
652  int i, j, ret;
653  AVFilterContext *ctx = inlink->dst;
654  CurvesContext *curves = ctx->priv;
656  char **pts = curves->comp_points_str;
657  struct keypoint *comp_points[NB_COMP + 1] = {0};
658 
659  ff_fill_rgba_map(curves->rgba_map, inlink->format);
660  curves->is_16bit = desc->comp[0].depth > 8;
661  curves->depth = desc->comp[0].depth;
662  curves->lut_size = 1 << curves->depth;
663  curves->step = av_get_padded_bits_per_pixel(desc) >> (3 + curves->is_16bit);
665 
666  for (i = 0; i < NB_COMP + 1; i++) {
667  curves->graph[i] = av_mallocz_array(curves->lut_size, sizeof(*curves->graph[0]));
668  if (!curves->graph[i])
669  return AVERROR(ENOMEM);
670  ret = parse_points_str(ctx, comp_points + i, curves->comp_points_str[i], curves->lut_size);
671  if (ret < 0)
672  return ret;
673  switch (curves->depth) {
674  case 8: ret = interpolate8 (ctx, curves->graph[i], comp_points[i]); break;
675  case 9: ret = interpolate9 (ctx, curves->graph[i], comp_points[i]); break;
676  case 10: ret = interpolate10(ctx, curves->graph[i], comp_points[i]); break;
677  case 12: ret = interpolate12(ctx, curves->graph[i], comp_points[i]); break;
678  case 14: ret = interpolate14(ctx, curves->graph[i], comp_points[i]); break;
679  case 16: ret = interpolate16(ctx, curves->graph[i], comp_points[i]); break;
680  }
681  if (ret < 0)
682  return ret;
683  }
684 
685  if (pts[NB_COMP]) {
686  for (i = 0; i < NB_COMP; i++)
687  for (j = 0; j < curves->lut_size; j++)
688  curves->graph[i][j] = curves->graph[NB_COMP][curves->graph[i][j]];
689  }
690 
691  if (av_log_get_level() >= AV_LOG_VERBOSE) {
692  for (i = 0; i < NB_COMP; i++) {
693  const struct keypoint *point = comp_points[i];
694  av_log(ctx, AV_LOG_VERBOSE, "#%d points:", i);
695  while (point) {
696  av_log(ctx, AV_LOG_VERBOSE, " (%f;%f)", point->x, point->y);
697  point = point->next;
698  }
699  }
700  }
701 
702  if (curves->plot_filename)
703  dump_curves(curves->plot_filename, curves->graph, comp_points, curves->lut_size);
704 
705  for (i = 0; i < NB_COMP + 1; i++) {
706  struct keypoint *point = comp_points[i];
707  while (point) {
708  struct keypoint *next = point->next;
709  av_free(point);
710  point = next;
711  }
712  }
713 
714  return 0;
715 }
716 
717 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
718 {
719  AVFilterContext *ctx = inlink->dst;
720  CurvesContext *curves = ctx->priv;
721  AVFilterLink *outlink = ctx->outputs[0];
722  AVFrame *out;
723  ThreadData td;
724 
725  if (av_frame_is_writable(in)) {
726  out = in;
727  } else {
728  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
729  if (!out) {
730  av_frame_free(&in);
731  return AVERROR(ENOMEM);
732  }
733  av_frame_copy_props(out, in);
734  }
735 
736  td.in = in;
737  td.out = out;
738  ctx->internal->execute(ctx, curves->filter_slice, &td, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
739 
740  if (out != in)
741  av_frame_free(&in);
742 
743  return ff_filter_frame(outlink, out);
744 }
745 
747 {
748  int i;
749  CurvesContext *curves = ctx->priv;
750 
751  for (i = 0; i < NB_COMP + 1; i++)
752  av_freep(&curves->graph[i]);
753 }
754 
755 static const AVFilterPad curves_inputs[] = {
756  {
757  .name = "default",
758  .type = AVMEDIA_TYPE_VIDEO,
759  .filter_frame = filter_frame,
760  .config_props = config_input,
761  },
762  { NULL }
763 };
764 
765 static const AVFilterPad curves_outputs[] = {
766  {
767  .name = "default",
768  .type = AVMEDIA_TYPE_VIDEO,
769  },
770  { NULL }
771 };
772 
774  .name = "curves",
775  .description = NULL_IF_CONFIG_SMALL("Adjust components curves."),
776  .priv_size = sizeof(CurvesContext),
777  .init = curves_init,
780  .inputs = curves_inputs,
781  .outputs = curves_outputs,
782  .priv_class = &curves_class,
784 };
#define MD
#define NULL
Definition: coverity.c:32
static int filter_slice_packed(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_curves.c:536
AVFrame * out
Definition: af_adeclick.c:485
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition: bprint.c:94
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2446
This structure describes decoded (raw) audio or video data.
Definition: frame.h:226
AVOption.
Definition: opt.h:246
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
struct keypoint * next
Definition: vf_curves.c:41
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:399
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
Main libavfilter public API header.
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:68
const char * g
Definition: vf_curves.c:115
const char * desc
Definition: nvenc.c:65
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:369
FILE * av_fopen_utf8(const char *path, const char *mode)
Open a file using a UTF-8 filename.
Definition: file_open.c:158
#define CLIP(v)
Natural cubic spline interpolation Finding curves using Cubic Splines notes by Steven Rauch and John ...
Definition: vf_curves.c:215
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
static struct keypoint * make_point(double x, double y, struct keypoint *next)
Definition: vf_curves.c:143
const char * b
Definition: vf_curves.c:116
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:395
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:374
#define AD
int version
Definition: avisynth_c.h:766
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:236
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:239
const char * master
Definition: vf_curves.c:117
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:99
#define src
Definition: vp8dsp.c:254
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Definition: bprint.c:235
#define G
Definition: vf_curves.c:35
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:244
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
char * psfile
Definition: vf_curves.c:68
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:125
BYTE int const BYTE * srcp
Definition: avisynth_c.h:813
const char * name
Pad name.
Definition: internal.h:60
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
char * plot_filename
Definition: vf_curves.c:71
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1080
AVFrame * in
Definition: af_afftdn.c:1082
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
static int filter_slice_planar(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_curves.c:584
uint8_t
#define av_cold
Definition: attributes.h:82
#define av_malloc(s)
static const AVOption curves_options[]
Definition: vf_curves.c:84
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:279
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:238
AVOptions.
#define NB_COMP
Definition: vf_curves.c:44
#define f(width, name)
Definition: cbs_vp9.c:255
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_curves.c:717
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:394
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:94
Misc file utilities.
static av_cold int curves_init(AVFilterContext *ctx)
Definition: vf_curves.c:470
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:370
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
static int parse_points_str(AVFilterContext *ctx, struct keypoint **points, const char *s, int lut_size)
Definition: vf_curves.c:155
ptrdiff_t size
Definition: opengl_enc.c:101
#define B
Definition: vf_curves.c:36
#define av_log(a,...)
char * comp_points_str_all
Definition: vf_curves.c:65
A filter pad used for either input or output.
Definition: internal.h:54
#define FLAGS
Definition: vf_curves.c:83
#define SET_COMP_IF_NOT_SET(n, name)
int width
Definition: frame.h:284
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
void av_file_unmap(uint8_t *bufptr, size_t size)
Unmap or free the buffer bufptr created by av_file_map().
Definition: file.c:139
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:568
#define td
Definition: regdef.h:70
int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, int log_offset, void *log_ctx)
Read the file with name filename, and put its content in a newly allocated buffer or map it with mmap...
Definition: file.c:53
#define AV_BPRINT_SIZE_UNLIMITED
BYTE * dstp
Definition: avisynth_c.h:813
#define AVERROR(e)
Definition: error.h:43
#define DECLARE_INTERPOLATE_FUNC(nbits)
Definition: vf_curves.c:339
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:202
#define READ16(dst)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Definition: bprint.c:69
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:95
const char * r
Definition: vf_curves.c:114
void * priv
private data for use by the filter
Definition: avfilter.h:353
int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel for the pixel format described by pixdesc, including any padding ...
Definition: pixdesc.c:2411
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:116
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
const char * arg
Definition: jacosubdec.c:66
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:400
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:365
simple assert() macros that are a bit more flexible than ISO C assert().
int av_log_get_level(void)
Get the current log level.
Definition: log.c:380
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:92
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:401
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
static int config_input(AVFilterLink *inlink)
Definition: vf_curves.c:650
double x
Definition: vf_curves.c:40
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:106
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:398
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:802
#define R
Definition: vf_curves.c:34
char * comp_points_str[NB_COMP+1]
Definition: vf_curves.c:64
#define FFMIN(a, b)
Definition: common.h:96
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: error.h:119
AVFormatContext * ctx
Definition: movenc.c:48
#define s(width, name)
Definition: cbs_vp9.c:257
int n
Definition: avisynth_c.h:684
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
AVFilter ff_vf_curves
Definition: vf_curves.c:773
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:397
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
#define FF_ARRAY_ELEMS(a)
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
Definition: drawutils.c:35
double av_strtod(const char *numstr, char **tail)
Parse the string in numstr and return its value as a double.
Definition: eval.c:106
#define AV_BPRINT_SIZE_AUTOMATIC
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:251
static int parse_psfile(AVFilterContext *ctx, const char *fname)
Definition: vf_curves.c:353
misc drawing utilities
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:594
Used for passing data between threads.
Definition: af_adeclick.c:484
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:257
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
#define BD
double y
Definition: vf_curves.c:40
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
void * buf
Definition: avisynth_c.h:690
static int dump_curves(const char *fname, uint16_t *graph[NB_COMP+1], struct keypoint *comp_points[NB_COMP+1], int lut_size)
Definition: vf_curves.c:409
static int get_nb_points(const struct keypoint *d)
Definition: vf_curves.c:199
#define OFFSET(x)
Definition: vf_curves.c:82
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:144
static const struct @215 curves_presets[]
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:240
const char * name
Filter name.
Definition: avfilter.h:148
static const AVFilterPad curves_inputs[]
Definition: vf_curves.c:755
#define A
Definition: vf_curves.c:37
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:350
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:396
static int64_t pts
#define flags(name, subs,...)
Definition: cbs_av1.c:596
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
Definition: avfilter.h:378
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:240
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
Definition: bprint.c:227
AVFILTER_DEFINE_CLASS(curves)
preset
Definition: vf_curves.c:46
int
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
static double c[64]
uint16_t * graph[NB_COMP+1]
Definition: vf_curves.c:66
avfilter_execute_func * execute
Definition: internal.h:155
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2029
#define av_free(p)
uint8_t rgba_map[4]
Definition: vf_curves.c:69
A list of supported formats for one end of a filter link.
Definition: formats.h:64
int(* filter_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_curves.c:75
An instance of a filter.
Definition: avfilter.h:338
int height
Definition: frame.h:284
FILE * out
Definition: movenc.c:54
#define av_freep(p)
static int query_formats(AVFilterContext *ctx)
Definition: vf_curves.c:512
internal API functions
static int interpolate(void *log_ctx, uint16_t *y, const struct keypoint *points, int nbits)
Definition: vf_curves.c:217
int depth
Number of bits in the component.
Definition: pixdesc.h:58
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:237
static av_cold void curves_uninit(AVFilterContext *ctx)
Definition: vf_curves.c:746
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Definition: pixdesc.h:144
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:654
#define av_unused
Definition: attributes.h:125
static const AVFilterPad curves_outputs[]
Definition: vf_curves.c:765
simple arithmetic expression evaluator
void * av_mallocz_array(size_t nmemb, size_t size)
Definition: mem.c:191