FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
af_firequalizer.c File Reference
#include "libavutil/opt.h"
#include "libavutil/eval.h"
#include "libavutil/avassert.h"
#include "libavcodec/avfft.h"
#include "avfilter.h"
#include "internal.h"
#include "audio.h"

Go to the source code of this file.

Data Structures

struct  GainEntry
 
struct  OverlapIndex
 
struct  FIREqualizerContext
 

Macros

#define RDFT_BITS_MIN   4
 
#define RDFT_BITS_MAX   16
 
#define NB_GAIN_ENTRY_MAX   4096
 
#define OFFSET(x)   offsetof(FIREqualizerContext, x)
 
#define FLAGS   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define SELECT_GAIN(s)   (s->gain_cmd ? s->gain_cmd : s->gain)
 
#define SELECT_GAIN_ENTRY(s)   (s->gain_entry_cmd ? s->gain_entry_cmd : s->gain_entry)
 

Enumerations

enum  WindowFunc {
  WFUNC_RECTANGULAR, WFUNC_HANN, WFUNC_HAMMING, WFUNC_BLACKMAN,
  WFUNC_NUTTALL3, WFUNC_MNUTTALL3, WFUNC_NUTTALL, WFUNC_BNUTTALL,
  WFUNC_BHARRIS, WFUNC_TUKEY, NB_WFUNC, WFUNC_RECT,
  WFUNC_HANNING, WFUNC_HAMMING, WFUNC_BLACKMAN, WFUNC_BARTLETT,
  WFUNC_WELCH, WFUNC_FLATTOP, WFUNC_BHARRIS, WFUNC_BNUTTALL,
  WFUNC_SINE, WFUNC_NUTTALL, WFUNC_BHANN, WFUNC_LANCZOS,
  WFUNC_GAUSS, WFUNC_TUKEY, WFUNC_DOLPH, WFUNC_CAUCHY,
  WFUNC_PARZEN, WFUNC_POISSON, NB_WFUNC
}
 
enum  Scale {
  SCALE_LINLIN, SCALE_LINLOG, SCALE_LOGLIN, SCALE_LOGLOG,
  NB_SCALE
}
 
enum  VarOffset {
  VAR_F, VAR_SR, VAR_CH, VAR_CHID,
  VAR_CHS, VAR_CHLAYOUT, VAR_NB
}
 

Functions

 AVFILTER_DEFINE_CLASS (firequalizer)
 
static void common_uninit (FIREqualizerContext *s)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static void fast_convolute (FIREqualizerContext *av_restrict s, const float *av_restrict kernel_buf, float *av_restrict conv_buf, OverlapIndex *av_restrict idx, float *av_restrict data, int nsamples)
 
static void fast_convolute_nonlinear (FIREqualizerContext *av_restrict s, const float *av_restrict kernel_buf, float *av_restrict conv_buf, OverlapIndex *av_restrict idx, float *av_restrict data, int nsamples)
 
static void fast_convolute2 (FIREqualizerContext *av_restrict s, const float *av_restrict kernel_buf, FFTComplex *av_restrict conv_buf, OverlapIndex *av_restrict idx, float *av_restrict data0, float *av_restrict data1, int nsamples)
 
static void dump_fir (AVFilterContext *ctx, FILE *fp, int ch)
 
static double entry_func (void *p, double freq, double gain)
 
static int gain_entry_compare (const void *key, const void *memb)
 
static double gain_interpolate_func (void *p, double freq)
 
static double cubic_interpolate_func (void *p, double freq)
 
static void generate_min_phase_kernel (FIREqualizerContext *s, float *rdft_buf)
 
static int generate_kernel (AVFilterContext *ctx, const char *gain, const char *gain_entry)
 
static int config_input (AVFilterLink *inlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *frame)
 
static int request_frame (AVFilterLink *outlink)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 

Variables

static const AVOption firequalizer_options []
 
static const char *const var_names []
 
static const AVFilterPad firequalizer_inputs []
 
static const AVFilterPad firequalizer_outputs []
 
AVFilter ff_af_firequalizer
 

Macro Definition Documentation

#define RDFT_BITS_MIN   4

Definition at line 29 of file af_firequalizer.c.

Referenced by config_input().

#define RDFT_BITS_MAX   16

Definition at line 30 of file af_firequalizer.c.

Referenced by config_input().

#define NB_GAIN_ENTRY_MAX   4096

Definition at line 54 of file af_firequalizer.c.

Referenced by entry_func().

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

Definition at line 113 of file af_firequalizer.c.

Definition at line 114 of file af_firequalizer.c.

#define SELECT_GAIN (   s)    (s->gain_cmd ? s->gain_cmd : s->gain)

Definition at line 753 of file af_firequalizer.c.

Referenced by config_input(), and process_command().

#define SELECT_GAIN_ENTRY (   s)    (s->gain_entry_cmd ? s->gain_entry_cmd : s->gain_entry)

Definition at line 754 of file af_firequalizer.c.

Referenced by config_input(), and process_command().

Enumeration Type Documentation

enum WindowFunc
Enumerator
WFUNC_RECTANGULAR 
WFUNC_HANN 
WFUNC_HAMMING 
WFUNC_BLACKMAN 
WFUNC_NUTTALL3 
WFUNC_MNUTTALL3 
WFUNC_NUTTALL 
WFUNC_BNUTTALL 
WFUNC_BHARRIS 
WFUNC_TUKEY 
NB_WFUNC 
WFUNC_RECT 
WFUNC_HANNING 
WFUNC_HAMMING 
WFUNC_BLACKMAN 
WFUNC_BARTLETT 
WFUNC_WELCH 
WFUNC_FLATTOP 
WFUNC_BHARRIS 
WFUNC_BNUTTALL 
WFUNC_SINE 
WFUNC_NUTTALL 
WFUNC_BHANN 
WFUNC_LANCZOS 
WFUNC_GAUSS 
WFUNC_TUKEY 
WFUNC_DOLPH 
WFUNC_CAUCHY 
WFUNC_PARZEN 
WFUNC_POISSON 
NB_WFUNC 

Definition at line 32 of file af_firequalizer.c.

enum Scale
Enumerator
SCALE_LINLIN 
SCALE_LINLOG 
SCALE_LOGLIN 
SCALE_LOGLOG 
NB_SCALE 

Definition at line 46 of file af_firequalizer.c.

enum VarOffset
Enumerator
VAR_F 
VAR_SR 
VAR_CH 
VAR_CHID 
VAR_CHS 
VAR_CHLAYOUT 
VAR_NB 

Definition at line 543 of file af_firequalizer.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( firequalizer  )
static void common_uninit ( FIREqualizerContext s)
static

Definition at line 149 of file af_firequalizer.c.

Referenced by config_input(), and uninit().

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 172 of file af_firequalizer.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 181 of file af_firequalizer.c.

static void fast_convolute ( FIREqualizerContext *av_restrict  s,
const float *av_restrict  kernel_buf,
float *av_restrict  conv_buf,
OverlapIndex *av_restrict  idx,
float *av_restrict  data,
int  nsamples 
)
static

Definition at line 211 of file af_firequalizer.c.

Referenced by filter_frame().

static void fast_convolute_nonlinear ( FIREqualizerContext *av_restrict  s,
const float *av_restrict  kernel_buf,
float *av_restrict  conv_buf,
OverlapIndex *av_restrict  idx,
float *av_restrict  data,
int  nsamples 
)
static

Definition at line 249 of file af_firequalizer.c.

Referenced by filter_frame().

static void fast_convolute2 ( FIREqualizerContext *av_restrict  s,
const float *av_restrict  kernel_buf,
FFTComplex *av_restrict  conv_buf,
OverlapIndex *av_restrict  idx,
float *av_restrict  data0,
float *av_restrict  data1,
int  nsamples 
)
static

