FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
f_ebur128.c File Reference
#include <math.h>
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/channel_layout.h"
#include "libavutil/dict.h"
#include "libavutil/ffmath.h"
#include "libavutil/xga_font_data.h"
#include "libavutil/opt.h"
#include "libavutil/timestamp.h"
#include "libswresample/swresample.h"
#include "audio.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  hist_entry
 A histogram is an array of HIST_SIZE hist_entry storing all the energies recorded (with an accuracy of 1/HIST_GRAIN) of the loudnesses from ABS_THRES (at 0) to ABS_UP_THRES (at HIST_SIZE-1). More...
 
struct  integrator
 
struct  rect
 
struct  EBUR128Context
 

Macros

#define MAX_CHANNELS   63
 
#define PRE_B0   1.53512485958697
 
#define PRE_B1   -2.69169618940638
 
#define PRE_B2   1.19839281085285
 
#define PRE_A1   -1.69065929318241
 
#define PRE_A2   0.73248077421585
 
#define RLB_B0   1.0
 
#define RLB_B1   -2.0
 
#define RLB_B2   1.0
 
#define RLB_A1   -1.99004745483398
 
#define RLB_A2   0.99007225036621
 
#define ABS_THRES   -70
 silence gate: we discard anything below this absolute (LUFS) threshold More...
 
#define ABS_UP_THRES   10
 upper loud limit to consider (ABS_THRES being the minimum) More...
 
#define HIST_GRAIN   100
 defines histogram precision More...
 
#define HIST_SIZE   ((ABS_UP_THRES - ABS_THRES) * HIST_GRAIN + 1)
 
#define I400_BINS   (48000 * 4 / 10)
 
#define I3000_BINS   (48000 * 3)
 
#define OFFSET(x)   offsetof(EBUR128Context, x)
 
#define A   AV_OPT_FLAG_AUDIO_PARAM
 
#define V   AV_OPT_FLAG_VIDEO_PARAM
 
#define F   AV_OPT_FLAG_FILTERING_PARAM
 
#define FONT8   0
 
#define FONT16   1
 
#define PAD   8
 
#define DRAW_RECT(r)
 
#define BACK_MASK
 
#define ENERGY(loudness)   (ff_exp10(((loudness) + 0.691) / 10.))
 
#define LOUDNESS(energy)   (-0.691 + 10 * log10(energy))
 
#define DBFS(energy)   (20 * log10(energy))
 
#define HIST_POS(power)   (int)(((power) - ABS_THRES) * HIST_GRAIN)
 
#define MOVE_TO_NEXT_CACHED_ENTRY(time)
 
#define FILTER(Y, X, name)
 
#define COMPUTE_LOUDNESS(m, time)
 
#define I_GATE_THRES   -10
 
#define LRA_GATE_THRES   -20
 
#define LRA_LOWER_PRC   10
 
#define LRA_HIGHER_PRC   95
 
#define LOG_FMT   "TARGET:%d LUFS M:%6.1f S:%6.1f I:%6.1f %s LRA:%6.1f LU"
 
#define META_PREFIX   "lavfi.r128."
 
#define SET_META(name, var)
 
#define SET_META_PEAK(name, ptype)
 
#define PRINT_PEAKS(str, sp, ptype)
 
#define PRINT_PEAK_SUMMARY(str, sp, ptype)
 

Enumerations

enum  { PEAK_MODE_NONE = 0, PEAK_MODE_SAMPLES_PEAKS = 1<<1, PEAK_MODE_TRUE_PEAKS = 1<<2 }
 
enum  { GAUGE_TYPE_MOMENTARY = 0, GAUGE_TYPE_SHORTTERM = 1 }
 
enum  { SCALE_TYPE_ABSOLUTE = 0, SCALE_TYPE_RELATIVE = 1 }
 

Functions

 AVFILTER_DEFINE_CLASS (ebur128)
 
static const uint8_tget_graph_color (const EBUR128Context *ebur128, int v, int y)
 
static int lu_to_y (const EBUR128Context *ebur128, double v)
 
static void drawtext (AVFrame *pic, int x, int y, int ftid, const uint8_t *color, const char *fmt,...)
 
static void drawline (AVFrame *pic, int x, int y, int len, int step)
 
