[FFmpeg-cvslog] avcodec/faandct: use more accurate constants

Ganesh Ajjanagadde git at videolan.org
Sun Nov 15 16:28:32 CET 2015


ffmpeg | branch: master | Ganesh Ajjanagadde <gajjanagadde at gmail.com> | Fri Nov 13 11:19:33 2015 -0500| [064ced5dc147c9b5a33807a90f07037feec57cbe] | committer: Ganesh Ajjanagadde

avcodec/faandct: use more accurate constants

This guarantees a "best effort precision".

Reviewed-by: Michael Niedermayer <michael at niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=064ced5dc147c9b5a33807a90f07037feec57cbe
---

 libavcodec/faandct.c |   29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/libavcodec/faandct.c b/libavcodec/faandct.c
index 4053d69..fc23df0 100644
--- a/libavcodec/faandct.c
+++ b/libavcodec/faandct.c
@@ -31,23 +31,20 @@
 
 #define FLOAT float
 
-//numbers generated by simple c code (not as accurate as they could be)
-/*
-for(i=0; i<8; i++){
-    printf("#define B%d %1.20llf\n", i, (long double)1.0/(cosl(i*acosl(-1.0)/(long double)16.0)*sqrtl(2)));
-}
+/* numbers generated by arbitrary precision arithmetic followed by truncation
+to 36 fractional digits (enough for a 128-bit IEEE quad, see /usr/include/math.h
+for this approach). This guarantees a "best effort precision".
 */
-#define B0 1.00000000000000000000
-#define B1 0.72095982200694791383 // (cos(pi*1/16)sqrt(2))^-1
-#define B2 0.76536686473017954350 // (cos(pi*2/16)sqrt(2))^-1
-#define B3 0.85043009476725644878 // (cos(pi*3/16)sqrt(2))^-1
-#define B4 1.00000000000000000000 // (cos(pi*4/16)sqrt(2))^-1
-#define B5 1.27275858057283393842 // (cos(pi*5/16)sqrt(2))^-1
-#define B6 1.84775906502257351242 // (cos(pi*6/16)sqrt(2))^-1
-#define B7 3.62450978541155137218 // (cos(pi*7/16)sqrt(2))^-1
-
-
-#define A1 0.70710678118654752438 // cos(pi*4/16)
+#define B0 1.000000000000000000000000000000000000L
+#define B1 0.720959822006947913789091890943021267L // (cos(pi*1/16)sqrt(2))^-1
+#define B2 0.765366864730179543456919968060797734L // (cos(pi*2/16)sqrt(2))^-1
+#define B3 0.850430094767256448766702844371412325L // (cos(pi*3/16)sqrt(2))^-1
+#define B4 1.000000000000000000000000000000000000L // (cos(pi*4/16)sqrt(2))^-1
+#define B5 1.272758580572833938461007018281767032L // (cos(pi*5/16)sqrt(2))^-1
+#define B6 1.847759065022573512256366378793576574L // (cos(pi*6/16)sqrt(2))^-1
+#define B7 3.624509785411551372409941227504289587L // (cos(pi*7/16)sqrt(2))^-1
+
+#define A1 M_SQRT1_2              // cos(pi*4/16)
 #define A2 0.54119610014619698435 // cos(pi*6/16)sqrt(2)
 #define A5 0.38268343236508977170 // cos(pi*6/16)
 #define A4 1.30656296487637652774 // cos(pi*2/16)sqrt(2)



More information about the ffmpeg-cvslog mailing list