FFmpeg
Data Structures | Macros | Functions | Variables
asrc_sinc.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/opt.h"
#include "libavcodec/avfft.h"
#include "audio.h"
#include "avfilter.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 request_frame (AVFilterLink *outlink)
 
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 []
 
AVFilter ff_asrc_sinc
 

Macro Definition Documentation

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

Definition at line 209 of file asrc_sinc.c.

Referenced by fir_to_phase().

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

Definition at line 210 of file asrc_sinc.c.

Referenced by fir_to_phase().

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

Definition at line 211 of file asrc_sinc.c.

Referenced by fir_to_phase().

Definition at line 428 of file asrc_sinc.c.

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

Definition at line 429 of file asrc_sinc.c.

Function Documentation

static int request_frame ( AVFilterLink outlink)
static

Definition at line 46 of file asrc_sinc.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 69 of file asrc_sinc.c.

static float bessel_I_0 ( float  x)
static

Definition at line 100 of file asrc_sinc.c.

Referenced by make_lpf().

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

Definition at line 115 of file asrc_sinc.c.

Referenced by lpf().

static float kaiser_beta ( float  att,
float  tr_bw 
)
static

Definition at line 140 of file asrc_sinc.c.

Referenced by kaiser_params(), and resample_init().

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

Definition at line 170 of file asrc_sinc.c.

Referenced by lpf().

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

Definition at line 178 of file asrc_sinc.c.

Referenced by config_output().

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

Definition at line 201 of file asrc_sinc.c.

Referenced by bitplane_decoding(), config_output(), and ff_vfscanf().

static float safe_log ( float  x)
static

Definition at line 213 of file asrc_sinc.c.

Referenced by fir_to_phase().

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

Definition at line 221 of file asrc_sinc.c.

Referenced by config_output().

static int config_output ( AVFilterLink outlink)
static

Definition at line 347 of file asrc_sinc.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 408 of file asrc_sinc.c.

AVFILTER_DEFINE_CLASS ( sinc  )

Variable Documentation

const AVFilterPad sinc_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
.request_frame = request_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_output(AVFilterLink *outlink)
Definition: asrc_sinc.c:347
static int request_frame(AVFilterLink *outlink)
Definition: asrc_sinc.c:46

Definition at line 418 of file asrc_sinc.c.

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 }
}
#define NULL
Definition: coverity.c:32
#define AF
Definition: asrc_sinc.c:428
static av_always_inline av_const double round(double x)
Definition: libm.h:444
sample_rate
#define OFFSET(x)
Definition: asrc_sinc.c:429

Definition at line 431 of file asrc_sinc.c.

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,
}
static int query_formats(AVFilterContext *ctx)
Definition: asrc_sinc.c:69
#define NULL
Definition: coverity.c:32
static av_cold void uninit(AVFilterContext *ctx)
Definition: asrc_sinc.c:408
static const AVFilterPad sinc_outputs[]
Definition: asrc_sinc.c:418
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
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 at line 449 of file asrc_sinc.c.