static int config_video_output (AVFilterLink *outlink)
 
static int config_audio_input (AVFilterLink *inlink)
 
static int config_audio_output (AVFilterLink *outlink)
 
static struct hist_entryget_histogram (void)
 
static av_cold int init (AVFilterContext *ctx)
 
static int gate_update (struct integrator *integ, double power, double loudness, int gate_thres)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *insamples)
 
static int query_formats (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption ebur128_options []
 
static const uint8_t graph_colors []
 
static const uint8_t font_colors []
 
static const AVFilterPad ebur128_inputs []
 
AVFilter ff_af_ebur128
 

Detailed Description

EBU R.128 implementation

See also
http://tech.ebu.ch/loudness
https://www.youtube.com/watch?v=iuEtQqC-Sqo "EBU R128 Introduction - Florian Camerer"
Todo:

implement start/stop/reset through filter command injection

support other frequencies to avoid resampling

Definition in file f_ebur128.c.

Macro Definition Documentation

◆ MAX_CHANNELS

#define MAX_CHANNELS   63

Definition at line 46 of file f_ebur128.c.

◆ PRE_B0

#define PRE_B0   1.53512485958697

Definition at line 49 of file f_ebur128.c.

◆ PRE_B1

#define PRE_B1   -2.69169618940638

Definition at line 50 of file f_ebur128.c.

◆ PRE_B2

#define PRE_B2   1.19839281085285

Definition at line 51 of file f_ebur128.c.

◆ PRE_A1

#define PRE_A1   -1.69065929318241

Definition at line 52 of file f_ebur128.c.

◆ PRE_A2

#define PRE_A2   0.73248077421585

Definition at line 53 of file f_ebur128.c.

◆ RLB_B0

#define RLB_B0   1.0

Definition at line 56 of file f_ebur128.c.

◆ RLB_B1

#define RLB_B1   -2.0

Definition at line 57 of file f_ebur128.c.

◆ RLB_B2

#define RLB_B2   1.0

Definition at line 58 of file f_ebur128.c.

◆ RLB_A1

#define RLB_A1   -1.99004745483398

Definition at line 59 of file f_ebur128.c.

◆ RLB_A2

#define RLB_A2   0.99007225036621

Definition at line 60 of file f_ebur128.c.

◆ ABS_THRES

#define ABS_THRES   -70

silence gate: we discard anything below this absolute (LUFS) threshold

Definition at line 62 of file f_ebur128.c.

◆ ABS_UP_THRES

#define ABS_UP_THRES   10

upper loud limit to consider (ABS_THRES being the minimum)

Definition at line 63 of file f_ebur128.c.

◆ HIST_GRAIN

#define HIST_GRAIN   100

defines histogram precision

Definition at line 64 of file f_ebur128.c.

◆ HIST_SIZE

#define HIST_SIZE   ((ABS_UP_THRES - ABS_THRES) * HIST_GRAIN + 1)

Definition at line 65 of file f_ebur128.c.

◆ I400_BINS

#define I400_BINS   (48000 * 4 / 10)

Definition at line 132 of file f_ebur128.c.

◆ I3000_BINS

#define I3000_BINS   (48000 * 3)

Definition at line 133 of file f_ebur128.c.

◆ OFFSET

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

Definition at line 168 of file f_ebur128.c.

◆ A

#define A   AV_OPT_FLAG_AUDIO_PARAM

Definition at line 169 of file f_ebur128.c.

◆ V

#define V   AV_OPT_FLAG_VIDEO_PARAM

Definition at line 170 of file f_ebur128.c.

◆ F

Definition at line 171 of file f_ebur128.c.

◆ FONT8

#define FONT8   0

Definition at line 239 of file f_ebur128.c.

◆ FONT16

#define FONT16   1

Definition at line 240 of file f_ebur128.c.

◆ PAD

#define PAD   8

◆ DRAW_RECT

#define DRAW_RECT (   r)
Value:
do { \
drawline(outpicref, r.x, r.y - 1, r.w, 3); \
drawline(outpicref, r.x, r.y + r.h, r.w, 3); \
drawline(outpicref, r.x - 1, r.y, r.h, outpicref->linesize[0]); \
drawline(outpicref, r.x + r.w, r.y, r.h, outpicref->linesize[0]); \
} while (0)

◆ BACK_MASK

#define BACK_MASK
Value:

◆ ENERGY

#define ENERGY (   loudness)    (ff_exp10(((loudness) + 0.691) / 10.))

Definition at line 477 of file f_ebur128.c.

◆ LOUDNESS

#define LOUDNESS (   energy)    (-0.691 + 10 * log10(energy))

Definition at line 478 of file f_ebur128.c.

◆ DBFS

#define DBFS (   energy)    (20 * log10(energy))

Definition at line 479 of file f_ebur128.c.

◆ HIST_POS

#define HIST_POS (   power)    (int)(((power) - ABS_THRES) * HIST_GRAIN)

Definition at line 561 of file f_ebur128.c.

◆ MOVE_TO_NEXT_CACHED_ENTRY

#define MOVE_TO_NEXT_CACHED_ENTRY (   time)
Value:
do { \
ebur128->i##time.cache_pos++; \
if (ebur128->i##time.cache_pos == I##time##_BINS) { \
ebur128->i##time.filled = 1; \
ebur128->i##time.cache_pos = 0; \
} \
} while (0)

◆ FILTER

#define FILTER (   Y,
  X,
  name 
)
Value:
do { \
double *dst = ebur128->Y + ch*3; \
double *src = ebur128->X + ch*3; \
dst[2] = dst[1]; \
dst[1] = dst[0]; \
dst[0] = src[0]*name##_B0 + src[1]*name##_B1 + src[2]*name##_B2 \
- dst[1]*name##_A1 - dst[2]*name##_A2; \
} while (0)

