FFmpeg
Data Structures | Enumerations | Functions
ebur128.h File Reference

libebur128 - a library for loudness measurement according to the EBU R128 standard. More...

#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  FFEBUR128State
 Contains information about the state of a loudness measurement. More...
 

Enumerations

enum  channel {
  FF_EBUR128_UNUSED = 0, FF_EBUR128_LEFT, FF_EBUR128_Mp030 = 1, FF_EBUR128_RIGHT,
  FF_EBUR128_Mm030 = 2, FF_EBUR128_CENTER, FF_EBUR128_Mp000 = 3, FF_EBUR128_LEFT_SURROUND,
  FF_EBUR128_Mp110 = 4, FF_EBUR128_RIGHT_SURROUND, FF_EBUR128_Mm110 = 5, FF_EBUR128_DUAL_MONO,
  FF_EBUR128_MpSC, FF_EBUR128_MmSC, FF_EBUR128_Mp060, FF_EBUR128_Mm060,
  FF_EBUR128_Mp090, FF_EBUR128_Mm090, FF_EBUR128_Mp135, FF_EBUR128_Mm135,
  FF_EBUR128_Mp180, FF_EBUR128_Up000, FF_EBUR128_Up030, FF_EBUR128_Um030,
  FF_EBUR128_Up045, FF_EBUR128_Um045, FF_EBUR128_Up090, FF_EBUR128_Um090,
  FF_EBUR128_Up110, FF_EBUR128_Um110, FF_EBUR128_Up135, FF_EBUR128_Um135,
  FF_EBUR128_Up180, FF_EBUR128_Tp000, FF_EBUR128_Bp000, FF_EBUR128_Bp045,
  FF_EBUR128_Bm045
}
 
enum  mode {
  FF_EBUR128_MODE_M = (1 << 0), FF_EBUR128_MODE_S = (1 << 1) | FF_EBUR128_MODE_M, FF_EBUR128_MODE_I = (1 << 2) | FF_EBUR128_MODE_M, FF_EBUR128_MODE_LRA = (1 << 3) | FF_EBUR128_MODE_S,
  FF_EBUR128_MODE_SAMPLE_PEAK = (1 << 4) | FF_EBUR128_MODE_M, MODE_NONE, MODE_RO, MODE_RW,
  MODE_TOGGLE, MODE_RANDOM, NB_MODES, MODE_COVER,
  MODE_BLUR, NB_MODES, MODE_HARD, MODE_SOFT,
  MODE_MEDIUM, MODE_HARD, MODE_SOFT, NB_MODES
}
 

Functions

FFEBUR128Stateff_ebur128_init (unsigned int channels, unsigned long samplerate, unsigned long window, int mode)
 Initialize library state. More...
 
void ff_ebur128_destroy (FFEBUR128State **st)
 Destroy library state. More...
 
int ff_ebur128_set_channel (FFEBUR128State *st, unsigned int channel_number, int value)
 Set channel type. More...
 
void ff_ebur128_add_frames_double (FFEBUR128State *st, const double *src, size_t frames)
 Add frames to be processed. More...
 
int ff_ebur128_loudness_global (FFEBUR128State *st, double *out)
 Get global integrated loudness in LUFS. More...
 
int ff_ebur128_loudness_shortterm (FFEBUR128State *st, double *out)
 Get short-term loudness (last 3s) in LUFS. More...
 
int ff_ebur128_loudness_range (FFEBUR128State *st, double *out)
 Get loudness range (LRA) of programme in LU. More...
 
int ff_ebur128_loudness_range_multiple (FFEBUR128State **sts, size_t size, double *out)
 Get loudness range (LRA) in LU across multiple instances. More...
 
int ff_ebur128_sample_peak (FFEBUR128State *st, unsigned int channel_number, double *out)
 Get maximum sample peak of selected channel in float format. More...
 
int ff_ebur128_relative_threshold (FFEBUR128State *st, double *out)
 Get relative threshold in LUFS. More...
 

Detailed Description

libebur128 - a library for loudness measurement according to the EBU R128 standard.

Definition in file ebur128.h.

