diff options
author | Paul B Mahol <onemda@gmail.com> | 2021-11-18 22:14:11 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2021-11-18 22:23:28 +0100 |
commit | 8c150d3d9794c29a54bbdf2f2a88066277c7197e (patch) | |
tree | a4bb4e989afe8ca31334bf0e76a1658a5a2a65b3 | |
parent | 2f472d5d653ae3b8e7d99e2449ae8fb71b502e6d (diff) | |
download | ffmpeg-8c150d3d9794c29a54bbdf2f2a88066277c7197e.tar.gz |
avfilter/af_drmeter: improve measurement precision
-rw-r--r-- | libavfilter/af_drmeter.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libavfilter/af_drmeter.c b/libavfilter/af_drmeter.c index 1ff769a29f..6e0d80a3f1 100644 --- a/libavfilter/af_drmeter.c +++ b/libavfilter/af_drmeter.c @@ -26,7 +26,7 @@ #include "avfilter.h" #include "internal.h" -#define BINS 10000 +#define BINS 32768 typedef struct ChannelStats { uint64_t nb_samples; @@ -75,8 +75,8 @@ static void finish_block(ChannelStats *p) rms = sqrt(2 * p->sum / p->nb_samples); peak = p->peak; - rms_bin = av_clip(rms * BINS, 0, BINS); - peak_bin = av_clip(peak * BINS, 0, BINS); + rms_bin = av_clip(lrintf(rms * BINS), 0, BINS); + peak_bin = av_clip(lrintf(peak * BINS), 0, BINS); p->rms[rms_bin]++; p->peaks[peak_bin]++; @@ -158,7 +158,7 @@ static void print_stats(AVFilterContext *ctx) for (i = BINS, j = 0; i >= 0 && j < 0.2 * p->blknum; i--) { if (p->rms[i]) { - rmssum += SQR(i / (double)BINS) * p->rms[i]; + rmssum += SQR(i / (double)BINS); j += p->rms[i]; } } |