1 /*
2 * Copyright (c) 2012 Clément Bœsch
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /**
22 * @file
23 * EBU R.128 implementation
24 * @see http://tech.ebu.ch/loudness
25 * @see https://www.youtube.com/watch?v=iuEtQqC-Sqo "EBU R128 Introduction - Florian Camerer"
26 * @todo implement start/stop/reset through filter command injection
27 */
28
30 #include <math.h>
31
47
48 #define ABS_THRES -70 ///< silence gate: we discard anything below this absolute (LUFS) threshold
49 #define ABS_UP_THRES 10
///< upper loud limit to consider (ABS_THRES being the minimum)
50 #define HIST_GRAIN 100
///< defines histogram precision
51 #define HIST_SIZE ((ABS_UP_THRES - ABS_THRES) * HIST_GRAIN + 1)
52
53 /**
54 * A histogram is an array of HIST_SIZE hist_entry storing all the energies
55 * recorded (with an accuracy of 1/HIST_GRAIN) of the loudnesses from ABS_THRES
56 * (at 0) to ABS_UP_THRES (at HIST_SIZE-1).
57 * This fixed-size system avoids the need of a list of energies growing
58 * infinitely over the time and is thus more scalable.
59 */
61 unsigned count;
///< how many times the corresponding value occurred
62 double energy;
///< E = 10^((L + 0.691) / 10)
63 double loudness;
///< L = -0.691 + 10 * log10(E)
64 };
65
67 double **
cache;
///< window of filtered samples (N ms)
68 int cache_pos;
///< focus on the last added bin in the cache array
70 double *
sum;
///< sum of the last N ms filtered samples (cache content)
71 int filled;
///< 1 if the cache is completely filled, 0 otherwise
73 double sum_kept_powers;
///< sum of the powers (weighted sums) above absolute threshold
76 };
77
79
81 const AVClass *
class;
///< AVClass context for log and options purpose
82
83 /* peak metering */
90 #if CONFIG_SWRESAMPLE
91 SwrContext *swr_ctx;
///< over-sampling context for true peak metering
92 double *swr_buf; ///< resampled audio data for true peak metering
93 int swr_linesize;
94 #endif
95
96 /* video */
97 int do_video;
///< 1 if video output enabled, 0 otherwise
98 int w,
h;
///< size of the video output
99 struct rect text;
///< rectangle for the LU legend on the left
100 struct rect graph;
///< rectangle for the main graph in the center
101 struct rect gauge;
///< rectangle for the gauge on the right
103 int meter;
///< select a EBU mode between +9 and +18
104 int scale_range;
///< the range of LU values according to the meter
105 int y_zero_lu;
///< the y value (pixel position) for 0 LU
106 int y_opt_max;
///< the y value (pixel position) for 1 LU
107 int y_opt_min;
///< the y value (pixel position) for -1 LU
108 int *
y_line_ref;
///< y reference values for drawing the LU lines in the graph and the gauge
109
110 /* audio */
113 int sample_count;
///< sample count used for refresh frequency, reset at refresh
114 int nb_samples;
///< number of samples to consume per single input frame
115 int idx_insample;
///< current sample position of processed samples in single input frame
117
118 /* Filter caches.
119 * The mult by 3 in the following is for X[i], X[i-1] and X[i-2] */
120 double *
x;
///< 3 input samples cache for each channel
121 double *
y;
///< 3 pre-filter samples cache for each channel
122 double *
z;
///< 3 RLB-filter samples cache for each channel
123 double pre_b[3];
///< pre-filter numerator coefficients
124 double pre_a[3];
///< pre-filter denominator coefficients
125 double rlb_b[3];
///< rlb-filter numerator coefficients
126 double rlb_a[3];
///< rlb-filter denominator coefficients
127
128 struct integrator i400;
///< 400ms integrator, used for Momentary loudness (M), and Integrated loudness (I)
129 struct integrator i3000;
///< 3s integrator, used for Short term loudness (S), and Loudness Range (LRA)
130
131 /* I and LRA specific */
135
136 /* misc */
138 int metadata;
///< whether or not to inject loudness results in frames
139 int dual_mono;
///< whether or not to treat single channel input files as dual-mono
140 double pan_law;
///< pan law value used to calculate dual-mono measurements
141 int target;
///< target level in LUFS used to set relative zero LU in visualization
143 int scale;
///< display scale type of statistics
145
146 enum {
150 };
151
152 enum {
155 };
156
157 enum {
160 };
161
162 #define OFFSET(x) offsetof(EBUR128Context, x)
163 #define A AV_OPT_FLAG_AUDIO_PARAM
164 #define V AV_OPT_FLAG_VIDEO_PARAM
165 #define F AV_OPT_FLAG_FILTERING_PARAM
166 #define X AV_OPT_FLAG_EXPORT
167 #define R AV_OPT_FLAG_READONLY
172 {
"framelog",
"force frame logging level",
OFFSET(loglevel),
AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX,
A|
V|
F, .unit =
"level" },
182 {
"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 },
183 {
"target",
"set a specific target level in LUFS (-23 to 0)",
OFFSET(target),
AV_OPT_TYPE_INT, {.i64 = -23}, -23, 0,
V|
F },
194 {
"integrated",
"integrated loudness (LUFS)",
OFFSET(integrated_loudness),
AV_OPT_TYPE_DOUBLE, {.dbl = 0}, -DBL_MAX, DBL_MAX,
A|
F|
X|
R },
201 };
202
204
206 0xdd, 0x66, 0x66, // value above 1LU non reached below -1LU (impossible)
207 0x66, 0x66, 0xdd, // value below 1LU non reached below -1LU
208 0x96, 0x33, 0x33, // value above 1LU reached below -1LU (impossible)
209 0x33, 0x33, 0x96, // value below 1LU reached below -1LU
210 0xdd, 0x96, 0x96, // value above 1LU line non reached below -1LU (impossible)
211 0x96, 0x96, 0xdd, // value below 1LU line non reached below -1LU
212 0xdd, 0x33, 0x33, // value above 1LU line reached below -1LU (impossible)
213 0x33, 0x33, 0xdd, // value below 1LU line reached below -1LU
214 0xdd, 0x66, 0x66, // value above 1LU non reached above -1LU
215 0x66, 0xdd, 0x66, // value below 1LU non reached above -1LU
216 0x96, 0x33, 0x33, // value above 1LU reached above -1LU
217 0x33, 0x96, 0x33, // value below 1LU reached above -1LU
218 0xdd, 0x96, 0x96, // value above 1LU line non reached above -1LU
219 0x96, 0xdd, 0x96, // value below 1LU line non reached above -1LU
220 0xdd, 0x33, 0x33, // value above 1LU line reached above -1LU
221 0x33, 0xdd, 0x33, // value below 1LU line reached above -1LU
222 };
223
225 {
226 const int above_opt_max = y > ebur128->
y_opt_max;
227 const int below_opt_min = y < ebur128->
y_opt_min;
228 const int reached = y >= v;
230 const int colorid = 8*below_opt_min+ 4*
line + 2*reached + above_opt_max;
232 }
233
235 {
236 v += 2 * ebur128->
meter;
// make it in range [0;...]
238 v = ebur128->
scale_range - v;
// invert value (y=0 is on top)
239 return v * ebur128->
graph.
h / ebur128->
scale_range;
// rescale from scale range to px height
240 }
241
244
246 0xdd, 0xdd, 0x00,
247 0x00, 0x96, 0x96,
248 };
249
251 {
253 char buf[128] = {0};
254 const uint8_t *font;
255 int font_height;
256 va_list vl;
257
260 else return;
261
262 va_start(vl, fmt);
264 va_end(vl);
265
266 for (
i = 0; buf[
i];
i++) {
268 uint8_t *p = pic->
data[0] + y*pic->
linesize[0] + (x +
i*8)*3;
269
270 for (char_y = 0; char_y < font_height; char_y++) {
272 if (font[buf[
i] * font_height + char_y] &
mask)
274 else
275 memcpy(p, "\x00\x00\x00", 3);
276 p += 3;
277 }
279 }
280 }
281 }
282
284 {
287
288 for (
i = 0;
i <
len;
i++) {
289 memcpy(p, "\x00\xff\x00", 3);
291 }
292 }
293
295 {
297 uint8_t *p;
301
302 /* check if there is enough space to represent everything decently */
303 if (ebur128->
w < 640 || ebur128->
h < 480) {
305 "minimum size is 640x480\n", ebur128->
w, ebur128->
h);
307 }
308 outlink->
w = ebur128->
w;
309 outlink->
h = ebur128->
h;
313
314 #define PAD 8
315
316 /* configure text area position and size */
318 ebur128->
text.
y = 40;
319 ebur128->
text.
w = 3 * 8;
// 3 characters
321
322 /* configure gauge position and size */
327
328 /* configure graph position and size */
333
334 /* graph and gauge share the LU-to-pixel code */
336
337 /* prepare the initial picref buffer */
341 if (!outpicref)
344
345 /* init y references values (to draw LU lines) */
349
350 /* black background */
351 for (
int y = 0; y < ebur128->
h; y++)
352 memset(outpicref->
data[0] + y * outpicref->
linesize[0], 0, ebur128->
w * 3);
353
354 /* draw LU legends */
358 x =
PAD + (i < 10 && i > -10) * 8;
360 y -= 4; // -4 to center vertically
362 "%c%d", i < 0 ? '-' : i > 0 ?
'+' :
' ',
FFABS(
i));
363 }
364
365 /* draw graph */
371 for (y = 0; y < ebur128->
graph.
h; y++) {
373
374 for (x = 0; x < ebur128->
graph.
w; x++)
375 memcpy(p + x*3,
c, 3);
377 }
378
379 /* draw fancy rectangles around the graph and the gauge */
380 #define DRAW_RECT(r) do { \
381 drawline(outpicref, r.x, r.y - 1, r.w, 3); \
382 drawline(outpicref, r.x, r.y + r.h, r.w, 3); \
383 drawline(outpicref, r.x - 1, r.y, r.h, outpicref->linesize[0]); \
384 drawline(outpicref, r.x + r.w, r.y, r.h, outpicref->linesize[0]); \
385 } while (0)
388
389 return 0;
390 }
391
393 {
396
397 /* Unofficial reversed parametrization of PRE
398 * and RLB from 48kHz */
399
400 double f0 = 1681.974450955533;
401 double G = 3.999843853973347;
402 double Q = 0.7071752369554196;
403
404 double K = tan(
M_PI * f0 / (
double)
inlink->sample_rate);
405 double Vh = pow(10.0,
G / 20.0);
406 double Vb = pow(Vh, 0.4996667741545416);
407
408 double a0 = 1.0 +
K /
Q +
K *
K;
409
410 ebur128->
pre_b[0] = (Vh + Vb *
K /
Q +
K *
K) /
a0;
411 ebur128->
pre_b[1] = 2.0 * (
K *
K - Vh) /
a0;
412 ebur128->
pre_b[2] = (Vh - Vb *
K /
Q +
K *
K) /
a0;
413 ebur128->
pre_a[1] = 2.0 * (
K *
K - 1.0) /
a0;
415
416 f0 = 38.13547087602444;
417 Q = 0.5003270373238773;
419
420 ebur128->
rlb_b[0] = 1.0;
421 ebur128->
rlb_b[1] = -2.0;
422 ebur128->
rlb_b[2] = 1.0;
423 ebur128->
rlb_a[1] = 2.0 * (
K *
K - 1.0) / (1.0 +
K /
Q +
K *
K);
424 ebur128->
rlb_a[2] = (1.0 -
K /
Q +
K *
K) / (1.0 +
K /
Q +
K *
K);
425
426 /* Force 100ms framing in case of metadata injection: the frames must have
427 * a granularity of the window overlap to be accurately exploited.
428 * As for the true peaks mode, it just simplifies the resampling buffer
429 * allocation and the lookup in it (since sample buffers differ in size, it
430 * can be more complex to integrate in the one-sample loop of
431 * filter_frame()). */
434 return 0;
435 }
436
438 {
443
444 #define BACK_MASK (AV_CH_BACK_LEFT |AV_CH_BACK_CENTER |AV_CH_BACK_RIGHT| \
445 AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_CENTER|AV_CH_TOP_BACK_RIGHT| \
446 AV_CH_SIDE_LEFT |AV_CH_SIDE_RIGHT| \
447 AV_CH_SURROUND_DIRECT_LEFT |AV_CH_SURROUND_DIRECT_RIGHT)
448
450 ebur128->
x =
av_calloc(nb_channels, 3 *
sizeof(*ebur128->
x));
451 ebur128->
y =
av_calloc(nb_channels, 3 *
sizeof(*ebur128->
y));
452 ebur128->
z =
av_calloc(nb_channels, 3 *
sizeof(*ebur128->
z));
454 if (!ebur128->
ch_weighting || !ebur128->
x || !ebur128->
y || !ebur128->
z)
456
457 #define I400_BINS(x) ((x) * 4 / 10)
458 #define I3000_BINS(x) ((x) * 3)
459
467
468 for (
i = 0;
i < nb_channels;
i++) {
469 /* channel weighting */
473 }
else if (chl < 64 && (1ULL << chl) &
BACK_MASK) {
475 } else {
477 }
478
480 continue;
481
482 /* bins buffer for the two integration window (400ms and 3s) */
489 }
490
491 #if CONFIG_SWRESAMPLE
494
495 ebur128->swr_buf =
av_malloc_array(nb_channels, 19200 *
sizeof(
double));
499 if (!ebur128->swr_buf || !ebur128->
true_peaks ||
502
506
510
514 }
515 #endif
516
521 }
522
523 return 0;
524 }
525
526 #define ENERGY(loudness) (ff_exp10(((loudness) + 0.691) / 10.))
527 #define LOUDNESS(energy) (-0.691 + 10 * log10(energy))
528 #define DBFS(energy) (20 * log10(energy))
529
531 {
534
540 }
542 }
543
545 {
549
555 else
557 }
558
561 "True-peak mode requires libswresample to be performed\n");
563 }
564
565 // if meter is +9 scale, scale range is from -18 LU to +9 LU (or 3*9)
566 // if meter is +18 scale, scale range is from -36 LU to +18 LU (or 3*18)
568
573
576
577 /* insert output pads */
583 };
587 }
592 };
596
597 /* summary */
599
600 return 0;
601 }
602
603 #define HIST_POS(power) (int)(((power) - ABS_THRES) * HIST_GRAIN)
604
605 /* loudness and power should be set such as loudness = -0.691 +
606 * 10*log10(power), we just avoid doing that calculus two times */
609 {
610 int ipower;
611 double relative_threshold;
612 int gate_hist_pos;
613
614 /* update powers histograms by incrementing current power count */
617
618 /* compute relative threshold and get its position in the histogram */
622 if (!relative_threshold)
623 relative_threshold = 1e-12;
626
627 return gate_hist_pos;
628 }
629
631 {
632 int i, ch, idx_insample,
ret;
637 const double *
samples = (
double *)insamples->
data[0];
639
640 #if CONFIG_SWRESAMPLE
642 const double *swr_samples = ebur128->swr_buf;
643 int ret =
swr_convert(ebur128->swr_ctx, (uint8_t**)&ebur128->swr_buf, 19200,
644 (
const uint8_t **)insamples->
data, nb_samples);
647 for (ch = 0; ch < nb_channels; ch++)
649 for (idx_insample = 0; idx_insample <
ret; idx_insample++) {
650 for (ch = 0; ch < nb_channels; ch++) {
654 swr_samples++;
655 }
656 }
657 }
658 #endif
659
660 for (idx_insample = ebur128->
idx_insample; idx_insample < nb_samples; idx_insample++) {
663
664 #define MOVE_TO_NEXT_CACHED_ENTRY(time) do { \
665 ebur128->i##time.cache_pos++; \
666 if (ebur128->i##time.cache_pos == \
667 ebur128->i##time.cache_size) { \
668 ebur128->i##time.filled = 1; \
669 ebur128->i##time.cache_pos = 0; \
670 } \
671 } while (0)
672
675
676 for (ch = 0; ch < nb_channels; ch++) {
677 double bin;
678
681
682 ebur128->
x[ch * 3] =
samples[idx_insample * nb_channels + ch];
// set X[i]
683
685 continue;
686
687 /* Y[i] = X[i]*b0 + X[i-1]*b1 + X[i-2]*b2 - Y[i-1]*a1 - Y[i-2]*a2 */
688 #define FILTER(Y, X, NUM, DEN) do { \
689 double *dst = ebur128->Y + ch*3; \
690 double *src = ebur128->X + ch*3; \
691 dst[2] = dst[1]; \
692 dst[1] = dst[0]; \
693 dst[0] = src[0]*NUM[0] + src[1]*NUM[1] + src[2]*NUM[2] \
694 - dst[1]*DEN[1] - dst[2]*DEN[2]; \
695 } while (0)
696
697 // TODO: merge both filters in one?
699 ebur128->
x[ch * 3 + 2] = ebur128->
x[ch * 3 + 1];
700 ebur128->
x[ch * 3 + 1] = ebur128->
x[ch * 3 ];
702
703 bin = ebur128->
z[ch * 3] * ebur128->
z[ch * 3];
704
705 /* add the new value, and limit the sum to the cache size (400ms or 3s)
706 * by removing the oldest one */
709
710 /* override old cache entry with the new value */
711 ebur128->
i400.
cache [ch][bin_id_400 ] = bin;
713 }
714
715 #define FIND_PEAK(global, sp, ptype) do { \
716 int ch; \
717 double maxpeak; \
718 maxpeak = 0.0; \
719 if (ebur128->peak_mode & PEAK_MODE_ ## ptype ## _PEAKS) { \
720 for (ch = 0; ch < ebur128->nb_channels; ch++) \
721 maxpeak = FFMAX(maxpeak, sp[ch]); \
722 global = DBFS(maxpeak); \
723 } \
724 } while (0)
725
728
729 /* For integrated loudness, gating blocks are 400ms long with 75%
730 * overlap (see BS.1770-2 p5), so a re-computation is needed each 100ms
731 * (4800 samples at 48kHz). */
733 double loudness_400, loudness_3000;
734 double power_400 = 1e-12, power_3000 = 1e-12;
739
741
742 #define COMPUTE_LOUDNESS(m, time) do { \
743 if (ebur128->i##time.filled) { \
744 /* weighting sum of the last <time> ms */ \
745 for (ch = 0; ch < nb_channels; ch++) \
746 power_##time += ebur128->ch_weighting[ch] * ebur128->i##time.sum[ch]; \
747 power_##time /= I##time##_BINS(inlink->sample_rate); \
748 } \
749 loudness_##time = LOUDNESS(power_##time); \
750 } while (0)
751
754
755 /* Integrated loudness */
756 #define I_GATE_THRES -10 // initially defined to -8 LU in the first EBU standard
757
759 double integrated_sum = 0.0;
760 uint64_t nb_integrated = 0;
763
764 /* compute integrated loudness by summing the histogram values
765 * above the relative threshold */
768 nb_integrated += nb_v;
770 }
771 if (nb_integrated) {
773 /* dual-mono correction */
774 if (nb_channels == 1 && ebur128->
dual_mono) {
776 }
777 }
778 }
779
780 /* LRA */
781 #define LRA_GATE_THRES -20
782 #define LRA_LOWER_PRC 10
783 #define LRA_HIGHER_PRC 95
784
785 /* XXX: example code in EBU 3342 is ">=" but formula in BS.1770
786 * specs is ">" */
788 uint64_t nb_powers = 0;
791
795 uint64_t n, nb_pow;
796
797 /* get lower loudness to consider */
798 n = 0;
802 if (n >= nb_pow) {
804 break;
805 }
806 }
807
808 /* get higher loudness to consider */
809 n = nb_powers;
813 if (n < nb_pow) {
815 break;
816 }
817 }
818
819 // XXX: show low & high on the graph?
821 }
822 }
823
824 /* dual-mono correction */
825 if (nb_channels == 1 && ebur128->
dual_mono) {
826 loudness_400 -= ebur128->
pan_law;
827 loudness_3000 -= ebur128->
pan_law;
828 }
829
830 #define LOG_FMT "TARGET:%d LUFS M:%6.1f S:%6.1f I:%6.1f %s LRA:%6.1f LU"
831
832 /* push one video frame */
835 int x, y;
836 uint8_t *p;
837 double gauge_value;
838 int y_loudness_lu_graph, y_loudness_lu_gauge;
839
841 gauge_value = loudness_400 - ebur128->
target;
842 } else {
843 gauge_value = loudness_3000 - ebur128->
target;
844 }
845
846 y_loudness_lu_graph =
lu_to_y(ebur128, loudness_3000 - ebur128->
target);
847 y_loudness_lu_gauge =
lu_to_y(ebur128, gauge_value);
848
854 }
856 /* draw the graph using the short-term loudness */
858 for (y = 0; y < ebur128->
graph.
h; y++) {
860
861 memmove(p, p + 3, (ebur128->
graph.
w - 1) * 3);
862 memcpy(p + (ebur128->
graph.
w - 1) * 3,
c, 3);
863 p += pic->linesize[0];
864 }
865
866 /* draw the gauge using either momentary or short-term loudness */
867 p = pic->data[0] + ebur128->
gauge.
y*pic->linesize[0] + ebur128->
gauge.
x*3;
868 for (y = 0; y < ebur128->
gauge.
h; y++) {
870
871 for (x = 0; x < ebur128->
gauge.
w; x++)
872 memcpy(p + x*3,
c, 3);
873 p += pic->linesize[0];
874 }
875
876 /* draw textual info */
879 LOG_FMT " ",
// padding to erase trailing characters
880 ebur128->
target, loudness_400, loudness_3000,
882 } else {
884 LOG_FMT " ",
// padding to erase trailing characters
887 }
888
889 /* set pts and push frame */
891 pic->duration = 1;
893 if (!clone)
898 }
899
900 if (ebur128->
metadata) {
/* happens only once per filter_frame call */
901 char metabuf[128];
902 #define META_PREFIX "lavfi.r128."
903
904 #define SET_META(name, var) do { \
905 snprintf(metabuf, sizeof(metabuf), "%.3f", var); \
906 av_dict_set(&insamples->metadata, name, metabuf, 0); \
907 } while (0)
908
909 #define SET_META_PEAK(name, ptype) do { \
910 if (ebur128->peak_mode & PEAK_MODE_ ## ptype ## _PEAKS) { \
911 double max_peak = 0.0; \
912 char key[64]; \
913 for (ch = 0; ch < nb_channels; ch++) { \
914 snprintf(key, sizeof(key), \
915 META_PREFIX AV_STRINGIFY(name) "_peaks_ch%d", ch); \
916 max_peak = fmax(max_peak, ebur128->name##_peaks[ch]); \
917 SET_META(key, ebur128->name##_peaks[ch]); \
918 } \
919 snprintf(key, sizeof(key), \
920 META_PREFIX AV_STRINGIFY(name) "_peak"); \
921 SET_META(key, max_peak); \
922 } \
923 } while (0)
924
931
934 }
935
940 ebur128->
target, loudness_400, loudness_3000,
942 } else {
947 }
948
949 #define PRINT_PEAKS(str, sp, ptype) do { \
950 if (ebur128->peak_mode & PEAK_MODE_ ## ptype ## _PEAKS) { \
951 av_log(ctx, ebur128->loglevel, " " str ":"); \
952 for (ch = 0; ch < nb_channels; ch++) \
953 av_log(ctx, ebur128->loglevel, " %5.1f", DBFS(sp[ch])); \
954 av_log(ctx, ebur128->loglevel, " dBFS"); \
955 } \
956 } while (0)
957
962 }
963 }
964 }
965
968
970 }
971
973 {
979
983
986
989 } else {
991 }
996 }
997
1000
1005
1007 }
1008
1010 {
1017
1020
1021 /* set optional output video format */
1026 outlink =
ctx->outputs[1];
1027 }
1028
1029 /* set input and output audio formats
1030 * Note: ff_set_common_* functions are not used because they affect all the
1031 * links, and thus break the video format negotiation */
1036
1041
1046
1047 return 0;
1048 }
1049
1051 {
1053
1054 /* dual-mono correction */
1060 }
1061
1064 " Integrated loudness:\n"
1065 " I: %5.1f LUFS\n"
1066 " Threshold: %5.1f LUFS\n\n"
1067 " Loudness range:\n"
1068 " LRA: %5.1f LU\n"
1069 " Threshold: %5.1f LUFS\n"
1070 " LRA low: %5.1f LUFS\n"
1071 " LRA high: %5.1f LUFS",
1075
1076 #define PRINT_PEAK_SUMMARY(str, value, ptype) do { \
1077 if (ebur128->peak_mode & PEAK_MODE_ ## ptype ## _PEAKS) { \
1078 av_log(ctx, AV_LOG_INFO, "\n\n " str " peak:\n" \
1079 " Peak: %5.1f dBFS", value); \
1080 } \
1081 } while (0)
1082
1086 }
1087
1105 }
1109 #if CONFIG_SWRESAMPLE
1112 #endif
1113 }
1114
1116 {
1120 },
1121 };
1122
1133 .priv_class = &ebur128_class,
1135 };