Go to the documentation of this file.
27 #define MAX_OVERSAMPLE 64
64 int nb_samples,
int channels,
int start,
int end);
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
95 double alpha = sin(w0) / (2 * 0.8);
99 s->da1 = -2 * cos(w0);
101 s->db0 = (1 - cos(w0)) / 2;
102 s->db1 = 1 - cos(w0);
103 s->db2 = (1 - cos(w0)) / 2;
112 factor = (
s->da0 +
s->da1 +
s->da2) / (
s->db0 +
s->db1 +
s->db2);
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;
138 void **dptr,
const void **sptr,
143 const int nb_osamples = nb_samples *
oversample;
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];
155 for (
int n = 0; n < nb_samples; n++) {
162 for (
int n = 0; n < nb_osamples && oversample > 1; n++)
167 for (
int n = 0; n < nb_osamples; n++) {
173 for (
int n = 0; n < nb_osamples; n++) {
179 for (
int n = 0; n < nb_osamples; n++) {
185 for (
int n = 0; n < nb_osamples; n++) {
196 for (
int n = 0; n < nb_osamples; n++) {
197 dst[n] = 2.f / (1.f +
expf(-2.
f * dst[n] *
factor)) - 1.;
202 for (
int n = 0; n < nb_osamples; n++) {
210 for (
int n = 0; n < nb_osamples; n++) {
221 for (
int n = 0; n < nb_osamples; n++) {
232 for (
int n = 0; n < nb_osamples; n++) {
233 dst[n] = erff(dst[n] *
factor);
241 w = (
float *)(
s->frame[1]->extended_data[
c]) + 2 * (
oversample - 1);
242 for (
int n = 0; n < nb_osamples && oversample > 1; n++)
245 for (
int n = 0; n < nb_samples; n++)
251 double src,
double *
w)
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;
263 void **dptr,
const void **sptr,
268 const int nb_osamples = nb_samples *
oversample;
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];
280 for (
int n = 0; n < nb_samples; n++) {
287 for (
int n = 0; n < nb_osamples && oversample > 1; n++)
292 for (
int n = 0; n < nb_osamples; n++) {
298 for (
int n = 0; n < nb_osamples; n++) {
304 for (
int n = 0; n < nb_osamples; n++) {
310 for (
int n = 0; n < nb_osamples; n++) {
321 for (
int n = 0; n < nb_osamples; n++) {
322 dst[n] = 2. / (1. +
exp(-2. * dst[n] *
factor)) - 1.;
327 for (
int n = 0; n < nb_osamples; n++) {
335 for (
int n = 0; n < nb_osamples; n++) {
346 for (
int n = 0; n < nb_osamples; n++) {
357 for (
int n = 0; n < nb_osamples; n++) {
366 w = (
double *)(
s->frame[1]->extended_data[
c]) + 2 * (
oversample - 1);
367 for (
int n = 0; n < nb_osamples && oversample > 1; n++)
370 for (
int n = 0; n < nb_samples; n++)
388 if (!
s->frame[0] || !
s->frame[1])
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;
446 td.nb_samples = nb_samples;
454 out->nb_samples /=
s->oversample;
479 .priv_class = &asoftclip_class,
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
@ AV_SAMPLE_FMT_FLTP
float, planar
static av_cold void uninit(AVFilterContext *ctx)
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
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
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
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
static int config_input(AVFilterLink *inlink)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
static const AVOption asoftclip_options[]
const char * name
Filter name.
int nb_channels
Number of channels in this layout.
A link between two filters.
static double run_lowpassd(const Lowpass *const s, double src, double *w)
AVChannelLayout ch_layout
Channel layout of the audio data.
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
A filter pad used for either input or output.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define FILTER_INPUTS(array)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static void filter_dbl(ASoftClipContext *s, void **dptr, const void **sptr, int nb_samples, int channels, int start, int end)
static const AVFilterPad inputs[]
Describe the class of an AVClass context structure.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
void(* filter)(struct ASoftClipContext *s, void **dst, const void **src, int nb_samples, int channels, int start, int end)
static float run_lowpassf(const Lowpass *const s, float src, float *w)
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
static __device__ float sqrtf(float a)
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
AVFILTER_DEFINE_CLASS(asoftclip)
static void scale(int *out, const int *in, const int w, const int h, const int shift)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
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.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
const AVFilter ff_af_asoftclip
int nb_samples
number of audio samples (per channel) described by this frame
#define i(width, name, range_min, range_max)
uint8_t ** extended_data
pointers to the data planes/channels.
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Used for passing data between threads.
const char * name
Pad name.
static double erf(double z)
erf function Algorithm taken from the Boost project, source: http://www.boost.org/doc/libs/1_46_1/boo...
@ AV_SAMPLE_FMT_DBLP
double, planar
static void filter_flt(ASoftClipContext *s, void **dptr, const void **sptr, int nb_samples, int channels, int start, int end)
static const int factor[16]
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
static int filter_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static const int16_t alpha[]
static void get_lowpass(Lowpass *s, double frequency, double sample_rate)
#define FILTER_OUTPUTS(array)
Lowpass lowpass[MAX_OVERSAMPLE]
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
#define FILTER_SAMPLEFMTS(...)