FFmpeg
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 []
 
const 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 639 of file af_loudnorm.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 684 of file af_loudnorm.c.

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 718 of file af_loudnorm.c.

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 772 of file af_loudnorm.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 793 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 }
}

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,
},
}

Definition at line 892 of file af_loudnorm.c.

◆ avfilter_af_loudnorm_outputs

const AVFilterPad avfilter_af_loudnorm_outputs[]
static
Initial value:
= {
{
.name = "default",
.request_frame = request_frame,
},
}

Definition at line 901 of file af_loudnorm.c.

◆ ff_af_loudnorm

const 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,
}

Definition at line 909 of file af_loudnorm.c.

init
static av_cold int init(AVFilterContext *ctx)
Definition: af_loudnorm.c:772
NONE
@ NONE
Definition: af_loudnorm.c:46
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_loudnorm.c:793
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:168
linear
static int linear(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:131
print_format
static char * print_format
Definition: ffprobe.c:126
avfilter_af_loudnorm_outputs
static const AVFilterPad avfilter_af_loudnorm_outputs[]
Definition: af_loudnorm.c:901
JSON
@ JSON
Definition: af_loudnorm.c:47
FLAGS
#define FLAGS
Definition: af_loudnorm.c:99
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: af_loudnorm.c:409
SUMMARY
@ SUMMARY
Definition: af_loudnorm.c:48
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:226
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
NULL
#define NULL
Definition: coverity.c:32
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: af_loudnorm.c:684
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:117
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
LoudNormContext
Definition: af_loudnorm.c:52
avfilter_af_loudnorm_inputs
static const AVFilterPad avfilter_af_loudnorm_inputs[]
Definition: af_loudnorm.c:892
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: af_loudnorm.c:639
config_input
static int config_input(AVFilterLink *inlink)
Definition: af_loudnorm.c:718
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
PF_NB
@ PF_NB
Definition: af_loudnorm.c:49
OFFSET
#define OFFSET(x)
Definition: af_loudnorm.c:98
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:241
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233