FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vf_pseudocolor.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Paul B Mahol
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/attributes.h"
22 #include "libavutil/common.h"
23 #include "libavutil/eval.h"
24 #include "libavutil/imgutils.h"
25 #include "libavutil/opt.h"
26 #include "libavutil/pixdesc.h"
27 #include "avfilter.h"
28 #include "formats.h"
29 #include "internal.h"
30 #include "video.h"
31 
32 static const char *const var_names[] = {
33  "w", ///< width of the input video
34  "h", ///< height of the input video
35  "val", ///< input value for the pixel
36  "ymin",
37  "umin",
38  "vmin",
39  "amin",
40  "ymax",
41  "umax",
42  "vmax",
43  "amax",
44  NULL
45 };
46 
47 enum var_name {
60 };
61 
62 typedef struct PseudoColorContext {
63  const AVClass *class;
64  int max;
65  int index;
66  int nb_planes;
67  int color;
68  int linesize[4];
69  int width[4], height[4];
71  char *comp_expr_str[4];
73  float lut[4][256*256];
74 
75  void (*filter[4])(int max, int width, int height,
76  const uint8_t *index, const uint8_t *src,
77  uint8_t *dst,
78  ptrdiff_t ilinesize,
79  ptrdiff_t slinesize,
80  ptrdiff_t dlinesize,
81  float *lut);
83 
84 #define OFFSET(x) offsetof(PseudoColorContext, x)
85 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
86 
87 static const AVOption pseudocolor_options[] = {
88  { "c0", "set component #0 expression", OFFSET(comp_expr_str[0]), AV_OPT_TYPE_STRING, {.str="val"}, .flags = FLAGS },
89  { "c1", "set component #1 expression", OFFSET(comp_expr_str[1]), AV_OPT_TYPE_STRING, {.str="val"}, .flags = FLAGS },
90  { "c2", "set component #2 expression", OFFSET(comp_expr_str[2]), AV_OPT_TYPE_STRING, {.str="val"}, .flags = FLAGS },
91  { "c3", "set component #3 expression", OFFSET(comp_expr_str[3]), AV_OPT_TYPE_STRING, {.str="val"}, .flags = FLAGS },
92  { "i", "set component as base", OFFSET(index), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, .flags = FLAGS },
93  { NULL }
94 };
95 
96 static const enum AVPixelFormat pix_fmts[] = {
123 };
124 
126 {
128  if (!fmts_list)
129  return AVERROR(ENOMEM);
130  return ff_set_common_formats(ctx, fmts_list);
131 }
132 
133 static void pseudocolor_filter(int max, int width, int height,
134  const uint8_t *index,
135  const uint8_t *src,
136  uint8_t *dst,
137  ptrdiff_t ilinesize,
138  ptrdiff_t slinesize,
139  ptrdiff_t dlinesize,
140  float *lut)
141 {
142  int x, y;
143 
144  for (y = 0; y < height; y++) {
145  for (x = 0; x < width; x++) {
146  int v = lut[index[x]];
147 
148  if (v >= 0 && v <= max) {
149  dst[x] = v;
150  } else {
151  dst[x] = src[x];
152  }
153  }
154  index += ilinesize;
155  src += slinesize;
156  dst += dlinesize;
157  }
158 }
159 
160 static void pseudocolor_filter_11(int max, int width, int height,
161  const uint8_t *index,
162  const uint8_t *src,
163  uint8_t *dst,
164  ptrdiff_t ilinesize,
165  ptrdiff_t slinesize,
166  ptrdiff_t dlinesize,
167  float *lut)
168 {
169  int x, y;
170 
171  for (y = 0; y < height; y++) {
172  for (x = 0; x < width; x++) {
173  int v = lut[index[(y << 1) * ilinesize + (x << 1)]];
174 
175  if (v >= 0 && v <= max) {
176  dst[x] = v;
177  } else {
178  dst[x] = src[x];
179  }
180  }
181  src += slinesize;
182  dst += dlinesize;
183  }
184 }
185 
186 static void pseudocolor_filter_11d(int max, int width, int height,
187  const uint8_t *index,
188  const uint8_t *src,
189  uint8_t *dst,
190  ptrdiff_t ilinesize,
191  ptrdiff_t slinesize,
192  ptrdiff_t dlinesize,
193  float *lut)
194 {
195  int x, y;
196 
197  for (y = 0; y < height; y++) {
198  for (x = 0; x < width; x++) {
199  int v = lut[index[(y >> 1) * ilinesize + (x >> 1)]];
200 
201  if (v >= 0 && v <= max) {
202  dst[x] = v;
203  } else {
204  dst[x] = src[x];
205  }
206  }
207  src += slinesize;
208  dst += dlinesize;
209  }
210 }
211 
212 static void pseudocolor_filter_10(int max, int width, int height,
213  const uint8_t *index,
214  const uint8_t *src,
215  uint8_t *dst,
216  ptrdiff_t ilinesize,
217  ptrdiff_t slinesize,
218  ptrdiff_t dlinesize,
219  float *lut)
220 {
221  int x, y;
222 
223  for (y = 0; y < height; y++) {
224  for (x = 0; x < width; x++) {
225  int v = lut[index[x << 1]];
226 
227  if (v >= 0 && v <= max) {
228  dst[x] = v;
229  } else {
230  dst[x] = src[x];
231  }
232  }
233  index += ilinesize;
234  src += slinesize;
235  dst += dlinesize;
236  }
237 }
238 
239 static void pseudocolor_filter_10d(int max, int width, int height,
240  const uint8_t *index,
241  const uint8_t *src,
242  uint8_t *dst,
243  ptrdiff_t ilinesize,
244  ptrdiff_t slinesize,
245  ptrdiff_t dlinesize,
246  float *lut)
247 {
248  int x, y;
249 
250  for (y = 0; y < height; y++) {
251  for (x = 0; x < width; x++) {
252  int v = lut[index[x >> 1]];
253 
254  if (v >= 0 && v <= max) {
255  dst[x] = v;
256  } else {
257  dst[x] = src[x];
258  }
259  }
260  index += ilinesize;
261  src += slinesize;
262  dst += dlinesize;
263  }
264 }
265 
266 static void pseudocolor_filter_16(int max, int width, int height,
267  const uint8_t *iindex,
268  const uint8_t *ssrc,
269  uint8_t *ddst,
270  ptrdiff_t ilinesize,
271  ptrdiff_t slinesize,
272  ptrdiff_t dlinesize,
273  float *lut)
274 {
275  const uint16_t *index = (const uint16_t *)iindex;
276  const uint16_t *src = (const uint16_t *)ssrc;
277  uint16_t *dst = (uint16_t *)ddst;
278  int x, y;
279 
280  for (y = 0; y < height; y++) {
281  for (x = 0; x < width; x++) {
282  int v = lut[index[x]];
283 
284  if (v >= 0 && v <= max) {
285  dst[x] = v;
286  } else {
287  dst[x] = src[x];
288  }
289  }
290  index += ilinesize / 2;
291  src += slinesize / 2;
292  dst += dlinesize / 2;
293  }
294 }
295 
296 static void pseudocolor_filter_16_10(int max, int width, int height,
297  const uint8_t *iindex,
298  const uint8_t *ssrc,
299  uint8_t *ddst,
300  ptrdiff_t ilinesize,
301  ptrdiff_t slinesize,
302  ptrdiff_t dlinesize,
303  float *lut)
304 {
305  const uint16_t *index = (const uint16_t *)iindex;
306  const uint16_t *src = (const uint16_t *)ssrc;
307  uint16_t *dst = (uint16_t *)ddst;
308  int x, y;
309 
310  for (y = 0; y < height; y++) {
311  for (x = 0; x < width; x++) {
312  int v = lut[index[x << 1]];
313 
314  if (v >= 0 && v <= max) {
315  dst[x] = v;
316  } else {
317  dst[x] = src[x];
318  }
319  }
320  index += ilinesize / 2;
321  src += slinesize / 2;
322  dst += dlinesize / 2;
323  }
324 }
325 
326 static void pseudocolor_filter_16_10d(int max, int width, int height,
327  const uint8_t *iindex,
328  const uint8_t *ssrc,
329  uint8_t *ddst,
330  ptrdiff_t ilinesize,
331  ptrdiff_t slinesize,
332  ptrdiff_t dlinesize,
333  float *lut)
334 {
335  const uint16_t *index = (const uint16_t *)iindex;
336  const uint16_t *src = (const uint16_t *)ssrc;
337  uint16_t *dst = (uint16_t *)ddst;
338  int x, y;
339 
340  for (y = 0; y < height; y++) {
341  for (x = 0; x < width; x++) {
342  int v = lut[index[x >> 1]];
343 
344  if (v >= 0 && v <= max) {
345  dst[x] = v;
346  } else {
347  dst[x] = src[x];
348  }
349  }
350  index += ilinesize / 2;
351  src += slinesize / 2;
352  dst += dlinesize / 2;
353  }
354 }
355 
356 static void pseudocolor_filter_16_11(int max, int width, int height,
357  const uint8_t *iindex,
358  const uint8_t *ssrc,
359  uint8_t *ddst,
360  ptrdiff_t ilinesize,
361  ptrdiff_t slinesize,
362  ptrdiff_t dlinesize,
363  float *lut)
364 {
365  const uint16_t *index = (const uint16_t *)iindex;
366  const uint16_t *src = (const uint16_t *)ssrc;
367  uint16_t *dst = (uint16_t *)ddst;
368  int x, y;
369 
370  ilinesize /= 2;
371  dlinesize /= 2;
372  slinesize /= 2;
373 
374  for (y = 0; y < height; y++) {
375  for (x = 0; x < width; x++) {
376  int v = lut[index[(y << 1) * ilinesize + (x << 1)]];
377 
378  if (v >= 0 && v <= max) {
379  dst[x] = v;
380  } else {
381  dst[x] = src[x];
382  }
383  }
384  src += slinesize;
385  dst += dlinesize;
386  }
387 }
388 
389 static void pseudocolor_filter_16_11d(int max, int width, int height,
390  const uint8_t *iindex,
391  const uint8_t *ssrc,
392  uint8_t *ddst,
393  ptrdiff_t ilinesize,
394  ptrdiff_t slinesize,
395  ptrdiff_t dlinesize,
396  float *lut)
397 {
398  const uint16_t *index = (const uint16_t *)iindex;
399  const uint16_t *src = (const uint16_t *)ssrc;
400  uint16_t *dst = (uint16_t *)ddst;
401  int x, y;
402 
403  ilinesize /= 2;
404  dlinesize /= 2;
405  slinesize /= 2;
406 
407  for (y = 0; y < height; y++) {
408  for (x = 0; x < width; x++) {
409  int v = lut[index[(y >> 1) * ilinesize + (x >> 1)]];
410 
411  if (v >= 0 && v <= max) {
412  dst[x] = v;
413  } else {
414  dst[x] = src[x];
415  }
416  }
417  src += slinesize;
418  dst += dlinesize;
419  }
420 }
421 
422 static int config_input(AVFilterLink *inlink)
423 {
424  AVFilterContext *ctx = inlink->dst;
425  PseudoColorContext *s = ctx->priv;
427  int depth, ret, hsub, vsub, color;
428 
429  depth = desc->comp[0].depth;
430  s->max = (1 << depth) - 1;
432 
433  if (s->index >= s->nb_planes) {
434  av_log(ctx, AV_LOG_ERROR, "index out of allowed range\n");
435  return AVERROR(EINVAL);
436  }
437 
438  if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
439  return ret;
440 
441  hsub = desc->log2_chroma_w;
442  vsub = desc->log2_chroma_h;
443  s->height[1] = s->height[2] = AV_CEIL_RSHIFT(inlink->h, vsub);
444  s->height[0] = s->height[3] = inlink->h;
445  s->width[1] = s->width[2] = AV_CEIL_RSHIFT(inlink->w, hsub);
446  s->width[0] = s->width[3] = inlink->w;
447 
448  s->var_values[VAR_W] = inlink->w;
449  s->var_values[VAR_H] = inlink->h;
450 
451  s->var_values[VAR_YMIN] = 16 * (1 << (depth - 8));
452  s->var_values[VAR_UMIN] = 16 * (1 << (depth - 8));
453  s->var_values[VAR_VMIN] = 16 * (1 << (depth - 8));
454  s->var_values[VAR_AMIN] = 0;
455  s->var_values[VAR_YMAX] = 235 * (1 << (depth - 8));
456  s->var_values[VAR_UMAX] = 240 * (1 << (depth - 8));
457  s->var_values[VAR_VMAX] = 240 * (1 << (depth - 8));
458  s->var_values[VAR_AMAX] = s->max;
459 
460  for (color = 0; color < s->nb_planes; color++) {
461  double res;
462  int val;
463 
464  /* create the parsed expression */
465  av_expr_free(s->comp_expr[color]);
466  s->comp_expr[color] = NULL;
467  ret = av_expr_parse(&s->comp_expr[color], s->comp_expr_str[color],
468  var_names, NULL, NULL, NULL, NULL, 0, ctx);
469  if (ret < 0) {
470  av_log(ctx, AV_LOG_ERROR,
471  "Error when parsing the expression '%s' for the component %d and color %d.\n",
472  s->comp_expr_str[color], color, color);
473  return AVERROR(EINVAL);
474  }
475 
476  /* compute the lut */
477  for (val = 0; val < FF_ARRAY_ELEMS(s->lut[color]); val++) {
478  s->var_values[VAR_VAL] = val;
479 
480  res = av_expr_eval(s->comp_expr[color], s->var_values, s);
481  if (isnan(res)) {
482  av_log(ctx, AV_LOG_ERROR,
483  "Error when evaluating the expression '%s' for the value %d for the component %d.\n",
484  s->comp_expr_str[color], val, color);
485  return AVERROR(EINVAL);
486  }
487  s->lut[color][val] = res;
488  }
489  }
490 
491  switch (inlink->format) {
492  case AV_PIX_FMT_YUV444P:
493  case AV_PIX_FMT_YUVA444P:
494  case AV_PIX_FMT_GBRP:
495  case AV_PIX_FMT_GBRAP:
496  case AV_PIX_FMT_GRAY8:
497  s->filter[0] = s->filter[1] = s->filter[2] = s->filter[3] = pseudocolor_filter;
498  break;
499  case AV_PIX_FMT_YUV420P:
500  case AV_PIX_FMT_YUVA420P:
501  switch (s->index) {
502  case 0:
503  case 3:
504  s->filter[0] = s->filter[3] = pseudocolor_filter;
505  s->filter[1] = s->filter[2] = pseudocolor_filter_11;
506  break;
507  case 1:
508  case 2:
509  s->filter[0] = s->filter[3] = pseudocolor_filter_11d;
510  s->filter[1] = s->filter[2] = pseudocolor_filter;
511  break;
512  }
513  break;
514  case AV_PIX_FMT_YUV422P:
515  case AV_PIX_FMT_YUVA422P:
516  switch (s->index) {
517  case 0:
518  case 3:
519  s->filter[0] = s->filter[3] = pseudocolor_filter;
520  s->filter[1] = s->filter[2] = pseudocolor_filter_10;
521  break;
522  case 1:
523  case 2:
524  s->filter[0] = s->filter[3] = pseudocolor_filter_10d;
525  s->filter[1] = s->filter[2] = pseudocolor_filter;
526  break;
527  }
528  break;
529  case AV_PIX_FMT_YUV444P9:
537  case AV_PIX_FMT_GBRP9:
538  case AV_PIX_FMT_GBRP10:
539  case AV_PIX_FMT_GBRP12:
540  case AV_PIX_FMT_GBRP14:
541  case AV_PIX_FMT_GBRP16:
542  case AV_PIX_FMT_GBRAP10:
543  case AV_PIX_FMT_GBRAP12:
544  case AV_PIX_FMT_GBRAP16:
545  case AV_PIX_FMT_GRAY9:
546  case AV_PIX_FMT_GRAY10:
547  case AV_PIX_FMT_GRAY12:
548  case AV_PIX_FMT_GRAY16:
549  s->filter[0] = s->filter[1] = s->filter[2] = s->filter[3] = pseudocolor_filter_16;
550  break;
551  case AV_PIX_FMT_YUV422P9:
559  switch (s->index) {
560  case 0:
561  case 3:
562  s->filter[0] = s->filter[3] = pseudocolor_filter_16;
563  s->filter[1] = s->filter[2] = pseudocolor_filter_16_10;
564  break;
565  case 1:
566  case 2:
567  s->filter[0] = s->filter[3] = pseudocolor_filter_16_10d;
568  s->filter[1] = s->filter[2] = pseudocolor_filter_16;
569  break;
570  }
571  break;
572  case AV_PIX_FMT_YUV420P9:
580  switch (s->index) {
581  case 0:
582  case 3:
583  s->filter[0] = s->filter[3] = pseudocolor_filter_16;
584  s->filter[1] = s->filter[2] = pseudocolor_filter_16_11;
585  break;
586  case 1:
587  case 2:
588  s->filter[0] = s->filter[3] = pseudocolor_filter_16_11d;
589  s->filter[1] = s->filter[2] = pseudocolor_filter_16;
590  break;
591  }
592  break;
593  }
594 
595  return 0;
596 }
597 
598 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
599 {
600  AVFilterContext *ctx = inlink->dst;
601  PseudoColorContext *s = ctx->priv;
602  AVFilterLink *outlink = ctx->outputs[0];
603  AVFrame *out;
604  int plane;
605 
606  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
607  if (!out) {
608  av_frame_free(&in);
609  return AVERROR(ENOMEM);
610  }
611  av_frame_copy_props(out, in);
612 
613  for (plane = 0; plane < s->nb_planes; plane++) {
614  const uint8_t *index = in->data[s->index];
615  const uint8_t *src = in->data[plane];
616  uint8_t *dst = out->data[plane];
617  ptrdiff_t ilinesize = in->linesize[s->index];
618  ptrdiff_t slinesize = in->linesize[plane];
619  ptrdiff_t dlinesize = out->linesize[plane];
620 
621  s->filter[plane](s->max, s->width[plane], s->height[plane],
622  index, src, dst, ilinesize, slinesize,
623  dlinesize, s->lut[plane]);
624  }
625 
626  av_frame_free(&in);
627  return ff_filter_frame(outlink, out);
628 }
629 
630 static const AVFilterPad inputs[] = {
631  {
632  .name = "default",
633  .type = AVMEDIA_TYPE_VIDEO,
634  .filter_frame = filter_frame,
635  .config_props = config_input,
636  },
637  { NULL }
638 };
639 
640 static const AVFilterPad outputs[] = {
641  {
642  .name = "default",
643  .type = AVMEDIA_TYPE_VIDEO,
644  },
645  { NULL }
646 };
647 
649 {
650  PseudoColorContext *s = ctx->priv;
651  int i;
652 
653  for (i = 0; i < 4; i++) {
654  av_expr_free(s->comp_expr[i]);
655  s->comp_expr[i] = NULL;
656  }
657 }
658 
659 AVFILTER_DEFINE_CLASS(pseudocolor);
660 
662  .name = "pseudocolor",
663  .description = NULL_IF_CONFIG_SMALL("Make pseudocolored video frames."),
664  .priv_size = sizeof(PseudoColorContext),
665  .priv_class = &pseudocolor_class,
666  .uninit = uninit,
668  .inputs = inputs,
669  .outputs = outputs,
671 };
int plane
Definition: avisynth_c.h:422
#define NULL
Definition: coverity.c:32
const char const char void * val
Definition: avisynth_c.h:771
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:407
const char * s
Definition: avisynth_c.h:768
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:401
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2363
#define OFFSET(x)
This structure describes decoded (raw) audio or video data.
Definition: frame.h:218
static const AVFilterPad outputs[]
AVOption.
Definition: opt.h:246
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:403
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:378
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:388
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:404
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
misc image utilities
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2403
Main libavfilter public API header.
const char * desc
Definition: nvenc.c:65
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:164
#define FLAGS
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:384
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:349
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:372
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
Definition: eval.c:679
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
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
Macro definitions for various function/variable attributes.
static void pseudocolor_filter_11(int max, int width, int height, const uint8_t *index, const uint8_t *src, uint8_t *dst, ptrdiff_t ilinesize, ptrdiff_t slinesize, ptrdiff_t dlinesize, float *lut)
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:350
#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
const char * name
Pad name.
Definition: internal.h:60
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:351
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1080
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:97
static void pseudocolor_filter_16_10d(int max, int width, int height, const uint8_t *iindex, const uint8_t *ssrc, uint8_t *ddst, ptrdiff_t ilinesize, ptrdiff_t slinesize, ptrdiff_t dlinesize, float *lut)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
uint8_t
#define av_cold
Definition: attributes.h:82
AVOptions.
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
Definition: log.c:92
float lut[4][256 *256]
static void pseudocolor_filter_16_10(int max, int width, int height, const uint8_t *iindex, const uint8_t *ssrc, uint8_t *ddst, ptrdiff_t ilinesize, ptrdiff_t slinesize, ptrdiff_t dlinesize, float *lut)
Definition: eval.c:157
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:400
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:383
#define height
static int flags
Definition: log.c:55
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:381
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:373
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:406
#define av_log(a,...)
A filter pad used for either input or output.
Definition: internal.h:54
char * comp_expr_str[4]
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:172
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
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
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:202
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
void * priv
private data for use by the filter
Definition: avfilter.h:353
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:408
uint16_t width
Definition: gdv.c:47
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:389
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:371
AVExpr * comp_expr[4]
static void pseudocolor_filter_16_11(int max, int width, int height, const uint8_t *iindex, const uint8_t *ssrc, uint8_t *ddst, ptrdiff_t ilinesize, ptrdiff_t slinesize, ptrdiff_t dlinesize, float *lut)
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:390
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
void(* filter[4])(int max, int width, int height, const uint8_t *index, const uint8_t *src, uint8_t *dst, ptrdiff_t ilinesize, ptrdiff_t slinesize, ptrdiff_t dlinesize, float *lut)
static const char *const var_names[]
var_name
Definition: aeval.c:46
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:366
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:387
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:352
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
AVFormatContext * ctx
Definition: movenc.c:48
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:405
static void pseudocolor_filter_10d(int max, int width, int height, const uint8_t *index, const uint8_t *src, uint8_t *dst, ptrdiff_t ilinesize, ptrdiff_t slinesize, ptrdiff_t dlinesize, float *lut)
static void pseudocolor_filter_10(int max, int width, int height, const uint8_t *index, const uint8_t *src, uint8_t *dst, ptrdiff_t ilinesize, ptrdiff_t slinesize, ptrdiff_t dlinesize, float *lut)
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:367
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:386
#define FF_ARRAY_ELEMS(a)
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:379
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:376
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Definition: eval.c:334
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:249
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:173
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
static void pseudocolor_filter(int max, int width, int height, const uint8_t *index, const uint8_t *src, uint8_t *dst, ptrdiff_t ilinesize, ptrdiff_t slinesize, ptrdiff_t dlinesize, float *lut)
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
AVFilter ff_vf_pseudocolor
static void pseudocolor_filter_16_11d(int max, int width, int height, const uint8_t *iindex, const uint8_t *ssrc, uint8_t *ddst, ptrdiff_t ilinesize, ptrdiff_t slinesize, ptrdiff_t dlinesize, float *lut)
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:368
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:144
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
Definition: imgutils.c:89
int index
Definition: gxfenc.c:89
#define isnan(x)
Definition: libm.h:340
const char * name
Filter name.
Definition: avfilter.h:148
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:365
static av_cold void uninit(AVFilterContext *ctx)
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:350
static void pseudocolor_filter_11d(int max, int width, int height, const uint8_t *index, const uint8_t *src, uint8_t *dst, ptrdiff_t ilinesize, ptrdiff_t slinesize, ptrdiff_t dlinesize, float *lut)
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:377
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:385
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:369
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:375
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:232
static void pseudocolor_filter_16(int max, int width, int height, const uint8_t *iindex, const uint8_t *ssrc, uint8_t *ddst, ptrdiff_t ilinesize, ptrdiff_t slinesize, ptrdiff_t dlinesize, float *lut)
static const AVOption pseudocolor_options[]
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
static int config_input(AVFilterLink *inlink)
Y , 8bpp.
Definition: pixfmt.h:70
common internal and external API header
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:211
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:402
static int query_formats(AVFilterContext *ctx)
static enum AVPixelFormat pix_fmts[]
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:734
AVFILTER_DEFINE_CLASS(pseudocolor)
A list of supported formats for one end of a filter link.
Definition: formats.h:64
An instance of a filter.
Definition: avfilter.h:338
FILE * out
Definition: movenc.c:54
double var_values[VAR_VARS_NB]
static const AVFilterPad inputs[]
internal API functions
int depth
Number of bits in the component.
Definition: pixdesc.h:58
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:380
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:652
simple arithmetic expression evaluator
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58