Go to the documentation of this file.
58 for (
int ch = 0; ch <
inlink->ch_layout.nb_channels; ch++) {
59 double *
state = (
double *)
s->state->extended_data[ch];
67 static double get_svf(
double in,
double *m,
double *
a,
double *
b)
70 const double v3 =
v0 -
b[1];
71 const double v1 =
a[0] *
b[0] +
a[1] * v3;
72 const double v2 =
b[1] +
a[1] *
b[0] +
a[2] * v3;
74 b[0] = 2. * v1 -
b[0];
75 b[1] = 2. * v2 -
b[1];
77 return m[0] *
v0 + m[1] * v1 + m[2] * v2;
91 const double makeup =
s->makeup;
92 const double ratio =
s->ratio;
93 const double range =
s->range;
96 const double release =
s->release_coef;
97 const double irelease = 1. - release;
98 const double attack =
s->attack_coef;
99 const double iattack = 1. - attack;
100 const double dqfactor =
s->dqfactor;
101 const double tqfactor =
s->tqfactor;
106 const int detection =
s->detection;
107 const int direction =
s->direction;
108 const int mode =
s->mode;
109 const int type =
s->type;
113 double k = 1. / dqfactor;
115 da[0] = 1. / (1. + dg * (dg + k));
124 for (
int ch = start; ch < end; ch++) {
126 double *dst = (
double *)
out->extended_data[ch];
127 double *
state = (
double *)
s->state->extended_data[ch];
128 const double threshold = detection == 0 ?
state[5] :
s->threshold;
131 state[5] = threshold;
133 for (
int n = 0; n <
out->nb_samples; n++) {
134 double detect, gain, v, listen;
139 detect =
fabs(detect);
144 if (direction == 0 &&
mode == 0 && detect < threshold)
145 detect = 1. /
av_clipd(1. + makeup + (threshold - detect) * ratio, 1., range);
146 else if (direction == 0 &&
mode == 1 && detect < threshold)
147 detect =
av_clipd(1. + makeup + (threshold - detect) * ratio, 1., range);
148 else if (direction == 1 &&
mode == 0 && detect > threshold)
149 detect = 1. /
av_clipd(1. + makeup + (detect - threshold) * ratio, 1., range);
150 else if (direction == 1 &&
mode == 1 && detect > threshold)
151 detect =
av_clipd(1. + makeup + (detect - threshold) * ratio, 1., range);
155 if (direction == 0) {
156 if (detect >
state[4]) {
157 detect = iattack * detect + attack *
state[4];
159 detect = irelease * detect + release *
state[4];
162 if (detect <
state[4]) {
163 detect = iattack * detect + attack *
state[4];
165 detect = irelease * detect + release *
state[4];
169 if (
state[4] != detect || n == 0) {
170 state[4] = gain = detect;
174 k = 1. / (tqfactor * gain);
176 fa[0] = 1. / (1. + fg * (fg + k));
181 fm[1] = k * (gain * gain - 1.);
188 fa[0] = 1. / (1. +
g * (
g + k));
193 fm[1] = k * (gain - 1.);
194 fm[2] = gain * gain - 1.;
200 fa[0] = 1. / (1. +
g * (
g + k));
205 fm[1] = k * (1. - gain) * gain;
206 fm[2] = 1. - gain * gain;
212 v =
mode == -1 ? listen : v;
213 dst[n] =
ctx->is_disabled ?
src[n] : v;
222 return exp(-1000. / (x * sr));
264 #define OFFSET(x) offsetof(AudioDynamicEqualizerContext, x)
265 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
315 .
name =
"adynamicequalizer",
318 .priv_class = &adynamicequalizer_class,
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
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.
#define FILTER_SINGLE_SAMPLEFMT(sample_fmt_)
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
const AVFilter ff_af_adynamicequalizer
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 int config_input(AVFilterLink *inlink)
static int filter_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
const char * name
Filter name.
int nb_channels
Number of channels in this layout.
A link between two filters.
static double get_coef(double x, double sr)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
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
static av_cold void uninit(AVFilterContext *ctx)
A filter pad used for either input or output.
static double get_svf(double in, double *m, double *a, double *b)
static const AVOption adynamicequalizer_options[]
#define FILTER_INPUTS(array)
Describe the class of an AVClass context structure.
static __device__ float fabs(float a)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFILTER_DEFINE_CLASS(adynamicequalizer)
static const AVFilterPad outputs[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int sample_rate
Sample rate of the audio data.
double fmin(double, double)
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.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
int nb_samples
number of audio samples (per channel) described by this frame
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.
double fmax(double, double)
@ AV_SAMPLE_FMT_DBLP
double, planar
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
#define FILTER_OUTPUTS(array)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
static const AVFilterPad inputs[]
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)