FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 "formats.h"
26 #include "audio.h"
27 #include "video.h"
28 #include "internal.h"
29 
35 
36 typedef struct AudioHistogramContext {
37  const AVClass *class;
39  int w, h;
41  uint64_t *achistogram;
42  uint64_t *shistogram;
43  int ascale;
44  int scale;
45  float phisto;
47  int apos;
48  int ypos;
49  int slide;
50  int dmode;
51  int dchannels;
52  int count;
55  AVFrame *in[101];
56  int first;
58 
59 #define OFFSET(x) offsetof(AudioHistogramContext, x)
60 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
61 
62 static const AVOption ahistogram_options[] = {
63  { "dmode", "set method to display channels", OFFSET(dmode), AV_OPT_TYPE_INT, {.i64=SINGLE}, 0, NB_DMODES-1, FLAGS, "dmode" },
64  { "single", "all channels use single histogram", 0, AV_OPT_TYPE_CONST, {.i64=SINGLE}, 0, 0, FLAGS, "dmode" },
65  { "separate", "each channel have own histogram", 0, AV_OPT_TYPE_CONST, {.i64=SEPARATE}, 0, 0, FLAGS, "dmode" },
66  { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
67  { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
68  { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS },
69  { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, 0, 0, FLAGS },
70  { "scale", "set display scale", OFFSET(scale), AV_OPT_TYPE_INT, {.i64=LOG}, LINEAR, NB_SCALES-1, FLAGS, "scale" },
71  { "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=LOG}, 0, 0, FLAGS, "scale" },
72  { "sqrt", "square root", 0, AV_OPT_TYPE_CONST, {.i64=SQRT}, 0, 0, FLAGS, "scale" },
73  { "cbrt", "cubic root", 0, AV_OPT_TYPE_CONST, {.i64=CBRT}, 0, 0, FLAGS, "scale" },
74  { "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=LINEAR}, 0, 0, FLAGS, "scale" },
75  { "rlog", "reverse logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=RLOG}, 0, 0, FLAGS, "scale" },
76  { "ascale", "set amplitude scale", OFFSET(ascale), AV_OPT_TYPE_INT, {.i64=ALOG}, LINEAR, NB_ASCALES-1, FLAGS, "ascale" },
77  { "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=ALOG}, 0, 0, FLAGS, "ascale" },
78  { "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=ALINEAR}, 0, 0, FLAGS, "ascale" },
79  { "acount", "how much frames to accumulate", OFFSET(count), AV_OPT_TYPE_INT, {.i64=1}, -1, 100, FLAGS },
80  { "rheight", "set histogram ratio of window height", OFFSET(phisto), AV_OPT_TYPE_FLOAT, {.dbl=0.10}, 0, 1, FLAGS },
81  { "slide", "set sonogram sliding", OFFSET(slide), AV_OPT_TYPE_INT, {.i64=REPLACE}, 0, NB_SLIDES-1, FLAGS, "slide" },
82  { "replace", "replace old rows with new", 0, AV_OPT_TYPE_CONST, {.i64=REPLACE}, 0, 0, FLAGS, "slide" },
83  { "scroll", "scroll from top to bottom", 0, AV_OPT_TYPE_CONST, {.i64=SCROLL}, 0, 0, FLAGS, "slide" },
84  { NULL }
85 };
86 
87 AVFILTER_DEFINE_CLASS(ahistogram);
88 
90 {
93  AVFilterLink *inlink = ctx->inputs[0];
94  AVFilterLink *outlink = ctx->outputs[0];
96  static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_YUVA444P, AV_PIX_FMT_NONE };
97  int ret = AVERROR(EINVAL);
98 
99  formats = ff_make_format_list(sample_fmts);
100  if ((ret = ff_formats_ref (formats, &inlink->out_formats )) < 0 ||
101  (layouts = ff_all_channel_counts()) == NULL ||
102  (ret = ff_channel_layouts_ref (layouts, &inlink->out_channel_layouts)) < 0)
103  return ret;
104 
105  formats = ff_all_samplerates();
106  if ((ret = ff_formats_ref(formats, &inlink->out_samplerates)) < 0)
107  return ret;
108 
109  formats = ff_make_format_list(pix_fmts);
110  if ((ret = ff_formats_ref(formats, &outlink->in_formats)) < 0)
111  return ret;
112 
113  return 0;
114 }
115 
116 static int config_input(AVFilterLink *inlink)
117 {
118  AVFilterContext *ctx = inlink->dst;
119  AudioHistogramContext *s = ctx->priv;
120  int nb_samples;
121 
122  nb_samples = FFMAX(1024, ((double)inlink->sample_rate / av_q2d(s->frame_rate)) + 0.5);
123  inlink->partial_buf_size =
124  inlink->min_samples =
125  inlink->max_samples = nb_samples;
126 
127  s->dchannels = s->dmode == SINGLE ? 1 : inlink->channels;
128  s->shistogram = av_calloc(s->w, s->dchannels * sizeof(*s->shistogram));
129  if (!s->shistogram)
130  return AVERROR(ENOMEM);
131 
132  s->achistogram = av_calloc(s->w, s->dchannels * sizeof(*s->achistogram));
133  if (!s->achistogram)
134  return AVERROR(ENOMEM);
135 
136  return 0;
137 }
138 
139 static int config_output(AVFilterLink *outlink)
140 {
141  AudioHistogramContext *s = outlink->src->priv;
142 
143  outlink->w = s->w;
144  outlink->h = s->h;
145  outlink->sample_aspect_ratio = (AVRational){1,1};
146  outlink->frame_rate = s->frame_rate;
147 
148  s->histogram_h = s->h * s->phisto;
149  s->ypos = s->h * s->phisto;
150 
151  if (s->dmode == SEPARATE) {
152  s->combine_buffer = av_malloc_array(outlink->w * 3, sizeof(*s->combine_buffer));
153  if (!s->combine_buffer)
154  return AVERROR(ENOMEM);
155  }
156 
157  return 0;
158 }
159 
160 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
161 {
162  AVFilterContext *ctx = inlink->dst;
163  AVFilterLink *outlink = ctx->outputs[0];
164  AudioHistogramContext *s = ctx->priv;
165  const int H = s->histogram_h;
166  const int w = s->w;
167  int c, y, n, p, bin;
168  uint64_t acmax = 1;
169 
170  if (!s->out || s->out->width != outlink->w ||
171  s->out->height != outlink->h) {
172  av_frame_free(&s->out);
173  s->out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
174  if (!s->out) {
175  av_frame_free(&in);
176  return AVERROR(ENOMEM);
177  }
178  for (n = H; n < s->h; n++) {
179  memset(s->out->data[0] + n * s->out->linesize[0], 0, w);
180  memset(s->out->data[1] + n * s->out->linesize[0], 127, w);
181  memset(s->out->data[2] + n * s->out->linesize[0], 127, w);
182  memset(s->out->data[3] + n * s->out->linesize[0], 0, w);
183  }
184  }
185 
186  if (s->dmode == SEPARATE) {
187  for (y = 0; y < w; y++) {
188  s->combine_buffer[3 * y ] = 0;
189  s->combine_buffer[3 * y + 1] = 127.5;
190  s->combine_buffer[3 * y + 2] = 127.5;
191  }
192  }
193 
194  for (n = 0; n < H; n++) {
195  memset(s->out->data[0] + n * s->out->linesize[0], 0, w);
196  memset(s->out->data[1] + n * s->out->linesize[0], 127, w);
197  memset(s->out->data[2] + n * s->out->linesize[0], 127, w);
198  memset(s->out->data[3] + n * s->out->linesize[0], 0, w);
199  }
200  s->out->pts = in->pts;
201 
202  s->first = s->frame_count;
203 
204  switch (s->ascale) {
205  case ALINEAR:
206  for (c = 0; c < inlink->channels; c++) {
207  const float *src = (const float *)in->extended_data[c];
208  uint64_t *achistogram = &s->achistogram[(s->dmode == SINGLE ? 0: c) * w];
209 
210  for (n = 0; n < in->nb_samples; n++) {
211  bin = lrint(av_clipf(fabsf(src[n]), 0, 1) * (w - 1));
212 
213  achistogram[bin]++;
214  }
215 
216  if (s->in[s->first] && s->count >= 0) {
217  uint64_t *shistogram = &s->shistogram[(s->dmode == SINGLE ? 0: c) * w];
218  const float *src2 = (const float *)s->in[s->first]->extended_data[c];
219 
220  for (n = 0; n < in->nb_samples; n++) {
221  bin = lrint(av_clipf(fabsf(src2[n]), 0, 1) * (w - 1));
222 
223  shistogram[bin]++;
224  }
225  }
226  }
227  break;
228  case ALOG:
229  for (c = 0; c < inlink->channels; c++) {
230  const float *src = (const float *)in->extended_data[c];
231  uint64_t *achistogram = &s->achistogram[(s->dmode == SINGLE ? 0: c) * w];
232 
233  for (n = 0; n < in->nb_samples; n++) {
234  bin = lrint(av_clipf(1 + log10(fabsf(src[n])) / 6, 0, 1) * (w - 1));
235 
236  achistogram[bin]++;
237  }
238 
239  if (s->in[s->first] && s->count >= 0) {
240  uint64_t *shistogram = &s->shistogram[(s->dmode == SINGLE ? 0: c) * w];
241  const float *src2 = (const float *)s->in[s->first]->extended_data[c];
242 
243  for (n = 0; n < in->nb_samples; n++) {
244  bin = lrint(av_clipf(1 + log10(fabsf(src2[n])) / 6, 0, 1) * (w - 1));
245 
246  shistogram[bin]++;
247  }
248  }
249  }
250  break;
251  }
252 
253  av_frame_free(&s->in[s->frame_count]);
254  s->in[s->frame_count] = in;
255  s->frame_count++;
256  if (s->frame_count > s->count)
257  s->frame_count = 0;
258 
259  for (n = 0; n < w * s->dchannels; n++) {
260  acmax = FFMAX(s->achistogram[n] - s->shistogram[n], acmax);
261  }
262 
263  for (c = 0; c < s->dchannels; c++) {
264  uint64_t *shistogram = &s->shistogram[c * w];
265  uint64_t *achistogram = &s->achistogram[c * w];
266  float yf, uf, vf;
267 
268  if (s->dmode == SEPARATE) {
269  yf = 256.0f / s->dchannels;
270  uf = yf * M_PI;
271  vf = yf * M_PI;
272  uf *= 0.5 * sin((2 * M_PI * c) / s->dchannels);
273  vf *= 0.5 * cos((2 * M_PI * c) / s->dchannels);
274  }
275 
276  for (n = 0; n < w; n++) {
277  double a, aa;
278  int h;
279 
280  a = achistogram[n] - shistogram[n];
281 
282  switch (s->scale) {
283  case LINEAR:
284  aa = a / (double)acmax;
285  break;
286  case SQRT:
287  aa = sqrt(a) / sqrt(acmax);
288  break;
289  case CBRT:
290  aa = cbrt(a) / cbrt(acmax);
291  break;
292  case LOG:
293  aa = log2(a + 1) / log2(acmax + 1);
294  break;
295  case RLOG:
296  aa = 1. - log2(a + 1) / log2(acmax + 1);
297  if (aa == 1.)
298  aa = 0;
299  break;
300  default:
301  av_assert0(0);
302  }
303 
304  h = aa * (H - 1);
305 
306  if (s->dmode == SINGLE) {
307 
308  for (y = H - h; y < H; y++) {
309  s->out->data[0][y * s->out->linesize[0] + n] = 255;
310  s->out->data[3][y * s->out->linesize[0] + n] = 255;
311  }
312 
313  if (s->h - H > 0) {
314  h = aa * 255;
315 
316  s->out->data[0][s->ypos * s->out->linesize[0] + n] = h;
317  s->out->data[1][s->ypos * s->out->linesize[1] + n] = 127;
318  s->out->data[2][s->ypos * s->out->linesize[2] + n] = 127;
319  s->out->data[3][s->ypos * s->out->linesize[3] + n] = 255;
320  }
321  } else if (s->dmode == SEPARATE) {
322  float *out = &s->combine_buffer[3 * n];
323  int old;
324 
325  old = s->out->data[0][(H - h) * s->out->linesize[0] + n];
326  for (y = H - h; y < H; y++) {
327  if (s->out->data[0][y * s->out->linesize[0] + n] != old)
328  break;
329  old = s->out->data[0][y * s->out->linesize[0] + n];
330  s->out->data[0][y * s->out->linesize[0] + n] = yf;
331  s->out->data[1][y * s->out->linesize[1] + n] = 128+uf;
332  s->out->data[2][y * s->out->linesize[2] + n] = 128+vf;
333  s->out->data[3][y * s->out->linesize[3] + n] = 255;
334  }
335 
336  out[0] += aa * yf;
337  out[1] += aa * uf;
338  out[2] += aa * vf;
339  }
340  }
341  }
342 
343  if (s->h - H > 0) {
344  if (s->dmode == SEPARATE) {
345  for (n = 0; n < w; n++) {
346  float *cb = &s->combine_buffer[3 * n];
347 
348  s->out->data[0][s->ypos * s->out->linesize[0] + n] = cb[0];
349  s->out->data[1][s->ypos * s->out->linesize[1] + n] = cb[1];
350  s->out->data[2][s->ypos * s->out->linesize[2] + n] = cb[2];
351  s->out->data[3][s->ypos * s->out->linesize[3] + n] = 255;
352  }
353  }
354 
355  if (s->slide == SCROLL) {
356  for (p = 0; p < 4; p++) {
357  for (y = s->h; y >= H + 1; y--) {
358  memmove(s->out->data[p] + (y ) * s->out->linesize[p],
359  s->out->data[p] + (y-1) * s->out->linesize[p], w);
360  }
361  }
362  }
363 
364  s->ypos++;
365  if (s->slide == SCROLL || s->ypos >= s->h)
366  s->ypos = H;
367  }
368 
369  return ff_filter_frame(outlink, av_frame_clone(s->out));
370 }
371 
373 {
374  AudioHistogramContext *s = ctx->priv;
375  int i;
376 
377  av_frame_free(&s->out);
378  av_freep(&s->shistogram);
379  av_freep(&s->achistogram);
381  for (i = 0; i < 101; i++)
382  av_frame_free(&s->in[i]);
383 }
384 
386  {
387  .name = "default",
388  .type = AVMEDIA_TYPE_AUDIO,
389  .config_props = config_input,
390  .filter_frame = filter_frame,
391  },
392  { NULL }
393 };
394 
396  {
397  .name = "default",
398  .type = AVMEDIA_TYPE_VIDEO,
399  .config_props = config_output,
400  },
401  { NULL }
402 };
403 
405  .name = "ahistogram",
406  .description = NULL_IF_CONFIG_SMALL("Convert input audio to histogram video output."),
407  .uninit = uninit,
408  .query_formats = query_formats,
409  .priv_size = sizeof(AudioHistogramContext),
410  .inputs = audiovectorscope_inputs,
411  .outputs = audiovectorscope_outputs,
412  .priv_class = &ahistogram_class,
413 };
float, planar
Definition: samplefmt.h:69
#define NULL
Definition: coverity.c:32
static const AVFilterPad audiovectorscope_outputs[]
const char * s
Definition: avisynth_c.h:768
This structure describes decoded (raw) audio or video data.
Definition: frame.h:187
AVOption.
Definition: opt.h:246
Main libavfilter public API header.
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:92
#define src
Definition: vp8dsp.c:254
#define log2(x)
Definition: libm.h:404
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:230
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
DisplayScale
const char * name
Pad name.
Definition: internal.h:60
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:331
AmplitudeScale
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition: formats.c:435
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:97
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1125
#define av_cold
Definition: attributes.h:82
AVOptions.
static int query_formats(AVFilterContext *ctx)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:271
#define OFFSET(x)
static const AVOption ahistogram_options[]
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition: rational.h:104
static int config_output(AVFilterLink *outlink)
SlideMode
A filter pad used for either input or output.
Definition: internal.h:54
int width
width and height of the video frame
Definition: frame.h:239
#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:163
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
void * priv
private data for use by the filter
Definition: avfilter.h:338
#define cbrt
Definition: tablegen.h:35
simple assert() macros that are a bit more flexible than ISO C assert().
static int config_input(AVFilterLink *inlink)
GLsizei count
Definition: opengl_enc.c:109
#define FFMAX(a, b)
Definition: common.h:94
#define FLAGS
AVFILTER_DEFINE_CLASS(ahistogram)
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:440
AVFormatContext * ctx
Definition: movenc.c:48
int n
Definition: avisynth_c.h:684
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:386
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:485
A list of supported channel layouts.
Definition: formats.h:85
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:376
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:218
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:189
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
HistogramMode
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:144
Rational number (pair of numerator and denominator).
Definition: rational.h:58
offset must point to AVRational
Definition: opt.h:236
const char * name
Filter name.
Definition: avfilter.h:148
offset must point to two consecutive integers
Definition: opt.h:233
misc parsing utilities
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:335
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:434
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:262
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:395
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:201
static const AVFilterPad audiovectorscope_inputs[]
static double c[64]
static av_cold void uninit(AVFilterContext *ctx)
#define H
Definition: pixlet.c:37
A list of supported formats for one end of a filter link.
Definition: formats.h:64
#define lrint
Definition: tablegen.h:53
AVFilter ff_avf_ahistogram
An instance of a filter.
Definition: avfilter.h:323
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:701
int height
Definition: frame.h:239
FILE * out
Definition: movenc.c:54
#define av_freep(p)
#define M_PI
Definition: mathematics.h:52
#define av_malloc_array(a, b)
formats
Definition: signature.h:48
internal API functions
AVFilterChannelLayouts * ff_all_channel_counts(void)
Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition...
Definition: formats.c:410
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:234
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:244
for(j=16;j >0;--j)
DisplayMode