mirror of https://git.ffmpeg.org/ffmpeg.git
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>
This commit is contained in:
parent
17ecb224e9
commit
988fd5743d
|
@ -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(float *window, float alpha, int n)
|
||||
{
|
||||
kbd_window_init(window, NULL, alpha, n);
|
||||
}
|
||||
|
||||
av_cold void ff_kbd_window_init_fixed(int32_t *window, float alpha, int n)
|
||||
{
|
||||
int i;
|
||||
float local_window[FF_KBD_WINDOW_MAX];
|
||||
|
||||
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);
|
||||
kbd_window_init(NULL, window, alpha, n);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue