[FFmpeg-cvslog] avfilter/f_ebur128: fix video output regression

Paul B Mahol git at videolan.org
Sun Jul 25 14:18:05 EEST 2021


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Jul 25 13:04:03 2021 +0200| [6f0f7bc7fe724731ed9b4f5a2c4cd6735a918276] | committer: Paul B Mahol

avfilter/f_ebur128: fix video output regression

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6f0f7bc7fe724731ed9b4f5a2c4cd6735a918276
---

 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 <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;                                             \
+        power_##time /= I##time##_BINS(inlink->sample_rate);                        \
     }                                                                               \
     loudness_##time = LOUDNESS(power_##time);                                       \
 } while (0)



More information about the ffmpeg-cvslog mailing list