diff options
| author | D G Turner | 2012-04-17 22:12:20 +0100 | 
|---|---|---|
| committer | D G Turner | 2012-04-17 22:12:20 +0100 | 
| commit | 0f66d2c701958dc70ed57b570a7f59965a90bf66 (patch) | |
| tree | c1adcd1753206e57a7284fe096a2ae144f1675cc /common | |
| parent | aa61c9abd3d1f89b6e689a25a81040011a25a069 (diff) | |
| download | scummvm-rg350-0f66d2c701958dc70ed57b570a7f59965a90bf66.tar.gz scummvm-rg350-0f66d2c701958dc70ed57b570a7f59965a90bf66.tar.bz2 scummvm-rg350-0f66d2c701958dc70ed57b570a7f59965a90bf66.zip  | |
COMMON: Update DCT & RDFT to avoid dynamic allocation of Sine/Cos Tables.
Diffstat (limited to 'common')
| -rw-r--r-- | common/dct.cpp | 7 | ||||
| -rw-r--r-- | common/dct.h | 6 | ||||
| -rw-r--r-- | common/rdft.cpp | 12 | ||||
| -rw-r--r-- | common/rdft.h | 10 | 
4 files changed, 13 insertions, 22 deletions
diff --git a/common/dct.cpp b/common/dct.cpp index a353a9ad88..38b4fbcff2 100644 --- a/common/dct.cpp +++ b/common/dct.cpp @@ -26,16 +26,14 @@  // Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>  // Copyright (c) 2010 Vitor Sessak -#include "common/cosinetables.h"  #include "common/dct.h"  namespace Common { -DCT::DCT(int bits, TransformType trans) : _bits(bits), _trans(trans), _rdft(0) { +DCT::DCT(int bits, TransformType trans) : _bits(bits), _cos(_bits + 2), _trans(trans), _rdft(0) {  	int n = 1 << _bits; -	_cos = new Common::CosineTable(_bits + 2); -	_tCos = _cos->getTable(); +	_tCos = _cos.getTable();  	_csc2 = new float[n / 2]; @@ -48,7 +46,6 @@ DCT::DCT(int bits, TransformType trans) : _bits(bits), _trans(trans), _rdft(0) {  DCT::~DCT() {  	delete _rdft;  	delete[] _csc2; -	delete _cos;  }  void DCT::calc(float *data) { diff --git a/common/dct.h b/common/dct.h index 7e69899fdc..085423ddff 100644 --- a/common/dct.h +++ b/common/dct.h @@ -33,9 +33,9 @@  #include "common/math.h"  #include "common/rdft.h" -namespace Common { +#include "common/cosinetables.h" -class CosineTable; +namespace Common {  /**   * (Inverse) Discrete Cosine Transforms. @@ -61,7 +61,7 @@ private:  	int _bits;  	TransformType _trans; -	CosineTable *_cos; +	CosineTable _cos;  	const float *_tCos;  	float *_csc2; diff --git a/common/rdft.cpp b/common/rdft.cpp index 3ebbf2e058..bfd6818fbd 100644 --- a/common/rdft.cpp +++ b/common/rdft.cpp @@ -25,12 +25,10 @@  // Copyright (c) 2009 Alex Converse <alex dot converse at gmail dot com>  #include "common/rdft.h" -#include "common/cosinetables.h" -#include "common/sinetables.h"  namespace Common { -RDFT::RDFT(int bits, TransformType trans) : _bits(bits), _fft(0) { +RDFT::RDFT(int bits, TransformType trans) : _bits(bits), _sin(bits), _cos(bits), _fft(0) {  	assert ((_bits >= 4) && (_bits <= 16));  	_inverse        = trans == IDFT_C2R || trans == DFT_C2R; @@ -40,16 +38,12 @@ RDFT::RDFT(int bits, TransformType trans) : _bits(bits), _fft(0) {  	int n = 1 << bits; -	_sin = new SineTable(bits); -	_tSin = _sin->getTable() + (trans == DFT_R2C || trans == DFT_C2R) * (n >> 2); -	_cos = new CosineTable(bits); -	_tCos = _cos->getTable(); +	_tSin = _sin.getTable() + (trans == DFT_R2C || trans == DFT_C2R) * (n >> 2); +	_tCos = _cos.getTable();  }  RDFT::~RDFT() {  	delete _fft; -	delete _sin; -	delete _cos;  }  void RDFT::calc(float *data) { diff --git a/common/rdft.h b/common/rdft.h index 04582b1fec..4bbde45d35 100644 --- a/common/rdft.h +++ b/common/rdft.h @@ -31,10 +31,10 @@  #include "common/math.h"  #include "common/fft.h" -namespace Common { +#include "common/cosinetables.h" +#include "common/sinetables.h" -class SineTable; -class CosineTable; +namespace Common {  /**   * (Inverse) Real Discrete Fourier Transform. @@ -62,8 +62,8 @@ private:  	int _inverse;  	int _signConvention; -	SineTable *_sin; -	CosineTable *_cos; +	SineTable _sin; +	CosineTable _cos;  	const float *_tSin;  	const float *_tCos;  | 
