tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

GIF2.h (2773B)


      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/. */
      5 
      6 #ifndef mozilla_image_decoders_GIF2_H
      7 #define mozilla_image_decoders_GIF2_H
      8 
      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
     13 
     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 };
     19 
     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
     32 
     33  // Output state machine
     34  int64_t pixels_remaining;  // Pixels remaining to be output.
     35 
     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
     45 
     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.
     56 
     57  bool is_transparent;  // TRUE, if tpixel is valid
     58 
     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
     64 
     65 } gif_struct;
     66 
     67 #endif  // mozilla_image_decoders_GIF2_H