aboutsummaryrefslogtreecommitdiff
path: root/image/codecs
diff options
context:
space:
mode:
Diffstat (limited to 'image/codecs')
-rw-r--r--image/codecs/cinepak.cpp242
-rw-r--r--image/codecs/cinepak.h18
-rw-r--r--image/codecs/cinepak_tables.h780
3 files changed, 1035 insertions, 5 deletions
diff --git a/image/codecs/cinepak.cpp b/image/codecs/cinepak.cpp
index 8464aa3889..9760b5b2a4 100644
--- a/image/codecs/cinepak.cpp
+++ b/image/codecs/cinepak.cpp
@@ -21,6 +21,7 @@
*/
#include "image/codecs/cinepak.h"
+#include "image/codecs/cinepak_tables.h"
#include "common/debug.h"
#include "common/stream.h"
@@ -47,10 +48,12 @@ namespace Image {
} else \
*((byte *)_curFrame.surface->getPixels() + offset) = lum
-CinepakDecoder::CinepakDecoder(int bitsPerPixel) : Codec() {
- _curFrame.surface = NULL;
- _curFrame.strips = NULL;
+CinepakDecoder::CinepakDecoder(int bitsPerPixel) : Codec(), _bitsPerPixel(bitsPerPixel) {
+ _curFrame.surface = 0;
+ _curFrame.strips = 0;
_y = 0;
+ _colorMap = 0;
+ _ditherPalette = 0;
if (bitsPerPixel == 8) {
_pixelFormat = Graphics::PixelFormat::createFormatCLUT8();
@@ -86,6 +89,9 @@ CinepakDecoder::~CinepakDecoder() {
delete[] _curFrame.strips;
delete[] _clipTableBuf;
+
+ delete[] _colorMap;
+ delete[] _ditherPalette;
}
const Graphics::Surface *CinepakDecoder::decodeFrame(Common::SeekableReadStream &stream) {
@@ -96,7 +102,7 @@ const Graphics::Surface *CinepakDecoder::decodeFrame(Common::SeekableReadStream
_curFrame.height = stream.readUint16BE();
_curFrame.stripCount = stream.readUint16BE();
- if (_curFrame.strips == NULL)
+ if (!_curFrame.strips)
_curFrame.strips = new CinepakStrip[_curFrame.stripCount];
debug(4, "Cinepak Frame: Width = %d, Height = %d, Strip Count = %d", _curFrame.width, _curFrame.height, _curFrame.stripCount);
@@ -166,7 +172,10 @@ const Graphics::Surface *CinepakDecoder::decodeFrame(Common::SeekableReadStream
case 0x30:
case 0x31:
case 0x32:
- decodeVectors(stream, i, chunkID, chunkSize);
+ if (_ditherPalette)
+ ditherVectors(stream, i, chunkID, chunkSize);
+ else
+ decodeVectors(stream, i, chunkID, chunkSize);
break;
default:
warning("Unknown Cinepak chunk ID %02x", chunkID);
@@ -311,4 +320,227 @@ void CinepakDecoder::decodeVectors(Common::SeekableReadStream &stream, uint16 st
}
}
+bool CinepakDecoder::canDither() const {
+ return _bitsPerPixel == 24;
+}
+
+void CinepakDecoder::setDither(const byte *palette) {
+ assert(canDither());
+
+ delete[] _colorMap;
+ delete[] _ditherPalette;
+
+ _ditherPalette = new byte[256 * 3];
+ memcpy(_ditherPalette, palette, 256 * 3);
+
+ _dirtyPalette = true;
+ _pixelFormat = Graphics::PixelFormat::createFormatCLUT8();
+ _colorMap = new byte[221];
+
+ for (int i = 0; i < 221; i++)
+ _colorMap[i] = findNearestRGB(i);
+}
+
+byte CinepakDecoder::findNearestRGB(int index) const {
+ int r = s_defaultPalette[index * 3];
+ int g = s_defaultPalette[index * 3 + 1];
+ int b = s_defaultPalette[index * 3 + 2];
+
+ byte result = 0;
+ int diff = 0x7FFFFFFF;
+
+ for (int i = 0; i < 256; i++) {
+ int bDiff = b - (int)_ditherPalette[i * 3 + 2];
+ int curDiffB = diff - (bDiff * bDiff);
+
+ if (curDiffB > 0) {
+ int gDiff = g - (int)_ditherPalette[i * 3 + 1];
+ int curDiffG = curDiffB - (gDiff * gDiff);
+
+ if (curDiffG > 0) {
+ int rDiff = r - (int)_ditherPalette[i * 3];
+ int curDiffR = curDiffG - (rDiff * rDiff);
+
+ if (curDiffR > 0) {
+ diff -= curDiffR;
+ result = i;
+
+ if (diff == 0)
+ break;
+ }
+ }
+ }
+ }
+
+ return result;
+}
+
+void CinepakDecoder::ditherVectors(Common::SeekableReadStream &stream, uint16 strip, byte chunkID, uint32 chunkSize) {
+ uint32 flag = 0, mask = 0;
+ byte *iy[4];
+ int32 startPos = stream.pos();
+
+ for (uint16 y = _curFrame.strips[strip].rect.top; y < _curFrame.strips[strip].rect.bottom; y += 4) {
+ iy[0] = (byte *)_curFrame.surface->getPixels() + _curFrame.strips[strip].rect.left + y * _curFrame.width;
+ iy[1] = iy[0] + _curFrame.width;
+ iy[2] = iy[1] + _curFrame.width;
+ iy[3] = iy[2] + _curFrame.width;
+
+ for (uint16 x = _curFrame.strips[strip].rect.left; x < _curFrame.strips[strip].rect.right; x += 4) {
+ if ((chunkID & 0x01) && !(mask >>= 1)) {
+ if ((stream.pos() - startPos + 4) > (int32)chunkSize)
+ return;
+
+ flag = stream.readUint32BE();
+ mask = 0x80000000;
+ }
+
+ if (!(chunkID & 0x01) || (flag & mask)) {
+ if (!(chunkID & 0x02) && !(mask >>= 1)) {
+ if ((stream.pos() - startPos + 4) > (int32)chunkSize)
+ return;
+
+ flag = stream.readUint32BE();
+ mask = 0x80000000;
+ }
+
+ byte blockBuffer[16];
+
+ if ((chunkID & 0x02) || (~flag & mask)) {
+ if ((stream.pos() - startPos + 1) > (int32)chunkSize)
+ return;
+
+ ditherCodebookSmooth(_curFrame.strips[strip].v1_codebook[stream.readByte()], blockBuffer);
+ iy[0][0] = blockBuffer[0];
+ iy[0][1] = blockBuffer[1];
+ iy[0][2] = blockBuffer[2];
+ iy[0][3] = blockBuffer[3];
+ iy[1][0] = blockBuffer[4];
+ iy[1][1] = blockBuffer[5];
+ iy[1][2] = blockBuffer[6];
+ iy[1][3] = blockBuffer[7];
+ iy[2][0] = blockBuffer[8];
+ iy[2][1] = blockBuffer[9];
+ iy[2][2] = blockBuffer[10];
+ iy[2][3] = blockBuffer[11];
+ iy[3][0] = blockBuffer[12];
+ iy[3][1] = blockBuffer[13];
+ iy[3][2] = blockBuffer[14];
+ iy[3][3] = blockBuffer[15];
+ } else if (flag & mask) {
+ if ((stream.pos() - startPos + 4) > (int32)chunkSize)
+ return;
+
+ ditherCodebookDetail(_curFrame.strips[strip].v4_codebook[stream.readByte()], blockBuffer);
+ iy[0][0] = blockBuffer[0];
+ iy[0][1] = blockBuffer[1];
+ iy[1][0] = blockBuffer[4];
+ iy[1][1] = blockBuffer[5];
+
+ ditherCodebookDetail(_curFrame.strips[strip].v4_codebook[stream.readByte()], blockBuffer);
+ iy[0][2] = blockBuffer[2];
+ iy[0][3] = blockBuffer[3];
+ iy[1][2] = blockBuffer[6];
+ iy[1][3] = blockBuffer[7];
+
+ ditherCodebookDetail(_curFrame.strips[strip].v4_codebook[stream.readByte()], blockBuffer);
+ iy[2][0] = blockBuffer[8];
+ iy[2][1] = blockBuffer[9];
+ iy[3][0] = blockBuffer[12];
+ iy[3][1] = blockBuffer[13];
+
+ ditherCodebookDetail(_curFrame.strips[strip].v4_codebook[stream.readByte()], blockBuffer);
+ iy[2][2] = blockBuffer[10];
+ iy[2][3] = blockBuffer[11];
+ iy[3][2] = blockBuffer[14];
+ iy[3][3] = blockBuffer[15];
+ }
+ }
+
+ for (byte i = 0; i < 4; i++)
+ iy[i] += 4;
+ }
+ }
+}
+
+void CinepakDecoder::ditherCodebookDetail(const CinepakCodebook &codebook, byte *dst) const {
+ int uLookup = (byte)codebook.u * 2;
+ int vLookup = (byte)codebook.v * 2;
+ uint32 uv1 = s_uLookup[uLookup] | s_vLookup[vLookup];
+ uint32 uv2 = s_uLookup[uLookup + 1] | s_vLookup[vLookup + 1];
+
+ int yLookup1 = codebook.y[0] * 2;
+ int yLookup2 = codebook.y[1] * 2;
+ int yLookup3 = codebook.y[2] * 2;
+ int yLookup4 = codebook.y[3] * 2;
+
+ uint32 pixelGroup1 = uv2 | s_yLookup[yLookup1 + 1];
+ uint32 pixelGroup2 = uv2 | s_yLookup[yLookup2 + 1];
+ uint32 pixelGroup3 = uv1 | s_yLookup[yLookup3];
+ uint32 pixelGroup4 = uv1 | s_yLookup[yLookup4];
+ uint32 pixelGroup5 = uv1 | s_yLookup[yLookup1];
+ uint32 pixelGroup6 = uv1 | s_yLookup[yLookup2];
+ uint32 pixelGroup7 = uv2 | s_yLookup[yLookup3 + 1];
+ uint32 pixelGroup8 = uv2 | s_yLookup[yLookup4 + 1];
+
+ dst[0] = getRGBLookupEntry(pixelGroup1 & 0xFFFF);
+ dst[1] = getRGBLookupEntry(pixelGroup2 >> 16);
+ dst[2] = getRGBLookupEntry(pixelGroup5 & 0xFFFF);
+ dst[3] = getRGBLookupEntry(pixelGroup6 >> 16);
+ dst[4] = getRGBLookupEntry(pixelGroup3 & 0xFFFF);
+ dst[5] = getRGBLookupEntry(pixelGroup4 >> 16);
+ dst[6] = getRGBLookupEntry(pixelGroup7 & 0xFFFF);
+ dst[7] = getRGBLookupEntry(pixelGroup8 >> 16);
+ dst[8] = getRGBLookupEntry(pixelGroup1 >> 16);
+ dst[9] = getRGBLookupEntry(pixelGroup6 & 0xFFFF);
+ dst[10] = getRGBLookupEntry(pixelGroup5 >> 16);
+ dst[11] = getRGBLookupEntry(pixelGroup2 & 0xFFFF);
+ dst[12] = getRGBLookupEntry(pixelGroup3 >> 16);
+ dst[13] = getRGBLookupEntry(pixelGroup8 & 0xFFFF);
+ dst[14] = getRGBLookupEntry(pixelGroup7 >> 16);
+ dst[15] = getRGBLookupEntry(pixelGroup4 & 0xFFFF);
+}
+
+void CinepakDecoder::ditherCodebookSmooth(const CinepakCodebook &codebook, byte *dst) const {
+ int uLookup = (byte)codebook.u * 2;
+ int vLookup = (byte)codebook.v * 2;
+ uint32 uv1 = s_uLookup[uLookup] | s_vLookup[vLookup];
+ uint32 uv2 = s_uLookup[uLookup + 1] | s_vLookup[vLookup + 1];
+
+ int yLookup1 = codebook.y[0] * 2;
+ int yLookup2 = codebook.y[1] * 2;
+ int yLookup3 = codebook.y[2] * 2;
+ int yLookup4 = codebook.y[3] * 2;
+
+ uint32 pixelGroup1 = uv2 | s_yLookup[yLookup1 + 1];
+ uint32 pixelGroup2 = uv1 | s_yLookup[yLookup2];
+ uint32 pixelGroup3 = uv1 | s_yLookup[yLookup1];
+ uint32 pixelGroup4 = uv2 | s_yLookup[yLookup2 + 1];
+ uint32 pixelGroup5 = uv2 | s_yLookup[yLookup3 + 1];
+ uint32 pixelGroup6 = uv1 | s_yLookup[yLookup3];
+ uint32 pixelGroup7 = uv1 | s_yLookup[yLookup4];
+ uint32 pixelGroup8 = uv2 | s_yLookup[yLookup4 + 1];
+
+ dst[0] = getRGBLookupEntry(pixelGroup1 & 0xFFFF);
+ dst[1] = getRGBLookupEntry(pixelGroup1 >> 16);
+ dst[2] = getRGBLookupEntry(pixelGroup2 & 0xFFFF);
+ dst[3] = getRGBLookupEntry(pixelGroup2 >> 16);
+ dst[4] = getRGBLookupEntry(pixelGroup3 & 0xFFFF);
+ dst[5] = getRGBLookupEntry(pixelGroup3 >> 16);
+ dst[6] = getRGBLookupEntry(pixelGroup4 & 0xFFFF);
+ dst[7] = getRGBLookupEntry(pixelGroup4 >> 16);
+ dst[8] = getRGBLookupEntry(pixelGroup5 >> 16);
+ dst[9] = getRGBLookupEntry(pixelGroup6 & 0xFFFF);
+ dst[10] = getRGBLookupEntry(pixelGroup7 >> 16);
+ dst[11] = getRGBLookupEntry(pixelGroup8 & 0xFFFF);
+ dst[12] = getRGBLookupEntry(pixelGroup6 >> 16);
+ dst[13] = getRGBLookupEntry(pixelGroup5 & 0xFFFF);
+ dst[14] = getRGBLookupEntry(pixelGroup8 >> 16);
+ dst[15] = getRGBLookupEntry(pixelGroup7 & 0xFFFF);
+}
+
+byte CinepakDecoder::getRGBLookupEntry(uint16 index) const {
+ return _colorMap[s_defaultPaletteLookup[CLIP<int>(index, 0, 1024)]];
+}
+
} // End of namespace Image
diff --git a/image/codecs/cinepak.h b/image/codecs/cinepak.h
index e9cd437730..ce8451bf9a 100644
--- a/image/codecs/cinepak.h
+++ b/image/codecs/cinepak.h
@@ -72,14 +72,32 @@ public:
const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream);
Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; }
+ bool containsPalette() const { return _ditherPalette != 0; }
+ const byte *getPalette() { _dirtyPalette = false; return _ditherPalette; }
+ bool hasDirtyPalette() const { return _dirtyPalette; }
+ bool canDither() const;
+ void setDither(const byte *palette);
+
private:
CinepakFrame _curFrame;
int32 _y;
+ int _bitsPerPixel;
Graphics::PixelFormat _pixelFormat;
byte *_clipTable, *_clipTableBuf;
+ byte *_ditherPalette;
+ bool _dirtyPalette;
+ byte *_rgbLookup;
+ byte *_colorMap;
+
void loadCodebook(Common::SeekableReadStream &stream, uint16 strip, byte codebookType, byte chunkID, uint32 chunkSize);
void decodeVectors(Common::SeekableReadStream &stream, uint16 strip, byte chunkID, uint32 chunkSize);
+
+ byte findNearestRGB(int index) const;
+ void ditherVectors(Common::SeekableReadStream &stream, uint16 strip, byte chunkID, uint32 chunkSize);
+ void ditherCodebookDetail(const CinepakCodebook &codebook, byte *dst) const;
+ void ditherCodebookSmooth(const CinepakCodebook &codebook, byte *dst) const;
+ byte getRGBLookupEntry(uint16 index) const;
};
} // End of namespace Image
diff --git a/image/codecs/cinepak_tables.h b/image/codecs/cinepak_tables.h
new file mode 100644
index 0000000000..03131cec22
--- /dev/null
+++ b/image/codecs/cinepak_tables.h
@@ -0,0 +1,780 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef IMAGE_CODECS_CINEPAK_TABLES_H
+#define IMAGE_CODECS_CINEPAK_TABLES_H
+
+#include "common/scummsys.h"
+
+namespace Image {
+
+static const byte s_defaultPaletteLookup[1024] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
+ 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
+ 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
+ 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
+ 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
+ 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02,
+ 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02,
+ 0x04, 0x04, 0x04, 0x05, 0x06, 0x07, 0x07, 0x07,
+ 0x04, 0x04, 0x04, 0x05, 0x06, 0x07, 0x07, 0x07,
+ 0x04, 0x04, 0x04, 0x05, 0x06, 0x07, 0x07, 0x07,
+ 0x04, 0x04, 0x04, 0x05, 0x06, 0x07, 0x07, 0x07,
+ 0x08, 0x08, 0x08, 0x09, 0x0A, 0x07, 0x07, 0x07,
+ 0x0B, 0x0B, 0x0B, 0x0C, 0x0D, 0x0D, 0x0D, 0x07,
+ 0x0E, 0x0E, 0x0E, 0x0F, 0x0D, 0x0D, 0x0D, 0x0D,
+ 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x0D, 0x0D,
+ 0x12, 0x12, 0x12, 0x13, 0x14, 0x15, 0x16, 0x16,
+ 0x12, 0x12, 0x12, 0x13, 0x14, 0x15, 0x16, 0x16,
+ 0x12, 0x12, 0x12, 0x13, 0x14, 0x15, 0x16, 0x16,
+ 0x12, 0x12, 0x12, 0x13, 0x14, 0x15, 0x16, 0x16,
+ 0x17, 0x17, 0x17, 0x18, 0x19, 0x1A, 0x16, 0x16,
+ 0x1B, 0x1B, 0x1B, 0x1C, 0x1D, 0x1E, 0x1E, 0x1E,
+ 0x1F, 0x1F, 0x1F, 0x20, 0x21, 0x1E, 0x1E, 0x1E,
+ 0x22, 0x22, 0x22, 0x23, 0x24, 0x24, 0x24, 0x1E,
+ 0x25, 0x25, 0x25, 0x26, 0x27, 0x28, 0x29, 0x29,
+ 0x25, 0x25, 0x25, 0x26, 0x27, 0x28, 0x29, 0x29,
+ 0x25, 0x25, 0x25, 0x26, 0x27, 0x28, 0x29, 0x29,
+ 0x25, 0x25, 0x25, 0x26, 0x27, 0x28, 0x29, 0x29,
+ 0x2A, 0x2A, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2E,
+ 0x2F, 0x2F, 0x2F, 0x30, 0x31, 0x32, 0x2E, 0x2E,
+ 0x33, 0x33, 0x33, 0x34, 0x35, 0x36, 0x36, 0x36,
+ 0x33, 0x33, 0x33, 0x34, 0x35, 0x36, 0x36, 0x36,
+ 0x37, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3B, 0x3B,
+ 0x37, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3B, 0x3B,
+ 0x37, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3B, 0x3B,
+ 0x3C, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x40, 0x40,
+ 0x41, 0x41, 0x42, 0x43, 0x44, 0x45, 0x45, 0x45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, 0xF0, 0xF6,
+ 0x9A, 0xD3, 0xF6,
+ 0xC8, 0xBC, 0xF6,
+ 0xF6, 0xA5, 0xF6,
+ 0xD5, 0xFB, 0x3D,
+ 0xD5, 0xED, 0x74,
+ 0xA7, 0xF7, 0xA7,
+ 0xD5, 0xE0, 0xA7,
+ 0xA7, 0xEC, 0xD5,
+ 0xD5, 0xD5, 0xD5,
+ 0xE1, 0xFA, 0x81,
+ 0xE1, 0xED, 0xB3,
+ 0xB3, 0xF8, 0xE1,
+ 0xE1, 0xE1, 0xE1,
+ 0xED, 0xF9, 0xBF,
+ 0xED, 0xED, 0xED,
+ 0xF8, 0xF8, 0xF8
+};
+
+static const uint32 s_yLookup[512] = {
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000040, 0x00000000, 0x00000040, 0x00000000,
+ 0x00000040, 0x00000000, 0x00000040, 0x00000000,
+ 0x00000040, 0x00000000, 0x00000040, 0x00000040,
+ 0x00000040, 0x00000040, 0x00000040, 0x00000040,
+ 0x00000040, 0x00000040, 0x00400040, 0x00000040,
+ 0x00400040, 0x00000040, 0x00400040, 0x00000040,
+ 0x00400040, 0x00000040, 0x00400040, 0x00000040,
+ 0x00400040, 0x00400040, 0x00400040, 0x00400040,
+ 0x00400040, 0x00400040, 0x00400040, 0x00400040,
+ 0x00400040, 0x00400040, 0x00400040, 0x00400040,
+ 0x00400040, 0x00400040, 0x00400040, 0x00400040,
+ 0x00400040, 0x00400040, 0x00400080, 0x00400040,
+ 0x00400080, 0x00400040, 0x00400080, 0x00400040,
+ 0x00400080, 0x00400040, 0x00400080, 0x00400080,
+ 0x00400080, 0x00400080, 0x00400080, 0x00400080,
+ 0x00400080, 0x00400080, 0x00400080, 0x00400080,
+ 0x00800080, 0x00400080, 0x00800080, 0x00400080,
+ 0x00800080, 0x00400080, 0x00800080, 0x00400080,
+ 0x00800080, 0x00800080, 0x00800080, 0x00800080,
+ 0x00800080, 0x00800080, 0x00800080, 0x00800080,
+ 0x00800080, 0x00800080, 0x00800080, 0x00800080,
+ 0x00800080, 0x00800080, 0x00800080, 0x00800080,
+ 0x00800080, 0x00800080, 0x008000C0, 0x00800080,
+ 0x008000C0, 0x00800080, 0x008000C0, 0x00800080,
+ 0x008000C0, 0x00800080, 0x008000C0, 0x008000C0,
+ 0x008000C0, 0x008000C0, 0x008000C0, 0x008000C0,
+ 0x008000C0, 0x008000C0, 0x00C000C0, 0x008000C0,
+ 0x00C000C0, 0x008000C0, 0x00C000C0, 0x008000C0,
+ 0x00C000C0, 0x008000C0, 0x00C000C0, 0x00C000C0,
+ 0x00C000C0, 0x00C000C0, 0x00C000C0, 0x00C000C0,
+ 0x00C000C0, 0x00C000C0, 0x00C000C0, 0x00C000C0,
+ 0x00C000C0, 0x00C000C0, 0x00C000C0, 0x00C000C0,
+ 0x00C000C0, 0x00C000C0, 0x00C00100, 0x00C000C0,
+ 0x00C00100, 0x00C000C0, 0x00C00100, 0x00C000C0,
+ 0x00C00100, 0x00C000C0, 0x00C00100, 0x00C00100,
+ 0x00C00100, 0x00C00100, 0x00C00100, 0x00C00100,
+ 0x00C00100, 0x00C00100, 0x01000100, 0x00C00100,
+ 0x01000100, 0x00C00100, 0x01000100, 0x00C00100,
+ 0x01000100, 0x00C00100, 0x01000100, 0x01000100,
+ 0x01000100, 0x01000100, 0x01000100, 0x01000100,
+ 0x01000100, 0x01000100, 0x01000100, 0x01000100,
+ 0x01000100, 0x01000100, 0x01000100, 0x01000100,
+ 0x01000100, 0x01000100, 0x01000140, 0x01000100,
+ 0x01000140, 0x01000100, 0x01000140, 0x01000100,
+ 0x01000140, 0x01000140, 0x01000140, 0x01000140,
+ 0x01000140, 0x01000140, 0x01000140, 0x01000140,
+ 0x01400140, 0x01000140, 0x01400140, 0x01000140,
+ 0x01400140, 0x01000140, 0x01400140, 0x01000140,
+ 0x01400140, 0x01400140, 0x01400140, 0x01400140,
+ 0x01400140, 0x01400140, 0x01400140, 0x01400140,
+ 0x01400140, 0x01400140, 0x01400140, 0x01400140,
+ 0x01400140, 0x01400140, 0x01400180, 0x01400140,
+ 0x01400180, 0x01400140, 0x01400180, 0x01400140,
+ 0x01400180, 0x01400140, 0x01400180, 0x01400180,
+ 0x01400180, 0x01400180, 0x01400180, 0x01400180,
+ 0x01800180, 0x01400180, 0x01800180, 0x01400180,
+ 0x01800180, 0x01400180, 0x01800180, 0x01400180,
+ 0x01800180, 0x01800180, 0x01800180, 0x01800180,
+ 0x01800180, 0x01800180, 0x01800180, 0x01800180,
+ 0x01800180, 0x01800180, 0x01800180, 0x01800180,
+ 0x01800180, 0x01800180, 0x018001C0, 0x01800180,
+ 0x018001C0, 0x01800180, 0x018001C0, 0x01800180,
+ 0x018001C0, 0x018001C0, 0x018001C0, 0x018001C0,
+ 0x018001C0, 0x018001C0, 0x018001C0, 0x018001C0,
+ 0x01C001C0, 0x018001C0, 0x01C001C0, 0x018001C0,
+ 0x01C001C0, 0x018001C0, 0x01C001C0, 0x01C001C0,
+ 0x01C001C0, 0x01C001C0, 0x01C001C0, 0x01C001C0,
+ 0x01C001C0, 0x01C001C0, 0x01C001C0, 0x01C001C0,
+ 0x01C001C0, 0x01C001C0, 0x01C00200, 0x01C001C0,
+ 0x01C00200, 0x01C001C0, 0x01C00200, 0x01C001C0,
+ 0x01C00200, 0x01C001C0, 0x01C00200, 0x01C00200,
+ 0x01C00200, 0x01C00200, 0x01C00200, 0x01C00200,
+ 0x02000200, 0x01C00200, 0x02000200, 0x01C00200,
+ 0x02000200, 0x01C00200, 0x02000200, 0x02000200,
+ 0x02000200, 0x02000200, 0x02000200, 0x02000200,
+ 0x02000200, 0x02000200, 0x02000200, 0x02000200,
+ 0x02000200, 0x02000200, 0x02000240, 0x02000200,
+ 0x02000240, 0x02000200, 0x02000240, 0x02000200,
+ 0x02000240, 0x02000240, 0x02000240, 0x02000240,
+ 0x02000240, 0x02000240, 0x02400240, 0x02000240,
+ 0x02400240, 0x02000240, 0x02400240, 0x02000240,
+ 0x02400240, 0x02000240, 0x02400240, 0x02400240,
+ 0x02400240, 0x02400240, 0x02400240, 0x02400240,
+ 0x02400240, 0x02400240, 0x02400240, 0x02400240,
+ 0x02400280, 0x02400240, 0x02400280, 0x02400240,
+ 0x02400280, 0x02400240, 0x02400280, 0x02400280,
+ 0x02400280, 0x02400280, 0x02400280, 0x02400280,
+ 0x02800280, 0x02400280, 0x02800280, 0x02400280,
+ 0x02800280, 0x02400280, 0x02800280, 0x02800280,
+ 0x02800280, 0x02800280, 0x02800280, 0x02800280,
+ 0x02800280, 0x02800280, 0x02800280, 0x02800280,
+ 0x02800280, 0x02800280, 0x028002C0, 0x02800280,
+ 0x028002C0, 0x02800280, 0x028002C0, 0x02800280,
+ 0x028002C0, 0x028002C0, 0x028002C0, 0x028002C0,
+ 0x02C002C0, 0x028002C0, 0x02C002C0, 0x028002C0,
+ 0x02C002C0, 0x028002C0, 0x02C002C0, 0x02C002C0,
+ 0x02C002C0, 0x02C002C0, 0x02C002C0, 0x02C002C0,
+ 0x02C002C0, 0x02C002C0, 0x02C002C0, 0x02C002C0,
+ 0x02C00300, 0x02C002C0, 0x02C00300, 0x02C002C0,
+ 0x02C00300, 0x02C002C0, 0x02C00300, 0x02C00300,
+ 0x02C00300, 0x02C00300, 0x02C00300, 0x02C00300,
+ 0x03000300, 0x02C00300, 0x03000300, 0x02C00300,
+ 0x03000300, 0x03000300, 0x03000300, 0x03000300,
+ 0x03000300, 0x03000300, 0x03000300, 0x03000300,
+ 0x03000300, 0x03000300, 0x03000340, 0x03000300,
+ 0x03000340, 0x03000300, 0x03000340, 0x03000300,
+ 0x03000340, 0x03000340, 0x03000340, 0x03000340,
+ 0x03400340, 0x03000340, 0x03400340, 0x03000340,
+ 0x03400340, 0x03000340, 0x03400340, 0x03400340,
+ 0x03400340, 0x03400340, 0x03400340, 0x03400340,
+ 0x03400340, 0x03400340, 0x03400340, 0x03400340,
+ 0x03400380, 0x03400340, 0x03400380, 0x03400340,
+ 0x03400380, 0x03400380, 0x03400380, 0x03400380,
+ 0x03800380, 0x03400380, 0x03800380, 0x03400380,
+ 0x03800380, 0x03400380, 0x03800380, 0x03800380,
+ 0x03800380, 0x03800380, 0x03800380, 0x03800380,
+ 0x03800380, 0x03800380, 0x038003C0, 0x03800380,
+ 0x038003C0, 0x03800380, 0x038003C0, 0x03800380,
+ 0x038003C0, 0x038003C0, 0x038003C0, 0x038003C0,
+ 0x03C003C0, 0x038003C0, 0x03C003C0, 0x038003C0,
+ 0x03C003C0, 0x03C003C0, 0x03C003C0, 0x03C003C0,
+ 0x03C003C0, 0x03C003C0, 0x03C003C0, 0x03C003C0,
+ 0x03C003C0, 0x03C003C0, 0x03C003C0, 0x03C003C0,
+ 0x03C003C0, 0x03C003C0, 0x03C003C0, 0x03C003C0,
+ 0x03C003C0, 0x03C003C0, 0x03C003C0, 0x03C003C0
+};
+
+static const uint32 s_uLookup[512] = {
+ 0x00200020, 0x00200020, 0x00200020, 0x00200020,
+ 0x00200020, 0x00200020, 0x00200020, 0x00200020,
+ 0x00200020, 0x00200020, 0x00280020, 0x00200020,
+ 0x00280020, 0x00200020, 0x00280020, 0x00200020,
+ 0x00280020, 0x00200020, 0x00280020, 0x00280020,
+ 0x00280020, 0x00280020, 0x00280020, 0x00280020,
+ 0x00280020, 0x00280020, 0x00280020, 0x00280020,
+ 0x00280020, 0x00280028, 0x00280020, 0x00280028,
+ 0x00280020, 0x00280028, 0x00280020, 0x00280028,
+ 0x00280028, 0x00280028, 0x00280028, 0x00280028,
+ 0x00280028, 0x00280028, 0x00280028, 0x00280028,
+ 0x00280028, 0x00280028, 0x00280028, 0x00280028,
+ 0x00280028, 0x00280028, 0x00280028, 0x00280028,
+ 0x00280028, 0x00280028, 0x00280028, 0x00280028,
+ 0x00280028, 0x00280028, 0x00300028, 0x00280028,
+ 0x00300028, 0x00280028, 0x00300028, 0x00280028,
+ 0x00300028, 0x00280028, 0x00300028, 0x00280028,
+ 0x00300028, 0x00300028, 0x00300028, 0x00300028,
+ 0x00300028, 0x00300028, 0x00300028, 0x00300028,
+ 0x00300028, 0x00300028, 0x00300028, 0x00300028,
+ 0x00300028, 0x00300030, 0x00300028, 0x00300030,
+ 0x00300028, 0x00300030, 0x00300028, 0x00300030,
+ 0x00300028, 0x00300030, 0x00300028, 0x00300030,
+ 0x00300030, 0x00300030, 0x00300030, 0x00300030,
+ 0x00300030, 0x00300030, 0x00300030, 0x00300030,
+ 0x00300030, 0x00300030, 0x00300030, 0x00300030,
+ 0x00300030, 0x00300030, 0x00300030, 0x00300030,
+ 0x00300030, 0x00300030, 0x00300030, 0x00300030,
+ 0x00300030, 0x00300030, 0x00300030, 0x00300030,
+ 0x00300030, 0x00300030, 0x00380030, 0x00300030,
+ 0x00380030, 0x00300030, 0x00380030, 0x00300030,
+ 0x00380030, 0x00300030, 0x00380030, 0x00300030,
+ 0x00380030, 0x00300030, 0x00380030, 0x00300030,
+ 0x00380030, 0x00380030, 0x00380030, 0x00380030,
+ 0x00380030, 0x00380030, 0x00380030, 0x00380030,
+ 0x00380030, 0x00380030, 0x00380030, 0x00380030,
+ 0x00380030, 0x00380030, 0x00380030, 0x00380038,
+ 0x00380030, 0x00380038, 0x00380030, 0x00380038,
+ 0x00380030, 0x00380038, 0x00380030, 0x00380038,
+ 0x00380030, 0x00380038, 0x00380030, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00380038, 0x00380038, 0x00380038, 0x00380038,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00080000, 0x00000000,
+ 0x00080000, 0x00000000, 0x00080000, 0x00000000,
+ 0x00080000, 0x00000000, 0x00080000, 0x00000000,
+ 0x00080000, 0x00000000, 0x00080000, 0x00000000,
+ 0x00080000, 0x00080000, 0x00080000, 0x00080000,
+ 0x00080000, 0x00080000, 0x00080000, 0x00080000,
+ 0x00080000, 0x00080000, 0x00080000, 0x00080000,
+ 0x00080000, 0x00080008, 0x00080000, 0x00080008,
+ 0x00080000, 0x00080008, 0x00080000, 0x00080008,
+ 0x00080000, 0x00080008, 0x00080000, 0x00080008,
+ 0x00080008, 0x00080008, 0x00080008, 0x00080008,
+ 0x00080008, 0x00080008, 0x00080008, 0x00080008,
+ 0x00080008, 0x00080008, 0x00080008, 0x00080008,
+ 0x00080008, 0x00080008, 0x00080008, 0x00080008,
+ 0x00080008, 0x00080008, 0x00080008, 0x00080008,
+ 0x00080008, 0x00080008, 0x00100008, 0x00080008,
+ 0x00100008, 0x00080008, 0x00100008, 0x00080008,
+ 0x00100008, 0x00080008, 0x00100008, 0x00080008,
+ 0x00100008, 0x00080008, 0x00100008, 0x00100008,
+ 0x00100008, 0x00100008, 0x00100008, 0x00100008,
+ 0x00100008, 0x00100008, 0x00100008, 0x00100008,
+ 0x00100008, 0x00100008, 0x00100008, 0x00100010,
+ 0x00100008, 0x00100010, 0x00100008, 0x00100010,
+ 0x00100008, 0x00100010, 0x00100008, 0x00100010,
+ 0x00100010, 0x00100010, 0x00100010, 0x00100010,
+ 0x00100010, 0x00100010, 0x00100010, 0x00100010,
+ 0x00100010, 0x00100010, 0x00100010, 0x00100010,
+ 0x00100010, 0x00100010, 0x00100010, 0x00100010,
+ 0x00100010, 0x00100010, 0x00100010, 0x00100010,
+ 0x00100010, 0x00100010, 0x00180010, 0x00100010,
+ 0x00180010, 0x00100010, 0x00180010, 0x00100010,
+ 0x00180010, 0x00100010, 0x00180010, 0x00100010,
+ 0x00180010, 0x00180010, 0x00180010, 0x00180010,
+ 0x00180010, 0x00180010, 0x00180010, 0x00180010,
+ 0x00180010, 0x00180010, 0x00180010, 0x00180018,
+ 0x00180010, 0x00180018, 0x00180010, 0x00180018,
+ 0x00180010, 0x00180018, 0x00180010, 0x00180018,
+ 0x00180018, 0x00180018, 0x00180018, 0x00180018,
+ 0x00180018, 0x00180018, 0x00180018, 0x00180018,
+ 0x00180018, 0x00180018, 0x00180018, 0x00180018,
+ 0x00180018, 0x00180018, 0x00180018, 0x00180018,
+ 0x00180018, 0x00180018, 0x00180018, 0x00180018,
+ 0x00200018, 0x00180018, 0x00200018, 0x00180018,
+ 0x00200018, 0x00180018, 0x00200018, 0x00180018,
+ 0x00200018, 0x00200018, 0x00200018, 0x00200018,
+ 0x00200018, 0x00200018, 0x00200018, 0x00200018,
+ 0x00200018, 0x00200018, 0x00200018, 0x00200020,
+ 0x00200018, 0x00200020, 0x00200018, 0x00200020,
+ 0x00200018, 0x00200020, 0x00200020, 0x00200020,
+ 0x00200020, 0x00200020, 0x00200020, 0x00200020,
+ 0x00200020, 0x00200020, 0x00200020, 0x00200020
+};
+
+static const uint32 s_vLookup[512] = {
+ 0x00030003, 0x00030003, 0x00030003, 0x00030003,
+ 0x00030003, 0x00030003, 0x00030003, 0x00030003,
+ 0x00030003, 0x00030003, 0x00030003, 0x00030004,
+ 0x00030003, 0x00030004, 0x00030003, 0x00030004,
+ 0x00030003, 0x00030004, 0x00030004, 0x00030004,
+ 0x00030004, 0x00030004, 0x00030004, 0x00030004,
+ 0x00030004, 0x00030004, 0x00030004, 0x00030004,
+ 0x00030004, 0x00040004, 0x00030004, 0x00040004,
+ 0x00030004, 0x00040004, 0x00030004, 0x00040004,
+ 0x00040004, 0x00040004, 0x00040004, 0x00040004,
+ 0x00040004, 0x00040004, 0x00040004, 0x00040004,
+ 0x00040004, 0x00040004, 0x00040004, 0x00040004,
+ 0x00040004, 0x00040004, 0x00040004, 0x00040004,
+ 0x00040004, 0x00040004, 0x00040004, 0x00040004,
+ 0x00040004, 0x00040005, 0x00040004, 0x00040005,
+ 0x00040004, 0x00040005, 0x00040004, 0x00040005,
+ 0x00040004, 0x00040005, 0x00040005, 0x00040005,
+ 0x00040005, 0x00040005, 0x00040005, 0x00040005,
+ 0x00040005, 0x00040005, 0x00040005, 0x00040005,
+ 0x00040005, 0x00050005, 0x00040005, 0x00050005,
+ 0x00040005, 0x00050005, 0x00040005, 0x00050005,
+ 0x00040005, 0x00050005, 0x00050005, 0x00050005,
+ 0x00050005, 0x00050005, 0x00050005, 0x00050005,
+ 0x00050005, 0x00050005, 0x00050005, 0x00050005,
+ 0x00050005, 0x00050005, 0x00050005, 0x00050005,
+ 0x00050005, 0x00050005, 0x00050005, 0x00050005,
+ 0x00050005, 0x00050005, 0x00050005, 0x00050005,
+ 0x00050005, 0x00050006, 0x00050005, 0x00050006,
+ 0x00050005, 0x00050006, 0x00050005, 0x00050006,
+ 0x00050005, 0x00050006, 0x00050006, 0x00050006,
+ 0x00050006, 0x00050006, 0x00050006, 0x00050006,
+ 0x00050006, 0x00050006, 0x00050006, 0x00050006,
+ 0x00050006, 0x00050006, 0x00050006, 0x00060006,
+ 0x00050006, 0x00060006, 0x00050006, 0x00060006,
+ 0x00050006, 0x00060006, 0x00050006, 0x00060006,
+ 0x00050006, 0x00060006, 0x00060006, 0x00060006,
+ 0x00060006, 0x00060006, 0x00060006, 0x00060006,
+ 0x00060006, 0x00060006, 0x00060006, 0x00060006,
+ 0x00060006, 0x00060006, 0x00060006, 0x00060006,
+ 0x00060006, 0x00060006, 0x00060006, 0x00060006,
+ 0x00060006, 0x00060006, 0x00060006, 0x00060006,
+ 0x00060006, 0x00060007, 0x00060006, 0x00060007,
+ 0x00060006, 0x00060007, 0x00060006, 0x00060007,
+ 0x00060006, 0x00060007, 0x00060006, 0x00060007,
+ 0x00060007, 0x00060007, 0x00060007, 0x00060007,
+ 0x00060007, 0x00060007, 0x00060007, 0x00060007,
+ 0x00060007, 0x00060007, 0x00060007, 0x00060007,
+ 0x00060007, 0x00070007, 0x00060007, 0x00070007,
+ 0x00060007, 0x00070007, 0x00060007, 0x00070007,
+ 0x00060007, 0x00070007, 0x00060007, 0x00070007,
+ 0x00060007, 0x00070007, 0x00070007, 0x00070007,
+ 0x00070007, 0x00070007, 0x00070007, 0x00070007,
+ 0x00070007, 0x00070007, 0x00070007, 0x00070007,
+ 0x00070007, 0x00070007, 0x00070007, 0x00070007,
+ 0x00070007, 0x00070007, 0x00070007, 0x00070007,
+ 0x00070007, 0x00070007, 0x00070007, 0x00070007,
+ 0x00070007, 0x00070007, 0x00070007, 0x00070007,
+ 0x00070007, 0x00070007, 0x00070007, 0x00070007,
+ 0x00070007, 0x00070007, 0x00070007, 0x00070007,
+ 0x00070007, 0x00070007, 0x00070007, 0x00070007,
+ 0x00070007, 0x00070007, 0x00070007, 0x00070007,
+ 0x00070007, 0x00070007, 0x00070007, 0x00070007,
+ 0x00070007, 0x00070007, 0x00070007, 0x00070007,
+ 0x00070007, 0x00070007, 0x00070007, 0x00070007,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000001, 0x00000000, 0x00000001,
+ 0x00000000, 0x00000001, 0x00000000, 0x00000001,
+ 0x00000000, 0x00000001, 0x00000000, 0x00000001,
+ 0x00000000, 0x00000001, 0x00000001, 0x00000001,
+ 0x00000001, 0x00000001, 0x00000001, 0x00000001,
+ 0x00000001, 0x00000001, 0x00000001, 0x00000001,
+ 0x00000001, 0x00000001, 0x00000001, 0x00000001,
+ 0x00000001, 0x00010001, 0x00000001, 0x00010001,
+ 0x00000001, 0x00010001, 0x00000001, 0x00010001,
+ 0x00000001, 0x00010001, 0x00000001, 0x00010001,
+ 0x00000001, 0x00010001, 0x00010001, 0x00010001,
+ 0x00010001, 0x00010001, 0x00010001, 0x00010001,
+ 0x00010001, 0x00010001, 0x00010001, 0x00010001,
+ 0x00010001, 0x00010001, 0x00010001, 0x00010001,
+ 0x00010001, 0x00010001, 0x00010001, 0x00010001,
+ 0x00010001, 0x00010001, 0x00010001, 0x00010001,
+ 0x00010001, 0x00010001, 0x00010001, 0x00010001,
+ 0x00010001, 0x00010002, 0x00010001, 0x00010002,
+ 0x00010001, 0x00010002, 0x00010001, 0x00010002,
+ 0x00010001, 0x00010002, 0x00010001, 0x00010002,
+ 0x00010002, 0x00010002, 0x00010002, 0x00010002,
+ 0x00010002, 0x00010002, 0x00010002, 0x00010002,
+ 0x00010002, 0x00010002, 0x00010002, 0x00010002,
+ 0x00010002, 0x00020002, 0x00010002, 0x00020002,
+ 0x00010002, 0x00020002, 0x00010002, 0x00020002,
+ 0x00010002, 0x00020002, 0x00020002, 0x00020002,
+ 0x00020002, 0x00020002, 0x00020002, 0x00020002,
+ 0x00020002, 0x00020002, 0x00020002, 0x00020002,
+ 0x00020002, 0x00020002, 0x00020002, 0x00020002,
+ 0x00020002, 0x00020002, 0x00020002, 0x00020002,
+ 0x00020002, 0x00020002, 0x00020002, 0x00020002,
+ 0x00020002, 0x00020003, 0x00020002, 0x00020003,
+ 0x00020002, 0x00020003, 0x00020002, 0x00020003,
+ 0x00020003, 0x00020003, 0x00020003, 0x00020003,
+ 0x00020003, 0x00020003, 0x00020003, 0x00020003,
+ 0x00020003, 0x00020003, 0x00020003, 0x00030003,
+ 0x00020003, 0x00030003, 0x00020003, 0x00030003,
+ 0x00020003, 0x00030003, 0x00030003, 0x00030003,
+ 0x00030003, 0x00030003, 0x00030003, 0x00030003,
+ 0x00030003, 0x00030003, 0x00030003, 0x00030003
+};
+
+} // End of namespace Image
+
+#endif