FFmpeg
Data Structures | Macros | Functions | Variables
asrc_sinc.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/opt.h"
#include "libavcodec/avfft.h"
#include "audio.h"
#include "avfilter.h"
#include "filters.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  SincContext
 

Macros

#define PACK(h, n)   h[1] = h[n]
 
#define UNPACK(h, n)   h[n] = h[1], h[n + 1] = h[1] = 0;
 
#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 (AVFilterContext *ctx)
 
static float bessel_I_0 (float x)
 
static float * make_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 float * lpf (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

◆ PACK

#define PACK (   h,
 
)    h[1] = h[n]

Definition at line 203 of file asrc_sinc.c.

◆ UNPACK

#define UNPACK (   h,
 
)    h[n] = h[1], h[n + 1] = h[1] = 0;

Definition at line 204 of file asrc_sinc.c.

◆ SQR

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

Definition at line 205 of file asrc_sinc.c.

◆ AF

Definition at line 418 of file asrc_sinc.c.

◆ OFFSET

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

Definition at line 419 of file asrc_sinc.c.

Function Documentation

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 48 of file asrc_sinc.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 76 of file asrc_sinc.c.

◆ bessel_I_0()

static float bessel_I_0 ( float  x)
static

Definition at line 94 of file asrc_sinc.c.

Referenced by make_lpf().

◆ make_lpf()

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

Definition at line 109 of file asrc_sinc.c.

Referenced by lpf().

◆ kaiser_beta()

static float kaiser_beta ( float  att,
float  tr_bw 
)
static

Definition at line 134 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 164 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 172 of file asrc_sinc.c.

Referenced by config_output().

◆ invert()

static void invert ( float *  h,
int  n 
)
static

◆ safe_log()

static float safe_log ( float  x)
static

Definition at line 207 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 215 of file asrc_sinc.c.

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 339 of file asrc_sinc.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 400 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 410 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 421 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 439 of file asrc_sinc.c.

SincContext
Definition: asrc_sinc.c:33
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:168
AF
#define AF
Definition: asrc_sinc.c:418
sample_rate
sample_rate
Definition: ffmpeg_filter.c:153
OFFSET
#define OFFSET(x)
Definition: asrc_sinc.c:419
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
NULL
#define NULL
Definition: coverity.c:32
sinc_outputs
static const AVFilterPad sinc_outputs[]
Definition: asrc_sinc.c:410
activate
static int activate(AVFilterContext *ctx)
Definition: asrc_sinc.c:48
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: asrc_sinc.c:400
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:117
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:227
round
static av_always_inline av_const double round(double x)
Definition: libm.h:444
config_output
static int config_output(AVFilterLink *outlink)
Definition: asrc_sinc.c:339
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:241
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: asrc_sinc.c:76