diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2017-04-22 17:41:45 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2017-04-22 17:41:45 +0000 |
commit | 79f1c6bf5a89a4e92fbfb8e6930086ea98877c35 (patch) | |
tree | a1c9b54e7007e0a4d47dae06c48808ee07a97407 | |
parent | fee986a7aa6ca2310366ae61620f521c5409c313 (diff) | |
download | netpbm-mirror-79f1c6bf5a89a4e92fbfb8e6930086ea98877c35.tar.gz netpbm-mirror-79f1c6bf5a89a4e92fbfb8e6930086ea98877c35.tar.xz netpbm-mirror-79f1c6bf5a89a4e92fbfb8e6930086ea98877c35.zip |
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2963 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r-- | converter/ppm/ppmtompeg/jrevdct.c | 44 | ||||
-rw-r--r-- | converter/ppm/ppmtompeg/mfwddct.c | 31 |
2 files changed, 35 insertions, 40 deletions
diff --git a/converter/ppm/ppmtompeg/jrevdct.c b/converter/ppm/ppmtompeg/jrevdct.c index bf9196c4..f7b32192 100644 --- a/converter/ppm/ppmtompeg/jrevdct.c +++ b/converter/ppm/ppmtompeg/jrevdct.c @@ -26,7 +26,11 @@ * matrix, perhaps with the difference cases encoded. */ +#define _XOPEN_SOURCE /* Make sure M_PI is in math.h */ + #include <memory.h> +#include <math.h> + #include "all.h" #include "dct.h" @@ -1211,35 +1215,29 @@ mpeg_jrevdct_quick(data) */ -/* Here we use math.h to generate constants. Compiler results may - vary a little */ - -#ifndef PI -#ifdef M_PI -#define PI M_PI -#else -#define PI 3.14159265358979323846 -#endif -#endif - /* cosine transform matrix for 8x1 IDCT */ static double itrans_coef[8][8]; -/* initialize DCT coefficient matrix */ -void init_idctref() -{ - int freq, time; - double scale; - - for (freq=0; freq < 8; freq++) - { - scale = (freq == 0) ? sqrt(0.125) : 0.5; - for (time=0; time<8; time++) - itrans_coef[freq][time] = scale*cos((PI/8.0)*freq*(time + 0.5)); - } + +void init_idctref() { +/*---------------------------------------------------------------------------- + initialize DCT coefficient matrix +-----------------------------------------------------------------------------*/ + unsigned int freq; + + for (freq=0; freq < 8; ++freq) { + double const scale = (freq == 0) ? sqrt(0.125) : 0.5; + + unsigned int time; + + for (time = 0; time < 8; ++time) + itrans_coef[freq][time] = scale*cos((M_PI/8.0)*freq*(time + 0.5)); + } } + + /* perform IDCT matrix multiply for 8x8 coefficient block */ void reference_rev_dct(block) diff --git a/converter/ppm/ppmtompeg/mfwddct.c b/converter/ppm/ppmtompeg/mfwddct.c index 75c3a718..ce85436d 100644 --- a/converter/ppm/ppmtompeg/mfwddct.c +++ b/converter/ppm/ppmtompeg/mfwddct.c @@ -15,6 +15,10 @@ * instead of floating point. */ +#define _XOPEN_SOURCE /* Make sure M_PI is in math.h */ + +#include <math.h> + #include "all.h" #include "dct.h" @@ -375,26 +379,19 @@ mp_fwd_dct_block2(data, dest) * */ -#ifndef PI -#ifdef M_PI -#define PI M_PI -#else -#define PI 3.14159265358979323846 -#endif -#endif -void init_fdct() -{ - int i, j; - double s; +void init_fdct() { - for (i=0; i<8; i++) - { - s = (i==0) ? sqrt(0.125) : 0.5; + unsigned int i; - for (j=0; j<8; j++) - trans_coef[i][j] = s * cos((PI/8.0)*i*(j+0.5)); - } + for (i = 0; i < 8; ++i) { + double const s = i == 0 ? sqrt(0.125) : 0.5; + + unsigned int j; + + for (j = 0; j < 8; ++j) + trans_coef[i][j] = s * cos((M_PI/8.0) * i * (j+0.5)); + } } |