FFmpeg
Loading...
Searching...
No Matches
af_biquads.c File Reference
#include "config_components.h"
#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/ffmath.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "audio.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"

Go to the source code of this file.

Data Structures

struct  BiquadsContext
 
struct  ThreadData
 Used for passing data between threads. More...
 

Macros

#define BIQUAD_FILTER(name, type, ftype, min, max, need_clipping)
 
#define BIQUAD_DII_FILTER(name, type, ftype, min, max, need_clipping)
 
#define BIQUAD_TDI_FILTER(name, type, ftype, min, max, need_clipping)
 
#define BIQUAD_TDII_FILTER(name, type, ftype, min, max, need_clipping)
 
#define BIQUAD_LATT_FILTER(name, type, ftype, min, max, need_clipping)
 
#define BIQUAD_SVF_FILTER(name, type, ftype, min, max, need_clipping)
 
#define BIQUAD_ZDF_FILTER(name, type, ftype, min, max, need_clipping, two)
 
#define OFFSET(x)
 
#define FLAGS   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
#define AF   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define DEFINE_BIQUAD_FILTER_2(name_, description_, priv_class_)
 
#define DEFINE_BIQUAD_FILTER(name, description)
 
#define WIDTH_OPTION(x)
 
#define WIDTH_TYPE_OPTION(x)
 
#define MIX_CHANNELS_NORMALIZE_OPTION(x, y, z)
 
#define TRANSFORM_OPTION(x)
 
#define PRECISION_OPTION(x)
 
#define BLOCKSIZE_OPTION(x)
 

Enumerations

enum  FilterType {
  biquad , equalizer , bass , treble ,
  bandpass , bandreject , allpass , highpass ,
  lowpass , lowshelf , highshelf , tiltshelf
}
 
enum  WidthType {
  NONE , HERTZ , OCTAVE , QFACTOR ,
  SLOPE , KHERTZ , NB_WTYPE
}
 
enum  TransformType {
  DI , DII , TDI , TDII ,
  LATT , SVF , ZDF , NB_TTYPE
}
 

Functions

static int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
static void convert_dir2latt (BiquadsContext *s)
 
static void convert_dir2svf (BiquadsContext *s)
 
static double convert_width2qfactor (double width, double frequency, double gain, double sample_rate, int width_type)
 
static void convert_dir2zdf (BiquadsContext *s, int sample_rate)
 
static int config_filter (AVFilterLink *outlink, int reset)
 
static int config_output (AVFilterLink *outlink)
 
static void reverse_samples (AVFrame *out, AVFrame *in, int p, int oo, int io, int nb_samples)
 
static int filter_channel (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *buf, int eof)
 
static int activate (AVFilterContext *ctx)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVFilterPad outputs []
 

Macro Definition Documentation

◆ BIQUAD_FILTER

#define BIQUAD_FILTER ( name,
type,
ftype,
min,
max,
need_clipping )

Definition at line 201 of file af_biquads.c.

◆ BIQUAD_DII_FILTER

#define BIQUAD_DII_FILTER ( name,
type,
ftype,
min,
max,
need_clipping )

Definition at line 283 of file af_biquads.c.

◆ BIQUAD_TDI_FILTER

#define BIQUAD_TDI_FILTER ( name,
type,
ftype,
min,
max,
need_clipping )

Definition at line 332 of file af_biquads.c.

◆ BIQUAD_TDII_FILTER

#define BIQUAD_TDII_FILTER ( name,
type,
ftype,
min,
max,
need_clipping )

Definition at line 389 of file af_biquads.c.

◆ BIQUAD_LATT_FILTER

#define BIQUAD_LATT_FILTER ( name,
type,
ftype,
min,
max,
need_clipping )

Definition at line 437 of file af_biquads.c.

◆ BIQUAD_SVF_FILTER

#define BIQUAD_SVF_FILTER ( name,
type,
ftype,
min,
max,
need_clipping )

Definition at line 496 of file af_biquads.c.

◆ BIQUAD_ZDF_FILTER

#define BIQUAD_ZDF_FILTER ( name,
type,
ftype,
min,
max,
need_clipping,
two )

Definition at line 548 of file af_biquads.c.

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 1446 of file af_biquads.c.

◆ FLAGS

◆ AF

Definition at line 1448 of file af_biquads.c.

◆ DEFINE_BIQUAD_FILTER_2

