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/dct.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'common/dct.cpp') diff --git a/common/dct.cpp b/common/dct.cpp index 6525c727ae..a353a9ad88 100644 --- a/common/dct.cpp +++ b/common/dct.cpp @@ -34,7 +34,8 @@ namespace Common { DCT::DCT(int bits, TransformType trans) : _bits(bits), _trans(trans), _rdft(0) { int n = 1 << _bits; - _tCos = getCosineTable(_bits + 2); + _cos = new Common::CosineTable(_bits + 2); + _tCos = _cos->getTable(); _csc2 = new float[n / 2]; @@ -47,6 +48,7 @@ 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) { -- 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/dct.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'common/dct.cpp') 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 // 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) { -- cgit v1.2.3