1 /* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. Oracle designates this 7 * particular file as subject to the "Classpath" exception as provided 8 * by Oracle in the LICENSE file that accompanied this code. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 */ 24 25 /****************************************************************************** 26 27 gif_hash.h - magfic constants and declarations for GIF LZW 28 29 SPDX-License-Identifier: MIT 30 31 ******************************************************************************/ 32 33 #ifndef _GIF_HASH_H_ 34 #define _GIF_HASH_H_ 35 36 /** Begin JDK modifications to support building on Windows **/ 37 #ifndef _WIN32 38 #include <unistd.h> 39 #endif 40 /** End JDK modifications to support building on Windows **/ 41 #include <stdint.h> 42 43 #define HT_SIZE 8192 /* 12bits = 4096 or twice as big! */ 44 #define HT_KEY_MASK 0x1FFF /* 13bits keys */ 45 #define HT_KEY_NUM_BITS 13 /* 13bits keys */ 46 #define HT_MAX_KEY 8191 /* 13bits - 1, maximal code possible */ 47 #define HT_MAX_CODE 4095 /* Biggest code possible in 12 bits. */ 48 49 /* The 32 bits of the long are divided into two parts for the key & code: */ 50 /* 1. The code is 12 bits as our compression algorithm is limited to 12bits */ 51 /* 2. The key is 12 bits Prefix code + 8 bit new char or 20 bits. */ 52 /* The key is the upper 20 bits. The code is the lower 12. */ 53 #define HT_GET_KEY(l) (l >> 12) 54 #define HT_GET_CODE(l) (l & 0x0FFF) 55 #define HT_PUT_KEY(l) (l << 12) 56 #define HT_PUT_CODE(l) (l & 0x0FFF) 57 58 typedef struct GifHashTableType { 59 uint32_t HTable[HT_SIZE]; 60 } GifHashTableType; 61 62 GifHashTableType *_InitHashTable(void); 63 void _ClearHashTable(GifHashTableType *HashTable); 64 void _InsertHashTable(GifHashTableType *HashTable, uint32_t Key, int Code); 65 int _ExistsHashTable(GifHashTableType *HashTable, uint32_t Key); 66 67 #endif /* _GIF_HASH_H_ */ 68 69 /* end */ 70