[Scummvm-cvs-logs] SF.net SVN: scummvm:[55586] scummvm/trunk/graphics
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Fri Jan 28 10:46:39 CET 2011
Revision: 55586
http://scummvm.svn.sourceforge.net/scummvm/?rev=55586&view=rev
Author: fingolfin
Date: 2011-01-28 09:46:39 +0000 (Fri, 28 Jan 2011)
Log Message:
-----------
GRAPHICS: Turn sqrt(2) and cosine values into constants ;)
Modified Paths:
--------------
scummvm/trunk/graphics/jpeg.cpp
scummvm/trunk/graphics/jpeg.h
Modified: scummvm/trunk/graphics/jpeg.cpp
===================================================================
--- scummvm/trunk/graphics/jpeg.cpp 2011-01-28 09:37:11 UTC (rev 55585)
+++ scummvm/trunk/graphics/jpeg.cpp 2011-01-28 09:46:39 UTC (rev 55586)
@@ -33,6 +33,10 @@
namespace Graphics {
+#ifndef M_SQRT2
+#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
+#endif /* M_SQRT2 */
+
// Order used to traverse the quantization tables
static const uint8 _zigZagOrder[64] = {
0, 1, 8, 16, 9, 2, 3, 10,
@@ -45,6 +49,17 @@
53, 60, 61, 54, 47, 55, 62, 63
};
+static const float _cosine32[32] = {
+ 1.000000000000000, 0.980785280403230, 0.923879532511287, 0.831469612302545,
+ 0.707106781186548, 0.555570233019602, 0.382683432365090, 0.195090322016128,
+ 0.000000000000000, -0.195090322016128, -0.382683432365090, -0.555570233019602,
+ -0.707106781186547, -0.831469612302545, -0.923879532511287, -0.980785280403230,
+ -1.000000000000000, -0.980785280403230, -0.923879532511287, -0.831469612302545,
+ -0.707106781186548, -0.555570233019602, -0.382683432365090, -0.195090322016129,
+ -0.000000000000000, 0.195090322016128, 0.382683432365090, 0.555570233019602,
+ 0.707106781186547, 0.831469612302545, 0.923879532511287, 0.980785280403230
+};
+
JPEG::JPEG() :
_stream(NULL), _w(0), _h(0), _numComp(0), _components(NULL), _numScanComp(0),
_scanComp(NULL), _currentComp(NULL) {
@@ -60,15 +75,6 @@
_huff[i].sizes = NULL;
_huff[i].codes = NULL;
}
-
- // Initialize sqrt_2 and cosine lookups
- _sqrt_2 = sqrt(2.0f);
- debug(2, "JPEG: _sqrt_2: %f", _sqrt_2);
-
- for(byte i = 0; i < 32; i++) {
- _cosine_32[i] = cos(i * PI / 16);
- debug(2, "JPEG: _cosine_32[%d]: %f", i, _cosine_32[i]);
- }
}
JPEG::~JPEG() {
@@ -504,13 +510,13 @@
float JPEG::idct(int x, int y, int weight, int fx, int fy) {
byte vx_in = ((int32)((2 * x) + 1) * fx) % 32;
byte vy_in = ((int32)((2 * y) + 1) * fy) % 32;
- float ret = (float)weight * _cosine_32[vx_in] * _cosine_32[vy_in];
+ float ret = (float)weight * _cosine32[vx_in] * _cosine32[vy_in];
if (fx == 0)
- ret /= _sqrt_2;
+ ret /= M_SQRT2;
if (fy == 0)
- ret /= _sqrt_2;
+ ret /= M_SQRT2;
return ret;
}
Modified: scummvm/trunk/graphics/jpeg.h
===================================================================
--- scummvm/trunk/graphics/jpeg.h 2011-01-28 09:37:11 UTC (rev 55585)
+++ scummvm/trunk/graphics/jpeg.h 2011-01-28 09:46:39 UTC (rev 55586)
@@ -118,8 +118,6 @@
uint8 _bitsData;
uint8 _bitsNumber;
- float _sqrt_2;
- float _cosine_32[32];
// Discrete Cosine Transformation
float idct(int x, int y, int weight, int fx, int fy);
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list