[Scummvm-git-logs] scummvm master -> e04000d4b08504bc0a7bee7e8299733075c178dc
sev-
noreply at scummvm.org
Sun Nov 20 13:32:09 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
e04000d4b0 COMMON: Move FFT, DCT, MDCT, RDFT, SineTable, CosineTable and getSineWindow into Math
Commit: e04000d4b08504bc0a7bee7e8299733075c178dc
https://github.com/scummvm/scummvm/commit/e04000d4b08504bc0a7bee7e8299733075c178dc
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-11-20T14:32:05+01:00
Commit Message:
COMMON: Move FFT, DCT, MDCT, RDFT, SineTable, CosineTable and getSineWindow into Math
Changed paths:
A math/cosinetables.cpp
A math/cosinetables.h
A math/dct.cpp
A math/dct.h
A math/fft.cpp
A math/fft.h
A math/mdct.cpp
A math/mdct.h
A math/rdft.cpp
A math/rdft.h
A math/sinetables.cpp
A math/sinetables.h
A math/sinewindows.cpp
A math/sinewindows.h
R common/cosinetables.cpp
R common/cosinetables.h
R common/dct.cpp
R common/dct.h
R common/fft.cpp
R common/fft.h
R common/mdct.cpp
R common/mdct.h
R common/rdft.cpp
R common/rdft.h
R common/sinetables.cpp
R common/sinetables.h
R common/sinewindows.cpp
R common/sinewindows.h
audio/decoders/qdm2.cpp
audio/decoders/wma.cpp
audio/decoders/wma.h
backends/platform/sdl/sdl-sys.h
common/math.h
common/module.mk
engines/bladerunner/bladerunner.cpp
engines/bladerunner/bladerunner.h
engines/hdb/gfx.cpp
engines/hdb/gfx.h
engines/startrek/startrek.h
engines/supernova/resman.cpp
engines/supernova/resman.h
math/module.mk
math/utils.h
video/bink_decoder.cpp
video/bink_decoder.h
diff --git a/audio/decoders/qdm2.cpp b/audio/decoders/qdm2.cpp
index f346876cf9f..03dc688a79e 100644
--- a/audio/decoders/qdm2.cpp
+++ b/audio/decoders/qdm2.cpp
@@ -34,12 +34,13 @@
#include "common/array.h"
#include "common/debug.h"
#include "common/math.h"
-#include "common/rdft.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "common/bitstream.h"
#include "common/textconsole.h"
+#include "math/rdft.h"
+
namespace Audio {
enum {
@@ -143,7 +144,7 @@ private:
int _fftCoefsMinIndex[5];
int _fftCoefsMaxIndex[5];
int _fftLevelExp[6];
- Common::RDFT *_rdft;
+ Math::RDFT *_rdft;
QDM2FFT _fft;
// I/O data
@@ -1201,7 +1202,7 @@ QDM2Stream::QDM2Stream(Common::SeekableReadStream *extraData, DisposeAfterUse::F
if (_fftOrder < 7 || _fftOrder > 9)
error("QDM2Stream::QDM2Stream() Unsupported fft_order: %d", _fftOrder);
- _rdft = new Common::RDFT(_fftOrder, Common::RDFT::IDFT_C2R);
+ _rdft = new Math::RDFT(_fftOrder, Math::RDFT::IDFT_C2R);
initVlc();
ff_mpa_synth_init(ff_mpa_synth_window);
diff --git a/audio/decoders/wma.cpp b/audio/decoders/wma.cpp
index 6014d5f6ecb..2eead20b598 100644
--- a/audio/decoders/wma.cpp
+++ b/audio/decoders/wma.cpp
@@ -24,12 +24,13 @@
#include "common/util.h"
#include "common/math.h"
-#include "common/sinewindows.h"
#include "common/error.h"
#include "common/memstream.h"
-#include "common/mdct.h"
#include "common/huffman.h"
+#include "math/mdct.h"
+#include "math/sinewindows.h"
+
#include "audio/audiostream.h"
#include "audio/decoders/util.h"
@@ -114,7 +115,7 @@ WMACodec::~WMACodec() {
delete _coefHuffman[i];
}
- for (Common::Array<Common::MDCT *>::iterator m = _mdct.begin(); m != _mdct.end(); ++m)
+ for (Common::Array<Math::MDCT *>::iterator m = _mdct.begin(); m != _mdct.end(); ++m)
delete *m;
}
@@ -459,12 +460,12 @@ void WMACodec::initCoefHuffman(float bps) {
void WMACodec::initMDCT() {
_mdct.reserve(_blockSizeCount);
for (int i = 0; i < _blockSizeCount; i++)
- _mdct.push_back(new Common::MDCT(_frameLenBits - i + 1, true, 1.0));
+ _mdct.push_back(new Math::MDCT(_frameLenBits - i + 1, true, 1.0));
// Init MDCT windows (simple sine window)
_mdctWindow.reserve(_blockSizeCount);
for (int i = 0; i < _blockSizeCount; i++)
- _mdctWindow.push_back(Common::getSineWindow(_frameLenBits - i));
+ _mdctWindow.push_back(Math::getSineWindow(_frameLenBits - i));
}
void WMACodec::initExponents() {
@@ -801,7 +802,7 @@ bool WMACodec::decodeChannels(Common::BitStream8MSB &bits, int bSize,
}
bool WMACodec::calculateIMDCT(int bSize, bool msStereo, bool *hasChannel) {
- Common::MDCT &mdct = *_mdct[bSize];
+ Math::MDCT &mdct = *_mdct[bSize];
for (int i = 0; i < _channels; i++) {
int n4 = _blockLen / 2;
diff --git a/audio/decoders/wma.h b/audio/decoders/wma.h
index 922d5edcd61..ee7aa805002 100644
--- a/audio/decoders/wma.h
+++ b/audio/decoders/wma.h
@@ -33,6 +33,9 @@
namespace Common {
template <class BITSTREAM>
class Huffman;
+}
+
+namespace Math {
class MDCT;
}
@@ -146,7 +149,7 @@ private:
float _lspPowMTable2[(1 << kLSPPowBits)];
// MDCT
- Common::Array<Common::MDCT *> _mdct; ///< MDCT contexts.
+ Common::Array<Math::MDCT *> _mdct; ///< MDCT contexts.
Common::Array<const float *> _mdctWindow; ///< MDCT window functions.
/** Overhang from the last superframe. */
diff --git a/backends/platform/sdl/sdl-sys.h b/backends/platform/sdl/sdl-sys.h
index 4fd48117980..59761b9c678 100644
--- a/backends/platform/sdl/sdl-sys.h
+++ b/backends/platform/sdl/sdl-sys.h
@@ -239,6 +239,10 @@
#undef False
#endif
+#ifdef Complex
+#undef Complex
+#endif
+
// Finally forbid FILE again (if it was forbidden to start with)
#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_FILE)
#undef FILE
diff --git a/common/math.h b/common/math.h
index 2c2a1554b0d..f6b4ad38cc3 100644
--- a/common/math.h
+++ b/common/math.h
@@ -61,11 +61,6 @@
namespace Common {
-/** A complex number. */
-struct Complex {
- float re, im;
-};
-
#if defined(__GNUC__)
inline int intLog2(uint32 v) {
// This is a slightly optimized implementation of log2 for natural numbers
diff --git a/common/module.mk b/common/module.mk
index 857bdf304f0..707c323d98a 100644
--- a/common/module.mk
+++ b/common/module.mk
@@ -26,7 +26,6 @@ MODULE_OBJS := \
macresman.o \
memorypool.o \
md5.o \
- mdct.o \
mutex.o \
osd_message_queue.o \
path.o \
@@ -36,7 +35,6 @@ MODULE_OBJS := \
random.o \
rational.o \
rendermode.o \
- sinewindows.o \
str.o \
stream.o \
streamdebug.o \
@@ -60,13 +58,6 @@ MODULE_OBJS := \
xpfloat.o \
zlib.o
-MODULE_OBJS += \
- cosinetables.o \
- dct.o \
- fft.o \
- rdft.o \
- sinetables.o
-
ifdef ENABLE_EVENTRECORDER
MODULE_OBJS += \
recorderfile.o
diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp
index a9534218118..23157671a34 100644
--- a/engines/bladerunner/bladerunner.cpp
+++ b/engines/bladerunner/bladerunner.cpp
@@ -702,8 +702,8 @@ bool BladeRunnerEngine::startup(bool hasSavegames) {
// Seed rand
- _cosTable1024 = new Common::CosineTable(1024); // 10-bits = 1024 points for 2*PI;
- _sinTable1024 = new Common::SineTable(1024);
+ _cosTable1024 = new Math::CosineTable(1024); // 10-bits = 1024 points for 2*PI;
+ _sinTable1024 = new Math::SineTable(1024);
_view = new View();
diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h
index 5ad2617994d..30ccf49521b 100644
--- a/engines/bladerunner/bladerunner.h
+++ b/engines/bladerunner/bladerunner.h
@@ -25,9 +25,7 @@
#include "bladerunner/archive.h"
#include "common/array.h"
-#include "common/cosinetables.h"
#include "common/random.h"
-#include "common/sinetables.h"
#include "common/stream.h"
#include "common/keyboard.h"
#include "common/events.h"
@@ -36,6 +34,9 @@
#include "graphics/surface.h"
+#include "math/cosinetables.h"
+#include "math/sinetables.h"
+
//TODO: change this to debugflag
#define BLADERUNNER_DEBUG_CONSOLE 0
#define BLADERUNNER_ORIGINAL_SETTINGS 0
@@ -213,8 +214,8 @@ public:
Debugger *_debugger;
- Common::CosineTable *_cosTable1024;
- Common::SineTable *_sinTable1024;
+ Math::CosineTable *_cosTable1024;
+ Math::SineTable *_sinTable1024;
bool _isWalkingInterruptible;
bool _interruptWalking;
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index b542a9cb81e..b0c6dd55747 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -19,12 +19,12 @@
*
*/
-#include "common/cosinetables.h"
-#include "common/sinetables.h"
#include "common/random.h"
#include "common/memstream.h"
#include "graphics/cursor.h"
#include "graphics/cursorman.h"
+#include "math/cosinetables.h"
+#include "math/sinetables.h"
#include "hdb/hdb.h"
#include "hdb/ai.h"
@@ -42,8 +42,8 @@ Gfx::Gfx() {
_gfxCache = new Common::Array<GfxCache *>;
_globalSurface.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_format);
_pointerDisplayable = 1;
- _sines = new Common::SineTable(360);
- _cosines = new Common::CosineTable(360);
+ _sines = new Math::SineTable(360);
+ _cosines = new Math::CosineTable(360);
_systemInit = false;
_numTiles = 0;
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h
index c18fa1b7f47..1db01e6ff45 100644
--- a/engines/hdb/gfx.h
+++ b/engines/hdb/gfx.h
@@ -24,7 +24,7 @@
#include "graphics/managed_surface.h"
-namespace Common {
+namespace Math {
class SineTable;
class CosineTable;
}
@@ -227,8 +227,8 @@ private:
bool _systemInit;
- Common::SineTable *_sines;
- Common::CosineTable *_cosines;
+ Math::SineTable *_sines;
+ Math::CosineTable *_cosines;
};
class Picture {
diff --git a/engines/startrek/startrek.h b/engines/startrek/startrek.h
index e97d4ab5294..2cb6be1e019 100644
--- a/engines/startrek/startrek.h
+++ b/engines/startrek/startrek.h
@@ -22,7 +22,6 @@
#ifndef STARTREK_H
#define STARTREK_H
-#include "common/cosinetables.h"
#include "common/events.h"
#include "common/list.h"
#include "common/ptr.h"
@@ -30,7 +29,6 @@
#include "common/rect.h"
#include "common/scummsys.h"
#include "common/serializer.h"
-#include "common/sinetables.h"
#include "common/str.h"
#include "common/stream.h"
#include "common/system.h"
@@ -40,6 +38,9 @@
#include "engines/engine.h"
+#include "math/cosinetables.h"
+#include "math/sinetables.h"
+
#include "startrek/action.h"
#include "startrek/awaymission.h"
#include "startrek/graphics.h"
@@ -803,8 +804,8 @@ private:
void bridgeLeftClick();
Common::RandomSource _randomSource;
- Common::SineTable _sineTable;
- Common::CosineTable _cosineTable;
+ Math::SineTable _sineTable;
+ Math::CosineTable _cosineTable;
Room *_room;
Common::List<ComputerTopic> _computerTopics;
};
diff --git a/engines/supernova/resman.cpp b/engines/supernova/resman.cpp
index d087595a273..45074cfe763 100644
--- a/engines/supernova/resman.cpp
+++ b/engines/supernova/resman.cpp
@@ -322,7 +322,7 @@ MSNImage *ResourceManager::getImage(int filenumber) {
// Generate a tone which minimal length is the length and ends at the end
// of sine period
// NOTE: Size of the SineTable has to be the same as audioRate and a multiple of 4
-byte *ResourceManager::generateTone(byte *buffer, int frequency, int length, int audioRate, Common::SineTable &table) {
+byte *ResourceManager::generateTone(byte *buffer, int frequency, int length, int audioRate, Math::SineTable &table) {
int i = 0;
// Make sure length is a multiple of audioRate / frequency to end on a full sine wave and not in the middle.
@@ -345,7 +345,7 @@ void ResourceManager::initSiren() {
// * 60 for the minimal length, another 20 * length as a spare, for longer tones
byte *buffer = new byte[length * 80];
byte *pBuffer = buffer;
- Common::SineTable table(audioRate);
+ Math::SineTable table(audioRate);
for (int i = 0; i < 30; i++)
pBuffer = generateTone(pBuffer, 1800 - i * 10, length, audioRate, table);
diff --git a/engines/supernova/resman.h b/engines/supernova/resman.h
index 58416920fb4..adf10a214df 100644
--- a/engines/supernova/resman.h
+++ b/engines/supernova/resman.h
@@ -24,7 +24,7 @@
#include "audio/audiostream.h"
#include "common/ptr.h"
-#include "common/sinetables.h"
+#include "math/sinetables.h"
#include "supernova/graphics.h"
#include "supernova/sound.h"
@@ -69,7 +69,7 @@ private:
void loadSound1(AudioId id);
void loadSound2(AudioId id);
void initSiren();
- byte *generateTone(byte *buffer, int frequency, int length, int audioRate, Common::SineTable &table);
+ byte *generateTone(byte *buffer, int frequency, int length, int audioRate, Math::SineTable &table);
private:
Common::ScopedPtr<Audio::SeekableAudioStream> *_soundSamples;
diff --git a/common/cosinetables.cpp b/math/cosinetables.cpp
similarity index 95%
rename from common/cosinetables.cpp
rename to math/cosinetables.cpp
index 53e76cbfa09..a370d4a6e1e 100644
--- a/common/cosinetables.cpp
+++ b/math/cosinetables.cpp
@@ -21,10 +21,9 @@
// Based on eos' cosine tables
-#include "common/cosinetables.h"
-#include "common/scummsys.h"
+#include "math/cosinetables.h"
-namespace Common {
+namespace Math {
CosineTable::CosineTable(int nPoints) {
assert((nPoints >= 16) && (nPoints <= 65536)); // log2 space is in [4,16]
@@ -75,4 +74,4 @@ CosineTable::~CosineTable() {
delete[] _table;
}
-} // End of namespace Common
+} // End of namespace Math
diff --git a/common/cosinetables.h b/math/cosinetables.h
similarity index 90%
rename from common/cosinetables.h
rename to math/cosinetables.h
index 4c090c2e3fb..0c02e6f0d93 100644
--- a/common/cosinetables.h
+++ b/math/cosinetables.h
@@ -19,14 +19,16 @@
*
*/
-#ifndef COMMON_COSINETABLES_H
-#define COMMON_COSINETABLES_H
+#ifndef MATH_COSINETABLES_H
+#define MATH_COSINETABLES_H
-namespace Common {
+#include "common/scummsys.h"
+
+namespace Math {
/**
- * @defgroup common_cosinetables Cosine tables
- * @ingroup common
+ * @defgroup math_cosinetables Cosine tables
+ * @ingroup math
*
* @brief Functions for working with cosine tables.
*
@@ -79,6 +81,6 @@ private:
/** @} */
-} // End of namespace Common
+} // End of namespace Math
-#endif // COMMON_COSINETABLES_H
+#endif // MATH_COSINETABLES_H
diff --git a/common/dct.cpp b/math/dct.cpp
similarity index 97%
rename from common/dct.cpp
rename to math/dct.cpp
index eddb3c5f617..3f98d852eed 100644
--- a/common/dct.cpp
+++ b/math/dct.cpp
@@ -25,9 +25,10 @@
// Copyright (c) 2010 Alex Converse <alex.converse at gmail.com>
// Copyright (c) 2010 Vitor Sessak
-#include "common/dct.h"
+#include "math/dct.h"
+#include "math/rdft.h"
-namespace Common {
+namespace Math {
DCT::DCT(int bits, TransformType trans) : _bits(bits), _cos(1 << (_bits + 2) ), _trans(trans), _rdft(nullptr) {
int n = 1 << _bits;
@@ -205,4 +206,4 @@ void DCT::calcDSTI(float *data) {
data[n - 1] = 0;
}
-} // End of namespace Common
+} // End of namespace Math
diff --git a/common/dct.h b/math/dct.h
similarity index 85%
rename from common/dct.h
rename to math/dct.h
index 3fd6292dd45..9453766832d 100644
--- a/common/dct.h
+++ b/math/dct.h
@@ -25,20 +25,18 @@
// Copyright (c) 2010 Alex Converse <alex.converse at gmail.com>
// Copyright (c) 2010 Vitor Sessak
-#ifndef COMMON_DCT_H
-#define COMMON_DCT_H
+#ifndef MATH_DCT_H
+#define MATH_DCT_H
-#include "common/scummsys.h"
-#include "common/math.h"
-#include "common/rdft.h"
+#include "math/cosinetables.h"
-#include "common/cosinetables.h"
+namespace Math {
-namespace Common {
+class RDFT;
/**
- * @defgroup common_dct Discrete Cosine Transforms
- * @ingroup common
+ * @defgroup math_dct Discrete Cosine Transforms
+ * @ingroup math
*
* @brief Discrete Cosine Transforms.
*
@@ -84,6 +82,6 @@ private:
/** @} */
-} // End of namespace Common
+} // End of namespace Math
-#endif // COMMON_DCT_H
+#endif // MATH_DCT_H
diff --git a/common/fft.cpp b/math/fft.cpp
similarity index 96%
rename from common/fft.cpp
rename to math/fft.cpp
index ab7ee247b0d..c2e0899abd2 100644
--- a/common/fft.cpp
+++ b/math/fft.cpp
@@ -25,12 +25,12 @@
// Copyright (c) 2002 Fabrice Bellard
// Partly based on libdjbfft by D. J. Bernstein
-#include "common/cosinetables.h"
-#include "common/fft.h"
+#include "math/fft.h"
+#include "math/cosinetables.h"
+#include "math/utils.h"
#include "common/util.h"
-#include "common/textconsole.h"
-namespace Common {
+namespace Math {
FFT::FFT(int bits, int inverse) : _bits(bits), _inverse(inverse) {
assert((_bits >= 2) && (_bits <= 16));
@@ -50,7 +50,7 @@ FFT::FFT(int bits, int inverse) : _bits(bits), _inverse(inverse) {
for (int i = 0; i < ARRAYSIZE(_cosTables); i++) {
if (i + 4 <= _bits) {
nPoints = 1 << (i + 4);
- _cosTables[i] = new Common::CosineTable(nPoints);
+ _cosTables[i] = new CosineTable(nPoints);
}
else
_cosTables[i] = nullptr;
@@ -255,4 +255,4 @@ void FFT::calc(Complex *z) {
fft(1 << _bits, _bits, z);
}
-} // End of namespace Common
+} // End of namespace Math
diff --git a/common/fft.h b/math/fft.h
similarity index 90%
rename from common/fft.h
rename to math/fft.h
index c5e73665bf6..b56ee5cd506 100644
--- a/common/fft.h
+++ b/math/fft.h
@@ -25,17 +25,16 @@
// Copyright (c) 2002 Fabrice Bellard
// Partly based on libdjbfft by D. J. Bernstein
-#ifndef COMMON_FFT_H
-#define COMMON_FFT_H
+#ifndef MATH_FFT_H
+#define MATH_FFT_H
#include "common/scummsys.h"
-#include "common/math.h"
-namespace Common {
+namespace Math {
/**
- * @defgroup common_fft Fast Fourier Transform (FFT)
- * @ingroup common
+ * @defgroup math_fft Fast Fourier Transform (FFT)
+ * @ingroup math
*
* @brief API for the FFT algorithm.
*
@@ -43,6 +42,7 @@ namespace Common {
*/
class CosineTable;
+struct Complex;
/**
* (Inverse) Fast Fourier Transform.
@@ -90,6 +90,6 @@ private:
/** @} */
-} // End of namespace Common
+} // End of namespace Math
-#endif // COMMON_FFT_H
+#endif // MATH_FFT_H
diff --git a/common/mdct.cpp b/math/mdct.cpp
similarity index 96%
rename from common/mdct.cpp
rename to math/mdct.cpp
index bf5abe0d6b3..e868d3b5495 100644
--- a/common/mdct.cpp
+++ b/math/mdct.cpp
@@ -23,16 +23,16 @@
// Based upon the (I)MDCT code in FFmpeg
// Copyright (c) 2002 Fabrice Bellard
-/** @file common/mdct.cpp
+/** @file math/mdct.cpp
* (Inverse) Modified Discrete Cosine Transforms.
*/
-#include "common/math.h"
+#include "math/mdct.h"
+#include "math/fft.h"
+#include "math/utils.h"
#include "common/util.h"
-#include "common/fft.h"
-#include "common/mdct.h"
-namespace Common {
+namespace Math {
MDCT::MDCT(int bits, bool inverse, double scale) : _bits(bits), _fft(nullptr) {
_size = 1 << bits;
@@ -156,4 +156,4 @@ void MDCT::calcHalfIMDCT(float *output, const float *input) {
}
}
-} // End of namespace Common
+} // End of namespace Math
diff --git a/common/mdct.h b/math/mdct.h
similarity index 91%
rename from common/mdct.h
rename to math/mdct.h
index 9589ebf0dec..01a1162ab5d 100644
--- a/common/mdct.h
+++ b/math/mdct.h
@@ -24,12 +24,12 @@
// Copyright (c) 2002 Fabrice Bellard
-#ifndef COMMON_MDCT_H
-#define COMMON_MDCT_H
+#ifndef MATH_MDCT_H
+#define MATH_MDCT_H
-#include "common/types.h"
+#include "common/scummsys.h"
-namespace Common {
+namespace Math {
class FFT;
@@ -60,6 +60,6 @@ private:
void calcHalfIMDCT(float *output, const float *input);
};
-} // End of namespace Common
+} // End of namespace Math
-#endif // COMMON_MDCT_H
+#endif // MATH_MDCT_H
diff --git a/math/module.mk b/math/module.mk
index d9385946561..a90ec4e496d 100644
--- a/math/module.mk
+++ b/math/module.mk
@@ -3,16 +3,23 @@ MODULE := math
MODULE_OBJS := \
aabb.o \
angle.o \
+ cosinetables.o \
+ dct.o \
+ fft.o \
frustum.o \
glmath.o \
line2d.o \
line3d.o \
matrix3.o \
matrix4.o \
+ mdct.o \
plane.o \
quat.o \
ray.o \
+ rdft.o \
rect2d.o \
+ sinetables.o \
+ sinewindows.o \
vector2d.o \
vector3d.o \
vector4d.o
diff --git a/common/rdft.cpp b/math/rdft.cpp
similarity index 96%
rename from common/rdft.cpp
rename to math/rdft.cpp
index e0e0e366293..2d99d93923c 100644
--- a/common/rdft.cpp
+++ b/math/rdft.cpp
@@ -23,9 +23,11 @@
// Based upon the (I)RDFT code in FFmpeg
// Copyright (c) 2009 Alex Converse <alex dot converse at gmail dot com>
-#include "common/rdft.h"
+#include "math/rdft.h"
+#include "math/fft.h"
+#include "math/utils.h"
-namespace Common {
+namespace Math {
RDFT::RDFT(int bits, TransformType trans) : _bits(bits), _sin(1 << bits), _cos(1 << bits), _fft(nullptr) {
assert((_bits >= 4) && (_bits <= 16));
@@ -96,4 +98,4 @@ void RDFT::calc(float *data) {
}
-} // End of namespace Common
+} // End of namespace Math
diff --git a/common/rdft.h b/math/rdft.h
similarity index 89%
rename from common/rdft.h
rename to math/rdft.h
index 4a79ceaef30..aef4ac67afa 100644
--- a/common/rdft.h
+++ b/math/rdft.h
@@ -23,21 +23,19 @@
// Based upon the (I)RDFT code in FFmpeg
// Copyright (c) 2009 Alex Converse <alex dot converse at gmail dot com>
-#ifndef COMMON_RDFT_H
-#define COMMON_RDFT_H
+#ifndef MATH_RDFT_H
+#define MATH_RDFT_H
-#include "common/scummsys.h"
-#include "common/math.h"
-#include "common/fft.h"
+#include "math/cosinetables.h"
+#include "math/sinetables.h"
-#include "common/cosinetables.h"
-#include "common/sinetables.h"
+namespace Math {
-namespace Common {
+class FFT;
/**
- * @defgroup common_rdft RDFT algorithm
- * @ingroup common
+ * @defgroup math_rdft RDFT algorithm
+ * @ingroup math
*
* @brief API for the Real Discrete Fourier Transform (RDFT) algorithm.
*
@@ -117,6 +115,6 @@ private:
/** @} */
-} // End of namespace Common
+} // End of namespace Math
-#endif // COMMON_RDFT_H
+#endif // MATH_RDFT_H
diff --git a/common/sinetables.cpp b/math/sinetables.cpp
similarity index 95%
rename from common/sinetables.cpp
rename to math/sinetables.cpp
index ca0aad93890..49187b41a01 100644
--- a/common/sinetables.cpp
+++ b/math/sinetables.cpp
@@ -21,10 +21,9 @@
// Based on eos' sine tables
-#include "common/scummsys.h"
-#include "common/sinetables.h"
+#include "math/sinetables.h"
-namespace Common {
+namespace Math {
SineTable::SineTable(int nPoints) {
assert((nPoints >= 16) && (nPoints <= 65536)); // log2 space is in [4,16]
@@ -78,4 +77,4 @@ SineTable::~SineTable() {
delete[] _table;
}
-} // End of namespace Common
+} // End of namespace Math
diff --git a/common/sinetables.h b/math/sinetables.h
similarity index 90%
rename from common/sinetables.h
rename to math/sinetables.h
index c9f6b51aaf9..48cc5127cb7 100644
--- a/common/sinetables.h
+++ b/math/sinetables.h
@@ -19,14 +19,16 @@
*
*/
-#ifndef COMMON_SINETABLES_H
-#define COMMON_SINETABLES_H
+#ifndef MATH_SINETABLES_H
+#define MATH_SINETABLES_H
-namespace Common {
+#include "common/scummsys.h"
+
+namespace Math {
/**
- * @defgroup common_sinetables Sine tables
- * @ingroup common
+ * @defgroup math_sinetables Sine tables
+ * @ingroup math
*
* @brief API for managing sine tables.
*
@@ -79,6 +81,6 @@ private:
/** @} */
-} // End of namespace Common
+} // End of namespace Math
-#endif // COMMON_SINETABLES_H
+#endif // MATH_SINETABLES_H
diff --git a/common/sinewindows.cpp b/math/sinewindows.cpp
similarity index 99%
rename from common/sinewindows.cpp
rename to math/sinewindows.cpp
index da36025df4d..6f3516e12bc 100644
--- a/common/sinewindows.cpp
+++ b/math/sinewindows.cpp
@@ -19,10 +19,9 @@
*
*/
-#include "common/scummsys.h"
-#include "common/sinewindows.h"
+#include "math/sinewindows.h"
-namespace Common {
+namespace Math {
static const float sineWindow32[32] = {
0.024541, 0.073565, 0.122411, 0.170962, 0.219101, 0.266713, 0.313682, 0.359895,
@@ -1080,4 +1079,4 @@ const float *getSineWindow(int bits) {
return sineWindows[bits];
}
-} // End of namespace Common
+} // End of namespace Math
diff --git a/common/sinewindows.h b/math/sinewindows.h
similarity index 85%
rename from common/sinewindows.h
rename to math/sinewindows.h
index 6247f3564c9..8a5a0f594bf 100644
--- a/common/sinewindows.h
+++ b/math/sinewindows.h
@@ -21,13 +21,15 @@
// Based on xoreos' SineWindow code
-#ifndef COMMON_SINEWINDOWS_H
-#define COMMON_SINEWINDOWS_H
+#ifndef MATH_SINEWINDOWS_H
+#define MATH_SINEWINDOWS_H
-namespace Common {
+#include "common/scummsys.h"
+
+namespace Math {
const float *getSineWindow(int bits);
-} // End of namespace Common
+} // End of namespace Math
-#endif // COMMON_SINEWINDOWS_H
+#endif // MATH_SINEWINDOWS_H
diff --git a/math/utils.h b/math/utils.h
index 55acf578ef6..28d8728c087 100644
--- a/math/utils.h
+++ b/math/utils.h
@@ -26,6 +26,11 @@
namespace Math {
+/** A complex number. */
+struct Complex {
+ float re, im;
+};
+
/* Math::epsilon is a constant with a small value which is used for comparing
* floating point numbers.
*
diff --git a/video/bink_decoder.cpp b/video/bink_decoder.cpp
index 1c4d08cd82a..30de3d478dc 100644
--- a/video/bink_decoder.cpp
+++ b/video/bink_decoder.cpp
@@ -35,13 +35,14 @@
#include "common/str.h"
#include "common/bitstream.h"
#include "common/huffman.h"
-#include "common/rdft.h"
-#include "common/dct.h"
#include "common/system.h"
#include "graphics/yuv_to_rgb.h"
#include "graphics/surface.h"
+#include "math/rdft.h"
+#include "math/dct.h"
+
#include "video/binkdata.h"
#include "video/bink_decoder.h"
@@ -1725,9 +1726,9 @@ void BinkDecoder::initAudioTrack(AudioInfo &audio) {
audio.codec = ((audio.flags & kAudioFlagDCT) != 0) ? kAudioCodecDCT : kAudioCodecRDFT;
if (audio.codec == kAudioCodecRDFT)
- audio.rdft = new Common::RDFT(frameLenBits, Common::RDFT::DFT_C2R);
+ audio.rdft = new Math::RDFT(frameLenBits, Math::RDFT::DFT_C2R);
else if (audio.codec == kAudioCodecDCT)
- audio.dct = new Common::DCT(frameLenBits, Common::DCT::DCT_III);
+ audio.dct = new Math::DCT(frameLenBits, Math::DCT::DCT_III);
addTrack(new BinkAudioTrack(audio, getSoundType()));
}
diff --git a/video/bink_decoder.h b/video/bink_decoder.h
index 9b0693470d3..e21d6777a7f 100644
--- a/video/bink_decoder.h
+++ b/video/bink_decoder.h
@@ -47,7 +47,9 @@ namespace Common {
class SeekableReadStream;
template <class BITSTREAM>
class Huffman;
+}
+namespace Math {
class RDFT;
class DCT;
}
@@ -123,8 +125,8 @@ private:
float *coeffsPtr[kAudioChannelsMax];
- Common::RDFT *rdft;
- Common::DCT *dct;
+ Math::RDFT *rdft;
+ Math::DCT *dct;
AudioInfo();
~AudioInfo();
More information about the Scummvm-git-logs
mailing list