Subversion Repositories Kolibri OS

Rev

Rev 6733 | 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 rb 64 ;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.         rb 2 ;align
  158. end if
  159. end if
  160.  
  161.         mode  dd ? ;uint_32 ;tells us where we are in the PNG file
  162.         flags dd ? ;uint_32 ;flags indicating various things to libpng
  163.         transformations dd ? ;uint_32 ;which transformations to perform
  164.  
  165.         zowner dd ? ;uint_32 ;ID (chunk type) of zstream owner, 0 if none
  166.         zstream z_stream ;decompression structure
  167.  
  168.         zbuffer_list dd ? ;png_compression_bufferp ;Created on demand during write
  169.         zbuffer_size dd ? ;uInt ;size of the actual buffer
  170.  
  171.         zlib_level  dd ? ;int ;holds zlib compression level
  172.         zlib_method dd ? ;int ;holds zlib compression method
  173.         zlib_window_bits dd ? ;int ;holds zlib compression window bits
  174.         zlib_mem_level dd ? ;int ;holds zlib compression memory level
  175.         zlib_strategy  dd ? ;int ;holds zlib compression strategy
  176. ; Added at libpng 1.5.4
  177. if PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED eq 1
  178.         zlib_text_level  dd ? ;int ;holds zlib compression level
  179.         zlib_text_method dd ? ;int ;holds zlib compression method
  180.         zlib_text_window_bits dd ? ;int ;holds zlib compression window bits
  181.         zlib_text_mem_level dd ? ;int ;holds zlib compression memory level
  182.         zlib_text_strategy  dd ? ;int ;holds zlib compression strategy
  183. end if
  184. ;End of material added at libpng 1.5.4
  185. ;Added at libpng 1.6.0
  186.         zlib_set_level  dd ? ;int ;Actual values set into the zstream on write
  187.         zlib_set_method dd ? ;int
  188.         zlib_set_window_bits dd ? ;int
  189.         zlib_set_mem_level dd ? ;int
  190.         zlib_set_strategy  dd ? ;int
  191.  
  192.         width    dd ? ;uint_32 ;width of image in pixels
  193.         height   dd ? ;uint_32 ;height of image in pixels
  194.         num_rows dd ? ;uint_32 ;number of rows in current pass
  195.         usr_width dd ? ;uint_32 ;width of row at start of write
  196.         rowbytes  dd ? ;png_size_t ;size of row in bytes
  197.         iwidth     dd ? ;uint_32 ;width of current interlaced row in pixels
  198.         row_number dd ? ;uint_32 ;current row in interlace pass
  199.         chunk_name dd ? ;uint_32 ;PNG_CHUNK() id of current chunk
  200.         prev_row dd ? ;bytep ;buffer to save previous (unfiltered) row.
  201.                         ;While reading this is a pointer into
  202.                         ;big_prev_row; while writing it is separately
  203.                         ;allocated if needed.
  204.  
  205.         row_buf dd ? ;bytep ;buffer to save current (unfiltered) row.
  206.                         ;While reading, this is a pointer into
  207.                         ;big_row_buf; while writing it is separately
  208.                         ;allocated.
  209.  
  210. if PNG_WRITE_FILTER_SUPPORTED eq 1
  211.         try_row dd ? ;bytep ;buffer to save trial row when filtering
  212.         tst_row dd ? ;bytep ;buffer to save best trial row when filtering
  213. end if
  214.         info_rowbytes dd ? ;png_size_t ;Added in 1.5.4: cache of updated row bytes
  215.  
  216.         idat_size dd ? ;uint_32 ;current IDAT size for read
  217.         crc dd ? ;uint_32 ;current chunk CRC value
  218.         palette dd ? ;png_colorp ;palette from the input file
  219.         num_palette dw ? ;uint_16 ;number of color entries in palette
  220.         rb 2 ;align
  221. ; Added at libpng-1.5.10
  222. if PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED eq 1
  223.         num_palette_max dd ? ;int ;maximum palette index found in IDAT
  224. end if
  225.  
  226.         num_trans   dw ? ;uint_16 ;number of transparency values
  227.         compression db ? ;byte ;file compression type (always 0)
  228.         filter      db ? ;byte ;file filter type (always 0)
  229.         interlaced  db ? ;byte ;PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7
  230.         pass        db ? ;byte ;current interlace pass (0 - 6)
  231.         do_filter   db ? ;byte ;row filter flags (see PNG_FILTER_ in png.inc)
  232.         color_type   db ? ;byte ;color type of file
  233.         bit_depth    db ? ;byte ;bit depth of file
  234.         usr_bit_depth db ? ;byte ;bit depth of users row: write only
  235.         pixel_depth  db ? ;byte ;number of bits per pixel
  236.         channels     db ? ;byte ;number of channels in file
  237.         usr_channels db ? ;byte ;channels at start of write: write only
  238.         sig_bytes    db ? ;byte ;magic bytes read/written from start of file
  239.         maximum_pixel_depth db ? ;byte ;pixel depth used for the row buffers
  240.         transformed_pixel_depth db ? ;byte ;pixel depth after read/write transforms
  241. ;if PNG_ZLIB_VERNUM >= 0x1240
  242.         ;zstream_start db 1 ;byte ;at start of an input zlib stream
  243. ;end if ;Zlib >= 1.2.4
  244. if (PNG_READ_FILLER_SUPPORTED eq 1) | (PNG_WRITE_FILLER_SUPPORTED eq 1)
  245.         filler dw ? ;uint_16 ;filler bytes for pixel expansion
  246. end if
  247.  
  248. if (PNG_bKGD_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1) | \
  249.         (PNG_READ_ALPHA_MODE_SUPPORTED eq 1)
  250.         background_gamma_type db ? ;byte
  251.         rb 1 ;align
  252.         background_gamma dd ? ;png_fixed_point
  253.         background png_color_16 ;background color in screen gamma space
  254.         rb 1 ;align
  255. if PNG_READ_GAMMA_SUPPORTED eq 1
  256.         background_1 png_color_16 ;background normalized to gamma 1.0
  257.         rb 1 ;align
  258. end if
  259. end if ;bKGD
  260.  
  261. if PNG_WRITE_FLUSH_SUPPORTED eq 1
  262.         output_flush_fn dd ? ;png_flush_ptr ;Function for flushing output
  263.         flush_dist dd ? ;uint_32 ;how many rows apart to flush, 0 - no flush
  264.         flush_rows dd ? ;uint_32 ;number of rows written since last flush
  265. end if
  266.  
  267. if PNG_READ_GAMMA_SUPPORTED eq 1
  268.         gamma_shift  dd ? ;int ;number of "insignificant" bits in 16-bit gamma
  269.         screen_gamma dd ? ;png_fixed_point ;screen gamma value (display_exponent)
  270.  
  271.         gamma_table  dd ? ;bytep ;gamma table for 8-bit depth files
  272.         gamma_16_table dd ? ;uint_16pp ;gamma table for 16-bit depth files
  273. if (PNG_READ_BACKGROUND_SUPPORTED eq 1) | \
  274.         (PNG_READ_ALPHA_MODE_SUPPORTED eq 1) | \
  275.         (PNG_READ_RGB_TO_GRAY_SUPPORTED eq 1)
  276.         gamma_from_1  dd ? ;bytep ;converts from 1.0 to screen
  277.         gamma_to_1    dd ? ;bytep ;converts from file to 1.0
  278.         gamma_16_from_1 dd ? ;uint_16pp ;converts from 1.0 to screen
  279.         gamma_16_to_1   dd ? ;uint_16pp ;converts from file to 1.0
  280. end if ;READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY
  281. end if
  282.  
  283. if (PNG_READ_GAMMA_SUPPORTED eq 1) | (PNG_sBIT_SUPPORTED eq 1)
  284.         sig_bit png_color_8 ;significant bits in each available channel
  285. end if
  286.  
  287. if (PNG_READ_SHIFT_SUPPORTED eq 1) | (PNG_WRITE_SHIFT_SUPPORTED eq 1)
  288.         shift   png_color_8 ;shift for significant bit tranformation
  289.         rb 2 ;align
  290. end if
  291.  
  292. if (PNG_tRNS_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1) \
  293.         | (PNG_READ_EXPAND_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1)
  294.         trans_alpha dd ? ;bytep ;alpha values for paletted files
  295.         trans_color png_color_16 ;transparent color for non-paletted files
  296.         rb 3 ;align
  297. end if
  298.  
  299.         read_row_fn  dd ? ;png_read_status_ptr ;called after each row is decoded
  300.         write_row_fn dd ? ;png_write_status_ptr ;called after each row is encoded
  301. if PNG_PROGRESSIVE_READ_SUPPORTED eq 1
  302.         info_fn      dd ? ;png_progressive_info_ptr ;called after header data fully read
  303.         row_fn        dd ? ;png_progressive_row_ptr ;called after a prog. row is decoded
  304.         end_fn         dd ? ;png_progressive_end_ptr ;called after image is complete
  305.         save_buffer_ptr dd ? ;bytep ;current location in save_buffer
  306.         save_buffer      dd ? ;bytep ;buffer for previously read data
  307.         current_buffer_ptr dd ? ;bytep ;current location in current_buffer
  308.         current_buffer   dd ? ;bytep ;buffer for recently used data
  309.         push_length      dd ? ;uint_32 ;size of current input chunk
  310.         skip_length      dd ? ;uint_32 ;bytes to skip in input data
  311.         save_buffer_size dd ? ;png_size_t ;amount of data now in save_buffer
  312.         save_buffer_max  dd ? ;png_size_t ;total size of save_buffer
  313.         buffer_size      dd ? ;png_size_t ;total amount of available input data
  314.         current_buffer_size dd ? ;png_size_t ;amount of data now in current_buffer
  315.         process_mode     dd ? ;int ;what push library is currently doing
  316.         cur_palette      dd ? ;int ;current push library palette index
  317.  
  318. end if ;PROGRESSIVE_READ
  319.  
  320. if PNG_READ_QUANTIZE_SUPPORTED eq 1
  321.         palette_lookup dd ? ;bytep ;lookup table for quantizing
  322.         quantize_index dd ? ;bytep ;index translation for palette files
  323. end if
  324.  
  325. ; Options
  326. if PNG_SET_OPTION_SUPPORTED eq 1
  327.         options db ? ;byte ;On/off state (up to 4 options)
  328. end if
  329.  
  330. ;#if PNG_LIBPNG_VER < 10700
  331. ; To do: remove this from libpng-1.7
  332. if PNG_TIME_RFC1123_SUPPORTED eq 1
  333.         time_buffer rb 29 ;char[29] ;String to hold RFC 1123 time text
  334.         rb 2 ;align
  335. end if
  336. ;end if
  337.  
  338. ; New members added in libpng-1.0.6
  339.  
  340.         free_me dd ? ;uint_32 ;flags items libpng is responsible for freeing
  341.  
  342. if PNG_USER_CHUNKS_SUPPORTED eq 1
  343.         user_chunk_ptr dd ? ;voidp
  344. if PNG_READ_USER_CHUNKS_SUPPORTED eq 1
  345.         read_user_chunk_fn dd ? ;png_user_chunk_ptr ;user read chunk handler
  346. end if
  347. end if
  348.  
  349. if PNG_SET_UNKNOWN_CHUNKS_SUPPORTED eq 1
  350.         unknown_default dd ? ;int          ; As PNG_HANDLE_*
  351.         num_chunk_list  dd ? ;unsigned int ; Number of entries in the list
  352.         chunk_list      dd ? ;bytep        ; List of byte[5]; the textual chunk name
  353.                         ; followed by a PNG_HANDLE_* byte
  354. end if
  355.  
  356. ; New members added in libpng-1.0.3
  357. if PNG_READ_RGB_TO_GRAY_SUPPORTED eq 1
  358.         rgb_to_gray_status db ? ;byte
  359.         ; Added in libpng 1.5.5 to record setting of coefficients:
  360.         rgb_to_gray_coefficients_set db ? ;byte
  361.         ; These were changed from byte in libpng-1.0.6
  362.         rgb_to_gray_red_coeff   dw ? ;uint_16
  363.         rgb_to_gray_green_coeff dw ? ;uint_16
  364.         ; deleted in 1.5.5: rgb_to_gray_blue_coeff;
  365.         rb 2 ;align
  366. end if
  367.  
  368. if PNG_MNG_FEATURES_SUPPORTED eq 1
  369. ; New member added in libpng-1.0.4 (renamed in 1.0.9)
  370. ; Changed from byte to uint_32 at version 1.2.0
  371.         mng_features_permitted dd ? ;uint_32
  372.  
  373. ; New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0
  374.         filter_type db ? ;byte
  375.         rb 3 ;align
  376. end if
  377.  
  378. ; New members added in libpng-1.2.0
  379.  
  380. ; New members added in libpng-1.0.2 but first enabled by default in 1.2.0
  381. if PNG_USER_MEM_SUPPORTED eq 1
  382.         mem_ptr   dd ? ;voidp      ;user supplied struct for mem functions
  383.         malloc_fn dd ? ;malloc_ptr ;function for allocating memory
  384.         free_fn   dd ? ;free_ptr   ;function for freeing memory
  385. end if
  386.  
  387. ; New member added in libpng-1.0.13 and 1.2.0
  388.         big_row_buf dd ? ;bytep ;buffer to save current (unfiltered) row
  389.  
  390. if PNG_READ_QUANTIZE_SUPPORTED eq 1
  391. ; The following three members were added at version 1.0.14 and 1.2.4
  392.         quantize_sort    dd ? ;bytep ;working sort array
  393.         index_to_palette dd ? ;bytep ;where the original index currently is in the palette
  394.         palette_to_index dd ? ;bytep ;which original index points to this palette color
  395. end if
  396.  
  397. ; New members added in libpng-1.0.16 and 1.2.6
  398.         compression_type db ? ;byte
  399.         rb 3 ;align
  400.  
  401. if PNG_USER_LIMITS_SUPPORTED eq 1
  402.         user_width_max dd ? ;uint_32
  403.         user_height_max dd ? ;uint_32
  404.  
  405.         ; Added in libpng-1.4.0: Total number of sPLT, text, and unknown
  406.         ; chunks that can be stored (0 means unlimited).
  407.  
  408.         user_chunk_cache_max dd ? ;uint_32
  409.  
  410.         ; Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk
  411.         ; can occupy when decompressed.  0 means unlimited.
  412.  
  413.         user_chunk_malloc_max dd ? ;png_alloc_size_t
  414. end if
  415.  
  416. ; New member added in libpng-1.0.25 and 1.2.17
  417. if PNG_READ_UNKNOWN_CHUNKS_SUPPORTED eq 1
  418.         ; Temporary storage for unknown chunk that the library doesn't recognize,
  419.         ; used while reading the chunk.
  420.  
  421.         unknown_chunk png_unknown_chunk
  422.         rb 3 ;align
  423. end if
  424.  
  425. ; New member added in libpng-1.2.26
  426.         old_big_row_buf_size dd ? ;png_size_t
  427.  
  428. if PNG_READ_SUPPORTED eq 1
  429. ; New member added in libpng-1.2.30
  430.         read_buffer dd ? ;bytep ;buffer for reading chunk data
  431.         read_buffer_size dd ? ;png_alloc_size_t ;current size of the buffer
  432. end if
  433. if PNG_SEQUENTIAL_READ_SUPPORTED eq 1
  434.         IDAT_read_size dd ? ;uInt ;limit on read buffer size for IDAT
  435. end if
  436.  
  437. if PNG_IO_STATE_SUPPORTED eq 1
  438. ; New member added in libpng-1.4.0
  439.         io_state dd ? ;uint_32
  440. end if
  441.  
  442.         ; New member added in libpng-1.5.6
  443.         big_prev_row dd ? ;bytep
  444.  
  445.         ; New member added in libpng-1.5.7
  446.         read_filter rd PNG_FILTER_VALUE_LAST-1
  447.  
  448. if PNG_READ_SUPPORTED eq 1
  449. if (PNG_COLORSPACE_SUPPORTED eq 1) | (PNG_GAMMA_SUPPORTED eq 1)
  450.         colorspace png_colorspace
  451. end if
  452. end if
  453. ends
  454.