Go to the documentation of this file.
60 #define OFFSET(x) offsetof(AudioRLSContext, x)
61 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
62 #define AT AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
82 const int order =
s->order;
87 memcpy(
tmp, coeffs + order - *
offset, order *
sizeof(
float));
89 output =
s->fdsp->scalarproduct_float(delay,
tmp,
s->kernel_size);
99 float *coeffs = (
float *)
s->coeffs->extended_data[ch];
100 float *delay = (
float *)
s->delay->extended_data[ch];
101 float *gains = (
float *)
s->gains->extended_data[ch];
102 float *
tmp = (
float *)
s->tmp->extended_data[ch];
103 float *
u = (
float *)
s->u->extended_data[ch];
104 float *p = (
float *)
s->p->extended_data[ch];
105 float *dp = (
float *)
s->dp->extended_data[ch];
106 int *offsetp = (
int *)
s->offset->extended_data[ch];
107 const int kernel_size =
s->kernel_size;
108 const int order =
s->order;
109 const float lambda =
s->lambda;
120 const int ikernel_size =
i * kernel_size;
124 u[
i] += p[ikernel_size + k] * delay[
pos];
131 for (
int i = 0;
i < order;
i++) {
132 const int ikernel_size =
i * kernel_size;
135 coeffs[
i] = coeffs[order +
i] = coeffs[
i] + gains[
i] * e;
138 tmp[
i] += p[ikernel_size + k] * delay[
pos];
141 for (
int i = 0;
i < order;
i++) {
142 const int ikernel_size =
i * kernel_size;
144 for (
int k = 0; k < order; k++)
145 dp[ikernel_size + k] = gains[
i] *
tmp[k];
148 for (
int i = 0;
i < order;
i++) {
149 const int ikernel_size =
i * kernel_size;
151 for (
int k = 0; k < order; k++)
152 p[ikernel_size + k] = (p[ikernel_size + k] - (dp[ikernel_size + k] + dp[kernel_size * k +
i]) * 0.5
f) * lambda;
155 switch (
s->output_mode) {
169 const int start = (
out->ch_layout.nb_channels * jobnr) / nb_jobs;
170 const int end = (
out->ch_layout.nb_channels * (jobnr+1)) / nb_jobs;
172 for (
int c = start;
c < end;
c++) {
173 const float *
input = (
const float *)
s->frame[0]->extended_data[
c];
174 const float *desired = (
const float *)
s->frame[1]->extended_data[
c];
175 float *
output = (
float *)
out->extended_data[
c];
177 for (
int n = 0; n <
out->nb_samples; n++) {
179 if (
ctx->is_disabled)
198 for (
i = 0;
i <
ctx->nb_inputs && nb_samples > 0;
i++) {
209 if (
s->frame[0] &&
s->frame[1]) {
222 out->pts =
s->frame[0]->pts;
233 for (
i = 0;
i < 2;
i++) {
242 for (
i = 0;
i < 2;
i++) {
276 if (!
s->delay || !
s->coeffs || !
s->p || !
s->dp || !
s->gains || !
s->offset || !
s->u || !
s->tmp)
279 for (
int ch = 0; ch <
s->offset->ch_layout.nb_channels; ch++) {
280 int *dst = (
int *)
s->offset->extended_data[ch];
282 for (
int i = 0;
i <
s->kernel_size;
i++)
283 dst[0] =
s->kernel_size - 1;
286 for (
int ch = 0; ch <
s->p->ch_layout.nb_channels; ch++) {
287 float *dst = (
float *)
s->p->extended_data[ch];
289 for (
int i = 0;
i <
s->kernel_size;
i++)
290 dst[
i *
s->kernel_size +
i] =
s->delta;
343 .description =
NULL_IF_CONFIG_SMALL(
"Apply Recursive Least Squares algorithm to first audio stream."),
345 .priv_class = &arls_class,
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
@ AV_SAMPLE_FMT_FLTP
float, planar
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 outputs[]
#define u(width, name, range_min, range_max)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
#define FILTER_SINGLE_SAMPLEFMT(sample_fmt_)
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static const AVOption arls_options[]
This structure describes decoded (raw) audio or video data.
static float process_sample(AudioRLSContext *s, float input, float desired, int ch)
static int config_output(AVFilterLink *outlink)
const char * name
Filter name.
A link between two filters.
static int process_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static const AVFilterPad inputs[]
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
static av_cold int init(AVFilterContext *ctx)
A filter pad used for either input or output.
int ff_inlink_check_available_samples(AVFilterLink *link, unsigned min)
Test if enough samples are available on the link.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
#define FILTER_INPUTS(array)
Describe the class of an AVClass context structure.
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
AVFilterContext * src
source 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.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
const AVFilter ff_af_arls
#define i(width, name, range_min, range_max)
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
const char * name
Pad name.
int ff_inlink_queued_samples(AVFilterLink *link)
static av_cold void uninit(AVFilterContext *ctx)
static float fir_sample(AudioRLSContext *s, float sample, float *delay, float *coeffs, float *tmp, int *offset)
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
static int activate(AVFilterContext *ctx)
#define FILTER_OUTPUTS(array)
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
AVFILTER_DEFINE_CLASS(arls)