FFmpeg
Data Structures | Macros | Functions | Variables
af_aspectralstats.c File Reference
#include <float.h>
#include <math.h>
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/tx.h"
#include "audio.h"
#include "avfilter.h"
#include "filters.h"
#include "window_func.h"

Go to the source code of this file.

Data Structures

struct  ChannelSpectralStats
 
struct  AudioSpectralStatsContext
 

Macros

#define MEASURE_ALL   UINT_MAX
 
#define MEASURE_NONE   0
 
#define MEASURE_MEAN   (1 << 0)
 
#define MEASURE_VARIANCE   (1 << 1)
 
#define MEASURE_CENTROID   (1 << 2)
 
#define MEASURE_SPREAD   (1 << 3)
 
#define MEASURE_SKEWNESS   (1 << 4)
 
#define MEASURE_KURTOSIS   (1 << 5)
 
#define MEASURE_ENTROPY   (1 << 6)
 
#define MEASURE_FLATNESS   (1 << 7)
 
#define MEASURE_CREST   (1 << 8)
 
#define MEASURE_FLUX   (1 << 9)
 
#define MEASURE_SLOPE   (1 << 10)
 
#define MEASURE_DECREASE   (1 << 11)
 
#define MEASURE_ROLLOFF   (1 << 12)
 
#define OFFSET(x)   offsetof(AudioSpectralStatsContext, x)
 
#define A   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 

Functions

 AVFILTER_DEFINE_CLASS (aspectralstats)
 
static int config_output (AVFilterLink *outlink)
 
static void set_meta (AVDictionary **metadata, int chan, const char *key, const char *fmt, float val)
 
static void set_metadata (AudioSpectralStatsContext *s, AVDictionary **metadata)
 
static float spectral_mean (const float *const spectral, int size, int max_freq)
 
static float sqrf (float a)
 
static float spectral_variance (const float *const spectral, int size, int max_freq, float mean)
 
static float spectral_centroid (const float *const spectral, int size, int max_freq)
 
static float spectral_spread (const float *const spectral, int size, int max_freq, float centroid)
 
static float cbrf (float a)
 
static float spectral_skewness (const float *const spectral, int size, int max_freq, float centroid, float spread)
 
static float spectral_kurtosis (const float *const spectral, int size, int max_freq, float centroid, float spread)
 
static float spectral_entropy (const float *const spectral, int size, int max_freq)
 
static float spectral_flatness (const float *const spectral, int size, int max_freq)
 
static float spectral_crest (const float *const spectral, int size, int max_freq)
 
static float spectral_flux (const float *const spectral, const float *const prev_spectral, int size, int max_freq)
 
static float spectral_slope (const float *const spectral, int size, int max_freq)
 
static float spectral_decrease (const float *const spectral, int size, int max_freq)
 
static float spectral_rolloff (const float *const spectral, int size, int max_freq)
 
