From f4ba8a6485b097a8ef1e2004d1af127243f379f1 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sat, 14 Apr 2012 11:18:55 +0100 Subject: COMMON: Replaced static Sine and Cosine tables with dynamic generated. This removes the large static tables from the binary (which saves 500K to 1Mb of binary size) and replaced them with a class which generates the required tables as needed in RAM. This has been tested with QDM2 and shows no obvious performance degredation and Memprof shows no significant rise in RAM usage. --- common/cosinetables.h | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'common/cosinetables.h') diff --git a/common/cosinetables.h b/common/cosinetables.h index 5744d21569..f9fb6fd59a 100644 --- a/common/cosinetables.h +++ b/common/cosinetables.h @@ -25,12 +25,30 @@ namespace Common { -/** - * Get a cosine table with the specified bit precision - * - * @param bits Precision of the table, which must be in range [4, 16] - */ -const float *getCosineTable(int bits); +class CosineTable { +public: + /** + * Construct a cosine table with the specified bit precision + * + * @param bitPrecision Precision of the table, which must be in range [4, 16] + */ + CosineTable(int bitPrecision); + ~CosineTable(); + + /** + * Get pointer to table + */ + const float *getTable() { return _table; } + + /** + * Get pointer to table + */ + int getPrecision() { return _bitPrecision; } + +private: + float *_table; + int _bitPrecision; +}; } // End of namespace Common -- cgit v1.2.3