Go to the documentation of this file.
57 for (
int i = 0;
i < n / 2;
i++)
58 q[
i] = 1. / (-2. * cos(
M_PI * (2. * (
i + 1) + n - 1.) / (2. * n)));
65 double w0 =
s->cutoff /
inlink->sample_rate;
66 double K = tan(
M_PI * w0);
69 s->bypass = w0 >= 0.5;
73 if (!strcmp(
ctx->filter->name,
"asubcut")) {
74 s->filter_count =
s->order / 2 + (
s->order & 1);
80 double omega = 2. * tan(
M_PI * w0);
82 coeffs->
b0 = 2. / (2. + omega);
83 coeffs->
b1 = -coeffs->
b0;
85 coeffs->
a1 = -(omega - 2.) / (2. + omega);
89 for (
int b = (
s->order & 1);
b <
s->filter_count;
b++) {
91 const int idx =
b - (
s->order & 1);
92 double norm = 1.0 / (1.0 +
K / q[idx] +
K *
K);
95 coeffs->
b1 = -2.0 * coeffs->
b0;
96 coeffs->
b2 = coeffs->
b0;
97 coeffs->
a1 = -2.0 * (
K *
K - 1.0) * norm;
98 coeffs->
a2 = -(1.0 -
K / q[idx] +
K *
K) * norm;
100 }
else if (!strcmp(
ctx->filter->name,
"asupercut")) {
101 s->filter_count =
s->order / 2 + (
s->order & 1);
107 double omega = 2. * tan(
M_PI * w0);
109 coeffs->
b0 = omega / (2. + omega);
110 coeffs->
b1 = coeffs->
b0;
112 coeffs->
a1 = -(omega - 2.) / (2. + omega);
116 for (
int b = (
s->order & 1);
b <
s->filter_count;
b++) {
118 const int idx =
b - (
s->order & 1);
119 double norm = 1.0 / (1.0 +
K / q[idx] +
K *
K);
121 coeffs->
b0 =
K *
K * norm;
122 coeffs->
b1 = 2.0 * coeffs->
b0;
123 coeffs->
b2 = coeffs->
b0;
124 coeffs->
a1 = -2.0 * (
K *
K - 1.0) * norm;
125 coeffs->
a2 = -(1.0 -
K / q[idx] +
K *
K) * norm;
127 }
else if (!strcmp(
ctx->filter->name,
"asuperpass")) {
128 double alpha, beta, gamma, theta;
129 double theta_0 = 2. *
M_PI * (
s->cutoff /
inlink->sample_rate);
132 s->filter_count =
s->order / 2;
133 d_E = (2. * tan(theta_0 / (2. *
s->qfactor))) / sin(theta_0);
135 for (
int b = 0;
b <
s->filter_count;
b += 2) {
136 double D = 2. * sin(((
b + 1) *
M_PI) / (2. *
s->filter_count));
137 double A = (1. + pow((d_E / 2.), 2)) / (
D * d_E / 2.);
138 double d = sqrt((d_E *
D) / (
A + sqrt(
A *
A - 1.)));
139 double B =
D * (d_E / 2.) /
d;
140 double W =
B + sqrt(
B *
B - 1.);
142 for (
int j = 0; j < 2; j++) {
146 theta = 2. * atan(tan(theta_0 / 2.) /
W);
148 theta = 2. * atan(
W * tan(theta_0 / 2.));
150 beta = 0.5 * ((1. - (
d / 2.) * sin(theta)) / (1. + (
d / 2.) * sin(theta)));
151 gamma = (0.5 + beta) * cos(theta);
152 alpha = 0.5 * (0.5 - beta) * sqrt(1. + pow((
W - (1. /
W)) /
d, 2.));
154 coeffs->
a1 = 2. * gamma;
155 coeffs->
a2 = -2. * beta;
161 }
else if (!strcmp(
ctx->filter->name,
"asuperstop")) {
162 double alpha, beta, gamma, theta;
163 double theta_0 = 2. *
M_PI * (
s->cutoff /
inlink->sample_rate);
166 s->filter_count =
s->order / 2;
167 d_E = (2. * tan(theta_0 / (2. *
s->qfactor))) / sin(theta_0);
169 for (
int b = 0;
b <
s->filter_count;
b += 2) {
170 double D = 2. * sin(((
b + 1) *
M_PI) / (2. *
s->filter_count));
171 double A = (1. + pow((d_E / 2.), 2)) / (
D * d_E / 2.);
172 double d = sqrt((d_E *
D) / (
A + sqrt(
A *
A - 1.)));
173 double B =
D * (d_E / 2.) /
d;
174 double W =
B + sqrt(
B *
B - 1.);
176 for (
int j = 0; j < 2; j++) {
180 theta = 2. * atan(tan(theta_0 / 2.) /
W);
182 theta = 2. * atan(
W * tan(theta_0 / 2.));
184 beta = 0.5 * ((1. - (
d / 2.) * sin(theta)) / (1. + (
d / 2.) * sin(theta)));
185 gamma = (0.5 + beta) * cos(theta);
186 alpha = 0.5 * (0.5 + beta) * ((1. - cos(theta)) / (1. - cos(theta_0)));
188 coeffs->
a1 = 2. * gamma;
189 coeffs->
a2 = -2. * beta;
191 coeffs->
b1 = -4. *
alpha * cos(theta_0);
204 #define FILTER(name, type) \
205 static int filter_channels_## name(AVFilterContext *ctx, void *arg, \
206 int jobnr, int nb_jobs) \
208 ASuperCutContext *s = ctx->priv; \
209 ThreadData *td = arg; \
210 AVFrame *out = td->out; \
211 AVFrame *in = td->in; \
212 const int start = (in->ch_layout.nb_channels * jobnr) / nb_jobs; \
213 const int end = (in->ch_layout.nb_channels * (jobnr+1)) / nb_jobs; \
214 const double level = s->level; \
216 for (int ch = start; ch < end; ch++) { \
217 const type *src = (const type *)in->extended_data[ch]; \
218 type *dst = (type *)out->extended_data[ch]; \
220 for (int b = 0; b < s->filter_count; b++) { \
221 BiquadCoeffs *coeffs = &s->coeffs[b]; \
222 const type a1 = coeffs->a1; \
223 const type a2 = coeffs->a2; \
224 const type b0 = coeffs->b0; \
225 const type b1 = coeffs->b1; \
226 const type b2 = coeffs->b2; \
227 type *w = ((type *)s->w->extended_data[ch]) + b * 2; \
229 for (int n = 0; n < in->nb_samples; n++) { \
230 type sin = b ? dst[n] : src[n] * level; \
231 type sout = sin * b0 + w[0]; \
233 w[0] = b1 * sin + w[1] + a1 * sout; \
234 w[1] = b2 * sin + a2 * sout; \
296 char *res,
int res_len,
int flags)
314 #define OFFSET(x) offsetof(ASuperCutContext, x)
315 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
339 .priv_class = &asupercut_class,
362 .priv_class = &asubcut_class,
384 .
name =
"asuperpass",
386 .priv_class = &asuperpass_asuperstop_class,
398 .
name =
"asuperstop",
400 .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.
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)
#define FILTER_INPUTS(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
#define FILTER_SAMPLEFMTS_ARRAY(array)
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[]
const char * name
Pad name.
static enum AVSampleFormat sample_fmts[]
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[]
#define FILTER_OUTPUTS(array)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
#define flags(name, subs,...)
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)