[FFmpeg-devel] [PATCHv3 2/2] avcodec/sinewin_tablegen: use sin instead of sinf for fixed point to improve precision

Marton Balint cus at passwd.hu
Mon Mar 14 10:48:45 CET 2016


Without this patch fixed point sinewin tables are different on x86_32 and x86_64.

Signed-off-by: Marton Balint <cus at passwd.hu>
---
 libavcodec/sinewin_tablegen.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/sinewin_tablegen.h b/libavcodec/sinewin_tablegen.h
index 4432135..bb1175d 100644
--- a/libavcodec/sinewin_tablegen.h
+++ b/libavcodec/sinewin_tablegen.h
@@ -30,6 +30,7 @@
 #include "libavcodec/aac_defines.h"
 #include "libavutil/attributes.h"
 #include "libavutil/common.h"
+#include "libavutil/tablegen.h"
 
 #if !CONFIG_HARDCODED_TABLES
 SINETABLE(  32);
@@ -50,9 +51,9 @@ SINETABLE(8192);
 #endif
 
 #if USE_FIXED
-#define SIN_FIX(a) (int)floor((a) * 0x80000000 + 0.5)
+#define SIN_FIX(a) (int)lrint(sin(a) * 0x80000000)
 #else
-#define SIN_FIX(a) a
+#define SIN_FIX(a) sinf(a)
 #endif
 
 SINETABLE_CONST INTFLOAT * const AAC_RENAME(ff_sine_windows)[] = {
@@ -66,7 +67,7 @@ SINETABLE_CONST INTFLOAT * const AAC_RENAME(ff_sine_windows)[] = {
 av_cold void AAC_RENAME(ff_sine_window_init)(INTFLOAT *window, int n) {
     int i;
     for(i = 0; i < n; i++)
-        window[i] = SIN_FIX(sinf((i + 0.5) * (M_PI / (2.0 * n))));
+        window[i] = SIN_FIX((i + 0.5) * (M_PI / (2.0 * n)));
 }
 
 av_cold void AAC_RENAME(ff_init_ff_sine_windows)(int index) {
-- 
2.6.2



More information about the ffmpeg-devel mailing list