From 6f0f7bc7fe724731ed9b4f5a2c4cd6735a918276 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sun, 25 Jul 2021 13:04:03 +0200 Subject: [PATCH] avfilter/f_ebur128: fix video output regression --- doc/filters.texi | 2 +- libavfilter/f_ebur128.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index b0d73abe5c..60b8b2886c 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -25286,7 +25286,7 @@ level. By default, it logs a message at a frequency of 10Hz with the Momentary loudness (identified by @code{M}), Short-term loudness (@code{S}), Integrated loudness (@code{I}) and Loudness Range (@code{LRA}). -The filter can only analyze streams which have a sampling rate of 48000 Hz and whose +The filter can only analyze streams which have sample format is double-precision floating point. The input stream will be converted to this specification, if needed. Users may need to insert aformat and/or aresample filters after this filter to obtain the original parameters. diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c index c4e77f434d..bf7bb3af68 100644 --- a/libavfilter/f_ebur128.c +++ b/libavfilter/f_ebur128.c @@ -435,8 +435,8 @@ static int config_audio_output(AVFilterLink *outlink) if (!ebur128->ch_weighting) return AVERROR(ENOMEM); -#define I400_BINS (outlink->sample_rate * 4 / 10) -#define I3000_BINS (outlink->sample_rate * 3) +#define I400_BINS(x) ((x) * 4 / 10) +#define I3000_BINS(x) ((x) * 3) for (i = 0; i < nb_channels; i++) { /* channel weighting */ @@ -453,8 +453,8 @@ static int config_audio_output(AVFilterLink *outlink) continue; /* bins buffer for the two integration window (400ms and 3s) */ - ebur128->i400.cache_size = I400_BINS; - ebur128->i3000.cache_size = I3000_BINS; + ebur128->i400.cache_size = I400_BINS(outlink->sample_rate); + ebur128->i3000.cache_size = I3000_BINS(outlink->sample_rate); ebur128->i400.cache[i] = av_calloc(ebur128->i400.cache_size, sizeof(*ebur128->i400.cache[0])); ebur128->i3000.cache[i] = av_calloc(ebur128->i3000.cache_size, sizeof(*ebur128->i3000.cache[0])); if (!ebur128->i400.cache[i] || !ebur128->i3000.cache[i]) @@ -687,7 +687,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) /* For integrated loudness, gating blocks are 400ms long with 75% * overlap (see BS.1770-2 p5), so a re-computation is needed each 100ms * (4800 samples at 48kHz). */ - if (++ebur128->sample_count == 4800) { + if (++ebur128->sample_count == inlink->sample_rate / 10) { double loudness_400, loudness_3000; double power_400 = 1e-12, power_3000 = 1e-12; AVFilterLink *outlink = ctx->outputs[0]; @@ -702,7 +702,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) /* weighting sum of the last