[FFmpeg-cvslog] avfilter/avf_showcwt: keep kernels precision as high as possible

Paul B Mahol git at videolan.org
Fri Jul 28 23:27:06 EEST 2023


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Jul 28 21:13:05 2023 +0200| [dca54600f0672f8f54cb61188a0bd35e7b4a53f2] | committer: Paul B Mahol

avfilter/avf_showcwt: keep kernels precision as high as possible

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

 libavfilter/avf_showcwt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavfilter/avf_showcwt.c b/libavfilter/avf_showcwt.c
index 1451bfb1e0..1bf874c97b 100644
--- a/libavfilter/avf_showcwt.c
+++ b/libavfilter/avf_showcwt.c
@@ -583,6 +583,7 @@ static int run_channel_cwt(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo
     AVComplexFloat *isrc = (AVComplexFloat *)s->ifft_in->extended_data[jobnr];
     AVComplexFloat *idst = (AVComplexFloat *)s->ifft_out->extended_data[jobnr];
     const int output_padding_size = s->output_padding_size;
+    const float scale = 1.f / s->input_padding_size;
     const int ihop_size = s->ihop_size;
     const int count = s->frequency_band_count;
     const int start = (count * jobnr) / nb_jobs;
@@ -601,6 +602,7 @@ static int run_channel_cwt(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo
 
         memcpy(srcx, fft_out + kernel_start, sizeof(*fft_out) * kernel_range);
 
+        s->fdsp->vector_fmul_scalar((float *)srcx, (const float *)srcx, scale, FFALIGN(kernel_range * 2, 4));
         s->fdsp->vector_fmul((float *)dstx, (const float *)srcx,
                              (const float *)kernel, FFALIGN(kernel_range * 2, 16));
 
@@ -630,7 +632,6 @@ static int compute_kernel(AVFilterContext *ctx)
     ShowCWTContext *s = ctx->priv;
     const float correction = s->input_padding_size / (float)s->input_sample_count;
     const int size = s->input_sample_count;
-    const float scale_factor = 1.f/(float)size;
     const int output_sample_count = s->output_sample_count;
     const int fsize = s->frequency_band_count;
     int *kernel_start = s->kernel_start;
@@ -655,7 +656,7 @@ static int compute_kernel(AVFilterContext *ctx)
         for (int n = 0; n < size; n++) {
             float ff, f = fabsf(n-frequency);
 
-            ff = expf(-f*f*deviation) * scale_factor;
+            ff = expf(-f*f*deviation);
             tkernel[n] = ff;
         }
 



More information about the ffmpeg-cvslog mailing list