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 "libavutil/tx.h"
#include "audio.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "internal.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 (AVFilterContext *ctx)
 
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 192 of file asrc_sinc.c.

◆ AF

Definition at line 401 of file asrc_sinc.c.

◆ OFFSET

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

Definition at line 402 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 ( AVFilterContext ctx)
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 95 of file asrc_sinc.c.

Referenced by lpf().

◆ kaiser_beta()

static float kaiser_beta ( float  att,
float  tr_bw 
)
static

Definition at line 123 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 153 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 161 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 194 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 202 of file asrc_sinc.c.

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 324 of file asrc_sinc.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 384 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 393 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 404 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 422 of file asrc_sinc.c.

SincContext
Definition: asrc_sinc.c:33
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:159
AF
#define AF
Definition: asrc_sinc.c:401
sample_rate
sample_rate
Definition: ffmpeg_filter.c:409
OFFSET
#define OFFSET(x)
Definition: asrc_sinc.c:402
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:393
activate
static int activate(AVFilterContext *ctx)
Definition: asrc_sinc.c:49
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: asrc_sinc.c:384
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:106
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:238
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:324
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: asrc_sinc.c:77