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/rdft.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'common/rdft.cpp') diff --git a/common/rdft.cpp b/common/rdft.cpp index 3f52a89cba..3ebbf2e058 100644 --- a/common/rdft.cpp +++ b/common/rdft.cpp @@ -40,12 +40,16 @@ RDFT::RDFT(int bits, TransformType trans) : _bits(bits), _fft(0) { int n = 1 << bits; - _tSin = getSineTable(bits) + (trans == DFT_R2C || trans == DFT_C2R) * (n >> 2); - _tCos = getCosineTable(bits); + _sin = new SineTable(bits); + _tSin = _sin->getTable() + (trans == DFT_R2C || trans == DFT_C2R) * (n >> 2); + _cos = new CosineTable(bits); + _tCos = _cos->getTable(); } RDFT::~RDFT() { delete _fft; + delete _sin; + delete _cos; } void RDFT::calc(float *data) { -- cgit v1.2.3 From 0f66d2c701958dc70ed57b570a7f59965a90bf66 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Tue, 17 Apr 2012 22:12:20 +0100 Subject: COMMON: Update DCT & RDFT to avoid dynamic allocation of Sine/Cos Tables. --- common/rdft.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'common/rdft.cpp') 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 #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) { -- cgit v1.2.3