FFmpeg  4.4.8
af_asoftclip.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 The FFmpeg Project
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"
23 #include "libavutil/opt.h"
25 #include "avfilter.h"
26 #include "filters.h"
27 #include "audio.h"
28 #include "formats.h"
29 
31  ASC_HARD = -1,
41 };
42 
43 typedef struct ASoftClipContext {
44  const AVClass *class;
45 
46  int type;
49  double threshold;
50  double output;
51  double param;
52 
55 
57 
58  void (*filter)(struct ASoftClipContext *s, void **dst, const void **src,
59  int nb_samples, int channels, int start, int end);
61 
62 #define OFFSET(x) offsetof(ASoftClipContext, x)
63 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
64 #define F AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
65 
66 static const AVOption asoftclip_options[] = {
67  { "type", "set softclip type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, -1, NB_TYPES-1, A, "types" },
68  { "hard", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_HARD}, 0, 0, A, "types" },
69  { "tanh", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_TANH}, 0, 0, A, "types" },
70  { "atan", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_ATAN}, 0, 0, A, "types" },
71  { "cubic", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_CUBIC}, 0, 0, A, "types" },
72  { "exp", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_EXP}, 0, 0, A, "types" },
73  { "alg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_ALG}, 0, 0, A, "types" },
74  { "quintic", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_QUINTIC},0, 0, A, "types" },
75  { "sin", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_SIN}, 0, 0, A, "types" },
76  { "erf", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_ERF}, 0, 0, A, "types" },
77  { "threshold", "set softclip threshold", OFFSET(threshold), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.000001, 1, A },
78  { "output", "set softclip output gain", OFFSET(output), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.000001, 16, A },
79  { "param", "set softclip parameter", OFFSET(param), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.01, 3, A },
80  { "oversample", "set oversample factor", OFFSET(oversample), AV_OPT_TYPE_INT, {.i64=1}, 1, 32, F },
81  { NULL }
82 };
83 
85 
87 {
90  static const enum AVSampleFormat sample_fmts[] = {
94  };
95  int ret;
96 
98  if (!formats)
99  return AVERROR(ENOMEM);
101  if (ret < 0)
102  return ret;
103 
105  if (!layouts)
106  return AVERROR(ENOMEM);
107 
109  if (ret < 0)
110  return ret;
111 
114 }
115 
117  void **dptr, const void **sptr,
118  int nb_samples, int channels,
119  int start, int end)
120 {
121  float threshold = s->threshold;
122  float gain = s->output * threshold;
123  float factor = 1.f / threshold;
124  float param = s->param;
125 
126  for (int c = start; c < end; c++) {
127  const float *src = sptr[c];
128  float *dst = dptr[c];
129 
130  switch (s->type) {
131  case ASC_HARD:
132  for (int n = 0; n < nb_samples; n++) {
133  dst[n] = av_clipf(src[n] * factor, -1.f, 1.f);
134  dst[n] *= gain;
135  }
136  break;
137  case ASC_TANH:
138  for (int n = 0; n < nb_samples; n++) {
139  dst[n] = tanhf(src[n] * factor * param);
140  dst[n] *= gain;
141  }
142  break;
143  case ASC_ATAN:
144  for (int n = 0; n < nb_samples; n++) {
145  dst[n] = 2.f / M_PI * atanf(src[n] * factor * param);
146  dst[n] *= gain;
147  }
148  break;
149  case ASC_CUBIC:
150  for (int n = 0; n < nb_samples; n++) {
151  float sample = src[n] * factor;
152 
153  if (FFABS(sample) >= 1.5f)
154  dst[n] = FFSIGN(sample);
155  else
156  dst[n] = sample - 0.1481f * powf(sample, 3.f);
157  dst[n] *= gain;
158  }
159  break;
160  case ASC_EXP:
161  for (int n = 0; n < nb_samples; n++) {
162  dst[n] = 2.f / (1.f + expf(-2.f * src[n] * factor)) - 1.;
163  dst[n] *= gain;
164  }
165  break;
166  case ASC_ALG:
167  for (int n = 0; n < nb_samples; n++) {
168  float sample = src[n] * factor;
169 
170  dst[n] = sample / (sqrtf(param + sample * sample));
171  dst[n] *= gain;
172  }
173  break;
174  case ASC_QUINTIC:
175  for (int n = 0; n < nb_samples; n++) {
176  float sample = src[n] * factor;
177 
178  if (FFABS(sample) >= 1.25)
179  dst[n] = FFSIGN(sample);
180  else
181  dst[n] = sample - 0.08192f * powf(sample, 5.f);
182  dst[n] *= gain;
183  }
184  break;
185  case ASC_SIN:
186  for (int n = 0; n < nb_samples; n++) {
187  float sample = src[n] * factor;
188 
189  if (FFABS(sample) >= M_PI_2)
190  dst[n] = FFSIGN(sample);
191  else
192  dst[n] = sinf(sample);
193  dst[n] *= gain;
194  }
195  break;
196  case ASC_ERF:
197  for (int n = 0; n < nb_samples; n++) {
198  dst[n] = erff(src[n] * factor);
199  dst[n] *= gain;
200  }
201  break;
202  default:
203  av_assert0(0);
204  }
205  }
206 }
207 
209  void **dptr, const void **sptr,
210  int nb_samples, int channels,
211  int start, int end)
212 {
213  double threshold = s->threshold;
214  double gain = s->output * threshold;
215  double factor = 1. / threshold;
216  double param = s->param;
217 
218  for (int c = start; c < end; c++) {
219  const double *src = sptr[c];
220  double *dst = dptr[c];
221 
222  switch (s->type) {
223  case ASC_HARD:
224  for (int n = 0; n < nb_samples; n++) {
225  dst[n] = av_clipd(src[n] * factor, -1., 1.);
226  dst[n] *= gain;
227  }
228  break;
229  case ASC_TANH:
230  for (int n = 0; n < nb_samples; n++) {
231  dst[n] = tanh(src[n] * factor * param);
232  dst[n] *= gain;
233  }
234  break;
235  case ASC_ATAN:
236  for (int n = 0; n < nb_samples; n++) {
237  dst[n] = 2. / M_PI * atan(src[n] * factor * param);
238  dst[n] *= gain;
239  }
240  break;
241  case ASC_CUBIC:
242  for (int n = 0; n < nb_samples; n++) {
243  double sample = src[n] * factor;
244 
245  if (FFABS(sample) >= 1.5)
246  dst[n] = FFSIGN(sample);
247  else
248  dst[n] = sample - 0.1481 * pow(sample, 3.);
249  dst[n] *= gain;
250  }
251  break;
252  case ASC_EXP:
253  for (int n = 0; n < nb_samples; n++) {
254  dst[n] = 2. / (1. + exp(-2. * src[n] * factor)) - 1.;
255  dst[n] *= gain;
256  }
257  break;
258  case ASC_ALG:
259  for (int n = 0; n < nb_samples; n++) {
260  double sample = src[n] * factor;
261 
262  dst[n] = sample / (sqrt(param + sample * sample));
263  dst[n] *= gain;
264  }
265  break;
266  case ASC_QUINTIC:
267  for (int n = 0; n < nb_samples; n++) {
268  double sample = src[n] * factor;
269 
270  if (FFABS(sample) >= 1.25)
271  dst[n] = FFSIGN(sample);
272  else
273  dst[n] = sample - 0.08192 * pow(sample, 5.);
274  dst[n] *= gain;
275  }
276  break;
277  case ASC_SIN:
278  for (int n = 0; n < nb_samples; n++) {
279  double sample = src[n] * factor;
280 
281  if (FFABS(sample) >= M_PI_2)
282  dst[n] = FFSIGN(sample);
283  else
284  dst[n] = sin(sample);
285  dst[n] *= gain;
286  }
287  break;
288  case ASC_ERF:
289  for (int n = 0; n < nb_samples; n++) {
290  dst[n] = erf(src[n] * factor);
291  dst[n] *= gain;
292  }
293  break;
294  default:
295  av_assert0(0);
296  }
297  }
298 }
299 
300 static int config_input(AVFilterLink *inlink)
301 {
302  AVFilterContext *ctx = inlink->dst;
303  ASoftClipContext *s = ctx->priv;
304  int ret;
305 
306  switch (inlink->format) {
307  case AV_SAMPLE_FMT_FLT:
308  case AV_SAMPLE_FMT_FLTP: s->filter = filter_flt; break;
309  case AV_SAMPLE_FMT_DBL:
310  case AV_SAMPLE_FMT_DBLP: s->filter = filter_dbl; break;
311  default: av_assert0(0);
312  }
313 
314  if (s->oversample <= 1)
315  return 0;
316 
317  s->up_ctx = swr_alloc();
318  s->down_ctx = swr_alloc();
319  if (!s->up_ctx || !s->down_ctx)
320  return AVERROR(ENOMEM);
321 
322  av_opt_set_int(s->up_ctx, "in_channel_layout", inlink->channel_layout, 0);
323  av_opt_set_int(s->up_ctx, "in_sample_rate", inlink->sample_rate, 0);
324  av_opt_set_sample_fmt(s->up_ctx, "in_sample_fmt", inlink->format, 0);
325 
326  av_opt_set_int(s->up_ctx, "out_channel_layout", inlink->channel_layout, 0);
327  av_opt_set_int(s->up_ctx, "out_sample_rate", inlink->sample_rate * s->oversample, 0);
328  av_opt_set_sample_fmt(s->up_ctx, "out_sample_fmt", inlink->format, 0);
329 
330  av_opt_set_int(s->down_ctx, "in_channel_layout", inlink->channel_layout, 0);
331  av_opt_set_int(s->down_ctx, "in_sample_rate", inlink->sample_rate * s->oversample, 0);
332  av_opt_set_sample_fmt(s->down_ctx, "in_sample_fmt", inlink->format, 0);
333 
334  av_opt_set_int(s->down_ctx, "out_channel_layout", inlink->channel_layout, 0);
335  av_opt_set_int(s->down_ctx, "out_sample_rate", inlink->sample_rate, 0);
336  av_opt_set_sample_fmt(s->down_ctx, "out_sample_fmt", inlink->format, 0);
337 
338  ret = swr_init(s->up_ctx);
339  if (ret < 0)
340  return ret;
341 
342  ret = swr_init(s->down_ctx);
343  if (ret < 0)
344  return ret;
345 
346  return 0;
347 }
348 
349 typedef struct ThreadData {
350  AVFrame *in, *out;
352  int channels;
353 } ThreadData;
354 
355 static int filter_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
356 {
357  ASoftClipContext *s = ctx->priv;
358  ThreadData *td = arg;
359  AVFrame *out = td->out;
360  AVFrame *in = td->in;
361  const int channels = td->channels;
362  const int nb_samples = td->nb_samples;
363  const int start = ff_slice_pos(channels, jobnr, nb_jobs);
364  const int end = ff_slice_pos(channels, jobnr + 1, nb_jobs);
365 
366  s->filter(s, (void **)out->extended_data, (const void **)in->extended_data,
367  nb_samples, channels, start, end);
368 
369  return 0;
370 }
371 
372 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
373 {
374  AVFilterContext *ctx = inlink->dst;
375  ASoftClipContext *s = ctx->priv;
376  AVFilterLink *outlink = ctx->outputs[0];
377  int ret, nb_samples, channels;
378  ThreadData td;
379  AVFrame *out;
380 
381  if (av_frame_is_writable(in)) {
382  out = in;
383  } else {
384  out = ff_get_audio_buffer(outlink, in->nb_samples);
385  if (!out) {
386  av_frame_free(&in);
387  return AVERROR(ENOMEM);
388  }
390  }
391 
392  if (av_sample_fmt_is_planar(in->format)) {
393  nb_samples = in->nb_samples;
394  channels = in->channels;
395  } else {
396  nb_samples = in->channels * in->nb_samples;
397  channels = 1;
398  }
399 
400  if (s->oversample > 1) {
401  s->frame = ff_get_audio_buffer(outlink, in->nb_samples * s->oversample);
402  if (!s->frame) {
403  ret = AVERROR(ENOMEM);
404  goto fail;
405  }
406 
407  ret = swr_convert(s->up_ctx, (uint8_t**)s->frame->extended_data, in->nb_samples * s->oversample,
408  (const uint8_t **)in->extended_data, in->nb_samples);
409  if (ret < 0)
410  goto fail;
411 
412  td.in = s->frame;
413  td.out = s->frame;
414  td.nb_samples = av_sample_fmt_is_planar(in->format) ? ret : ret * in->channels;
415  td.channels = channels;
418 
419  ret = swr_convert(s->down_ctx, (uint8_t**)out->extended_data, out->nb_samples,
420  (const uint8_t **)s->frame->extended_data, ret);
421  if (ret < 0)
422  goto fail;
423 
424  if (out->pts)
425  out->pts -= s->delay;
426  s->delay += in->nb_samples - ret;
427  out->nb_samples = ret;
428 
429  av_frame_free(&s->frame);
430  } else {
431  td.in = in;
432  td.out = out;
433  td.nb_samples = nb_samples;
434  td.channels = channels;
437  }
438 
439  if (out != in)
440  av_frame_free(&in);
441 
442  return ff_filter_frame(outlink, out);
443 fail:
444  if (out != in)
445  av_frame_free(&out);
446  av_frame_free(&in);
447  av_frame_free(&s->frame);
448 
449  return ret;
450 }
451 
453 {
454  ASoftClipContext *s = ctx->priv;
455 
456  swr_free(&s->up_ctx);
457  swr_free(&s->down_ctx);
458 }
459 
460 static const AVFilterPad inputs[] = {
461  {
462  .name = "default",
463  .type = AVMEDIA_TYPE_AUDIO,
464  .filter_frame = filter_frame,
465  .config_props = config_input,
466  },
467  { NULL }
468 };
469 
470 static const AVFilterPad outputs[] = {
471  {
472  .name = "default",
473  .type = AVMEDIA_TYPE_AUDIO,
474  },
475  { NULL }
476 };
477 
479  .name = "asoftclip",
480  .description = NULL_IF_CONFIG_SMALL("Audio Soft Clipper."),
481  .query_formats = query_formats,
482  .priv_size = sizeof(ASoftClipContext),
483  .priv_class = &asoftclip_class,
484  .inputs = inputs,
485  .outputs = outputs,
486  .uninit = uninit,
490 };
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:925
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: af_acrusher.c:336
static const AVOption asoftclip_options[]
Definition: af_asoftclip.c:66
static void filter_dbl(ASoftClipContext *s, void **dptr, const void **sptr, int nb_samples, int channels, int start, int end)
Definition: af_asoftclip.c:208
#define F
Definition: af_asoftclip.c:64
static int query_formats(AVFilterContext *ctx)
Definition: af_asoftclip.c:86
static int filter_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: af_asoftclip.c:355
static int config_input(AVFilterLink *inlink)
Definition: af_asoftclip.c:300
ASoftClipTypes
Definition: af_asoftclip.c:30
@ ASC_HARD
Definition: af_asoftclip.c:31
@ ASC_ALG
Definition: af_asoftclip.c:36
@ ASC_SIN
Definition: af_asoftclip.c:38
@ ASC_TANH
Definition: af_asoftclip.c:32
@ ASC_ATAN
Definition: af_asoftclip.c:33
@ ASC_ERF
Definition: af_asoftclip.c:39
@ ASC_CUBIC
Definition: af_asoftclip.c:34
@ ASC_EXP
Definition: af_asoftclip.c:35
@ ASC_QUINTIC
Definition: af_asoftclip.c:37
@ NB_TYPES
Definition: af_asoftclip.c:40
static const AVFilterPad inputs[]
Definition: af_asoftclip.c:460
static const AVFilterPad outputs[]
Definition: af_asoftclip.c:470
static void filter_flt(ASoftClipContext *s, void **dptr, const void **sptr, int nb_samples, int channels, int start, int end)
Definition: af_asoftclip.c:116
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: af_asoftclip.c:372
#define A
Definition: af_asoftclip.c:63
AVFILTER_DEFINE_CLASS(asoftclip)
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_asoftclip.c:452
AVFilter ff_af_asoftclip
Definition: af_asoftclip.c:478
#define OFFSET(x)
Definition: af_asoftclip.c:62
channels
Definition: aptx.h:33
#define av_cold
Definition: attributes.h:88
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:86
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;} return ac;} 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;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->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);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
uint8_t
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1096
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition: avfilter.c:882
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:802
Main libavfilter public API header.
#define flags(name, subs,...)
Definition: cbs_av1.c:572
#define s(width, name)
Definition: cbs_vp9.c:257
audio channel layout utility functions
#define fail()
Definition: checkasm.h:133
#define FFMIN(a, b)
Definition: common.h:105
#define av_clipd
Definition: common.h:173
#define av_clipf
Definition: common.h:170
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
#define FFSIGN(a)
Definition: common.h:73
#define NULL
Definition: coverity.c:32
long long int64_t
Definition: coverity.c:34
int8_t exp
Definition: eval.c:74
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
Definition: filters.h:271
#define sample
AVFilterChannelLayouts * ff_all_channel_counts(void)
Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition.
Definition: formats.c:436
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:587
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:286
int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates)
Definition: formats.c:575
int ff_set_common_channel_layouts(AVFilterContext *ctx, AVFilterChannelLayouts *channel_layouts)
A helper for query_formats() which sets all links to the same list of channel layouts/sample rates.
Definition: formats.c:568
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:421
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
@ AV_OPT_TYPE_INT
Definition: opt.h:225
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:227
#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:126
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
#define AVERROR(e)
Definition: error.h:43
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:594
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:658
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
Definition: samplefmt.c:112
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:69
@ AV_SAMPLE_FMT_FLT
float
Definition: samplefmt.h:63
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
@ AV_SAMPLE_FMT_DBLP
double, planar
Definition: samplefmt.h:70
@ AV_SAMPLE_FMT_DBL
double
Definition: samplefmt.h:64
av_cold void swr_free(SwrContext **ss)
Free the given SwrContext and set the pointer to NULL.
Definition: swresample.c:137
av_cold int swr_init(struct SwrContext *s)
Initialize context after user parameters have been set.
Definition: swresample.c:152
av_cold struct SwrContext * swr_alloc(void)
Allocate SwrContext.
Definition: options.c:149
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
Definition: opt.c:586
int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags)
Definition: opt.c:704
cl_device_type type
const char * arg
Definition: jacosubdec.c:66
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
static double erf(double z)
erf function Algorithm taken from the Boost project, source: http://www.boost.org/doc/libs/1_46_1/boo...
Definition: libm.h:121
#define atanf(x)
Definition: libm.h:40
#define sinf(x)
Definition: libm.h:419
#define expf(x)
Definition: libm.h:283
#define powf(x, y)
Definition: libm.h:50
#define M_PI_2
Definition: mathematics.h:55
#define M_PI
Definition: mathematics.h:52
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:434
AVOptions.
#define td
Definition: regdef.h:70
typedef void(RENAME(mix_any_func_type))
formats
Definition: signature.h:48
AVFrame * frame
Definition: af_asoftclip.c:56
SwrContext * down_ctx
Definition: af_asoftclip.c:54
void(* filter)(struct ASoftClipContext *s, void **dst, const void **src, int nb_samples, int channels, int start, int end)
Definition: af_asoftclip.c:58
SwrContext * up_ctx
Definition: af_asoftclip.c:53
Describe the class of an AVClass context structure.
Definition: log.h:67
A list of supported channel layouts.
Definition: formats.h:86
An instance of a filter.
Definition: avfilter.h:341
A list of supported formats for one end of a filter link.
Definition: formats.h:65
A filter pad used for either input or output.
Definition: internal.h:54
const char * name
Pad name.
Definition: internal.h:60
Filter definition.
Definition: avfilter.h:145
const char * name
Filter name.
Definition: avfilter.h:149
AVFormatInternal * internal
An opaque field for libavformat internal usage.
Definition: avformat.h:1699
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
AVOption.
Definition: opt.h:248
The libswresample context.
Used for passing data between threads.
Definition: dsddec.c:67
AVFrame * out
Definition: af_adeclick.c:502
AVFrame * in
Definition: af_adenorm.c:223
int attribute_align_arg swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_count, const uint8_t *in_arg[SWR_CH_MAX], int in_count)
Definition: swresample.c:714
libswresample public header
#define src
Definition: vp8dsp.c:255
FILE * out
Definition: movenc.c:54
AVFormatContext * ctx
Definition: movenc.c:48
static const int factor[16]
Definition: vf_pp7.c:77
static double c[64]