◆ COMPUTE_LOUDNESS

#define COMPUTE_LOUDNESS (   m,
  time 
)
Value:
do { \
if (ebur128->i##time.filled) { \
/* weighting sum of the last <time> ms */ \
for (ch = 0; ch < nb_channels; ch++) \
power_##time += ebur128->ch_weighting[ch] * ebur128->i##time.sum[ch]; \
power_##time /= I##time##_BINS; \
} \
loudness_##time = LOUDNESS(power_##time); \
} while (0)

◆ I_GATE_THRES

#define I_GATE_THRES   -10

◆ LRA_GATE_THRES

#define LRA_GATE_THRES   -20

◆ LRA_LOWER_PRC

#define LRA_LOWER_PRC   10

◆ LRA_HIGHER_PRC

#define LRA_HIGHER_PRC   95

◆ LOG_FMT

#define LOG_FMT   "TARGET:%d LUFS M:%6.1f S:%6.1f I:%6.1f %s LRA:%6.1f LU"

◆ META_PREFIX

#define META_PREFIX   "lavfi.r128."

◆ SET_META

#define SET_META (   name,
  var 
)
Value:
do { \
snprintf(metabuf, sizeof(metabuf), "%.3f", var); \
av_dict_set(&insamples->metadata, name, metabuf, 0); \
} while (0)

◆ SET_META_PEAK

#define SET_META_PEAK (   name,
  ptype 
)
Value:
do { \
if (ebur128->peak_mode & PEAK_MODE_ ## ptype ## _PEAKS) { \
char key[64]; \
for (ch = 0; ch < nb_channels; ch++) { \
snprintf(key, sizeof(key), \
META_PREFIX AV_STRINGIFY(name) "_peaks_ch%d", ch); \
SET_META(key, ebur128->name##_peaks[ch]); \
} \
} \
} while (0)

◆ PRINT_PEAKS

#define PRINT_PEAKS (   str,
  sp,
  ptype 
)
Value:
do { \
if (ebur128->peak_mode & PEAK_MODE_ ## ptype ## _PEAKS) { \
av_log(ctx, ebur128->loglevel, " " str ":"); \
for (ch = 0; ch < nb_channels; ch++) \
av_log(ctx, ebur128->loglevel, " %5.1f", DBFS(sp[ch])); \
av_log(ctx, ebur128->loglevel, " dBFS"); \
} \
} while (0)

◆ PRINT_PEAK_SUMMARY

