52 return wp * tan(
w *
T * 0.5) / tan(wp *
T * 0.5);
55static double mz(
int i,
double w0,
double r,
double alpha)
60static double mp(
int i,
double w0,
double r)
62 return w0 * pow(
r,
i);
65static double mzh(
int i,
double T,
double w0,
double r,
double alpha)
70static double mph(
int i,
double T,
double w0,
double r)
76 double w1,
double sr,
double alpha)
78 double c = 1.0 / tan(w1 * 0.5 / sr);
83 coeffs->
a1 = (
a0 -
c) / d;
88 int order,
double sr,
double f0,
89 double bw,
double alpha)
92 const double w0 = 2. *
M_PI * f0;
93 const double f1 = f0 + bw;
95 const double r = pow(f1 / f0, 1.0 / (order - 1.0));
96 const double T = 1. / sr;
98 for (
int i = 0;
i < order;
i++) {
101 set_tf1s(coeffs, 1.0,
mzh(
i,
T, w0,
r,
alpha),
mph(
i,
T, w0,
r),
120#define FILTER(name, type) \
121static int filter_channels_## name(AVFilterContext *ctx, void *arg, \
122 int jobnr, int nb_jobs) \
124 ATiltContext *s = ctx->priv; \
125 ThreadData *td = arg; \
126 AVFrame *out = td->out; \
127 AVFrame *in = td->in; \
128 const int start = ff_slice_pos(in->ch_layout.nb_channels, jobnr, nb_jobs); \
129 const int end = ff_slice_pos(in->ch_layout.nb_channels, jobnr + 1, nb_jobs); \
130 const type level = s->level; \
132 for (int ch = start; ch < end; ch++) { \
133 const type *src = (const type *)in->extended_data[ch]; \
134 type *dst = (type *)out->extended_data[ch]; \
136 for (int b = 0; b < s->order; b++) { \
137 Coeffs *coeffs = &s->coeffs[b]; \
138 const type g = coeffs->g; \
139 const type a1 = coeffs->a1; \
140 const type b0 = coeffs->b0; \
141 const type b1 = coeffs->b1; \
142 type *w = ((type *)s->w->extended_data[ch]) + b * 2; \
144 for (int n = 0; n < in->nb_samples; n++) { \
145 type sain = b ? dst[n] : src[n] * level; \
146 type saout = sain * b0 + w[0] * b1 - w[1] * a1; \
151 dst[n] = saout * g; \
167 switch (inlink->format) {
168 case AV_SAMPLE_FMT_FLTP: s->filter_channels = filter_channels_fltp; break;
169 case AV_SAMPLE_FMT_DBLP: s->filter_channels = filter_channels_dblp; break;
208 char *res,
int res_len,
int flags)
226#define OFFSET(x) offsetof(ATiltContext, x)
227#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
252 .p.priv_class = &atilt_class,
static const AVFilterPad inputs[]
static int config_input(AVFilterLink *inlink)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static void set_tf1s(Coeffs *coeffs, double b1, double b0, double a0, double w1, double sr, double alpha)
static int get_coeffs(AVFilterContext *ctx)
static double mph(int i, double T, double w0, double r)
static void set_filter(AVFilterContext *ctx, int order, double sr, double f0, double bw, double alpha)
static double mp(int i, double w0, double r)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static double mzh(int i, double T, double w0, double r, double alpha)
#define FILTER(name, type)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static av_cold void uninit(AVFilterContext *ctx)
static double mz(int i, double w0, double r, double alpha)
const FFFilter ff_af_atilt
static double prewarp(double w, double T, double wp)
static const AVOption atilt_options[]
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
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.
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Main libavfilter public API header.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
internal math functions header
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
@ AV_SAMPLE_FMT_FLTP
float, planar
@ AV_SAMPLE_FMT_DBLP
double, planar
static const int16_t alpha[]
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FILTER_SAMPLEFMTS(...)
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int(* filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
A link between two filters.
int sample_rate
samples per second
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
Used for passing data between threads.
static AVFormatContext * ctx
static double b1(void *priv, double x, double y)
static double a0(void *priv, double x, double y)
static double b0(void *priv, double x, double y)