52#define OFFSET(x) offsetof(AExciterContext, x)
53#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
69static inline double M(
double x)
71 return (
fabs(x) > 0.00000001) ? x : 0.0;
74static inline double D(
double x)
78 return (x > 0.00000001) ? sqrt(x) : 0.0;
82 double blend,
double drive,
83 double srate,
double freq,
88 p->rdrive = 12.0 / drive;
89 p->rbdr = p->rdrive / (10.5 - blend) * 780.0 / 33.0;
90 p->kpa =
D(2.0 * (p->rdrive*p->rdrive) - 1.0) + 1.0;
91 p->kpb = (2.0 - p->kpa) / 2.0;
92 p->ap = ((p->rdrive*p->rdrive) - p->kpa + 1.0) / 2.0;
93 p->kc = p->kpa /
D(2.0 *
D(2.0 * (p->rdrive*p->rdrive) - 1.0) - 2.0 * p->rdrive*p->rdrive);
95 p->srct = (0.1 * srate) / (0.1 * srate + 1.0);
96 p->sq = p->kc*p->kc + 1.0;
97 p->knb = -1.0 * p->rbdr /
D(p->sq);
98 p->kna = 2.0 * p->kc * p->rbdr /
D(p->sq);
99 p->an = p->rbdr*p->rbdr / p->sq;
100 p->imr = 2.0 * p->knb +
D(2.0 * p->kna + 4.0 * p->an - 1.0);
101 p->pwrq = 2.0 / (p->imr + 1.0);
103 w0 = 2 *
M_PI * freq / srate;
104 alpha = sin(w0) / (2. * 0.707);
108 b0 = (1 + cos(w0)) / 2;
110 b2 = (1 + cos(w0)) / 2;
119 alpha = sin(w0) / (2. * 0.707);
123 b0 = (1 - cos(w0)) / 2;
125 b2 = (1 - cos(w0)) / 2;
135 double *w1,
double *w2)
137 double out =
c[2] * in + *w1;
139 *w1 =
c[3] * in + *w2 +
c[0] *
out;
140 *w2 =
c[4] * in +
c[1] *
out;
147 double proc = in, med;
149 proc =
bprocess(proc, p->hp, &p->hw[0][0], &p->hw[0][1]);
150 proc =
bprocess(proc, p->hp, &p->hw[1][0], &p->hw[1][1]);
153 med = (
D(p->ap + proc * (p->kpa - proc)) + p->kpb) * p->pwrq;
155 med = (
D(p->an - proc * (p->kna + proc)) + p->knb) * p->pwrq * -1.0;
158 proc = p->srct * (med - p->prev_med + p->prev_out);
159 p->prev_med =
M(med);
160 p->prev_out =
M(proc);
162 proc =
bprocess(proc, p->hp, &p->hw[2][0], &p->hw[2][1]);
163 proc =
bprocess(proc, p->hp, &p->hw[3][0], &p->hw[3][1]);
165 if (
s->ceil >= 10000.) {
166 proc =
bprocess(proc, p->lp, &p->lw[0][0], &p->lw[0][1]);
167 proc =
bprocess(proc, p->lp, &p->lw[1][0], &p->lw[1][1]);
179 const double *
src = (
const double *)in->
data[0];
180 const double level_in =
s->level_in;
181 const double level_out =
s->level_out;
182 const double amount =
s->amount;
183 const double listen = 1.0 -
s->listen;
197 dst = (
double *)
out->data[0];
206 if (
ctx->is_disabled)
247 char *res,
int res_len,
int flags)
269 .p.name =
"aexciter",
271 .p.priv_class = &aexciter_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
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)
const FFFilter ff_af_aexciter
static double distortion_process(AExciterContext *s, ChannelParams *p, double in)
static int config_input(AVFilterLink *inlink)
static const AVFilterPad avfilter_af_aexciter_inputs[]
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static void set_params(ChannelParams *p, double blend, double drive, double srate, double freq, double ceil)
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 const AVOption aexciter_options[]
static double bprocess(double in, const double *const c, double *w1, double *w2)
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.
Main libavfilter public API header.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static __device__ float ceil(float a)
static __device__ float fabs(float a)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
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_DBL
double
static const int16_t alpha[]
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FILTER_SINGLE_SAMPLEFMT(sample_fmt_)
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
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
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
sample data coding information
static AVFormatContext * ctx
static double b1(void *priv, double x, double y)
static double a0(void *priv, double x, double y)
static double b2(void *priv, double x, double y)
static double b0(void *priv, double x, double y)
static double a2(void *priv, double x, double y)
static double a1(void *priv, double x, double y)