FFmpeg
Data Structures | Macros | Functions | Variables
af_arnndn.c File Reference
#include <float.h>
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/float_dsp.h"
#include "libavutil/opt.h"
#include "libavutil/tx.h"
#include "avfilter.h"
#include "audio.h"
#include "filters.h"
#include "formats.h"

Go to the source code of this file.

Data Structures

struct  DenseLayer
 
struct  GRULayer
 
struct  RNNModel
 
struct  RNNState
 
struct  DenoiseState
 
struct  AudioRNNContext
 
struct  ThreadData
 Used for passing data between threads. More...
 

Macros

#define FRAME_SIZE_SHIFT   2
 
#define FRAME_SIZE   (120<<FRAME_SIZE_SHIFT)
 
#define WINDOW_SIZE   (2*FRAME_SIZE)
 
#define FREQ_SIZE   (FRAME_SIZE + 1)
 
#define PITCH_MIN_PERIOD   60
 
#define PITCH_MAX_PERIOD   768
 
#define PITCH_FRAME_SIZE   960
 
#define PITCH_BUF_SIZE   (PITCH_MAX_PERIOD+PITCH_FRAME_SIZE)
 
#define SQUARE(x)   ((x)*(x))
 
#define NB_BANDS   22
 
#define CEPS_MEM   8
 
#define NB_DELTA_CEPS   6
 
#define NB_FEATURES   (NB_BANDS+3*NB_DELTA_CEPS+2)
 
#define WEIGHTS_SCALE   (1.f/256)
 
#define MAX_NEURONS   128
 
#define ACTIVATION_TANH   0
 
#define ACTIVATION_SIGMOID   1
 
#define ACTIVATION_RELU   2
 
#define Q15ONE   1.0f
 
#define F_ACTIVATION_TANH   0
 
#define F_ACTIVATION_SIGMOID   1
 
#define F_ACTIVATION_RELU   2
 
#define FREE_MAYBE(ptr)   do { if (ptr) free(ptr); } while (0)
 
#define FREE_DENSE(name)
 
#define FREE_GRU(name)
 
#define ALLOC_LAYER(type, name)
 
#define INPUT_VAL(name)
 
#define INPUT_ACTIVATION(name)
 
#define INPUT_ARRAY(name, len)
 
#define INPUT_ARRAY3(name, len0, len1, len2)
 
#define INPUT_DENSE(name)
 
#define INPUT_GRU(name)
 
#define RNN_MOVE(dst, src, n)   (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
 
#define RNN_CLEAR(dst, n)   (memset((dst), 0, (n)*sizeof(*(dst))))
 
#define RNN_COPY(dst, src, n)   (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
 
#define INPUT_SIZE   42
 
#define OFFSET(x)   offsetof(AudioRNNContext, x)
 
#define AF   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 

Functions

static void rnnoise_model_free (RNNModel *model)
 
static RNNModelrnnoise_model_from_file (FILE *f)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 
static void biquad (float *y, float mem[2], const float *x, const float *b, const float *a, int N)
 
static void forward_transform (DenoiseState *st, AVComplexFloat *out, const float *in)
 
static void inverse_transform (DenoiseState *st, float *out, const AVComplexFloat *in)
 
static void compute_band_energy (float *bandE, const AVComplexFloat *X)
 
static void compute_band_corr (float *bandE, const AVComplexFloat *X, const AVComplexFloat *P)
 
static void frame_analysis (AudioRNNContext *s, DenoiseState *st, AVComplexFloat *X, float *Ex, const float *in)
 
static void frame_synthesis (AudioRNNContext *s, DenoiseState *st, float *out, const AVComplexFloat *y)
 
static void xcorr_kernel (const float *x, const float *y, float sum[4], int len)
 
static float celt_inner_prod (const float *x, const float *y, int N)
 
static void celt_pitch_xcorr (const float *x, const float *y, float *xcorr, int len, int max_pitch)
 
static int celt_autocorr (const float *x, float *ac, const float *window, int overlap, int lag, int n)
 
static void celt_lpc (float *lpc, const float *ac, int p)
 
static void celt_fir5 (const float *x, const float *num, float *y, int N, float *mem)
 
static void pitch_downsample (float *x[], float *x_lp, int len, int C)
 