#define DEFINE_BIQUAD_FILTER_2 ( name_,
description_,
priv_class_ )
Value:
static av_cold int name_##_init(AVFilterContext *ctx) \
{ \
BiquadsContext *s = ctx->priv; \
s->filter_type = name_; \
s->pts = AV_NOPTS_VALUE; \
return 0; \
} \
\
const FFFilter ff_af_##name_ = { \
.p.name = #name_, \
.p.description = NULL_IF_CONFIG_SMALL(description_), \
.p.priv_class = &priv_class_##_class, \
.priv_size = sizeof(BiquadsContext), \
.init = name_##_init, \
.uninit = uninit, \
FILTER_OUTPUTS(outputs), \
FILTER_QUERY_FUNC2(query_formats), \
.process_command = process_command, \
}
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition aeval.c:246
static const AVFilterPad outputs[]
Definition af_aap.c:310
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static AVFormatContext * ctx
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 s(width, name)
Definition cbs_vp9.c:198
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#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
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition avutil.h:247
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define av_cold
Definition attributes.h:117
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
An instance of a filter.
Definition avfilter.h:273

Definition at line 1450 of file af_biquads.c.

◆ DEFINE_BIQUAD_FILTER

#define DEFINE_BIQUAD_FILTER ( name,
description )
Value:
DEFINE_BIQUAD_FILTER_2(name, description, name)
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:478
const char * name
Definition qsvenc.c:142

Definition at line 1475 of file af_biquads.c.

◆ WIDTH_OPTION

#define WIDTH_OPTION ( x)
Value:
{"width", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=x}, 0, 99999, FLAGS}, \
{"w", "set width", OFFSET(width), AV_OPT_TYPE_DOUBLE, {.dbl=x}, 0, 99999, FLAGS}
#define FLAGS
Definition cmdutils.c:598
#define OFFSET(x)
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
Definition opt.h:266
#define width
Definition dsp.h:89

Definition at line 1479 of file af_biquads.c.

◆ WIDTH_TYPE_OPTION

#define WIDTH_TYPE_OPTION ( x)
Value:
{"width_type", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=x}, HERTZ, NB_WTYPE-1, FLAGS, .unit = "width_type"}, \
{"t", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=x}, HERTZ, NB_WTYPE-1, FLAGS, .unit = "width_type"}, \
{"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, .unit = "width_type"}, \
{"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, .unit = "width_type"}, \
{"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, .unit = "width_type"}, \
{"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, .unit = "width_type"}, \
{"k", "kHz", 0, AV_OPT_TYPE_CONST, {.i64=KHERTZ}, 0, 0, FLAGS, .unit = "width_type"}
@ KHERTZ
Definition af_biquads.c:99
@ HERTZ
Definition af_biquads.c:95
@ OCTAVE
Definition af_biquads.c:96
@ QFACTOR
Definition af_biquads.c:97
@ NB_WTYPE
Definition af_biquads.c:100
@ SLOPE
Definition af_biquads.c:98
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258

Definition at line 1483 of file af_biquads.c.

◆ MIX_CHANNELS_NORMALIZE_OPTION

#define MIX_CHANNELS_NORMALIZE_OPTION ( x,
y,
z )
Value:
{"mix", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=x}, 0, 1, FLAGS}, \
{"m", "set mix", OFFSET(mix), AV_OPT_TYPE_DOUBLE, {.dbl=x}, 0, 1, FLAGS}, \
{"channels", "set channels to filter", OFFSET(ch_layout_str), AV_OPT_TYPE_STRING, {.str=y}, 0, 0, FLAGS}, \
{"c", "set channels to filter", OFFSET(ch_layout_str), AV_OPT_TYPE_STRING, {.str=y}, 0, 0, FLAGS}, \
{"normalize", "normalize coefficients", OFFSET(normalize), AV_OPT_TYPE_BOOL, {.i64=z}, 0, 1, FLAGS}, \
{"n", "normalize coefficients", OFFSET(normalize), AV_OPT_TYPE_BOOL, {.i64=z}, 0, 1, FLAGS}
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
static int mix(int c0, int c1)
Definition 4xm.c:717

Definition at line 1492 of file af_biquads.c.

◆ TRANSFORM_OPTION

#define TRANSFORM_OPTION ( x)
Value:
{"transform", "set transform type", OFFSET(transform_type), AV_OPT_TYPE_INT, {.i64=x}, 0, NB_TTYPE-1, AF, .unit = "transform_type"}, \
{"a", "set transform type", OFFSET(transform_type), AV_OPT_TYPE_INT, {.i64=x}, 0, NB_TTYPE-1, AF, .unit = "transform_type"}, \
{"di", "direct form I", 0, AV_OPT_TYPE_CONST, {.i64=DI}, 0, 0, AF, .unit = "transform_type"}, \
{"dii", "direct form II", 0, AV_OPT_TYPE_CONST, {.i64=DII}, 0, 0, AF, .unit = "transform_type"}, \
{"tdi", "transposed direct form I", 0, AV_OPT_TYPE_CONST, {.i64=TDI}, 0, 0, AF, .unit = "transform_type"}, \
{"tdii", "transposed direct form II", 0, AV_OPT_TYPE_CONST, {.i64=TDII}, 0, 0, AF, .unit = "transform_type"}, \
{"latt", "lattice-ladder form", 0, AV_OPT_TYPE_CONST, {.i64=LATT}, 0, 0, AF, .unit = "transform_type"}, \
{"svf", "state variable filter form", 0, AV_OPT_TYPE_CONST, {.i64=SVF}, 0, 0, AF, .unit = "transform_type"}, \
{"zdf", "zero-delay filter form", 0, AV_OPT_TYPE_CONST, {.i64=ZDF}, 0, 0, AF, .unit = "transform_type"}
#define AF
@ ZDF
Definition af_biquads.c:110
@ DI
Definition af_biquads.c:104
@ SVF
Definition af_biquads.c:109
@ DII
Definition af_biquads.c:105
@ TDII
Definition af_biquads.c:107
@ TDI
Definition af_biquads.c:106
@ LATT
Definition af_biquads.c:108
@ NB_TTYPE
Definition af_biquads.c:111

