xref: /aosp_15_r20/external/libpng/pngstruct.h (revision a67afe4df73cf47866eedc69947994b8ff839aba)
1*a67afe4dSAndroid Build Coastguard Worker 
2*a67afe4dSAndroid Build Coastguard Worker /* pngstruct.h - header file for PNG reference library
3*a67afe4dSAndroid Build Coastguard Worker  *
4*a67afe4dSAndroid Build Coastguard Worker  * Copyright (c) 2018-2022 Cosmin Truta
5*a67afe4dSAndroid Build Coastguard Worker  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
6*a67afe4dSAndroid Build Coastguard Worker  * Copyright (c) 1996-1997 Andreas Dilger
7*a67afe4dSAndroid Build Coastguard Worker  * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
8*a67afe4dSAndroid Build Coastguard Worker  *
9*a67afe4dSAndroid Build Coastguard Worker  * This code is released under the libpng license.
10*a67afe4dSAndroid Build Coastguard Worker  * For conditions of distribution and use, see the disclaimer
11*a67afe4dSAndroid Build Coastguard Worker  * and license in png.h
12*a67afe4dSAndroid Build Coastguard Worker  */
13*a67afe4dSAndroid Build Coastguard Worker 
14*a67afe4dSAndroid Build Coastguard Worker /* The structure that holds the information to read and write PNG files.
15*a67afe4dSAndroid Build Coastguard Worker  * The only people who need to care about what is inside of this are the
16*a67afe4dSAndroid Build Coastguard Worker  * people who will be modifying the library for their own special needs.
17*a67afe4dSAndroid Build Coastguard Worker  * It should NOT be accessed directly by an application.
18*a67afe4dSAndroid Build Coastguard Worker  */
19*a67afe4dSAndroid Build Coastguard Worker 
20*a67afe4dSAndroid Build Coastguard Worker #ifndef PNGSTRUCT_H
21*a67afe4dSAndroid Build Coastguard Worker #define PNGSTRUCT_H
22*a67afe4dSAndroid Build Coastguard Worker /* zlib.h defines the structure z_stream, an instance of which is included
23*a67afe4dSAndroid Build Coastguard Worker  * in this structure and is required for decompressing the LZ compressed
24*a67afe4dSAndroid Build Coastguard Worker  * data in PNG files.
25*a67afe4dSAndroid Build Coastguard Worker  */
26*a67afe4dSAndroid Build Coastguard Worker #ifndef ZLIB_CONST
27*a67afe4dSAndroid Build Coastguard Worker    /* We must ensure that zlib uses 'const' in declarations. */
28*a67afe4dSAndroid Build Coastguard Worker #  define ZLIB_CONST
29*a67afe4dSAndroid Build Coastguard Worker #endif
30*a67afe4dSAndroid Build Coastguard Worker #include "zlib.h"
31*a67afe4dSAndroid Build Coastguard Worker #ifdef const
32*a67afe4dSAndroid Build Coastguard Worker    /* zlib.h sometimes #defines const to nothing, undo this. */
33*a67afe4dSAndroid Build Coastguard Worker #  undef const
34*a67afe4dSAndroid Build Coastguard Worker #endif
35*a67afe4dSAndroid Build Coastguard Worker 
36*a67afe4dSAndroid Build Coastguard Worker /* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility
37*a67afe4dSAndroid Build Coastguard Worker  * with older builds.
38*a67afe4dSAndroid Build Coastguard Worker  */
39*a67afe4dSAndroid Build Coastguard Worker #if ZLIB_VERNUM < 0x1260
40*a67afe4dSAndroid Build Coastguard Worker #  define PNGZ_MSG_CAST(s) png_constcast(char*,s)
41*a67afe4dSAndroid Build Coastguard Worker #  define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b)
42*a67afe4dSAndroid Build Coastguard Worker #else
43*a67afe4dSAndroid Build Coastguard Worker #  define PNGZ_MSG_CAST(s) (s)
44*a67afe4dSAndroid Build Coastguard Worker #  define PNGZ_INPUT_CAST(b) (b)
45*a67afe4dSAndroid Build Coastguard Worker #endif
46*a67afe4dSAndroid Build Coastguard Worker 
47*a67afe4dSAndroid Build Coastguard Worker /* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib
48*a67afe4dSAndroid Build Coastguard Worker  * can handle at once.  This type need be no larger than 16 bits (so maximum of
49*a67afe4dSAndroid Build Coastguard Worker  * 65535), this define allows us to discover how big it is, but limited by the
50*a67afe4dSAndroid Build Coastguard Worker  * maximum for size_t.  The value can be overridden in a library build
51*a67afe4dSAndroid Build Coastguard Worker  * (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably
52*a67afe4dSAndroid Build Coastguard Worker  * lower value (e.g. 255 works).  A lower value may help memory usage (slightly)
53*a67afe4dSAndroid Build Coastguard Worker  * and may even improve performance on some systems (and degrade it on others.)
54*a67afe4dSAndroid Build Coastguard Worker  */
55*a67afe4dSAndroid Build Coastguard Worker #ifndef ZLIB_IO_MAX
56*a67afe4dSAndroid Build Coastguard Worker #  define ZLIB_IO_MAX ((uInt)-1)
57*a67afe4dSAndroid Build Coastguard Worker #endif
58*a67afe4dSAndroid Build Coastguard Worker 
59*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_WRITE_SUPPORTED
60*a67afe4dSAndroid Build Coastguard Worker /* The type of a compression buffer list used by the write code. */
61*a67afe4dSAndroid Build Coastguard Worker typedef struct png_compression_buffer
62*a67afe4dSAndroid Build Coastguard Worker {
63*a67afe4dSAndroid Build Coastguard Worker    struct png_compression_buffer *next;
64*a67afe4dSAndroid Build Coastguard Worker    png_byte                       output[1]; /* actually zbuf_size */
65*a67afe4dSAndroid Build Coastguard Worker } png_compression_buffer, *png_compression_bufferp;
66*a67afe4dSAndroid Build Coastguard Worker 
67*a67afe4dSAndroid Build Coastguard Worker #define PNG_COMPRESSION_BUFFER_SIZE(pp)\
68*a67afe4dSAndroid Build Coastguard Worker    (offsetof(png_compression_buffer, output) + (pp)->zbuffer_size)
69*a67afe4dSAndroid Build Coastguard Worker #endif
70*a67afe4dSAndroid Build Coastguard Worker 
71*a67afe4dSAndroid Build Coastguard Worker /* Colorspace support; structures used in png_struct, png_info and in internal
72*a67afe4dSAndroid Build Coastguard Worker  * functions to hold and communicate information about the color space.
73*a67afe4dSAndroid Build Coastguard Worker  *
74*a67afe4dSAndroid Build Coastguard Worker  * PNG_COLORSPACE_SUPPORTED is only required if the application will perform
75*a67afe4dSAndroid Build Coastguard Worker  * colorspace corrections, otherwise all the colorspace information can be
76*a67afe4dSAndroid Build Coastguard Worker  * skipped and the size of libpng can be reduced (significantly) by compiling
77*a67afe4dSAndroid Build Coastguard Worker  * out the colorspace support.
78*a67afe4dSAndroid Build Coastguard Worker  */
79*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_COLORSPACE_SUPPORTED
80*a67afe4dSAndroid Build Coastguard Worker /* The chromaticities of the red, green and blue colorants and the chromaticity
81*a67afe4dSAndroid Build Coastguard Worker  * of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)).
82*a67afe4dSAndroid Build Coastguard Worker  */
83*a67afe4dSAndroid Build Coastguard Worker typedef struct png_xy
84*a67afe4dSAndroid Build Coastguard Worker {
85*a67afe4dSAndroid Build Coastguard Worker    png_fixed_point redx, redy;
86*a67afe4dSAndroid Build Coastguard Worker    png_fixed_point greenx, greeny;
87*a67afe4dSAndroid Build Coastguard Worker    png_fixed_point bluex, bluey;
88*a67afe4dSAndroid Build Coastguard Worker    png_fixed_point whitex, whitey;
89*a67afe4dSAndroid Build Coastguard Worker } png_xy;
90*a67afe4dSAndroid Build Coastguard Worker 
91*a67afe4dSAndroid Build Coastguard Worker /* The same data as above but encoded as CIE XYZ values.  When this data comes
92*a67afe4dSAndroid Build Coastguard Worker  * from chromaticities the sum of the Y values is assumed to be 1.0
93*a67afe4dSAndroid Build Coastguard Worker  */
94*a67afe4dSAndroid Build Coastguard Worker typedef struct png_XYZ
95*a67afe4dSAndroid Build Coastguard Worker {
96*a67afe4dSAndroid Build Coastguard Worker    png_fixed_point red_X, red_Y, red_Z;
97*a67afe4dSAndroid Build Coastguard Worker    png_fixed_point green_X, green_Y, green_Z;
98*a67afe4dSAndroid Build Coastguard Worker    png_fixed_point blue_X, blue_Y, blue_Z;
99*a67afe4dSAndroid Build Coastguard Worker } png_XYZ;
100*a67afe4dSAndroid Build Coastguard Worker #endif /* COLORSPACE */
101*a67afe4dSAndroid Build Coastguard Worker 
102*a67afe4dSAndroid Build Coastguard Worker #if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
103*a67afe4dSAndroid Build Coastguard Worker /* A colorspace is all the above plus, potentially, profile information;
104*a67afe4dSAndroid Build Coastguard Worker  * however at present libpng does not use the profile internally so it is only
105*a67afe4dSAndroid Build Coastguard Worker  * stored in the png_info struct (if iCCP is supported.)  The rendering intent
106*a67afe4dSAndroid Build Coastguard Worker  * is retained here and is checked.
107*a67afe4dSAndroid Build Coastguard Worker  *
108*a67afe4dSAndroid Build Coastguard Worker  * The file gamma encoding information is also stored here and gamma correction
109*a67afe4dSAndroid Build Coastguard Worker  * is done by libpng, whereas color correction must currently be done by the
110*a67afe4dSAndroid Build Coastguard Worker  * application.
111*a67afe4dSAndroid Build Coastguard Worker  */
112*a67afe4dSAndroid Build Coastguard Worker typedef struct png_colorspace
113*a67afe4dSAndroid Build Coastguard Worker {
114*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_GAMMA_SUPPORTED
115*a67afe4dSAndroid Build Coastguard Worker    png_fixed_point gamma;        /* File gamma */
116*a67afe4dSAndroid Build Coastguard Worker #endif
117*a67afe4dSAndroid Build Coastguard Worker 
118*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_COLORSPACE_SUPPORTED
119*a67afe4dSAndroid Build Coastguard Worker    png_xy      end_points_xy;    /* End points as chromaticities */
120*a67afe4dSAndroid Build Coastguard Worker    png_XYZ     end_points_XYZ;   /* End points as CIE XYZ colorant values */
121*a67afe4dSAndroid Build Coastguard Worker    png_uint_16 rendering_intent; /* Rendering intent of a profile */
122*a67afe4dSAndroid Build Coastguard Worker #endif
123*a67afe4dSAndroid Build Coastguard Worker 
124*a67afe4dSAndroid Build Coastguard Worker    /* Flags are always defined to simplify the code. */
125*a67afe4dSAndroid Build Coastguard Worker    png_uint_16 flags;            /* As defined below */
126*a67afe4dSAndroid Build Coastguard Worker } png_colorspace, * PNG_RESTRICT png_colorspacerp;
127*a67afe4dSAndroid Build Coastguard Worker 
128*a67afe4dSAndroid Build Coastguard Worker typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;
129*a67afe4dSAndroid Build Coastguard Worker 
130*a67afe4dSAndroid Build Coastguard Worker /* General flags for the 'flags' field */
131*a67afe4dSAndroid Build Coastguard Worker #define PNG_COLORSPACE_HAVE_GAMMA           0x0001
132*a67afe4dSAndroid Build Coastguard Worker #define PNG_COLORSPACE_HAVE_ENDPOINTS       0x0002
133*a67afe4dSAndroid Build Coastguard Worker #define PNG_COLORSPACE_HAVE_INTENT          0x0004
134*a67afe4dSAndroid Build Coastguard Worker #define PNG_COLORSPACE_FROM_gAMA            0x0008
135*a67afe4dSAndroid Build Coastguard Worker #define PNG_COLORSPACE_FROM_cHRM            0x0010
136*a67afe4dSAndroid Build Coastguard Worker #define PNG_COLORSPACE_FROM_sRGB            0x0020
137*a67afe4dSAndroid Build Coastguard Worker #define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040
138*a67afe4dSAndroid Build Coastguard Worker #define PNG_COLORSPACE_MATCHES_sRGB         0x0080 /* exact match on profile */
139*a67afe4dSAndroid Build Coastguard Worker #define PNG_COLORSPACE_INVALID              0x8000
140*a67afe4dSAndroid Build Coastguard Worker #define PNG_COLORSPACE_CANCEL(flags)        (0xffff ^ (flags))
141*a67afe4dSAndroid Build Coastguard Worker #endif /* COLORSPACE || GAMMA */
142*a67afe4dSAndroid Build Coastguard Worker 
143*a67afe4dSAndroid Build Coastguard Worker struct png_struct_def
144*a67afe4dSAndroid Build Coastguard Worker {
145*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_SETJMP_SUPPORTED
146*a67afe4dSAndroid Build Coastguard Worker    jmp_buf jmp_buf_local;     /* New name in 1.6.0 for jmp_buf in png_struct */
147*a67afe4dSAndroid Build Coastguard Worker    png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */
148*a67afe4dSAndroid Build Coastguard Worker    jmp_buf *jmp_buf_ptr;      /* passed to longjmp_fn */
149*a67afe4dSAndroid Build Coastguard Worker    size_t jmp_buf_size;       /* size of the above, if allocated */
150*a67afe4dSAndroid Build Coastguard Worker #endif
151*a67afe4dSAndroid Build Coastguard Worker    png_error_ptr error_fn;    /* function for printing errors and aborting */
152*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_WARNINGS_SUPPORTED
153*a67afe4dSAndroid Build Coastguard Worker    png_error_ptr warning_fn;  /* function for printing warnings */
154*a67afe4dSAndroid Build Coastguard Worker #endif
155*a67afe4dSAndroid Build Coastguard Worker    png_voidp error_ptr;       /* user supplied struct for error functions */
156*a67afe4dSAndroid Build Coastguard Worker    png_rw_ptr write_data_fn;  /* function for writing output data */
157*a67afe4dSAndroid Build Coastguard Worker    png_rw_ptr read_data_fn;   /* function for reading input data */
158*a67afe4dSAndroid Build Coastguard Worker    png_voidp io_ptr;          /* ptr to application struct for I/O functions */
159*a67afe4dSAndroid Build Coastguard Worker 
160*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
161*a67afe4dSAndroid Build Coastguard Worker    png_user_transform_ptr read_user_transform_fn; /* user read transform */
162*a67afe4dSAndroid Build Coastguard Worker #endif
163*a67afe4dSAndroid Build Coastguard Worker 
164*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
165*a67afe4dSAndroid Build Coastguard Worker    png_user_transform_ptr write_user_transform_fn; /* user write transform */
166*a67afe4dSAndroid Build Coastguard Worker #endif
167*a67afe4dSAndroid Build Coastguard Worker 
168*a67afe4dSAndroid Build Coastguard Worker /* These were added in libpng-1.0.2 */
169*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
170*a67afe4dSAndroid Build Coastguard Worker #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
171*a67afe4dSAndroid Build Coastguard Worker     defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
172*a67afe4dSAndroid Build Coastguard Worker    png_voidp user_transform_ptr; /* user supplied struct for user transform */
173*a67afe4dSAndroid Build Coastguard Worker    png_byte user_transform_depth;    /* bit depth of user transformed pixels */
174*a67afe4dSAndroid Build Coastguard Worker    png_byte user_transform_channels; /* channels in user transformed pixels */
175*a67afe4dSAndroid Build Coastguard Worker #endif
176*a67afe4dSAndroid Build Coastguard Worker #endif
177*a67afe4dSAndroid Build Coastguard Worker 
178*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 mode;          /* tells us where we are in the PNG file */
179*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 flags;         /* flags indicating various things to libpng */
180*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 transformations; /* which transformations to perform */
181*a67afe4dSAndroid Build Coastguard Worker 
182*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 zowner;        /* ID (chunk type) of zstream owner, 0 if none */
183*a67afe4dSAndroid Build Coastguard Worker    z_stream    zstream;       /* decompression structure */
184*a67afe4dSAndroid Build Coastguard Worker 
185*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_WRITE_SUPPORTED
186*a67afe4dSAndroid Build Coastguard Worker    png_compression_bufferp zbuffer_list; /* Created on demand during write */
187*a67afe4dSAndroid Build Coastguard Worker    uInt                    zbuffer_size; /* size of the actual buffer */
188*a67afe4dSAndroid Build Coastguard Worker 
189*a67afe4dSAndroid Build Coastguard Worker    int zlib_level;            /* holds zlib compression level */
190*a67afe4dSAndroid Build Coastguard Worker    int zlib_method;           /* holds zlib compression method */
191*a67afe4dSAndroid Build Coastguard Worker    int zlib_window_bits;      /* holds zlib compression window bits */
192*a67afe4dSAndroid Build Coastguard Worker    int zlib_mem_level;        /* holds zlib compression memory level */
193*a67afe4dSAndroid Build Coastguard Worker    int zlib_strategy;         /* holds zlib compression strategy */
194*a67afe4dSAndroid Build Coastguard Worker #endif
195*a67afe4dSAndroid Build Coastguard Worker /* Added at libpng 1.5.4 */
196*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
197*a67afe4dSAndroid Build Coastguard Worker    int zlib_text_level;            /* holds zlib compression level */
198*a67afe4dSAndroid Build Coastguard Worker    int zlib_text_method;           /* holds zlib compression method */
199*a67afe4dSAndroid Build Coastguard Worker    int zlib_text_window_bits;      /* holds zlib compression window bits */
200*a67afe4dSAndroid Build Coastguard Worker    int zlib_text_mem_level;        /* holds zlib compression memory level */
201*a67afe4dSAndroid Build Coastguard Worker    int zlib_text_strategy;         /* holds zlib compression strategy */
202*a67afe4dSAndroid Build Coastguard Worker #endif
203*a67afe4dSAndroid Build Coastguard Worker /* End of material added at libpng 1.5.4 */
204*a67afe4dSAndroid Build Coastguard Worker /* Added at libpng 1.6.0 */
205*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_WRITE_SUPPORTED
206*a67afe4dSAndroid Build Coastguard Worker    int zlib_set_level;        /* Actual values set into the zstream on write */
207*a67afe4dSAndroid Build Coastguard Worker    int zlib_set_method;
208*a67afe4dSAndroid Build Coastguard Worker    int zlib_set_window_bits;
209*a67afe4dSAndroid Build Coastguard Worker    int zlib_set_mem_level;
210*a67afe4dSAndroid Build Coastguard Worker    int zlib_set_strategy;
211*a67afe4dSAndroid Build Coastguard Worker #endif
212*a67afe4dSAndroid Build Coastguard Worker 
213*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 width;         /* width of image in pixels */
214*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 height;        /* height of image in pixels */
215*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 num_rows;      /* number of rows in current pass */
216*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 usr_width;     /* width of row at start of write */
217*a67afe4dSAndroid Build Coastguard Worker    size_t rowbytes;           /* size of row in bytes */
218*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 iwidth;        /* width of current interlaced row in pixels */
219*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 row_number;    /* current row in interlace pass */
220*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 chunk_name;    /* PNG_CHUNK() id of current chunk */
221*a67afe4dSAndroid Build Coastguard Worker    png_bytep prev_row;        /* buffer to save previous (unfiltered) row.
222*a67afe4dSAndroid Build Coastguard Worker                                * While reading this is a pointer into
223*a67afe4dSAndroid Build Coastguard Worker                                * big_prev_row; while writing it is separately
224*a67afe4dSAndroid Build Coastguard Worker                                * allocated if needed.
225*a67afe4dSAndroid Build Coastguard Worker                                */
226*a67afe4dSAndroid Build Coastguard Worker    png_bytep row_buf;         /* buffer to save current (unfiltered) row.
227*a67afe4dSAndroid Build Coastguard Worker                                * While reading, this is a pointer into
228*a67afe4dSAndroid Build Coastguard Worker                                * big_row_buf; while writing it is separately
229*a67afe4dSAndroid Build Coastguard Worker                                * allocated.
230*a67afe4dSAndroid Build Coastguard Worker                                */
231*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_WRITE_FILTER_SUPPORTED
232*a67afe4dSAndroid Build Coastguard Worker    png_bytep try_row;    /* buffer to save trial row when filtering */
233*a67afe4dSAndroid Build Coastguard Worker    png_bytep tst_row;    /* buffer to save best trial row when filtering */
234*a67afe4dSAndroid Build Coastguard Worker #endif
235*a67afe4dSAndroid Build Coastguard Worker    size_t info_rowbytes;      /* Added in 1.5.4: cache of updated row bytes */
236*a67afe4dSAndroid Build Coastguard Worker 
237*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 idat_size;     /* current IDAT size for read */
238*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 crc;           /* current chunk CRC value */
239*a67afe4dSAndroid Build Coastguard Worker    png_colorp palette;        /* palette from the input file */
240*a67afe4dSAndroid Build Coastguard Worker    png_uint_16 num_palette;   /* number of color entries in palette */
241*a67afe4dSAndroid Build Coastguard Worker 
242*a67afe4dSAndroid Build Coastguard Worker /* Added at libpng-1.5.10 */
243*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
244*a67afe4dSAndroid Build Coastguard Worker    int num_palette_max;       /* maximum palette index found in IDAT */
245*a67afe4dSAndroid Build Coastguard Worker #endif
246*a67afe4dSAndroid Build Coastguard Worker 
247*a67afe4dSAndroid Build Coastguard Worker    png_uint_16 num_trans;     /* number of transparency values */
248*a67afe4dSAndroid Build Coastguard Worker    png_byte compression;      /* file compression type (always 0) */
249*a67afe4dSAndroid Build Coastguard Worker    png_byte filter;           /* file filter type (always 0) */
250*a67afe4dSAndroid Build Coastguard Worker    png_byte interlaced;       /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
251*a67afe4dSAndroid Build Coastguard Worker    png_byte pass;             /* current interlace pass (0 - 6) */
252*a67afe4dSAndroid Build Coastguard Worker    png_byte do_filter;        /* row filter flags (see PNG_FILTER_ in png.h ) */
253*a67afe4dSAndroid Build Coastguard Worker    png_byte color_type;       /* color type of file */
254*a67afe4dSAndroid Build Coastguard Worker    png_byte bit_depth;        /* bit depth of file */
255*a67afe4dSAndroid Build Coastguard Worker    png_byte usr_bit_depth;    /* bit depth of users row: write only */
256*a67afe4dSAndroid Build Coastguard Worker    png_byte pixel_depth;      /* number of bits per pixel */
257*a67afe4dSAndroid Build Coastguard Worker    png_byte channels;         /* number of channels in file */
258*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_WRITE_SUPPORTED
259*a67afe4dSAndroid Build Coastguard Worker    png_byte usr_channels;     /* channels at start of write: write only */
260*a67afe4dSAndroid Build Coastguard Worker #endif
261*a67afe4dSAndroid Build Coastguard Worker    png_byte sig_bytes;        /* magic bytes read/written from start of file */
262*a67afe4dSAndroid Build Coastguard Worker    png_byte maximum_pixel_depth;
263*a67afe4dSAndroid Build Coastguard Worker                               /* pixel depth used for the row buffers */
264*a67afe4dSAndroid Build Coastguard Worker    png_byte transformed_pixel_depth;
265*a67afe4dSAndroid Build Coastguard Worker                               /* pixel depth after read/write transforms */
266*a67afe4dSAndroid Build Coastguard Worker #if ZLIB_VERNUM >= 0x1240
267*a67afe4dSAndroid Build Coastguard Worker    png_byte zstream_start;    /* at start of an input zlib stream */
268*a67afe4dSAndroid Build Coastguard Worker #endif /* Zlib >= 1.2.4 */
269*a67afe4dSAndroid Build Coastguard Worker #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
270*a67afe4dSAndroid Build Coastguard Worker    png_uint_16 filler;           /* filler bytes for pixel expansion */
271*a67afe4dSAndroid Build Coastguard Worker #endif
272*a67afe4dSAndroid Build Coastguard Worker 
273*a67afe4dSAndroid Build Coastguard Worker #if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
274*a67afe4dSAndroid Build Coastguard Worker    defined(PNG_READ_ALPHA_MODE_SUPPORTED)
275*a67afe4dSAndroid Build Coastguard Worker    png_byte background_gamma_type;
276*a67afe4dSAndroid Build Coastguard Worker    png_fixed_point background_gamma;
277*a67afe4dSAndroid Build Coastguard Worker    png_color_16 background;   /* background color in screen gamma space */
278*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_READ_GAMMA_SUPPORTED
279*a67afe4dSAndroid Build Coastguard Worker    png_color_16 background_1; /* background normalized to gamma 1.0 */
280*a67afe4dSAndroid Build Coastguard Worker #endif
281*a67afe4dSAndroid Build Coastguard Worker #endif /* bKGD */
282*a67afe4dSAndroid Build Coastguard Worker 
283*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_WRITE_FLUSH_SUPPORTED
284*a67afe4dSAndroid Build Coastguard Worker    png_flush_ptr output_flush_fn; /* Function for flushing output */
285*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 flush_dist;    /* how many rows apart to flush, 0 - no flush */
286*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 flush_rows;    /* number of rows written since last flush */
287*a67afe4dSAndroid Build Coastguard Worker #endif
288*a67afe4dSAndroid Build Coastguard Worker 
289*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_READ_GAMMA_SUPPORTED
290*a67afe4dSAndroid Build Coastguard Worker    int gamma_shift;      /* number of "insignificant" bits in 16-bit gamma */
291*a67afe4dSAndroid Build Coastguard Worker    png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
292*a67afe4dSAndroid Build Coastguard Worker 
293*a67afe4dSAndroid Build Coastguard Worker    png_bytep gamma_table;     /* gamma table for 8-bit depth files */
294*a67afe4dSAndroid Build Coastguard Worker    png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
295*a67afe4dSAndroid Build Coastguard Worker #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
296*a67afe4dSAndroid Build Coastguard Worker    defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
297*a67afe4dSAndroid Build Coastguard Worker    defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
298*a67afe4dSAndroid Build Coastguard Worker    png_bytep gamma_from_1;    /* converts from 1.0 to screen */
299*a67afe4dSAndroid Build Coastguard Worker    png_bytep gamma_to_1;      /* converts from file to 1.0 */
300*a67afe4dSAndroid Build Coastguard Worker    png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
301*a67afe4dSAndroid Build Coastguard Worker    png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
302*a67afe4dSAndroid Build Coastguard Worker #endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
303*a67afe4dSAndroid Build Coastguard Worker #endif
304*a67afe4dSAndroid Build Coastguard Worker 
305*a67afe4dSAndroid Build Coastguard Worker #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
306*a67afe4dSAndroid Build Coastguard Worker    png_color_8 sig_bit;       /* significant bits in each available channel */
307*a67afe4dSAndroid Build Coastguard Worker #endif
308*a67afe4dSAndroid Build Coastguard Worker 
309*a67afe4dSAndroid Build Coastguard Worker #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
310*a67afe4dSAndroid Build Coastguard Worker    png_color_8 shift;         /* shift for significant bit transformation */
311*a67afe4dSAndroid Build Coastguard Worker #endif
312*a67afe4dSAndroid Build Coastguard Worker 
313*a67afe4dSAndroid Build Coastguard Worker #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
314*a67afe4dSAndroid Build Coastguard Worker  || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
315*a67afe4dSAndroid Build Coastguard Worker    png_bytep trans_alpha;           /* alpha values for paletted files */
316*a67afe4dSAndroid Build Coastguard Worker    png_color_16 trans_color;  /* transparent color for non-paletted files */
317*a67afe4dSAndroid Build Coastguard Worker #endif
318*a67afe4dSAndroid Build Coastguard Worker 
319*a67afe4dSAndroid Build Coastguard Worker    png_read_status_ptr read_row_fn;   /* called after each row is decoded */
320*a67afe4dSAndroid Build Coastguard Worker    png_write_status_ptr write_row_fn; /* called after each row is encoded */
321*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
322*a67afe4dSAndroid Build Coastguard Worker    png_progressive_info_ptr info_fn; /* called after header data fully read */
323*a67afe4dSAndroid Build Coastguard Worker    png_progressive_row_ptr row_fn;   /* called after a prog. row is decoded */
324*a67afe4dSAndroid Build Coastguard Worker    png_progressive_end_ptr end_fn;   /* called after image is complete */
325*a67afe4dSAndroid Build Coastguard Worker    png_bytep save_buffer_ptr;        /* current location in save_buffer */
326*a67afe4dSAndroid Build Coastguard Worker    png_bytep save_buffer;            /* buffer for previously read data */
327*a67afe4dSAndroid Build Coastguard Worker    png_bytep current_buffer_ptr;     /* current location in current_buffer */
328*a67afe4dSAndroid Build Coastguard Worker    png_bytep current_buffer;         /* buffer for recently used data */
329*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 push_length;          /* size of current input chunk */
330*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 skip_length;          /* bytes to skip in input data */
331*a67afe4dSAndroid Build Coastguard Worker    size_t save_buffer_size;          /* amount of data now in save_buffer */
332*a67afe4dSAndroid Build Coastguard Worker    size_t save_buffer_max;           /* total size of save_buffer */
333*a67afe4dSAndroid Build Coastguard Worker    size_t buffer_size;               /* total amount of available input data */
334*a67afe4dSAndroid Build Coastguard Worker    size_t current_buffer_size;       /* amount of data now in current_buffer */
335*a67afe4dSAndroid Build Coastguard Worker    int process_mode;                 /* what push library is currently doing */
336*a67afe4dSAndroid Build Coastguard Worker    int cur_palette;                  /* current push library palette index */
337*a67afe4dSAndroid Build Coastguard Worker #endif /* PROGRESSIVE_READ */
338*a67afe4dSAndroid Build Coastguard Worker 
339*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_READ_QUANTIZE_SUPPORTED
340*a67afe4dSAndroid Build Coastguard Worker    png_bytep palette_lookup; /* lookup table for quantizing */
341*a67afe4dSAndroid Build Coastguard Worker    png_bytep quantize_index; /* index translation for palette files */
342*a67afe4dSAndroid Build Coastguard Worker #endif
343*a67afe4dSAndroid Build Coastguard Worker 
344*a67afe4dSAndroid Build Coastguard Worker /* Options */
345*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_SET_OPTION_SUPPORTED
346*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 options;           /* On/off state (up to 16 options) */
347*a67afe4dSAndroid Build Coastguard Worker #endif
348*a67afe4dSAndroid Build Coastguard Worker 
349*a67afe4dSAndroid Build Coastguard Worker #if PNG_LIBPNG_VER < 10700
350*a67afe4dSAndroid Build Coastguard Worker /* To do: remove this from libpng-1.7 */
351*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_TIME_RFC1123_SUPPORTED
352*a67afe4dSAndroid Build Coastguard Worker    char time_buffer[29]; /* String to hold RFC 1123 time text */
353*a67afe4dSAndroid Build Coastguard Worker #endif
354*a67afe4dSAndroid Build Coastguard Worker #endif
355*a67afe4dSAndroid Build Coastguard Worker 
356*a67afe4dSAndroid Build Coastguard Worker /* New members added in libpng-1.0.6 */
357*a67afe4dSAndroid Build Coastguard Worker 
358*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 free_me;    /* flags items libpng is responsible for freeing */
359*a67afe4dSAndroid Build Coastguard Worker 
360*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_USER_CHUNKS_SUPPORTED
361*a67afe4dSAndroid Build Coastguard Worker    png_voidp user_chunk_ptr;
362*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_READ_USER_CHUNKS_SUPPORTED
363*a67afe4dSAndroid Build Coastguard Worker    png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
364*a67afe4dSAndroid Build Coastguard Worker #endif
365*a67afe4dSAndroid Build Coastguard Worker #endif
366*a67afe4dSAndroid Build Coastguard Worker 
367*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
368*a67afe4dSAndroid Build Coastguard Worker    int          unknown_default; /* As PNG_HANDLE_* */
369*a67afe4dSAndroid Build Coastguard Worker    unsigned int num_chunk_list;  /* Number of entries in the list */
370*a67afe4dSAndroid Build Coastguard Worker    png_bytep    chunk_list;      /* List of png_byte[5]; the textual chunk name
371*a67afe4dSAndroid Build Coastguard Worker                                   * followed by a PNG_HANDLE_* byte */
372*a67afe4dSAndroid Build Coastguard Worker #endif
373*a67afe4dSAndroid Build Coastguard Worker 
374*a67afe4dSAndroid Build Coastguard Worker /* New members added in libpng-1.0.3 */
375*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
376*a67afe4dSAndroid Build Coastguard Worker    png_byte rgb_to_gray_status;
377*a67afe4dSAndroid Build Coastguard Worker    /* Added in libpng 1.5.5 to record setting of coefficients: */
378*a67afe4dSAndroid Build Coastguard Worker    png_byte rgb_to_gray_coefficients_set;
379*a67afe4dSAndroid Build Coastguard Worker    /* These were changed from png_byte in libpng-1.0.6 */
380*a67afe4dSAndroid Build Coastguard Worker    png_uint_16 rgb_to_gray_red_coeff;
381*a67afe4dSAndroid Build Coastguard Worker    png_uint_16 rgb_to_gray_green_coeff;
382*a67afe4dSAndroid Build Coastguard Worker    /* deleted in 1.5.5: rgb_to_gray_blue_coeff; */
383*a67afe4dSAndroid Build Coastguard Worker #endif
384*a67afe4dSAndroid Build Coastguard Worker 
385*a67afe4dSAndroid Build Coastguard Worker /* New member added in libpng-1.6.36 */
386*a67afe4dSAndroid Build Coastguard Worker #if defined(PNG_READ_EXPAND_SUPPORTED) && \
387*a67afe4dSAndroid Build Coastguard Worker     defined(PNG_ARM_NEON_IMPLEMENTATION)
388*a67afe4dSAndroid Build Coastguard Worker    png_bytep riffled_palette; /* buffer for accelerated palette expansion */
389*a67afe4dSAndroid Build Coastguard Worker #endif
390*a67afe4dSAndroid Build Coastguard Worker 
391*a67afe4dSAndroid Build Coastguard Worker /* New member added in libpng-1.0.4 (renamed in 1.0.9) */
392*a67afe4dSAndroid Build Coastguard Worker #if defined(PNG_MNG_FEATURES_SUPPORTED)
393*a67afe4dSAndroid Build Coastguard Worker /* Changed from png_byte to png_uint_32 at version 1.2.0 */
394*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 mng_features_permitted;
395*a67afe4dSAndroid Build Coastguard Worker #endif
396*a67afe4dSAndroid Build Coastguard Worker 
397*a67afe4dSAndroid Build Coastguard Worker /* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */
398*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_MNG_FEATURES_SUPPORTED
399*a67afe4dSAndroid Build Coastguard Worker    png_byte filter_type;
400*a67afe4dSAndroid Build Coastguard Worker #endif
401*a67afe4dSAndroid Build Coastguard Worker 
402*a67afe4dSAndroid Build Coastguard Worker /* New members added in libpng-1.2.0 */
403*a67afe4dSAndroid Build Coastguard Worker 
404*a67afe4dSAndroid Build Coastguard Worker /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
405*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_USER_MEM_SUPPORTED
406*a67afe4dSAndroid Build Coastguard Worker    png_voidp mem_ptr;             /* user supplied struct for mem functions */
407*a67afe4dSAndroid Build Coastguard Worker    png_malloc_ptr malloc_fn;      /* function for allocating memory */
408*a67afe4dSAndroid Build Coastguard Worker    png_free_ptr free_fn;          /* function for freeing memory */
409*a67afe4dSAndroid Build Coastguard Worker #endif
410*a67afe4dSAndroid Build Coastguard Worker 
411*a67afe4dSAndroid Build Coastguard Worker /* New member added in libpng-1.0.13 and 1.2.0 */
412*a67afe4dSAndroid Build Coastguard Worker    png_bytep big_row_buf;         /* buffer to save current (unfiltered) row */
413*a67afe4dSAndroid Build Coastguard Worker 
414*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_READ_QUANTIZE_SUPPORTED
415*a67afe4dSAndroid Build Coastguard Worker /* The following three members were added at version 1.0.14 and 1.2.4 */
416*a67afe4dSAndroid Build Coastguard Worker    png_bytep quantize_sort;          /* working sort array */
417*a67afe4dSAndroid Build Coastguard Worker    png_bytep index_to_palette;       /* where the original index currently is
418*a67afe4dSAndroid Build Coastguard Worker                                         in the palette */
419*a67afe4dSAndroid Build Coastguard Worker    png_bytep palette_to_index;       /* which original index points to this
420*a67afe4dSAndroid Build Coastguard Worker                                          palette color */
421*a67afe4dSAndroid Build Coastguard Worker #endif
422*a67afe4dSAndroid Build Coastguard Worker 
423*a67afe4dSAndroid Build Coastguard Worker /* New members added in libpng-1.0.16 and 1.2.6 */
424*a67afe4dSAndroid Build Coastguard Worker    png_byte compression_type;
425*a67afe4dSAndroid Build Coastguard Worker 
426*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_USER_LIMITS_SUPPORTED
427*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 user_width_max;
428*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 user_height_max;
429*a67afe4dSAndroid Build Coastguard Worker 
430*a67afe4dSAndroid Build Coastguard Worker    /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown
431*a67afe4dSAndroid Build Coastguard Worker     * chunks that can be stored (0 means unlimited).
432*a67afe4dSAndroid Build Coastguard Worker     */
433*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 user_chunk_cache_max;
434*a67afe4dSAndroid Build Coastguard Worker 
435*a67afe4dSAndroid Build Coastguard Worker    /* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk
436*a67afe4dSAndroid Build Coastguard Worker     * can occupy when decompressed.  0 means unlimited.
437*a67afe4dSAndroid Build Coastguard Worker     */
438*a67afe4dSAndroid Build Coastguard Worker    png_alloc_size_t user_chunk_malloc_max;
439*a67afe4dSAndroid Build Coastguard Worker #endif
440*a67afe4dSAndroid Build Coastguard Worker 
441*a67afe4dSAndroid Build Coastguard Worker /* New member added in libpng-1.0.25 and 1.2.17 */
442*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
443*a67afe4dSAndroid Build Coastguard Worker    /* Temporary storage for unknown chunk that the library doesn't recognize,
444*a67afe4dSAndroid Build Coastguard Worker     * used while reading the chunk.
445*a67afe4dSAndroid Build Coastguard Worker     */
446*a67afe4dSAndroid Build Coastguard Worker    png_unknown_chunk unknown_chunk;
447*a67afe4dSAndroid Build Coastguard Worker #endif
448*a67afe4dSAndroid Build Coastguard Worker 
449*a67afe4dSAndroid Build Coastguard Worker /* New member added in libpng-1.2.26 */
450*a67afe4dSAndroid Build Coastguard Worker    size_t old_big_row_buf_size;
451*a67afe4dSAndroid Build Coastguard Worker 
452*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_READ_SUPPORTED
453*a67afe4dSAndroid Build Coastguard Worker /* New member added in libpng-1.2.30 */
454*a67afe4dSAndroid Build Coastguard Worker   png_bytep        read_buffer;      /* buffer for reading chunk data */
455*a67afe4dSAndroid Build Coastguard Worker   png_alloc_size_t read_buffer_size; /* current size of the buffer */
456*a67afe4dSAndroid Build Coastguard Worker #endif
457*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_SEQUENTIAL_READ_SUPPORTED
458*a67afe4dSAndroid Build Coastguard Worker   uInt             IDAT_read_size;   /* limit on read buffer size for IDAT */
459*a67afe4dSAndroid Build Coastguard Worker #endif
460*a67afe4dSAndroid Build Coastguard Worker 
461*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_IO_STATE_SUPPORTED
462*a67afe4dSAndroid Build Coastguard Worker /* New member added in libpng-1.4.0 */
463*a67afe4dSAndroid Build Coastguard Worker    png_uint_32 io_state;
464*a67afe4dSAndroid Build Coastguard Worker #endif
465*a67afe4dSAndroid Build Coastguard Worker 
466*a67afe4dSAndroid Build Coastguard Worker /* New member added in libpng-1.5.6 */
467*a67afe4dSAndroid Build Coastguard Worker    png_bytep big_prev_row;
468*a67afe4dSAndroid Build Coastguard Worker 
469*a67afe4dSAndroid Build Coastguard Worker /* New member added in libpng-1.5.7 */
470*a67afe4dSAndroid Build Coastguard Worker    void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
471*a67afe4dSAndroid Build Coastguard Worker       png_bytep row, png_const_bytep prev_row);
472*a67afe4dSAndroid Build Coastguard Worker 
473*a67afe4dSAndroid Build Coastguard Worker #ifdef PNG_READ_SUPPORTED
474*a67afe4dSAndroid Build Coastguard Worker #if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
475*a67afe4dSAndroid Build Coastguard Worker    png_colorspace   colorspace;
476*a67afe4dSAndroid Build Coastguard Worker #endif
477*a67afe4dSAndroid Build Coastguard Worker #endif
478*a67afe4dSAndroid Build Coastguard Worker };
479*a67afe4dSAndroid Build Coastguard Worker #endif /* PNGSTRUCT_H */
480