Bug 1883853 [wpt PR 44937] - [wdspec] fix test_set_permission_origin_unknown, a=testonly
[gecko.git] / image / decoders / GIF2.h
blobc0c6bf0fde1cf23028d4ae59763571faf8204fba
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_image_decoders_GIF2_H
7 #define mozilla_image_decoders_GIF2_H
9 #define MAX_LZW_BITS 12
10 #define MAX_BITS 4097 // 2^MAX_LZW_BITS+1
11 #define MAX_COLORS 256
12 #define MIN_HOLD_SIZE 256
14 enum { GIF_TRAILER = 0x3B }; // ';'
15 enum { GIF_IMAGE_SEPARATOR = 0x2C }; // ','
16 enum { GIF_EXTENSION_INTRODUCER = 0x21 }; // '!'
17 enum { GIF_GRAPHIC_CONTROL_LABEL = 0xF9 };
18 enum { GIF_APPLICATION_EXTENSION_LABEL = 0xFF };
20 // A GIF decoder's state
21 typedef struct gif_struct {
22 // LZW decoder state machine
23 uint8_t* stackp; // Current stack pointer
24 int datasize;
25 int codesize;
26 int codemask;
27 int avail; // Index of next available slot in dictionary
28 int oldcode;
29 uint8_t firstchar;
30 int bits; // Number of unread bits in "datum"
31 int32_t datum; // 32-bit input buffer
33 // Output state machine
34 int64_t pixels_remaining; // Pixels remaining to be output.
36 // Parameters for image frame currently being decoded
37 int tpixel; // Index of transparent pixel
38 int32_t disposal_method; // Restore to background, leave in place, etc.
39 uint32_t* local_colormap; // Per-image colormap
40 uint32_t local_colormap_buffer_size; // Size of the buffer containing the
41 // local colormap.
42 int local_colormap_size; // Size of local colormap array.
43 uint32_t delay_time; // Display time, in milliseconds,
44 // for this image in a multi-image GIF
46 // Global (multi-image) state
47 int version; // Either 89 for GIF89 or 87 for GIF87
48 int32_t screen_width; // Logical screen width & height
49 int32_t screen_height;
50 uint8_t global_colormap_depth; // Depth of global colormap array
51 uint16_t global_colormap_count; // Number of colors in global colormap
52 int images_decoded; // Counts images for multi-part GIFs
53 int loop_count; // Netscape specific extension block to control
54 // the number of animation loops a GIF
55 // renders.
57 bool is_transparent; // TRUE, if tpixel is valid
59 uint16_t prefix[MAX_BITS]; // LZW decoding tables
60 uint32_t global_colormap[MAX_COLORS]; // Default colormap if local not
61 // supplied
62 uint8_t suffix[MAX_BITS]; // LZW decoding tables
63 uint8_t stack[MAX_BITS]; // Base of LZW decoder stack
65 } gif_struct;
67 #endif // mozilla_image_decoders_GIF2_H