Go to the documentation of this file.
56 double w0 = 2 *
M_PI *
s->cutoff /
inlink->sample_rate;
57 double alpha = sin(w0) / 2 * sqrt(2. * (1. /
s->slope - 1.) + 2.);
62 s->b0 = (1 - cos(w0)) / 2;
64 s->b2 = (1 - cos(w0)) / 2;
72 s->buffer_samples =
inlink->sample_rate *
s->delay / 1000;
85 if (!
s->buffer || !
s->w || !
s->write_pos)
101 const double mix =
ctx->is_disabled ? 0. : 1.;
102 const double wet =
ctx->is_disabled ? 1. :
s->wet_gain;
103 const double dry =
ctx->is_disabled ? 1. :
s->dry_gain;
104 const double feedback =
s->feedback, decay =
s->decay;
105 const double max_boost =
s->max_boost;
106 const double b0 =
s->b0;
107 const double b1 =
s->b1;
108 const double b2 =
s->b2;
109 const double a1 = -
s->a1;
110 const double a2 = -
s->a2;
113 const int buffer_samples =
s->buffer_samples;
115 for (
int ch = start; ch < end; ch++) {
117 double *
dst = (
double *)
out->extended_data[ch];
118 double *
buffer = (
double *)
s->buffer->extended_data[ch];
119 double *
w = (
double *)
s->w->extended_data[ch];
120 int write_pos =
s->write_pos[ch];
123 const double a = 0.00001;
124 const double b = 1. -
a;
134 double out_sample, boost;
136 out_sample =
src[n] *
b0 +
w[0];
137 w[0] =
b1 *
src[n] +
w[1] +
a1 * out_sample;
138 w[1] =
b2 *
src[n] +
a2 * out_sample;
140 buffer[write_pos] =
buffer[write_pos] * decay + out_sample * feedback;
142 w[2] = boost >
w[2] ?
w[2] *
b +
a * boost :
w[2] *
a +
b * boost;
146 if (++write_pos >= buffer_samples)
150 s->write_pos[ch] = write_pos;
168 if (strcmp(
s->ch_layout_str,
"all"))
203 char *res,
int res_len,
int flags)
214 #define OFFSET(x) offsetof(ASubBoostContext, x)
215 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
245 .priv_class = &asubboost_class,
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
static int mix(int c0, int c1)
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
static const AVFilterPad inputs[]
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 int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
enum AVChannel av_channel_layout_channel_from_index(const AVChannelLayout *channel_layout, unsigned int idx)
Get the channel with the given index in a channel layout.
const char * name
Filter name.
int nb_channels
Number of channels in this layout.
A link between two filters.
static double b1(void *priv, double x, double y)
static int config_input(AVFilterLink *inlink)
AVChannelLayout ch_layout
Channel layout of the audio data.
static double a2(void *priv, double x, double y)
A filter pad used for either input or output.
AVFILTER_DEFINE_CLASS(asubboost)
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
#define FILTER_OUTPUTS(array)
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.
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static int get_coeffs(AVFilterContext *ctx)
#define FILTER_SINGLE_SAMPLEFMT(sample_fmt_)
static const AVOption asubboost_options[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
An AVChannelLayout holds information about the channel layout of audio data.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
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 double b2(void *priv, double x, double y)
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 av_channel_layout_from_string(AVChannelLayout *channel_layout, const char *str)
Initialize a channel layout from a given string description.
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 AVFilter ff_af_asubboost
const char * name
Pad name.
AVChannelLayout ch_layout
void * av_calloc(size_t nmemb, size_t size)
static int filter_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static av_cold void uninit(AVFilterContext *ctx)
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
int av_channel_layout_index_from_channel(const AVChannelLayout *channel_layout, enum AVChannel channel)
Get the index of a given channel in a channel layout.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
@ AV_SAMPLE_FMT_DBLP
double, planar
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
#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 AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
#define flags(name, subs,...)
static double b0(void *priv, double x, double y)
static double a1(void *priv, double x, double y)
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...