#define PRINT_PEAK_SUMMARY (   str,
  sp,
  ptype 
)
Value:
do { \
int ch; \
double maxpeak; \
maxpeak = 0.0; \
if (ebur128->peak_mode & PEAK_MODE_ ## ptype ## _PEAKS) { \
for (ch = 0; ch < ebur128->nb_channels; ch++) \
maxpeak = FFMAX(maxpeak, sp[ch]); \
av_log(ctx, AV_LOG_INFO, "\n\n " str " peak:\n" \
" Peak: %5.1f dBFS", \
DBFS(maxpeak)); \
} \
} while (0)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PEAK_MODE_NONE 
PEAK_MODE_SAMPLES_PEAKS 
PEAK_MODE_TRUE_PEAKS 

Definition at line 152 of file f_ebur128.c.

◆ anonymous enum

anonymous enum
Enumerator
GAUGE_TYPE_MOMENTARY 
GAUGE_TYPE_SHORTTERM 

Definition at line 158 of file f_ebur128.c.

◆ anonymous enum

anonymous enum
Enumerator
SCALE_TYPE_ABSOLUTE 
SCALE_TYPE_RELATIVE 

Definition at line 163 of file f_ebur128.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( ebur128  )

◆ get_graph_color()

static const uint8_t* get_graph_color ( const EBUR128Context ebur128,
int  v,
int  y 
)
static

Definition at line 221 of file f_ebur128.c.

Referenced by config_video_output(), and filter_frame().

◆ lu_to_y()

static int lu_to_y ( const EBUR128Context ebur128,
double  v 
)
inlinestatic

Definition at line 231 of file f_ebur128.c.

Referenced by config_video_output(), and filter_frame().

◆ drawtext()

static void drawtext ( AVFrame pic,
int  x,
int  y,
int  ftid,
const uint8_t color,
const char *  fmt,
  ... 
)
static

Definition at line 247 of file f_ebur128.c.

Referenced by config_video_output(), and filter_frame().

◆ drawline()

static void drawline ( AVFrame pic,
int  x,
int  y,
int  len,
int  step 
)
static

Definition at line 280 of file f_ebur128.c.

◆ config_video_output()

static int config_video_output ( AVFilterLink outlink)
static

Definition at line 291 of file f_ebur128.c.

Referenced by init().

◆ config_audio_input()

static int config_audio_input ( AVFilterLink inlink)
static

Definition at line 386 of file f_ebur128.c.

◆ config_audio_output()

static int config_audio_output ( AVFilterLink outlink)
static

Definition at line 404 of file f_ebur128.c.

Referenced by init().

◆ get_histogram()

static struct hist_entry* get_histogram ( void  )
static

Definition at line 481 of file f_ebur128.c.

Referenced by init().

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 495 of file f_ebur128.c.

◆ gate_update()

static int gate_update ( struct integrator integ,
double  power,
double  loudness,
int  gate_thres 
)
static

Definition at line 565 of file f_ebur128.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame insamples 
)
static

Definition at line 588 of file f_ebur128.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 893 of file f_ebur128.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 935 of file f_ebur128.c.

Variable Documentation

◆ ebur128_options