Enumeration Type Documentation

◆ channel

enum channel

Use these values when setting the channel map with ebur128_set_channel(). See definitions in ITU R-REC-BS 1770-4

Enumerator
FF_EBUR128_UNUSED 

unused channel (for example LFE channel)

FF_EBUR128_LEFT 
FF_EBUR128_Mp030 

itu M+030

FF_EBUR128_RIGHT 
FF_EBUR128_Mm030 

itu M-030

FF_EBUR128_CENTER 
FF_EBUR128_Mp000 

itu M+000

FF_EBUR128_LEFT_SURROUND 
FF_EBUR128_Mp110 

itu M+110

FF_EBUR128_RIGHT_SURROUND 
FF_EBUR128_Mm110 

itu M-110

FF_EBUR128_DUAL_MONO 

a channel that is counted twice

FF_EBUR128_MpSC 

itu M+SC

FF_EBUR128_MmSC 

itu M-SC

FF_EBUR128_Mp060 

itu M+060

FF_EBUR128_Mm060 

itu M-060

FF_EBUR128_Mp090 

itu M+090

FF_EBUR128_Mm090 

itu M-090

FF_EBUR128_Mp135 

itu M+135

FF_EBUR128_Mm135 

itu M-135

FF_EBUR128_Mp180 

itu M+180

FF_EBUR128_Up000 

itu U+000

FF_EBUR128_Up030 

itu U+030

FF_EBUR128_Um030 

itu U-030

FF_EBUR128_Up045 

itu U+045

FF_EBUR128_Um045 

itu U-030

FF_EBUR128_Up090 

itu U+090

FF_EBUR128_Um090 

itu U-090

FF_EBUR128_Up110 

itu U+110

FF_EBUR128_Um110 

itu U-110

FF_EBUR128_Up135 

itu U+135

FF_EBUR128_Um135 

itu U-135

FF_EBUR128_Up180 

itu U+180

FF_EBUR128_Tp000 

itu T+000

FF_EBUR128_Bp000 

itu B+000

FF_EBUR128_Bp045 

itu B+045

FF_EBUR128_Bm045 

itu B-045

Definition at line 39 of file ebur128.h.

◆ mode

enum mode

