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