Debian Codegraph @

frmts/gif/giflib/gif_lib_private.h

raw
1 /****************************************************************************
2
3 gif_lib_private.h - internal giflib routines and structures
4
5 SPDX-License-Identifier: MIT
6
7 ****************************************************************************/
8
9 #ifndef _GIF_LIB_PRIVATE_H
10 #define _GIF_LIB_PRIVATE_H
11
12 #include "gif_hash.h"
13 #include "gif_lib.h"
14
15 #include <stdio.h>
16
17 #ifndef SIZE_MAX
18 #define SIZE_MAX UINTPTR_MAX
19 #endif
20
21 #define EXTENSION_INTRODUCER 0x21
22 #define DESCRIPTOR_INTRODUCER 0x2c
23 #define TERMINATOR_INTRODUCER 0x3b
24
25 #define LZ_MAX_CODE 4095 /* Biggest code possible in 12 bits. */
26 #define LZ_BITS 12
27
28 #define FLUSH_OUTPUT 4096 /* Impossible code, to signal flush. */
29 #define FIRST_CODE 4097 /* Impossible code, to signal first. */
30 #define NO_SUCH_CODE 4098 /* Impossible code, to signal empty. */
31
32 #define FILE_STATE_WRITE 0x01
33 #define FILE_STATE_SCREEN 0x02
34 #define FILE_STATE_IMAGE 0x04
35 #define FILE_STATE_READ 0x08
36
37 #define IS_READABLE(Private) (Private->FileState & FILE_STATE_READ)
38 #define IS_WRITEABLE(Private) (Private->FileState & FILE_STATE_WRITE)
39
40 typedef struct GifFilePrivateType {
41 GifWord FileState, FileHandle, /* Where all this data goes to! */
42 BitsPerPixel, /* Bits per pixel (Codes uses at least this + 1). */
43 ClearCode, /* The CLEAR LZ code. */
44 EOFCode, /* The EOF LZ code. */
45 RunningCode, /* The next code algorithm can generate. */
46 RunningBits, /* The number of bits required to represent
47 RunningCode. */
48 MaxCode1, /* 1 bigger than max. possible code, in RunningBits bits.
49 */
50 LastCode, /* The code before the current code. */
51 CrntCode, /* Current algorithm code. */
52 StackPtr, /* For character stack (see below). */
53 CrntShiftState; /* Number of bits in CrntShiftDWord. */
54 unsigned long CrntShiftDWord; /* For bytes decomposition into codes. */
55 unsigned long PixelCount; /* Number of pixels in image. */
56 FILE *File; /* File as stream. */
57 InputFunc Read; /* function to read gif input (TVT) */
58 OutputFunc Write; /* function to write gif output (MRB) */
59 GifByteType Buf[256]; /* Compressed input is buffered here. */
60 GifByteType Stack[LZ_MAX_CODE]; /* Decoded pixels are stacked here. */
61 GifByteType Suffix[LZ_MAX_CODE + 1]; /* So we can trace the codes. */
62 GifPrefixType Prefix[LZ_MAX_CODE + 1];
63 GifHashTableType *HashTable;
64 bool gif89;
65 } GifFilePrivateType;
66
67 #ifndef HAVE_REALLOCARRAY
68 extern void *openbsd_reallocarray(void *optr, size_t nmemb, size_t size);
69 #define reallocarray openbsd_reallocarray
70 #endif
71
72 #endif /* _GIF_LIB_PRIVATE_H */
73
74 /* end */