static int filter_channel (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static int activate (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption aspectralstats_options []
 
static const AVFilterPad aspectralstats_outputs []
 
const AVFilter ff_af_aspectralstats
 

Macro Definition Documentation

◆ MEASURE_ALL

#define MEASURE_ALL   UINT_MAX

Definition at line 32 of file af_aspectralstats.c.

◆ MEASURE_NONE

#define MEASURE_NONE   0

Definition at line 33 of file af_aspectralstats.c.

◆ MEASURE_MEAN

#define MEASURE_MEAN   (1 << 0)

Definition at line 34 of file af_aspectralstats.c.

◆ MEASURE_VARIANCE

#define MEASURE_VARIANCE   (1 << 1)

Definition at line 35 of file af_aspectralstats.c.

◆ MEASURE_CENTROID

#define MEASURE_CENTROID   (1 << 2)

Definition at line 36 of file af_aspectralstats.c.

◆ MEASURE_SPREAD

#define MEASURE_SPREAD   (1 << 3)

Definition at line 37 of file af_aspectralstats.c.

◆ MEASURE_SKEWNESS

#define MEASURE_SKEWNESS   (1 << 4)

Definition at line 38 of file af_aspectralstats.c.

◆ MEASURE_KURTOSIS

#define MEASURE_KURTOSIS   (1 << 5)

Definition at line 39 of file af_aspectralstats.c.

◆ MEASURE_ENTROPY

#define MEASURE_ENTROPY   (1 << 6)

Definition at line 40 of file af_aspectralstats.c.

◆ MEASURE_FLATNESS

#define MEASURE_FLATNESS   (1 << 7)

Definition at line 41 of file af_aspectralstats.c.

◆ MEASURE_CREST

#define MEASURE_CREST   (1 << 8)

Definition at line 42 of file af_aspectralstats.c.

◆ MEASURE_FLUX

#define MEASURE_FLUX   (1 << 9)

Definition at line 43 of file af_aspectralstats.c.

◆ MEASURE_SLOPE

#define MEASURE_SLOPE   (1 << 10)

Definition at line 44 of file af_aspectralstats.c.

◆ MEASURE_DECREASE

#define MEASURE_DECREASE   (1 << 11)

Definition at line 45 of file af_aspectralstats.c.

◆ MEASURE_ROLLOFF

#define MEASURE_ROLLOFF   (1 << 12)

Definition at line 46 of file af_aspectralstats.c.

◆ OFFSET

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

Definition at line 83 of file af_aspectralstats.c.

◆ A

Definition at line 84 of file af_aspectralstats.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( aspectralstats  )

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 111 of file af_aspectralstats.c.

◆ set_meta()

static void set_meta ( AVDictionary **  metadata,
int  chan,
const char *  key,
const char *  fmt,
float  val 
)
static

Definition at line 183 of file af_aspectralstats.c.

Referenced by do_vif(), and set_metadata().

◆ set_metadata()

static void set_metadata ( AudioSpectralStatsContext s,
AVDictionary **  metadata 
)
static

Definition at line 197 of file af_aspectralstats.c.

Referenced by filter_frame().

◆ spectral_mean()

static float spectral_mean ( const float *const  spectral,
int  size,
int  max_freq 
)
static

Definition at line 231 of file af_aspectralstats.c.

Referenced by filter_channel().

◆ sqrf()

static float sqrf ( float  a)
static

◆ spectral_variance()

static float spectral_variance ( const float *const  spectral,
int  size,
int  max_freq,
float  mean 
)
static

Definition at line 246 of file af_aspectralstats.c.

Referenced by filter_channel().

◆ spectral_centroid()

static float spectral_centroid ( const float *const  spectral,
int  size,
int  max_freq 
)
static

Definition at line 256 of file af_aspectralstats.c.

Referenced by filter_channel().

◆ spectral_spread()

static float spectral_spread ( const float *const  spectral,
int  size,
int  max_freq,
float  centroid 
)
static

Definition at line 271 of file af_aspectralstats.c.

Referenced by filter_channel().

◆ cbrf()

static float cbrf ( float  a)
static

Definition at line 286 of file af_aspectralstats.c.

Referenced by spectral_skewness().

◆ spectral_skewness()

static float spectral_skewness ( const float *const  spectral,
int  size,
int  max_freq,
float  centroid,
float  spread 
)
static

Definition at line 291 of file af_aspectralstats.c.

Referenced by filter_channel().

◆ spectral_kurtosis()

static float spectral_kurtosis ( const float *const  spectral,
int  size,
int  max_freq,
float  centroid,
float  spread 
)
static

Definition at line 307 of file af_aspectralstats.c.

Referenced by filter_channel().

◆ spectral_entropy()

static float spectral_entropy ( const float *const  spectral,
int  size,
int  max_freq 
)
static

Definition at line 323 of file af_aspectralstats.c.

Referenced by filter_channel().

◆ spectral_flatness()

static float spectral_flatness ( const float *const  spectral,
int  size,
int  max_freq 
)
static

Definition at line 337 of file af_aspectralstats.c.

Referenced by filter_channel().

◆ spectral_crest()

static float spectral_crest ( const float *const  spectral,
int  size,
int  max_freq 
)
static

Definition at line 355 of file af_aspectralstats.c.

Referenced by filter_channel().

◆ spectral_flux()

static float spectral_flux ( const float *const  spectral,
const float *const  prev_spectral,
int  size,
int  max_freq 
)
static

Definition at line 370 of file af_aspectralstats.c.

Referenced by filter_channel().

◆ spectral_slope()

static float spectral_slope ( const float *const  spectral,
int  size,
int  max_freq 
)
static

Definition at line 381 of file af_aspectralstats.c.

Referenced by filter_channel().

◆ spectral_decrease()

static float spectral_decrease ( const float *const  spectral,
int  size,
int  max_freq 
)
static

Definition at line 400 of file af_aspectralstats.c.

Referenced by filter_channel().

◆ spectral_rolloff()

static float spectral_rolloff ( const float *const  spectral,
int  size,
int  max_freq 
)
static

Definition at line 414 of file af_aspectralstats.c.

Referenced by filter_channel().

◆ filter_channel()

static int filter_channel ( AVFilterContext ctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 435 of file af_aspectralstats.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 506 of file af_aspectralstats.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 546 of file af_aspectralstats.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 575 of file af_aspectralstats.c.

Variable Documentation

◆ aspectralstats_options

const AVOption aspectralstats_options[]
static
Initial value:
= {
{ "win_size", "set the window size", OFFSET(win_size), AV_OPT_TYPE_INT, {.i64=2048}, 32, 65536, A },
WIN_FUNC_OPTION("win_func", OFFSET(win_func), A, WFUNC_HANNING),
{ "overlap", "set window overlap", OFFSET(overlap), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, A },
{ "measure", "select the parameters which are measured", OFFSET(measure), AV_OPT_TYPE_FLAGS, {.i64=MEASURE_ALL}, 0, UINT_MAX, A, .unit = "measure" },
{ "none", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_NONE }, 0, 0, A, .unit = "measure" },
{ "all", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_ALL }, 0, 0, A, .unit = "measure" },
{ "mean", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_MEAN }, 0, 0, A, .unit = "measure" },
{ "variance", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_VARIANCE}, 0, 0, A, .unit = "measure" },
{ "centroid", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_CENTROID}, 0, 0, A, .unit = "measure" },
{ "spread", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_SPREAD }, 0, 0, A, .unit = "measure" },
{ "skewness", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_SKEWNESS}, 0, 0, A, .unit = "measure" },
{ "kurtosis", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_KURTOSIS}, 0, 0, A, .unit = "measure" },
{ "entropy", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_ENTROPY }, 0, 0, A, .unit = "measure" },
{ "flatness", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_FLATNESS}, 0, 0, A, .unit = "measure" },
{ "crest", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_CREST }, 0, 0, A, .unit = "measure" },
{ "flux", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_FLUX }, 0, 0, A, .unit = "measure" },
{ "slope", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_SLOPE }, 0, 0, A, .unit = "measure" },
{ "decrease", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_DECREASE}, 0, 0, A, .unit = "measure" },
{ "rolloff", "", 0, AV_OPT_TYPE_CONST, {.i64=MEASURE_ROLLOFF }, 0, 0, A, .unit = "measure" },
{ NULL }
}