Definition at line 289 of file af_firequalizer.c.

Referenced by filter_frame().

static void dump_fir ( AVFilterContext ctx,
FILE *  fp,
int  ch 
)
static

Definition at line 353 of file af_firequalizer.c.

Referenced by generate_kernel().

static double entry_func ( void p,
double  freq,
double  gain 
)
static

Definition at line 412 of file af_firequalizer.c.

Referenced by generate_kernel().

static int gain_entry_compare ( const void key,
const void memb 
)
static

Definition at line 441 of file af_firequalizer.c.

Referenced by cubic_interpolate_func(), and gain_interpolate_func().

static double gain_interpolate_func ( void p,
double  freq 
)
static

Definition at line 453 of file af_firequalizer.c.

Referenced by generate_kernel().

static double cubic_interpolate_func ( void p,
double  freq 
)
static

Definition at line 488 of file af_firequalizer.c.

Referenced by generate_kernel().

static void generate_min_phase_kernel ( FIREqualizerContext s,
float *  rdft_buf 
)
static

Definition at line 553 of file af_firequalizer.c.

Referenced by generate_kernel().

static int generate_kernel ( AVFilterContext ctx,
const char *  gain,
const char *  gain_entry 
)
static

Definition at line 601 of file af_firequalizer.c.

Referenced by config_input(), and process_command().

static int config_input ( AVFilterLink inlink)
static

Definition at line 756 of file af_firequalizer.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 843 of file af_firequalizer.c.

Referenced by request_frame().

static int request_frame ( AVFilterLink outlink)
static

Definition at line 879 of file af_firequalizer.c.

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

Definition at line 901 of file af_firequalizer.c.

Variable Documentation

