[FFmpeg-cvslog] avcodec/kbdwin: Use av_bessel_i0()
Michael Niedermayer
git at videolan.org
Mon May 29 02:00:51 EEST 2023
ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Tue May 23 00:17:58 2023 +0200| [4ea87c0f73d4178fd5dd60cf8ec19e5e71508c9c] | committer: Michael Niedermayer
avcodec/kbdwin: Use av_bessel_i0()
Old code used about 7 times as many cpu cycles as new
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4ea87c0f73d4178fd5dd60cf8ec19e5e71508c9c
---
libavcodec/kbdwin.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/libavcodec/kbdwin.c b/libavcodec/kbdwin.c
index bf32aeb317..5dff334250 100644
--- a/libavcodec/kbdwin.c
+++ b/libavcodec/kbdwin.c
@@ -21,8 +21,6 @@
#include "libavutil/attributes.h"
#include "kbdwin.h"
-#define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation
-
av_cold void ff_kbd_window_init(float *window, float alpha, int n)
{
int i, j;
@@ -34,9 +32,7 @@ av_cold void ff_kbd_window_init(float *window, float alpha, int n)
for (i = 0; i < n; i++) {
tmp = i * (n - i) * alpha2;
- bessel = 1.0;
- for (j = BESSEL_I0_ITER; j > 0; j--)
- bessel = bessel * tmp / (j * j) + 1;
+ bessel = av_bessel_i0(sqrt(tmp) * 2);
sum += bessel;
local_window[i] = sum;
}
More information about the ffmpeg-cvslog
mailing list