Definition at line 86 of file af_aspectralstats.c.

◆ aspectralstats_outputs

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

Definition at line 603 of file af_aspectralstats.c.

◆ ff_af_aspectralstats

const AVFilter ff_af_aspectralstats
Initial value:
= {
.name = "aspectralstats",
.description = NULL_IF_CONFIG_SMALL("Show frequency domain statistics about audio frames."),
.priv_size = sizeof(AudioSpectralStatsContext),
.priv_class = &aspectralstats_class,
}

Definition at line 611 of file af_aspectralstats.c.

AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
MEASURE_KURTOSIS
#define MEASURE_KURTOSIS
Definition: af_aspectralstats.c:39
MEASURE_ALL
#define MEASURE_ALL
Definition: af_aspectralstats.c:32
MEASURE_ENTROPY
#define MEASURE_ENTROPY
Definition: af_aspectralstats.c:40
AudioSpectralStatsContext
Definition: af_aspectralstats.c:64
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
MEASURE_FLUX
#define MEASURE_FLUX
Definition: af_aspectralstats.c:43
WIN_FUNC_OPTION
#define WIN_FUNC_OPTION(win_func_opt_name, win_func_offset, flag, default_window_func)
Definition: window_func.h:37
aspectralstats_outputs
static const AVFilterPad aspectralstats_outputs[]
Definition: af_aspectralstats.c:603
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
MEASURE_CREST
#define MEASURE_CREST
Definition: af_aspectralstats.c:42
MEASURE_SLOPE
#define MEASURE_SLOPE
Definition: af_aspectralstats.c:44
MEASURE_DECREASE
#define MEASURE_DECREASE
Definition: af_aspectralstats.c:45
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
NULL
#define NULL
Definition: coverity.c:32
ff_audio_default_filterpad
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
Definition: audio.c:34
WFUNC_HANNING
@ WFUNC_HANNING
Definition: window_func.h:29
FILTER_SINGLE_SAMPLEFMT
#define FILTER_SINGLE_SAMPLEFMT(sample_fmt_)
Definition: filters.h:255
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
MEASURE_VARIANCE
#define MEASURE_VARIANCE
Definition: af_aspectralstats.c:35
activate
static int activate(AVFilterContext *ctx)
Definition: af_aspectralstats.c:546
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_aspectralstats.c:575
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition: opt.h:271
MEASURE_FLATNESS
#define MEASURE_FLATNESS
Definition: af_aspectralstats.c:41
MEASURE_SKEWNESS
#define MEASURE_SKEWNESS
Definition: af_aspectralstats.c:38
MEASURE_ROLLOFF
#define MEASURE_ROLLOFF
Definition: af_aspectralstats.c:46
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_aspectralstats.c:111
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:152
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
Definition: opt.h:255
A
#define A
Definition: af_aspectralstats.c:84
MEASURE_NONE
#define MEASURE_NONE
Definition: af_aspectralstats.c:33
MEASURE_CENTROID
#define MEASURE_CENTROID
Definition: af_aspectralstats.c:36
MEASURE_MEAN
#define MEASURE_MEAN
Definition: af_aspectralstats.c:34
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
MEASURE_SPREAD
#define MEASURE_SPREAD
Definition: af_aspectralstats.c:37
OFFSET
#define OFFSET(x)
Definition: af_aspectralstats.c:83