const AVOption firequalizer_options[]
static
Initial value:
= {
{ "gain", "set gain curve", OFFSET(gain), AV_OPT_TYPE_STRING, { .str = "gain_interpolate(f)" }, 0, 0, FLAGS },
{ "gain_entry", "set gain entry", OFFSET(gain_entry), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
{ "delay", "set delay", OFFSET(delay), AV_OPT_TYPE_DOUBLE, { .dbl = 0.01 }, 0.0, 1e10, FLAGS },
{ "accuracy", "set accuracy", OFFSET(accuracy), AV_OPT_TYPE_DOUBLE, { .dbl = 5.0 }, 0.0, 1e10, FLAGS },
{ "wfunc", "set window function", OFFSET(wfunc), AV_OPT_TYPE_INT, { .i64 = WFUNC_HANN }, 0, NB_WFUNC-1, FLAGS, "wfunc" },
{ "rectangular", "rectangular window", 0, AV_OPT_TYPE_CONST, { .i64 = WFUNC_RECTANGULAR }, 0, 0, FLAGS, "wfunc" },
{ "hann", "hann window", 0, AV_OPT_TYPE_CONST, { .i64 = WFUNC_HANN }, 0, 0, FLAGS, "wfunc" },
{ "hamming", "hamming window", 0, AV_OPT_TYPE_CONST, { .i64 = WFUNC_HAMMING }, 0, 0, FLAGS, "wfunc" },
{ "blackman", "blackman window", 0, AV_OPT_TYPE_CONST, { .i64 = WFUNC_BLACKMAN }, 0, 0, FLAGS, "wfunc" },
{ "nuttall3", "3-term nuttall window", 0, AV_OPT_TYPE_CONST, { .i64 = WFUNC_NUTTALL3 }, 0, 0, FLAGS, "wfunc" },
{ "mnuttall3", "minimum 3-term nuttall window", 0, AV_OPT_TYPE_CONST, { .i64 = WFUNC_MNUTTALL3 }, 0, 0, FLAGS, "wfunc" },
{ "nuttall", "nuttall window", 0, AV_OPT_TYPE_CONST, { .i64 = WFUNC_NUTTALL }, 0, 0, FLAGS, "wfunc" },
{ "bnuttall", "blackman-nuttall window", 0, AV_OPT_TYPE_CONST, { .i64 = WFUNC_BNUTTALL }, 0, 0, FLAGS, "wfunc" },
{ "bharris", "blackman-harris window", 0, AV_OPT_TYPE_CONST, { .i64 = WFUNC_BHARRIS }, 0, 0, FLAGS, "wfunc" },
{ "tukey", "tukey window", 0, AV_OPT_TYPE_CONST, { .i64 = WFUNC_TUKEY }, 0, 0, FLAGS, "wfunc" },
{ "fixed", "set fixed frame samples", OFFSET(fixed), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
{ "multi", "set multi channels mode", OFFSET(multi), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
{ "zero_phase", "set zero phase mode", OFFSET(zero_phase), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
{ "scale", "set gain scale", OFFSET(scale), AV_OPT_TYPE_INT, { .i64 = SCALE_LINLOG }, 0, NB_SCALE-1, FLAGS, "scale" },
{ "linlin", "linear-freq linear-gain", 0, AV_OPT_TYPE_CONST, { .i64 = SCALE_LINLIN }, 0, 0, FLAGS, "scale" },
{ "linlog", "linear-freq logarithmic-gain", 0, AV_OPT_TYPE_CONST, { .i64 = SCALE_LINLOG }, 0, 0, FLAGS, "scale" },
{ "loglin", "logarithmic-freq linear-gain", 0, AV_OPT_TYPE_CONST, { .i64 = SCALE_LOGLIN }, 0, 0, FLAGS, "scale" },
{ "loglog", "logarithmic-freq logarithmic-gain", 0, AV_OPT_TYPE_CONST, { .i64 = SCALE_LOGLOG }, 0, 0, FLAGS, "scale" },
{ "dumpfile", "set dump file", OFFSET(dumpfile), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
{ "dumpscale", "set dump scale", OFFSET(dumpscale), AV_OPT_TYPE_INT, { .i64 = SCALE_LINLOG }, 0, NB_SCALE-1, FLAGS, "scale" },
{ "fft2", "set 2-channels fft", OFFSET(fft2), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
{ "min_phase", "set minimum phase mode", OFFSET(min_phase), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
{ NULL }
}
#define NULL
Definition: coverity.c:32
#define FLAGS
#define OFFSET(x)

Definition at line 116 of file af_firequalizer.c.

const char* const var_names[]
static
Initial value:
= {
"f",
"sr",
"ch",
"chid",
"chs",
"chlayout",
}
#define NULL
Definition: coverity.c:32

Definition at line 533 of file af_firequalizer.c.

Referenced by generate_kernel().

const AVFilterPad firequalizer_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
.filter_frame = filter_frame,
.needs_writable = 1,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_input(AVFilterLink *inlink)
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)

Definition at line 950 of file af_firequalizer.c.

const AVFilterPad firequalizer_outputs[]
static
Initial value:
= {
{
.name = "default",
.request_frame = request_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int request_frame(AVFilterLink *outlink)

Definition at line 961 of file af_firequalizer.c.

AVFilter ff_af_firequalizer
Initial value:
= {
.name = "firequalizer",
.description = NULL_IF_CONFIG_SMALL("Finite Impulse Response Equalizer."),
.uninit = uninit,
.query_formats = query_formats,
.process_command = process_command,
.priv_size = sizeof(FIREqualizerContext),
.priv_class = &firequalizer_class,
}
static const AVFilterPad firequalizer_outputs[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static av_cold void uninit(AVFilterContext *ctx)
static const AVFilterPad firequalizer_inputs[]
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static int query_formats(AVFilterContext *ctx)

Definition at line 970 of file af_firequalizer.c.