aboutsummaryrefslogtreecommitdiff
path: root/Src/f263/idctref.cpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/f263/idctref.cpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/f263/idctref.cpp')
-rw-r--r--Src/f263/idctref.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/Src/f263/idctref.cpp b/Src/f263/idctref.cpp
new file mode 100644
index 00000000..6bab912f
--- /dev/null
+++ b/Src/f263/idctref.cpp
@@ -0,0 +1,66 @@
+#include "idctref.h"
+#include <math.h>
+#ifndef PI
+# ifdef M_PI
+# define PI M_PI
+# else
+# define PI 3.14159265358979323846
+# endif
+#endif
+
+ bool IDCTRef::initted = false;
+ double IDCTRef::c[8][8]; /* cosine transform matrix for 8x1 IDCT */
+
+
+ /* initialize DCT coefficient matrix */
+
+ void IDCTRef::init()
+ {
+ if (!initted)
+ {
+ int freq, time;
+
+ for (freq=0; freq < 8; freq++)
+ {
+ double scale = (freq == 0) ? sqrt(0.125) : 0.5;
+ for (time=0; time<8; time++)
+ c[freq][time] = scale*cos((PI/8.0)*freq*(time + 0.5));
+ }
+ initted=true;
+ }
+ }
+
+ /* perform IDCT matrix multiply for 8x8 coefficient block */
+
+ void IDCTRef::idct(short *block)
+ {
+ int i, j, k, v;
+ double partial_product;
+ double tmp[64];
+
+ for (i=0; i<8; i++)
+ for (j=0; j<8; j++)
+ {
+ partial_product = 0.0;
+
+ for (k=0; k<8; k++)
+ partial_product+= c[k][j]*block[8*i+k];
+
+ tmp[8*i+j] = partial_product;
+ }
+
+ /* Transpose operation is integrated into address mapping by switching
+ loop order of i and j */
+
+ for (j=0; j<8; j++)
+ for (i=0; i<8; i++)
+ {
+ partial_product = 0.0;
+
+ for (k=0; k<8; k++)
+ partial_product+= c[k][i]*tmp[8*k+j];
+
+ v = (int)floor(partial_product+0.5);
+ block[8*i+j] = (v<-256) ? -256 : ((v>255) ? 255 : v);
+ }
+ }