diff options
author | Ganesh Ajjanagadde <gajjanagadde@gmail.com> | 2015-11-13 19:19:33 +0300 |
---|---|---|
committer | Ganesh Ajjanagadde <gajjanagadde@gmail.com> | 2015-11-15 18:26:26 +0300 |
commit | 064ced5dc147c9b5a33807a90f07037feec57cbe (patch) | |
tree | 0f2d6725fb661747b8891285e798ada5894cbe9a /libavcodec/faandct.c | |
parent | 2d8c2f1a28073d451c7db31291c333cb15ca3d0b (diff) |
avcodec/faandct: use more accurate constants
This guarantees a "best effort precision".
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Diffstat (limited to 'libavcodec/faandct.c')
-rw-r--r-- | libavcodec/faandct.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/libavcodec/faandct.c b/libavcodec/faandct.c index 4053d69db1..fc23df0796 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) |