FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
af_biquads.c File Reference
#include "config_components.h"
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/ffmath.h"
#include "libavutil/opt.h"
#include "audio.h"
#include "avfilter.h"
#include "filters.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

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

Macros

#define BIQUAD_FILTER(name, type, min, max, need_clipping)
 
#define BIQUAD_DII_FILTER(name, type, min, max, need_clipping)
 
#define BIQUAD_TDI_FILTER(name, type, min, max, need_clipping)
 
#define BIQUAD_TDII_FILTER(name, type, min, max, need_clipping)
 
#define BIQUAD_LATT_FILTER(name, type, min, max, need_clipping)
 
#define BIQUAD_SVF_FILTER(name, type, min, max, need_clipping)
 
#define BIQUAD_ZDF_FILTER(name, type, min, max, need_clipping)
 
#define OFFSET(x)   offsetof(BiquadsContext, 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 {
  DC_TYPE, AC_TYPE, SQ_TYPE, PS_TYPE,
  NB_TYPES, BUTTERWORTH, CHEBYSHEV1, CHEBYSHEV2,
  NB_TYPES, biquad, equalizer, bass,
  treble, bandpass, bandreject, allpass,
  highpass, lowpass, lowshelf, highshelf,
  tiltshelf, WEAK, STRONG, NB_FILTER,
  LOWPASS, FLAT, AFLAT, CHROMA,
  COLOR, ACOLOR, XFLAT, YFLAT,
  NB_FILTERS
}
 
enum  WidthType {
  NONE, HERTZ, OCTAVE, QFACTOR,
  SLOPE, KHERTZ, NB_WTYPE
}
 
enum  TransformType {
  PREDICTOR_TRANSFORM = 0, COLOR_TRANSFORM = 1, SUBTRACT_GREEN = 2, COLOR_INDEXING_TRANSFORM = 3,
  DI, DII, TDI, TDII,
  LATT, SVF, ZDF, NB_TTYPE
}
 

Functions

static int query_formats (AVFilterContext *ctx)
 
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 inputs []
 
static const AVFilterPad outputs []
 

Macro Definition Documentation

◆ BIQUAD_FILTER

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

Definition at line 205 of file af_biquads.c.

◆ BIQUAD_DII_FILTER

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

Definition at line 288 of file af_biquads.c.

◆ BIQUAD_TDI_FILTER

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

Definition at line 336 of file af_biquads.c.

◆ BIQUAD_TDII_FILTER

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

Definition at line 392 of file af_biquads.c.

◆ BIQUAD_LATT_FILTER

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

Definition at line 439 of file af_biquads.c.

◆ BIQUAD_SVF_FILTER

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

Definition at line 495 of file af_biquads.c.

◆ BIQUAD_ZDF_FILTER

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

Definition at line 543 of file af_biquads.c.

◆ OFFSET

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

Definition at line 1424 of file af_biquads.c.

◆ FLAGS

Definition at line 1425 of file af_biquads.c.

◆ AF

Definition at line 1426 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 AVFilter ff_af_##name_ = { \
.name = #name_, \
.description = NULL_IF_CONFIG_SMALL(description_), \
.priv_class = &priv_class_##_class, \
.priv_size = sizeof(BiquadsContext), \
.init = name_##_init, \
.uninit = uninit, \
FILTER_OUTPUTS(outputs), \
FILTER_QUERY_FUNC(query_formats), \
.process_command = process_command, \
}

Definition at line 1428 of file af_biquads.c.

◆ DEFINE_BIQUAD_FILTER

#define DEFINE_BIQUAD_FILTER (   name,
  description 
)
Value:
DEFINE_BIQUAD_FILTER_2(name, description, name)

Definition at line 1452 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}

