@@ -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);
}
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> --- libavcodec/kbdwin.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)