Path: blob/master/src/java.desktop/share/native/libsplashscreen/libpng/pngstruct.h
41154 views
/*1* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation. Oracle designates this6* particular file as subject to the "Classpath" exception as provided7* by Oracle in the LICENSE file that accompanied this code.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*/2324/* pngstruct.h - header file for PNG reference library25*26* This file is available under and governed by the GNU General Public27* License version 2 only, as published by the Free Software Foundation.28* However, the following notice accompanied the original version of this29* file and, per its terms, should not be removed:30*31* Copyright (c) 2018-2019 Cosmin Truta32* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson33* Copyright (c) 1996-1997 Andreas Dilger34* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.35*36* This code is released under the libpng license.37* For conditions of distribution and use, see the disclaimer38* and license in png.h39*/4041/* The structure that holds the information to read and write PNG files.42* The only people who need to care about what is inside of this are the43* people who will be modifying the library for their own special needs.44* It should NOT be accessed directly by an application.45*/4647#ifndef PNGSTRUCT_H48#define PNGSTRUCT_H49/* zlib.h defines the structure z_stream, an instance of which is included50* in this structure and is required for decompressing the LZ compressed51* data in PNG files.52*/53#ifndef ZLIB_CONST54/* We must ensure that zlib uses 'const' in declarations. */55# define ZLIB_CONST56#endif57#include "zlib.h"58#ifdef const59/* zlib.h sometimes #defines const to nothing, undo this. */60# undef const61#endif6263/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility64* with older builds.65*/66#if ZLIB_VERNUM < 0x126067# define PNGZ_MSG_CAST(s) png_constcast(char*,s)68# define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b)69#else70# define PNGZ_MSG_CAST(s) (s)71# define PNGZ_INPUT_CAST(b) (b)72#endif7374/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib75* can handle at once. This type need be no larger than 16 bits (so maximum of76* 65535), this define allows us to discover how big it is, but limited by the77* maximum for size_t. The value can be overridden in a library build78* (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably79* lower value (e.g. 255 works). A lower value may help memory usage (slightly)80* and may even improve performance on some systems (and degrade it on others.)81*/82#ifndef ZLIB_IO_MAX83# define ZLIB_IO_MAX ((uInt)-1)84#endif8586#ifdef PNG_WRITE_SUPPORTED87/* The type of a compression buffer list used by the write code. */88typedef struct png_compression_buffer89{90struct png_compression_buffer *next;91png_byte output[1]; /* actually zbuf_size */92} png_compression_buffer, *png_compression_bufferp;9394#define PNG_COMPRESSION_BUFFER_SIZE(pp)\95(offsetof(png_compression_buffer, output) + (pp)->zbuffer_size)96#endif9798/* Colorspace support; structures used in png_struct, png_info and in internal99* functions to hold and communicate information about the color space.100*101* PNG_COLORSPACE_SUPPORTED is only required if the application will perform102* colorspace corrections, otherwise all the colorspace information can be103* skipped and the size of libpng can be reduced (significantly) by compiling104* out the colorspace support.105*/106#ifdef PNG_COLORSPACE_SUPPORTED107/* The chromaticities of the red, green and blue colorants and the chromaticity108* of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)).109*/110typedef struct png_xy111{112png_fixed_point redx, redy;113png_fixed_point greenx, greeny;114png_fixed_point bluex, bluey;115png_fixed_point whitex, whitey;116} png_xy;117118/* The same data as above but encoded as CIE XYZ values. When this data comes119* from chromaticities the sum of the Y values is assumed to be 1.0120*/121typedef struct png_XYZ122{123png_fixed_point red_X, red_Y, red_Z;124png_fixed_point green_X, green_Y, green_Z;125png_fixed_point blue_X, blue_Y, blue_Z;126} png_XYZ;127#endif /* COLORSPACE */128129#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)130/* A colorspace is all the above plus, potentially, profile information;131* however at present libpng does not use the profile internally so it is only132* stored in the png_info struct (if iCCP is supported.) The rendering intent133* is retained here and is checked.134*135* The file gamma encoding information is also stored here and gamma correction136* is done by libpng, whereas color correction must currently be done by the137* application.138*/139typedef struct png_colorspace140{141#ifdef PNG_GAMMA_SUPPORTED142png_fixed_point gamma; /* File gamma */143#endif144145#ifdef PNG_COLORSPACE_SUPPORTED146png_xy end_points_xy; /* End points as chromaticities */147png_XYZ end_points_XYZ; /* End points as CIE XYZ colorant values */148png_uint_16 rendering_intent; /* Rendering intent of a profile */149#endif150151/* Flags are always defined to simplify the code. */152png_uint_16 flags; /* As defined below */153} png_colorspace, * PNG_RESTRICT png_colorspacerp;154155typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;156157/* General flags for the 'flags' field */158#define PNG_COLORSPACE_HAVE_GAMMA 0x0001159#define PNG_COLORSPACE_HAVE_ENDPOINTS 0x0002160#define PNG_COLORSPACE_HAVE_INTENT 0x0004161#define PNG_COLORSPACE_FROM_gAMA 0x0008162#define PNG_COLORSPACE_FROM_cHRM 0x0010163#define PNG_COLORSPACE_FROM_sRGB 0x0020164#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040165#define PNG_COLORSPACE_MATCHES_sRGB 0x0080 /* exact match on profile */166#define PNG_COLORSPACE_INVALID 0x8000167#define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags))168#endif /* COLORSPACE || GAMMA */169170struct png_struct_def171{172#ifdef PNG_SETJMP_SUPPORTED173jmp_buf jmp_buf_local; /* New name in 1.6.0 for jmp_buf in png_struct */174png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */175jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */176size_t jmp_buf_size; /* size of the above, if allocated */177#endif178png_error_ptr error_fn; /* function for printing errors and aborting */179#ifdef PNG_WARNINGS_SUPPORTED180png_error_ptr warning_fn; /* function for printing warnings */181#endif182png_voidp error_ptr; /* user supplied struct for error functions */183png_rw_ptr write_data_fn; /* function for writing output data */184png_rw_ptr read_data_fn; /* function for reading input data */185png_voidp io_ptr; /* ptr to application struct for I/O functions */186187#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED188png_user_transform_ptr read_user_transform_fn; /* user read transform */189#endif190191#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED192png_user_transform_ptr write_user_transform_fn; /* user write transform */193#endif194195/* These were added in libpng-1.0.2 */196#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED197#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \198defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)199png_voidp user_transform_ptr; /* user supplied struct for user transform */200png_byte user_transform_depth; /* bit depth of user transformed pixels */201png_byte user_transform_channels; /* channels in user transformed pixels */202#endif203#endif204205png_uint_32 mode; /* tells us where we are in the PNG file */206png_uint_32 flags; /* flags indicating various things to libpng */207png_uint_32 transformations; /* which transformations to perform */208209png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */210z_stream zstream; /* decompression structure */211212#ifdef PNG_WRITE_SUPPORTED213png_compression_bufferp zbuffer_list; /* Created on demand during write */214uInt zbuffer_size; /* size of the actual buffer */215216int zlib_level; /* holds zlib compression level */217int zlib_method; /* holds zlib compression method */218int zlib_window_bits; /* holds zlib compression window bits */219int zlib_mem_level; /* holds zlib compression memory level */220int zlib_strategy; /* holds zlib compression strategy */221#endif222/* Added at libpng 1.5.4 */223#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED224int zlib_text_level; /* holds zlib compression level */225int zlib_text_method; /* holds zlib compression method */226int zlib_text_window_bits; /* holds zlib compression window bits */227int zlib_text_mem_level; /* holds zlib compression memory level */228int zlib_text_strategy; /* holds zlib compression strategy */229#endif230/* End of material added at libpng 1.5.4 */231/* Added at libpng 1.6.0 */232#ifdef PNG_WRITE_SUPPORTED233int zlib_set_level; /* Actual values set into the zstream on write */234int zlib_set_method;235int zlib_set_window_bits;236int zlib_set_mem_level;237int zlib_set_strategy;238#endif239240png_uint_32 width; /* width of image in pixels */241png_uint_32 height; /* height of image in pixels */242png_uint_32 num_rows; /* number of rows in current pass */243png_uint_32 usr_width; /* width of row at start of write */244size_t rowbytes; /* size of row in bytes */245png_uint_32 iwidth; /* width of current interlaced row in pixels */246png_uint_32 row_number; /* current row in interlace pass */247png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */248png_bytep prev_row; /* buffer to save previous (unfiltered) row.249* While reading this is a pointer into250* big_prev_row; while writing it is separately251* allocated if needed.252*/253png_bytep row_buf; /* buffer to save current (unfiltered) row.254* While reading, this is a pointer into255* big_row_buf; while writing it is separately256* allocated.257*/258#ifdef PNG_WRITE_FILTER_SUPPORTED259png_bytep try_row; /* buffer to save trial row when filtering */260png_bytep tst_row; /* buffer to save best trial row when filtering */261#endif262size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */263264png_uint_32 idat_size; /* current IDAT size for read */265png_uint_32 crc; /* current chunk CRC value */266png_colorp palette; /* palette from the input file */267png_uint_16 num_palette; /* number of color entries in palette */268269/* Added at libpng-1.5.10 */270#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED271int num_palette_max; /* maximum palette index found in IDAT */272#endif273274png_uint_16 num_trans; /* number of transparency values */275png_byte compression; /* file compression type (always 0) */276png_byte filter; /* file filter type (always 0) */277png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */278png_byte pass; /* current interlace pass (0 - 6) */279png_byte do_filter; /* row filter flags (see PNG_FILTER_ in png.h ) */280png_byte color_type; /* color type of file */281png_byte bit_depth; /* bit depth of file */282png_byte usr_bit_depth; /* bit depth of users row: write only */283png_byte pixel_depth; /* number of bits per pixel */284png_byte channels; /* number of channels in file */285#ifdef PNG_WRITE_SUPPORTED286png_byte usr_channels; /* channels at start of write: write only */287#endif288png_byte sig_bytes; /* magic bytes read/written from start of file */289png_byte maximum_pixel_depth;290/* pixel depth used for the row buffers */291png_byte transformed_pixel_depth;292/* pixel depth after read/write transforms */293#if ZLIB_VERNUM >= 0x1240294png_byte zstream_start; /* at start of an input zlib stream */295#endif /* Zlib >= 1.2.4 */296#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)297png_uint_16 filler; /* filler bytes for pixel expansion */298#endif299300#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\301defined(PNG_READ_ALPHA_MODE_SUPPORTED)302png_byte background_gamma_type;303png_fixed_point background_gamma;304png_color_16 background; /* background color in screen gamma space */305#ifdef PNG_READ_GAMMA_SUPPORTED306png_color_16 background_1; /* background normalized to gamma 1.0 */307#endif308#endif /* bKGD */309310#ifdef PNG_WRITE_FLUSH_SUPPORTED311png_flush_ptr output_flush_fn; /* Function for flushing output */312png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */313png_uint_32 flush_rows; /* number of rows written since last flush */314#endif315316#ifdef PNG_READ_GAMMA_SUPPORTED317int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */318png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */319320png_bytep gamma_table; /* gamma table for 8-bit depth files */321png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */322#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \323defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \324defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)325png_bytep gamma_from_1; /* converts from 1.0 to screen */326png_bytep gamma_to_1; /* converts from file to 1.0 */327png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */328png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */329#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */330#endif331332#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)333png_color_8 sig_bit; /* significant bits in each available channel */334#endif335336#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)337png_color_8 shift; /* shift for significant bit transformation */338#endif339340#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \341|| defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)342png_bytep trans_alpha; /* alpha values for paletted files */343png_color_16 trans_color; /* transparent color for non-paletted files */344#endif345346png_read_status_ptr read_row_fn; /* called after each row is decoded */347png_write_status_ptr write_row_fn; /* called after each row is encoded */348#ifdef PNG_PROGRESSIVE_READ_SUPPORTED349png_progressive_info_ptr info_fn; /* called after header data fully read */350png_progressive_row_ptr row_fn; /* called after a prog. row is decoded */351png_progressive_end_ptr end_fn; /* called after image is complete */352png_bytep save_buffer_ptr; /* current location in save_buffer */353png_bytep save_buffer; /* buffer for previously read data */354png_bytep current_buffer_ptr; /* current location in current_buffer */355png_bytep current_buffer; /* buffer for recently used data */356png_uint_32 push_length; /* size of current input chunk */357png_uint_32 skip_length; /* bytes to skip in input data */358size_t save_buffer_size; /* amount of data now in save_buffer */359size_t save_buffer_max; /* total size of save_buffer */360size_t buffer_size; /* total amount of available input data */361size_t current_buffer_size; /* amount of data now in current_buffer */362int process_mode; /* what push library is currently doing */363int cur_palette; /* current push library palette index */364365#endif /* PROGRESSIVE_READ */366367#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)368/* For the Borland special 64K segment handler */369png_bytepp offset_table_ptr;370png_bytep offset_table;371png_uint_16 offset_table_number;372png_uint_16 offset_table_count;373png_uint_16 offset_table_count_free;374#endif375376#ifdef PNG_READ_QUANTIZE_SUPPORTED377png_bytep palette_lookup; /* lookup table for quantizing */378png_bytep quantize_index; /* index translation for palette files */379#endif380381/* Options */382#ifdef PNG_SET_OPTION_SUPPORTED383png_uint_32 options; /* On/off state (up to 16 options) */384#endif385386#if PNG_LIBPNG_VER < 10700387/* To do: remove this from libpng-1.7 */388#ifdef PNG_TIME_RFC1123_SUPPORTED389char time_buffer[29]; /* String to hold RFC 1123 time text */390#endif391#endif392393/* New members added in libpng-1.0.6 */394395png_uint_32 free_me; /* flags items libpng is responsible for freeing */396397#ifdef PNG_USER_CHUNKS_SUPPORTED398png_voidp user_chunk_ptr;399#ifdef PNG_READ_USER_CHUNKS_SUPPORTED400png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */401#endif402#endif403404#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED405int unknown_default; /* As PNG_HANDLE_* */406unsigned int num_chunk_list; /* Number of entries in the list */407png_bytep chunk_list; /* List of png_byte[5]; the textual chunk name408* followed by a PNG_HANDLE_* byte */409#endif410411/* New members added in libpng-1.0.3 */412#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED413png_byte rgb_to_gray_status;414/* Added in libpng 1.5.5 to record setting of coefficients: */415png_byte rgb_to_gray_coefficients_set;416/* These were changed from png_byte in libpng-1.0.6 */417png_uint_16 rgb_to_gray_red_coeff;418png_uint_16 rgb_to_gray_green_coeff;419/* deleted in 1.5.5: rgb_to_gray_blue_coeff; */420#endif421422/* New member added in libpng-1.6.36 */423#if defined(PNG_READ_EXPAND_SUPPORTED) && \424defined(PNG_ARM_NEON_IMPLEMENTATION)425png_bytep riffled_palette; /* buffer for accelerated palette expansion */426#endif427428/* New member added in libpng-1.0.4 (renamed in 1.0.9) */429#if defined(PNG_MNG_FEATURES_SUPPORTED)430/* Changed from png_byte to png_uint_32 at version 1.2.0 */431png_uint_32 mng_features_permitted;432#endif433434/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */435#ifdef PNG_MNG_FEATURES_SUPPORTED436png_byte filter_type;437#endif438439/* New members added in libpng-1.2.0 */440441/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */442#ifdef PNG_USER_MEM_SUPPORTED443png_voidp mem_ptr; /* user supplied struct for mem functions */444png_malloc_ptr malloc_fn; /* function for allocating memory */445png_free_ptr free_fn; /* function for freeing memory */446#endif447448/* New member added in libpng-1.0.13 and 1.2.0 */449png_bytep big_row_buf; /* buffer to save current (unfiltered) row */450451#ifdef PNG_READ_QUANTIZE_SUPPORTED452/* The following three members were added at version 1.0.14 and 1.2.4 */453png_bytep quantize_sort; /* working sort array */454png_bytep index_to_palette; /* where the original index currently is455in the palette */456png_bytep palette_to_index; /* which original index points to this457palette color */458#endif459460/* New members added in libpng-1.0.16 and 1.2.6 */461png_byte compression_type;462463#ifdef PNG_USER_LIMITS_SUPPORTED464png_uint_32 user_width_max;465png_uint_32 user_height_max;466467/* Added in libpng-1.4.0: Total number of sPLT, text, and unknown468* chunks that can be stored (0 means unlimited).469*/470png_uint_32 user_chunk_cache_max;471472/* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk473* can occupy when decompressed. 0 means unlimited.474*/475png_alloc_size_t user_chunk_malloc_max;476#endif477478/* New member added in libpng-1.0.25 and 1.2.17 */479#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED480/* Temporary storage for unknown chunk that the library doesn't recognize,481* used while reading the chunk.482*/483png_unknown_chunk unknown_chunk;484#endif485486/* New member added in libpng-1.2.26 */487size_t old_big_row_buf_size;488489#ifdef PNG_READ_SUPPORTED490/* New member added in libpng-1.2.30 */491png_bytep read_buffer; /* buffer for reading chunk data */492png_alloc_size_t read_buffer_size; /* current size of the buffer */493#endif494#ifdef PNG_SEQUENTIAL_READ_SUPPORTED495uInt IDAT_read_size; /* limit on read buffer size for IDAT */496#endif497498#ifdef PNG_IO_STATE_SUPPORTED499/* New member added in libpng-1.4.0 */500png_uint_32 io_state;501#endif502503/* New member added in libpng-1.5.6 */504png_bytep big_prev_row;505506/* New member added in libpng-1.5.7 */507void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,508png_bytep row, png_const_bytep prev_row);509510#ifdef PNG_READ_SUPPORTED511#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)512png_colorspace colorspace;513#endif514#endif515};516#endif /* PNGSTRUCT_H */517518519