Definition at line 1456 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, "width_type"}, \
{"t", "set filter-width type", OFFSET(width_type), AV_OPT_TYPE_INT, {.i64=x}, HERTZ, NB_WTYPE-1, FLAGS, "width_type"}, \
{"h", "Hz", 0, AV_OPT_TYPE_CONST, {.i64=HERTZ}, 0, 0, FLAGS, "width_type"}, \
{"q", "Q-Factor", 0, AV_OPT_TYPE_CONST, {.i64=QFACTOR}, 0, 0, FLAGS, "width_type"}, \
{"o", "octave", 0, AV_OPT_TYPE_CONST, {.i64=OCTAVE}, 0, 0, FLAGS, "width_type"}, \
{"s", "slope", 0, AV_OPT_TYPE_CONST, {.i64=SLOPE}, 0, 0, FLAGS, "width_type"}, \
{"k", "kHz", 0, AV_OPT_TYPE_CONST, {.i64=KHERTZ}, 0, 0, FLAGS, "width_type"}

Definition at line 1460 of file af_biquads.c.

◆ MIX_CHANNELS_NORMALIZE_OPTION

#define MIX_CHANNELS_NORMALIZE_OPTION (   x,
  y,
 
)
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}

Definition at line 1469 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, "transform_type"}, \
{"a", "set transform type", OFFSET(transform_type), AV_OPT_TYPE_INT, {.i64=x}, 0, NB_TTYPE-1, AF, "transform_type"}, \
{"di", "direct form I", 0, AV_OPT_TYPE_CONST, {.i64=DI}, 0, 0, AF, "transform_type"}, \
{"dii", "direct form II", 0, AV_OPT_TYPE_CONST, {.i64=DII}, 0, 0, AF, "transform_type"}, \
{"tdi", "transposed direct form I", 0, AV_OPT_TYPE_CONST, {.i64=TDI}, 0, 0, AF, "transform_type"}, \
{"tdii", "transposed direct form II", 0, AV_OPT_TYPE_CONST, {.i64=TDII}, 0, 0, AF, "transform_type"}, \
{"latt", "lattice-ladder form", 0, AV_OPT_TYPE_CONST, {.i64=LATT}, 0, 0, AF, "transform_type"}, \
{"svf", "state variable filter form", 0, AV_OPT_TYPE_CONST, {.i64=SVF}, 0, 0, AF, "transform_type"}, \
{"zdf", "zero-delay filter form", 0, AV_OPT_TYPE_CONST, {.i64=ZDF}, 0, 0, AF, "transform_type"}

Definition at line 1477 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, "precision"}, \
{"r", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=x}, -1, 3, AF, "precision"}, \
{"auto", "automatic", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, AF, "precision"}, \
{"s16", "signed 16-bit", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "precision"}, \
{"s32", "signed 32-bit", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "precision"}, \
{"f32", "floating-point single", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "precision"}, \
{"f64", "floating-point double", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, AF, "precision"}

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

Enumeration Type Documentation

◆ FilterType

enum FilterType
Enumerator
DC_TYPE 
AC_TYPE 
SQ_TYPE 
PS_TYPE 
NB_TYPES 
BUTTERWORTH 
CHEBYSHEV1 
CHEBYSHEV2 
NB_TYPES 
biquad 
equalizer 
bass 
treble 
bandpass 
bandreject 
allpass 
highpass 
lowpass 
lowshelf 
highshelf 
tiltshelf 
WEAK 
STRONG 
NB_FILTER 
LOWPASS 
FLAT 
AFLAT 
CHROMA 
COLOR 
ACOLOR 
XFLAT 
YFLAT 
NB_FILTERS 

Definition at line 76 of file af_biquads.c.

◆ WidthType

enum WidthType
Enumerator
NONE 
HERTZ 
OCTAVE 
QFACTOR 
SLOPE 
KHERTZ 
NB_WTYPE 

Definition at line 91 of file af_biquads.c.

◆ TransformType

