FFmpeg
Data Structures | Macros | Functions | Variables
asrc_afirsrc.c File Reference
#include "libavutil/cpu.h"
#include "libavutil/channel_layout.h"
#include "libavutil/ffmath.h"
#include "libavutil/eval.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/tx.h"
#include "audio.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "window_func.h"

Go to the source code of this file.

Data Structures

struct  AudioFIRSourceContext
 
struct  EqPreset
 

Macros

#define OFFSET(x)   offsetof(AudioFIRSourceContext, x)
 
#define FLAGS   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define DEFAULT_BANDS   "25 40 63 100 160 250 400 630 1000 1600 2500 4000 6300 10000 16000 24000"
 

Functions

 AVFILTER_DEFINE_CLASS (afirsrc)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static av_cold int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
static int parse_string (char *str, float **items, int *nb_items, int *items_size)
 
static void lininterp (AVComplexFloat *complexf, const float *freq, const float *magnitude, const float *phase, int m, int minterp)
 
static av_cold int config_output (AVFilterLink *outlink)
 
static int activate (AVFilterContext *ctx)
 
 AVFILTER_DEFINE_CLASS (afireqsrc)
 
static void eq_interp (AVComplexFloat *complexf, const float *freq, const float *magnitude, int m, int interp, int minterp, const float factor)
 
static av_cold int config_eq_output (AVFilterLink *outlink)
 

Variables

static const AVOption afirsrc_options []
 
static const AVFilterPad afirsrc_outputs []
 
const AVFilter ff_asrc_afirsrc
 
static const EqPreset eq_presets []
 
static const AVOption afireqsrc_options []
 
static const AVFilterPad afireqsrc_outputs []
 
const AVFilter ff_asrc_afireqsrc
 

Macro Definition Documentation

◆ OFFSET

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

Definition at line 67 of file asrc_afirsrc.c.

◆ FLAGS

Definition at line 68 of file asrc_afirsrc.c.

◆ DEFAULT_BANDS

#define DEFAULT_BANDS   "25 40 63 100 160 250 400 630 1000 1600 2500 4000 6300 10000 16000 24000"

Definition at line 313 of file asrc_afirsrc.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS() [1/2]

AVFILTER_DEFINE_CLASS ( afirsrc  )

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 90 of file asrc_afirsrc.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 102 of file asrc_afirsrc.c.

◆ query_formats()

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

Definition at line 116 of file asrc_afirsrc.c.

◆ parse_string()

static int parse_string ( char *  str,
float **  items,
int *  nb_items,
int *  items_size 
)
static

Definition at line 138 of file asrc_afirsrc.c.

Referenced by config_eq_output(), and config_output().

◆ lininterp()

static void lininterp ( AVComplexFloat complexf,
const float freq,
const float magnitude,
const float phase,
int  m,
int  minterp 
)
static

Definition at line 165 of file asrc_afirsrc.c.

Referenced by config_output().

◆ config_output()

static av_cold int config_output ( AVFilterLink outlink)
static

Definition at line 187 of file asrc_afirsrc.c.

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 266 of file asrc_afirsrc.c.

◆ AVFILTER_DEFINE_CLASS() [2/2]

AVFILTER_DEFINE_CLASS ( afireqsrc  )

◆ eq_interp()

static void eq_interp ( AVComplexFloat complexf,
const float freq,
const float magnitude,
int  m,
int  interp,
int  minterp,
const float  factor 
)
static

Definition at line 386 of file asrc_afirsrc.c.

Referenced by config_eq_output().

◆ config_eq_output()

static av_cold int config_eq_output ( AVFilterLink outlink)
static

Definition at line 455 of file asrc_afirsrc.c.

Variable Documentation

◆ afirsrc_options

