FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
af_loudnorm.c File Reference
#include "libavutil/opt.h"
#include "avfilter.h"
#include "internal.h"
#include "audio.h"
#include "ebur128.h"

Go to the source code of this file.

Data Structures

struct  LoudNormContext
 

Macros

#define OFFSET(x)   offsetof(LoudNormContext, x)
 
#define FLAGS   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 

Enumerations

enum  FrameType {
  ACTIVE_FRAME, SID_FRAME, UNTRANSMITTED_FRAME, INTRA_FRAME = 0,
  INTER_FRAME, SKIP_FRAME, FIRST_FRAME, INNER_FRAME,
  FINAL_FRAME, LINEAR_MODE, FRAME_NB
}
 
enum  LimiterState {
  OUT, ATTACK, SUSTAIN, RELEASE,
  STATE_NB
}
 
enum  PrintFormat { NONE, JSON, SUMMARY, PF_NB }
 

Functions

 AVFILTER_DEFINE_CLASS (loudnorm)
 
static int frame_size (int sample_rate, int frame_len_msec)
 
static void init_gaussian_filter (LoudNormContext *s)
 
static double gaussian_filter (LoudNormContext *s, int index)
 
static void detect_peak (LoudNormContext *s, int offset, int nb_samples, int channels, int *peak_delta, double *peak_value)
 
static void true_peak_limiter (LoudNormContext *s, double *out, int nb_samples, int channels)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static int request_frame (AVFilterLink *outlink)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption loudnorm_options []
 
static const AVFilterPad avfilter_af_loudnorm_inputs []
 
static const AVFilterPad avfilter_af_loudnorm_outputs []
 
AVFilter ff_af_loudnorm
 

Macro Definition Documentation

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

Definition at line 98 of file af_loudnorm.c.

Definition at line 99 of file af_loudnorm.c.

Enumeration Type Documentation

enum FrameType
Enumerator
ACTIVE_FRAME 

Active speech.

SID_FRAME 

Silence Insertion Descriptor frame.

UNTRANSMITTED_FRAME 
INTRA_FRAME 
INTER_FRAME 
SKIP_FRAME 
FIRST_FRAME 
INNER_FRAME 
FINAL_FRAME 
LINEAR_MODE 
FRAME_NB 

Definition at line 29 of file af_loudnorm.c.

Enumerator
OUT 
ATTACK 
SUSTAIN 
RELEASE 
STATE_NB 

Definition at line 37 of file af_loudnorm.c.

Enumerator
NONE 
JSON 
SUMMARY 
PF_NB 

Definition at line 45 of file af_loudnorm.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( loudnorm  )
static int frame_size ( int  sample_rate,
int  frame_len_msec 
)
inlinestatic

Definition at line 127 of file af_loudnorm.c.

Referenced by config_input(), filter_frame(), and request_frame().

static void init_gaussian_filter ( LoudNormContext s)
static

Definition at line 133 of file af_loudnorm.c.

Referenced by config_input().

static double gaussian_filter ( LoudNormContext s,
int  index 
)
static

Definition at line 155 of file af_loudnorm.c.

Referenced by filter_frame().

static void detect_peak ( LoudNormContext s,
int  offset,
int  nb_samples,
int  channels,
int peak_delta,
double *  peak_value 
)
static

Definition at line 167 of file af_loudnorm.c.

Referenced by true_peak_limiter().

static void true_peak_limiter ( LoudNormContext s,
double *  out,
int  nb_samples,
int  channels 
)
static

Definition at line 230 of file af_loudnorm.c.

Referenced by filter_frame().

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 409 of file af_loudnorm.c.

Referenced by request_frame().

static int request_frame ( AVFilterLink outlink)
static

Definition at line 638 of file af_loudnorm.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 683 of file af_loudnorm.c.

static int config_input ( AVFilterLink inlink)
static

Definition at line 723 of file af_loudnorm.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 793 of file af_loudnorm.c.

Variable Documentation

