Go to the documentation of this file.
58 for (
int i = 0;
i < n / 2;
i++)
59 q[
i] = 1. / (-2. * cos(
M_PI * (2. * (
i + 1) + n - 1.) / (2. * n)));
66 double w0 =
s->cutoff /
inlink->sample_rate;
67 double K = tan(
M_PI * w0);
70 s->bypass = w0 >= 0.5;
74 if (!strcmp(
ctx->filter->name,
"asubcut")) {
75 s->filter_count =
s->order / 2 + (
s->order & 1);
81 double omega = 2. * tan(
M_PI * w0);
83 coeffs->
b0 = 2. / (2. + omega);
84 coeffs->
b1 = -coeffs->
b0;
86 coeffs->
a1 = -(omega - 2.) / (2. + omega);
90 for (
int b = (
s->order & 1);
b <
s->filter_count;
b++) {
92 const int idx =
b - (
s->order & 1);
93 double norm = 1.0 / (1.0 +
K / q[idx] +
K *
K);
96 coeffs->
b1 = -2.0 * coeffs->
b0;
97 coeffs->
b2 = coeffs->
b0;
98 coeffs->
a1 = -2.0 * (
K *
K - 1.0) * norm;
99 coeffs->
a2 = -(1.0 -
K / q[idx] +
K *
K) * norm;
101 }
else if (!strcmp(
ctx->filter->name,
"asupercut")) {
102 s->filter_count =
s->order / 2 + (
s->order & 1);
108 double omega = 2. * tan(
M_PI * w0);
110 coeffs->
b0 = omega / (2. + omega);
111 coeffs->
b1 = coeffs->
b0;
113 coeffs->
a1 = -(omega - 2.) / (2. + omega);
117 for (
int b = (
s->order & 1);
b <
s->filter_count;
b++) {
119 const int idx =
b - (
s->order & 1);
120 double norm = 1.0 / (1.0 +
K / q[idx] +
K *
K);
122 coeffs->
b0 =
K *
K * norm;
123 coeffs->
b1 = 2.0 * coeffs->
b0;
124 coeffs->
b2 = coeffs->
b0;
125 coeffs->
a1 = -2.0 * (
K *
K - 1.0) * norm;
126 coeffs->
a2 = -(1.0 -
K / q[idx] +
K *
K) * norm;
128 }
else if (!strcmp(
ctx->filter->name,
"asuperpass")) {
129 double alpha, beta, gamma, theta;
130 double theta_0 = 2. *
M_PI * (
s->cutoff /
inlink->sample_rate);
133 s->filter_count =
s->order / 2;
134 d_E = (2. * tan(theta_0 / (2. *
s->qfactor))) / sin(theta_0);
136 for (
int b = 0;
b <
s->filter_count;
b += 2) {
137 double D = 2. * sin(((
b + 1) *
M_PI) / (2. *
s->filter_count));
138 double A = (1. + pow((d_E / 2.), 2)) / (
D * d_E / 2.);
139 double d = sqrt((d_E *
D) / (
A + sqrt(
A *
A - 1.)));
140 double B =
D * (d_E / 2.) / d;
141 double W =
B + sqrt(
B *
B - 1.);
143 for (
int j = 0; j < 2; j++) {
147 theta = 2. * atan(tan(theta_0 / 2.) /
W);
149 theta = 2. * atan(
W * tan(theta_0 / 2.));
151 beta = 0.5 * ((1. - (d / 2.) * sin(theta)) / (1. + (d / 2.) * sin(theta)));
152 gamma = (0.5 + beta) * cos(theta);
153 alpha = 0.5 * (0.5 - beta) * sqrt(1. + pow((
W - (1. /
W)) / d, 2.));
155 coeffs->
a1 = 2. * gamma;
156 coeffs->
a2 = -2. * beta;
162 }
else if (!strcmp(
ctx->filter->name,
"asuperstop")) {
163 double alpha, beta, gamma, theta;
164 double theta_0 = 2. *
M_PI * (
s->cutoff /
inlink->sample_rate);
167 s->filter_count =
s->order / 2;
168 d_E = (2. * tan(theta_0 / (2. *
s->qfactor))) / sin(theta_0);
170 for (
int b = 0;
b <
s->filter_count;
b += 2) {
171 double D = 2. * sin(((
b + 1) *
M_PI) / (2. *
s->filter_count));
172 double A = (1. + pow((d_E / 2.), 2)) / (
D * d_E / 2.);
173 double d = sqrt((d_E *
D) / (
A + sqrt(
A *
A - 1.)));
174 double B =
D * (d_E / 2.) / d;
175 double W =
B + sqrt(
B *
B - 1.);
177 for (
int j = 0; j < 2; j++) {
181 theta = 2. * atan(tan(theta_0 / 2.) /
W);
183 theta = 2. * atan(
W * tan(theta_0 / 2.));
185 beta = 0.5 * ((1. - (d / 2.) * sin(theta)) / (1. + (d / 2.) * sin(theta)));
186 gamma = (0.5 + beta) * cos(theta);
187 alpha = 0.5 * (0.5 + beta) * ((1. - cos(theta)) / (1. - cos(theta_0)));
189 coeffs->
a1 = 2. * gamma;
190 coeffs->
a2 = -2. * beta;
192 coeffs->
b1 = -4. *
alpha * cos(theta_0);
205 #define FILTER(name, type) \
206 static int filter_channels_## name(AVFilterContext *ctx, void *arg, \
207 int jobnr, int nb_jobs) \
209 ASuperCutContext *s = ctx->priv; \
210 ThreadData *td = arg; \
211 AVFrame *out = td->out; \
212 AVFrame *in = td->in; \
213 const int start = (in->ch_layout.nb_channels * jobnr) / nb_jobs; \
214 const int end = (in->ch_layout.nb_channels * (jobnr+1)) / nb_jobs; \
215 const double level = s->level; \
217 for (int ch = start; ch < end; ch++) { \
218 const type *src = (const type *)in->extended_data[ch]; \
219 type *dst = (type *)out->extended_data[ch]; \
221 for (int b = 0; b < s->filter_count; b++) { \
222 BiquadCoeffs *coeffs = &s->coeffs[b]; \
223 const type a1 = coeffs->a1; \
224 const type a2 = coeffs->a2; \
225 const type b0 = coeffs->b0; \
226 const type b1 = coeffs->b1; \
227 const type b2 = coeffs->b2; \
228 type *w = ((type *)s->w->extended_data[ch]) + b * 2; \
230 for (int n = 0; n < in->nb_samples; n++) { \
231 type sin = b ? dst[n] : src[n] * level; \
232 type sout = sin * b0 + w[0]; \
234 w[0] = b1 * sin + w[1] + a1 * sout; \
235 w[1] = b2 * sin + a2 * sout; \
297 char *res,
int res_len,
int flags)
315 #define OFFSET(x) offsetof(ASuperCutContext, x)
316 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
340 .priv_class = &asupercut_class,
363 .priv_class = &asubcut_class,
385 .
name =
"asuperpass",
387 .priv_class = &asuperpass_asuperstop_class,
399 .
name =
"asuperstop",
401 .priv_class = &asuperpass_asuperstop_class,
const AVFilter ff_af_asuperpass
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
static const AVOption asupercut_options[]
@ AV_SAMPLE_FMT_FLTP
float, planar
static int config_input(AVFilterLink *inlink)
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.
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
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
static void calc_q_factors(int n, double *q)
const char * name
Filter name.
A link between two filters.
const AVFilter ff_af_asupercut
#define FILTER(name, type)
static int get_coeffs(AVFilterContext *ctx)
A filter pad used for either input or output.
AVFILTER_DEFINE_CLASS(asupercut)
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
#define FILTER_OUTPUTS(array)
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.
const AVFilter ff_af_asuperstop
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
const AVFilter ff_af_asubcut
static const AVOption asubcut_options[]
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.
static av_cold void uninit(AVFilterContext *ctx)
int(* filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
int nb_samples
number of audio samples (per channel) described by this frame
#define i(width, name, range_min, range_max)
static const AVFilterPad inputs[]
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
AVSampleFormat
Audio sample formats.
Used for passing data between threads.
AVFILTER_DEFINE_CLASS_EXT(asuperpass_asuperstop, "asuperpass/asuperstop", asuperpass_asuperstop_options)
static const AVOption asuperpass_asuperstop_options[]
#define FILTER_SAMPLEFMTS_ARRAY(array)
const char * name
Pad name.
static enum AVSampleFormat sample_fmts[]
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
@ AV_OPT_TYPE_INT
Underlying C type is int.
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
@ 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 const int16_t alpha[]
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
#define flags(name, subs,...)