const AVOption afirsrc_options[]
static
Initial value:
= {
{ "taps", "set number of taps", OFFSET(nb_taps), AV_OPT_TYPE_INT, {.i64=1025}, 9, UINT16_MAX, FLAGS },
{ "t", "set number of taps", OFFSET(nb_taps), AV_OPT_TYPE_INT, {.i64=1025}, 9, UINT16_MAX, FLAGS },
{ "frequency", "set frequency points", OFFSET(freq_points_str), AV_OPT_TYPE_STRING, {.str="0 1"}, 0, 0, FLAGS },
{ "f", "set frequency points", OFFSET(freq_points_str), AV_OPT_TYPE_STRING, {.str="0 1"}, 0, 0, FLAGS },
{ "magnitude", "set magnitude values", OFFSET(magnitude_str), AV_OPT_TYPE_STRING, {.str="1 1"}, 0, 0, FLAGS },
{ "m", "set magnitude values", OFFSET(magnitude_str), AV_OPT_TYPE_STRING, {.str="1 1"}, 0, 0, FLAGS },
{ "phase", "set phase values", OFFSET(phase_str), AV_OPT_TYPE_STRING, {.str="0 0"}, 0, 0, FLAGS },
{ "p", "set phase values", OFFSET(phase_str), AV_OPT_TYPE_STRING, {.str="0 0"}, 0, 0, FLAGS },
{ "sample_rate", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, INT_MAX, FLAGS },
{ "r", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, INT_MAX, FLAGS },
{ "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 1024}, 1, INT_MAX, FLAGS },
{ "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 1024}, 1, INT_MAX, FLAGS },
WIN_FUNC_OPTION("win_func", OFFSET(win_func), FLAGS, WFUNC_BLACKMAN),
{NULL}
}

Definition at line 70 of file asrc_afirsrc.c.

◆ afirsrc_outputs

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

Definition at line 292 of file asrc_afirsrc.c.

◆ ff_asrc_afirsrc

const AVFilter ff_asrc_afirsrc
Initial value:
= {
.name = "afirsrc",
.description = NULL_IF_CONFIG_SMALL("Generate a FIR coefficients audio stream."),
.init = init,
.uninit = uninit,
.activate = activate,
.priv_size = sizeof(AudioFIRSourceContext),
.priv_class = &afirsrc_class,
}

Definition at line 300 of file asrc_afirsrc.c.

◆ eq_presets

const EqPreset eq_presets[]
static
Initial value:
= {
{ "flat", { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{ "acoustic", { 5.0, 4.5, 4.0, 3.5, 1.5, 1.0, 1.5, 1.5, 2.0, 3.0, 3.5, 4.0, 3.7, 3.0, 3.0 } },
{ "bass", { 10.0, 8.8, 8.5, 6.5, 2.5, 1.5, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
{ "beats", { -5.5, -5.0, -4.5, -4.2, -3.5, -3.0, -1.9, 0, 0, 0, 0, 0, 0, 0, 0 } },
{ "classic", { -0.3, 0.3, -3.5, -9.0, -1.0, 0.0, 1.8, 2.1, 0.0, 0.0, 0.0, 4.4, 9.0, 9.0, 9.0 } },
{ "clear", { 3.5, 5.5, 6.5, 9.5, 8.0, 6.5, 3.5, 2.5, 1.3, 5.0, 7.0, 9.0, 10.0, 11.0, 9.0 } },
{ "deep bass", { 12.0, 8.0, 0.0, -6.7, -12.0, -9.0, -3.5, -3.5, -6.1, 0.0, -3.0, -5.0, 0.0, 1.2, 3.0 } },
{ "dubstep", { 12.0, 10.0, 0.5, -1.0, -3.0, -5.0, -5.0, -4.8, -4.5, -2.5, -1.0, 0.0, -2.5, -2.5, 0.0 } },
{ "electronic", { 4.0, 4.0, 3.5, 1.0, 0.0, -0.5, -2.0, 0.0, 2.0, 0.0, 0.0, 1.0, 3.0, 4.0, 4.5 } },
{ "hardstyle", { 6.1, 7.0, 12.0, 6.1, -5.0, -12.0, -2.5, 3.0, 6.5, 0.0, -2.2, -4.5, -6.1, -9.2, -10.0 } },
{ "hip-hop", { 4.5, 4.3, 4.0, 2.5, 1.5, 3.0, -1.0, -1.5, -1.5, 1.5, 0.0, -1.0, 0.0, 1.5, 3.0 } },
{ "jazz", { 0.0, 0.0, 0.0, 2.0, 4.0, 5.9, -5.9, -4.5, -2.5, 2.5, 1.0, -0.8, -0.8, -0.8, -0.8 } },
{ "metal", { 10.5, 10.5, 7.5, 0.0, 2.0, 5.5, 0.0, 0.0, 0.0, 6.1, 0.0, 0.0, 6.1, 10.0, 12.0 } },
{ "movie", { 3.0, 3.0, 6.1, 8.5, 9.0, 7.0, 6.1, 6.1, 5.0, 8.0, 3.5, 3.5, 8.0, 10.0, 8.0 } },
{ "pop", { 0.0, 0.0, 0.0, 0.0, 0.0, 1.3, 2.0, 2.5, 5.0, -1.5, -2.0, -3.0, -3.0, -3.0, -3.0 } },
{ "r&b", { 3.0, 3.0, 7.0, 6.1, 4.5, 1.5, -1.5, -2.0, -1.5, 2.0, 2.5, 3.0, 3.5, 3.8, 4.0 } },
{ "rock", { 0.0, 0.0, 0.0, 3.0, 3.0, -10.0, -4.0, -1.0, 0.8, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 } },
{ "vocal booster", { -1.5, -2.0, -3.0, -3.0, -0.5, 1.5, 3.5, 3.5, 3.5, 3.0, 2.0, 1.5, 0.0, 0.0, -1.5 } },
}

Definition at line 320 of file asrc_afirsrc.c.

Referenced by config_eq_output().

◆ afireqsrc_options

const AVOption afireqsrc_options[]
static

Definition at line 341 of file asrc_afirsrc.c.

◆ afireqsrc_outputs

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

Definition at line 574 of file asrc_afirsrc.c.

◆ ff_asrc_afireqsrc

const AVFilter ff_asrc_afireqsrc
Initial value:
= {
.name = "afireqsrc",
.description = NULL_IF_CONFIG_SMALL("Generate a FIR equalizer coefficients audio stream."),
.uninit = uninit,
.activate = activate,
.priv_size = sizeof(AudioFIRSourceContext),
.priv_class = &afireqsrc_class,
}

Definition at line 582 of file asrc_afirsrc.c.

AudioFIRSourceContext
Definition: asrc_afirsrc.c:34
activate
static int activate(AVFilterContext *ctx)
Definition: asrc_afirsrc.c:266
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: asrc_afirsrc.c:102
WIN_FUNC_OPTION
#define WIN_FUNC_OPTION(win_func_opt_name, win_func_offset, flag, default_window_func)
Definition: window_func.h:37
WFUNC_BLACKMAN
@ WFUNC_BLACKMAN
Definition: af_firequalizer.c:39
OFFSET
#define OFFSET(x)
Definition: asrc_afirsrc.c:67
config_eq_output
static av_cold int config_eq_output(AVFilterLink *outlink)
Definition: asrc_afirsrc.c:455
afireqsrc_outputs
static const AVFilterPad afireqsrc_outputs[]
Definition: asrc_afirsrc.c:574
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
NULL
#define NULL
Definition: coverity.c:32
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
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:94
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:239
query_formats
static av_cold int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: asrc_afirsrc.c:116
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
FLAGS
#define FLAGS
Definition: asrc_afirsrc.c:68
init
static av_cold int init(AVFilterContext *ctx)
Definition: asrc_afirsrc.c:90
AV_OPT_TYPE_STRING
@ 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:276
afirsrc_outputs
static const AVFilterPad afirsrc_outputs[]
Definition: asrc_afirsrc.c:292
config_output
static av_cold int config_output(AVFilterLink *outlink)
Definition: asrc_afirsrc.c:187