static void dual_inner_prod (const float *x, const float *y01, const float *y02, int N, float *xy1, float *xy2)
 
static float compute_pitch_gain (float xy, float xx, float yy)
 
static float remove_doubling (float *x, int maxperiod, int minperiod, int N, int *T0_, int prev_period, float prev_gain)
 
static void find_best_pitch (float *xcorr, float *y, int len, int max_pitch, int *best_pitch)
 
static void pitch_search (const float *x_lp, float *y, int len, int max_pitch, int *pitch)
 
static void dct (AudioRNNContext *s, float *out, const float *in)
 
static int compute_frame_features (AudioRNNContext *s, DenoiseState *st, AVComplexFloat *X, AVComplexFloat *P, float *Ex, float *Ep, float *Exp, float *features, const float *in)
 
static void interp_band_gain (float *g, const float *bandE)
 
static void pitch_filter (AVComplexFloat *X, const AVComplexFloat *P, const float *Ex, const float *Ep, const float *Exp, const float *g)
 
static float tansig_approx (float x)
 
static float sigmoid_approx (float x)
 
static void compute_dense (const DenseLayer *layer, float *output, const float *input)
 
static void compute_gru (AudioRNNContext *s, const GRULayer *gru, float *state, const float *input)
 
static void compute_rnn (AudioRNNContext *s, RNNState *rnn, float *gains, float *vad, const float *input)
 
static float rnnoise_channel (AudioRNNContext *s, DenoiseState *st, float *out, const float *in, int disabled)
 
static int rnnoise_channels (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static int activate (AVFilterContext *ctx)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
 AVFILTER_DEFINE_CLASS (arnndn)
 

Variables

static const uint8_t eband5ms []
 
static const uint8_t second_check [16] = {0, 0, 3, 2, 3, 2, 5, 2, 3, 2, 3, 2, 5, 2, 3, 2}
 
static const float tansig_table [201]
 
static const AVFilterPad inputs []
 
static const AVFilterPad outputs []
 
static const AVOption arnndn_options []
 
AVFilter ff_af_arnndn
 

Macro Definition Documentation

#define FRAME_SIZE_SHIFT   2

Definition at line 46 of file af_arnndn.c.

Referenced by compute_band_corr(), compute_band_energy(), and interp_band_gain().

#define FRAME_SIZE   (120<<FRAME_SIZE_SHIFT)
#define WINDOW_SIZE   (2*FRAME_SIZE)
#define FREQ_SIZE   (FRAME_SIZE + 1)
#define PITCH_MIN_PERIOD   60

Definition at line 51 of file af_arnndn.c.

Referenced by compute_frame_features().

#define PITCH_MAX_PERIOD   768

Definition at line 52 of file af_arnndn.c.

Referenced by compute_frame_features(), and remove_doubling().

#define PITCH_FRAME_SIZE   960

Definition at line 53 of file af_arnndn.c.

Referenced by compute_frame_features().

#define PITCH_BUF_SIZE   (PITCH_MAX_PERIOD+PITCH_FRAME_SIZE)

Definition at line 54 of file af_arnndn.c.

Referenced by celt_autocorr(), and compute_frame_features().

#define SQUARE (   x)    ((x)*(x))

Definition at line 56 of file af_arnndn.c.

Referenced by compute_band_energy(), and pitch_filter().

#define NB_BANDS   22
#define CEPS_MEM   8

Definition at line 60 of file af_arnndn.c.

Referenced by compute_frame_features().

#define NB_DELTA_CEPS   6

Definition at line 61 of file af_arnndn.c.

Referenced by compute_frame_features().

#define NB_FEATURES   (NB_BANDS+3*NB_DELTA_CEPS+2)

Definition at line 63 of file af_arnndn.c.

Referenced by compute_frame_features(), and rnnoise_channel().

#define WEIGHTS_SCALE   (1.f/256)

Definition at line 65 of file af_arnndn.c.

Referenced by compute_dense(), and compute_gru().

#define MAX_NEURONS   128

Definition at line 67 of file af_arnndn.c.

Referenced by compute_gru(), and compute_rnn().

#define ACTIVATION_TANH   0

Definition at line 69 of file af_arnndn.c.

Referenced by compute_dense(), and compute_gru().

#define ACTIVATION_SIGMOID   1

Definition at line 70 of file af_arnndn.c.

Referenced by compute_dense(), and compute_gru().

#define ACTIVATION_RELU   2

Definition at line 71 of file af_arnndn.c.

Referenced by compute_dense(), and compute_gru().

#define Q15ONE   1.0f

Definition at line 73 of file af_arnndn.c.

Referenced by pitch_downsample(), and remove_doubling().

#define F_ACTIVATION_TANH   0

Definition at line 151 of file af_arnndn.c.

#define F_ACTIVATION_SIGMOID   1

Definition at line 152 of file af_arnndn.c.

#define F_ACTIVATION_RELU   2

Definition at line 153 of file af_arnndn.c.

#define FREE_MAYBE (   ptr)    do { if (ptr) free(ptr); } while (0)
#define FREE_DENSE (   name)
Value:
do { \
if (model->name) { \
av_free((void *) model->name->input_weights); \
av_free((void *) model->name->bias); \
av_free((void *) model->name); \
} \
} while (0)
if(ret)
#define av_free(p)

Referenced by rnnoise_model_free().

#define FREE_GRU (   name)
Value:
do { \
if (model->name) { \
av_free((void *) model->name->input_weights); \
av_free((void *) model->name->recurrent_weights); \
av_free((void *) model->name->bias); \
av_free((void *) model->name); \
} \
} while (0)
if(ret)
#define av_free(p)

Referenced by rnnoise_model_free().

#define ALLOC_LAYER (   type,
  name 
)
Value:
name = av_calloc(1, sizeof(type)); \
if (!name) { \
} \
ret->name = name
#define NULL
Definition: coverity.c:32
GLint GLenum type
Definition: opengl_enc.c:104
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:245
static void rnnoise_model_free(RNNModel *model)
Definition: af_arnndn.c:155
if(ret)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a it should return
const char * name
Definition: opengl_enc.c:102