Definition at line 1500 of file af_biquads.c.

◆ PRECISION_OPTION

#define PRECISION_OPTION ( x)
Value:
{"precision", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=x}, -1, 3, AF, .unit = "precision"}, \
{"r", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=x}, -1, 3, AF, .unit = "precision"}, \
{"auto", "automatic", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, AF, .unit = "precision"}, \
{"s16", "signed 16-bit", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, .unit = "precision"}, \
{"s32", "signed 32-bit", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, .unit = "precision"}, \
{"f32", "floating-point single", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, .unit = "precision"}, \
{"f64", "floating-point double", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, AF, .unit = "precision"}

Definition at line 1511 of file af_biquads.c.

◆ BLOCKSIZE_OPTION

#define BLOCKSIZE_OPTION ( x)
Value:
{"blocksize", "set the block size", OFFSET(block_samples), AV_OPT_TYPE_INT, {.i64=x}, 0, 32768, AF}, \
{"b", "set the block size", OFFSET(block_samples), AV_OPT_TYPE_INT, {.i64=x}, 0, 32768, AF}

Definition at line 1520 of file af_biquads.c.

Enumeration Type Documentation

◆ FilterType

enum FilterType
Enumerator
biquad 
equalizer 
bass 
treble 
bandpass 
bandreject 
allpass 
highpass 
lowpass 
lowshelf 
highshelf 
tiltshelf 

Definition at line 78 of file af_biquads.c.

◆ WidthType

enum WidthType
Enumerator
NONE 
HERTZ 
OCTAVE 
QFACTOR 
SLOPE 
KHERTZ 
NB_WTYPE 

Definition at line 93 of file af_biquads.c.

◆ TransformType

Enumerator
DI 
DII 
TDI 
TDII 
LATT 
SVF 
ZDF 
NB_TTYPE 

Definition at line 103 of file af_biquads.c.

Function Documentation

◆ query_formats()

static int query_formats ( const AVFilterContext * ctx,
AVFilterFormatsConfig ** cfg_in,
AVFilterFormatsConfig ** cfg_out )
static

Definition at line 158 of file af_biquads.c.

◆ convert_dir2latt()

static void convert_dir2latt ( BiquadsContext * s)
static

Definition at line 603 of file af_biquads.c.

Referenced by config_filter(), and convert_dir2latt().

◆ convert_dir2svf()

static void convert_dir2svf ( BiquadsContext * s)
static

Definition at line 620 of file af_biquads.c.

Referenced by config_filter().

◆ convert_width2qfactor()

static double convert_width2qfactor ( double width,
double frequency,
double gain,
double sample_rate,
int width_type )
static

Definition at line 638 of file af_biquads.c.

Referenced by convert_dir2zdf().

◆ convert_dir2zdf()

static void convert_dir2zdf ( BiquadsContext * s,
int sample_rate )
static

Definition at line 673 of file af_biquads.c.

Referenced by config_filter().

◆ config_filter()

static int config_filter ( AVFilterLink * outlink,
int reset )
static

Definition at line 797 of file af_biquads.c.

Referenced by config_output(), and process_command().

◆ config_output()

static int config_output ( AVFilterLink * outlink)
static

Definition at line 1196 of file af_biquads.c.

◆ reverse_samples()

static void reverse_samples ( AVFrame * out,
AVFrame * in,
int p,
int oo,
int io,
int nb_samples )
static

Definition at line 1206 of file af_biquads.c.

Referenced by filter_channel().

◆ filter_channel()

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

Definition at line 1241 of file af_biquads.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink * inlink,
AVFrame * buf,
int eof )
static

Definition at line 1298 of file af_biquads.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext * ctx)
static

Definition at line 1367 of file af_biquads.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 1413 of file af_biquads.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 1426 of file af_biquads.c.

Variable Documentation

◆ outputs

const AVFilterPad outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
static int config_output(AVBitStreamFilterLink *outlink)

Definition at line 1438 of file af_biquads.c.