gif_hash.h 1.4 KB

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