diff options
author | Kyle Swanson <k@ylo.ph> | 2015-09-30 10:35:08 -0500 |
---|---|---|
committer | Clément Bœsch <u@pkh.me> | 2015-10-04 13:10:26 +0200 |
commit | 4f721bfd46120aa2a7c7cdcbdd7c8db3b767dd1d (patch) | |
tree | e4a4a7f82a0265e6720dc3c3722304725586492d /libavfilter | |
parent | a2b8b163004e643d27d85dcafd220c0ffcce8f59 (diff) | |
download | ffmpeg-4f721bfd46120aa2a7c7cdcbdd7c8db3b767dd1d.tar.gz |
avfilter/ebur128: add dualmono measurement option
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/f_ebur128.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c index 1d5c8fd0f1..c63356fbca 100644 --- a/libavfilter/f_ebur128.c +++ b/libavfilter/f_ebur128.c @@ -139,6 +139,8 @@ typedef struct { /* misc */ int loglevel; ///< log level for frame logging int metadata; ///< whether or not to inject loudness results in frames + int dual_mono; ///< whether or not to treat single channel input files as dual-mono + double pan_law; ///< pan law value used to calulate dual-mono measurements } EBUR128Context; enum { @@ -163,6 +165,8 @@ static const AVOption ebur128_options[] = { { "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 }, { NULL }, }; @@ -661,6 +665,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) } if (nb_integrated) ebur128->integrated_loudness = LOUDNESS(integrated_sum / nb_integrated); + /* dual-mono correction */ + if (nb_channels == 1 && ebur128->dual_mono) { + ebur128->integrated_loudness -= ebur128->pan_law; + } } /* LRA */ @@ -707,6 +715,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) } } + /* dual-mono correction */ + if (nb_channels == 1 && ebur128->dual_mono) { + loudness_400 -= ebur128->pan_law; + loudness_3000 -= ebur128->pan_law; + } + #define LOG_FMT "M:%6.1f S:%6.1f I:%6.1f LUFS LRA:%6.1f LU" /* push one video frame */ @@ -855,6 +869,14 @@ static av_cold void uninit(AVFilterContext *ctx) int i; EBUR128Context *ebur128 = ctx->priv; + /* dual-mono correction */ + if (ebur128->nb_channels == 1 && ebur128->dual_mono) { + ebur128->i400.rel_threshold -= ebur128->pan_law; + ebur128->i3000.rel_threshold -= ebur128->pan_law; + ebur128->lra_low -= ebur128->pan_law; + ebur128->lra_high -= ebur128->pan_law; + } + av_log(ctx, AV_LOG_INFO, "Summary:\n\n" " Integrated loudness:\n" " I: %5.1f LUFS\n" |