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"
25 #include "avfilter.h"
26 #include "audio.h"
27 #include "formats.h"
28 
30  ASC_HARD = -1,
40 };
41 
42 typedef struct ASoftClipContext {
43  const AVClass *class;
44 
45  int type;
47  int64_t delay;
48  double threshold;
49  double output;
50  double param;
51 
54 
56 
57  void (*filter)(struct ASoftClipContext *s, void **dst, const void **src,
58  int nb_samples, int channels, int start, int end);
60 
61 #define OFFSET(x) offsetof(ASoftClipContext, x)
62 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
63 #define F AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
64 
65 static const AVOption asoftclip_options[] = {
66  { "type", "set softclip type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, -1, NB_TYPES-1, A, "types" },
67  { "hard", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_HARD}, 0, 0, A, "types" },
68  { "tanh", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_TANH}, 0, 0, A, "types" },
69  { "atan", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_ATAN}, 0, 0, A, "types" },
70  { "cubic", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_CUBIC}, 0, 0, A, "types" },
71  { "exp", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_EXP}, 0, 0, A, "types" },
72  { "alg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_ALG}, 0, 0, A, "types" },
73  { "quintic", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_QUINTIC},0, 0, A, "types" },
74  { "sin", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_SIN}, 0, 0, A, "types" },
75  { "erf", NULL, 0, AV_OPT_TYPE_CONST, {.i64=ASC_ERF}, 0, 0, A, "types" },
76  { "threshold", "set softclip threshold", OFFSET(threshold), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.000001, 1, A },
77  { "output", "set softclip output gain", OFFSET(output), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.000001, 16, A },
78  { "param", "set softclip parameter", OFFSET(param), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.01, 3, A },
79  { "oversample", "set oversample factor", OFFSET(oversample), AV_OPT_TYPE_INT, {.i64=1}, 1, 32, F },
80  { NULL }
81 };
82 
83 AVFILTER_DEFINE_CLASS(asoftclip);
84 
86 {
89  static const enum AVSampleFormat sample_fmts[] = {
93  };
94  int ret;
95 
97  if (!formats)
98  return AVERROR(ENOMEM);
100  if (ret < 0)
101  return ret;
102 
104  if (!layouts)
105  return AVERROR(ENOMEM);
106 
108  if (ret < 0)
109  return ret;
110 
113 }
114 
116  void **dptr, const void **sptr,
117  int nb_samples, int channels,
118  int start, int end)
119 {
120  float threshold = s->threshold;
121  float gain = s->output * threshold;
122  float factor = 1.f / threshold;
123  float param = s->param;
124 
125  for (int c = start; c < end; c++) {
126  const float *src = sptr[c];
127  float *dst = dptr[c];
128 
129  switch (s->type) {
130  case ASC_HARD:
131  for (int n = 0; n < nb_samples; n++) {
132  dst[n] = av_clipf(src[n] * factor, -1.f, 1.f);
133  dst[n] *= gain;
134  }
135  break;
136  case ASC_TANH:
137  for (int n = 0; n < nb_samples; n++) {
138  dst[n] = tanhf(src[n] * factor * param);
139  dst[n] *= gain;
140  }
141  break;
142  case ASC_ATAN:
143  for (int n = 0; n < nb_samples; n++) {
144  dst[n] = 2.f / M_PI * atanf(src[n] * factor * param);
145  dst[n] *= gain;
146  }
147  break;
148  case ASC_CUBIC:
149  for (int n = 0; n < nb_samples; n++) {
150  float sample = src[n] * factor;
151 
152  if (FFABS(sample) >= 1.5f)
153  dst[n] = FFSIGN(sample);
154  else
155  dst[n] = sample - 0.1481f * powf(sample, 3.f);
156  dst[n] *= gain;
157  }
158  break;
159  case ASC_EXP:
160  for (int n = 0; n < nb_samples; n++) {
161  dst[n] = 2.f / (1.f + expf(-2.f * src[n] * factor)) - 1.;
162  dst[n] *= gain;
163  }
164  break;
165  case ASC_ALG:
166  for (int n = 0; n < nb_samples; n++) {
167  float sample = src[n] * factor;
168 
169  dst[n] = sample / (sqrtf(param + sample * sample));
170  dst[n] *= gain;
171  }
172  break;
173  case ASC_QUINTIC:
174  for (int n = 0; n < nb_samples; n++) {
175  float sample = src[n] * factor;
176 
177  if (FFABS(sample) >= 1.25)
178  dst[n] = FFSIGN(sample);
179  else
180  dst[n] = sample - 0.08192f * powf(sample, 5.f);
181  dst[n] *= gain;
182  }
183  break;
184  case ASC_SIN:
185  for (int n = 0; n < nb_samples; n++) {
186  float sample = src[n] * factor;
187 
188  if (FFABS(sample) >= M_PI_2)
189  dst[n] = FFSIGN(sample);
190  else
191  dst[n] = sinf(sample);
192  dst[n] *= gain;
193  }
194  break;
195  case ASC_ERF:
196  for (int n = 0; n < nb_samples; n++) {
197  dst[n] = erff(src[n] * factor);
198  dst[n] *= gain;
199  }
200  break;
201  default:
202  av_assert0(0);
203  }
204  }
205 }
206 
208  void **dptr, const void **sptr,
209  int nb_samples, int channels,
210  int start, int end)
211 {
212  double threshold = s->threshold;
213  double gain = s->output * threshold;
214  double factor = 1. / threshold;
215  double param = s->param;
216 
217  for (int c = start; c < end; c++) {
218  const double *src = sptr[c];
219  double *dst = dptr[c];
220 
221  switch (s->type) {
222  case ASC_HARD:
223  for (int n = 0; n < nb_samples; n++) {
224  dst[n] = av_clipd(src[n] * factor, -1., 1.);
225  dst[n] *= gain;
226  }
227  break;
228  case ASC_TANH:
229  for (int n = 0; n < nb_samples; n++) {
230  dst[n] = tanh(src[n] * factor * param);
231  dst[n] *= gain;
232  }
233  break;
234  case ASC_ATAN:
235  for (int n = 0; n < nb_samples; n++) {
236  dst[n] = 2. / M_PI * atan(src[n] * factor * param);
237  dst[n] *= gain;
238  }
239  break;
240  case ASC_CUBIC:
241  for (int n = 0; n < nb_samples; n++) {
242  double sample = src[n] * factor;
243 
244  if (FFABS(sample) >= 1.5)
245  dst[n] = FFSIGN(sample);
246  else
247  dst[n] = sample - 0.1481 * pow(sample, 3.);
248  dst[n] *= gain;
249  }
250  break;
251  case ASC_EXP:
252  for (int n = 0; n < nb_samples; n++) {
253  dst[n] = 2. / (1. + exp(-2. * src[n] * factor)) - 1.;
254  dst[n] *= gain;
255  }
256  break;
257  case ASC_ALG:
258  for (int n = 0; n < nb_samples; n++) {
259  double sample = src[n] * factor;
260 
261  dst[n] = sample / (sqrt(param + sample * sample));
262  dst[n] *= gain;
263  }
264  break;
265  case ASC_QUINTIC:
266  for (int n = 0; n < nb_samples; n++) {
267  double sample = src[n] * factor;
268 
269  if (FFABS(sample) >= 1.25)
270  dst[n] = FFSIGN(sample);
271  else
272  dst[n] = sample - 0.08192 * pow(sample, 5.);
273  dst[n] *= gain;
274  }
275  break;
276  case ASC_SIN:
277  for (int n = 0; n < nb_samples; n++) {
278  double sample = src[n] * factor;
279 
280  if (FFABS(sample) >= M_PI_2)
281  dst[n] = FFSIGN(sample);
282  else
283  dst[n] = sin(sample);
284  dst[n] *= gain;
285  }
286  break;
287  case ASC_ERF:
288  for (int n = 0; n < nb_samples; n++) {
289  dst[n] = erf(src[n] * factor);
290  dst[n] *= gain;
291  }
292  break;
293  default:
294  av_assert0(0);
295  }
296  }
297 }
298 
300 {
301  AVFilterContext *ctx = inlink->dst;
302  ASoftClipContext *s = ctx->priv;
303  int ret;
304 
305  switch (inlink->format) {
306  case AV_SAMPLE_FMT_FLT:
307  case AV_SAMPLE_FMT_FLTP: s->filter = filter_flt; break;
308  case AV_SAMPLE_FMT_DBL:
309  case AV_SAMPLE_FMT_DBLP: s->filter = filter_dbl; break;
310  default: av_assert0(0);
311  }
312 
313  if (s->oversample <= 1)
314  return 0;
315 
316  s->up_ctx = swr_alloc();
317  s->down_ctx = swr_alloc();
318  if (!s->up_ctx || !s->down_ctx)
319  return AVERROR(ENOMEM);
320 
321  av_opt_set_int(s->up_ctx, "in_channel_layout", inlink->channel_layout, 0);
322  av_opt_set_int(s->up_ctx, "in_sample_rate", inlink->sample_rate, 0);
323  av_opt_set_sample_fmt(s->up_ctx, "in_sample_fmt", inlink->format, 0);
324 
325  av_opt_set_int(s->up_ctx, "out_channel_layout", inlink->channel_layout, 0);
326  av_opt_set_int(s->up_ctx, "out_sample_rate", inlink->sample_rate * s->oversample, 0);
327  av_opt_set_sample_fmt(s->up_ctx, "out_sample_fmt", inlink->format, 0);
328 
329  av_opt_set_int(s->down_ctx, "in_channel_layout", inlink->channel_layout, 0);
330  av_opt_set_int(s->down_ctx, "in_sample_rate", inlink->sample_rate * s->oversample, 0);
331  av_opt_set_sample_fmt(s->down_ctx, "in_sample_fmt", inlink->format, 0);
332 
333  av_opt_set_int(s->down_ctx, "out_channel_layout", inlink->channel_layout, 0);
334  av_opt_set_int(s->down_ctx, "out_sample_rate", inlink->sample_rate, 0);
335  av_opt_set_sample_fmt(s->down_ctx, "out_sample_fmt", inlink->format, 0);
336 
337  ret = swr_init(s->up_ctx);
338  if (ret < 0)
339  return ret;
340 
341  ret = swr_init(s->down_ctx);
342  if (ret < 0)
343  return ret;
344 
345  return 0;
346 }
347 
348 typedef struct ThreadData {
349  AVFrame *in, *out;
351  int channels;
352 } ThreadData;
353 
354 static int filter_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
355 {
356  ASoftClipContext *s = ctx->priv;
357  ThreadData *td = arg;
358  AVFrame *out = td->out;
359  AVFrame *in = td->in;
360  const int channels = td->channels;
361  const int nb_samples = td->nb_samples;
362  const int start = (channels * jobnr) / nb_jobs;
363  const int end = (channels * (jobnr+1)) / nb_jobs;
364 
365  s->filter(s, (void **)out->extended_data, (const void **)in->extended_data,
366  nb_samples, channels, start, end);
367 
368  return 0;
369 }
370 
372 {
373  AVFilterContext *ctx = inlink->dst;
374  ASoftClipContext *s = ctx->priv;
375  AVFilterLink *outlink = ctx->outputs[0];
376  int ret, nb_samples, channels;
377  ThreadData td;
378  AVFrame *out;
379 
380  if (av_frame_is_writable(in)) {
381  out = in;
382  } else {
383  out = ff_get_audio_buffer(outlink, in->nb_samples);
384  if (!out) {
385  av_frame_free(&in);
386  return AVERROR(ENOMEM);
387  }
389  }
390 
391  if (av_sample_fmt_is_planar(in->format)) {
392  nb_samples = in->nb_samples;
393  channels = in->channels;
394  } else {
395  nb_samples = in->channels * in->nb_samples;
396  channels = 1;
397  }
398 
399  if (s->oversample > 1) {
400  s->frame = ff_get_audio_buffer(outlink, in->nb_samples * s->oversample);
401  if (!s->frame) {
402  ret = AVERROR(ENOMEM);
403  goto fail;
404  }
405 
406  ret = swr_convert(s->up_ctx, (uint8_t**)s->frame->extended_data, in->nb_samples * s->oversample,
407  (const uint8_t **)in->extended_data, in->nb_samples);
408  if (ret < 0)
409  goto fail;
410 
411  td.in = s->frame;
412  td.out = s->frame;
413  td.nb_samples = av_sample_fmt_is_planar(in->format) ? ret : ret * in->channels;
414  td.channels = channels;
417 
418  ret = swr_convert(s->down_ctx, (uint8_t**)out->extended_data, out->nb_samples,
419  (const uint8_t **)s->frame->extended_data, ret);
420  if (ret < 0)
421  goto fail;
422 
423  if (out->pts)
424  out->pts -= s->delay;
425  s->delay += in->nb_samples - ret;
426  out->nb_samples = ret;
427 
428  av_frame_free(&s->frame);
429  } else {
430  td.in = in;
431  td.out = out;
432  td.nb_samples = nb_samples;
433  td.channels = channels;
436  }
437 
438  if (out != in)
439  av_frame_free(&in);
440 
441  return ff_filter_frame(outlink, out);
442 fail:
443  if (out != in)
444  av_frame_free(&out);
445  av_frame_free(&in);
446  av_frame_free(&s->frame);
447 
448  return ret;
449 }
450 
452 {
453  ASoftClipContext *s = ctx->priv;
454 
455  swr_free(&s->up_ctx);
456  swr_free(&s->down_ctx);
457 }
458 
459 static const AVFilterPad inputs[] = {
460  {
461  .name = "default",
462  .type = AVMEDIA_TYPE_AUDIO,
463  .filter_frame = filter_frame,
464  .config_props = config_input,
465  },
466  { NULL }
467 };
468 
469 static const AVFilterPad outputs[] = {
470  {
471  .name = "default",
472  .type = AVMEDIA_TYPE_AUDIO,
473  },
474  { NULL }
475 };
476 
478  .name = "asoftclip",
479  .description = NULL_IF_CONFIG_SMALL("Audio Soft Clipper."),
480  .query_formats = query_formats,
481  .priv_size = sizeof(ASoftClipContext),
482  .priv_class = &asoftclip_class,
483  .inputs = inputs,
484  .outputs = outputs,
485  .uninit = uninit,
489 };
formats
formats
Definition: signature.h:48
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:86
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:69
AVFilterChannelLayouts
A list of supported channel layouts.
Definition: formats.h:86
td
#define td
Definition: regdef.h:70
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_asoftclip.c:451
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
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:286
out
FILE * out
Definition: movenc.c:54
ASoftClipContext::output
double output
Definition: af_asoftclip.c:49
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:978
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:953
layouts
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:434
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:299
outputs
static const AVFilterPad outputs[]
Definition: af_asoftclip.c:469
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:111
ff_all_channel_counts
AVFilterChannelLayouts * ff_all_channel_counts(void)
Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition.
Definition: formats.c:429
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:303
M_PI_2
#define M_PI_2
Definition: mathematics.h:55
AVOption
AVOption.
Definition: opt.h:248
expf
#define expf(x)
Definition: libm.h:283
asoftclip_options
static const AVOption asoftclip_options[]
Definition: af_asoftclip.c:65
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:149
ThreadData::out
AVFrame * out
Definition: af_adeclick.c:502
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: af_asoftclip.c:85
AVFormatContext::internal
AVFormatInternal * internal
An opaque field for libavformat internal usage.
Definition: avformat.h:1555
ThreadData::channels
int channels
Definition: af_asoftclip.c:351
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:65
ASC_ALG
@ ASC_ALG
Definition: af_asoftclip.c:35
formats.h
fail
#define fail()
Definition: checkasm.h:134
FFSIGN
#define FFSIGN(a)
Definition: common.h:73
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
OFFSET
#define OFFSET(x)
Definition: af_asoftclip.c:61
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
ASoftClipContext::oversample
int oversample
Definition: af_asoftclip.c:46
avassert.h
av_cold
#define av_cold
Definition: attributes.h:90
ASoftClipContext::down_ctx
SwrContext * down_ctx
Definition: af_asoftclip.c:53
ff_set_common_formats
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:580
ASC_ATAN
@ ASC_ATAN
Definition: af_asoftclip.c:32
swr_init
av_cold int swr_init(struct SwrContext *s)
Initialize context after user parameters have been set.
Definition: swresample.c:152
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:227
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
swr_alloc
av_cold struct SwrContext * swr_alloc(void)
Allocate SwrContext.
Definition: options.c:149
ThreadData::nb_samples
int nb_samples
Definition: af_asoftclip.c:350
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
av_sample_fmt_is_planar
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
Definition: samplefmt.c:112
swr_convert
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
ctx
AVFormatContext * ctx
Definition: movenc.c:48
channels
channels
Definition: aptx.h:33
ASoftClipContext
Definition: af_asoftclip.c:42
SwrContext
The libswresample context.
Definition: swresample_internal.h:95
f
#define f(width, name)
Definition: cbs_vp9.c:255
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:72
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:207
inputs
static const AVFilterPad inputs[]
Definition: af_asoftclip.c:459
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
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:536
ASoftClipContext::type
int type
Definition: af_asoftclip.c:45
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:57
A
#define A
Definition: af_asoftclip.c:62
av_clipf
#define av_clipf
Definition: common.h:170
src
#define src
Definition: vp8dsp.c:255
ASC_QUINTIC
@ ASC_QUINTIC
Definition: af_asoftclip.c:36
sinf
#define sinf(x)
Definition: libm.h:419
exp
int8_t exp
Definition: eval.c:72
swresample.h
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)
av_opt_set_int
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
Definition: opt.c:586
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
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: af_acrusher.c:336
av_clipd
#define av_clipd
Definition: common.h:173
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
sample
#define sample
Definition: flacdsp_template.c:44
swr_free
av_cold void swr_free(SwrContext **ss)
Free the given SwrContext and set the pointer to NULL.
Definition: swresample.c:137
av_frame_is_writable
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:472
ASoftClipContext::threshold
double threshold
Definition: af_asoftclip.c:48
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:376
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:842
FFMIN
#define FFMIN(a, b)
Definition: common.h:105
ASC_ERF
@ ASC_ERF
Definition: af_asoftclip.c:38
ASC_SIN
@ ASC_SIN
Definition: af_asoftclip.c:37
M_PI
#define M_PI
Definition: mathematics.h:52
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:126
ff_af_asoftclip
const AVFilter ff_af_asoftclip
Definition: af_asoftclip.c:477
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:369
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:350
ASoftClipContext::frame
AVFrame * frame
Definition: af_asoftclip.c:55
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:762
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
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
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:145
ret
ret
Definition: filter_design.txt:187
ASoftClipTypes
ASoftClipTypes
Definition: af_asoftclip.c:29
ff_all_samplerates
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:414
channel_layout.h
ASoftClipContext::up_ctx
SwrContext * up_ctx
Definition: af_asoftclip.c:52
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
avfilter.h
F
#define F
Definition: af_asoftclip.c:63
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:115
AVFilterContext
An instance of a filter.
Definition: avfilter.h:333
factor
static const int factor[16]
Definition: vf_pp7.c:77
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:354
ThreadData::in
AVFrame * in
Definition: af_adenorm.c:223
ASoftClipContext::param
double param
Definition: af_asoftclip.c:50
ASoftClipContext::delay
int64_t delay
Definition: af_asoftclip.c:47
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
ASC_HARD
@ ASC_HARD
Definition: af_asoftclip.c:30
ff_set_common_samplerates
int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates)
Definition: formats.c:568
AV_SAMPLE_FMT_DBL
@ AV_SAMPLE_FMT_DBL
double
Definition: samplefmt.h:64
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: af_asoftclip.c:371
av_opt_set_sample_fmt
int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags)
Definition: opt.c:704
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
AV_SAMPLE_FMT_FLT
@ AV_SAMPLE_FMT_FLT
float
Definition: samplefmt.h:63
ff_set_common_channel_layouts
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:561