const AVOption loudnorm_options[]
static
Initial value:
= {
{ "I", "set integrated loudness target", OFFSET(target_i), AV_OPT_TYPE_DOUBLE, {.dbl = -24.}, -70., -5., FLAGS },
{ "i", "set integrated loudness target", OFFSET(target_i), AV_OPT_TYPE_DOUBLE, {.dbl = -24.}, -70., -5., FLAGS },
{ "LRA", "set loudness range target", OFFSET(target_lra), AV_OPT_TYPE_DOUBLE, {.dbl = 7.}, 1., 20., FLAGS },
{ "lra", "set loudness range target", OFFSET(target_lra), AV_OPT_TYPE_DOUBLE, {.dbl = 7.}, 1., 20., FLAGS },
{ "TP", "set maximum true peak", OFFSET(target_tp), AV_OPT_TYPE_DOUBLE, {.dbl = -2.}, -9., 0., FLAGS },
{ "tp", "set maximum true peak", OFFSET(target_tp), AV_OPT_TYPE_DOUBLE, {.dbl = -2.}, -9., 0., FLAGS },
{ "measured_I", "measured IL of input file", OFFSET(measured_i), AV_OPT_TYPE_DOUBLE, {.dbl = 0.}, -99., 0., FLAGS },
{ "measured_i", "measured IL of input file", OFFSET(measured_i), AV_OPT_TYPE_DOUBLE, {.dbl = 0.}, -99., 0., FLAGS },
{ "measured_LRA", "measured LRA of input file", OFFSET(measured_lra), AV_OPT_TYPE_DOUBLE, {.dbl = 0.}, 0., 99., FLAGS },
{ "measured_lra", "measured LRA of input file", OFFSET(measured_lra), AV_OPT_TYPE_DOUBLE, {.dbl = 0.}, 0., 99., FLAGS },
{ "measured_TP", "measured true peak of input file", OFFSET(measured_tp), AV_OPT_TYPE_DOUBLE, {.dbl = 99.}, -99., 99., FLAGS },
{ "measured_tp", "measured true peak of input file", OFFSET(measured_tp), AV_OPT_TYPE_DOUBLE, {.dbl = 99.}, -99., 99., FLAGS },
{ "measured_thresh", "measured threshold of input file", OFFSET(measured_thresh), AV_OPT_TYPE_DOUBLE, {.dbl = -70.}, -99., 0., FLAGS },
{ "offset", "set offset gain", OFFSET(offset), AV_OPT_TYPE_DOUBLE, {.dbl = 0.}, -99., 99., FLAGS },
{ "linear", "normalize linearly if possible", OFFSET(linear), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS },
{ "dual_mono", "treat mono input as dual-mono", OFFSET(dual_mono), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
{ "print_format", "set print format for stats", OFFSET(print_format), AV_OPT_TYPE_INT, {.i64 = NONE}, NONE, PF_NB -1, FLAGS, "print_format" },
{ "none", 0, 0, AV_OPT_TYPE_CONST, {.i64 = NONE}, 0, 0, FLAGS, "print_format" },
{ "json", 0, 0, AV_OPT_TYPE_CONST, {.i64 = JSON}, 0, 0, FLAGS, "print_format" },
{ "summary", 0, 0, AV_OPT_TYPE_CONST, {.i64 = SUMMARY}, 0, 0, FLAGS, "print_format" },
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int linear(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:121
static char * print_format
Definition: ffprobe.c:117
static const uint8_t offset[127][2]
Definition: vf_spp.c:92
#define OFFSET(x)
Definition: af_loudnorm.c:98
#define FLAGS
Definition: af_loudnorm.c:99

Definition at line 101 of file af_loudnorm.c.

const AVFilterPad avfilter_af_loudnorm_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
.filter_frame = filter_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_input(AVFilterLink *inlink)
Definition: af_loudnorm.c:723
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: af_loudnorm.c:409

Definition at line 892 of file af_loudnorm.c.

const AVFilterPad avfilter_af_loudnorm_outputs[]
static
Initial value:
= {
{
.name = "default",
.request_frame = request_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int request_frame(AVFilterLink *outlink)
Definition: af_loudnorm.c:638

Definition at line 902 of file af_loudnorm.c.

AVFilter ff_af_loudnorm
Initial value:
= {
.name = "loudnorm",
.description = NULL_IF_CONFIG_SMALL("EBU R128 loudness normalization"),
.priv_size = sizeof(LoudNormContext),
.priv_class = &loudnorm_class,
}
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
static const AVFilterPad avfilter_af_loudnorm_inputs[]
Definition: af_loudnorm.c:892
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:386
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:376
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_loudnorm.c:793
static int query_formats(AVFilterContext *ctx)
Definition: af_loudnorm.c:683
static const AVFilterPad avfilter_af_loudnorm_outputs[]
Definition: af_loudnorm.c:902

Definition at line 911 of file af_loudnorm.c.