FFmpeg
Loading...
Searching...
No Matches
af_afftdn.c File Reference
#include <float.h>
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/channel_layout.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/tx.h"
#include "avfilter.h"
#include "audio.h"
#include "filters.h"

Go to the source code of this file.

Data Structures

struct  DeNoiseChannel
 
struct  AudioFFTDeNoiseContext
 

Macros

#define C   (M_LN10 * 0.1)
 
#define SOLVE_SIZE   (5)
 
#define NB_PROFILE_BANDS   (15)
 
#define OFFSET(x)
 
#define AF   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define AFR   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 

Enumerations

enum  SampleNoiseModes { SAMPLE_NONE , SAMPLE_START , SAMPLE_STOP , NB_SAMPLEMODES }
 
enum  OutModes { IN_MODE , OUT_MODE , NOISE_MODE , NB_MODES }
 
enum  NoiseLinkType {
  NONE_LINK , MIN_LINK , MAX_LINK , AVERAGE_LINK ,
  NB_LINK
}
 
enum  NoiseType {
  WHITE_NOISE , VINYL_NOISE , SHELLAC_NOISE , CUSTOM_NOISE ,
  NB_NOISE
}
 

Functions

 AVFILTER_DEFINE_CLASS (afftdn)
 
static double get_band_noise (AudioFFTDeNoiseContext *s, int band, double a, double b, double c)
 
static void factor (double *array, int size)
 
static void solve (double *matrix, double *vector, int size)
 
static double process_get_band_noise (AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, int band)
 
static double limit_gain (double a, double b)
 
static void spectral_flatness (AudioFFTDeNoiseContext *s, const double *const spectral, double floor, int len, double *rnum, double *rden)
 
static void set_parameters (AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, int update_var, int update_auto_var)
 
static double floor_offset (const double *S, int size, double mean)
 
static void process_frame (AVFilterContext *ctx, AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, double *prior, double *prior_band_excit, int track_noise)
 
static double freq2bark (double x)
 
static int get_band_centre (AudioFFTDeNoiseContext *s, int band)
 
static int get_band_edge (AudioFFTDeNoiseContext *s, int band)
 
static void set_band_parameters (AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch)
 
static void read_custom_noise (AVFilterContext *ctx, int ch)
 
static void reduce_mean (double *band_noise)
 
static int config_input (AVFilterLink *inlink)
 
static void init_sample_noise (DeNoiseChannel *dnch)
 
static void sample_noise_block (AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, AVFrame *in, int ch)
 
static void finish_sample_noise (AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, double *sample_noise)
 
static void set_noise_profile (AVFilterContext *ctx, DeNoiseChannel *dnch, double *sample_noise)
 
