FFmpeg
avf_ahistogram.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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/avassert.h"
22 #include "libavutil/opt.h"
23 #include "libavutil/parseutils.h"
24 #include "avfilter.h"
25 #include "filters.h"
26 #include "formats.h"
27 #include "audio.h"
28 #include "video.h"
29 #include "internal.h"
30 
36 
37 typedef struct AudioHistogramContext {
38  const AVClass *class;
40  int w, h;
42  uint64_t *achistogram;
43  uint64_t *shistogram;
44  int ascale;
45  int scale;
46  float phisto;
48  int apos;
49  int ypos;
50  int slide;
51  int dmode;
52  int hmode;
53  int dchannels;
54  int count;
57  AVFrame *in[101];
58  int first;
60 
61  int (*get_bin)(float in, int w);
63 
64 #define OFFSET(x) offsetof(AudioHistogramContext, x)
65 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
66 
67 static const AVOption ahistogram_options[] = {
68  { "dmode", "set method to display channels", OFFSET(dmode), AV_OPT_TYPE_INT, {.i64=SINGLE}, 0, NB_DMODES-1, FLAGS, .unit = "dmode" },
69  { "single", "all channels use single histogram", 0, AV_OPT_TYPE_CONST, {.i64=SINGLE}, 0, 0, FLAGS, .unit = "dmode" },
70  { "separate", "each channel have own histogram", 0, AV_OPT_TYPE_CONST, {.i64=SEPARATE}, 0, 0, FLAGS, .unit = "dmode" },
71  { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
72  { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
73  { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS },
74  { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS },
75  { "scale", "set display scale", OFFSET(scale), AV_OPT_TYPE_INT, {.i64=LOG}, LINEAR, NB_SCALES-1, FLAGS, .unit = "scale" },
76  { "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=LOG}, 0, 0, FLAGS, .unit = "scale" },
77  { "sqrt", "square root", 0, AV_OPT_TYPE_CONST, {.i64=SQRT}, 0, 0, FLAGS, .unit = "scale" },
78  { "cbrt", "cubic root", 0, AV_OPT_TYPE_CONST, {.i64=CBRT}, 0, 0, FLAGS, .unit = "scale" },
79  { "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=LINEAR}, 0, 0, FLAGS, .unit = "scale" },
80  { "rlog", "reverse logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=RLOG}, 0, 0, FLAGS, .unit = "scale" },
81  { "ascale", "set amplitude scale", OFFSET(ascale), AV_OPT_TYPE_INT, {.i64=ALOG}, LINEAR, NB_ASCALES-1, FLAGS, .unit = "ascale" },
82  { "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=ALOG}, 0, 0, FLAGS, .unit = "ascale" },
83  { "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=ALINEAR}, 0, 0, FLAGS, .unit = "ascale" },
84  { "acount", "how much frames to accumulate", OFFSET(count), AV_OPT_TYPE_INT, {.i64=1}, -1, 100, FLAGS },
85  { "rheight", "set histogram ratio of window height", OFFSET(phisto), AV_OPT_TYPE_FLOAT, {.dbl=0.10}, 0, 1, FLAGS },
86  { "slide", "set sonogram sliding", OFFSET(slide), AV_OPT_TYPE_INT, {.i64=REPLACE}, 0, NB_SLIDES-1, FLAGS, .unit = "slide" },
87  { "replace", "replace old rows with new", 0, AV_OPT_TYPE_CONST, {.i64=REPLACE}, 0, 0, FLAGS, .unit = "slide" },
88  { "scroll", "scroll from top to bottom", 0, AV_OPT_TYPE_CONST, {.i64=SCROLL}, 0, 0, FLAGS, .unit = "slide" },
89  { "hmode", "set histograms mode", OFFSET(hmode), AV_OPT_TYPE_INT, {.i64=ABS}, 0, NB_HMODES-1, FLAGS, .unit = "hmode" },
90  { "abs", "use absolute samples", 0, AV_OPT_TYPE_CONST, {.i64=ABS}, 0, 0, FLAGS, .unit = "hmode" },
91  { "sign", "use unchanged samples", 0, AV_OPT_TYPE_CONST, {.i64=SIGN},0, 0, FLAGS, .unit = "hmode" },
92  { NULL }
93 };
94 
95 AVFILTER_DEFINE_CLASS(ahistogram);
96 
98 {
101  AVFilterLink *inlink = ctx->inputs[0];
102  AVFilterLink *outlink = ctx->outputs[0];
104  static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_YUVA444P, AV_PIX_FMT_NONE };
105  int ret = AVERROR(EINVAL);
106 
108  if ((ret = ff_formats_ref (formats, &inlink->outcfg.formats )) < 0 ||
110  (ret = ff_channel_layouts_ref (layouts, &inlink->outcfg.channel_layouts)) < 0)
111  return ret;
112 
114  if ((ret = ff_formats_ref(formats, &inlink->outcfg.samplerates)) < 0)
115  return ret;
116 
118  if ((ret = ff_formats_ref(formats, &outlink->incfg.formats)) < 0)
119  return ret;
120 
121  return 0;
122 }
123 
125 {
126  AVFilterContext *ctx = inlink->dst;
127  AudioHistogramContext *s = ctx->priv;
128 
129  s->nb_samples = FFMAX(1, av_rescale(inlink->sample_rate, s->frame_rate.den, s->frame_rate.num));
130  s->dchannels = s->dmode == SINGLE ? 1 : inlink->ch_layout.nb_channels;
131  s->shistogram = av_calloc(s->w, s->dchannels * sizeof(*s->shistogram));
132  if (!s->shistogram)
133  return AVERROR(ENOMEM);
134 
135  s->achistogram = av_calloc(s->w, s->dchannels * sizeof(*s->achistogram));
136  if (!s->achistogram)
137  return AVERROR(ENOMEM);
138 
139  return 0;
140 }
141 
142 static int get_lin_bin_abs(float in, int w)
143 {
144  return lrintf(av_clipf(fabsf(in), 0.f, 1.f) * (w - 1));
145 }
146 
147 static int get_lin_bin_sign(float in, int w)
148 {
149  return lrintf((1.f + av_clipf(in, -1.f, 1.f)) * 0.5f * (w - 1));
150 }
151 
152 static int get_log_bin_abs(float in, int w)
153 {
154  return lrintf(av_clipf(1.f + log10f(fabsf(in)) / 6.f, 0.f, 1.f) * (w - 1));
155 }
156 
157 static int get_log_bin_sign(float in, int w)
158 {
159  return (w / 2) + FFSIGN(in) * lrintf(av_clipf(1.f + log10f(fabsf(in)) / 6.f, 0.f, 1.f) * (w / 2));
160 }
161 
162 static int config_output(AVFilterLink *outlink)
163 {
164  AudioHistogramContext *s = outlink->src->priv;
165 
166  outlink->w = s->w;
167  outlink->h = s->h;
168  outlink->sample_aspect_ratio = (AVRational){1,1};
169  outlink->frame_rate = s->frame_rate;
170  outlink->time_base = av_inv_q(outlink->frame_rate);
171 
172  s->histogram_h = s->h * s->phisto;
173  s->ypos = s->h * s->phisto;
174 
175  switch (s->ascale) {
176  case ALINEAR:
177  switch (s->hmode) {
178  case ABS: s->get_bin = get_lin_bin_abs; break;
179  case SIGN: s->get_bin = get_lin_bin_sign; break;
180  default:
181  return AVERROR_BUG;
182  }
183  break;
184  case ALOG:
185  switch (s->hmode) {
186  case ABS: s->get_bin = get_log_bin_abs; break;
187  case SIGN: s->get_bin = get_log_bin_sign; break;
188  default:
189  return AVERROR_BUG;
190  }
191  break;
192  default:
193  return AVERROR_BUG;
194  }
195 
196  if (s->dmode == SEPARATE) {
197  s->combine_buffer = av_malloc_array(outlink->w * 3, sizeof(*s->combine_buffer));
198  if (!s->combine_buffer)
199  return AVERROR(ENOMEM);
200  }
201 
202  return 0;
203 }
204 
206 {
207  AVFilterContext *ctx = inlink->dst;
208  AVFilterLink *outlink = ctx->outputs[0];
209  AudioHistogramContext *s = ctx->priv;
210  const int nb_samples = in->nb_samples;
211  const int H = s->histogram_h;
212  const int w = s->w;
213  int c, y, n, p, bin, ret;
214  uint64_t acmax = 1;
215  AVFrame *clone;
216 
217  if (!s->out || s->out->width != outlink->w ||
218  s->out->height != outlink->h) {
219  av_frame_free(&s->out);
220  s->out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
221  if (!s->out) {
222  av_frame_free(&in);
223  return AVERROR(ENOMEM);
224  }
225  for (n = H; n < s->h; n++) {
226  memset(s->out->data[0] + n * s->out->linesize[0], 0, w);
227  memset(s->out->data[1] + n * s->out->linesize[0], 127, w);
228  memset(s->out->data[2] + n * s->out->linesize[0], 127, w);
229  memset(s->out->data[3] + n * s->out->linesize[0], 0, w);
230  }
231  }
232 
233  ret = ff_inlink_make_frame_writable(outlink, &s->out);
234  if (ret < 0) {
235  av_frame_free(&in);
236  return ret;
237  }
238 
239  if (s->dmode == SEPARATE) {
240  for (y = 0; y < w; y++) {
241  s->combine_buffer[3 * y ] = 0;
242  s->combine_buffer[3 * y + 1] = 127.5;
243  s->combine_buffer[3 * y + 2] = 127.5;
244  }
245  }
246 
247  for (n = 0; n < H; n++) {
248  memset(s->out->data[0] + n * s->out->linesize[0], 0, w);
249  memset(s->out->data[1] + n * s->out->linesize[0], 127, w);
250  memset(s->out->data[2] + n * s->out->linesize[0], 127, w);
251  memset(s->out->data[3] + n * s->out->linesize[0], 0, w);
252  }
253  s->out->pts = av_rescale_q(in->pts, inlink->time_base, outlink->time_base);
254  s->out->duration = 1;
255 
256  s->first = s->frame_count;
257 
258  switch (s->ascale) {
259  case ALINEAR:
260  for (c = 0; c < inlink->ch_layout.nb_channels; c++) {
261  const float *src = (const float *)in->extended_data[c];
262  uint64_t *achistogram = &s->achistogram[(s->dmode == SINGLE ? 0: c) * w];
263 
264  for (n = 0; n < nb_samples; n++) {
265  bin = s->get_bin(src[n], w);
266 
267  achistogram[bin]++;
268  }
269 
270  if (s->in[s->first] && s->count >= 0) {
271  uint64_t *shistogram = &s->shistogram[(s->dmode == SINGLE ? 0: c) * w];
272  const float *src2 = (const float *)s->in[s->first]->extended_data[c];
273 
274  for (n = 0; n < nb_samples; n++) {
275  bin = s->get_bin(src2[n], w);
276 
277  shistogram[bin]++;
278  }
279  }
280  }
281  break;
282  case ALOG:
283  for (c = 0; c < inlink->ch_layout.nb_channels; c++) {
284  const float *src = (const float *)in->extended_data[c];
285  uint64_t *achistogram = &s->achistogram[(s->dmode == SINGLE ? 0: c) * w];
286 
287  for (n = 0; n < nb_samples; n++) {
288  bin = s->get_bin(src[n], w);
289 
290  achistogram[bin]++;
291  }
292 
293  if (s->in[s->first] && s->count >= 0) {
294  uint64_t *shistogram = &s->shistogram[(s->dmode == SINGLE ? 0: c) * w];
295  const float *src2 = (const float *)s->in[s->first]->extended_data[c];
296 
297  for (n = 0; n < nb_samples; n++) {
298  bin = s->get_bin(src2[n], w);
299 
300  shistogram[bin]++;
301  }
302  }
303  }
304  break;
305  }
306 
307  av_frame_free(&s->in[s->frame_count]);
308  s->in[s->frame_count] = in;
309  s->frame_count++;
310  if (s->frame_count > s->count)
311  s->frame_count = 0;
312 
313  for (n = 0; n < w * s->dchannels; n++) {
314  acmax = FFMAX(s->achistogram[n] - s->shistogram[n], acmax);
315  }
316 
317  for (c = 0; c < s->dchannels; c++) {
318  uint64_t *shistogram = &s->shistogram[c * w];
319  uint64_t *achistogram = &s->achistogram[c * w];
320  float yf, uf, vf;
321 
322  if (s->dmode == SEPARATE) {
323  yf = 255.0f / s->dchannels;
324  uf = yf * M_PI;
325  vf = yf * M_PI;
326  uf *= 0.5 * sin((2 * M_PI * c) / s->dchannels);
327  vf *= 0.5 * cos((2 * M_PI * c) / s->dchannels);
328  }
329 
330  for (n = 0; n < w; n++) {
331  double a, aa;
332  int h;
333 
334  a = achistogram[n] - shistogram[n];
335 
336  switch (s->scale) {
337  case LINEAR:
338  aa = a / (double)acmax;
339  break;
340  case SQRT:
341  aa = sqrt(a) / sqrt(acmax);
342  break;
343  case CBRT:
344  aa = cbrt(a) / cbrt(acmax);
345  break;
346  case LOG:
347  aa = log2(a + 1) / log2(acmax + 1);
348  break;
349  case RLOG:
350  aa = 1. - log2(a + 1) / log2(acmax + 1);
351  if (aa == 1.)
352  aa = 0;
353  break;
354  default:
355  av_assert0(0);
356  }
357 
358  h = aa * (H - 1);
359 
360  if (s->dmode == SINGLE) {
361  int start = H - h, end = H;
362  const int linesizey = s->out->linesize[0];
363  const int linesizea = s->out->linesize[3];
364  uint8_t *dsty = s->out->data[0] + start * linesizey;
365  uint8_t *dsta = s->out->data[3] + start * linesizea;
366 
367  for (y = start; y < end; y++, dsty += linesizey, dsta += linesizea) {
368  dsty[n] = 255;
369  dsta[n] = 255;
370  }
371 
372  if (s->h - H > 0) {
373  h = aa * 255;
374 
375  s->out->data[0][s->ypos * s->out->linesize[0] + n] = av_clip_uint8(h);
376  s->out->data[1][s->ypos * s->out->linesize[1] + n] = 127;
377  s->out->data[2][s->ypos * s->out->linesize[2] + n] = 127;
378  s->out->data[3][s->ypos * s->out->linesize[3] + n] = 255;
379  }
380  } else if (s->dmode == SEPARATE) {
381  int start = H - h, end = H;
382  float *out = &s->combine_buffer[3 * n];
383  const int linesizey = s->out->linesize[0];
384  const int linesizeu = s->out->linesize[1];
385  const int linesizev = s->out->linesize[2];
386  const int linesizea = s->out->linesize[3];
387  uint8_t *dsty = s->out->data[0] + start * linesizey;
388  uint8_t *dstu = s->out->data[1] + start * linesizeu;
389  uint8_t *dstv = s->out->data[2] + start * linesizev;
390  uint8_t *dsta = s->out->data[3] + start * linesizea;
391  int old;
392 
393  old = dsty[n];
394  for (y = start; y < end; y++) {
395  if (dsty[n] != old)
396  break;
397  old = dsty[n];
398  dsty[n] = av_clip_uint8(yf);
399  dstu[n] = av_clip_uint8(128.f+uf);
400  dstv[n] = av_clip_uint8(128.f+vf);
401  dsta[n] = 255;
402 
403  dsty += linesizey;
404  dstu += linesizeu;
405  dstv += linesizev;
406  dsta += linesizea;
407  }
408 
409  out[0] += aa * yf;
410  out[1] += aa * uf;
411  out[2] += aa * vf;
412  }
413  }
414  }
415 
416  if (s->h - H > 0) {
417  if (s->dmode == SEPARATE) {
418  for (n = 0; n < w; n++) {
419  float *cb = &s->combine_buffer[3 * n];
420 
421  s->out->data[0][s->ypos * s->out->linesize[0] + n] = cb[0];
422  s->out->data[1][s->ypos * s->out->linesize[1] + n] = cb[1];
423  s->out->data[2][s->ypos * s->out->linesize[2] + n] = cb[2];
424  s->out->data[3][s->ypos * s->out->linesize[3] + n] = 255;
425  }
426  }
427 
428  if (s->slide == SCROLL) {
429  for (p = 0; p < 4; p++) {
430  for (y = s->h - 1; y >= H + 1; y--) {
431  memmove(s->out->data[p] + (y ) * s->out->linesize[p],
432  s->out->data[p] + (y-1) * s->out->linesize[p], w);
433  }
434  }
435  }
436 
437  s->ypos++;
438  if (s->slide == SCROLL || s->ypos >= s->h)
439  s->ypos = H;
440  }
441 
442  clone = av_frame_clone(s->out);
443  if (!clone)
444  return AVERROR(ENOMEM);
445 
446  return ff_filter_frame(outlink, clone);
447 }
448 
450 {
451  AVFilterLink *inlink = ctx->inputs[0];
452  AVFilterLink *outlink = ctx->outputs[0];
453  AudioHistogramContext *s = ctx->priv;
454  AVFrame *in;
455  int ret;
456 
458 
459  ret = ff_inlink_consume_samples(inlink, s->nb_samples, s->nb_samples, &in);
460  if (ret < 0)
461  return ret;
462  if (ret > 0)
463  return filter_frame(inlink, in);
464 
465  if (ff_inlink_queued_samples(inlink) >= s->nb_samples) {
467  return 0;
468  }
469 
472 
473  return FFERROR_NOT_READY;
474 }
475 
477 {
478  AudioHistogramContext *s = ctx->priv;
479  int i;
480 
481  av_frame_free(&s->out);
482  av_freep(&s->shistogram);
483  av_freep(&s->achistogram);
484  av_freep(&s->combine_buffer);
485  for (i = 0; i < 101; i++)
486  av_frame_free(&s->in[i]);
487 }
488 
489 static const AVFilterPad ahistogram_inputs[] = {
490  {
491  .name = "default",
492  .type = AVMEDIA_TYPE_AUDIO,
493  .config_props = config_input,
494  },
495 };
496 
497 static const AVFilterPad ahistogram_outputs[] = {
498  {
499  .name = "default",
500  .type = AVMEDIA_TYPE_VIDEO,
501  .config_props = config_output,
502  },
503 };
504 
506  .name = "ahistogram",
507  .description = NULL_IF_CONFIG_SMALL("Convert input audio to histogram video output."),
508  .uninit = uninit,
509  .priv_size = sizeof(AudioHistogramContext),
510  .activate = activate,
514  .priv_class = &ahistogram_class,
515 };
NB_SLIDES
@ NB_SLIDES
Definition: avf_ahistogram.c:33
formats
formats
Definition: signature.h:48
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:112
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
AVFilterChannelLayouts
A list of supported channel layouts.
Definition: formats.h:85
AudioHistogramContext::histogram_h
int histogram_h
Definition: avf_ahistogram.c:47
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
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
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:435
out
FILE * out
Definition: movenc.c:54
LOG
@ LOG
Definition: avf_ahistogram.c:31
cb
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:241
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:947
ff_channel_layouts_ref
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition: formats.c:673
layouts
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:261
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
AudioHistogramContext::slide
int slide
Definition: avf_ahistogram.c:50
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
Definition: opt.h:248
NB_HMODES
@ NB_HMODES
Definition: avf_ahistogram.c:35
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
AudioHistogramContext::count
int count
Definition: avf_ahistogram.c:54
config_output
static int config_output(AVFilterLink *outlink)
Definition: avf_ahistogram.c:162
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:130
ff_all_channel_counts
AVFilterChannelLayouts * ff_all_channel_counts(void)
Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition.
Definition: formats.c:621
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:456
w
uint8_t w
Definition: llviddspenc.c:38
AVOption
AVOption.
Definition: opt.h:346
AudioHistogramContext::ascale
int ascale
Definition: avf_ahistogram.c:44
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:159
REPLACE
@ REPLACE
Definition: avf_ahistogram.c:33
SCROLL
@ SCROLL
Definition: avf_ahistogram.c:33
AudioHistogramContext::first
int first
Definition: avf_ahistogram.c:58
FLAGS
#define FLAGS
Definition: avf_ahistogram.c:65
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
video.h
FF_FILTER_FORWARD_STATUS_BACK
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
Definition: filters.h:199
ALINEAR
@ ALINEAR
Definition: avf_ahistogram.c:32
AudioHistogramContext::w
int w
Definition: avf_ahistogram.c:40
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
formats.h
NB_DMODES
@ NB_DMODES
Definition: avf_ahistogram.c:34
AudioHistogramContext::combine_buffer
float * combine_buffer
Definition: avf_ahistogram.c:56
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:422
log10f
#define log10f(x)
Definition: libm.h:414
FFSIGN
#define FFSIGN(a)
Definition: common.h:73
get_log_bin_abs
static int get_log_bin_abs(float in, int w)
Definition: avf_ahistogram.c:152
AudioHistogramContext::hmode
int hmode
Definition: avf_ahistogram.c:52
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: avf_ahistogram.c:476
fabsf
static __device__ float fabsf(float a)
Definition: cuda_runtime.h:181
NB_SCALES
@ NB_SCALES
Definition: avf_ahistogram.c:31
ahistogram_outputs
static const AVFilterPad ahistogram_outputs[]
Definition: avf_ahistogram.c:497
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
cbrt
#define cbrt
Definition: tablegen.h:35
AudioHistogramContext::get_bin
int(* get_bin)(float in, int w)
Definition: avf_ahistogram.c:61
avassert.h
av_cold
#define av_cold
Definition: attributes.h:90
AmplitudeScale
AmplitudeScale
Definition: avf_ahistogram.c:32
s
#define s(width, name)
Definition: cbs_vp9.c:198
AudioHistogramContext::h
int h
Definition: avf_ahistogram.c:40
AudioHistogramContext::ypos
int ypos
Definition: avf_ahistogram.c:49
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
ff_formats_ref
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:678
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
SQRT
@ SQRT
Definition: avf_ahistogram.c:31
filters.h
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:304
config_input
static int config_input(AVFilterLink *inlink)
Definition: avf_ahistogram.c:124
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:563
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
OFFSET
#define OFFSET(x)
Definition: avf_ahistogram.c:64
ff_inlink_make_frame_writable
int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame **rframe)
Make sure a frame is writable.
Definition: avfilter.c:1492
AudioHistogramContext::apos
int apos
Definition: avf_ahistogram.c:48
ALOG
@ ALOG
Definition: avf_ahistogram.c:32
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
ff_inlink_consume_samples
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
Definition: avfilter.c:1465
NULL
#define NULL
Definition: coverity.c:32
get_log_bin_sign
static int get_log_bin_sign(float in, int w)
Definition: avf_ahistogram.c:157
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AudioHistogramContext::dchannels
int dchannels
Definition: avf_ahistogram.c:53
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Definition: opt.h:245
parseutils.h
double
double
Definition: af_crystalizer.c:131
av_clipf
av_clipf
Definition: af_crystalizer.c:121
AudioHistogramContext::frame_rate
AVRational frame_rate
Definition: avf_ahistogram.c:41
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
AudioHistogramContext::in
AVFrame * in[101]
Definition: avf_ahistogram.c:57
AudioHistogramContext
Definition: avf_ahistogram.c:37
f
f
Definition: af_crystalizer.c:121
SIGN
@ SIGN
Definition: avf_ahistogram.c:35
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: vvc_intra.c:291
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:106
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
SINGLE
@ SINGLE
Definition: avf_ahistogram.c:34
RLOG
@ RLOG
Definition: avf_ahistogram.c:31
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
get_lin_bin_abs
static int get_lin_bin_abs(float in, int w)
Definition: avf_ahistogram.c:142
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
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:174
H
#define H
Definition: pixlet.c:38
FF_FILTER_FORWARD_WANTED
FF_FILTER_FORWARD_WANTED(outlink, inlink)
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: avf_ahistogram.c:205
get_lin_bin_sign
static int get_lin_bin_sign(float in, int w)
Definition: avf_ahistogram.c:147
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(ahistogram)
M_PI
#define M_PI
Definition: mathematics.h:67
CBRT
@ CBRT
Definition: avf_ahistogram.c:31
internal.h
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:238
AudioHistogramContext::phisto
float phisto
Definition: avf_ahistogram.c:46
ABS
@ ABS
Definition: avf_ahistogram.c:35
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:424
lrintf
#define lrintf(x)
Definition: libm_mips.h:72
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AudioHistogramContext::dmode
int dmode
Definition: avf_ahistogram.c:51
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:405
LINEAR
@ LINEAR
Definition: avf_ahistogram.c:31
AudioHistogramContext::scale
int scale
Definition: avf_ahistogram.c:45
src2
const pixel * src2
Definition: h264pred_template.c:422
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:31
HistogramMode
HistogramMode
Definition: avf_ahistogram.c:35
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
ff_avf_ahistogram
const AVFilter ff_avf_ahistogram
Definition: avf_ahistogram.c:505
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
AudioHistogramContext::nb_samples
int nb_samples
Definition: avf_ahistogram.c:59
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
ff_inlink_queued_samples
int ff_inlink_queued_samples(AVFilterLink *link)
Definition: avfilter.c:1420
av_rescale
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:129
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
log2
#define log2(x)
Definition: libm.h:404
AVFilter
Filter definition.
Definition: avfilter.h:166
ret
ret
Definition: filter_design.txt:187
AudioHistogramContext::out
AVFrame * out
Definition: avf_ahistogram.c:39
NB_ASCALES
@ NB_ASCALES
Definition: avf_ahistogram.c:32
ahistogram_inputs
static const AVFilterPad ahistogram_inputs[]
Definition: avf_ahistogram.c:489
SEPARATE
@ SEPARATE
Definition: avf_ahistogram.c:34
ff_all_samplerates
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:606
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
avfilter.h
av_clip_uint8
#define av_clip_uint8
Definition: common.h:104
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: avf_ahistogram.c:97
DisplayMode
DisplayMode
Definition: avf_ahistogram.c:34
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AudioHistogramContext::shistogram
uint64_t * shistogram
Definition: avf_ahistogram.c:43
audio.h
AVFilterFormatsConfig::formats
AVFilterFormats * formats
List of supported formats (pixel or sample).
Definition: avfilter.h:510
DisplayScale
DisplayScale
Definition: avf_ahistogram.c:31
FF_FILTER_FORWARD_STATUS
FF_FILTER_FORWARD_STATUS(inlink, outlink)
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
AudioHistogramContext::frame_count
int frame_count
Definition: avf_ahistogram.c:55
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
ahistogram_options
static const AVOption ahistogram_options[]
Definition: avf_ahistogram.c:67
h
h
Definition: vp9dsp_template.c:2038
activate
static int activate(AVFilterContext *ctx)
Definition: avf_ahistogram.c:449
int
int
Definition: ffmpeg_filter.c:409
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244
AudioHistogramContext::achistogram
uint64_t * achistogram
Definition: avf_ahistogram.c:42
SlideMode
SlideMode
Definition: avf_ahistogram.c:33
ff_filter_set_ready
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
Definition: avfilter.c:234