Referenced by rnnoise_model_from_file().

#define INPUT_VAL (   name)
Value:
do { \
if (fscanf(f, "%d", &in) != 1 || in < 0 || in > 128) { \
} \
name = in; \
} while (0)
#define NULL
Definition: coverity.c:32
#define f(width, name)
Definition: cbs_vp9.c:255
static void rnnoise_model_free(RNNModel *model)
Definition: af_arnndn.c:155
if(ret)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31))))#define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac){}void ff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map){AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);return NULL;}return ac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;}int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){int use_generic=1;int len=in->nb_samples;int p;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a it should return
const char * name
Definition: opengl_enc.c:102
#define INPUT_ACTIVATION (   name)
Value:
do { \
int activation; \
INPUT_VAL(activation); \
switch (activation) { \
break; \
break; \
default: \
} \
} while (0)
#define INPUT_VAL(name)
#define F_ACTIVATION_SIGMOID
Definition: af_arnndn.c:152
#define ACTIVATION_TANH
Definition: af_arnndn.c:69
int
#define F_ACTIVATION_RELU
Definition: af_arnndn.c:153
#define ACTIVATION_RELU
Definition: af_arnndn.c:71
#define ACTIVATION_SIGMOID
Definition: af_arnndn.c:70
const char * name
Definition: opengl_enc.c:102
#define INPUT_ARRAY (   name,
  len 
)
Value:
do { \
float *values = av_calloc((len), sizeof(float)); \
if (!values) { \
} \
for (int i = 0; i < (len); i++) { \
if (fscanf(f, "%d", &in) != 1) { \
} \
values[i] = in; \
} \
} while (0)
#define NULL
Definition: coverity.c:32
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:245
#define f(width, name)
Definition: cbs_vp9.c:255
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return values
static void rnnoise_model_free(RNNModel *model)
Definition: af_arnndn.c:155
if(ret)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31))))#define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac){}void ff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map){AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);return NULL;}return ac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;}int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){int use_generic=1;int len=in->nb_samples;int p;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
int len
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a it should return
for(j=16;j >0;--j)
int i
Definition: input.c:407
const char * name
Definition: opengl_enc.c:102
#define INPUT_ARRAY3 (   name,
  len0,
  len1,
  len2 
)
Value:
do { \
float *values = av_calloc(FFALIGN((len0), 4) * FFALIGN((len1), 4) * (len2), sizeof(float)); \
if (!values) { \
} \
for (int k = 0; k < (len0); k++) { \
for (int i = 0; i < (len2); i++) { \
for (int j = 0; j < (len1); j++) { \
if (fscanf(f, "%d", &in) != 1) { \
} \
values[j * (len2) * FFALIGN((len0), 4) + i * FFALIGN((len0), 4) + k] = in; \
} \
} \
} \
} while (0)
#define NULL
Definition: coverity.c:32
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:245
#define f(width, name)
Definition: cbs_vp9.c:255
#define FFALIGN(x, a)
Definition: macros.h:48
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return values
static void rnnoise_model_free(RNNModel *model)
Definition: af_arnndn.c:155
if(ret)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31))))#define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac){}void ff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map){AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);return NULL;}return ac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;}int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){int use_generic=1;int len=in->nb_samples;int p;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a it should return
for(j=16;j >0;--j)
int i
Definition: input.c:407
const char * name
Definition: opengl_enc.c:102
#define INPUT_DENSE (   name)
Value:
do { \
INPUT_VAL(name->nb_inputs); \
INPUT_VAL(name->nb_neurons); \
ret->name ## _size = name->nb_neurons; \
INPUT_ACTIVATION(name->activation); \
INPUT_ARRAY(name->input_weights, name->nb_inputs * name->nb_neurons); \
INPUT_ARRAY(name->bias, name->nb_neurons); \
} while (0)
#define INPUT_VAL(name)
#define INPUT_ACTIVATION(name)
#define INPUT_ARRAY(name, len)
const char * name
Definition: opengl_enc.c:102

