COMMON: Move FFT, DCT, MDCT, RDFT, SineTable, CosineTable and getSineWindow into Math
This commit is contained in:
parent
3441c7230d
commit
e04000d4b0
31 changed files with 151 additions and 137 deletions
|
@ -34,12 +34,13 @@
|
||||||
#include "common/array.h"
|
#include "common/array.h"
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
#include "common/math.h"
|
#include "common/math.h"
|
||||||
#include "common/rdft.h"
|
|
||||||
#include "common/stream.h"
|
#include "common/stream.h"
|
||||||
#include "common/memstream.h"
|
#include "common/memstream.h"
|
||||||
#include "common/bitstream.h"
|
#include "common/bitstream.h"
|
||||||
#include "common/textconsole.h"
|
#include "common/textconsole.h"
|
||||||
|
|
||||||
|
#include "math/rdft.h"
|
||||||
|
|
||||||
namespace Audio {
|
namespace Audio {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -143,7 +144,7 @@ private:
|
||||||
int _fftCoefsMinIndex[5];
|
int _fftCoefsMinIndex[5];
|
||||||
int _fftCoefsMaxIndex[5];
|
int _fftCoefsMaxIndex[5];
|
||||||
int _fftLevelExp[6];
|
int _fftLevelExp[6];
|
||||||
Common::RDFT *_rdft;
|
Math::RDFT *_rdft;
|
||||||
QDM2FFT _fft;
|
QDM2FFT _fft;
|
||||||
|
|
||||||
// I/O data
|
// I/O data
|
||||||
|
@ -1201,7 +1202,7 @@ QDM2Stream::QDM2Stream(Common::SeekableReadStream *extraData, DisposeAfterUse::F
|
||||||
if (_fftOrder < 7 || _fftOrder > 9)
|
if (_fftOrder < 7 || _fftOrder > 9)
|
||||||
error("QDM2Stream::QDM2Stream() Unsupported fft_order: %d", _fftOrder);
|
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();
|
initVlc();
|
||||||
ff_mpa_synth_init(ff_mpa_synth_window);
|
ff_mpa_synth_init(ff_mpa_synth_window);
|
||||||
|
|
|
@ -24,12 +24,13 @@
|
||||||
|
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
#include "common/math.h"
|
#include "common/math.h"
|
||||||
#include "common/sinewindows.h"
|
|
||||||
#include "common/error.h"
|
#include "common/error.h"
|
||||||
#include "common/memstream.h"
|
#include "common/memstream.h"
|
||||||
#include "common/mdct.h"
|
|
||||||
#include "common/huffman.h"
|
#include "common/huffman.h"
|
||||||
|
|
||||||
|
#include "math/mdct.h"
|
||||||
|
#include "math/sinewindows.h"
|
||||||
|
|
||||||
#include "audio/audiostream.h"
|
#include "audio/audiostream.h"
|
||||||
|
|
||||||
#include "audio/decoders/util.h"
|
#include "audio/decoders/util.h"
|
||||||
|
@ -114,7 +115,7 @@ WMACodec::~WMACodec() {
|
||||||
delete _coefHuffman[i];
|
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;
|
delete *m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,12 +460,12 @@ void WMACodec::initCoefHuffman(float bps) {
|
||||||
void WMACodec::initMDCT() {
|
void WMACodec::initMDCT() {
|
||||||
_mdct.reserve(_blockSizeCount);
|
_mdct.reserve(_blockSizeCount);
|
||||||
for (int i = 0; i < _blockSizeCount; i++)
|
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)
|
// Init MDCT windows (simple sine window)
|
||||||
_mdctWindow.reserve(_blockSizeCount);
|
_mdctWindow.reserve(_blockSizeCount);
|
||||||
for (int i = 0; i < _blockSizeCount; i++)
|
for (int i = 0; i < _blockSizeCount; i++)
|
||||||
_mdctWindow.push_back(Common::getSineWindow(_frameLenBits - i));
|
_mdctWindow.push_back(Math::getSineWindow(_frameLenBits - i));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WMACodec::initExponents() {
|
void WMACodec::initExponents() {
|
||||||
|
@ -801,7 +802,7 @@ bool WMACodec::decodeChannels(Common::BitStream8MSB &bits, int bSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WMACodec::calculateIMDCT(int bSize, bool msStereo, bool *hasChannel) {
|
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++) {
|
for (int i = 0; i < _channels; i++) {
|
||||||
int n4 = _blockLen / 2;
|
int n4 = _blockLen / 2;
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
namespace Common {
|
namespace Common {
|
||||||
template <class BITSTREAM>
|
template <class BITSTREAM>
|
||||||
class Huffman;
|
class Huffman;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Math {
|
||||||
class MDCT;
|
class MDCT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +149,7 @@ private:
|
||||||
float _lspPowMTable2[(1 << kLSPPowBits)];
|
float _lspPowMTable2[(1 << kLSPPowBits)];
|
||||||
|
|
||||||
// MDCT
|
// MDCT
|
||||||
Common::Array<Common::MDCT *> _mdct; ///< MDCT contexts.
|
Common::Array<Math::MDCT *> _mdct; ///< MDCT contexts.
|
||||||
Common::Array<const float *> _mdctWindow; ///< MDCT window functions.
|
Common::Array<const float *> _mdctWindow; ///< MDCT window functions.
|
||||||
|
|
||||||
/** Overhang from the last superframe. */
|
/** Overhang from the last superframe. */
|
||||||
|
|
|
@ -239,6 +239,10 @@
|
||||||
#undef False
|
#undef False
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef Complex
|
||||||
|
#undef Complex
|
||||||
|
#endif
|
||||||
|
|
||||||
// Finally forbid FILE again (if it was forbidden to start with)
|
// Finally forbid FILE again (if it was forbidden to start with)
|
||||||
#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_FILE)
|
#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && !defined(FORBIDDEN_SYMBOL_EXCEPTION_FILE)
|
||||||
#undef FILE
|
#undef FILE
|
||||||
|
|
|
@ -61,11 +61,6 @@
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
/** A complex number. */
|
|
||||||
struct Complex {
|
|
||||||
float re, im;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
inline int intLog2(uint32 v) {
|
inline int intLog2(uint32 v) {
|
||||||
// This is a slightly optimized implementation of log2 for natural numbers
|
// This is a slightly optimized implementation of log2 for natural numbers
|
||||||
|
|
|
@ -26,7 +26,6 @@ MODULE_OBJS := \
|
||||||
macresman.o \
|
macresman.o \
|
||||||
memorypool.o \
|
memorypool.o \
|
||||||
md5.o \
|
md5.o \
|
||||||
mdct.o \
|
|
||||||
mutex.o \
|
mutex.o \
|
||||||
osd_message_queue.o \
|
osd_message_queue.o \
|
||||||
path.o \
|
path.o \
|
||||||
|
@ -36,7 +35,6 @@ MODULE_OBJS := \
|
||||||
random.o \
|
random.o \
|
||||||
rational.o \
|
rational.o \
|
||||||
rendermode.o \
|
rendermode.o \
|
||||||
sinewindows.o \
|
|
||||||
str.o \
|
str.o \
|
||||||
stream.o \
|
stream.o \
|
||||||
streamdebug.o \
|
streamdebug.o \
|
||||||
|
@ -60,13 +58,6 @@ MODULE_OBJS := \
|
||||||
xpfloat.o \
|
xpfloat.o \
|
||||||
zlib.o
|
zlib.o
|
||||||
|
|
||||||
MODULE_OBJS += \
|
|
||||||
cosinetables.o \
|
|
||||||
dct.o \
|
|
||||||
fft.o \
|
|
||||||
rdft.o \
|
|
||||||
sinetables.o
|
|
||||||
|
|
||||||
ifdef ENABLE_EVENTRECORDER
|
ifdef ENABLE_EVENTRECORDER
|
||||||
MODULE_OBJS += \
|
MODULE_OBJS += \
|
||||||
recorderfile.o
|
recorderfile.o
|
||||||
|
|
|
@ -702,8 +702,8 @@ bool BladeRunnerEngine::startup(bool hasSavegames) {
|
||||||
|
|
||||||
// Seed rand
|
// Seed rand
|
||||||
|
|
||||||
_cosTable1024 = new Common::CosineTable(1024); // 10-bits = 1024 points for 2*PI;
|
_cosTable1024 = new Math::CosineTable(1024); // 10-bits = 1024 points for 2*PI;
|
||||||
_sinTable1024 = new Common::SineTable(1024);
|
_sinTable1024 = new Math::SineTable(1024);
|
||||||
|
|
||||||
_view = new View();
|
_view = new View();
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,7 @@
|
||||||
#include "bladerunner/archive.h"
|
#include "bladerunner/archive.h"
|
||||||
|
|
||||||
#include "common/array.h"
|
#include "common/array.h"
|
||||||
#include "common/cosinetables.h"
|
|
||||||
#include "common/random.h"
|
#include "common/random.h"
|
||||||
#include "common/sinetables.h"
|
|
||||||
#include "common/stream.h"
|
#include "common/stream.h"
|
||||||
#include "common/keyboard.h"
|
#include "common/keyboard.h"
|
||||||
#include "common/events.h"
|
#include "common/events.h"
|
||||||
|
@ -36,6 +34,9 @@
|
||||||
|
|
||||||
#include "graphics/surface.h"
|
#include "graphics/surface.h"
|
||||||
|
|
||||||
|
#include "math/cosinetables.h"
|
||||||
|
#include "math/sinetables.h"
|
||||||
|
|
||||||
//TODO: change this to debugflag
|
//TODO: change this to debugflag
|
||||||
#define BLADERUNNER_DEBUG_CONSOLE 0
|
#define BLADERUNNER_DEBUG_CONSOLE 0
|
||||||
#define BLADERUNNER_ORIGINAL_SETTINGS 0
|
#define BLADERUNNER_ORIGINAL_SETTINGS 0
|
||||||
|
@ -213,8 +214,8 @@ public:
|
||||||
|
|
||||||
Debugger *_debugger;
|
Debugger *_debugger;
|
||||||
|
|
||||||
Common::CosineTable *_cosTable1024;
|
Math::CosineTable *_cosTable1024;
|
||||||
Common::SineTable *_sinTable1024;
|
Math::SineTable *_sinTable1024;
|
||||||
|
|
||||||
bool _isWalkingInterruptible;
|
bool _isWalkingInterruptible;
|
||||||
bool _interruptWalking;
|
bool _interruptWalking;
|
||||||
|
|
|
@ -19,12 +19,12 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common/cosinetables.h"
|
|
||||||
#include "common/sinetables.h"
|
|
||||||
#include "common/random.h"
|
#include "common/random.h"
|
||||||
#include "common/memstream.h"
|
#include "common/memstream.h"
|
||||||
#include "graphics/cursor.h"
|
#include "graphics/cursor.h"
|
||||||
#include "graphics/cursorman.h"
|
#include "graphics/cursorman.h"
|
||||||
|
#include "math/cosinetables.h"
|
||||||
|
#include "math/sinetables.h"
|
||||||
|
|
||||||
#include "hdb/hdb.h"
|
#include "hdb/hdb.h"
|
||||||
#include "hdb/ai.h"
|
#include "hdb/ai.h"
|
||||||
|
@ -42,8 +42,8 @@ Gfx::Gfx() {
|
||||||
_gfxCache = new Common::Array<GfxCache *>;
|
_gfxCache = new Common::Array<GfxCache *>;
|
||||||
_globalSurface.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_format);
|
_globalSurface.create(g_hdb->_screenWidth, g_hdb->_screenHeight, g_hdb->_format);
|
||||||
_pointerDisplayable = 1;
|
_pointerDisplayable = 1;
|
||||||
_sines = new Common::SineTable(360);
|
_sines = new Math::SineTable(360);
|
||||||
_cosines = new Common::CosineTable(360);
|
_cosines = new Math::CosineTable(360);
|
||||||
_systemInit = false;
|
_systemInit = false;
|
||||||
|
|
||||||
_numTiles = 0;
|
_numTiles = 0;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include "graphics/managed_surface.h"
|
#include "graphics/managed_surface.h"
|
||||||
|
|
||||||
namespace Common {
|
namespace Math {
|
||||||
class SineTable;
|
class SineTable;
|
||||||
class CosineTable;
|
class CosineTable;
|
||||||
}
|
}
|
||||||
|
@ -227,8 +227,8 @@ private:
|
||||||
|
|
||||||
bool _systemInit;
|
bool _systemInit;
|
||||||
|
|
||||||
Common::SineTable *_sines;
|
Math::SineTable *_sines;
|
||||||
Common::CosineTable *_cosines;
|
Math::CosineTable *_cosines;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Picture {
|
class Picture {
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#ifndef STARTREK_H
|
#ifndef STARTREK_H
|
||||||
#define STARTREK_H
|
#define STARTREK_H
|
||||||
|
|
||||||
#include "common/cosinetables.h"
|
|
||||||
#include "common/events.h"
|
#include "common/events.h"
|
||||||
#include "common/list.h"
|
#include "common/list.h"
|
||||||
#include "common/ptr.h"
|
#include "common/ptr.h"
|
||||||
|
@ -30,7 +29,6 @@
|
||||||
#include "common/rect.h"
|
#include "common/rect.h"
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
#include "common/serializer.h"
|
#include "common/serializer.h"
|
||||||
#include "common/sinetables.h"
|
|
||||||
#include "common/str.h"
|
#include "common/str.h"
|
||||||
#include "common/stream.h"
|
#include "common/stream.h"
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
|
@ -40,6 +38,9 @@
|
||||||
|
|
||||||
#include "engines/engine.h"
|
#include "engines/engine.h"
|
||||||
|
|
||||||
|
#include "math/cosinetables.h"
|
||||||
|
#include "math/sinetables.h"
|
||||||
|
|
||||||
#include "startrek/action.h"
|
#include "startrek/action.h"
|
||||||
#include "startrek/awaymission.h"
|
#include "startrek/awaymission.h"
|
||||||
#include "startrek/graphics.h"
|
#include "startrek/graphics.h"
|
||||||
|
@ -803,8 +804,8 @@ private:
|
||||||
void bridgeLeftClick();
|
void bridgeLeftClick();
|
||||||
|
|
||||||
Common::RandomSource _randomSource;
|
Common::RandomSource _randomSource;
|
||||||
Common::SineTable _sineTable;
|
Math::SineTable _sineTable;
|
||||||
Common::CosineTable _cosineTable;
|
Math::CosineTable _cosineTable;
|
||||||
Room *_room;
|
Room *_room;
|
||||||
Common::List<ComputerTopic> _computerTopics;
|
Common::List<ComputerTopic> _computerTopics;
|
||||||
};
|
};
|
||||||
|
|
|
@ -322,7 +322,7 @@ MSNImage *ResourceManager::getImage(int filenumber) {
|
||||||
// Generate a tone which minimal length is the length and ends at the end
|
// Generate a tone which minimal length is the length and ends at the end
|
||||||
// of sine period
|
// of sine period
|
||||||
// NOTE: Size of the SineTable has to be the same as audioRate and a multiple of 4
|
// 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;
|
int i = 0;
|
||||||
|
|
||||||
// Make sure length is a multiple of audioRate / frequency to end on a full sine wave and not in the middle.
|
// 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
|
// * 60 for the minimal length, another 20 * length as a spare, for longer tones
|
||||||
byte *buffer = new byte[length * 80];
|
byte *buffer = new byte[length * 80];
|
||||||
byte *pBuffer = buffer;
|
byte *pBuffer = buffer;
|
||||||
Common::SineTable table(audioRate);
|
Math::SineTable table(audioRate);
|
||||||
|
|
||||||
for (int i = 0; i < 30; i++)
|
for (int i = 0; i < 30; i++)
|
||||||
pBuffer = generateTone(pBuffer, 1800 - i * 10, length, audioRate, table);
|
pBuffer = generateTone(pBuffer, 1800 - i * 10, length, audioRate, table);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include "audio/audiostream.h"
|
#include "audio/audiostream.h"
|
||||||
#include "common/ptr.h"
|
#include "common/ptr.h"
|
||||||
#include "common/sinetables.h"
|
#include "math/sinetables.h"
|
||||||
|
|
||||||
#include "supernova/graphics.h"
|
#include "supernova/graphics.h"
|
||||||
#include "supernova/sound.h"
|
#include "supernova/sound.h"
|
||||||
|
@ -69,7 +69,7 @@ private:
|
||||||
void loadSound1(AudioId id);
|
void loadSound1(AudioId id);
|
||||||
void loadSound2(AudioId id);
|
void loadSound2(AudioId id);
|
||||||
void initSiren();
|
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:
|
private:
|
||||||
Common::ScopedPtr<Audio::SeekableAudioStream> *_soundSamples;
|
Common::ScopedPtr<Audio::SeekableAudioStream> *_soundSamples;
|
||||||
|
|
|
@ -21,10 +21,9 @@
|
||||||
|
|
||||||
// Based on eos' cosine tables
|
// Based on eos' cosine tables
|
||||||
|
|
||||||
#include "common/cosinetables.h"
|
#include "math/cosinetables.h"
|
||||||
#include "common/scummsys.h"
|
|
||||||
|
|
||||||
namespace Common {
|
namespace Math {
|
||||||
|
|
||||||
CosineTable::CosineTable(int nPoints) {
|
CosineTable::CosineTable(int nPoints) {
|
||||||
assert((nPoints >= 16) && (nPoints <= 65536)); // log2 space is in [4,16]
|
assert((nPoints >= 16) && (nPoints <= 65536)); // log2 space is in [4,16]
|
||||||
|
@ -75,4 +74,4 @@ CosineTable::~CosineTable() {
|
||||||
delete[] _table;
|
delete[] _table;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace Common
|
} // End of namespace Math
|
|
@ -19,14 +19,16 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef COMMON_COSINETABLES_H
|
#ifndef MATH_COSINETABLES_H
|
||||||
#define COMMON_COSINETABLES_H
|
#define MATH_COSINETABLES_H
|
||||||
|
|
||||||
namespace Common {
|
#include "common/scummsys.h"
|
||||||
|
|
||||||
|
namespace Math {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup common_cosinetables Cosine tables
|
* @defgroup math_cosinetables Cosine tables
|
||||||
* @ingroup common
|
* @ingroup math
|
||||||
*
|
*
|
||||||
* @brief Functions for working with cosine tables.
|
* @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
|
|
@ -25,9 +25,10 @@
|
||||||
// Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
|
// Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
|
||||||
// Copyright (c) 2010 Vitor Sessak
|
// 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) {
|
DCT::DCT(int bits, TransformType trans) : _bits(bits), _cos(1 << (_bits + 2) ), _trans(trans), _rdft(nullptr) {
|
||||||
int n = 1 << _bits;
|
int n = 1 << _bits;
|
||||||
|
@ -205,4 +206,4 @@ void DCT::calcDSTI(float *data) {
|
||||||
data[n - 1] = 0;
|
data[n - 1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace Common
|
} // End of namespace Math
|
|
@ -25,20 +25,18 @@
|
||||||
// Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
|
// Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
|
||||||
// Copyright (c) 2010 Vitor Sessak
|
// Copyright (c) 2010 Vitor Sessak
|
||||||
|
|
||||||
#ifndef COMMON_DCT_H
|
#ifndef MATH_DCT_H
|
||||||
#define COMMON_DCT_H
|
#define MATH_DCT_H
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "math/cosinetables.h"
|
||||||
#include "common/math.h"
|
|
||||||
#include "common/rdft.h"
|
|
||||||
|
|
||||||
#include "common/cosinetables.h"
|
namespace Math {
|
||||||
|
|
||||||
namespace Common {
|
class RDFT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup common_dct Discrete Cosine Transforms
|
* @defgroup math_dct Discrete Cosine Transforms
|
||||||
* @ingroup common
|
* @ingroup math
|
||||||
*
|
*
|
||||||
* @brief Discrete Cosine Transforms.
|
* @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
|
|
@ -25,12 +25,12 @@
|
||||||
// Copyright (c) 2002 Fabrice Bellard
|
// Copyright (c) 2002 Fabrice Bellard
|
||||||
// Partly based on libdjbfft by D. J. Bernstein
|
// Partly based on libdjbfft by D. J. Bernstein
|
||||||
|
|
||||||
#include "common/cosinetables.h"
|
#include "math/fft.h"
|
||||||
#include "common/fft.h"
|
#include "math/cosinetables.h"
|
||||||
|
#include "math/utils.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
#include "common/textconsole.h"
|
|
||||||
|
|
||||||
namespace Common {
|
namespace Math {
|
||||||
|
|
||||||
FFT::FFT(int bits, int inverse) : _bits(bits), _inverse(inverse) {
|
FFT::FFT(int bits, int inverse) : _bits(bits), _inverse(inverse) {
|
||||||
assert((_bits >= 2) && (_bits <= 16));
|
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++) {
|
for (int i = 0; i < ARRAYSIZE(_cosTables); i++) {
|
||||||
if (i + 4 <= _bits) {
|
if (i + 4 <= _bits) {
|
||||||
nPoints = 1 << (i + 4);
|
nPoints = 1 << (i + 4);
|
||||||
_cosTables[i] = new Common::CosineTable(nPoints);
|
_cosTables[i] = new CosineTable(nPoints);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_cosTables[i] = nullptr;
|
_cosTables[i] = nullptr;
|
||||||
|
@ -255,4 +255,4 @@ void FFT::calc(Complex *z) {
|
||||||
fft(1 << _bits, _bits, z);
|
fft(1 << _bits, _bits, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace Common
|
} // End of namespace Math
|
|
@ -25,17 +25,16 @@
|
||||||
// Copyright (c) 2002 Fabrice Bellard
|
// Copyright (c) 2002 Fabrice Bellard
|
||||||
// Partly based on libdjbfft by D. J. Bernstein
|
// Partly based on libdjbfft by D. J. Bernstein
|
||||||
|
|
||||||
#ifndef COMMON_FFT_H
|
#ifndef MATH_FFT_H
|
||||||
#define COMMON_FFT_H
|
#define MATH_FFT_H
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
#include "common/math.h"
|
|
||||||
|
|
||||||
namespace Common {
|
namespace Math {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup common_fft Fast Fourier Transform (FFT)
|
* @defgroup math_fft Fast Fourier Transform (FFT)
|
||||||
* @ingroup common
|
* @ingroup math
|
||||||
*
|
*
|
||||||
* @brief API for the FFT algorithm.
|
* @brief API for the FFT algorithm.
|
||||||
*
|
*
|
||||||
|
@ -43,6 +42,7 @@ namespace Common {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class CosineTable;
|
class CosineTable;
|
||||||
|
struct Complex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (Inverse) Fast Fourier Transform.
|
* (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
|
|
@ -23,16 +23,16 @@
|
||||||
// Based upon the (I)MDCT code in FFmpeg
|
// Based upon the (I)MDCT code in FFmpeg
|
||||||
// Copyright (c) 2002 Fabrice Bellard
|
// Copyright (c) 2002 Fabrice Bellard
|
||||||
|
|
||||||
/** @file common/mdct.cpp
|
/** @file math/mdct.cpp
|
||||||
* (Inverse) Modified Discrete Cosine Transforms.
|
* (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/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) {
|
MDCT::MDCT(int bits, bool inverse, double scale) : _bits(bits), _fft(nullptr) {
|
||||||
_size = 1 << bits;
|
_size = 1 << bits;
|
||||||
|
@ -156,4 +156,4 @@ void MDCT::calcHalfIMDCT(float *output, const float *input) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace Common
|
} // End of namespace Math
|
|
@ -24,12 +24,12 @@
|
||||||
// Copyright (c) 2002 Fabrice Bellard
|
// Copyright (c) 2002 Fabrice Bellard
|
||||||
|
|
||||||
|
|
||||||
#ifndef COMMON_MDCT_H
|
#ifndef MATH_MDCT_H
|
||||||
#define COMMON_MDCT_H
|
#define MATH_MDCT_H
|
||||||
|
|
||||||
#include "common/types.h"
|
#include "common/scummsys.h"
|
||||||
|
|
||||||
namespace Common {
|
namespace Math {
|
||||||
|
|
||||||
class FFT;
|
class FFT;
|
||||||
|
|
||||||
|
@ -60,6 +60,6 @@ private:
|
||||||
void calcHalfIMDCT(float *output, const float *input);
|
void calcHalfIMDCT(float *output, const float *input);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Common
|
} // End of namespace Math
|
||||||
|
|
||||||
#endif // COMMON_MDCT_H
|
#endif // MATH_MDCT_H
|
|
@ -3,16 +3,23 @@ MODULE := math
|
||||||
MODULE_OBJS := \
|
MODULE_OBJS := \
|
||||||
aabb.o \
|
aabb.o \
|
||||||
angle.o \
|
angle.o \
|
||||||
|
cosinetables.o \
|
||||||
|
dct.o \
|
||||||
|
fft.o \
|
||||||
frustum.o \
|
frustum.o \
|
||||||
glmath.o \
|
glmath.o \
|
||||||
line2d.o \
|
line2d.o \
|
||||||
line3d.o \
|
line3d.o \
|
||||||
matrix3.o \
|
matrix3.o \
|
||||||
matrix4.o \
|
matrix4.o \
|
||||||
|
mdct.o \
|
||||||
plane.o \
|
plane.o \
|
||||||
quat.o \
|
quat.o \
|
||||||
ray.o \
|
ray.o \
|
||||||
|
rdft.o \
|
||||||
rect2d.o \
|
rect2d.o \
|
||||||
|
sinetables.o \
|
||||||
|
sinewindows.o \
|
||||||
vector2d.o \
|
vector2d.o \
|
||||||
vector3d.o \
|
vector3d.o \
|
||||||
vector4d.o
|
vector4d.o
|
||||||
|
|
|
@ -23,9 +23,11 @@
|
||||||
// Based upon the (I)RDFT code in FFmpeg
|
// Based upon the (I)RDFT code in FFmpeg
|
||||||
// Copyright (c) 2009 Alex Converse <alex dot converse at gmail dot com>
|
// 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) {
|
RDFT::RDFT(int bits, TransformType trans) : _bits(bits), _sin(1 << bits), _cos(1 << bits), _fft(nullptr) {
|
||||||
assert((_bits >= 4) && (_bits <= 16));
|
assert((_bits >= 4) && (_bits <= 16));
|
||||||
|
@ -96,4 +98,4 @@ void RDFT::calc(float *data) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace Common
|
} // End of namespace Math
|
|
@ -23,21 +23,19 @@
|
||||||
// Based upon the (I)RDFT code in FFmpeg
|
// Based upon the (I)RDFT code in FFmpeg
|
||||||
// Copyright (c) 2009 Alex Converse <alex dot converse at gmail dot com>
|
// Copyright (c) 2009 Alex Converse <alex dot converse at gmail dot com>
|
||||||
|
|
||||||
#ifndef COMMON_RDFT_H
|
#ifndef MATH_RDFT_H
|
||||||
#define COMMON_RDFT_H
|
#define MATH_RDFT_H
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "math/cosinetables.h"
|
||||||
#include "common/math.h"
|
#include "math/sinetables.h"
|
||||||
#include "common/fft.h"
|
|
||||||
|
|
||||||
#include "common/cosinetables.h"
|
namespace Math {
|
||||||
#include "common/sinetables.h"
|
|
||||||
|
|
||||||
namespace Common {
|
class FFT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup common_rdft RDFT algorithm
|
* @defgroup math_rdft RDFT algorithm
|
||||||
* @ingroup common
|
* @ingroup math
|
||||||
*
|
*
|
||||||
* @brief API for the Real Discrete Fourier Transform (RDFT) algorithm.
|
* @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
|
|
@ -21,10 +21,9 @@
|
||||||
|
|
||||||
// Based on eos' sine tables
|
// Based on eos' sine tables
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "math/sinetables.h"
|
||||||
#include "common/sinetables.h"
|
|
||||||
|
|
||||||
namespace Common {
|
namespace Math {
|
||||||
|
|
||||||
SineTable::SineTable(int nPoints) {
|
SineTable::SineTable(int nPoints) {
|
||||||
assert((nPoints >= 16) && (nPoints <= 65536)); // log2 space is in [4,16]
|
assert((nPoints >= 16) && (nPoints <= 65536)); // log2 space is in [4,16]
|
||||||
|
@ -78,4 +77,4 @@ SineTable::~SineTable() {
|
||||||
delete[] _table;
|
delete[] _table;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace Common
|
} // End of namespace Math
|
|
@ -19,14 +19,16 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef COMMON_SINETABLES_H
|
#ifndef MATH_SINETABLES_H
|
||||||
#define COMMON_SINETABLES_H
|
#define MATH_SINETABLES_H
|
||||||
|
|
||||||
namespace Common {
|
#include "common/scummsys.h"
|
||||||
|
|
||||||
|
namespace Math {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup common_sinetables Sine tables
|
* @defgroup math_sinetables Sine tables
|
||||||
* @ingroup common
|
* @ingroup math
|
||||||
*
|
*
|
||||||
* @brief API for managing sine tables.
|
* @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
|
|
@ -19,10 +19,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "math/sinewindows.h"
|
||||||
#include "common/sinewindows.h"
|
|
||||||
|
|
||||||
namespace Common {
|
namespace Math {
|
||||||
|
|
||||||
static const float sineWindow32[32] = {
|
static const float sineWindow32[32] = {
|
||||||
0.024541, 0.073565, 0.122411, 0.170962, 0.219101, 0.266713, 0.313682, 0.359895,
|
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];
|
return sineWindows[bits];
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace Common
|
} // End of namespace Math
|
|
@ -21,13 +21,15 @@
|
||||||
|
|
||||||
// Based on xoreos' SineWindow code
|
// Based on xoreos' SineWindow code
|
||||||
|
|
||||||
#ifndef COMMON_SINEWINDOWS_H
|
#ifndef MATH_SINEWINDOWS_H
|
||||||
#define COMMON_SINEWINDOWS_H
|
#define MATH_SINEWINDOWS_H
|
||||||
|
|
||||||
namespace Common {
|
#include "common/scummsys.h"
|
||||||
|
|
||||||
|
namespace Math {
|
||||||
|
|
||||||
const float *getSineWindow(int bits);
|
const float *getSineWindow(int bits);
|
||||||
|
|
||||||
} // End of namespace Common
|
} // End of namespace Math
|
||||||
|
|
||||||
#endif // COMMON_SINEWINDOWS_H
|
#endif // MATH_SINEWINDOWS_H
|
|
@ -26,6 +26,11 @@
|
||||||
|
|
||||||
namespace Math {
|
namespace Math {
|
||||||
|
|
||||||
|
/** A complex number. */
|
||||||
|
struct Complex {
|
||||||
|
float re, im;
|
||||||
|
};
|
||||||
|
|
||||||
/* Math::epsilon is a constant with a small value which is used for comparing
|
/* Math::epsilon is a constant with a small value which is used for comparing
|
||||||
* floating point numbers.
|
* floating point numbers.
|
||||||
*
|
*
|
||||||
|
|
|
@ -35,13 +35,14 @@
|
||||||
#include "common/str.h"
|
#include "common/str.h"
|
||||||
#include "common/bitstream.h"
|
#include "common/bitstream.h"
|
||||||
#include "common/huffman.h"
|
#include "common/huffman.h"
|
||||||
#include "common/rdft.h"
|
|
||||||
#include "common/dct.h"
|
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
|
|
||||||
#include "graphics/yuv_to_rgb.h"
|
#include "graphics/yuv_to_rgb.h"
|
||||||
#include "graphics/surface.h"
|
#include "graphics/surface.h"
|
||||||
|
|
||||||
|
#include "math/rdft.h"
|
||||||
|
#include "math/dct.h"
|
||||||
|
|
||||||
#include "video/binkdata.h"
|
#include "video/binkdata.h"
|
||||||
#include "video/bink_decoder.h"
|
#include "video/bink_decoder.h"
|
||||||
|
|
||||||
|
@ -1725,9 +1726,9 @@ void BinkDecoder::initAudioTrack(AudioInfo &audio) {
|
||||||
audio.codec = ((audio.flags & kAudioFlagDCT) != 0) ? kAudioCodecDCT : kAudioCodecRDFT;
|
audio.codec = ((audio.flags & kAudioFlagDCT) != 0) ? kAudioCodecDCT : kAudioCodecRDFT;
|
||||||
|
|
||||||
if (audio.codec == 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)
|
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()));
|
addTrack(new BinkAudioTrack(audio, getSoundType()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,9 @@ namespace Common {
|
||||||
class SeekableReadStream;
|
class SeekableReadStream;
|
||||||
template <class BITSTREAM>
|
template <class BITSTREAM>
|
||||||
class Huffman;
|
class Huffman;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Math {
|
||||||
class RDFT;
|
class RDFT;
|
||||||
class DCT;
|
class DCT;
|
||||||
}
|
}
|
||||||
|
@ -123,8 +125,8 @@ private:
|
||||||
|
|
||||||
float *coeffsPtr[kAudioChannelsMax];
|
float *coeffsPtr[kAudioChannelsMax];
|
||||||
|
|
||||||
Common::RDFT *rdft;
|
Math::RDFT *rdft;
|
||||||
Common::DCT *dct;
|
Math::DCT *dct;
|
||||||
|
|
||||||
AudioInfo();
|
AudioInfo();
|
||||||
~AudioInfo();
|
~AudioInfo();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue