[Scummvm-cvs-logs] scummvm master -> bc358b77a8b018901f58e43a8b530113c7716688

lordhoto lordhoto at gmail.com
Sat Jun 8 22:03:24 CEST 2013


This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
21f87070af COMMON: Fix regression in SineTable creation.
4efc9b152c COMMON: Save memory by allocating only required entries in Cosine-/SineTable.
4da5d11e1f COMMON: Try to document the SineTable/CosineTable table entries.
bc358b77a8 COMMON: Improve comment in CosineTable::CosineTable.


Commit: 21f87070afa31f30593e85a9ddd5fcb84c292ec8
    https://github.com/scummvm/scummvm/commit/21f87070afa31f30593e85a9ddd5fcb84c292ec8
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2013-06-08T12:47:51-07:00

Commit Message:
COMMON: Fix regression in SineTable creation.

This is a regression from f4ba8a6485b097a8ef1e2004d1af127243f379f1. The
commit replaced the static cosine and sine tables with dynamically created
ones. In the process of that a copy&paste error happened which made the sine
table use the layout of the cosine table. This commit now changes the
dynamically created sine tables to conform to the layout of the previous
static tables.

Changed paths:
    common/sinetables.cpp



diff --git a/common/sinetables.cpp b/common/sinetables.cpp
index a6ec994..2198dbf 100644
--- a/common/sinetables.cpp
+++ b/common/sinetables.cpp
@@ -36,13 +36,13 @@ SineTable::SineTable(int bitPrecision) {
 	double freq = 2 * M_PI / m;
 	_table = new float[m];
 
-	// Table contains sin(2*pi*x/n) for 0<=x<=n/4,
-	// followed by its reverse
-	for (int i = 0; i <= m / 4; i++)
+	// Table contains sin(2*pi*i/m) for 0<=i<m/4,
+	// followed by m/2<=i<3m/4
+	for (int i = 0; i < m / 4; i++)
 		_table[i] = sin(i * freq);
 
-	for (int i = 1; i < m / 4; i++)
-		_table[m / 2 - i] = _table[i];
+	for (int i = 0; i < m / 4; i++)
+		_table[m / 4 + i] = -_table[i];
 }
 
 SineTable::~SineTable() {


Commit: 4efc9b152c89aafe8a8b4f47c7f0d3d9db945df8
    https://github.com/scummvm/scummvm/commit/4efc9b152c89aafe8a8b4f47c7f0d3d9db945df8
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2013-06-08T12:47:52-07:00

Commit Message:
COMMON: Save memory by allocating only required entries in Cosine-/SineTable.

The tables only contain (2^bitPrecision)/2 entries. The code allocated twice
as many entries previously.

Changed paths:
    common/cosinetables.cpp
    common/sinetables.cpp



diff --git a/common/cosinetables.cpp b/common/cosinetables.cpp
index fe8f454..e6bf790 100644
--- a/common/cosinetables.cpp
+++ b/common/cosinetables.cpp
@@ -34,7 +34,7 @@ CosineTable::CosineTable(int bitPrecision) {
 
 	int m = 1 << _bitPrecision;
 	double freq = 2 * M_PI / m;
-	_table = new float[m];
+	_table = new float[m / 2];
 
 	// Table contains cos(2*pi*x/n) for 0<=x<=n/4,
 	// followed by its reverse
diff --git a/common/sinetables.cpp b/common/sinetables.cpp
index 2198dbf..7338166 100644
--- a/common/sinetables.cpp
+++ b/common/sinetables.cpp
@@ -34,7 +34,7 @@ SineTable::SineTable(int bitPrecision) {
 
 	int m = 1 << _bitPrecision;
 	double freq = 2 * M_PI / m;
-	_table = new float[m];
+	_table = new float[m / 2];
 
 	// Table contains sin(2*pi*i/m) for 0<=i<m/4,
 	// followed by m/2<=i<3m/4


Commit: 4da5d11e1f7eff787144289af08dd50cd788423e
    https://github.com/scummvm/scummvm/commit/4da5d11e1f7eff787144289af08dd50cd788423e
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2013-06-08T12:56:48-07:00

Commit Message:
COMMON: Try to document the SineTable/CosineTable table entries.

Changed paths:
    common/cosinetables.h
    common/sinetables.h



diff --git a/common/cosinetables.h b/common/cosinetables.h
index f9fb6fd..f5c95ec 100644
--- a/common/cosinetables.h
+++ b/common/cosinetables.h
@@ -36,7 +36,14 @@ public:
 	~CosineTable();
 
 	/**
-	 * Get pointer to table
+	 * Get pointer to table.
+	 *
+	 * This table contains 2^bitPrecision/2 entries.
+	 * The layout of this table is as follows:
+	 * - Entries 0 up to (excluding) 2^bitPrecision/4:
+	 *           cos(0) till (excluding) cos(1/2*pi)
+	 * - Entries 2^bitPrecision/4 up to (excluding) 2^bitPrecision/2:
+	 *           cos(3/2*pi) till (excluding) cos(2*pi)
 	 */
 	const float *getTable() { return _table; }
 
diff --git a/common/sinetables.h b/common/sinetables.h
index 16e203f..348966366 100644
--- a/common/sinetables.h
+++ b/common/sinetables.h
@@ -37,6 +37,13 @@ public:
 
 	/**
 	 * Get pointer to table
+	 *
+	 * This table contains 2^bitPrecision/2 entries.
+	 * The layout of this table is as follows:
+	 * - Entries 0 up to (excluding) 2^bitPrecision/4:
+	 *           sin(0) till (excluding) sin(1/2*pi)
+	 * - Entries 2^bitPrecision/4 up to (excluding) 2^bitPrecision/2:
+	 *           sin(pi) till (excluding) sin(3/2*pi)
 	 */
 	const float *getTable() { return _table; }
 


Commit: bc358b77a8b018901f58e43a8b530113c7716688
    https://github.com/scummvm/scummvm/commit/bc358b77a8b018901f58e43a8b530113c7716688
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2013-06-08T12:56:48-07:00

Commit Message:
COMMON: Improve comment in CosineTable::CosineTable.

This commit changes the comment to use the same variable names as we do in the
code. Furthermore, it also makes the comment a bit easier to grasp.

Changed paths:
    common/cosinetables.cpp



diff --git a/common/cosinetables.cpp b/common/cosinetables.cpp
index e6bf790..3b24575 100644
--- a/common/cosinetables.cpp
+++ b/common/cosinetables.cpp
@@ -36,8 +36,8 @@ CosineTable::CosineTable(int bitPrecision) {
 	double freq = 2 * M_PI / m;
 	_table = new float[m / 2];
 
-	// Table contains cos(2*pi*x/n) for 0<=x<=n/4,
-	// followed by its reverse
+	// Table contains cos(2*pi*i/m) for 0<=i<m/4,
+	// followed by 3m/4<=i<m
 	for (int i = 0; i <= m / 4; i++)
 		_table[i] = cos(i * freq);
 






More information about the Scummvm-git-logs mailing list