61 #define OFFSET(x) offsetof(AudioNLMSContext, x)
62 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
63 #define AT AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
113 const int order =
s->order;
118 memcpy(
tmp, coeffs + order - *
offset, order *
sizeof(
float));
120 output =
s->fdsp->scalarproduct_float(delay,
tmp,
s->kernel_size);
129 float *delay,
float *coeffs,
float *
tmp,
int *offsetp)
131 const int order =
s->order;
132 const float leakage =
s->leakage;
133 const float mu =
s->mu;
134 const float a = 1.f - leakage * mu;
135 float sum, output, e, norm,
b;
138 delay[
offset + order] = input;
141 e = desired - output;
143 sum =
s->fdsp->scalarproduct_float(delay, delay,
s->kernel_size);
148 memcpy(
tmp, delay +
offset, order *
sizeof(
float));
150 s->fdsp->vector_fmul_scalar(coeffs, coeffs,
a,
s->kernel_size);
152 s->fdsp->vector_fmac_scalar(coeffs,
tmp,
b,
s->kernel_size);
154 memcpy(coeffs + order, coeffs, order *
sizeof(
float));
156 switch (
s->output_mode) {
157 case IN_MODE: output = input;
break;
160 case NOISE_MODE: output = desired - output;
break;
169 const int start = (
out->channels * jobnr) / nb_jobs;
170 const int end = (
out->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 *delay = (
float *)
s->delay->extended_data[
c];
176 float *coeffs = (
float *)
s->coeffs->extended_data[
c];
177 float *
tmp = (
float *)
s->tmp->extended_data[
c];
178 int *
offset = (
int *)
s->offset->extended_data[
c];
179 float *output = (
float *)
out->extended_data[
c];
181 for (
int n = 0; n <
out->nb_samples; n++)
199 for (
i = 0;
i <
ctx->nb_inputs && nb_samples > 0;
i++) {
210 if (
s->frame[0] &&
s->frame[1]) {
223 out->pts =
s->frame[0]->pts;
234 for (
i = 0;
i < 2;
i++) {
243 for (
i = 0;
i < 2;
i++) {
268 if (!
s->delay || !
s->coeffs || !
s->offset || !
s->tmp)
319 .description =
NULL_IF_CONFIG_SMALL(
"Apply Normalized Least-Mean-Squares algorithm to first audio stream."),
321 .priv_class = &anlms_class,
static enum AVSampleFormat sample_fmts[]
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static const AVOption anlms_options[]
static float fir_sample(AudioNLMSContext *s, float sample, float *delay, float *coeffs, float *tmp, int *offset)
AVFILTER_DEFINE_CLASS(anlms)
static int process_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static int query_formats(AVFilterContext *ctx)
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
static float process_sample(AudioNLMSContext *s, float input, float desired, float *delay, float *coeffs, float *tmp, int *offsetp)
static int activate(AVFilterContext *ctx)
static av_cold int init(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
static int config_output(AVFilterLink *outlink)
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
simple assert() macros that are a bit more flexible than ISO C assert().
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
int ff_inlink_check_available_samples(AVFilterLink *link, unsigned min)
Test if enough samples are available on the link.
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_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_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
int ff_inlink_queued_samples(AVFilterLink *link)
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Main libavfilter public API header.
#define flags(name, subs,...)
audio channel layout utility functions
common internal and external API header
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
Forward the status on an output link to all input links.
static int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_FLTP
float, planar
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
enum MovChannelLayoutTag * layouts
Describe the class of an AVClass context structure.
A list of supported channel layouts.
A link between two filters.
AVFilterContext * src
source filter
A filter pad used for either input or output.
const char * name
Pad name.
const char * name
Filter name.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
This structure describes decoded (raw) audio or video data.
static const uint8_t offset[127][2]