const AVOption ebur128_options[]
static
Initial value:
= {
{ "video", "set video output", OFFSET(do_video), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, V|F },
{ "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "640x480"}, 0, 0, V|F },
{ "meter", "set scale meter (+9 to +18)", OFFSET(meter), AV_OPT_TYPE_INT, {.i64 = 9}, 9, 18, V|F },
{ "framelog", "force frame logging level", OFFSET(loglevel), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, A|V|F, "level" },
{ "info", "information logging level", 0, AV_OPT_TYPE_CONST, {.i64 = AV_LOG_INFO}, INT_MIN, INT_MAX, A|V|F, "level" },
{ "verbose", "verbose logging level", 0, AV_OPT_TYPE_CONST, {.i64 = AV_LOG_VERBOSE}, INT_MIN, INT_MAX, A|V|F, "level" },
{ "metadata", "inject metadata in the filtergraph", OFFSET(metadata), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, A|V|F },
{ "peak", "set peak mode", OFFSET(peak_mode), AV_OPT_TYPE_FLAGS, {.i64 = PEAK_MODE_NONE}, 0, INT_MAX, A|F, "mode" },
{ "none", "disable any peak mode", 0, AV_OPT_TYPE_CONST, {.i64 = PEAK_MODE_NONE}, INT_MIN, INT_MAX, A|F, "mode" },
{ "sample", "enable peak-sample mode", 0, AV_OPT_TYPE_CONST, {.i64 = PEAK_MODE_SAMPLES_PEAKS}, INT_MIN, INT_MAX, A|F, "mode" },
{ "true", "enable true-peak mode", 0, AV_OPT_TYPE_CONST, {.i64 = PEAK_MODE_TRUE_PEAKS}, INT_MIN, INT_MAX, A|F, "mode" },
{ "dualmono", "treat mono input files as dual-mono", OFFSET(dual_mono), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, A|F },
{ "panlaw", "set a specific pan law for dual-mono files", OFFSET(pan_law), AV_OPT_TYPE_DOUBLE, {.dbl = -3.01029995663978}, -10.0, 0.0, A|F },
{ "target", "set a specific target level in LUFS (-23 to 0)", OFFSET(target), AV_OPT_TYPE_INT, {.i64 = -23}, -23, 0, V|F },
{ "gauge", "set gauge display type", OFFSET(gauge_type), AV_OPT_TYPE_INT, {.i64 = 0 }, GAUGE_TYPE_MOMENTARY, GAUGE_TYPE_SHORTTERM, V|F, "gaugetype" },
{ "momentary", "display momentary value", 0, AV_OPT_TYPE_CONST, {.i64 = GAUGE_TYPE_MOMENTARY}, INT_MIN, INT_MAX, V|F, "gaugetype" },
{ "m", "display momentary value", 0, AV_OPT_TYPE_CONST, {.i64 = GAUGE_TYPE_MOMENTARY}, INT_MIN, INT_MAX, V|F, "gaugetype" },
{ "shortterm", "display short-term value", 0, AV_OPT_TYPE_CONST, {.i64 = GAUGE_TYPE_SHORTTERM}, INT_MIN, INT_MAX, V|F, "gaugetype" },
{ "s", "display short-term value", 0, AV_OPT_TYPE_CONST, {.i64 = GAUGE_TYPE_SHORTTERM}, INT_MIN, INT_MAX, V|F, "gaugetype" },
{ "scale", "sets display method for the stats", OFFSET(scale), AV_OPT_TYPE_INT, {.i64 = 0}, SCALE_TYPE_ABSOLUTE, SCALE_TYPE_RELATIVE, V|F, "scaletype" },
{ "absolute", "display absolute values (LUFS)", 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_TYPE_ABSOLUTE}, INT_MIN, INT_MAX, V|F, "scaletype" },
{ "LUFS", "display absolute values (LUFS)", 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_TYPE_ABSOLUTE}, INT_MIN, INT_MAX, V|F, "scaletype" },
{ "relative", "display values relative to target (LU)", 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_TYPE_RELATIVE}, INT_MIN, INT_MAX, V|F, "scaletype" },
{ "LU", "display values relative to target (LU)", 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_TYPE_RELATIVE}, INT_MIN, INT_MAX, V|F, "scaletype" },
{ NULL },
}

Definition at line 172 of file f_ebur128.c.

◆ graph_colors

const uint8_t graph_colors[]
static
Initial value:
= {
0xdd, 0x66, 0x66,
0x66, 0x66, 0xdd,
0x96, 0x33, 0x33,
0x33, 0x33, 0x96,
0xdd, 0x96, 0x96,
0x96, 0x96, 0xdd,
0xdd, 0x33, 0x33,
0x33, 0x33, 0xdd,
0xdd, 0x66, 0x66,
0x66, 0xdd, 0x66,
0x96, 0x33, 0x33,
0x33, 0x96, 0x33,
0xdd, 0x96, 0x96,
0x96, 0xdd, 0x96,
0xdd, 0x33, 0x33,
0x33, 0xdd, 0x33,
}

Definition at line 202 of file f_ebur128.c.

Referenced by get_graph_color().

◆ font_colors

const uint8_t font_colors[]
static
Initial value:
= {
0xdd, 0xdd, 0x00,
0x00, 0x96, 0x96,
}

Definition at line 242 of file f_ebur128.c.

Referenced by config_video_output(), and filter_frame().

◆ ebur128_inputs

const AVFilterPad ebur128_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
.config_props = config_audio_input,
},
{ NULL }
}

Definition at line 998 of file f_ebur128.c.

◆ ff_af_ebur128

