summaryrefslogtreecommitdiff
path: root/src/audio/idct.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio/idct.cpp')
-rw-r--r--src/audio/idct.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/audio/idct.cpp b/src/audio/idct.cpp
new file mode 100644
index 0000000..a32f92e
--- /dev/null
+++ b/src/audio/idct.cpp
@@ -0,0 +1,17 @@
+#include "dct.h"
+#include "util/math.h"
+#include <math.h>
+
+void idct_512(const float input[DCT_SIZE], float output[DCT_SIZE]) {
+ float scale_k0 = sqrtf(1.0f / DCT_SIZE);
+ float scale_kn = sqrtf(2.0f / DCT_SIZE);
+
+ for (int n = 0; n < DCT_SIZE; ++n) {
+ float sum = 0.0f;
+ for (int k = 0; k < DCT_SIZE; ++k) {
+ float scale = (k == 0) ? scale_k0 : scale_kn;
+ sum += scale * input[k] * cosf((PI / DCT_SIZE) * (n + 0.5f) * k);
+ }
+ output[n] = sum;
+ }
+}