Go to the documentation of this file.
61 static double get_svf(
double in,
double *m,
double *
a,
double *
b)
64 const double v3 =
v0 -
b[1];
65 const double v1 =
a[0] *
b[0] +
a[1] * v3;
66 const double v2 =
b[1] +
a[1] *
b[0] +
a[2] * v3;
68 b[0] = 2. * v1 -
b[0];
69 b[1] = 2. * v2 -
b[1];
71 return m[0] *
v0 + m[1] * v1 + m[2] * v2;
79 static inline double to_dB(
double x)
81 return 20. * log10(x);
84 static inline double sqr(
double x)
89 static double get_gain(
double in,
double srate,
double makeup,
90 double aattack,
double iratio,
double knee,
double range,
91 double thresdb,
double slewfactor,
double *
state,
92 double attack_coeff,
double release_coeff,
double nc)
94 double width = (6. * knee) + 0.01;
97 double Lxg, Lxl, Lyg, Lyl, Ly1;
98 double checkwidth = 0.;
99 double slewwidth = 1.8;
105 Lyg = Lxg + (iratio - 1.) *
sqr(Lxg - thresdb +
width * .5) / (2. *
width);
107 checkwidth = 2. *
fabs(Lxg - thresdb);
108 if (2. * (Lxg - thresdb) < -
width) {
110 }
else if (checkwidth <=
width) {
111 Lyg = thresdb + (Lxg - thresdb) * iratio;
112 if (checkwidth <= slewwidth) {
116 }
else if (2. * (Lxg-thresdb) >
width) {
117 Lyg = thresdb + (Lxg - thresdb) * iratio;
120 attack_coeff = attslew ? aattack : attack_coeff;
124 Ly1 =
fmaxf(Lxl, release_coeff *
state[1] +(1. - release_coeff) * Lxl);
125 Lyl = attack_coeff *
state[0] + (1. - attack_coeff) * Ly1;
148 const double makeup =
s->makeup;
149 const double iratio = 1. /
s->ratio;
150 const double range =
s->range;
153 const double threshold = log(
s->threshold + DBL_EPSILON);
154 const double release =
s->release_coef;
155 const double attack =
s->attack_coef;
156 const double dqfactor =
s->dqfactor;
157 const double tqfactor =
s->tqfactor;
160 const int start = (in->
channels * jobnr) / nb_jobs;
161 const int end = (in->
channels * (jobnr+1)) / nb_jobs;
162 const int mode =
s->mode;
163 const double knee =
s->knee;
164 const double slew =
s->slew;
165 const double aattack =
exp(-1000. / ((
s->attack + 2.0 * (slew - 1.)) *
sample_rate));
166 const double nc =
mode == 0 ? 1. : -1.;
170 double k = 1. / dqfactor;
172 da[0] = 1. / (1. + dg * (dg + k));
181 for (
int ch = start; ch < end; ch++) {
183 double *dst = (
double *)
out->extended_data[ch];
184 double *
state = (
double *)
s->state->extended_data[ch];
186 for (
int n = 0; n <
out->nb_samples; n++) {
187 double detect, gain, v, listen;
191 detect =
fabs(detect);
194 aattack, iratio, knee, range, threshold, slew,
195 &
state[4], attack, release, nc);
198 double k = 1. / (tqfactor * gain);
200 fa[0] = 1. / (1. + fg * (fg + k));
205 fm[1] = k * (gain * gain - 1.);
210 v =
mode == -1 ? listen : v;
211 dst[n] =
ctx->is_disabled ?
src[n] : v;
220 return exp(-1000. / (x * sr));
262 #define OFFSET(x) offsetof(AudioDynamicEqualizerContext, x)
263 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
304 .
name =
"adynamicequalizer",
307 .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.
A link between two filters.
static double get_coef(double x, double sr)
int channels
Number of channels.
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
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[]
int channels
number of audio channels, only used for audio.
#define FILTER_INPUTS(array)
static double to_dB(double x)
static double sqr(double x)
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.
float fmaxf(float, float)
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.
static double from_dB(double x)
@ 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...
static double get_gain(double in, double srate, double makeup, double aattack, double iratio, double knee, double range, double thresdb, double slewfactor, double *state, double attack_coeff, double release_coeff, double nc)
#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)