aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMatthew Hoops2011-07-19 10:23:16 -0400
committerMatthew Hoops2011-07-19 10:31:03 -0400
commit9ad45e28a19917fb11893f2712a9cab53c2142c8 (patch)
treedca34882991502f5379d6ce21f13f39544200347 /common
parentb3e6899f900226c4afd44cee68b06453258e1ac8 (diff)
downloadscummvm-rg350-9ad45e28a19917fb11893f2712a9cab53c2142c8.tar.gz
scummvm-rg350-9ad45e28a19917fb11893f2712a9cab53c2142c8.tar.bz2
scummvm-rg350-9ad45e28a19917fb11893f2712a9cab53c2142c8.zip
COMMON: Fix some formatting
Diffstat (limited to 'common')
-rw-r--r--common/dct.cpp35
-rw-r--r--common/fft.cpp163
2 files changed, 95 insertions, 103 deletions
diff --git a/common/dct.cpp b/common/dct.cpp
index d98f2f4cc3..6525c727ae 100644
--- a/common/dct.cpp
+++ b/common/dct.cpp
@@ -51,21 +51,18 @@ DCT::~DCT() {
void DCT::calc(float *data) {
switch (_trans) {
- case DCT_I:
- calcDCTI(data);
- break;
-
- case DCT_II:
- calcDCTII(data);
- break;
-
- case DCT_III:
- calcDCTIII(data);
- break;
-
- case DST_I:
- calcDSTI(data);
- break;
+ case DCT_I:
+ calcDCTI(data);
+ break;
+ case DCT_II:
+ calcDCTII(data);
+ break;
+ case DCT_III:
+ calcDCTIII(data);
+ break;
+ case DST_I:
+ calcDSTI(data);
+ break;
}
}
@@ -119,8 +116,8 @@ void DCT::calcDCTII(float *data) {
tmp1 = (tmp1 + tmp2) * 0.5;
- data[i ] = tmp1 + s;
- data[n-i-1] = tmp1 - s;
+ data[i ] = tmp1 + s;
+ data[n - i - 1] = tmp1 - s;
}
_rdft->calc(data);
@@ -136,8 +133,8 @@ void DCT::calcDCTII(float *data) {
float c = COS(n, i);
float s = SIN(n, i);
- data[i ] = c * inr + s * ini;
- data[i+1] = next;
+ data[i ] = c * inr + s * ini;
+ data[i + 1] = next;
next += s * inr - c * ini;
}
diff --git a/common/fft.cpp b/common/fft.cpp
index 5dc378d886..5852698b61 100644
--- a/common/fft.cpp
+++ b/common/fft.cpp
@@ -57,7 +57,7 @@ void FFT::permute(Complex *z) {
int np = 1 << _bits;
if (_tmpBuf) {
- for(int j = 0; j < np; j++)
+ for (int j = 0; j < np; j++)
_tmpBuf[_revTab[j]] = z[j];
memcpy(z, _tmpBuf, np * sizeof(Complex));
@@ -66,7 +66,7 @@ void FFT::permute(Complex *z) {
}
// Reverse
- for(int j = 0; j < np; j++) {
+ for (int j = 0; j < np; j++) {
int k = _revTab[j];
if (k < j)
@@ -80,12 +80,12 @@ int FFT::splitRadixPermutation(int i, int n, int inverse) {
int m = n >> 1;
- if(!(i & m))
+ if (!(i & m))
return splitRadixPermutation(i, m, inverse) * 2;
m >>= 1;
- if(inverse == !(i & m))
+ if (inverse == !(i & m))
return splitRadixPermutation(i, m, inverse) * 4 + 1;
return splitRadixPermutation(i, m, inverse) * 4 - 1;
@@ -93,68 +93,67 @@ int FFT::splitRadixPermutation(int i, int n, int inverse) {
#define sqrthalf (float)M_SQRT1_2
-#define BF(x,y,a,b) {\
- x = a - b;\
- y = a + b;\
+#define BF(x, y, a, b) { \
+ x = a - b; \
+ y = a + b; \
}
-#define BUTTERFLIES(a0,a1,a2,a3) {\
- BF(t3, t5, t5, t1);\
- BF(a2.re, a0.re, a0.re, t5);\
- BF(a3.im, a1.im, a1.im, t3);\
- BF(t4, t6, t2, t6);\
- BF(a3.re, a1.re, a1.re, t4);\
- BF(a2.im, a0.im, a0.im, t6);\
+#define BUTTERFLIES(a0, a1, a2, a3) { \
+ BF(t3, t5, t5, t1); \
+ BF(a2.re, a0.re, a0.re, t5); \
+ BF(a3.im, a1.im, a1.im, t3); \
+ BF(t4, t6, t2, t6); \
+ BF(a3.re, a1.re, a1.re, t4); \
+ BF(a2.im, a0.im, a0.im, t6); \
}
// force loading all the inputs before storing any.
// this is slightly slower for small data, but avoids store->load aliasing
// for addresses separated by large powers of 2.
-#define BUTTERFLIES_BIG(a0,a1,a2,a3) {\
- float r0=a0.re, i0=a0.im, r1=a1.re, i1=a1.im;\
- BF(t3, t5, t5, t1);\
- BF(a2.re, a0.re, r0, t5);\
- BF(a3.im, a1.im, i1, t3);\
- BF(t4, t6, t2, t6);\
- BF(a3.re, a1.re, r1, t4);\
- BF(a2.im, a0.im, i0, t6);\
+#define BUTTERFLIES_BIG(a0, a1, a2, a3) { \
+ float r0 = a0.re, i0 = a0.im, r1 = a1.re, i1 = a1.im; \
+ BF(t3, t5, t5, t1); \
+ BF(a2.re, a0.re, r0, t5); \
+ BF(a3.im, a1.im, i1, t3); \
+ BF(t4, t6, t2, t6); \
+ BF(a3.re, a1.re, r1, t4); \
+ BF(a2.im, a0.im, i0, t6); \
}
-#define TRANSFORM(a0,a1,a2,a3,wre,wim) {\
- t1 = a2.re * wre + a2.im * wim;\
- t2 = a2.im * wre - a2.re * wim;\
- t5 = a3.re * wre - a3.im * wim;\
- t6 = a3.im * wre + a3.re * wim;\
- BUTTERFLIES(a0,a1,a2,a3)\
+#define TRANSFORM(a0, a1, a2, a3, wre, wim) { \
+ t1 = a2.re * wre + a2.im * wim; \
+ t2 = a2.im * wre - a2.re * wim; \
+ t5 = a3.re * wre - a3.im * wim; \
+ t6 = a3.im * wre + a3.re * wim; \
+ BUTTERFLIES(a0, a1, a2, a3) \
}
-#define TRANSFORM_ZERO(a0,a1,a2,a3) {\
- t1 = a2.re;\
- t2 = a2.im;\
- t5 = a3.re;\
- t6 = a3.im;\
- BUTTERFLIES(a0,a1,a2,a3)\
+#define TRANSFORM_ZERO(a0, a1, a2, a3) { \
+ t1 = a2.re; \
+ t2 = a2.im; \
+ t5 = a3.re; \
+ t6 = a3.im; \
+ BUTTERFLIES(a0, a1, a2, a3) \
}
/* z[0...8n-1], w[1...2n-1] */
-#define PASS(name)\
-static void name(Complex *z, const float *wre, unsigned int n)\
-{\
- float t1, t2, t3, t4, t5, t6;\
- int o1 = 2*n;\
- int o2 = 4*n;\
- int o3 = 6*n;\
- const float *wim = wre+o1;\
- n--;\
-\
- TRANSFORM_ZERO(z[0],z[o1],z[o2],z[o3]);\
- TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\
- do {\
- z += 2;\
- wre += 2;\
- wim -= 2;\
- TRANSFORM(z[0],z[o1],z[o2],z[o3],wre[0],wim[0]);\
- TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\
+#define PASS(name) \
+static void name(Complex *z, const float *wre, unsigned int n) { \
+ float t1, t2, t3, t4, t5, t6; \
+ int o1 = 2 * n; \
+ int o2 = 4 * n; \
+ int o3 = 6 * n; \
+ const float *wim = wre + o1; \
+ n--; \
+ \
+ TRANSFORM_ZERO(z[0], z[o1], z[o2], z[o3]); \
+ TRANSFORM(z[1], z[o1 + 1], z[o2 + 1], z[o3 + 1], wre[1], wim[-1]); \
+ do { \
+ z += 2; \
+ wre += 2; \
+ wim -= 2; \
+ TRANSFORM(z[0], z[o1], z[o2], z[o3], wre[0], wim[0]);\
+ TRANSFORM(z[1], z[o1 + 1], z[o2 + 1], z[o3 + 1], wre[1], wim[-1]);\
} while(--n);\
}
@@ -163,17 +162,15 @@ PASS(pass)
#define BUTTERFLIES BUTTERFLIES_BIG
PASS(pass_big)
-#define DECL_FFT(t,n,n2,n4)\
-static void fft##n(Complex *z)\
-{\
- fft##n2(z);\
- fft##n4(z+n4*2);\
- fft##n4(z+n4*3);\
- pass(z,getCosineTable(t),n4/2);\
+#define DECL_FFT(t, n, n2, n4) \
+static void fft##n(Complex *z) { \
+ fft##n2(z); \
+ fft##n4(z + n4 * 2); \
+ fft##n4(z + n4 * 3); \
+ pass(z, getCosineTable(t), n4 / 2);\
}
-static void fft4(Complex *z)
-{
+static void fft4(Complex *z) {
float t1, t2, t3, t4, t5, t6, t7, t8;
BF(t3, t1, z[0].re, z[1].re);
@@ -186,8 +183,7 @@ static void fft4(Complex *z)
BF(z[2].im, z[0].im, t2, t5);
}
-static void fft8(Complex *z)
-{
+static void fft8(Complex *z) {
float t1, t2, t3, t4, t5, t6, t7, t8;
fft4(z);
@@ -203,38 +199,37 @@ static void fft8(Complex *z)
BF(z[6].re, z[2].re, z[2].re, t7);
BF(z[6].im, z[2].im, z[2].im, t8);
- TRANSFORM(z[1],z[3],z[5],z[7],sqrthalf,sqrthalf);
+ TRANSFORM(z[1], z[3], z[5], z[7], sqrthalf, sqrthalf);
}
-static void fft16(Complex *z)
-{
+static void fft16(Complex *z) {
float t1, t2, t3, t4, t5, t6;
fft8(z);
- fft4(z+8);
- fft4(z+12);
+ fft4(z + 8);
+ fft4(z + 12);
const float * const cosTable = getCosineTable(4);
- TRANSFORM_ZERO(z[0],z[4],z[8],z[12]);
- TRANSFORM(z[2],z[6],z[10],z[14],sqrthalf,sqrthalf);
- TRANSFORM(z[1],z[5],z[9],z[13],cosTable[1],cosTable[3]);
- TRANSFORM(z[3],z[7],z[11],z[15],cosTable[3],cosTable[1]);
+ TRANSFORM_ZERO(z[0], z[4], z[8], z[12]);
+ TRANSFORM(z[2], z[6], z[10], z[14], sqrthalf, sqrthalf);
+ TRANSFORM(z[1], z[5], z[9], z[13], cosTable[1],cosTable[3]);
+ TRANSFORM(z[3], z[7], z[11], z[15], cosTable[3], cosTable[1]);
}
-DECL_FFT(5, 32,16,8)
-DECL_FFT(6, 64,32,16)
-DECL_FFT(7, 128,64,32)
-DECL_FFT(8, 256,128,64)
-DECL_FFT(9, 512,256,128)
+DECL_FFT(5, 32, 16, 8)
+DECL_FFT(6, 64, 32, 16)
+DECL_FFT(7, 128, 64, 32)
+DECL_FFT(8, 256, 128, 64)
+DECL_FFT(9, 512, 256, 128)
#define pass pass_big
-DECL_FFT(10, 1024,512,256)
-DECL_FFT(11, 2048,1024,512)
-DECL_FFT(12, 4096,2048,1024)
-DECL_FFT(13, 8192,4096,2048)
-DECL_FFT(14, 16384,8192,4096)
-DECL_FFT(15, 32768,16384,8192)
-DECL_FFT(16, 65536,32768,16384)
+DECL_FFT(10, 1024, 512, 256)
+DECL_FFT(11, 2048, 1024, 512)
+DECL_FFT(12, 4096, 2048, 1024)
+DECL_FFT(13, 8192, 4096, 2048)
+DECL_FFT(14, 16384, 8192, 4096)
+DECL_FFT(15, 32768, 16384, 8192)
+DECL_FFT(16, 65536, 32768, 16384)
static void (* const fft_dispatch[])(Complex*) = {
fft4, fft8, fft16, fft32, fft64, fft128, fft256, fft512, fft1024,