Referenced by rnnoise_model_from_file().

#define INPUT_GRU (   name)
Value:
do { \
INPUT_VAL(name->nb_inputs); \
INPUT_VAL(name->nb_neurons); \
ret->name ## _size = name->nb_neurons; \
INPUT_ACTIVATION(name->activation); \
INPUT_ARRAY3(name->input_weights, name->nb_inputs, name->nb_neurons, 3); \
INPUT_ARRAY3(name->recurrent_weights, name->nb_neurons, name->nb_neurons, 3); \
INPUT_ARRAY(name->bias, name->nb_neurons * 3); \
} while (0)
#define INPUT_VAL(name)
#define INPUT_ACTIVATION(name)
#define INPUT_ARRAY(name, len)
#define INPUT_ARRAY3(name, len0, len1, len2)
const char * name
Definition: opengl_enc.c:102

Referenced by rnnoise_model_from_file().

#define RNN_MOVE (   dst,
  src,
 
)    (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))

Definition at line 392 of file af_arnndn.c.

Referenced by compute_frame_features().

#define RNN_CLEAR (   dst,
 
)    (memset((dst), 0, (n)*sizeof(*(dst))))

Definition at line 393 of file af_arnndn.c.

Referenced by celt_lpc(), and compute_frame_features().

#define RNN_COPY (   dst,
  src,
 
)    (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
#define INPUT_SIZE   42

Definition at line 1311 of file af_arnndn.c.

Referenced by compute_rnn().

#define OFFSET (   x)    offsetof(AudioRNNContext, x)

Definition at line 1523 of file af_arnndn.c.

Definition at line 1524 of file af_arnndn.c.

Function Documentation

static void rnnoise_model_free ( RNNModel model)
static

Definition at line 155 of file af_arnndn.c.

Referenced by rnnoise_model_from_file(), and uninit().

static RNNModel* rnnoise_model_from_file ( FILE *  f)
static

Definition at line 185 of file af_arnndn.c.

Referenced by init().

static int query_formats ( AVFilterContext ctx)
static

Definition at line 311 of file af_arnndn.c.

static int config_input ( AVFilterLink inlink)
static

Definition at line 342 of file af_arnndn.c.

static void biquad ( float *  y,
float  mem[2],
const float *  x,
const float *  b,
const float *  a,
int  N 
)
static

Definition at line 378 of file af_arnndn.c.

Referenced by rnnoise_channel().

static void forward_transform ( DenoiseState st,
AVComplexFloat out,
const float *  in 
)
static

Definition at line 396 of file af_arnndn.c.

Referenced by compute_frame_features(), and frame_analysis().

static void inverse_transform ( DenoiseState st,
float *  out,
const AVComplexFloat in 
)
static

Definition at line 411 of file af_arnndn.c.

Referenced by frame_synthesis().

static void compute_band_energy ( float *  bandE,
const AVComplexFloat X 
)
static

Definition at line 434 of file af_arnndn.c.

Referenced by compute_frame_features(), frame_analysis(), and pitch_filter().

static void compute_band_corr ( float *  bandE,
const AVComplexFloat X,
const AVComplexFloat P 
)
static

Definition at line 459 of file af_arnndn.c.

Referenced by compute_frame_features().

static void frame_analysis ( AudioRNNContext s,
DenoiseState st,
AVComplexFloat X,
float *  Ex,
const float *  in 
)
static

Definition at line 484 of file af_arnndn.c.

Referenced by compute_frame_features().

static void frame_synthesis ( AudioRNNContext s,
DenoiseState st,
float *  out,
const AVComplexFloat y 
)
static

Definition at line 496 of file af_arnndn.c.

Referenced by rnnoise_channel().

static void xcorr_kernel ( const float *  x,
const float *  y,
float  sum[4],
int  len 
)
inlinestatic

Definition at line 507 of file af_arnndn.c.

Referenced by celt_pitch_xcorr().

static float celt_inner_prod ( const float *  x,
const float *  y,
int  N 
)
inlinestatic

Definition at line 576 of file af_arnndn.c.

Referenced by celt_pitch_xcorr(), pitch_search(), and remove_doubling().

static void celt_pitch_xcorr ( const float *  x,
const float *  y,
float *  xcorr,
int  len,
int  max_pitch 
)
static

Definition at line 587 of file af_arnndn.c.

Referenced by celt_autocorr(), and pitch_search().

static int celt_autocorr ( const float *  x,
float *  ac,
const float *  window,
int  overlap,
int  lag,
int  n 
)
static

Definition at line 608 of file af_arnndn.c.

Referenced by pitch_downsample().

static void celt_lpc ( float *  lpc,
const float *  ac,
int  p 
)
static

Definition at line 646 of file af_arnndn.c.

Referenced by pitch_downsample().

static void celt_fir5 ( const float *  x,
const float *  num,
float *  y,
int  N,
float *  mem 
)
static

Definition at line 679 of file af_arnndn.c.

Referenced by pitch_downsample().

static void pitch_downsample ( float *  x[],
float *  x_lp,
int  len,
int  C 
)
static

Definition at line 722 of file af_arnndn.c.

Referenced by compute_frame_features().

static void dual_inner_prod ( const float *  x,
const float *  y01,
const float *  y02,
int  N,
float *  xy1,
float *  xy2 
)
inlinestatic

Definition at line 764 of file af_arnndn.c.

Referenced by remove_doubling().

static float compute_pitch_gain ( float  xy,
float  xx,
float  yy 
)
static

Definition at line 778 of file af_arnndn.c.

Referenced by remove_doubling().

static float remove_doubling ( float *  x,
int  maxperiod,
int  minperiod,
int  N,
int T0_,
int  prev_period,
float  prev_gain 
)
static

Definition at line 784 of file af_arnndn.c.

Referenced by compute_frame_features().

static void find_best_pitch ( float *  xcorr,
float *  y,
int  len,
int  max_pitch,
int best_pitch 
)
static

Definition at line 887 of file af_arnndn.c.

Referenced by pitch_search().

static void pitch_search ( const float *  x_lp,
float *  y,
int  len,
int  max_pitch,
int pitch 
)
static

Definition at line 934 of file af_arnndn.c.

Referenced by compute_frame_features().

static void dct ( AudioRNNContext s,
float *  out,
const float *  in 
)
static

Definition at line 991 of file af_arnndn.c.

Referenced by compute_frame_features(), dct_sad8x8_c(), and ff_mpadsp_init().

static int compute_frame_features ( AudioRNNContext s,
DenoiseState st,
AVComplexFloat X,
AVComplexFloat P,
float *  Ex,
float *  Ep,
float *  Exp,
float *  features,
const float *  in 
)
static

Definition at line 1001 of file af_arnndn.c.

Referenced by rnnoise_channel().

static void interp_band_gain ( float *  g,
const float *  bandE 
)
static

Definition at line 1109 of file af_arnndn.c.

Referenced by pitch_filter(), and rnnoise_channel().

static void pitch_filter ( AVComplexFloat X,
const AVComplexFloat P,
const float *  Ex,
const float *  Ep,
const float *  Exp,
const float *  g 
)
static

Definition at line 1124 of file af_arnndn.c.

Referenced by rnnoise_channel().

static float tansig_approx ( float  x)
inlinestatic

Definition at line 1199 of file af_arnndn.c.

Referenced by compute_dense(), compute_gru(), and sigmoid_approx().

static float sigmoid_approx ( float  x)
inlinestatic

Definition at line 1227 of file af_arnndn.c.

Referenced by compute_dense(), and compute_gru().

static void compute_dense ( const DenseLayer layer,
float *  output,
const float *  input 
)
static

Definition at line 1232 of file af_arnndn.c.

Referenced by compute_rnn().

static void compute_gru ( AudioRNNContext s,
const GRULayer gru,
float *  state,
const float *  input 
)
static

Definition at line 1260 of file af_arnndn.c.

Referenced by compute_rnn().

static void compute_rnn ( AudioRNNContext s,
RNNState rnn,
float *  gains,
float *  vad,
const float *  input 
)
static

Definition at line 1313 of file af_arnndn.c.

Referenced by rnnoise_channel().

static float rnnoise_channel ( AudioRNNContext s,
DenoiseState st,
float *  out,
const float *  in,
int  disabled 
)
static

Definition at line 1341 of file af_arnndn.c.

Referenced by rnnoise_channels().

static int rnnoise_channels ( AVFilterContext ctx,
void arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 1387 of file af_arnndn.c.

Referenced by filter_frame().

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 1406 of file af_arnndn.c.

Referenced by activate().

static int activate ( AVFilterContext ctx)
static

Definition at line 1428 of file af_arnndn.c.

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 1450 of file af_arnndn.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 1486 of file af_arnndn.c.

AVFILTER_DEFINE_CLASS ( arnndn  )

Variable Documentation

const uint8_t eband5ms[]
static
Initial value:
= {
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 34, 40, 48, 60, 78, 100
}

Definition at line 429 of file af_arnndn.c.

Referenced by compute_band_corr(), compute_band_energy(), and interp_band_gain().

const uint8_t second_check[16] = {0, 0, 3, 2, 3, 2, 5, 2, 3, 2, 3, 2, 5, 2, 3, 2}
static

Definition at line 783 of file af_arnndn.c.

Referenced by remove_doubling().

const float tansig_table[201]
static

Definition at line 1155 of file af_arnndn.c.

Referenced by tansig_approx().

const AVFilterPad inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_input(AVFilterLink *inlink)
Definition: af_arnndn.c:342

Definition at line 1506 of file af_arnndn.c.

const AVFilterPad outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}
#define NULL
Definition: coverity.c:32

Definition at line 1515 of file af_arnndn.c.

const AVOption arnndn_options[]
static
Initial value:
= {
{ "model", "set model name", OFFSET(model_name), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, AF },
{ "m", "set model name", OFFSET(model_name), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, AF },
{ NULL }
}
#define NULL
Definition: coverity.c:32
#define AF
Definition: af_arnndn.c:1524
#define OFFSET(x)
Definition: af_arnndn.c:1523

Definition at line 1526 of file af_arnndn.c.

AVFilter ff_af_arnndn
Initial value:
= {
.name = "arnndn",
.description = NULL_IF_CONFIG_SMALL("Reduce noise from speech using Recurrent Neural Networks."),
.query_formats = query_formats,
.priv_size = sizeof(AudioRNNContext),
.priv_class = &arnndn_class,
.init = init,
}
static int query_formats(AVFilterContext *ctx)
Definition: af_arnndn.c:311
static const AVFilterPad inputs[]
Definition: af_arnndn.c:1506
static int activate(AVFilterContext *ctx)
Definition: af_arnndn.c:1428
static const AVFilterPad outputs[]
Definition: af_arnndn.c:1515
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_arnndn.c:1486
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:153
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
static av_cold int init(AVFilterContext *ctx)
Definition: af_arnndn.c:1450
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:134
#define flags(name, subs,...)
Definition: cbs_av1.c:560

Definition at line 1534 of file af_arnndn.c.