1 /****************************************************************************** 2 * Declarations, global to other of the GIF-HASH.C module. * 3 * * 4 * Written by Gershon Elber, Jun 1989 * 5 ******************************************************************************* 6 * History: * 7 * 14 Jun 89 - Version 1.0 by Gershon Elber. * 8 ******************************************************************************/ 9 10 #ifndef _GIF_HASH_H_ 11 #define _GIF_HASH_H_ 12 13 /* Find a thirty-two bit int type */ 14 #ifdef HAVE_SYS_TYPES_H 15 #include <sys/types.h> 16 #endif 17 #ifdef HAVE_BASETSD_H 18 #include <basetsd.h> 19 #endif 20 21 #ifdef _WIN32 22 # include "../win32/afterbase.h" 23 #else 24 # include "../afterbase.h" 25 #endif 26 #define UINT32 CARD32 27 28 29 #define HT_SIZE 8192 /* 12bits = 4096 or twice as big! */ 30 #define HT_KEY_MASK 0x1FFF /* 13bits keys */ 31 #define HT_KEY_NUM_BITS 13 /* 13bits keys */ 32 #define HT_MAX_KEY 8191 /* 13bits - 1, maximal code possible */ 33 #define HT_MAX_CODE 4095 /* Biggest code possible in 12 bits. */ 34 35 /* The 32 bits of the long are divided into two parts for the key & code: */ 36 /* 1. The code is 12 bits as our compression algorithm is limited to 12bits */ 37 /* 2. The key is 12 bits Prefix code + 8 bit new char or 20 bits. */ 38 /* The key is the upper 20 bits. The code is the lower 12. */ 39 #define HT_GET_KEY(l) (l >> 12) 40 #define HT_GET_CODE(l) (l & 0x0FFF) 41 #define HT_PUT_KEY(l) (l << 12) 42 #define HT_PUT_CODE(l) (l & 0x0FFF) 43 44 typedef struct GifHashTableType { 45 UINT32 HTable[HT_SIZE]; 46 } GifHashTableType; 47 48 GifHashTableType *_InitHashTable(void); 49 void _ClearHashTable(GifHashTableType *HashTable); 50 void _InsertHashTable(GifHashTableType *HashTable, UINT32 Key, int Code); 51 int _ExistsHashTable(GifHashTableType *HashTable, UINT32 Key); 52 53 #endif /* _GIF_HASH_H_ */ 54