FFmpeg
Data Structures | Macros | Functions | Variables
asrc_sinc.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.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"

Go to the source code of this file.

Data Structures

struct  SincContext
 

Macros

#define SQR(a)   ((a) * (a))
 
#define AF   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define OFFSET(x)   offsetof(SincContext, x)
 

Functions

static int activate (AVFilterContext *ctx)
 
static int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
static floatmake_lpf (int num_taps, float Fc, float beta, float rho, float scale, int dc_norm)
 
static float kaiser_beta (float att, float tr_bw)
 
static void kaiser_params (float att, float Fc, float tr_bw, float *beta, int *num_taps)
 
static floatlpf (float Fn, float Fc, float tbw, int *num_taps, float att, float *beta, int round)
 
static void invert (float *h, int n)
 
static float safe_log (float x)
 
static int fir_to_phase (SincContext *s, float **h, int *len, int *post_len, float phase)
 
static int config_output (AVFilterLink *outlink)
 
static av_cold void uninit (AVFilterContext *ctx)
 
 AVFILTER_DEFINE_CLASS (sinc)
 

Variables

static const AVFilterPad sinc_outputs []
 
static const AVOption sinc_options []
 
const AVFilter ff_asrc_sinc
 

Macro Definition Documentation

◆ SQR

#define SQR (   a)    ((a) * (a))

Definition at line 194 of file asrc_sinc.c.

◆ AF

Definition at line 403 of file asrc_sinc.c.

◆ OFFSET

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

Definition at line 404 of file asrc_sinc.c.

Function Documentation

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 49 of file asrc_sinc.c.

◆ query_formats()

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

Definition at line 77 of file asrc_sinc.c.

◆ make_lpf()

static float* make_lpf ( int  num_taps,
float  Fc,
float  beta,
float  rho,
float  scale,
int  dc_norm 
)
static

Definition at line 97 of file asrc_sinc.c.

Referenced by lpf().

◆ kaiser_beta()

static float kaiser_beta ( float  att,
float  tr_bw 
)
static

Definition at line 125 of file asrc_sinc.c.

Referenced by build_filter(), kaiser_params(), and resample_init().

◆ kaiser_params()

static void kaiser_params ( float  att,
float  Fc,
float  tr_bw,
float beta,
int *  num_taps 
)
static

Definition at line 155 of file asrc_sinc.c.

Referenced by lpf().

◆ lpf()

static float* lpf ( float  Fn,
float  Fc,
float  tbw,
int *  num_taps,
float  att,
float beta,
int  round 
)
static

Definition at line 163 of file asrc_sinc.c.

Referenced by config_output(), and fluxlr().

◆ invert()

static void invert ( float h,
int  n 
)
static

◆ safe_log()

static float safe_log ( float  x)
static

Definition at line 196 of file asrc_sinc.c.

Referenced by fir_to_phase().

◆ fir_to_phase()

static int fir_to_phase ( SincContext s,
float **  h,
int *  len,
int *  post_len,
float  phase 
)
static

Definition at line 204 of file asrc_sinc.c.

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 326 of file asrc_sinc.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 386 of file asrc_sinc.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( sinc  )

Variable Documentation

◆ sinc_outputs

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

Definition at line 395 of file asrc_sinc.c.

◆ sinc_options

const AVOption sinc_options[]
static
Initial value:
= {
{ "sample_rate", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, INT_MAX, AF },
{ "r", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64=44100}, 1, INT_MAX, AF },
{ "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX, AF },
{ "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64=1024}, 1, INT_MAX, AF },
{ "hp", "set high-pass filter frequency", OFFSET(Fc0), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, INT_MAX, AF },
{ "lp", "set low-pass filter frequency", OFFSET(Fc1), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, INT_MAX, AF },
{ "phase", "set filter phase response", OFFSET(phase), AV_OPT_TYPE_FLOAT, {.dbl=50}, 0, 100, AF },
{ "beta", "set kaiser window beta", OFFSET(beta), AV_OPT_TYPE_FLOAT, {.dbl=-1}, -1, 256, AF },
{ "att", "set stop-band attenuation", OFFSET(att), AV_OPT_TYPE_FLOAT, {.dbl=120}, 40, 180, AF },
{ "round", "enable rounding", OFFSET(round), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, AF },
{ "hptaps", "set number of taps for high-pass filter", OFFSET(num_taps[0]), AV_OPT_TYPE_INT, {.i64=0}, 0, 32768, AF },
{ "lptaps", "set number of taps for low-pass filter", OFFSET(num_taps[1]), AV_OPT_TYPE_INT, {.i64=0}, 0, 32768, AF },
{ NULL }
}

Definition at line 406 of file asrc_sinc.c.

◆ ff_asrc_sinc

const AVFilter ff_asrc_sinc
Initial value:
= {
.name = "sinc",
.description = NULL_IF_CONFIG_SMALL("Generate a sinc kaiser-windowed low-pass, high-pass, band-pass, or band-reject FIR coefficients."),
.priv_size = sizeof(SincContext),
.priv_class = &sinc_class,
}

Definition at line 424 of file asrc_sinc.c.

SincContext
Definition: asrc_sinc.c:33
AF
#define AF
Definition: asrc_sinc.c:403
query_formats
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: asrc_sinc.c:77
OFFSET
#define OFFSET(x)
Definition: asrc_sinc.c:404
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
sinc_outputs
static const AVFilterPad sinc_outputs[]
Definition: asrc_sinc.c:395
activate
static int activate(AVFilterContext *ctx)
Definition: asrc_sinc.c:49
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: asrc_sinc.c:386
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
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition: opt.h:271
round
static av_always_inline av_const double round(double x)
Definition: libm.h:444
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:239
config_output
static int config_output(AVFilterLink *outlink)
Definition: asrc_sinc.c:326
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327