Main Page | Modules | Namespace List | Data Structures | File List | Data Fields | Globals

Tables.h

Go to the documentation of this file.
00001 /*
00002  
00003 Copyright (c) 2004, Cornell University
00004 All rights reserved.
00005  
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions are met:
00008  
00009    - Redistributions of source code must retain the above copyright notice,
00010        this list of conditions and the following disclaimer.
00011    - Redistributions in binary form must reproduce the above copyright
00012        notice, this list of conditions and the following disclaimer in the
00013        documentation and/or other materials provided with the distribution.
00014    - Neither the name of Cornell University nor the names of its
00015        contributors may be used to endorse or promote products derived from
00016        this software without specific prior written permission.
00017  
00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00022 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
00028 THE POSSIBILITY OF SUCH DAMAGE.
00029  
00030 */
00031 
00032 
00033 /////////////////////////////////////////////////////////////////////
00034 /// Tables.h
00035 ///
00036 /// For gathering the lookup tables in one place.
00037 /////////////////////////////////////////////////////////////////////
00038 
00039 #ifndef TABLES_H
00040 #define TABLES_H
00041 
00042 /////////////////////////////////////////////////////////////////////
00043 /// @addtogroup BitmapProcessingGroup
00044 /** @{ */
00045 
00046 const int SIZE_BYTE = 8;
00047 const int SIZE_INT = sizeof(int);
00048 const int SIZE_UINT = sizeof(unsigned int);
00049 const int SIZE_USHORT = sizeof(unsigned short);
00050 
00051 const int SHORT_PER_INT = SIZE_UINT / SIZE_USHORT;
00052 const int BITS_PER_INT = SIZE_UINT * SIZE_BYTE;
00053 const int BITS_PER_SHORT = SIZE_USHORT * SIZE_BYTE;
00054 
00055 
00056 /// Bit32Table[i] contains a 1 at only position i
00057 const unsigned int Bit32Table[32] =
00058     {
00059         2147483648UL, 1073741824UL, 536870912UL, 268435456UL,
00060         134217728, 67108864, 33554432, 16777216,
00061         8388608, 4194304, 2097152, 1048576,
00062         524288, 262144, 131072, 65536,
00063         32768, 16384, 8192, 4096,
00064         2048, 1024, 512, 256,
00065         128, 64, 32, 16,
00066         8, 4, 2, 1
00067     };
00068 
00069 /// Bit16Table[i] contains a 1 at only position i
00070 const int Bit16Table[16] =
00071     {
00072         32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1
00073     };
00074 
00075 
00076 /// CountTable[i] contains the number of 1's in the byte value of i
00077 const char CountTable[256] =
00078     {
00079         0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1,
00080         2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 1,
00081         2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 2,
00082         3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
00083     };
00084 
00085 /** @} */
00086 
00087 #endif

Generated on Thu Mar 11 12:01:52 2004 for SPAM by doxygen 1.3.4