AVFilter ff_af_ebur128
Initial value:
= {
.name = "ebur128",
.description = NULL_IF_CONFIG_SMALL("EBU R128 scanner."),
.priv_size = sizeof(EBUR128Context),
.init = init,
.priv_class = &ebur128_class,
}

Definition at line 1008 of file f_ebur128.c.

V
#define V
Definition: f_ebur128.c:170
r
const char * r
Definition: vf_curves.c:114
PEAK_MODE_NONE
@ PEAK_MODE_NONE
Definition: f_ebur128.c:153
A
#define A
Definition: f_ebur128.c:169
ch
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
Definition: audioconvert.c:56
w
uint8_t w
Definition: llviddspenc.c:38
name
const char * name
Definition: avisynth_c.h:867
F
#define F
Definition: f_ebur128.c:171
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
init
static av_cold int init(AVFilterContext *ctx)
Definition: f_ebur128.c:495
GAUGE_TYPE_MOMENTARY
@ GAUGE_TYPE_MOMENTARY
Definition: f_ebur128.c:159
AV_CH_SURROUND_DIRECT_RIGHT
#define AV_CH_SURROUND_DIRECT_RIGHT
Definition: channel_layout.h:72
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: f_ebur128.c:935
AV_CH_TOP_BACK_CENTER
#define AV_CH_TOP_BACK_CENTER
Definition: channel_layout.h:65
AV_CH_BACK_LEFT
#define AV_CH_BACK_LEFT
Definition: channel_layout.h:53
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: f_ebur128.c:893
src
#define src
Definition: vp8dsp.c:254
PEAK_MODE_SAMPLES_PEAKS
@ PEAK_MODE_SAMPLES_PEAKS
Definition: f_ebur128.c:154
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
Definition: f_ebur128.c:588
OFFSET
#define OFFSET(x)
Definition: f_ebur128.c:168
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:225
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
ctx
AVFormatContext * ctx
Definition: movenc.c:48
key
const char * key
Definition: hwcontext_opencl.c:168
PEAK_MODE_TRUE_PEAKS
@ PEAK_MODE_TRUE_PEAKS
Definition: f_ebur128.c:155
NULL
#define NULL
Definition: coverity.c:32
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Definition: opt.h:233
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
EBUR128Context
Definition: f_ebur128.c:93
AVFILTER_FLAG_DYNAMIC_OUTPUTS
#define AVFILTER_FLAG_DYNAMIC_OUTPUTS
The number of the filter outputs is not determined just by AVFilter.outputs.
Definition: avfilter.h:111
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:188
sp
#define sp
Definition: regdef.h:63
FFMAX
#define FFMAX(a, b)
Definition: common.h:94
SCALE_TYPE_RELATIVE
@ SCALE_TYPE_RELATIVE
Definition: f_ebur128.c:165
AV_CH_TOP_BACK_RIGHT
#define AV_CH_TOP_BACK_RIGHT
Definition: channel_layout.h:66
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
AV_CH_BACK_CENTER
#define AV_CH_BACK_CENTER
Definition: channel_layout.h:57
AV_STRINGIFY
#define AV_STRINGIFY(s)
Definition: macros.h:36
AV_CH_SIDE_RIGHT
#define AV_CH_SIDE_RIGHT
Definition: channel_layout.h:59
SCALE_TYPE_ABSOLUTE
@ SCALE_TYPE_ABSOLUTE
Definition: f_ebur128.c:164
META_PREFIX
#define META_PREFIX
LOUDNESS
#define LOUDNESS(energy)
Definition: f_ebur128.c:478
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
DBFS
#define DBFS(energy)
Definition: f_ebur128.c:479
GAUGE_TYPE_SHORTTERM
@ GAUGE_TYPE_SHORTTERM
Definition: f_ebur128.c:160
ebur128_inputs
static const AVFilterPad ebur128_inputs[]
Definition: f_ebur128.c:998
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:240
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:222
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:565
config_audio_input
static int config_audio_input(AVFilterLink *inlink)
Definition: f_ebur128.c:386
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AV_CH_BACK_RIGHT
#define AV_CH_BACK_RIGHT
Definition: channel_layout.h:54
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:232
nb_channels
int nb_channels
Definition: channel_layout.c:76