diff options
author | Max Horn | 2006-04-17 11:16:11 +0000 |
---|---|---|
committer | Max Horn | 2006-04-17 11:16:11 +0000 |
commit | 340705c138f2d7f3218ae6e4bac1423d21196024 (patch) | |
tree | 0f9bdf6be13d5f3b6c103392dc980294120804d6 /graphics/scaler.cpp | |
parent | 35a2fc402811b1dd047d62e571164f3d50d86393 (diff) | |
download | scummvm-rg350-340705c138f2d7f3218ae6e4bac1423d21196024.tar.gz scummvm-rg350-340705c138f2d7f3218ae6e4bac1423d21196024.tar.bz2 scummvm-rg350-340705c138f2d7f3218ae6e4bac1423d21196024.zip |
Allocate LUT/YUV tables on the heap
svn-id: r21971
Diffstat (limited to 'graphics/scaler.cpp')
-rw-r--r-- | graphics/scaler.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/graphics/scaler.cpp b/graphics/scaler.cpp index 1853742ce2..1f32d4cea6 100644 --- a/graphics/scaler.cpp +++ b/graphics/scaler.cpp @@ -43,9 +43,8 @@ extern "C" { #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 @@ extern "C" { // 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 @@ void InitLUT() { 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); |