FFmpeg  4.0
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 int init (AVFilterContext *ctx)
 
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

◆ OFFSET

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

Definition at line 98 of file af_loudnorm.c.

◆ FLAGS

Definition at line 99 of file af_loudnorm.c.

Enumeration Type Documentation

◆ FrameType

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.

◆ LimiterState

Enumerator
OUT 
ATTACK 
SUSTAIN 
RELEASE 
STATE_NB 

Definition at line 37 of file af_loudnorm.c.

◆ PrintFormat

Enumerator
NONE 
JSON 
SUMMARY 
PF_NB 

Definition at line 45 of file af_loudnorm.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( loudnorm  )

◆ frame_size()

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

◆ init_gaussian_filter()

static void init_gaussian_filter ( LoudNormContext s)
static

Definition at line 133 of file af_loudnorm.c.

Referenced by config_input().

◆ gaussian_filter()

static double gaussian_filter ( LoudNormContext s,
int  index 
)
static

Definition at line 155 of file af_loudnorm.c.

Referenced by filter_frame().

◆ detect_peak()

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

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

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 409 of file af_loudnorm.c.

Referenced by request_frame().

◆ request_frame()

static int request_frame ( AVFilterLink outlink)
static

Definition at line 641 of file af_loudnorm.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 686 of file af_loudnorm.c.

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 729 of file af_loudnorm.c.

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 784 of file af_loudnorm.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 805 of file af_loudnorm.c.

Variable Documentation

◆ loudnorm_options

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:118
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.

◆ avfilter_af_loudnorm_inputs

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:729
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: af_loudnorm.c:409

Definition at line 904 of file af_loudnorm.c.

◆ avfilter_af_loudnorm_outputs

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:641

Definition at line 914 of file af_loudnorm.c.

◆ ff_af_loudnorm

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,
.init = init,
}
#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 avfilter_af_loudnorm_inputs[]
Definition: af_loudnorm.c:904
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
static av_cold int init(AVFilterContext *ctx)
Definition: af_loudnorm.c:784
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_loudnorm.c:805
static int query_formats(AVFilterContext *ctx)
Definition: af_loudnorm.c:686
static const AVFilterPad avfilter_af_loudnorm_outputs[]
Definition: af_loudnorm.c:914

Definition at line 923 of file af_loudnorm.c.