Subversion Repositories Kolibri OS

Rev

Rev 6881 | Go to most recent revision | Details | Last modification | View Log | RSS feed

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