[Scummvm-cvs-logs] SF.net SVN: scummvm: [21971] scummvm/trunk/graphics/scaler.cpp
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Mon Apr 17 04:17:02 CEST 2006
Revision: 21971
Author: fingolfin
Date: 2006-04-17 04:16:11 -0700 (Mon, 17 Apr 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=21971&view=rev
Log Message:
-----------
Allocate LUT/YUV tables on the heap
Modified Paths:
--------------
scummvm/trunk/graphics/scaler.cpp
Modified: scummvm/trunk/graphics/scaler.cpp
===================================================================
--- scummvm/trunk/graphics/scaler.cpp 2006-04-17 11:11:07 UTC (rev 21970)
+++ scummvm/trunk/graphics/scaler.cpp 2006-04-17 11:16:11 UTC (rev 21971)
@@ -43,9 +43,8 @@
#endif
-// FIXME/TODO: The following two tables suck up 512 KB.
-// They should at least be allocated on the heap, to reduce the size of the
-// binary.
+// FIXME/TODO: The following two tables suck up 512 KB. This is bad.
+// In addition we never free them...
//
// Note: a memory lookup table is *not* necessarily faster than computing
// these things on the fly, because of its size. Both tables together, plus
@@ -69,9 +68,8 @@
// Of course, the above is largely a conjecture, and the actual speed
// differences are likely to vary a lot between different architectures and
// CPUs.
-uint RGBtoYUVstorage[65536];
-uint *RGBtoYUV = RGBtoYUVstorage;
-uint LUT16to32[65536];
+uint32 *RGBtoYUV = 0;
+uint32 *LUT16to32 = 0;
}
template<class T>
@@ -81,6 +79,12 @@
assert(T::kBytesPerPixel == 2);
+ // Allocate the YUV/LUT buffers on the fly if needed.
+ if (RGBtoYUV == 0)
+ RGBtoYUV = (uint32 *)malloc(65536 * sizeof(uint32));
+ if (LUT16to32 == 0)
+ LUT16to32 = (uint32 *)malloc(65536 * sizeof(uint32));
+
for (int color = 0; color < 65536; ++color) {
r = ((color & T::kRedMask) >> T::kRedShift) << (8 - T::kRedBits);
g = ((color & T::kGreenMask) >> T::kGreenShift) << (8 - T::kGreenBits);
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