diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2023-05-23 01:19:32 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2023-05-29 00:55:52 +0200 |
commit | 988fd5743d3a286e490e1860ddef169cf8174a1b (patch) | |
tree | fdaaf4c734e243af64d0eeac768706fa21762d3c | |
parent | 17ecb224e94a3c111017843afbc255303ed01474 (diff) | |
download | ffmpeg-988fd5743d3a286e490e1860ddef169cf8174a1b.tar.gz |
avcodec/kbdwin: Remove low precision intermediate in ff_kbd_window_init_fixed()
Previously floats where scaled up to 32bit int, but floats do not
have 32bits in their mantisse so a quarter of the bits where nonsense.
It seems no fate test is affected by this change, which is interresting
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/kbdwin.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/libavcodec/kbdwin.c b/libavcodec/kbdwin.c index e2f6491124..163f9d5251 100644 --- a/libavcodec/kbdwin.c +++ b/libavcodec/kbdwin.c @@ -21,7 +21,7 @@ #include "libavutil/attributes.h" #include "kbdwin.h" -av_cold void ff_kbd_window_init(float *window, float alpha, int n) +av_cold static void kbd_window_init(float *float_window, int *int_window, float alpha, int n) { int i; double sum = 0.0, tmp; @@ -40,20 +40,22 @@ av_cold void ff_kbd_window_init(float *window, float alpha, int n) for (i = 0; i <= n / 2; i++) { sum += temp[i]; - window[i] = sqrt(sum * scale); + if (float_window) float_window[i] = sqrt(sum * scale); + else int_window[i] = lrint(2147483647 * sqrt(sum * scale)); } for (; i < n; i++) { sum += temp[n - i]; - window[i] = sqrt(sum * scale); + if (float_window) float_window[i] = sqrt(sum * scale); + else int_window[i] = lrint(2147483647 * sqrt(sum * scale)); } } -av_cold void ff_kbd_window_init_fixed(int32_t *window, float alpha, int n) +av_cold void ff_kbd_window_init(float *window, float alpha, int n) { - int i; - float local_window[FF_KBD_WINDOW_MAX]; + kbd_window_init(window, NULL, alpha, n); +} - ff_kbd_window_init(local_window, alpha, n); - for (i = 0; i < n; i++) - window[i] = (int)floor(2147483647.0 * local_window[i] + 0.5); +av_cold void ff_kbd_window_init_fixed(int32_t *window, float alpha, int n) +{ + kbd_window_init(NULL, window, alpha, n); } |