X Tutup
Skip to content

Commit e04000d

Browse files
ccawley2011sev-
authored andcommitted
COMMON: Move FFT, DCT, MDCT, RDFT, SineTable, CosineTable and getSineWindow into Math
1 parent 3441c72 commit e04000d

File tree

31 files changed

+151
-137
lines changed

31 files changed

+151
-137
lines changed

audio/decoders/qdm2.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@
3434
#include "common/array.h"
3535
#include "common/debug.h"
3636
#include "common/math.h"
37-
#include "common/rdft.h"
3837
#include "common/stream.h"
3938
#include "common/memstream.h"
4039
#include "common/bitstream.h"
4140
#include "common/textconsole.h"
4241

42+
#include "math/rdft.h"
43+
4344
namespace Audio {
4445

4546
enum {
@@ -143,7 +144,7 @@ class QDM2Stream : public Codec {
143144
int _fftCoefsMinIndex[5];
144145
int _fftCoefsMaxIndex[5];
145146
int _fftLevelExp[6];
146-
Common::RDFT *_rdft;
147+
Math::RDFT *_rdft;
147148
QDM2FFT _fft;
148149

149150
// I/O data
@@ -1201,7 +1202,7 @@ QDM2Stream::QDM2Stream(Common::SeekableReadStream *extraData, DisposeAfterUse::F
12011202
if (_fftOrder < 7 || _fftOrder > 9)
12021203
error("QDM2Stream::QDM2Stream() Unsupported fft_order: %d", _fftOrder);
12031204

1204-
_rdft = new Common::RDFT(_fftOrder, Common::RDFT::IDFT_C2R);
1205+
_rdft = new Math::RDFT(_fftOrder, Math::RDFT::IDFT_C2R);
12051206

12061207
initVlc();
12071208
ff_mpa_synth_init(ff_mpa_synth_window);

audio/decoders/wma.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424

2525
#include "common/util.h"
2626
#include "common/math.h"
27-
#include "common/sinewindows.h"
2827
#include "common/error.h"
2928
#include "common/memstream.h"
30-
#include "common/mdct.h"
3129
#include "common/huffman.h"
3230

31+
#include "math/mdct.h"
32+
#include "math/sinewindows.h"
33+
3334
#include "audio/audiostream.h"
3435

3536
#include "audio/decoders/util.h"
@@ -114,7 +115,7 @@ WMACodec::~WMACodec() {
114115
delete _coefHuffman[i];
115116
}
116117

117-
for (Common::Array<Common::MDCT *>::iterator m = _mdct.begin(); m != _mdct.end(); ++m)
118+
for (Common::Array<Math::MDCT *>::iterator m = _mdct.begin(); m != _mdct.end(); ++m)
118119
delete *m;
119120
}
120121

@@ -459,12 +460,12 @@ void WMACodec::initCoefHuffman(float bps) {
459460
void WMACodec::initMDCT() {
460461
_mdct.reserve(_blockSizeCount);
461462
for (int i = 0; i < _blockSizeCount; i++)
462-
_mdct.push_back(new Common::MDCT(_frameLenBits - i + 1, true, 1.0));
463+
_mdct.push_back(new Math::MDCT(_frameLenBits - i + 1, true, 1.0));
463464

464465
// Init MDCT windows (simple sine window)
465466
_mdctWindow.reserve(_blockSizeCount);
466467
for (int i = 0; i < _blockSizeCount; i++)
467-
_mdctWindow.push_back(Common::getSineWindow(_frameLenBits - i));
468+
_mdctWindow.push_back(Math::getSineWindow(_frameLenBits - i));
468469
}
469470

470471
void WMACodec::initExponents() {
@@ -801,7 +802,7 @@ bool WMACodec::decodeChannels(Common::BitStream8MSB &bits, int bSize,
801802
}
802803

803804
bool WMACodec::calculateIMDCT(int bSize, bool msStereo, bool *hasChannel) {
804-
Common::MDCT &mdct = *_mdct[bSize];
805+
Math::MDCT &mdct = *_mdct[bSize];
805806

806807
for (int i = 0; i < _channels; i++) {
807808
int n4 = _blockLen / 2;

audio/decoders/wma.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
namespace Common {
3434
template <class BITSTREAM>
3535
class Huffman;
36+
}
37+
38+
namespace Math {
3639
class MDCT;
3740
}
3841

@@ -146,7 +149,7 @@ class WMACodec : public Codec {
146149
float _lspPowMTable2[(1 << kLSPPowBits)];
147150

148151
// MDCT
149-
Common::Array<Common::MDCT *> _mdct; ///< MDCT contexts.
152+
Common::Array<Math::MDCT *> _mdct; ///< MDCT contexts.
150153
Common::Array<const float *> _mdctWindow; ///< MDCT window functions.
151154

152155
/** Overhang from the last superframe. */

backends/platform/sdl/sdl-sys.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@
239239
#undef False
240240
#endif
241241

242+
#ifdef Complex
243+
#undef Complex
244+
#endif
245+
242246
// Finally forbid FILE again (if it was forbidden to start with)
243247
#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_FILE)
244248
#undef FILE

common/math.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@
6161

6262
namespace Common {
6363

64-
/** A complex number. */
65-
struct Complex {
66-
float re, im;
67-
};
68-
6964
#if defined(__GNUC__)
7065
inline int intLog2(uint32 v) {
7166
// This is a slightly optimized implementation of log2 for natural numbers

common/module.mk

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ MODULE_OBJS := \
2626
macresman.o \
2727
memorypool.o \
2828
md5.o \
29-
mdct.o \
3029
mutex.o \
3130
osd_message_queue.o \
3231
path.o \
@@ -36,7 +35,6 @@ MODULE_OBJS := \
3635
random.o \
3736
rational.o \
3837
rendermode.o \
39-
sinewindows.o \
4038
str.o \
4139
stream.o \
4240
streamdebug.o \
@@ -60,13 +58,6 @@ MODULE_OBJS := \
6058
xpfloat.o \
6159
zlib.o
6260

63-
MODULE_OBJS += \
64-
cosinetables.o \
65-
dct.o \
66-
fft.o \
67-
rdft.o \
68-
sinetables.o
69-
7061
ifdef ENABLE_EVENTRECORDER
7162
MODULE_OBJS += \
7263
recorderfile.o

engines/bladerunner/bladerunner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,8 @@ bool BladeRunnerEngine::startup(bool hasSavegames) {
702702

703703
// Seed rand
704704

705-
_cosTable1024 = new Common::CosineTable(1024); // 10-bits = 1024 points for 2*PI;
706-
_sinTable1024 = new Common::SineTable(1024);
705+
_cosTable1024 = new Math::CosineTable(1024); // 10-bits = 1024 points for 2*PI;
706+
_sinTable1024 = new Math::SineTable(1024);
707707

708708
_view = new View();
709709

engines/bladerunner/bladerunner.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
#include "bladerunner/archive.h"
2626

2727
#include "common/array.h"
28-
#include "common/cosinetables.h"
2928
#include "common/random.h"
30-
#include "common/sinetables.h"
3129
#include "common/stream.h"
3230
#include "common/keyboard.h"
3331
#include "common/events.h"
@@ -36,6 +34,9 @@
3634

3735
#include "graphics/surface.h"
3836

37+
#include "math/cosinetables.h"
38+
#include "math/sinetables.h"
39+
3940
//TODO: change this to debugflag
4041
#define BLADERUNNER_DEBUG_CONSOLE 0
4142
#define BLADERUNNER_ORIGINAL_SETTINGS 0
@@ -213,8 +214,8 @@ class BladeRunnerEngine : public Engine {
213214

214215
Debugger *_debugger;
215216

216-
Common::CosineTable *_cosTable1024;
217-
Common::SineTable *_sinTable1024;
217+
Math::CosineTable *_cosTable1024;
218+
Math::SineTable *_sinTable1024;
218219

219220
bool _isWalkingInterruptible;
220221
bool _interruptWalking;

engines/hdb/gfx.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
*
2020
*/
2121

22-
#include "common/cosinetables.h"
23-
#include "common/sinetables.h"
2422
#include "common/random.h"
2523
#include "common/memstream.h"
2624
#include "graphics/cursor.h"
2725
#include "graphics/cursorman.h"
26+
#include "math/cosinetables.h"
27+
#include "math/sinetables.h"
2828

2929
#include "hdb/hdb.h"
3030
#include "hdb/ai.h"
@@ -42,8 +42,8 @@ Gfx::Gfx() {
4242
_gfxCache = new Common::Array<GfxCache *>;
4343
_globalSurface.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_format);
4444
_pointerDisplayable = 1;
45-
_sines = new Common::SineTable(360);
46-
_cosines = new Common::CosineTable(360);
45+
_sines = new Math::SineTable(360);
46+
_cosines = new Math::CosineTable(360);
4747
_systemInit = false;
4848

4949
_numTiles = 0;

engines/hdb/gfx.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#include "graphics/managed_surface.h"
2626

27-
namespace Common {
27+
namespace Math {
2828
class SineTable;
2929
class CosineTable;
3030
}
@@ -227,8 +227,8 @@ class Gfx {
227227

228228
bool _systemInit;
229229

230-
Common::SineTable *_sines;
231-
Common::CosineTable *_cosines;
230+
Math::SineTable *_sines;
231+
Math::CosineTable *_cosines;
232232
};
233233

234234
class Picture {

0 commit comments

Comments
 (0)
X Tutup