Gif.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * The Python Imaging Library.
  3. * $Id$
  4. *
  5. * Declarations for a fast, suspendable GIF decoder.
  6. *
  7. * Copyright (c) Fredrik Lundh 1995-96.
  8. */
  9. /* Max size for a LZW code word. */
  10. #define GIFBITS 12
  11. #define GIFTABLE (1<<GIFBITS)
  12. #define GIFBUFFER (1<<GIFBITS)
  13. typedef struct {
  14. /* CONFIGURATION */
  15. /* Initial number of bits. The caller should clear all fields in
  16. this structure and set this field before calling the decoder
  17. the first time. */
  18. int bits;
  19. /* If set, this is an interlaced image. Process it the following way:
  20. * 1st pass: start at top line, lines are 8 pixels high, step 8 pixels
  21. * 2nd pass: start at line 4, lines are 4 pixels high, step 8 pixels
  22. * 3rd pass: start at line 2, lines are 2 pixels high, step 4 pixels
  23. * 4th pass: start at line 1, lines are 1 pixels high, step 2 pixels
  24. */
  25. int interlace;
  26. /* The transparent palette index, or -1 for no transparency */
  27. int transparency;
  28. /* PRIVATE CONTEXT (set by decoder) */
  29. /* Interlace parameters */
  30. int step, repeat;
  31. /* Input bit buffer */
  32. INT32 bitbuffer;
  33. int bitcount;
  34. int blocksize;
  35. /* Code buffer */
  36. int codesize;
  37. int codemask;
  38. /* Constant symbol codes */
  39. int clear, end;
  40. /* Symbol history */
  41. int lastcode;
  42. unsigned char lastdata;
  43. /* History buffer */
  44. int bufferindex;
  45. unsigned char buffer[GIFTABLE];
  46. /* Symbol table */
  47. UINT16 link[GIFTABLE];
  48. unsigned char data[GIFTABLE];
  49. int next;
  50. } GIFDECODERSTATE;
  51. /* For GIF LZW encoder. */
  52. #define TABLE_SIZE 8192
  53. typedef struct {
  54. /* CONFIGURATION */
  55. /* Initial number of bits. The caller should clear all fields in
  56. this structure and set this field before calling the encoder
  57. the first time. */
  58. int bits;
  59. /* NOTE: the expanding encoder ignores this field */
  60. /* If set, write an interlaced image (see above) */
  61. int interlace;
  62. /* PRIVATE CONTEXT (set by encoder) */
  63. /* Interlace parameters */
  64. int step;
  65. /* For GIF LZW encoder. */
  66. UINT32 put_state;
  67. UINT32 entry_state;
  68. UINT32 clear_code, end_code, next_code, max_code;
  69. UINT32 code_width, code_bits_left, buf_bits_left;
  70. UINT32 code_buffer;
  71. UINT32 head, tail;
  72. int probe;
  73. UINT32 code;
  74. UINT32 codes[TABLE_SIZE];
  75. } GIFENCODERSTATE;