[FFmpeg-cvslog] avfilter/af_dialoguenhance: do output scaling once

Paul B Mahol git at videolan.org
Mon Nov 27 12:49:10 EET 2023


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Nov 27 11:52:37 2023 +0100| [f1f973313b6edc460339c2dfa4675dd3ad72fe98] | committer: Paul B Mahol

avfilter/af_dialoguenhance: do output scaling once

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

 libavfilter/af_dialoguenhance.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/libavfilter/af_dialoguenhance.c b/libavfilter/af_dialoguenhance.c
index 5c8614c185..2674313f5c 100644
--- a/libavfilter/af_dialoguenhance.c
+++ b/libavfilter/af_dialoguenhance.c
@@ -108,7 +108,7 @@ static int config_input(AVFilterLink *inlink)
 
     generate_window_func(s->window, s->fft_size, WFUNC_SINE, &overlap);
 
-    iscale = 1.f / s->fft_size;
+    iscale = 1.f / (s->fft_size * 1.5f);
 
     ret = av_tx_init(&s->tx_ctx[0], &s->tx_fn, AV_TX_FLOAT_RDFT, 0, s->fft_size, &scale, 0);
     if (ret < 0)
@@ -296,13 +296,10 @@ static int de_stereo(AVFilterContext *ctx, AVFrame *out)
     memcpy(left_osamples, left_in, overlap * sizeof(float));
     memcpy(right_osamples, right_in, overlap * sizeof(float));
 
-    // 4 times overlap with squared hanning window results in 1.5 time increase in amplitude
-    if (!ctx->is_disabled) {
-        for (int i = 0; i < overlap; i++)
-            center_osamples[i] = left_out[i] / 1.5f;
-    } else {
+    if (ctx->is_disabled)
         memset(center_osamples, 0, overlap * sizeof(float));
-    }
+    else
+        memcpy(center_osamples, left_out, overlap * sizeof(float));
 
     return 0;
 }



More information about the ffmpeg-cvslog mailing list