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 "formats.h"
#include "internal.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)   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 outputs []
 

Macro Definition Documentation

◆ BIQUAD_FILTER

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

Definition at line 200 of file af_biquads.c.

◆ BIQUAD_DII_FILTER

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

Definition at line 282 of file af_biquads.c.

◆ BIQUAD_TDI_FILTER

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

Definition at line 331 of file af_biquads.c.

◆ BIQUAD_TDII_FILTER

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

Definition at line 388 of file af_biquads.c.

◆ BIQUAD_LATT_FILTER

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

Definition at line 436 of file af_biquads.c.

◆ BIQUAD_SVF_FILTER

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

Definition at line 495 of file af_biquads.c.

◆ BIQUAD_ZDF_FILTER

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

Definition at line 547 of file af_biquads.c.

◆ OFFSET

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

Definition at line 1443 of file af_biquads.c.

◆ FLAGS

Definition at line 1444 of file af_biquads.c.

◆ AF

Definition at line 1445 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 1447 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 1471 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 1475 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"}

Definition at line 1479 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 1488 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"}

Definition at line 1496 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 1507 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 1516 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 77 of file af_biquads.c.

◆ WidthType

enum WidthType
Enumerator
NONE 
HERTZ 
OCTAVE 
QFACTOR 
SLOPE 
KHERTZ 
NB_WTYPE 

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

Function Documentation

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 157 of file af_biquads.c.

◆ convert_dir2latt()

static void convert_dir2latt ( BiquadsContext s)
static

Definition at line 602 of file af_biquads.c.

Referenced by config_filter().

◆ convert_dir2svf()

static void convert_dir2svf ( BiquadsContext s)
static

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

Referenced by convert_dir2zdf().

◆ convert_dir2zdf()

static void convert_dir2zdf ( BiquadsContext s,
int  sample_rate 
)
static

Definition at line 672 of file af_biquads.c.

Referenced by config_filter().

◆ config_filter()

static int config_filter ( AVFilterLink outlink,
int  reset 
)
static

Definition at line 796 of file af_biquads.c.

Referenced by config_output(), and process_command().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 1193 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 1203 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 1238 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 1295 of file af_biquads.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext ctx)
static

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

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 1423 of file af_biquads.c.

Variable Documentation

◆ outputs

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

Definition at line 1435 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:715
DII
@ DII
Definition: af_biquads.c:104
BiquadsContext
Definition: af_biquads.c:113
NB_TTYPE
@ NB_TTYPE
Definition: af_biquads.c:110
SLOPE
@ SLOPE
Definition: af_biquads.c:97
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
outputs
static const AVFilterPad outputs[]
Definition: af_biquads.c:1435
ZDF
@ ZDF
Definition: af_biquads.c:109
description
Tag description
Definition: snow.txt:206
activate
static int activate(AVFilterContext *ctx)
Definition: af_biquads.c:1364
av_cold
#define av_cold
Definition: attributes.h:90
width
#define width
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:237
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
NB_WTYPE
@ NB_WTYPE
Definition: af_biquads.c:99
ctx
AVFormatContext * ctx
Definition: movenc.c:48
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
ff_audio_default_filterpad
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:33
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:1410
KHERTZ
@ KHERTZ
Definition: af_biquads.c:98
AF
#define AF
Definition: af_biquads.c:1445
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:365
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:106
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:1193
LATT
@ LATT
Definition: af_biquads.c:107
AVFILTER_DEFINE_CLASS
#define AVFILTER_DEFINE_CLASS(fname)
Definition: internal.h:323
QFACTOR
@ QFACTOR
Definition: af_biquads.c:96
normalize
Definition: normalize.py:1
TDII
@ TDII
Definition: af_biquads.c:106
AVFilter
Filter definition.
Definition: avfilter.h:166
OFFSET
#define OFFSET(x)
Definition: af_biquads.c:1443
HERTZ
@ HERTZ
Definition: af_biquads.c:94
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: af_biquads.c:157
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_biquads.c:1423
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
FLAGS
#define FLAGS
Definition: af_biquads.c:1444
DI
@ DI
Definition: af_biquads.c:103
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:117
TDI
@ TDI
Definition: af_biquads.c:105
SVF
@ SVF
Definition: af_biquads.c:108
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
OCTAVE
@ OCTAVE
Definition: af_biquads.c:95
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:155
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:239
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244