The Android Open Source Project | c2eacae | 2009-03-03 19:29:32 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
Chris Craik | 9aef3ea | 2013-06-24 19:34:25 -0700 | [diff] [blame] | 2 | |
| 3 | gif_hash.h - magfic constants and declarations for GIF LZW |
| 4 | |
The Android Open Source Project | c2eacae | 2009-03-03 19:29:32 -0800 | [diff] [blame] | 5 | ******************************************************************************/ |
| 6 | |
| 7 | #ifndef _GIF_HASH_H_ |
| 8 | #define _GIF_HASH_H_ |
| 9 | |
The Android Open Source Project | c2eacae | 2009-03-03 19:29:32 -0800 | [diff] [blame] | 10 | #include <unistd.h> |
Chris Craik | 9aef3ea | 2013-06-24 19:34:25 -0700 | [diff] [blame] | 11 | #include <stdint.h> |
The Android Open Source Project | c2eacae | 2009-03-03 19:29:32 -0800 | [diff] [blame] | 12 | |
| 13 | #define HT_SIZE 8192 /* 12bits = 4096 or twice as big! */ |
| 14 | #define HT_KEY_MASK 0x1FFF /* 13bits keys */ |
| 15 | #define HT_KEY_NUM_BITS 13 /* 13bits keys */ |
| 16 | #define HT_MAX_KEY 8191 /* 13bits - 1, maximal code possible */ |
| 17 | #define HT_MAX_CODE 4095 /* Biggest code possible in 12 bits. */ |
| 18 | |
| 19 | /* The 32 bits of the long are divided into two parts for the key & code: */ |
| 20 | /* 1. The code is 12 bits as our compression algorithm is limited to 12bits */ |
| 21 | /* 2. The key is 12 bits Prefix code + 8 bit new char or 20 bits. */ |
| 22 | /* The key is the upper 20 bits. The code is the lower 12. */ |
| 23 | #define HT_GET_KEY(l) (l >> 12) |
| 24 | #define HT_GET_CODE(l) (l & 0x0FFF) |
| 25 | #define HT_PUT_KEY(l) (l << 12) |
| 26 | #define HT_PUT_CODE(l) (l & 0x0FFF) |
| 27 | |
| 28 | typedef struct GifHashTableType { |
Chris Craik | 9aef3ea | 2013-06-24 19:34:25 -0700 | [diff] [blame] | 29 | uint32_t HTable[HT_SIZE]; |
The Android Open Source Project | c2eacae | 2009-03-03 19:29:32 -0800 | [diff] [blame] | 30 | } GifHashTableType; |
| 31 | |
| 32 | GifHashTableType *_InitHashTable(void); |
| 33 | void _ClearHashTable(GifHashTableType *HashTable); |
Chris Craik | 9aef3ea | 2013-06-24 19:34:25 -0700 | [diff] [blame] | 34 | void _InsertHashTable(GifHashTableType *HashTable, uint32_t Key, int Code); |
| 35 | int _ExistsHashTable(GifHashTableType *HashTable, uint32_t Key); |
The Android Open Source Project | c2eacae | 2009-03-03 19:29:32 -0800 | [diff] [blame] | 36 | |
| 37 | #endif /* _GIF_HASH_H_ */ |
Chris Craik | 9aef3ea | 2013-06-24 19:34:25 -0700 | [diff] [blame] | 38 | |
| 39 | /* end */ |