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

◆ PACK

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

Definition at line 209 of file asrc_sinc.c.

◆ UNPACK

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

Definition at line 210 of file asrc_sinc.c.

◆ SQR

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

Definition at line 211 of file asrc_sinc.c.

◆ AF

Definition at line 425 of file asrc_sinc.c.

◆ OFFSET

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

Definition at line 426 of file asrc_sinc.c.

Function Documentation

◆ request_frame()

static int request_frame ( AVFilterLink outlink)
static

Definition at line 46 of file asrc_sinc.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 69 of file asrc_sinc.c.

◆ bessel_I_0()

static float bessel_I_0 ( float  x)
static

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

Referenced by lpf().

◆ kaiser_beta()

static float kaiser_beta ( float  att,
float  tr_bw 
)
static

Definition at line 140 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 170 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 178 of file asrc_sinc.c.

Referenced by config_output().

◆ invert()

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().

◆ safe_log()

static float safe_log ( float  x)
static

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

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 344 of file asrc_sinc.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 405 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,
.request_frame = request_frame,
},
{ NULL }
}

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

◆ ff_asrc_sinc

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 446 of file asrc_sinc.c.

SincContext
Definition: asrc_sinc.c:31
AF
#define AF
Definition: asrc_sinc.c:425
sample_rate
sample_rate
Definition: ffmpeg_filter.c:191
OFFSET
#define OFFSET(x)
Definition: asrc_sinc.c:426
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
NULL
#define NULL
Definition: coverity.c:32
sinc_outputs
static const AVFilterPad sinc_outputs[]
Definition: asrc_sinc.c:415
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: asrc_sinc.c:405
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
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: asrc_sinc.c:46
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:188
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:226
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:344
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:240
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: asrc_sinc.c:69