static int filter_channel (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int output_frame (AVFilterLink *inlink, AVFrame *in)
 
static int activate (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 

Variables

static const AVOption afftdn_options []
 
static const AVFilterPad inputs []
 
const FFFilter ff_af_afftdn
 

Macro Definition Documentation

◆ C

#define C   (M_LN10 * 0.1)

Definition at line 33 of file af_afftdn.c.

◆ SOLVE_SIZE

#define SOLVE_SIZE   (5)

Definition at line 34 of file af_afftdn.c.

Referenced by config_input(), process_get_band_noise(), and set_noise_profile().

◆ NB_PROFILE_BANDS

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 163 of file af_afftdn.c.

◆ AF

Definition at line 164 of file af_afftdn.c.

◆ AFR

Enumeration Type Documentation

◆ SampleNoiseModes

Enumerator
SAMPLE_NONE 
SAMPLE_START 
SAMPLE_STOP 
NB_SAMPLEMODES 

Definition at line 37 of file af_afftdn.c.

◆ OutModes

enum OutModes
Enumerator
IN_MODE 
OUT_MODE 
NOISE_MODE 
NB_MODES 

Definition at line 44 of file af_afftdn.c.

◆ NoiseLinkType

Enumerator
NONE_LINK 
MIN_LINK 
MAX_LINK 
AVERAGE_LINK 
NB_LINK 

Definition at line 51 of file af_afftdn.c.

◆ NoiseType

enum NoiseType
Enumerator
WHITE_NOISE 
VINYL_NOISE 
SHELLAC_NOISE 
CUSTOM_NOISE 
NB_NOISE 

Definition at line 59 of file af_afftdn.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( afftdn )

◆ get_band_noise()

static double get_band_noise ( AudioFFTDeNoiseContext * s,
int band,
double a,
double b,
double c )
static

Definition at line 224 of file af_afftdn.c.

Referenced by config_input().

◆ factor()

static void factor ( double * array,
int size )
static

Definition at line 240 of file af_afftdn.c.

◆ solve()

static void solve ( double * matrix,
double * vector,
int size )
static

Definition at line 254 of file af_afftdn.c.

Referenced by process_get_band_noise(), and set_noise_profile().

◆ process_get_band_noise()

static double process_get_band_noise ( AudioFFTDeNoiseContext * s,
DeNoiseChannel * dnch,
int band )
static

Definition at line 273 of file af_afftdn.c.

Referenced by set_band_parameters(), and set_parameters().

◆ limit_gain()

static double limit_gain ( double a,
double b )
static

Definition at line 303 of file af_afftdn.c.

Referenced by process_frame().

◆ spectral_flatness()

static void spectral_flatness ( AudioFFTDeNoiseContext * s,
const double *const spectral,
double floor,
int len,
double * rnum,
double * rden )
static

Definition at line 312 of file af_afftdn.c.

Referenced by process_frame().

◆ set_parameters()

static void set_parameters ( AudioFFTDeNoiseContext * s,
DeNoiseChannel * dnch,
int update_var,
int update_auto_var )
static

Definition at line 580 of file af_afftdn.c.

Referenced by config_input(), output_frame(), process_command(), and process_frame().

◆ floor_offset()

static double floor_offset ( const double * S,
int size,
double mean )
static

Definition at line 340 of file af_afftdn.c.

Referenced by process_frame().

◆ process_frame()

static void process_frame ( AVFilterContext * ctx,
AudioFFTDeNoiseContext * s,
DeNoiseChannel * dnch,
double * prior,
double * prior_band_excit,
int track_noise )
static

Definition at line 353 of file af_afftdn.c.

Referenced by filter_channel().

◆ freq2bark()

static double freq2bark ( double x)
static

Definition at line 486 of file af_afftdn.c.

Referenced by config_input().

◆ get_band_centre()

static int get_band_centre ( AudioFFTDeNoiseContext * s,
int band )
static

Definition at line 493 of file af_afftdn.c.

Referenced by set_band_parameters().

◆ get_band_edge()

static int get_band_edge ( AudioFFTDeNoiseContext * s,
int band )
static

Definition at line 501 of file af_afftdn.c.

Referenced by config_input().

◆ set_band_parameters()

static void set_band_parameters ( AudioFFTDeNoiseContext * s,
DeNoiseChannel * dnch )
static

Definition at line 514 of file af_afftdn.c.

Referenced by set_parameters().

◆ read_custom_noise()

static void read_custom_noise ( AVFilterContext * ctx,
int ch )
static

Definition at line 544 of file af_afftdn.c.

Referenced by config_input().

◆ reduce_mean()

static void reduce_mean ( double * band_noise)
static

Definition at line 620 of file af_afftdn.c.

Referenced by config_input(), and set_noise_profile().

◆ config_input()

static int config_input ( AVFilterLink * inlink)
static

Definition at line 632 of file af_afftdn.c.

◆ init_sample_noise()

static void init_sample_noise ( DeNoiseChannel * dnch)
static

Definition at line 899 of file af_afftdn.c.

Referenced by output_frame().

◆ sample_noise_block()

static void sample_noise_block ( AudioFFTDeNoiseContext * s,
DeNoiseChannel * dnch,
AVFrame * in,
int ch )
static

Definition at line 909 of file af_afftdn.c.

Referenced by output_frame().

◆ finish_sample_noise()

static void finish_sample_noise ( AudioFFTDeNoiseContext * s,
DeNoiseChannel * dnch,
double * sample_noise )
static

Definition at line 994 of file af_afftdn.c.

Referenced by output_frame().

◆ set_noise_profile()

static void set_noise_profile ( AVFilterContext * ctx,
DeNoiseChannel * dnch,
double * sample_noise )
static

Definition at line 1013 of file af_afftdn.c.

Referenced by output_frame().

◆ filter_channel()

static int filter_channel ( AVFilterContext * ctx,
void * arg,
int jobnr,
int nb_jobs )
static

Definition at line 1051 of file af_afftdn.c.

◆ output_frame()

static int output_frame ( AVFilterLink * inlink,
AVFrame * in )
static

Definition at line 1109 of file af_afftdn.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext * ctx)
static

Definition at line 1271 of file af_afftdn.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 1298 of file af_afftdn.c.

◆ process_command()

static int process_command ( AVFilterContext * ctx,
const char * cmd,
const char * args,
char * res,
int res_len,
int flags )
static

Definition at line 1334 of file af_afftdn.c.

Variable Documentation

◆ afftdn_options

const AVOption afftdn_options[]
static

Definition at line 167 of file af_afftdn.c.

◆ inputs

const AVFilterPad inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
},
}
static int config_input(AVFilterLink *inlink)
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201

Definition at line 1360 of file af_afftdn.c.

◆ ff_af_afftdn

const FFFilter ff_af_afftdn
Initial value:
= {
.p.name = "afftdn",
.p.description = NULL_IF_CONFIG_SMALL("Denoise audio samples using FFT."),
.p.priv_class = &afftdn_class,
.priv_size = sizeof(AudioFFTDeNoiseContext),
.process_command = process_command,
}
static const AVFilterPad inputs[]
Definition af_aap.c:299
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
Definition audio.c:34
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:166
#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:204
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition samplefmt.h:66
@ AV_SAMPLE_FMT_DBLP
double, planar
Definition samplefmt.h:67
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_SAMPLEFMTS(...)
Definition filters.h:252
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88

Definition at line 1368 of file af_afftdn.c.