1 /*****************************************************************************\
2 compression.h : Interface for BertCompress and BertUncompress
4 Copyright (c) 1996 - 2001, Hewlett-Packard Co.
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15 3. Neither the name of Hewlett-Packard nor the names of its
16 contributors may be used to endorse or promote products derived
17 from this software without specific prior written permission.
19 THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
20 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
22 NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24 TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
25 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 \*****************************************************************************/
32 #ifndef APDK_COMPRESSION_H
33 #define APDK_COMPRESSION_H
40 #define kBertDecompressPixelSize 3
42 // Follows are all the masks for the command byte.
43 #define kTypeMask 0x80
44 #define kTypeShiftAmount 7
46 #define kCacheLiteralBitsMask 0x60
47 #define kCacheLiteralBitsShiftAmount 5
49 #define kCacheBitsMask 0x60
50 #define kCacheBitsShiftAmount 5
52 #define kRoffMask 0x18
53 #define kRoffShiftAmount 3
55 #define kReplace_countMask 0x07
57 // Now have the compiler check to make sure none of the masks overlap/underlap bits accidently.
58 #if ((kTypeMask | kCacheLiteralBitsMask | kRoffMask | kReplace_countMask) != 255)
59 #error "Your mask bits are messed up!"
62 #if ((kTypeMask | kCacheBitsMask | kRoffMask | kReplace_countMask) != 255)
63 #error "Your mask bits are messed up!"
85 eNorthEastColor = 0x2,
91 #define M10_MAX_OFFSET0 2 /* Largest unscaled value an offset can have before extra byte is needed. */
92 #define M10_MAX_COUNT0 6 /* Largest unscaled and unbiased value a count can have before extra byte is needed */
93 #define M10_COUNT_START0 1 /* What a count of zero has a value of. */
96 #define M10_MAX_OFFSET1 2
97 #define M10_MAX_COUNT1 6
98 #define M10_COUNT_START1 2
100 //int BertCompress(unsigned char *currentRow, int byteCount, unsigned char *dest, unsigned char *seed, int pixelSizeInBytes);
101 int BertCompress(unsigned char *currentRow, unsigned char *seed, unsigned char *dest, int byteCount, int pixelSizeInBytes);
102 unsigned int decodeDataToPixel(const unsigned char *compressedDataPtr, int *CBI, const unsigned char *seedRowPtr, const int curPixel, int pixelSizeInBytes);
103 void BertUncompress(const unsigned char *compressedDataPtr,
104 unsigned char *seedRowPtr,
105 int numberOfCompressedBytes,
106 int pixelSizeInBytes,
108 int *firstPixelThatChanged,
109 int *lastPixelThatChanged);
110 /*unsigned int BertUncompress(const unsigned char *inPtr,
113 unsigned char *ulSeedPtr,
114 unsigned char *ulOutPtr);
119 #endif //APDK_COMPRESSION_H