63 const int size2 =
_size >> 1;
64 const int size4 =
_size >> 2;
69 const double theta = 1.0 / 8.0 + (scale < 0 ? size4 : 0);
71 scale = sqrt(
ABS(scale));
72 for (
int i = 0; i < size4; i++) {
73 const double alpha = 2 *
M_PI * (i + theta) /
_size;
75 _tCos[i] = -cos(alpha) * scale;
76 _tSin[i] = -sin(alpha) * scale;
83 #define CMUL(dre, dim, are, aim, bre, bim) do { \ 84 (dre) = (are) * (bre) - (aim) * (bim); \ 85 (dim) = (are) * (bim) + (aim) * (bre); \ 91 const int size2 =
_size >> 1;
92 const int size4 =
_size >> 2;
93 const int size8 =
_size >> 3;
94 const int size3 =
_size * 3;
99 for (
int i = 0; i < size8; i++) {
100 float re = -input[2 * i + size3] - input[size3 - 1 - 2 * i];
101 float im = -input[2 * i + size4] + input[size4 - 1 - 2 * i];
106 re = input[2 * i ] - input[size2 - 1 - 2 * i];
107 im = -input[2 * i + size2] - input[
_size - 1 - 2 * i];
108 j = revTab[size8 + i];
110 CMUL(x[j].re, x[j].im, re, im, -
_tCos[size8 + i],
_tSin[size8 + i]);
116 for (
int i = 0; i < size8; i++) {
117 float r0, i0, r1, i1;
119 CMUL(i1, r0, x[size8-i-1].re, x[size8-i-1].im, -
_tSin[size8-i-1], -
_tCos[size8-i-1]);
120 CMUL(i0, r1, x[size8+i ].re, x[size8+i ].im, -
_tSin[size8+i ], -
_tCos[size8+i ]);
122 x[size8 - i - 1].
re = r0;
123 x[size8 - i - 1].
im = i0;
124 x[size8 + i ].
re = r1;
125 x[size8 + i ].
im = i1;
130 const int size2 =
_size >> 1;
131 const int size4 =
_size >> 2;
135 for (
int k = 0; k < size4; k++) {
136 output[ k ] = -output[size2 - k - 1];
137 output[
_size - k - 1] = output[size2 + k ];
144 const int size2 =
_size >> 1;
145 const int size4 =
_size >> 2;
146 const int size8 =
_size >> 3;
151 const float *in1 = input;
152 const float *in2 = input + size2 - 1;
153 for (
int k = 0; k < size4; k++) {
154 const int j = revTab[k];
165 for (
int k = 0; k < size8; k++) {
166 float r0, i0, r1, i1;
168 CMUL(r0, i1, z[size8-k-1].im, z[size8-k-1].re,
_tSin[size8-k-1],
_tCos[size8-k-1]);
169 CMUL(r1, i0, z[size8+k ].im, z[size8+k ].re,
_tSin[size8+k ],
_tCos[size8+k ]);
171 z[size8 - k - 1].
re = r0;
172 z[size8 - k - 1].
im = i0;
173 z[size8 + k ].
re = r1;
174 z[size8 + k ].
im = i1;
(Inverse) Modified Discrete Cosine Transforms.
void reset(PointerType o=0)
Resets the pointer with the new value.
void calcHalfIMDCT(float *output, const float *input)
Compute the middle half of the inverse MDCT of size N = 2^nbits, thus excluding the parts that can be...
Utility templates and functions.
ScopedArray< float > _tCos
#define CMUL(dre, dim, are, aim, bre, bim)
void calcIMDCT(float *output, const float *input)
Compute inverse MDCT of size N = 2^nbits.
PointerType get() const
Returns the plain pointer value.
static glm::mat4 inverse(const glm::mat4 &m)
(Inverse) Fast Fourier Transform.
(Inverse) Fast Fourier Transform.
void calcMDCT(float *output, const float *input)
Compute MDCT of size N = 2^nbits.
MDCT(int bits, bool inverse, double scale)