Use these values in ebur128_init (or'ed). Try to use the lowest possible modes that suit your needs, as performance will be better.

Enumerator
FF_EBUR128_MODE_M 

can resurrrect and call ff_ebur128_loudness_momentary

FF_EBUR128_MODE_S 

can call ff_ebur128_loudness_shortterm

FF_EBUR128_MODE_I 

can call ff_ebur128_loudness_global_* and ff_ebur128_relative_threshold

FF_EBUR128_MODE_LRA 

can call ff_ebur128_loudness_range

FF_EBUR128_MODE_SAMPLE_PEAK 

can call ff_ebur128_sample_peak

MODE_NONE 
MODE_RO 
MODE_RW 
MODE_TOGGLE 
MODE_RANDOM 
NB_MODES 
MODE_COVER 
MODE_BLUR 
NB_MODES 
MODE_HARD 
MODE_SOFT 
MODE_MEDIUM 
MODE_HARD 
MODE_SOFT 
NB_MODES 

Definition at line 83 of file ebur128.h.

Function Documentation

◆ ff_ebur128_init()

FFEBUR128State* ff_ebur128_init ( unsigned int  channels,
unsigned long  samplerate,
unsigned long  window,
int  mode 
)

Initialize library state.

Parameters
channelsthe number of channels.
sampleratethe sample rate.
windowset the maximum window size in ms, set to 0 for auto.
modesee the mode enum for possible values.
Returns
an initialized library state.

Definition at line 219 of file ebur128.c.

Referenced by config_input().

◆ ff_ebur128_destroy()

void ff_ebur128_destroy ( FFEBUR128State **  st)

Destroy library state.

Parameters
stpointer to a library state.

Definition at line 304 of file ebur128.c.

Referenced by uninit().

◆ ff_ebur128_set_channel()

int ff_ebur128_set_channel ( FFEBUR128State st,
unsigned int  channel_number,
int  value 
)

Set channel type.

The default is:

  • 0 -> FF_EBUR128_LEFT
  • 1 -> FF_EBUR128_RIGHT
  • 2 -> FF_EBUR128_CENTER
  • 3 -> FF_EBUR128_UNUSED
  • 4 -> FF_EBUR128_LEFT_SURROUND
  • 5 -> FF_EBUR128_RIGHT_SURROUND
Parameters
stlibrary state.
channel_numberzero based channel index.
valuechannel type from the "channel" enum.
Returns

Definition at line 445 of file ebur128.c.

Referenced by config_input().

◆ ff_ebur128_add_frames_double()

void ff_ebur128_add_frames_double ( FFEBUR128State st,
const double src,
size_t  frames 
)

Add frames to be processed.

Parameters
stlibrary state.
srcarray of source frames. Channels must be interleaved.
framesnumber of frames. Not number of samples!

Referenced by filter_frame().

◆ ff_ebur128_loudness_global()

int ff_ebur128_loudness_global ( FFEBUR128State st,
double out 
)

Get global integrated loudness in LUFS.

Parameters
stlibrary state.
outintegrated loudness in LUFS. -HUGE_VAL if result is negative infinity.
Returns
  • 0 on success.
  • AVERROR(EINVAL) if mode "FF_EBUR128_MODE_I" has not been set.

Definition at line 596 of file ebur128.c.

Referenced by filter_frame(), and uninit().

◆ ff_ebur128_loudness_shortterm()

int ff_ebur128_loudness_shortterm ( FFEBUR128State st,
double out 
)

Get short-term loudness (last 3s) in LUFS.

Parameters
stlibrary state.
outshort-term loudness in LUFS. -HUGE_VAL if result is negative infinity.
Returns
  • 0 on success.
  • AVERROR(EINVAL) if mode "FF_EBUR128_MODE_S" has not been set.

Definition at line 617 of file ebur128.c.

Referenced by filter_frame().

◆ ff_ebur128_loudness_range()

int ff_ebur128_loudness_range ( FFEBUR128State st,
double out 
)

Get loudness range (LRA) of programme in LU.

Calculates loudness range according to EBU 3342.

Parameters
stlibrary state.
outloudness range (LRA) in LU. Will not be changed in case of error. AVERROR(EINVAL) will be returned in this case.
Returns
  • 0 on success.
  • AVERROR(EINVAL) if mode "FF_EBUR128_MODE_LRA" has not been set.

Definition at line 709 of file ebur128.c.

Referenced by filter_frame(), and uninit().

◆ ff_ebur128_loudness_range_multiple()

int ff_ebur128_loudness_range_multiple ( FFEBUR128State **  sts,
size_t  size,
double out 
)

Get loudness range (LRA) in LU across multiple instances.

Calculates loudness range according to EBU 3342.

Parameters
stsarray of library states.
sizelength of sts
outloudness range (LRA) in LU. Will not be changed in case of error. AVERROR(EINVAL) will be returned in this case.
Returns
  • 0 on success.
  • AVERROR(EINVAL) if mode "FF_EBUR128_MODE_LRA" has not been set.

Definition at line 632 of file ebur128.c.

Referenced by ff_ebur128_loudness_range().

◆ ff_ebur128_sample_peak()

int ff_ebur128_sample_peak ( FFEBUR128State st,
unsigned int  channel_number,
double out 
)

Get maximum sample peak of selected channel in float format.

Parameters
stlibrary state
channel_numberchannel to analyse
outmaximum sample peak in float format (1.0 is 0 dBFS)
Returns

Definition at line 714 of file ebur128.c.

Referenced by filter_frame(), and uninit().

◆ ff_ebur128_relative_threshold()

int ff_ebur128_relative_threshold ( FFEBUR128State st,
double out 
)

Get relative threshold in LUFS.

Parameters
stlibrary state
outrelative threshold in LUFS.
Returns
  • 0 on success.
  • AVERROR(EINVAL) if mode "FF_EBUR128_MODE_I" has not been set.

Definition at line 580 of file ebur128.c.

Referenced by filter_frame(), and uninit().