FFmpeg
vf_histogram.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2019 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/colorspace.h"
22 #include "libavutil/opt.h"
23 #include "libavutil/parseutils.h"
24 #include "libavutil/pixdesc.h"
25 #include "libavutil/imgutils.h"
26 #include "libavutil/intreadwrite.h"
27 #include "avfilter.h"
28 #include "formats.h"
29 #include "internal.h"
30 #include "video.h"
31 
32 typedef struct HistogramContext {
33  const AVClass *class; ///< AVClass context for log and options purpose
35  int envelope;
36  int slide;
37  unsigned histogram[256*256];
39  int width;
40  int x_pos;
41  int mult;
42  int mid;
43  int ncomp;
44  int dncomp;
45  uint8_t bg_color[4][4];
46  uint8_t fg_color[4][4];
47  uint8_t envelope_rgba[4];
48  uint8_t envelope_color[4];
56  float fgopacity;
57  float bgopacity;
58  int planewidth[4];
59  int planeheight[4];
60  int start[4];
63 
64 #define OFFSET(x) offsetof(HistogramContext, x)
65 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
66 
67 #define COMMON_OPTIONS \
68  { "display_mode", "set display mode", OFFSET(display_mode), AV_OPT_TYPE_INT, {.i64=2}, 0, 2, FLAGS, "display_mode"}, \
69  { "d", "set display mode", OFFSET(display_mode), AV_OPT_TYPE_INT, {.i64=2}, 0, 2, FLAGS, "display_mode"}, \
70  { "overlay", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "display_mode" }, \
71  { "parade", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "display_mode" }, \
72  { "stack", NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "display_mode" }, \
73  { "levels_mode", "set levels mode", OFFSET(levels_mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "levels_mode"}, \
74  { "m", "set levels mode", OFFSET(levels_mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "levels_mode"}, \
75  { "linear", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "levels_mode" }, \
76  { "logarithmic", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "levels_mode" }, \
77  { "components", "set color components to display", OFFSET(components), AV_OPT_TYPE_INT, {.i64=7}, 1, 15, FLAGS}, \
78  { "c", "set color components to display", OFFSET(components), AV_OPT_TYPE_INT, {.i64=7}, 1, 15, FLAGS},
79 
80 static const AVOption histogram_options[] = {
81  { "level_height", "set level height", OFFSET(level_height), AV_OPT_TYPE_INT, {.i64=200}, 50, 2048, FLAGS},
82  { "scale_height", "set scale height", OFFSET(scale_height), AV_OPT_TYPE_INT, {.i64=12}, 0, 40, FLAGS},
84  { "fgopacity", "set foreground opacity", OFFSET(fgopacity), AV_OPT_TYPE_FLOAT, {.dbl=0.7}, 0, 1, FLAGS},
85  { "f", "set foreground opacity", OFFSET(fgopacity), AV_OPT_TYPE_FLOAT, {.dbl=0.7}, 0, 1, FLAGS},
86  { "bgopacity", "set background opacity", OFFSET(bgopacity), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGS},
87  { "b", "set background opacity", OFFSET(bgopacity), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGS},
88  { "colors_mode", "set colors mode", OFFSET(colors_mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 9, FLAGS, "colors_mode"},
89  { "l", "set colors mode", OFFSET(colors_mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 9, FLAGS, "colors_mode"},
90  { "whiteonblack", NULL, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "colors_mode" },
91  { "blackonwhite", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "colors_mode" },
92  { "whiteongray", NULL, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "colors_mode" },
93  { "blackongray", NULL, 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, FLAGS, "colors_mode" },
94  { "coloronblack", NULL, 0, AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, FLAGS, "colors_mode" },
95  { "coloronwhite", NULL, 0, AV_OPT_TYPE_CONST, {.i64=5}, 0, 0, FLAGS, "colors_mode" },
96  { "colorongray" , NULL, 0, AV_OPT_TYPE_CONST, {.i64=6}, 0, 0, FLAGS, "colors_mode" },
97  { "blackoncolor", NULL, 0, AV_OPT_TYPE_CONST, {.i64=7}, 0, 0, FLAGS, "colors_mode" },
98  { "whiteoncolor", NULL, 0, AV_OPT_TYPE_CONST, {.i64=8}, 0, 0, FLAGS, "colors_mode" },
99  { "grayoncolor" , NULL, 0, AV_OPT_TYPE_CONST, {.i64=9}, 0, 0, FLAGS, "colors_mode" },
100  { NULL }
101 };
102 
103 AVFILTER_DEFINE_CLASS(histogram);
104 
105 static const enum AVPixelFormat levels_in_pix_fmts[] = {
122 };
123 
127 };
128 
132 };
133 
137 };
138 
142 };
143 
147 };
148 
152 };
153 
157 };
158 
162 };
163 
165 {
166  AVFilterFormats *avff;
167  const AVPixFmtDescriptor *desc;
168  const enum AVPixelFormat *out_pix_fmts;
169  int rgb, i, bits;
170  int ret;
171 
172  if (!ctx->inputs[0]->incfg.formats ||
173  !ctx->inputs[0]->incfg.formats->nb_formats) {
174  return AVERROR(EAGAIN);
175  }
176 
177  if (!ctx->inputs[0]->outcfg.formats)
178  if ((ret = ff_formats_ref(ff_make_format_list(levels_in_pix_fmts), &ctx->inputs[0]->outcfg.formats)) < 0)
179  return ret;
180  avff = ctx->inputs[0]->incfg.formats;
181  desc = av_pix_fmt_desc_get(avff->formats[0]);
182  rgb = desc->flags & AV_PIX_FMT_FLAG_RGB;
183  bits = desc->comp[0].depth;
184  for (i = 1; i < avff->nb_formats; i++) {
185  desc = av_pix_fmt_desc_get(avff->formats[i]);
186  if ((rgb != (desc->flags & AV_PIX_FMT_FLAG_RGB)) ||
187  (bits != desc->comp[0].depth))
188  return AVERROR(EAGAIN);
189  }
190 
191  if (rgb && bits == 8)
193  else if (rgb && bits == 9)
195  else if (rgb && bits == 10)
197  else if (rgb && bits == 12)
199  else if (bits == 8)
201  else if (bits == 9)
203  else if (bits == 10)
205  else if (bits == 12)
207  else
208  return AVERROR(EAGAIN);
209  if ((ret = ff_formats_ref(ff_make_format_list(out_pix_fmts), &ctx->outputs[0]->incfg.formats)) < 0)
210  return ret;
211 
212  return 0;
213 }
214 
215 static const uint8_t black_yuva_color[4] = { 0, 127, 127, 255 };
216 static const uint8_t black_gbrp_color[4] = { 0, 0, 0, 255 };
217 static const uint8_t white_yuva_color[4] = { 255, 127, 127, 255 };
218 static const uint8_t white_gbrp_color[4] = { 255, 255, 255, 255 };
219 static const uint8_t gray_color[4] = { 127, 127, 127, 255 };
220 static const uint8_t red_yuva_color[4] = { 127, 127, 255, 255 };
221 static const uint8_t red_gbrp_color[4] = { 255, 0, 0, 255 };
222 static const uint8_t green_yuva_color[4] = { 255, 127, 127, 255 };
223 static const uint8_t igreen_yuva_color[4]= { 0, 127, 127, 255 };
224 static const uint8_t green_gbrp_color[4] = { 0, 255, 0, 255 };
225 static const uint8_t blue_yuva_color[4] = { 127, 255, 127, 255 };
226 static const uint8_t blue_gbrp_color[4] = { 0, 0, 255, 255 };
227 
229 {
230  HistogramContext *s = inlink->dst->priv;
231  int rgb = 0;
232 
233  s->desc = av_pix_fmt_desc_get(inlink->format);
234  s->ncomp = s->desc->nb_components;
235  s->histogram_size = 1 << s->desc->comp[0].depth;
236  s->mult = s->histogram_size / 256;
237 
238  switch (inlink->format) {
239  case AV_PIX_FMT_GBRAP12:
240  case AV_PIX_FMT_GBRP12:
241  case AV_PIX_FMT_GBRAP10:
242  case AV_PIX_FMT_GBRP10:
243  case AV_PIX_FMT_GBRP9:
244  case AV_PIX_FMT_GBRAP:
245  case AV_PIX_FMT_GBRP:
246  memcpy(s->bg_color[0], black_gbrp_color, 4);
247  memcpy(s->fg_color[0], white_gbrp_color, 4);
248  s->start[0] = s->start[1] = s->start[2] = s->start[3] = 0;
249  memcpy(s->envelope_color, s->envelope_rgba, 4);
250  rgb = 1;
251  break;
252  default:
253  s->mid = 127;
254  memcpy(s->bg_color[0], black_yuva_color, 4);
255  memcpy(s->fg_color[0], white_yuva_color, 4);
256  s->start[0] = s->start[3] = 0;
257  s->start[1] = s->start[2] = s->histogram_size / 2;
258  s->envelope_color[0] = RGB_TO_Y_BT709(s->envelope_rgba[0], s->envelope_rgba[1], s->envelope_rgba[2]);
259  s->envelope_color[1] = RGB_TO_U_BT709(s->envelope_rgba[0], s->envelope_rgba[1], s->envelope_rgba[2], 0);
260  s->envelope_color[2] = RGB_TO_V_BT709(s->envelope_rgba[0], s->envelope_rgba[1], s->envelope_rgba[2], 0);
261  s->envelope_color[3] = s->envelope_rgba[3];
262  }
263 
264  for (int i = 1; i < 4; i++) {
265  memcpy(s->fg_color[i], s->fg_color[0], 4);
266  memcpy(s->bg_color[i], s->bg_color[0], 4);
267  }
268 
269  if (s->display_mode) {
270  if (s->colors_mode == 1) {
271  for (int i = 0; i < 4; i++)
272  for (int j = 0; j < 4; j++)
273  FFSWAP(uint8_t, s->fg_color[i][j], s->bg_color[i][j]);
274  } else if (s->colors_mode == 2) {
275  for (int i = 0; i < 4; i++)
276  memcpy(s->bg_color[i], gray_color, 4);
277  } else if (s->colors_mode == 3) {
278  for (int i = 0; i < 4; i++)
279  for (int j = 0; j < 4; j++)
280  FFSWAP(uint8_t, s->fg_color[i][j], s->bg_color[i][j]);
281  for (int i = 0; i < 4; i++)
282  memcpy(s->bg_color[i], gray_color, 4);
283  } else if (s->colors_mode == 4) {
284  if (rgb) {
285  memcpy(s->fg_color[0], red_gbrp_color, 4);
286  memcpy(s->fg_color[1], green_gbrp_color, 4);
287  memcpy(s->fg_color[2], blue_gbrp_color, 4);
288  } else {
289  memcpy(s->fg_color[0], green_yuva_color, 4);
290  memcpy(s->fg_color[1], blue_yuva_color, 4);
291  memcpy(s->fg_color[2], red_yuva_color, 4);
292  }
293  } else if (s->colors_mode == 5) {
294  for (int i = 0; i < 4; i++)
295  for (int j = 0; j < 4; j++)
296  FFSWAP(uint8_t, s->fg_color[i][j], s->bg_color[i][j]);
297  if (rgb) {
298  memcpy(s->fg_color[0], red_gbrp_color, 4);
299  memcpy(s->fg_color[1], green_gbrp_color, 4);
300  memcpy(s->fg_color[2], blue_gbrp_color, 4);
301  } else {
302  memcpy(s->fg_color[0], igreen_yuva_color,4);
303  memcpy(s->fg_color[1], blue_yuva_color, 4);
304  memcpy(s->fg_color[2], red_yuva_color, 4);
305  }
306  } else if (s->colors_mode == 6) {
307  for (int i = 0; i < 4; i++)
308  memcpy(s->bg_color[i], gray_color, 4);
309  if (rgb) {
310  memcpy(s->fg_color[0], red_gbrp_color, 4);
311  memcpy(s->fg_color[1], green_gbrp_color, 4);
312  memcpy(s->fg_color[2], blue_gbrp_color, 4);
313  } else {
314  memcpy(s->fg_color[0], green_yuva_color, 4);
315  memcpy(s->fg_color[1], blue_yuva_color, 4);
316  memcpy(s->fg_color[2], red_yuva_color, 4);
317  }
318  } else if (s->colors_mode == 7) {
319  for (int i = 0; i < 4; i++)
320  for (int j = 0; j < 4; j++)
321  FFSWAP(uint8_t, s->fg_color[i][j], s->bg_color[i][j]);
322  if (rgb) {
323  memcpy(s->bg_color[0], red_gbrp_color, 4);
324  memcpy(s->bg_color[1], green_gbrp_color, 4);
325  memcpy(s->bg_color[2], blue_gbrp_color, 4);
326  } else {
327  memcpy(s->bg_color[0], green_yuva_color, 4);
328  memcpy(s->bg_color[1], blue_yuva_color, 4);
329  memcpy(s->bg_color[2], red_yuva_color, 4);
330  }
331  } else if (s->colors_mode == 8) {
332  if (rgb) {
333  memcpy(s->bg_color[0], red_gbrp_color, 4);
334  memcpy(s->bg_color[1], green_gbrp_color, 4);
335  memcpy(s->bg_color[2], blue_gbrp_color, 4);
336  } else {
337  memcpy(s->bg_color[0], igreen_yuva_color,4);
338  memcpy(s->bg_color[1], blue_yuva_color, 4);
339  memcpy(s->bg_color[2], red_yuva_color, 4);
340  }
341  } else if (s->colors_mode == 9) {
342  for (int i = 0; i < 4; i++)
343  memcpy(s->fg_color[i], gray_color, 4);
344  if (rgb) {
345  memcpy(s->bg_color[0], red_gbrp_color, 4);
346  memcpy(s->bg_color[1], green_gbrp_color, 4);
347  memcpy(s->bg_color[2], blue_gbrp_color, 4);
348  } else {
349  memcpy(s->bg_color[0], igreen_yuva_color,4);
350  memcpy(s->bg_color[1], blue_yuva_color, 4);
351  memcpy(s->bg_color[2], red_yuva_color, 4);
352  }
353  }
354  }
355 
356  for (int i = 0; i < 4; i++) {
357  s->fg_color[i][3] = s->fgopacity * 255;
358  s->bg_color[i][3] = s->bgopacity * 255;
359  }
360 
361  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, s->desc->log2_chroma_h);
362  s->planeheight[0] = s->planeheight[3] = inlink->h;
363  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, s->desc->log2_chroma_w);
364  s->planewidth[0] = s->planewidth[3] = inlink->w;
365 
366  return 0;
367 }
368 
369 static int config_output(AVFilterLink *outlink)
370 {
371  AVFilterContext *ctx = outlink->src;
372  HistogramContext *s = ctx->priv;
373  int ncomp = 0, i;
374 
375  if (!strcmp(ctx->filter->name, "thistogram"))
376  s->thistogram = 1;
377 
378  for (i = 0; i < s->ncomp; i++) {
379  if ((1 << i) & s->components)
380  ncomp++;
381  }
382 
383  if (s->thistogram) {
384  if (!s->width)
385  s->width = ctx->inputs[0]->w;
386  outlink->w = s->width * FFMAX(ncomp * (s->display_mode == 1), 1);
387  outlink->h = s->histogram_size * FFMAX(ncomp * (s->display_mode == 2), 1);
388  } else {
389  outlink->w = s->histogram_size * FFMAX(ncomp * (s->display_mode == 1), 1);
390  outlink->h = (s->level_height + s->scale_height) * FFMAX(ncomp * (s->display_mode == 2), 1);
391  }
392 
393  s->odesc = av_pix_fmt_desc_get(outlink->format);
394  s->dncomp = s->odesc->nb_components;
395  outlink->sample_aspect_ratio = (AVRational){1,1};
396 
397  return 0;
398 }
399 
401 {
402  HistogramContext *s = inlink->dst->priv;
403  AVFilterContext *ctx = inlink->dst;
404  AVFilterLink *outlink = ctx->outputs[0];
405  AVFrame *out = s->out;
406  int i, j, k, l, m;
407 
408  if (!s->thistogram || !out) {
409  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
410  if (!out) {
411  av_frame_free(&in);
412  return AVERROR(ENOMEM);
413  }
414  s->out = out;
415 
416  for (k = 0; k < 4 && out->data[k]; k++) {
417  const int is_chroma = (k == 1 || k == 2);
418  const int dst_h = AV_CEIL_RSHIFT(outlink->h, (is_chroma ? s->odesc->log2_chroma_h : 0));
419  const int dst_w = AV_CEIL_RSHIFT(outlink->w, (is_chroma ? s->odesc->log2_chroma_w : 0));
420 
421  if (s->histogram_size <= 256) {
422  for (i = 0; i < dst_h ; i++)
423  memset(out->data[s->odesc->comp[k].plane] +
424  i * out->linesize[s->odesc->comp[k].plane],
425  s->bg_color[0][k], dst_w);
426  } else {
427  const int mult = s->mult;
428 
429  for (i = 0; i < dst_h ; i++)
430  for (j = 0; j < dst_w; j++)
431  AV_WN16(out->data[s->odesc->comp[k].plane] +
432  i * out->linesize[s->odesc->comp[k].plane] + j * 2,
433  s->bg_color[0][k] * mult);
434  }
435  }
436  }
437 
438  for (m = 0, k = 0; k < s->ncomp; k++) {
439  const int p = s->desc->comp[k].plane;
440  const int max_value = s->histogram_size - 1 - s->start[p];
441  const int height = s->planeheight[p];
442  const int width = s->planewidth[p];
443  const int mid = s->mid;
444  double max_hval_log;
445  unsigned max_hval = 0;
446  int starty, startx;
447 
448  if (!((1 << k) & s->components))
449  continue;
450  if (s->thistogram) {
451  starty = m * s->histogram_size * (s->display_mode == 2);
452  startx = m++ * s->width * (s->display_mode == 1);
453  } else {
454  startx = m * s->histogram_size * (s->display_mode == 1);
455  starty = m++ * (s->level_height + s->scale_height) * (s->display_mode == 2);
456  }
457 
458  if (s->histogram_size <= 256) {
459  for (i = 0; i < height; i++) {
460  const uint8_t *src = in->data[p] + i * in->linesize[p];
461  for (j = 0; j < width; j++)
462  s->histogram[src[j]]++;
463  }
464  } else {
465  for (i = 0; i < height; i++) {
466  const uint16_t *src = (const uint16_t *)(in->data[p] + i * in->linesize[p]);
467  for (j = 0; j < width; j++)
468  s->histogram[src[j]]++;
469  }
470  }
471 
472  for (i = 0; i < s->histogram_size; i++)
473  max_hval = FFMAX(max_hval, s->histogram[i]);
474  max_hval_log = log2(max_hval + 1);
475 
476  if (s->thistogram) {
477  const int bpp = 1 + (s->histogram_size > 256);
478  int minh = s->histogram_size - 1, maxh = 0;
479 
480  if (s->slide == 2) {
481  s->x_pos = out->width - 1;
482  for (j = 0; j < outlink->h; j++) {
483  memmove(out->data[p] + j * out->linesize[p] ,
484  out->data[p] + j * out->linesize[p] + bpp,
485  (outlink->w - 1) * bpp);
486  }
487  } else if (s->slide == 3) {
488  s->x_pos = 0;
489  for (j = 0; j < outlink->h; j++) {
490  memmove(out->data[p] + j * out->linesize[p] + bpp,
491  out->data[p] + j * out->linesize[p],
492  (outlink->w - 1) * bpp);
493  }
494  }
495 
496  for (int i = 0; i < s->histogram_size; i++) {
497  int idx = s->histogram_size - i - 1;
498  int value = s->start[p];
499 
500  if (s->envelope && s->histogram[idx]) {
501  minh = FFMIN(minh, i);
502  maxh = FFMAX(maxh, i);
503  }
504 
505  if (s->levels_mode)
506  value += lrint(max_value * (log2(s->histogram[idx] + 1) / max_hval_log));
507  else
508  value += lrint(max_value * s->histogram[idx] / (float)max_hval);
509 
510  if (s->histogram_size <= 256) {
511  s->out->data[p][(i + starty) * s->out->linesize[p] + startx + s->x_pos] = value;
512  } else {
513  AV_WN16(s->out->data[p] + (i + starty) * s->out->linesize[p] + startx * 2 + s->x_pos * 2, value);
514  }
515  }
516 
517  if (s->envelope) {
518  if (s->histogram_size <= 256) {
519  s->out->data[0][(minh + starty) * s->out->linesize[p] + startx + s->x_pos] = s->envelope_color[0];
520  s->out->data[0][(maxh + starty) * s->out->linesize[p] + startx + s->x_pos] = s->envelope_color[0];
521  if (s->dncomp >= 3) {
522  s->out->data[1][(minh + starty) * s->out->linesize[p] + startx + s->x_pos] = s->envelope_color[1];
523  s->out->data[2][(minh + starty) * s->out->linesize[p] + startx + s->x_pos] = s->envelope_color[2];
524  s->out->data[1][(maxh + starty) * s->out->linesize[p] + startx + s->x_pos] = s->envelope_color[1];
525  s->out->data[2][(maxh + starty) * s->out->linesize[p] + startx + s->x_pos] = s->envelope_color[2];
526  }
527  } else {
528  const int mult = s->mult;
529 
530  AV_WN16(s->out->data[0] + (minh + starty) * s->out->linesize[p] + startx * 2 + s->x_pos * 2, s->envelope_color[0] * mult);
531  AV_WN16(s->out->data[0] + (maxh + starty) * s->out->linesize[p] + startx * 2 + s->x_pos * 2, s->envelope_color[0] * mult);
532  if (s->dncomp >= 3) {
533  AV_WN16(s->out->data[1] + (minh + starty) * s->out->linesize[p] + startx * 2 + s->x_pos * 2, s->envelope_color[1] * mult);
534  AV_WN16(s->out->data[2] + (minh + starty) * s->out->linesize[p] + startx * 2 + s->x_pos * 2, s->envelope_color[2] * mult);
535  AV_WN16(s->out->data[1] + (maxh + starty) * s->out->linesize[p] + startx * 2 + s->x_pos * 2, s->envelope_color[1] * mult);
536  AV_WN16(s->out->data[2] + (maxh + starty) * s->out->linesize[p] + startx * 2 + s->x_pos * 2, s->envelope_color[2] * mult);
537  }
538  }
539  }
540  } else {
541  for (i = 0; i < s->histogram_size; i++) {
542  int col_height;
543 
544  if (s->levels_mode)
545  col_height = lrint(s->level_height * (1. - (log2(s->histogram[i] + 1) / max_hval_log)));
546  else
547  col_height = s->level_height - (s->histogram[i] * (int64_t)s->level_height + max_hval - 1) / max_hval;
548 
549  if (s->histogram_size <= 256) {
550  for (j = s->level_height - 1; j >= col_height; j--) {
551  if (s->display_mode) {
552  for (l = 0; l < s->dncomp; l++)
553  out->data[l][(j + starty) * out->linesize[l] + startx + i] = s->fg_color[p][l];
554  } else {
555  out->data[p][(j + starty) * out->linesize[p] + startx + i] = 255;
556  }
557  }
558  if (s->display_mode) {
559  for (j = col_height - 1; j >= 0; j--) {
560  for (l = 0; l < s->dncomp; l++)
561  out->data[l][(j + starty) * out->linesize[l] + startx + i] = s->bg_color[p][l];
562  }
563  }
564  for (j = s->level_height + s->scale_height - 1; j >= s->level_height; j--)
565  for (l = 0; l < s->dncomp; l++)
566  out->data[l][(j + starty) * out->linesize[l] + startx + i] = p == l ? i : mid;
567  } else {
568  const int mult = s->mult;
569 
570  for (j = s->level_height - 1; j >= col_height; j--) {
571  if (s->display_mode) {
572  for (l = 0; l < s->dncomp; l++)
573  AV_WN16(out->data[l] + (j + starty) * out->linesize[l] + startx * 2 + i * 2, s->fg_color[p][l] * mult);
574  } else {
575  AV_WN16(out->data[p] + (j + starty) * out->linesize[p] + startx * 2 + i * 2, 255 * mult);
576  }
577  }
578  if (s->display_mode) {
579  for (j = col_height - 1; j >= 0; j--) {
580  for (l = 0; l < s->dncomp; l++)
581  AV_WN16(out->data[l] + (j + starty) * out->linesize[l] + startx * 2 + i * 2, s->bg_color[p][l] * mult);
582  }
583  }
584  for (j = s->level_height + s->scale_height - 1; j >= s->level_height; j--)
585  for (l = 0; l < s->dncomp; l++)
586  AV_WN16(out->data[l] + (j + starty) * out->linesize[l] + startx * 2 + i * 2, p == l ? i : mid * mult);
587  }
588  }
589  }
590 
591  memset(s->histogram, 0, s->histogram_size * sizeof(unsigned));
592  }
593 
594  out->pts = in->pts;
595  av_frame_free(&in);
596  s->x_pos++;
597  if (s->x_pos >= s->width) {
598  s->x_pos = 0;
599  if (s->thistogram && (s->slide == 4 || s->slide == 0)) {
600  s->out = NULL;
601  goto end;
602  }
603  } else if (s->thistogram && s->slide == 4) {
604  return 0;
605  }
606 
607  if (s->thistogram) {
608  AVFrame *clone = av_frame_clone(out);
609 
610  if (!clone)
611  return AVERROR(ENOMEM);
612  return ff_filter_frame(outlink, clone);
613  }
614 end:
615  return ff_filter_frame(outlink, out);
616 }
617 
618 static const AVFilterPad inputs[] = {
619  {
620  .name = "default",
621  .type = AVMEDIA_TYPE_VIDEO,
622  .filter_frame = filter_frame,
623  .config_props = config_input,
624  },
625 };
626 
627 static const AVFilterPad outputs[] = {
628  {
629  .name = "default",
630  .type = AVMEDIA_TYPE_VIDEO,
631  .config_props = config_output,
632  },
633 };
634 
635 #if CONFIG_HISTOGRAM_FILTER
636 
637 const AVFilter ff_vf_histogram = {
638  .name = "histogram",
639  .description = NULL_IF_CONFIG_SMALL("Compute and draw a histogram."),
640  .priv_size = sizeof(HistogramContext),
644  .priv_class = &histogram_class,
645 };
646 
647 #endif /* CONFIG_HISTOGRAM_FILTER */
648 
649 #if CONFIG_THISTOGRAM_FILTER
650 
651 static av_cold void uninit(AVFilterContext *ctx)
652 {
653  HistogramContext *s = ctx->priv;
654 
655  av_frame_free(&s->out);
656 }
657 
658 static const AVOption thistogram_options[] = {
659  { "width", "set width", OFFSET(width), AV_OPT_TYPE_INT, {.i64=0}, 0, 8192, FLAGS},
660  { "w", "set width", OFFSET(width), AV_OPT_TYPE_INT, {.i64=0}, 0, 8192, FLAGS},
662  { "bgopacity", "set background opacity", OFFSET(bgopacity), AV_OPT_TYPE_FLOAT, {.dbl=0.9}, 0, 1, FLAGS},
663  { "b", "set background opacity", OFFSET(bgopacity), AV_OPT_TYPE_FLOAT, {.dbl=0.9}, 0, 1, FLAGS},
664  { "envelope", "display envelope", OFFSET(envelope), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
665  { "e", "display envelope", OFFSET(envelope), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
666  { "ecolor", "set envelope color", OFFSET(envelope_rgba), AV_OPT_TYPE_COLOR, {.str="gold"}, 0, 0, FLAGS },
667  { "ec", "set envelope color", OFFSET(envelope_rgba), AV_OPT_TYPE_COLOR, {.str="gold"}, 0, 0, FLAGS },
668  { "slide", "set slide mode", OFFSET(slide), AV_OPT_TYPE_INT, {.i64=1}, 0, 4, FLAGS, "slide" },
669  {"frame", "draw new frames", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "slide"},
670  {"replace", "replace old columns with new", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "slide"},
671  {"scroll", "scroll from right to left", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "slide"},
672  {"rscroll", "scroll from left to right", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, FLAGS, "slide"},
673  {"picture", "display graph in single frame", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, FLAGS, "slide"},
674  { NULL }
675 };
676 
677 AVFILTER_DEFINE_CLASS(thistogram);
678 
679 const AVFilter ff_vf_thistogram = {
680  .name = "thistogram",
681  .description = NULL_IF_CONFIG_SMALL("Compute and draw a temporal histogram."),
682  .priv_size = sizeof(HistogramContext),
686  .uninit = uninit,
687  .priv_class = &thistogram_class,
688 };
689 
690 #endif /* CONFIG_THISTOGRAM_FILTER */
FLAGS
#define FLAGS
Definition: vf_histogram.c:65
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:98
HistogramContext::fg_color
uint8_t fg_color[4][4]
Definition: vf_histogram.c:46
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
HistogramContext::ncomp
int ncomp
Definition: vf_histogram.c:43
ff_vf_thistogram
const AVFilter ff_vf_thistogram
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
HistogramContext::colors_mode
int colors_mode
Definition: vf_histogram.c:52
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:381
out
FILE * out
Definition: movenc.c:54
HistogramContext::envelope_rgba
uint8_t envelope_rgba[4]
Definition: vf_histogram.c:47
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
outputs
static const AVFilterPad outputs[]
Definition: vf_histogram.c:627
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2660
HistogramContext::out
AVFrame * out
Definition: vf_histogram.c:61
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
HistogramContext::odesc
const AVPixFmtDescriptor * odesc
Definition: vf_histogram.c:54
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:109
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:439
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_histogram.c:164
HistogramContext::level_height
int level_height
Definition: vf_histogram.c:49
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
pixdesc.h
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:424
black_yuva_color
static const uint8_t black_yuva_color[4]
Definition: vf_histogram.c:215
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:441
AVOption
AVOption.
Definition: opt.h:247
levels_out_yuv8_pix_fmts
static enum AVPixelFormat levels_out_yuv8_pix_fmts[]
Definition: vf_histogram.c:124
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:168
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:404
levels_out_yuv9_pix_fmts
static enum AVPixelFormat levels_out_yuv9_pix_fmts[]
Definition: vf_histogram.c:129
green_gbrp_color
static const uint8_t green_gbrp_color[4]
Definition: vf_histogram.c:224
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_histogram.c:228
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVFilterFormats::formats
int * formats
list of media formats
Definition: formats.h:66
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_histogram.c:400
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:169
white_gbrp_color
static const uint8_t white_gbrp_color[4]
Definition: vf_histogram.c:218
video.h
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:442
HistogramContext::display_mode
int display_mode
Definition: vf_histogram.c:51
blue_yuva_color
static const uint8_t blue_yuva_color[4]
Definition: vf_histogram.c:225
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:338
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
formats.h
HistogramContext::envelope
int envelope
Definition: vf_histogram.c:35
HistogramContext
Definition: vf_histogram.c:32
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:438
rgb
Definition: rpzaenc.c:59
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:205
red_gbrp_color
static const uint8_t red_gbrp_color[4]
Definition: vf_histogram.c:221
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:420
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:402
HistogramContext::bg_color
uint8_t bg_color[4][4]
Definition: vf_histogram.c:45
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
levels_out_rgb10_pix_fmts
static enum AVPixelFormat levels_out_rgb10_pix_fmts[]
Definition: vf_histogram.c:154
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:407
AV_PIX_FMT_YUVJ411P
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:248
mult
static int16_t mult(Float11 *f1, Float11 *f2)
Definition: g726.c:56
lrint
#define lrint
Definition: tablegen.h:53
colorspace.h
av_cold
#define av_cold
Definition: attributes.h:90
HistogramContext::levels_mode
int levels_mode
Definition: vf_histogram.c:53
HistogramContext::slide
int slide
Definition: vf_histogram.c:36
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:424
width
#define width
HistogramContext::scale_height
int scale_height
Definition: vf_histogram.c:50
RGB_TO_Y_BT709
#define RGB_TO_Y_BT709(r, g, b)
Definition: vf_pseudocolor.c:553
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:257
histogram_options
static const AVOption histogram_options[]
Definition: vf_histogram.c:80
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:425
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:51
RGB_TO_U_BT709
#define RGB_TO_U_BT709(r1, g1, b1, max)
Definition: vf_pseudocolor.c:557
ff_formats_ref
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:555
HistogramContext::envelope_color
uint8_t envelope_color[4]
Definition: vf_histogram.c:48
HistogramContext::bgopacity
float bgopacity
Definition: vf_histogram.c:57
bits
uint8_t bits
Definition: vp3data.h:141
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:445
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:401
ctx
AVFormatContext * ctx
Definition: movenc.c:48
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:422
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
HistogramContext::mult
int mult
Definition: vf_histogram.c:41
HistogramContext::start
int start[4]
Definition: vf_histogram.c:60
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
AV_OPT_TYPE_COLOR
@ AV_OPT_TYPE_COLOR
Definition: opt.h:239
levels_out_rgb12_pix_fmts
static enum AVPixelFormat levels_out_rgb12_pix_fmts[]
Definition: vf_histogram.c:159
parseutils.h
AVFilterFormats::nb_formats
unsigned nb_formats
number of formats
Definition: formats.h:65
HistogramContext::thistogram
int thistogram
Definition: vf_histogram.c:34
HistogramContext::histogram_size
int histogram_size
Definition: vf_histogram.c:38
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:405
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:419
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_histogram.c:369
ff_vf_histogram
const AVFilter ff_vf_histogram
blue_gbrp_color
static const uint8_t blue_gbrp_color[4]
Definition: vf_histogram.c:226
HistogramContext::width
int width
Definition: vf_histogram.c:39
RGB_TO_V_BT709
#define RGB_TO_V_BT709(r1, g1, b1, max)
Definition: vf_pseudocolor.c:561
inputs
static const AVFilterPad inputs[]
Definition: vf_histogram.c:618
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
AV_PIX_FMT_FLAG_RGB
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:136
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(histogram)
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:409
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:411
HistogramContext::dncomp
int dncomp
Definition: vf_histogram.c:44
OFFSET
#define OFFSET(x)
Definition: vf_histogram.c:64
red_yuva_color
static const uint8_t red_yuva_color[4]
Definition: vf_histogram.c:220
height
#define height
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:167
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:443
levels_in_pix_fmts
static enum AVPixelFormat levels_in_pix_fmts[]
Definition: vf_histogram.c:105
internal.h
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:227
gray_color
static const uint8_t gray_color[4]
Definition: vf_histogram.c:219
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
envelope
static float envelope(const float x)
Definition: vf_monochrome.c:46
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:421
HistogramContext::fgopacity
float fgopacity
Definition: vf_histogram.c:56
out_pix_fmts
static enum AVPixelFormat out_pix_fmts[]
Definition: vf_ciescope.c:133
HistogramContext::planeheight
int planeheight[4]
Definition: vf_histogram.c:59
levels_out_yuv10_pix_fmts
static enum AVPixelFormat levels_out_yuv10_pix_fmts[]
Definition: vf_histogram.c:134
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
HistogramContext::x_pos
int x_pos
Definition: vf_histogram.c:40
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
HistogramContext::desc
const AVPixFmtDescriptor * desc
Definition: vf_histogram.c:54
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
HistogramContext::components
int components
Definition: vf_histogram.c:55
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:403
log2
#define log2(x)
Definition: libm.h:404
COMMON_OPTIONS
#define COMMON_OPTIONS
Definition: vf_histogram.c:67
AVFilter
Filter definition.
Definition: avfilter.h:165
ret
ret
Definition: filter_design.txt:187
FFSWAP
#define FFSWAP(type, a, b)
Definition: macros.h:52
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:440
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:408
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:444
igreen_yuva_color
static const uint8_t igreen_yuva_color[4]
Definition: vf_histogram.c:223
levels_out_rgb8_pix_fmts
static enum AVPixelFormat levels_out_rgb8_pix_fmts[]
Definition: vf_histogram.c:144
HistogramContext::mid
int mid
Definition: vf_histogram.c:42
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
avfilter.h
HistogramContext::planewidth
int planewidth[4]
Definition: vf_histogram.c:58
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
AVFilterContext
An instance of a filter.
Definition: avfilter.h:402
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:158
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
levels_out_yuv12_pix_fmts
static enum AVPixelFormat levels_out_yuv12_pix_fmts[]
Definition: vf_histogram.c:139
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:241
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
imgutils.h
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:362
rgb
static const SheerTable rgb[2]
Definition: sheervideodata.h:32
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
levels_out_rgb9_pix_fmts
static enum AVPixelFormat levels_out_rgb9_pix_fmts[]
Definition: vf_histogram.c:149
HistogramContext::histogram
unsigned histogram[256 *256]
Definition: vf_histogram.c:37
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:282
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:410
black_gbrp_color
static const uint8_t black_gbrp_color[4]
Definition: vf_histogram.c:216
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:166
white_yuva_color
static const uint8_t white_yuva_color[4]
Definition: vf_histogram.c:217
green_yuva_color
static const uint8_t green_yuva_color[4]
Definition: vf_histogram.c:222
AV_WN16
#define AV_WN16(p, v)
Definition: intreadwrite.h:372