Subversion Repositories Kolibri OS

Rev

Rev 6881 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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