Enumerator
PREDICTOR_TRANSFORM 
COLOR_TRANSFORM 
SUBTRACT_GREEN 
COLOR_INDEXING_TRANSFORM 
DI 
DII 
TDI 
TDII 
LATT 
SVF 
ZDF 
NB_TTYPE 

Definition at line 101 of file af_biquads.c.

Function Documentation

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 162 of file af_biquads.c.

◆ convert_dir2latt()

static void convert_dir2latt ( BiquadsContext s)
static

Definition at line 593 of file af_biquads.c.

Referenced by config_filter().

◆ convert_dir2svf()

static void convert_dir2svf ( BiquadsContext s)
static

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

Referenced by convert_dir2zdf().

◆ convert_dir2zdf()

static void convert_dir2zdf ( BiquadsContext s,
int  sample_rate 
)
static

Definition at line 663 of file af_biquads.c.

Referenced by config_filter().

◆ config_filter()

static int config_filter ( AVFilterLink outlink,
int  reset 
)
static

Definition at line 787 of file af_biquads.c.

Referenced by config_output(), and process_command().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 1162 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 1172 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 1207 of file af_biquads.c.

Referenced by filter_frame().

◆ filter_frame()

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

Definition at line 1271 of file af_biquads.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext ctx)
static

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

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 1399 of file af_biquads.c.

Variable Documentation

◆ inputs

const AVFilterPad inputs[]
static
Initial value:
= {
{
.name = "default",
},
}

Definition at line 1409 of file af_biquads.c.

◆ outputs

const AVFilterPad outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}

Definition at line 1416 of file af_biquads.c.

name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
mix
static int mix(int c0, int c1)
Definition: 4xm.c:717
DII
@ DII
Definition: af_biquads.c:103
BiquadsContext
Definition: af_biquads.c:120
NB_TTYPE
@ NB_TTYPE
Definition: af_biquads.c:109
SLOPE
@ SLOPE
Definition: af_biquads.c:96
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:175
init
static int init
Definition: av_tx.c:47
outputs
static const AVFilterPad outputs[]
Definition: af_biquads.c:1416
ZDF
@ ZDF
Definition: af_biquads.c:108
description
Tag description
Definition: snow.txt:206
activate
static int activate(AVFilterContext *ctx)
Definition: af_biquads.c:1340
av_cold
#define av_cold
Definition: attributes.h:90
width
#define width
s
#define s(width, name)
Definition: cbs_vp9.c:256
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:227
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
NB_WTYPE
@ NB_WTYPE
Definition: af_biquads.c:98
ctx
AVFormatContext * ctx
Definition: movenc.c:48
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: af_biquads.c:1386
KHERTZ
@ KHERTZ
Definition: af_biquads.c:97
AF
#define AF
Definition: af_biquads.c:1426
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_biquads.c:1162
LATT
@ LATT
Definition: af_biquads.c:106
inputs
static const AVFilterPad inputs[]
Definition: af_biquads.c:1409
AVFILTER_DEFINE_CLASS
#define AVFILTER_DEFINE_CLASS(fname)
Definition: internal.h:325
QFACTOR
@ QFACTOR
Definition: af_biquads.c:95
normalize
Definition: normalize.py:1
TDII
@ TDII
Definition: af_biquads.c:105
AVFilter
Filter definition.
Definition: avfilter.h:171
OFFSET
#define OFFSET(x)
Definition: af_biquads.c:1424
HERTZ
@ HERTZ
Definition: af_biquads.c:93
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: af_biquads.c:162
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_biquads.c:1399
AVFilterContext
An instance of a filter.
Definition: avfilter.h:408
FLAGS
#define FLAGS
Definition: af_biquads.c:1425
DI
@ DI
Definition: af_biquads.c:102
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:127
TDI
@ TDI
Definition: af_biquads.c:104
SVF
@ SVF
Definition: af_biquads.c:107
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
OCTAVE
@ OCTAVE
Definition: af_biquads.c:94
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#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:160
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234