aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/fft.cpp34
-rw-r--r--common/huffman.cpp9
-rw-r--r--common/huffman.h4
-rw-r--r--common/math.h28
4 files changed, 27 insertions, 48 deletions
diff --git a/common/fft.cpp b/common/fft.cpp
index e9764ab9e6..5dc378d886 100644
--- a/common/fft.cpp
+++ b/common/fft.cpp
@@ -163,13 +163,13 @@ PASS(pass)
#define BUTTERFLIES BUTTERFLIES_BIG
PASS(pass_big)
-#define DECL_FFT(n,n2,n4)\
+#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,cosTable##n,n4/2);\
+ pass(z,getCosineTable(t),n4/2);\
}
static void fft4(Complex *z)
@@ -214,25 +214,27 @@ static void fft16(Complex *z)
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],cosTable16[1],cosTable16[3]);
- TRANSFORM(z[3],z[7],z[11],z[15],cosTable16[3],cosTable16[1]);
+ 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(32,16,8)
-DECL_FFT(64,32,16)
-DECL_FFT(128,64,32)
-DECL_FFT(256,128,64)
-DECL_FFT(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(1024,512,256)
-DECL_FFT(2048,1024,512)
-DECL_FFT(4096,2048,1024)
-DECL_FFT(8192,4096,2048)
-DECL_FFT(16384,8192,4096)
-DECL_FFT(32768,16384,8192)
-DECL_FFT(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,
diff --git a/common/huffman.cpp b/common/huffman.cpp
index 668e2216c9..a8ebe4142a 100644
--- a/common/huffman.cpp
+++ b/common/huffman.cpp
@@ -34,12 +34,17 @@ Huffman::Symbol::Symbol(uint32 c, uint32 s) : code(c), symbol(s) {
Huffman::Huffman(uint8 maxLength, uint32 codeCount, const uint32 *codes, const uint8 *lengths, const uint32 *symbols) {
- assert(maxLength > 0);
assert(codeCount > 0);
assert(codes);
assert(lengths);
+ if (maxLength == 0)
+ for (uint32 i = 0; i < codeCount; i++)
+ maxLength = MAX(maxLength, lengths[i]);
+
+ assert(maxLength <= 32);
+
_codes.resize(maxLength);
_symbols.resize(codeCount);
@@ -63,7 +68,7 @@ void Huffman::setSymbols(const uint32 *symbols) {
_symbols[i]->symbol = symbols ? *symbols++ : i;
}
-uint32 Huffman::getSymbol(BitStream &bits) {
+uint32 Huffman::getSymbol(BitStream &bits) const {
uint32 code = 0;
for (uint32 i = 0; i < _codes.size(); i++) {
diff --git a/common/huffman.h b/common/huffman.h
index 7d0bdcabf4..9a8b712c23 100644
--- a/common/huffman.h
+++ b/common/huffman.h
@@ -43,7 +43,7 @@ class Huffman {
public:
/** Construct a Huffman decoder.
*
- * @param maxLength Maximal code length.
+ * @param maxLength Maximal code length. If 0, it's searched for.
* @param codeCount Number of codes.
* @param codes The actual codes.
* @param lengths Lengths of the individual codes.
@@ -56,7 +56,7 @@ public:
void setSymbols(const uint32 *symbols = 0);
/** Return the next symbol in the bitstream. */
- uint32 getSymbol(BitStream &bits);
+ uint32 getSymbol(BitStream &bits) const;
private:
struct Symbol {
diff --git a/common/math.h b/common/math.h
index db803d9889..e6399f0692 100644
--- a/common/math.h
+++ b/common/math.h
@@ -43,34 +43,6 @@
#define FLT_MAX 1E+37
#endif
-extern const float sinTable16[8];
-extern const float sinTable32[16];
-extern const float sinTable64[32];
-extern const float sinTable128[64];
-extern const float sinTable256[128];
-extern const float sinTable512[256];
-extern const float sinTable1024[512];
-extern const float sinTable2048[1024];
-extern const float sinTable4096[2048];
-extern const float sinTable8192[4096];
-extern const float sinTable16384[8192];
-extern const float sinTable32768[16384];
-extern const float sinTable65536[32768];
-
-extern const float cosTable16[8];
-extern const float cosTable32[16];
-extern const float cosTable64[32];
-extern const float cosTable128[64];
-extern const float cosTable256[128];
-extern const float cosTable512[256];
-extern const float cosTable1024[512];
-extern const float cosTable2048[1024];
-extern const float cosTable4096[2048];
-extern const float cosTable8192[4096];
-extern const float cosTable16384[8192];
-extern const float cosTable32768[16384];
-extern const float cosTable65536[32768];
-
namespace Common {
/** A complex number. */