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