FFmpeg
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"
24 #include "avfilter.h"
25 #include "audio.h"
26 #include "formats.h"
27 
28 #define MAX_OVERSAMPLE 64
29 
31  ASC_HARD = -1,
41 };
42 
43 typedef struct Lowpass {
44  float fb0, fb1, fb2;
45  float fa0, fa1, fa2;
46 
47  double db0, db1, db2;
48  double da0, da1, da2;
49 } Lowpass;
50 
51 typedef struct ASoftClipContext {
52  const AVClass *class;
53 
54  int type;
56  int64_t delay;
57  double threshold;
58  double output;
59  double param;
60 
63 
64  void (*filter)(struct ASoftClipContext *s, void **dst, const void **src,
65  int nb_samples, int channels, int start, int end);
67 
68 #define OFFSET(x) offsetof(ASoftClipContext, x)
69 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
70 
71 static const AVOption asoftclip_options[] = {
72  { "type", "set softclip type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, -1, NB_TYPES-1, A, "types" },
73  { "hard", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_HARD}, 0, 0, A, "types" },
74  { "tanh", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_TANH}, 0, 0, A, "types" },
75  { "atan", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_ATAN}, 0, 0, A, "types" },
76  { "cubic", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_CUBIC}, 0, 0, A, "types" },
77  { "exp", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_EXP}, 0, 0, A, "types" },
78  { "alg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_ALG}, 0, 0, A, "types" },
79  { "quintic", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_QUINTIC},0, 0, A, "types" },
80  { "sin", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_SIN}, 0, 0, A, "types" },
81  { "erf", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_ERF}, 0, 0, A, "types" },
82  { "threshold", "set softclip threshold", OFFSET(threshold), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.000001, 1, A },
83  { "output", "set softclip output gain", OFFSET(output), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.000001, 16, A },
84  { "param", "set softclip parameter", OFFSET(param), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.01, 3, A },
85  { "oversample", "set oversample factor", OFFSET(oversample), AV_OPT_TYPE_INT, {.i64=1}, 1, MAX_OVERSAMPLE, A },
86  { NULL }
87 };
88 
89 AVFILTER_DEFINE_CLASS(asoftclip);
90 
92 {
93  static const enum AVSampleFormat sample_fmts[] = {
96  };
98  if (ret < 0)
99  return ret;
100 
102  if (ret < 0)
103  return ret;
104 
106 }
107 
108 static void get_lowpass(Lowpass *s,
109  double frequency,
110  double sample_rate)
111 {
112  double w0 = 2 * M_PI * frequency / sample_rate;
113  double alpha = sin(w0) / (2 * 0.8);
114  double factor;
115 
116  s->da0 = 1 + alpha;
117  s->da1 = -2 * cos(w0);
118  s->da2 = 1 - alpha;
119  s->db0 = (1 - cos(w0)) / 2;
120  s->db1 = 1 - cos(w0);
121  s->db2 = (1 - cos(w0)) / 2;
122 
123  s->da1 /= s->da0;
124  s->da2 /= s->da0;
125  s->db0 /= s->da0;
126  s->db1 /= s->da0;
127  s->db2 /= s->da0;
128  s->da0 /= s->da0;
129 
130  factor = (s->da0 + s->da1 + s->da2) / (s->db0 + s->db1 + s->db2);
131  s->db0 *= factor;
132  s->db1 *= factor;
133  s->db2 *= factor;
134 
135  s->fa0 = s->da0;
136  s->fa1 = s->da1;
137  s->fa2 = s->da2;
138  s->fb0 = s->db0;
139  s->fb1 = s->db1;
140  s->fb2 = s->db2;
141 }
142 
143 static inline float run_lowpassf(const Lowpass *const s,
144  float src, float *w)
145 {
146  float dst;
147 
148  dst = src * s->fb0 + w[0];
149  w[0] = s->fb1 * src + w[1] - s->fa1 * dst;
150  w[1] = s->fb2 * src - s->fa2 * dst;
151 
152  return dst;
153 }
154 
156  void **dptr, const void **sptr,
157  int nb_samples, int channels,
158  int start, int end)
159 {
160  const int oversample = s->oversample;
161  const int nb_osamples = nb_samples * oversample;
162  const float scale = oversample > 1 ? oversample * 0.5f : 1.f;
163  float threshold = s->threshold;
164  float gain = s->output * threshold;
165  float factor = 1.f / threshold;
166  float param = s->param;
167 
168  for (int c = start; c < end; c++) {
169  float *w = (float *)(s->frame[0]->extended_data[c]) + 2 * (oversample - 1);
170  const float *src = sptr[c];
171  float *dst = dptr[c];
172 
173  for (int n = 0; n < nb_samples; n++) {
174  dst[oversample * n] = src[n];
175 
176  for (int m = 1; m < oversample; m++)
177  dst[oversample * n + m] = 0.f;
178  }
179 
180  for (int n = 0; n < nb_osamples && oversample > 1; n++)
181  dst[n] = run_lowpassf(&s->lowpass[oversample - 1], dst[n], w);
182 
183  switch (s->type) {
184  case ASC_HARD:
185  for (int n = 0; n < nb_osamples; n++) {
186  dst[n] = av_clipf(dst[n] * factor, -1.f, 1.f);
187  dst[n] *= gain;
188  }
189  break;
190  case ASC_TANH:
191  for (int n = 0; n < nb_osamples; n++) {
192  dst[n] = tanhf(dst[n] * factor * param);
193  dst[n] *= gain;
194  }
195  break;
196  case ASC_ATAN:
197  for (int n = 0; n < nb_osamples; n++) {
198  dst[n] = 2.f / M_PI * atanf(dst[n] * factor * param);
199  dst[n] *= gain;
200  }
201  break;
202  case ASC_CUBIC:
203  for (int n = 0; n < nb_osamples; n++) {
204  float sample = dst[n] * factor;
205 
206  if (FFABS(sample) >= 1.5f)
207  dst[n] = FFSIGN(sample);
208  else
209  dst[n] = sample - 0.1481f * powf(sample, 3.f);
210  dst[n] *= gain;
211  }
212  break;
213  case ASC_EXP:
214  for (int n = 0; n < nb_osamples; n++) {
215  dst[n] = 2.f / (1.f + expf(-2.f * dst[n] * factor)) - 1.;
216  dst[n] *= gain;
217  }
218  break;
219  case ASC_ALG:
220  for (int n = 0; n < nb_osamples; n++) {
221  float sample = dst[n] * factor;
222 
223  dst[n] = sample / (sqrtf(param + sample * sample));
224  dst[n] *= gain;
225  }
226  break;
227  case ASC_QUINTIC:
228  for (int n = 0; n < nb_osamples; n++) {
229  float sample = dst[n] * factor;
230 
231  if (FFABS(sample) >= 1.25)
232  dst[n] = FFSIGN(sample);
233  else
234  dst[n] = sample - 0.08192f * powf(sample, 5.f);
235  dst[n] *= gain;
236  }
237  break;
238  case ASC_SIN:
239  for (int n = 0; n < nb_osamples; n++) {
240  float sample = dst[n] * factor;
241 
242  if (FFABS(sample) >= M_PI_2)
243  dst[n] = FFSIGN(sample);
244  else
245  dst[n] = sinf(sample);
246  dst[n] *= gain;
247  }
248  break;
249  case ASC_ERF:
250  for (int n = 0; n < nb_osamples; n++) {
251  dst[n] = erff(dst[n] * factor);
252  dst[n] *= gain;
253  }
254  break;
255  default:
256  av_assert0(0);
257  }
258 
259  w = (float *)(s->frame[1]->extended_data[c]) + 2 * (oversample - 1);
260  for (int n = 0; n < nb_osamples && oversample > 1; n++)
261  dst[n] = run_lowpassf(&s->lowpass[oversample - 1], dst[n], w);
262 
263  for (int n = 0; n < nb_samples; n++)
264  dst[n] = dst[n * oversample] * scale;
265  }
266 }
267 
268 static inline double run_lowpassd(const Lowpass *const s,
269  double src, double *w)
270 {
271  double dst;
272 
273  dst = src * s->db0 + w[0];
274  w[0] = s->db1 * src + w[1] - s->da1 * dst;
275  w[1] = s->db2 * src - s->da2 * dst;
276 
277  return dst;
278 }
279 
281  void **dptr, const void **sptr,
282  int nb_samples, int channels,
283  int start, int end)
284 {
285  const int oversample = s->oversample;
286  const int nb_osamples = nb_samples * oversample;
287  const double scale = oversample > 1 ? oversample * 0.5 : 1.;
288  double threshold = s->threshold;
289  double gain = s->output * threshold;
290  double factor = 1. / threshold;
291  double param = s->param;
292 
293  for (int c = start; c < end; c++) {
294  double *w = (double *)(s->frame[0]->extended_data[c]) + 2 * (oversample - 1);
295  const double *src = sptr[c];
296  double *dst = dptr[c];
297 
298  for (int n = 0; n < nb_samples; n++) {
299  dst[oversample * n] = src[n];
300 
301  for (int m = 1; m < oversample; m++)
302  dst[oversample * n + m] = 0.f;
303  }
304 
305  for (int n = 0; n < nb_osamples && oversample > 1; n++)
306  dst[n] = run_lowpassd(&s->lowpass[oversample - 1], dst[n], w);
307 
308  switch (s->type) {
309  case ASC_HARD:
310  for (int n = 0; n < nb_osamples; n++) {
311  dst[n] = av_clipd(dst[n] * factor, -1., 1.);
312  dst[n] *= gain;
313  }
314  break;
315  case ASC_TANH:
316  for (int n = 0; n < nb_osamples; n++) {
317  dst[n] = tanh(dst[n] * factor * param);
318  dst[n] *= gain;
319  }
320  break;
321  case ASC_ATAN:
322  for (int n = 0; n < nb_osamples; n++) {
323  dst[n] = 2. / M_PI * atan(dst[n] * factor * param);
324  dst[n] *= gain;
325  }
326  break;
327  case ASC_CUBIC:
328  for (int n = 0; n < nb_osamples; n++) {
329  double sample = dst[n] * factor;
330 
331  if (FFABS(sample) >= 1.5)
332  dst[n] = FFSIGN(sample);
333  else
334  dst[n] = sample - 0.1481 * pow(sample, 3.);
335  dst[n] *= gain;
336  }
337  break;
338  case ASC_EXP:
339  for (int n = 0; n < nb_osamples; n++) {
340  dst[n] = 2. / (1. + exp(-2. * dst[n] * factor)) - 1.;
341  dst[n] *= gain;
342  }
343  break;
344  case ASC_ALG:
345  for (int n = 0; n < nb_osamples; n++) {
346  double sample = dst[n] * factor;
347 
348  dst[n] = sample / (sqrt(param + sample * sample));
349  dst[n] *= gain;
350  }
351  break;
352  case ASC_QUINTIC:
353  for (int n = 0; n < nb_osamples; n++) {
354  double sample = dst[n] * factor;
355 
356  if (FFABS(sample) >= 1.25)
357  dst[n] = FFSIGN(sample);
358  else
359  dst[n] = sample - 0.08192 * pow(sample, 5.);
360  dst[n] *= gain;
361  }
362  break;
363  case ASC_SIN:
364  for (int n = 0; n < nb_osamples; n++) {
365  double sample = dst[n] * factor;
366 
367  if (FFABS(sample) >= M_PI_2)
368  dst[n] = FFSIGN(sample);
369  else
370  dst[n] = sin(sample);
371  dst[n] *= gain;
372  }
373  break;
374  case ASC_ERF:
375  for (int n = 0; n < nb_osamples; n++) {
376  dst[n] = erf(dst[n] * factor);
377  dst[n] *= gain;
378  }
379  break;
380  default:
381  av_assert0(0);
382  }
383 
384  w = (double *)(s->frame[1]->extended_data[c]) + 2 * (oversample - 1);
385  for (int n = 0; n < nb_osamples && oversample > 1; n++)
386  dst[n] = run_lowpassd(&s->lowpass[oversample - 1], dst[n], w);
387 
388  for (int n = 0; n < nb_samples; n++)
389  dst[n] = dst[n * oversample] * scale;
390  }
391 }
392 
394 {
395  AVFilterContext *ctx = inlink->dst;
396  ASoftClipContext *s = ctx->priv;
397 
398  switch (inlink->format) {
399  case AV_SAMPLE_FMT_FLTP: s->filter = filter_flt; break;
400  case AV_SAMPLE_FMT_DBLP: s->filter = filter_dbl; break;
401  default: av_assert0(0);
402  }
403 
404  s->frame[0] = ff_get_audio_buffer(inlink, 2 * MAX_OVERSAMPLE);
405  s->frame[1] = ff_get_audio_buffer(inlink, 2 * MAX_OVERSAMPLE);
406  if (!s->frame[0] || !s->frame[1])
407  return AVERROR(ENOMEM);
408 
409  for (int i = 0; i < MAX_OVERSAMPLE; i++) {
410  get_lowpass(&s->lowpass[i], inlink->sample_rate / 2, inlink->sample_rate * (i + 1));
411  }
412 
413  return 0;
414 }
415 
416 typedef struct ThreadData {
417  AVFrame *in, *out;
419  int channels;
420 } ThreadData;
421 
422 static int filter_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
423 {
424  ASoftClipContext *s = ctx->priv;
425  ThreadData *td = arg;
426  AVFrame *out = td->out;
427  AVFrame *in = td->in;
428  const int channels = td->channels;
429  const int nb_samples = td->nb_samples;
430  const int start = (channels * jobnr) / nb_jobs;
431  const int end = (channels * (jobnr+1)) / nb_jobs;
432 
433  s->filter(s, (void **)out->extended_data, (const void **)in->extended_data,
434  nb_samples, channels, start, end);
435 
436  return 0;
437 }
438 
440 {
441  AVFilterContext *ctx = inlink->dst;
442  ASoftClipContext *s = ctx->priv;
443  AVFilterLink *outlink = ctx->outputs[0];
444  int nb_samples, channels;
445  ThreadData td;
446  AVFrame *out;
447 
448  if (av_frame_is_writable(in) && s->oversample == 1) {
449  out = in;
450  } else {
451  out = ff_get_audio_buffer(outlink, in->nb_samples * s->oversample);
452  if (!out) {
453  av_frame_free(&in);
454  return AVERROR(ENOMEM);
455  }
457  }
458 
459  nb_samples = in->nb_samples;
460  channels = in->channels;
461 
462  td.in = in;
463  td.out = out;
464  td.nb_samples = nb_samples;
465  td.channels = channels;
468 
469  if (out != in)
470  av_frame_free(&in);
471 
472  out->nb_samples /= s->oversample;
473  return ff_filter_frame(outlink, out);
474 }
475 
477 {
478  ASoftClipContext *s = ctx->priv;
479 
480  av_frame_free(&s->frame[0]);
481  av_frame_free(&s->frame[1]);
482 }
483 
484 static const AVFilterPad inputs[] = {
485  {
486  .name = "default",
487  .type = AVMEDIA_TYPE_AUDIO,
488  .filter_frame = filter_frame,
489  .config_props = config_input,
490  },
491 };
492 
493 static const AVFilterPad outputs[] = {
494  {
495  .name = "default",
496  .type = AVMEDIA_TYPE_AUDIO,
497  },
498 };
499 
501  .name = "asoftclip",
502  .description = NULL_IF_CONFIG_SMALL("Audio Soft Clipper."),
503  .query_formats = query_formats,
504  .priv_size = sizeof(ASoftClipContext),
505  .priv_class = &asoftclip_class,
508  .uninit = uninit,
509  .process_command = ff_filter_process_command,
512 };
ff_get_audio_buffer
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:88
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:69
MAX_OVERSAMPLE
#define MAX_OVERSAMPLE
Definition: af_asoftclip.c:28
td
#define td
Definition: regdef.h:70
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_asoftclip.c:476
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
NB_TYPES
@ NB_TYPES
Definition: af_asoftclip.c:40
opt.h
ASC_EXP
@ ASC_EXP
Definition: af_asoftclip.c:35
out
FILE * out
Definition: movenc.c:54
ASoftClipContext::output
double output
Definition: af_asoftclip.c:58
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1019
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:948
output
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
Definition: filter_design.txt:225
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
config_input
static int config_input(AVFilterLink *inlink)
Definition: af_asoftclip.c:393
outputs
static const AVFilterPad outputs[]
Definition: af_asoftclip.c:493
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:112
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:303
w
uint8_t w
Definition: llviddspenc.c:38
M_PI_2
#define M_PI_2
Definition: mathematics.h:55
AVOption
AVOption.
Definition: opt.h:247
expf
#define expf(x)
Definition: libm.h:283
asoftclip_options
static const AVOption asoftclip_options[]
Definition: af_asoftclip.c:71
ff_set_common_all_samplerates
int ff_set_common_all_samplerates(AVFilterContext *ctx)
Equivalent to ff_set_common_samplerates(ctx, ff_all_samplerates())
Definition: formats.c:687
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:153
ThreadData::out
AVFrame * out
Definition: af_adeclick.c:492
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: af_asoftclip.c:91
ThreadData::channels
int channels
Definition: af_asoftclip.c:419
Lowpass::db1
double db1
Definition: af_asoftclip.c:47
sample_rate
sample_rate
Definition: ffmpeg_filter.c:156
ASC_ALG
@ ASC_ALG
Definition: af_asoftclip.c:36
formats.h
run_lowpassd
static double run_lowpassd(const Lowpass *const s, double src, double *w)
Definition: af_asoftclip.c:268
Lowpass::db0
double db0
Definition: af_asoftclip.c:47
FFSIGN
#define FFSIGN(a)
Definition: common.h:66
Lowpass::fb2
float fb2
Definition: af_asoftclip.c:44
type
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 type
Definition: writing_filters.txt:86
ASC_TANH
@ ASC_TANH
Definition: af_asoftclip.c:32
scale
static av_always_inline float scale(float x, float s)
Definition: vf_v360.c:1376
OFFSET
#define OFFSET(x)
Definition: af_asoftclip.c:68
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
ASoftClipContext::oversample
int oversample
Definition: af_asoftclip.c:55
avassert.h
av_cold
#define av_cold
Definition: attributes.h:90
ASC_ATAN
@ ASC_ATAN
Definition: af_asoftclip.c:33
s
#define s(width, name)
Definition: cbs_vp9.c:257
AVFrame::channels
int channels
number of audio channels, only used for audio.
Definition: frame.h:592
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:226
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
ThreadData::nb_samples
int nb_samples
Definition: af_asoftclip.c:418
ff_set_common_formats_from_list
int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts)
Equivalent to ff_set_common_formats(ctx, ff_make_format_list(fmts))
Definition: formats.c:703
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
ctx
AVFormatContext * ctx
Definition: movenc.c:48
channels
channels
Definition: aptx.h:33
Lowpass::fb0
float fb0
Definition: af_asoftclip.c:44
ASoftClipContext
Definition: af_asoftclip.c:51
f
#define f(width, name)
Definition: cbs_vp9.c:255
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:152
arg
const char * arg
Definition: jacosubdec.c:67
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:65
filter_dbl
static void filter_dbl(ASoftClipContext *s, void **dptr, const void **sptr, int nb_samples, int channels, int start, int end)
Definition: af_asoftclip.c:280
inputs
static const AVFilterPad inputs[]
Definition: af_asoftclip.c:484
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
ASC_CUBIC
@ ASC_CUBIC
Definition: af_asoftclip.c:34
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:537
ASoftClipContext::type
int type
Definition: af_asoftclip.c:54
ASoftClipContext::filter
void(* filter)(struct ASoftClipContext *s, void **dst, const void **src, int nb_samples, int channels, int start, int end)
Definition: af_asoftclip.c:64
A
#define A
Definition: af_asoftclip.c:69
av_clipf
#define av_clipf
Definition: common.h:144
run_lowpassf
static float run_lowpassf(const Lowpass *const s, float src, float *w)
Definition: af_asoftclip.c:143
Lowpass
Definition: af_asoftclip.c:43
src
#define src
Definition: vp8dsp.c:255
Lowpass::fa1
float fa1
Definition: af_asoftclip.c:45
ASC_QUINTIC
@ ASC_QUINTIC
Definition: af_asoftclip.c:37
sinf
#define sinf(x)
Definition: libm.h:419
ff_set_common_all_channel_counts
int ff_set_common_all_channel_counts(AVFilterContext *ctx)
Equivalent to ff_set_common_channel_layouts(ctx, ff_all_channel_counts())
Definition: formats.c:669
exp
int8_t exp
Definition: eval.c:72
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
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(asoftclip)
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
powf
#define powf(x, y)
Definition: libm.h:50
av_clipd
#define av_clipd
Definition: common.h:147
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
sample
#define sample
Definition: flacdsp_template.c:44
av_frame_is_writable
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:473
ASoftClipContext::threshold
double threshold
Definition: af_asoftclip.c:57
ff_filter_process_command
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:883
ASC_ERF
@ ASC_ERF
Definition: af_asoftclip.c:39
Lowpass::fa0
float fa0
Definition: af_asoftclip.c:45
Lowpass::fb1
float fb1
Definition: af_asoftclip.c:44
ASC_SIN
@ ASC_SIN
Definition: af_asoftclip.c:38
M_PI
#define M_PI
Definition: mathematics.h:52
Lowpass::da1
double da1
Definition: af_asoftclip.c:48
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#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:130
ff_af_asoftclip
const AVFilter ff_af_asoftclip
Definition: af_asoftclip.c:500
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:369
i
int i
Definition: input.c:406
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:350
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:804
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
atanf
#define atanf(x)
Definition: libm.h:40
ThreadData
Used for passing data between threads.
Definition: dsddec.c:67
Lowpass::db2
double db2
Definition: af_asoftclip.c:47
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
ASoftClipContext::frame
AVFrame * frame[2]
Definition: af_asoftclip.c:62
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
erf
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
AVFilter
Filter definition.
Definition: avfilter.h:149
ret
ret
Definition: filter_design.txt:187
ASoftClipTypes
ASoftClipTypes
Definition: af_asoftclip.c:30
Lowpass::fa2
float fa2
Definition: af_asoftclip.c:45
channel_layout.h
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
avfilter.h
AV_SAMPLE_FMT_DBLP
@ AV_SAMPLE_FMT_DBLP
double, planar
Definition: samplefmt.h:70
filter_flt
static void filter_flt(ASoftClipContext *s, void **dptr, const void **sptr, int nb_samples, int channels, int start, int end)
Definition: af_asoftclip.c:155
AVFilterContext
An instance of a filter.
Definition: avfilter.h:346
factor
static const int factor[16]
Definition: vf_pp7.c:76
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:121
audio.h
filter_channels
static int filter_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: af_asoftclip.c:422
ThreadData::in
AVFrame * in
Definition: af_adecorrelate.c:171
ASoftClipContext::param
double param
Definition: af_asoftclip.c:59
alpha
static const int16_t alpha[]
Definition: ilbcdata.h:55
Lowpass::da2
double da2
Definition: af_asoftclip.c:48
get_lowpass
static void get_lowpass(Lowpass *s, double frequency, double sample_rate)
Definition: af_asoftclip.c:108
ASoftClipContext::delay
int64_t delay
Definition: af_asoftclip.c:56
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:153
Lowpass::da0
double da0
Definition: af_asoftclip.c:48
ASoftClipContext::lowpass
Lowpass lowpass[MAX_OVERSAMPLE]
Definition: af_asoftclip.c:61
ASC_HARD
@ ASC_HARD
Definition: af_asoftclip.c:31
ff_filter_execute
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: internal.h:143
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: af_asoftclip.c:439
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233