Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

309 lines
13 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. /* pngstruct.h - header file for PNG reference library
  3. *
  4. * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  5. * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  6. * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  7. *
  8. * Last changed in libpng 1.5.0 [January 6, 2011]
  9. *
  10. * This code is released under the libpng license.
  11. * For conditions of distribution and use, see the disclaimer
  12. * and license in png.h
  13. */
  14. /* The structure that holds the information to read and write PNG files.
  15. * The only people who need to care about what is inside of this are the
  16. * people who will be modifying the library for their own special needs.
  17. * It should NOT be accessed directly by an application.
  18. */
  19. #ifndef PNGSTRUCT_H
  20. #define PNGSTRUCT_H
  21. /* zlib.h defines the structure z_stream, an instance of which is included
  22. * in this structure and is required for decompressing the LZ compressed
  23. * data in PNG files.
  24. */
  25. #include "../zlib/zlib.h"
  26. struct png_struct_def
  27. {
  28. #ifdef PNG_SETJMP_SUPPORTED
  29. jmp_buf png_jmpbuf; /* used in png_error */
  30. png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */
  31. #endif
  32. png_error_ptr error_fn; /* function for printing errors and aborting */
  33. png_error_ptr warning_fn; /* function for printing warnings */
  34. png_voidp error_ptr; /* user supplied struct for error functions */
  35. png_rw_ptr write_data_fn; /* function for writing output data */
  36. png_rw_ptr read_data_fn; /* function for reading input data */
  37. png_voidp io_ptr; /* ptr to application struct for I/O functions */
  38. #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
  39. png_user_transform_ptr read_user_transform_fn; /* user read transform */
  40. #endif
  41. #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
  42. png_user_transform_ptr write_user_transform_fn; /* user write transform */
  43. #endif
  44. /* These were added in libpng-1.0.2 */
  45. #ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
  46. #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
  47. defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
  48. png_voidp user_transform_ptr; /* user supplied struct for user transform */
  49. png_byte user_transform_depth; /* bit depth of user transformed pixels */
  50. png_byte user_transform_channels; /* channels in user transformed pixels */
  51. #endif
  52. #endif
  53. png_uint_32 mode; /* tells us where we are in the PNG file */
  54. png_uint_32 flags; /* flags indicating various things to libpng */
  55. png_uint_32 transformations; /* which transformations to perform */
  56. z_stream zstream; /* pointer to decompression structure (below) */
  57. png_bytep zbuf; /* buffer for zlib */
  58. uInt zbuf_size; /* size of zbuf (typically 65536) */
  59. int zlib_level; /* holds zlib compression level */
  60. int zlib_method; /* holds zlib compression method */
  61. int zlib_window_bits; /* holds zlib compression window bits */
  62. int zlib_mem_level; /* holds zlib compression memory level */
  63. int zlib_strategy; /* holds zlib compression strategy */
  64. png_uint_32 width; /* width of image in pixels */
  65. png_uint_32 height; /* height of image in pixels */
  66. png_uint_32 num_rows; /* number of rows in current pass */
  67. png_uint_32 usr_width; /* width of row at start of write */
  68. png_size_t rowbytes; /* size of row in bytes */
  69. png_uint_32 iwidth; /* width of current interlaced row in pixels */
  70. png_uint_32 row_number; /* current row in interlace pass */
  71. png_bytep prev_row; /* buffer to save previous (unfiltered) row */
  72. png_bytep row_buf; /* buffer to save current (unfiltered) row */
  73. png_bytep sub_row; /* buffer to save "sub" row when filtering */
  74. png_bytep up_row; /* buffer to save "up" row when filtering */
  75. png_bytep avg_row; /* buffer to save "avg" row when filtering */
  76. png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
  77. png_row_info row_info; /* used for transformation routines */
  78. png_uint_32 idat_size; /* current IDAT size for read */
  79. png_uint_32 crc; /* current chunk CRC value */
  80. png_colorp palette; /* palette from the input file */
  81. png_uint_16 num_palette; /* number of color entries in palette */
  82. png_uint_16 num_trans; /* number of transparency values */
  83. png_byte chunk_name[5]; /* null-terminated name of current chunk */
  84. png_byte compression; /* file compression type (always 0) */
  85. png_byte filter; /* file filter type (always 0) */
  86. png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
  87. png_byte pass; /* current interlace pass (0 - 6) */
  88. png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
  89. png_byte color_type; /* color type of file */
  90. png_byte bit_depth; /* bit depth of file */
  91. png_byte usr_bit_depth; /* bit depth of users row */
  92. png_byte pixel_depth; /* number of bits per pixel */
  93. png_byte channels; /* number of channels in file */
  94. png_byte usr_channels; /* channels at start of write */
  95. png_byte sig_bytes; /* magic bytes read/written from start of file */
  96. #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
  97. png_uint_16 filler; /* filler bytes for pixel expansion */
  98. #endif
  99. #ifdef PNG_bKGD_SUPPORTED
  100. png_byte background_gamma_type;
  101. png_fixed_point background_gamma;
  102. png_color_16 background; /* background color in screen gamma space */
  103. #ifdef PNG_READ_GAMMA_SUPPORTED
  104. png_color_16 background_1; /* background normalized to gamma 1.0 */
  105. #endif
  106. #endif /* PNG_bKGD_SUPPORTED */
  107. #ifdef PNG_WRITE_FLUSH_SUPPORTED
  108. png_flush_ptr output_flush_fn; /* Function for flushing output */
  109. png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */
  110. png_uint_32 flush_rows; /* number of rows written since last flush */
  111. #endif
  112. #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
  113. int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
  114. png_fixed_point gamma; /* file gamma value */
  115. png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
  116. #endif
  117. #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
  118. png_bytep gamma_table; /* gamma table for 8-bit depth files */
  119. png_bytep gamma_from_1; /* converts from 1.0 to screen */
  120. png_bytep gamma_to_1; /* converts from file to 1.0 */
  121. png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
  122. png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
  123. png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
  124. #endif
  125. #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
  126. png_color_8 sig_bit; /* significant bits in each available channel */
  127. #endif
  128. #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
  129. png_color_8 shift; /* shift for significant bit tranformation */
  130. #endif
  131. #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
  132. || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
  133. png_bytep trans_alpha; /* alpha values for paletted files */
  134. png_color_16 trans_color; /* transparent color for non-paletted files */
  135. #endif
  136. png_read_status_ptr read_row_fn; /* called after each row is decoded */
  137. png_write_status_ptr write_row_fn; /* called after each row is encoded */
  138. #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  139. png_progressive_info_ptr info_fn; /* called after header data fully read */
  140. png_progressive_row_ptr row_fn; /* called after a prog. row is decoded */
  141. png_progressive_end_ptr end_fn; /* called after image is complete */
  142. png_bytep save_buffer_ptr; /* current location in save_buffer */
  143. png_bytep save_buffer; /* buffer for previously read data */
  144. png_bytep current_buffer_ptr; /* current location in current_buffer */
  145. png_bytep current_buffer; /* buffer for recently used data */
  146. png_uint_32 push_length; /* size of current input chunk */
  147. png_uint_32 skip_length; /* bytes to skip in input data */
  148. png_size_t save_buffer_size; /* amount of data now in save_buffer */
  149. png_size_t save_buffer_max; /* total size of save_buffer */
  150. png_size_t buffer_size; /* total amount of available input data */
  151. png_size_t current_buffer_size; /* amount of data now in current_buffer */
  152. int process_mode; /* what push library is currently doing */
  153. int cur_palette; /* current push library palette index */
  154. # ifdef PNG_TEXT_SUPPORTED
  155. png_size_t current_text_size; /* current size of text input data */
  156. png_size_t current_text_left; /* how much text left to read in input */
  157. png_charp current_text; /* current text chunk buffer */
  158. png_charp current_text_ptr; /* current location in current_text */
  159. # endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */
  160. #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
  161. #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
  162. /* For the Borland special 64K segment handler */
  163. png_bytepp offset_table_ptr;
  164. png_bytep offset_table;
  165. png_uint_16 offset_table_number;
  166. png_uint_16 offset_table_count;
  167. png_uint_16 offset_table_count_free;
  168. #endif
  169. #ifdef PNG_READ_QUANTIZE_SUPPORTED
  170. png_bytep palette_lookup; /* lookup table for quantizing */
  171. png_bytep quantize_index; /* index translation for palette files */
  172. #endif
  173. #if defined(PNG_READ_QUANTIZE_SUPPORTED) || defined(PNG_hIST_SUPPORTED)
  174. png_uint_16p hist; /* histogram */
  175. #endif
  176. #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
  177. png_byte heuristic_method; /* heuristic for row filter selection */
  178. png_byte num_prev_filters; /* number of weights for previous rows */
  179. png_bytep prev_filters; /* filter type(s) of previous row(s) */
  180. png_uint_16p filter_weights; /* weight(s) for previous line(s) */
  181. png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */
  182. png_uint_16p filter_costs; /* relative filter calculation cost */
  183. png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
  184. #endif
  185. #ifdef PNG_TIME_RFC1123_SUPPORTED
  186. png_charp time_buffer; /* String to hold RFC 1123 time text */
  187. #endif
  188. /* New members added in libpng-1.0.6 */
  189. png_uint_32 free_me; /* flags items libpng is responsible for freeing */
  190. #ifdef PNG_USER_CHUNKS_SUPPORTED
  191. png_voidp user_chunk_ptr;
  192. png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
  193. #endif
  194. #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
  195. int num_chunk_list;
  196. png_bytep chunk_list;
  197. #endif
  198. /* New members added in libpng-1.0.3 */
  199. #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
  200. png_byte rgb_to_gray_status;
  201. /* These were changed from png_byte in libpng-1.0.6 */
  202. png_uint_16 rgb_to_gray_red_coeff;
  203. png_uint_16 rgb_to_gray_green_coeff;
  204. png_uint_16 rgb_to_gray_blue_coeff;
  205. #endif
  206. /* New member added in libpng-1.0.4 (renamed in 1.0.9) */
  207. #if defined(PNG_MNG_FEATURES_SUPPORTED) || \
  208. defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
  209. defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
  210. /* Changed from png_byte to png_uint_32 at version 1.2.0 */
  211. png_uint_32 mng_features_permitted;
  212. #endif
  213. /* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */
  214. #ifdef PNG_MNG_FEATURES_SUPPORTED
  215. png_byte filter_type;
  216. #endif
  217. /* New members added in libpng-1.2.0 */
  218. /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
  219. #ifdef PNG_USER_MEM_SUPPORTED
  220. png_voidp mem_ptr; /* user supplied struct for mem functions */
  221. png_malloc_ptr malloc_fn; /* function for allocating memory */
  222. png_free_ptr free_fn; /* function for freeing memory */
  223. #endif
  224. /* New member added in libpng-1.0.13 and 1.2.0 */
  225. png_bytep big_row_buf; /* buffer to save current (unfiltered) row */
  226. #ifdef PNG_READ_QUANTIZE_SUPPORTED
  227. /* The following three members were added at version 1.0.14 and 1.2.4 */
  228. png_bytep quantize_sort; /* working sort array */
  229. png_bytep index_to_palette; /* where the original index currently is
  230. in the palette */
  231. png_bytep palette_to_index; /* which original index points to this
  232. palette color */
  233. #endif
  234. /* New members added in libpng-1.0.16 and 1.2.6 */
  235. png_byte compression_type;
  236. #ifdef PNG_USER_LIMITS_SUPPORTED
  237. png_uint_32 user_width_max;
  238. png_uint_32 user_height_max;
  239. /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown
  240. * chunks that can be stored (0 means unlimited).
  241. */
  242. png_uint_32 user_chunk_cache_max;
  243. /* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk
  244. * can occupy when decompressed. 0 means unlimited.
  245. */
  246. png_alloc_size_t user_chunk_malloc_max;
  247. #endif
  248. /* New member added in libpng-1.0.25 and 1.2.17 */
  249. #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
  250. /* Storage for unknown chunk that the library doesn't recognize. */
  251. png_unknown_chunk unknown_chunk;
  252. #endif
  253. /* New members added in libpng-1.2.26 */
  254. png_size_t old_big_row_buf_size;
  255. png_size_t old_prev_row_size;
  256. /* New member added in libpng-1.2.30 */
  257. png_charp chunkdata; /* buffer for reading chunk data */
  258. #ifdef PNG_IO_STATE_SUPPORTED
  259. /* New member added in libpng-1.4.0 */
  260. png_uint_32 io_state;
  261. #endif
  262. };
  263. #endif /* PNGSTRUCT_H */