Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: third_party/libpng/png.c

Issue 140074: Updates the PNG library to 1.2.37, enables some functionality for O3D (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/libpng/png.h ('k') | third_party/libpng/pngconf.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* png.c - location for general purpose libpng functions 2 /* png.c - location for general purpose libpng functions
3 * 3 *
4 * Last changed in libpng 1.2.34 [December 18, 2008] 4 * Last changed in libpng 1.2.37 [June 4, 2009]
5 * For conditions of distribution and use, see copyright notice in png.h 5 * For conditions of distribution and use, see copyright notice in png.h
6 * Copyright (c) 1998-2008 Glenn Randers-Pehrson 6 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
9 */ 9 */
10 10
11 #define PNG_INTERNAL 11 #define PNG_INTERNAL
12 #define PNG_NO_EXTERN 12 #define PNG_NO_EXTERN
13 #include "png.h" 13 #include "png.h"
14 14
15 /* Generate a compiler error if there is an old png.h in the search path. */ 15 /* Generate a compiler error if there is an old png.h in the search path. */
16 typedef version_1_2_36 Your_png_h_is_not_version_1_2_36; 16 typedef version_1_2_37 Your_png_h_is_not_version_1_2_37;
17 17
18 /* Version information for C files. This had better match the version 18 /* Version information for C files. This had better match the version
19 * string defined in png.h. */ 19 * string defined in png.h. */
20 20
21 #ifdef PNG_USE_GLOBAL_ARRAYS 21 #ifdef PNG_USE_GLOBAL_ARRAYS
22 /* png_libpng_ver was changed to a function in version 1.0.5c */ 22 /* png_libpng_ver was changed to a function in version 1.0.5c */
23 PNG_CONST char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING; 23 PNG_CONST char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING;
24 24
25 #ifdef PNG_READ_SUPPORTED 25 #ifdef PNG_READ_SUPPORTED
26 26
(...skipping 19 matching lines...) Expand all
46 PNG_pHYs; 46 PNG_pHYs;
47 PNG_sBIT; 47 PNG_sBIT;
48 PNG_sPLT; 48 PNG_sPLT;
49 PNG_sRGB; 49 PNG_sRGB;
50 PNG_tEXt; 50 PNG_tEXt;
51 PNG_tIME; 51 PNG_tIME;
52 PNG_tRNS; 52 PNG_tRNS;
53 PNG_zTXt; 53 PNG_zTXt;
54 54
55 #ifdef PNG_READ_SUPPORTED 55 #ifdef PNG_READ_SUPPORTED
56 /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ 56 /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
57 57
58 /* start of interlace block */ 58 /* Start of interlace block */
59 PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; 59 PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
60 60
61 /* offset to next interlace block */ 61 /* Offset to next interlace block */
62 PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; 62 PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
63 63
64 /* start of interlace block in the y direction */ 64 /* Start of interlace block in the y direction */
65 PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; 65 PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
66 66
67 /* offset to next interlace block in the y direction */ 67 /* Offset to next interlace block in the y direction */
68 PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; 68 PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
69 69
70 /* Height of interlace block. This is not currently used - if you need 70 /* Height of interlace block. This is not currently used - if you need
71 * it, uncomment it here and in png.h 71 * it, uncomment it here and in png.h
72 PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; 72 PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
73 */ 73 */
74 74
75 /* Mask to determine which pixels are valid in a pass */ 75 /* Mask to determine which pixels are valid in a pass */
76 PNG_CONST int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xf f}; 76 PNG_CONST int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xf f};
77 77
78 /* Mask to determine which pixels to overwrite while displaying */ 78 /* Mask to determine which pixels to overwrite while displaying */
79 PNG_CONST int FARDATA png_pass_dsp_mask[] 79 PNG_CONST int FARDATA png_pass_dsp_mask[]
80 = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; 80 = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
81 81
82 #endif /* PNG_READ_SUPPORTED */ 82 #endif /* PNG_READ_SUPPORTED */
83 #endif /* PNG_USE_GLOBAL_ARRAYS */ 83 #endif /* PNG_USE_GLOBAL_ARRAYS */
84 84
85 /* Tells libpng that we have already handled the first "num_bytes" bytes 85 /* Tells libpng that we have already handled the first "num_bytes" bytes
86 * of the PNG file signature. If the PNG data is embedded into another 86 * of the PNG file signature. If the PNG data is embedded into another
87 * stream we can set num_bytes = 8 so that libpng will not attempt to read 87 * stream we can set num_bytes = 8 so that libpng will not attempt to read
88 * or write any of the magic bytes before it starts on the IHDR. 88 * or write any of the magic bytes before it starts on the IHDR.
89 */ 89 */
90 90
91 #ifdef PNG_READ_SUPPORTED 91 #ifdef PNG_READ_SUPPORTED
92 void PNGAPI 92 void PNGAPI
93 png_set_sig_bytes(png_structp png_ptr, int num_bytes) 93 png_set_sig_bytes(png_structp png_ptr, int num_bytes)
94 { 94 {
95 if (png_ptr == NULL) return; 95 if (png_ptr == NULL)
96 return;
96 png_debug(1, "in png_set_sig_bytes"); 97 png_debug(1, "in png_set_sig_bytes");
97 if (num_bytes > 8) 98 if (num_bytes > 8)
98 png_error(png_ptr, "Too many bytes for PNG signature."); 99 png_error(png_ptr, "Too many bytes for PNG signature.");
99 100
100 png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes); 101 png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes);
101 } 102 }
102 103
103 /* Checks whether the supplied bytes match the PNG signature. We allow 104 /* Checks whether the supplied bytes match the PNG signature. We allow
104 * checking less than the full 8-byte signature so that those apps that 105 * checking less than the full 8-byte signature so that those apps that
105 * already read the first few bytes of a file to determine the file type 106 * already read the first few bytes of a file to determine the file type
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 #else 147 #else
147 voidpf /* private */ 148 voidpf /* private */
148 #endif 149 #endif
149 png_zalloc(voidpf png_ptr, uInt items, uInt size) 150 png_zalloc(voidpf png_ptr, uInt items, uInt size)
150 { 151 {
151 png_voidp ptr; 152 png_voidp ptr;
152 png_structp p=(png_structp)png_ptr; 153 png_structp p=(png_structp)png_ptr;
153 png_uint_32 save_flags=p->flags; 154 png_uint_32 save_flags=p->flags;
154 png_uint_32 num_bytes; 155 png_uint_32 num_bytes;
155 156
156 if (png_ptr == NULL) return (NULL); 157 if (png_ptr == NULL)
158 return (NULL);
157 if (items > PNG_UINT_32_MAX/size) 159 if (items > PNG_UINT_32_MAX/size)
158 { 160 {
159 png_warning (p, "Potential overflow in png_zalloc()"); 161 png_warning (p, "Potential overflow in png_zalloc()");
160 return (NULL); 162 return (NULL);
161 } 163 }
162 num_bytes = (png_uint_32)items * size; 164 num_bytes = (png_uint_32)items * size;
163 165
164 p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; 166 p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
165 ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes); 167 ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
166 p->flags=save_flags; 168 p->flags=save_flags;
167 169
168 #if defined(PNG_1_0_X) && !defined(PNG_NO_ZALLOC_ZERO) 170 #if defined(PNG_1_0_X) && !defined(PNG_NO_ZALLOC_ZERO)
169 if (ptr == NULL) 171 if (ptr == NULL)
170 return ((voidpf)ptr); 172 return ((voidpf)ptr);
171 173
172 if (num_bytes > (png_uint_32)0x8000L) 174 if (num_bytes > (png_uint_32)0x8000L)
173 { 175 {
174 png_memset(ptr, 0, (png_size_t)0x8000L); 176 png_memset(ptr, 0, (png_size_t)0x8000L);
175 png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0, 177 png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0,
176 (png_size_t)(num_bytes - (png_uint_32)0x8000L)); 178 (png_size_t)(num_bytes - (png_uint_32)0x8000L));
177 } 179 }
178 else 180 else
179 { 181 {
180 png_memset(ptr, 0, (png_size_t)num_bytes); 182 png_memset(ptr, 0, (png_size_t)num_bytes);
181 } 183 }
182 #endif 184 #endif
183 return ((voidpf)ptr); 185 return ((voidpf)ptr);
184 } 186 }
185 187
186 /* function to free memory for zlib */ 188 /* Function to free memory for zlib */
187 #ifdef PNG_1_0_X 189 #ifdef PNG_1_0_X
188 void PNGAPI 190 void PNGAPI
189 #else 191 #else
190 void /* private */ 192 void /* private */
191 #endif 193 #endif
192 png_zfree(voidpf png_ptr, voidpf ptr) 194 png_zfree(voidpf png_ptr, voidpf ptr)
193 { 195 {
194 png_free((png_structp)png_ptr, (png_voidp)ptr); 196 png_free((png_structp)png_ptr, (png_voidp)ptr);
195 } 197 }
196 198
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 * future. This should be used in favour of malloc(png_sizeof(png_info)) 236 * future. This should be used in favour of malloc(png_sizeof(png_info))
235 * and png_info_init() so that applications that want to use a shared 237 * and png_info_init() so that applications that want to use a shared
236 * libpng don't have to be recompiled if png_info changes size. 238 * libpng don't have to be recompiled if png_info changes size.
237 */ 239 */
238 png_infop PNGAPI 240 png_infop PNGAPI
239 png_create_info_struct(png_structp png_ptr) 241 png_create_info_struct(png_structp png_ptr)
240 { 242 {
241 png_infop info_ptr; 243 png_infop info_ptr;
242 244
243 png_debug(1, "in png_create_info_struct"); 245 png_debug(1, "in png_create_info_struct");
244 if (png_ptr == NULL) return (NULL); 246 if (png_ptr == NULL)
247 return (NULL);
245 #ifdef PNG_USER_MEM_SUPPORTED 248 #ifdef PNG_USER_MEM_SUPPORTED
246 info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, 249 info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO,
247 png_ptr->malloc_fn, png_ptr->mem_ptr); 250 png_ptr->malloc_fn, png_ptr->mem_ptr);
248 #else 251 #else
249 info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); 252 info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);
250 #endif 253 #endif
251 if (info_ptr != NULL) 254 if (info_ptr != NULL)
252 png_info_init_3(&info_ptr, png_sizeof(png_info)); 255 png_info_init_3(&info_ptr, png_sizeof(png_info));
253 256
254 return (info_ptr); 257 return (info_ptr);
255 } 258 }
256 259
257 /* This function frees the memory associated with a single info struct. 260 /* This function frees the memory associated with a single info struct.
258 * Normally, one would use either png_destroy_read_struct() or 261 * Normally, one would use either png_destroy_read_struct() or
259 * png_destroy_write_struct() to free an info struct, but this may be 262 * png_destroy_write_struct() to free an info struct, but this may be
260 * useful for some applications. 263 * useful for some applications.
261 */ 264 */
262 void PNGAPI 265 void PNGAPI
263 png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) 266 png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
264 { 267 {
265 png_infop info_ptr = NULL; 268 png_infop info_ptr = NULL;
266 if (png_ptr == NULL) return; 269 if (png_ptr == NULL)
270 return;
267 271
268 png_debug(1, "in png_destroy_info_struct"); 272 png_debug(1, "in png_destroy_info_struct");
269 if (info_ptr_ptr != NULL) 273 if (info_ptr_ptr != NULL)
270 info_ptr = *info_ptr_ptr; 274 info_ptr = *info_ptr_ptr;
271 275
272 if (info_ptr != NULL) 276 if (info_ptr != NULL)
273 { 277 {
274 png_info_destroy(png_ptr, info_ptr); 278 png_info_destroy(png_ptr, info_ptr);
275 279
276 #ifdef PNG_USER_MEM_SUPPORTED 280 #ifdef PNG_USER_MEM_SUPPORTED
(...skipping 18 matching lines...) Expand all
295 /* We only come here via pre-1.0.12-compiled applications */ 299 /* We only come here via pre-1.0.12-compiled applications */
296 png_info_init_3(&info_ptr, 0); 300 png_info_init_3(&info_ptr, 0);
297 } 301 }
298 #endif 302 #endif
299 303
300 void PNGAPI 304 void PNGAPI
301 png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size) 305 png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size)
302 { 306 {
303 png_infop info_ptr = *ptr_ptr; 307 png_infop info_ptr = *ptr_ptr;
304 308
305 if (info_ptr == NULL) return; 309 if (info_ptr == NULL)
310 return;
306 311
307 png_debug(1, "in png_info_init_3"); 312 png_debug(1, "in png_info_init_3");
308 313
309 if (png_sizeof(png_info) > png_info_struct_size) 314 if (png_sizeof(png_info) > png_info_struct_size)
310 { 315 {
311 png_destroy_struct(info_ptr); 316 png_destroy_struct(info_ptr);
312 info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); 317 info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);
313 *ptr_ptr = info_ptr; 318 *ptr_ptr = info_ptr;
314 } 319 }
315 320
316 /* set everything to 0 */ 321 /* Set everything to 0 */
317 png_memset(info_ptr, 0, png_sizeof(png_info)); 322 png_memset(info_ptr, 0, png_sizeof(png_info));
318 } 323 }
319 324
320 #ifdef PNG_FREE_ME_SUPPORTED 325 #ifdef PNG_FREE_ME_SUPPORTED
321 void PNGAPI 326 void PNGAPI
322 png_data_freer(png_structp png_ptr, png_infop info_ptr, 327 png_data_freer(png_structp png_ptr, png_infop info_ptr,
323 int freer, png_uint_32 mask) 328 int freer, png_uint_32 mask)
324 { 329 {
325 png_debug(1, "in png_data_freer"); 330 png_debug(1, "in png_data_freer");
326 if (png_ptr == NULL || info_ptr == NULL) 331 if (png_ptr == NULL || info_ptr == NULL)
(...skipping 10 matching lines...) Expand all
337 342
338 void PNGAPI 343 void PNGAPI
339 png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, 344 png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
340 int num) 345 int num)
341 { 346 {
342 png_debug(1, "in png_free_data"); 347 png_debug(1, "in png_free_data");
343 if (png_ptr == NULL || info_ptr == NULL) 348 if (png_ptr == NULL || info_ptr == NULL)
344 return; 349 return;
345 350
346 #if defined(PNG_TEXT_SUPPORTED) 351 #if defined(PNG_TEXT_SUPPORTED)
347 /* free text item num or (if num == -1) all text items */ 352 /* Free text item num or (if num == -1) all text items */
348 #ifdef PNG_FREE_ME_SUPPORTED 353 #ifdef PNG_FREE_ME_SUPPORTED
349 if ((mask & PNG_FREE_TEXT) & info_ptr->free_me) 354 if ((mask & PNG_FREE_TEXT) & info_ptr->free_me)
350 #else 355 #else
351 if (mask & PNG_FREE_TEXT) 356 if (mask & PNG_FREE_TEXT)
352 #endif 357 #endif
353 { 358 {
354 if (num != -1) 359 if (num != -1)
355 { 360 {
356 if (info_ptr->text && info_ptr->text[num].key) 361 if (info_ptr->text && info_ptr->text[num].key)
357 { 362 {
358 png_free(png_ptr, info_ptr->text[num].key); 363 png_free(png_ptr, info_ptr->text[num].key);
359 info_ptr->text[num].key = NULL; 364 info_ptr->text[num].key = NULL;
360 } 365 }
361 } 366 }
367 else
368 {
369 int i;
370 for (i = 0; i < info_ptr->num_text; i++)
371 png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i);
372 png_free(png_ptr, info_ptr->text);
373 info_ptr->text = NULL;
374 info_ptr->num_text=0;
375 }
376 }
377 #endif
378
379 #if defined(PNG_tRNS_SUPPORTED)
380 /* Free any tRNS entry */
381 #ifdef PNG_FREE_ME_SUPPORTED
382 if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)
383 #else
384 if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS))
385 #endif
386 {
387 png_free(png_ptr, info_ptr->trans);
388 info_ptr->trans = NULL;
389 info_ptr->valid &= ~PNG_INFO_tRNS;
390 #ifndef PNG_FREE_ME_SUPPORTED
391 png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
392 #endif
393 }
394 #endif
395
396 #if defined(PNG_sCAL_SUPPORTED)
397 /* Free any sCAL entry */
398 #ifdef PNG_FREE_ME_SUPPORTED
399 if ((mask & PNG_FREE_SCAL) & info_ptr->free_me)
400 #else
401 if (mask & PNG_FREE_SCAL)
402 #endif
403 {
404 #if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
405 png_free(png_ptr, info_ptr->scal_s_width);
406 png_free(png_ptr, info_ptr->scal_s_height);
407 info_ptr->scal_s_width = NULL;
408 info_ptr->scal_s_height = NULL;
409 #endif
410 info_ptr->valid &= ~PNG_INFO_sCAL;
411 }
412 #endif
413
414 #if defined(PNG_pCAL_SUPPORTED)
415 /* Free any pCAL entry */
416 #ifdef PNG_FREE_ME_SUPPORTED
417 if ((mask & PNG_FREE_PCAL) & info_ptr->free_me)
418 #else
419 if (mask & PNG_FREE_PCAL)
420 #endif
421 {
422 png_free(png_ptr, info_ptr->pcal_purpose);
423 png_free(png_ptr, info_ptr->pcal_units);
424 info_ptr->pcal_purpose = NULL;
425 info_ptr->pcal_units = NULL;
426 if (info_ptr->pcal_params != NULL)
427 {
428 int i;
429 for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
430 {
431 png_free(png_ptr, info_ptr->pcal_params[i]);
432 info_ptr->pcal_params[i]=NULL;
433 }
434 png_free(png_ptr, info_ptr->pcal_params);
435 info_ptr->pcal_params = NULL;
436 }
437 info_ptr->valid &= ~PNG_INFO_pCAL;
438 }
439 #endif
440
441 #if defined(PNG_iCCP_SUPPORTED)
442 /* Free any iCCP entry */
443 #ifdef PNG_FREE_ME_SUPPORTED
444 if ((mask & PNG_FREE_ICCP) & info_ptr->free_me)
445 #else
446 if (mask & PNG_FREE_ICCP)
447 #endif
448 {
449 png_free(png_ptr, info_ptr->iccp_name);
450 png_free(png_ptr, info_ptr->iccp_profile);
451 info_ptr->iccp_name = NULL;
452 info_ptr->iccp_profile = NULL;
453 info_ptr->valid &= ~PNG_INFO_iCCP;
454 }
455 #endif
456
457 #if defined(PNG_sPLT_SUPPORTED)
458 /* Free a given sPLT entry, or (if num == -1) all sPLT entries */
459 #ifdef PNG_FREE_ME_SUPPORTED
460 if ((mask & PNG_FREE_SPLT) & info_ptr->free_me)
461 #else
462 if (mask & PNG_FREE_SPLT)
463 #endif
464 {
465 if (num != -1)
466 {
467 if (info_ptr->splt_palettes)
468 {
469 png_free(png_ptr, info_ptr->splt_palettes[num].name);
470 png_free(png_ptr, info_ptr->splt_palettes[num].entries);
471 info_ptr->splt_palettes[num].name = NULL;
472 info_ptr->splt_palettes[num].entries = NULL;
473 }
474 }
475 else
476 {
477 if (info_ptr->splt_palettes_num)
478 {
479 int i;
480 for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
481 png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i);
482
483 png_free(png_ptr, info_ptr->splt_palettes);
484 info_ptr->splt_palettes = NULL;
485 info_ptr->splt_palettes_num = 0;
486 }
487 info_ptr->valid &= ~PNG_INFO_sPLT;
488 }
489 }
490 #endif
491
492 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
493 if (png_ptr->unknown_chunk.data)
494 {
495 png_free(png_ptr, png_ptr->unknown_chunk.data);
496 png_ptr->unknown_chunk.data = NULL;
497 }
498
499 #ifdef PNG_FREE_ME_SUPPORTED
500 if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
501 #else
502 if (mask & PNG_FREE_UNKN)
503 #endif
504 {
505 if (num != -1)
506 {
507 if (info_ptr->unknown_chunks)
508 {
509 png_free(png_ptr, info_ptr->unknown_chunks[num].data);
510 info_ptr->unknown_chunks[num].data = NULL;
511 }
512 }
513 else
514 {
515 int i;
516
517 if (info_ptr->unknown_chunks_num)
518 {
519 for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++)
520 png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i);
521
522 png_free(png_ptr, info_ptr->unknown_chunks);
523 info_ptr->unknown_chunks = NULL;
524 info_ptr->unknown_chunks_num = 0;
525 }
526 }
527 }
528 #endif
529
530 #if defined(PNG_hIST_SUPPORTED)
531 /* Free any hIST entry */
532 #ifdef PNG_FREE_ME_SUPPORTED
533 if ((mask & PNG_FREE_HIST) & info_ptr->free_me)
534 #else
535 if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST))
536 #endif
537 {
538 png_free(png_ptr, info_ptr->hist);
539 info_ptr->hist = NULL;
540 info_ptr->valid &= ~PNG_INFO_hIST;
541 #ifndef PNG_FREE_ME_SUPPORTED
542 png_ptr->flags &= ~PNG_FLAG_FREE_HIST;
543 #endif
544 }
545 #endif
546
547 /* Free any PLTE entry that was internally allocated */
548 #ifdef PNG_FREE_ME_SUPPORTED
549 if ((mask & PNG_FREE_PLTE) & info_ptr->free_me)
550 #else
551 if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE))
552 #endif
553 {
554 png_zfree(png_ptr, info_ptr->palette);
555 info_ptr->palette = NULL;
556 info_ptr->valid &= ~PNG_INFO_PLTE;
557 #ifndef PNG_FREE_ME_SUPPORTED
558 png_ptr->flags &= ~PNG_FLAG_FREE_PLTE;
559 #endif
560 info_ptr->num_palette = 0;
561 }
562
563 #if defined(PNG_INFO_IMAGE_SUPPORTED)
564 /* Free any image bits attached to the info structure */
565 #ifdef PNG_FREE_ME_SUPPORTED
566 if ((mask & PNG_FREE_ROWS) & info_ptr->free_me)
567 #else
568 if (mask & PNG_FREE_ROWS)
569 #endif
570 {
571 if (info_ptr->row_pointers)
572 {
573 int row;
574 for (row = 0; row < (int)info_ptr->height; row++)
575 {
576 png_free(png_ptr, info_ptr->row_pointers[row]);
577 info_ptr->row_pointers[row]=NULL;
578 }
579 png_free(png_ptr, info_ptr->row_pointers);
580 info_ptr->row_pointers=NULL;
581 }
582 info_ptr->valid &= ~PNG_INFO_IDAT;
583 }
584 #endif
585
586 #ifdef PNG_FREE_ME_SUPPORTED
587 if (num == -1)
588 info_ptr->free_me &= ~mask;
362 else 589 else
363 { 590 info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL);
364 int i; 591 #endif
365 for (i = 0; i < info_ptr->num_text; i++)
366 png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i);
367 png_free(png_ptr, info_ptr->text);
368 info_ptr->text = NULL;
369 info_ptr->num_text=0;
370 }
371 } 592 }
372 #endif 593
373
374 #if defined(PNG_tRNS_SUPPORTED)
375 /* free any tRNS entry */
376 #ifdef PNG_FREE_ME_SUPPORTED
377 if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)
378 #else
379 if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS))
380 #endif
381 {
382 png_free(png_ptr, info_ptr->trans);
383 info_ptr->trans = NULL;
384 info_ptr->valid &= ~PNG_INFO_tRNS;
385 #ifndef PNG_FREE_ME_SUPPORTED
386 png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
387 #endif
388 }
389 #endif
390
391 #if defined(PNG_sCAL_SUPPORTED)
392 /* free any sCAL entry */
393 #ifdef PNG_FREE_ME_SUPPORTED
394 if ((mask & PNG_FREE_SCAL) & info_ptr->free_me)
395 #else
396 if (mask & PNG_FREE_SCAL)
397 #endif
398 {
399 #if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
400 png_free(png_ptr, info_ptr->scal_s_width);
401 png_free(png_ptr, info_ptr->scal_s_height);
402 info_ptr->scal_s_width = NULL;
403 info_ptr->scal_s_height = NULL;
404 #endif
405 info_ptr->valid &= ~PNG_INFO_sCAL;
406 }
407 #endif
408
409 #if defined(PNG_pCAL_SUPPORTED)
410 /* free any pCAL entry */
411 #ifdef PNG_FREE_ME_SUPPORTED
412 if ((mask & PNG_FREE_PCAL) & info_ptr->free_me)
413 #else
414 if (mask & PNG_FREE_PCAL)
415 #endif
416 {
417 png_free(png_ptr, info_ptr->pcal_purpose);
418 png_free(png_ptr, info_ptr->pcal_units);
419 info_ptr->pcal_purpose = NULL;
420 info_ptr->pcal_units = NULL;
421 if (info_ptr->pcal_params != NULL)
422 {
423 int i;
424 for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
425 {
426 png_free(png_ptr, info_ptr->pcal_params[i]);
427 info_ptr->pcal_params[i]=NULL;
428 }
429 png_free(png_ptr, info_ptr->pcal_params);
430 info_ptr->pcal_params = NULL;
431 }
432 info_ptr->valid &= ~PNG_INFO_pCAL;
433 }
434 #endif
435
436 #if defined(PNG_iCCP_SUPPORTED)
437 /* free any iCCP entry */
438 #ifdef PNG_FREE_ME_SUPPORTED
439 if ((mask & PNG_FREE_ICCP) & info_ptr->free_me)
440 #else
441 if (mask & PNG_FREE_ICCP)
442 #endif
443 {
444 png_free(png_ptr, info_ptr->iccp_name);
445 png_free(png_ptr, info_ptr->iccp_profile);
446 info_ptr->iccp_name = NULL;
447 info_ptr->iccp_profile = NULL;
448 info_ptr->valid &= ~PNG_INFO_iCCP;
449 }
450 #endif
451
452 #if defined(PNG_sPLT_SUPPORTED)
453 /* free a given sPLT entry, or (if num == -1) all sPLT entries */
454 #ifdef PNG_FREE_ME_SUPPORTED
455 if ((mask & PNG_FREE_SPLT) & info_ptr->free_me)
456 #else
457 if (mask & PNG_FREE_SPLT)
458 #endif
459 {
460 if (num != -1)
461 {
462 if (info_ptr->splt_palettes)
463 {
464 png_free(png_ptr, info_ptr->splt_palettes[num].name);
465 png_free(png_ptr, info_ptr->splt_palettes[num].entries);
466 info_ptr->splt_palettes[num].name = NULL;
467 info_ptr->splt_palettes[num].entries = NULL;
468 }
469 }
470 else
471 {
472 if (info_ptr->splt_palettes_num)
473 {
474 int i;
475 for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
476 png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i);
477
478 png_free(png_ptr, info_ptr->splt_palettes);
479 info_ptr->splt_palettes = NULL;
480 info_ptr->splt_palettes_num = 0;
481 }
482 info_ptr->valid &= ~PNG_INFO_sPLT;
483 }
484 }
485 #endif
486
487 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
488 if (png_ptr->unknown_chunk.data)
489 {
490 png_free(png_ptr, png_ptr->unknown_chunk.data);
491 png_ptr->unknown_chunk.data = NULL;
492 }
493
494 #ifdef PNG_FREE_ME_SUPPORTED
495 if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
496 #else
497 if (mask & PNG_FREE_UNKN)
498 #endif
499 {
500 if (num != -1)
501 {
502 if (info_ptr->unknown_chunks)
503 {
504 png_free(png_ptr, info_ptr->unknown_chunks[num].data);
505 info_ptr->unknown_chunks[num].data = NULL;
506 }
507 }
508 else
509 {
510 int i;
511
512 if (info_ptr->unknown_chunks_num)
513 {
514 for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++)
515 png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i);
516
517 png_free(png_ptr, info_ptr->unknown_chunks);
518 info_ptr->unknown_chunks = NULL;
519 info_ptr->unknown_chunks_num = 0;
520 }
521 }
522 }
523 #endif
524
525 #if defined(PNG_hIST_SUPPORTED)
526 /* free any hIST entry */
527 #ifdef PNG_FREE_ME_SUPPORTED
528 if ((mask & PNG_FREE_HIST) & info_ptr->free_me)
529 #else
530 if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST))
531 #endif
532 {
533 png_free(png_ptr, info_ptr->hist);
534 info_ptr->hist = NULL;
535 info_ptr->valid &= ~PNG_INFO_hIST;
536 #ifndef PNG_FREE_ME_SUPPORTED
537 png_ptr->flags &= ~PNG_FLAG_FREE_HIST;
538 #endif
539 }
540 #endif
541
542 /* free any PLTE entry that was internally allocated */
543 #ifdef PNG_FREE_ME_SUPPORTED
544 if ((mask & PNG_FREE_PLTE) & info_ptr->free_me)
545 #else
546 if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE))
547 #endif
548 {
549 png_zfree(png_ptr, info_ptr->palette);
550 info_ptr->palette = NULL;
551 info_ptr->valid &= ~PNG_INFO_PLTE;
552 #ifndef PNG_FREE_ME_SUPPORTED
553 png_ptr->flags &= ~PNG_FLAG_FREE_PLTE;
554 #endif
555 info_ptr->num_palette = 0;
556 }
557
558 #if defined(PNG_INFO_IMAGE_SUPPORTED)
559 /* free any image bits attached to the info structure */
560 #ifdef PNG_FREE_ME_SUPPORTED
561 if ((mask & PNG_FREE_ROWS) & info_ptr->free_me)
562 #else
563 if (mask & PNG_FREE_ROWS)
564 #endif
565 {
566 if (info_ptr->row_pointers)
567 {
568 int row;
569 for (row = 0; row < (int)info_ptr->height; row++)
570 {
571 png_free(png_ptr, info_ptr->row_pointers[row]);
572 info_ptr->row_pointers[row]=NULL;
573 }
574 png_free(png_ptr, info_ptr->row_pointers);
575 info_ptr->row_pointers=NULL;
576 }
577 info_ptr->valid &= ~PNG_INFO_IDAT;
578 }
579 #endif
580
581 #ifdef PNG_FREE_ME_SUPPORTED
582 if (num == -1)
583 info_ptr->free_me &= ~mask;
584 else
585 info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL);
586 #endif
587 }
588
589 /* This is an internal routine to free any memory that the info struct is 594 /* This is an internal routine to free any memory that the info struct is
590 * pointing to before re-using it or freeing the struct itself. Recall 595 * pointing to before re-using it or freeing the struct itself. Recall
591 * that png_free() checks for NULL pointers for us. 596 * that png_free() checks for NULL pointers for us.
592 */ 597 */
593 void /* PRIVATE */ 598 void /* PRIVATE */
594 png_info_destroy(png_structp png_ptr, png_infop info_ptr) 599 png_info_destroy(png_structp png_ptr, png_infop info_ptr)
595 { 600 {
596 png_debug(1, "in png_info_destroy"); 601 png_debug(1, "in png_info_destroy");
597 602
598 png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); 603 png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
599 604
600 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 605 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
601 if (png_ptr->num_chunk_list) 606 if (png_ptr->num_chunk_list)
602 { 607 {
603 png_free(png_ptr, png_ptr->chunk_list); 608 png_free(png_ptr, png_ptr->chunk_list);
604 png_ptr->chunk_list=NULL; 609 png_ptr->chunk_list=NULL;
605 png_ptr->num_chunk_list = 0; 610 png_ptr->num_chunk_list = 0;
606 } 611 }
607 #endif 612 #endif
608 613
609 png_info_init_3(&info_ptr, png_sizeof(png_info)); 614 png_info_init_3(&info_ptr, png_sizeof(png_info));
610 } 615 }
611 #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ 616 #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
612 617
613 /* This function returns a pointer to the io_ptr associated with the user 618 /* This function returns a pointer to the io_ptr associated with the user
614 * functions. The application should free any memory associated with this 619 * functions. The application should free any memory associated with this
615 * pointer before png_write_destroy() or png_read_destroy() are called. 620 * pointer before png_write_destroy() or png_read_destroy() are called.
616 */ 621 */
617 png_voidp PNGAPI 622 png_voidp PNGAPI
618 png_get_io_ptr(png_structp png_ptr) 623 png_get_io_ptr(png_structp png_ptr)
619 { 624 {
620 if (png_ptr == NULL) return (NULL); 625 if (png_ptr == NULL)
626 return (NULL);
621 return (png_ptr->io_ptr); 627 return (png_ptr->io_ptr);
622 } 628 }
623 629
624 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 630 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
625 #if !defined(PNG_NO_STDIO) 631 #if !defined(PNG_NO_STDIO)
626 /* Initialize the default input/output functions for the PNG file. If you 632 /* Initialize the default input/output functions for the PNG file. If you
627 * use your own read or write routines, you can call either png_set_read_fn() 633 * use your own read or write routines, you can call either png_set_read_fn()
628 * or png_set_write_fn() instead of png_init_io(). If you have defined 634 * or png_set_write_fn() instead of png_init_io(). If you have defined
629 * PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't 635 * PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't
630 * necessarily available. 636 * necessarily available.
631 */ 637 */
632 void PNGAPI 638 void PNGAPI
633 png_init_io(png_structp png_ptr, png_FILE_p fp) 639 png_init_io(png_structp png_ptr, png_FILE_p fp)
634 { 640 {
635 png_debug(1, "in png_init_io"); 641 png_debug(1, "in png_init_io");
636 if (png_ptr == NULL) return; 642 if (png_ptr == NULL)
643 return;
637 png_ptr->io_ptr = (png_voidp)fp; 644 png_ptr->io_ptr = (png_voidp)fp;
638 } 645 }
639 #endif 646 #endif
640 647
641 #if defined(PNG_TIME_RFC1123_SUPPORTED) 648 #if defined(PNG_TIME_RFC1123_SUPPORTED)
642 /* Convert the supplied time into an RFC 1123 string suitable for use in 649 /* Convert the supplied time into an RFC 1123 string suitable for use in
643 * a "Creation Time" or other text-based time string. 650 * a "Creation Time" or other text-based time string.
644 */ 651 */
645 png_charp PNGAPI 652 png_charp PNGAPI
646 png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) 653 png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
647 { 654 {
648 static PNG_CONST char short_months[12][4] = 655 static PNG_CONST char short_months[12][4] =
649 {"Jan", "Feb", "Mar", "Apr", "May", "Jun", 656 {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
650 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; 657 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
651 658
652 if (png_ptr == NULL) return (NULL); 659 if (png_ptr == NULL)
660 return (NULL);
653 if (png_ptr->time_buffer == NULL) 661 if (png_ptr->time_buffer == NULL)
654 { 662 {
655 png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29* 663 png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29*
656 png_sizeof(char))); 664 png_sizeof(char)));
657 } 665 }
658 666
659 #if defined(_WIN32_WCE) 667 #if defined(_WIN32_WCE)
660 { 668 {
661 wchar_t time_buf[29]; 669 wchar_t time_buf[29];
662 wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"), 670 wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"),
(...skipping 23 matching lines...) Expand all
686 #endif /* _WIN32_WCE */ 694 #endif /* _WIN32_WCE */
687 return ((png_charp)png_ptr->time_buffer); 695 return ((png_charp)png_ptr->time_buffer);
688 } 696 }
689 #endif /* PNG_TIME_RFC1123_SUPPORTED */ 697 #endif /* PNG_TIME_RFC1123_SUPPORTED */
690 698
691 #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ 699 #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
692 700
693 png_charp PNGAPI 701 png_charp PNGAPI
694 png_get_copyright(png_structp png_ptr) 702 png_get_copyright(png_structp png_ptr)
695 { 703 {
696 png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ 704 png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
697 return ((png_charp) "\n libpng version 1.2.36 - May 7, 2009\n\ 705 return ((png_charp) "\n libpng version 1.2.37 - June 4, 2009\n\
698 Copyright (c) 1998-2008 Glenn Randers-Pehrson\n\ 706 Copyright (c) 1998-2009 Glenn Randers-Pehrson\n\
699 Copyright (c) 1996-1997 Andreas Dilger\n\ 707 Copyright (c) 1996-1997 Andreas Dilger\n\
700 Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); 708 Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
701 } 709 }
702 710
703 /* The following return the library version as a short string in the 711 /* The following return the library version as a short string in the
704 * format 1.0.0 through 99.99.99zz. To get the version of *.h files 712 * format 1.0.0 through 99.99.99zz. To get the version of *.h files
705 * used with your application, print out PNG_LIBPNG_VER_STRING, which 713 * used with your application, print out PNG_LIBPNG_VER_STRING, which
706 * is defined in png.h. 714 * is defined in png.h.
707 * Note: now there is no difference between png_get_libpng_ver() and 715 * Note: now there is no difference between png_get_libpng_ver() and
708 * png_get_header_ver(). Due to the version_nn_nn_nn typedef guard, 716 * png_get_header_ver(). Due to the version_nn_nn_nn typedef guard,
709 * it is guaranteed that png.c uses the correct version of png.h. 717 * it is guaranteed that png.c uses the correct version of png.h.
710 */ 718 */
711 png_charp PNGAPI 719 png_charp PNGAPI
712 png_get_libpng_ver(png_structp png_ptr) 720 png_get_libpng_ver(png_structp png_ptr)
713 { 721 {
714 /* Version of *.c files used when building libpng */ 722 /* Version of *.c files used when building libpng */
715 png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ 723 png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
716 return ((png_charp) PNG_LIBPNG_VER_STRING); 724 return ((png_charp) PNG_LIBPNG_VER_STRING);
717 } 725 }
718 726
719 png_charp PNGAPI 727 png_charp PNGAPI
720 png_get_header_ver(png_structp png_ptr) 728 png_get_header_ver(png_structp png_ptr)
721 { 729 {
722 /* Version of *.h files used when building libpng */ 730 /* Version of *.h files used when building libpng */
723 png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ 731 png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
724 return ((png_charp) PNG_LIBPNG_VER_STRING); 732 return ((png_charp) PNG_LIBPNG_VER_STRING);
725 } 733 }
726 734
727 png_charp PNGAPI 735 png_charp PNGAPI
728 png_get_header_version(png_structp png_ptr) 736 png_get_header_version(png_structp png_ptr)
729 { 737 {
730 /* Returns longer string containing both version and date */ 738 /* Returns longer string containing both version and date */
731 png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ 739 png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */
732 return ((png_charp) PNG_HEADER_VERSION_STRING 740 return ((png_charp) PNG_HEADER_VERSION_STRING
733 #ifndef PNG_READ_SUPPORTED 741 #ifndef PNG_READ_SUPPORTED
734 " (NO READ SUPPORT)" 742 " (NO READ SUPPORT)"
735 #endif 743 #endif
736 "\n"); 744 "\n");
737 } 745 }
738 746
739 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 747 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
740 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED 748 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
741 int PNGAPI 749 int PNGAPI
742 png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) 750 png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
743 { 751 {
744 /* check chunk_name and return "keep" value if it's on the list, else 0 */ 752 /* Check chunk_name and return "keep" value if it's on the list, else 0 */
745 int i; 753 int i;
746 png_bytep p; 754 png_bytep p;
747 if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0) 755 if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0)
748 return 0; 756 return 0;
749 p = png_ptr->chunk_list + png_ptr->num_chunk_list*5 - 5; 757 p = png_ptr->chunk_list + png_ptr->num_chunk_list*5 - 5;
750 for (i = png_ptr->num_chunk_list; i; i--, p -= 5) 758 for (i = png_ptr->num_chunk_list; i; i--, p -= 5)
751 if (!png_memcmp(chunk_name, p, 4)) 759 if (!png_memcmp(chunk_name, p, 4))
752 return ((int)*(p + 4)); 760 return ((int)*(p + 4));
753 return 0; 761 return 0;
754 } 762 }
755 #endif 763 #endif
756 764
757 /* This function, added to libpng-1.0.6g, is untested. */ 765 /* This function, added to libpng-1.0.6g, is untested. */
758 int PNGAPI 766 int PNGAPI
759 png_reset_zstream(png_structp png_ptr) 767 png_reset_zstream(png_structp png_ptr)
760 { 768 {
761 if (png_ptr == NULL) return Z_STREAM_ERROR; 769 if (png_ptr == NULL)
770 return Z_STREAM_ERROR;
762 return (inflateReset(&png_ptr->zstream)); 771 return (inflateReset(&png_ptr->zstream));
763 } 772 }
764 #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ 773 #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
765 774
766 /* This function was added to libpng-1.0.7 */ 775 /* This function was added to libpng-1.0.7 */
767 png_uint_32 PNGAPI 776 png_uint_32 PNGAPI
768 png_access_version_number(void) 777 png_access_version_number(void)
769 { 778 {
770 /* Version of *.c files used when building libpng */ 779 /* Version of *.c files used when building libpng */
771 return((png_uint_32) PNG_LIBPNG_VER); 780 return((png_uint_32) PNG_LIBPNG_VER);
772 } 781 }
773 782
774 783
775 #if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) 784 #if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED)
776 #if !defined(PNG_1_0_X) 785 #if !defined(PNG_1_0_X)
777 /* this function was added to libpng 1.2.0 */ 786 /* This function was added to libpng 1.2.0 */
778 int PNGAPI 787 int PNGAPI
779 png_mmx_support(void) 788 png_mmx_support(void)
780 { 789 {
781 /* obsolete, to be removed from libpng-1.4.0 */ 790 /* Obsolete, to be removed from libpng-1.4.0 */
782 return -1; 791 return -1;
783 } 792 }
784 #endif /* PNG_1_0_X */ 793 #endif /* PNG_1_0_X */
785 #endif /* PNG_READ_SUPPORTED && PNG_ASSEMBLER_CODE_SUPPORTED */ 794 #endif /* PNG_READ_SUPPORTED && PNG_ASSEMBLER_CODE_SUPPORTED */
786 795
787 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 796 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
788 #ifdef PNG_SIZE_T 797 #ifdef PNG_SIZE_T
789 /* Added at libpng version 1.2.6 */ 798 /* Added at libpng version 1.2.6 */
790 PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); 799 PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size));
791 png_size_t PNGAPI 800 png_size_t PNGAPI
792 png_convert_size(size_t size) 801 png_convert_size(size_t size)
793 { 802 {
794 if (size > (png_size_t)-1) 803 if (size > (png_size_t)-1)
795 PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */ 804 PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */
796 return ((png_size_t)size); 805 return ((png_size_t)size);
797 } 806 }
798 #endif /* PNG_SIZE_T */ 807 #endif /* PNG_SIZE_T */
799 808
800 /* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */ 809 /* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */
801 #if defined(PNG_cHRM_SUPPORTED) 810 #if defined(PNG_cHRM_SUPPORTED)
802 #if !defined(PNG_NO_CHECK_cHRM) 811 #if !defined(PNG_NO_CHECK_cHRM)
803 812
804 /* 813 /*
805 Multiply two 32-bit numbers, V1 and V2, using 32-bit 814 * Multiply two 32-bit numbers, V1 and V2, using 32-bit
806 arithmetic, to produce a 64 bit result in the HI/LO words. 815 * arithmetic, to produce a 64 bit result in the HI/LO words.
807 816 *
808 A B 817 * A B
809 x C D 818 * x C D
810 ------ 819 * ------
811 AD || BD 820 * AD || BD
812 AC || CB || 0 821 * AC || CB || 0
813 822 *
814 where A and B are the high and low 16-bit words of V1, 823 * where A and B are the high and low 16-bit words of V1,
815 C and D are the 16-bit words of V2, AD is the product of 824 * C and D are the 16-bit words of V2, AD is the product of
816 A and D, and X || Y is (X << 16) + Y. 825 * A and D, and X || Y is (X << 16) + Y.
817 */ 826 */
818 827
819 void png_64bit_product (long v1, long v2, unsigned long *hi_product, 828 void png_64bit_product (long v1, long v2, unsigned long *hi_product,
820 unsigned long *lo_product) 829 unsigned long *lo_product)
821 { 830 {
822 int a, b, c, d; 831 int a, b, c, d;
823 long lo, hi, x, y; 832 long lo, hi, x, y;
824 833
825 a = (v1 >> 16) & 0xffff; 834 a = (v1 >> 16) & 0xffff;
826 b = v1 & 0xffff; 835 b = v1 & 0xffff;
827 c = (v2 >> 16) & 0xffff; 836 c = (v2 >> 16) & 0xffff;
828 d = v2 & 0xffff; 837 d = v2 & 0xffff;
829 838
830 lo = b * d; /* BD */ 839 lo = b * d; /* BD */
831 x = a * d + c * b; /* AD + CB */ 840 x = a * d + c * b; /* AD + CB */
832 y = ((lo >> 16) & 0xffff) + x; 841 y = ((lo >> 16) & 0xffff) + x;
833 842
834 lo = (lo & 0xffff) | ((y & 0xffff) << 16); 843 lo = (lo & 0xffff) | ((y & 0xffff) << 16);
835 hi = (y >> 16) & 0xffff; 844 hi = (y >> 16) & 0xffff;
836 845
837 hi += a * c; /* AC */ 846 hi += a * c; /* AC */
838 847
839 *hi_product = (unsigned long)hi; 848 *hi_product = (unsigned long)hi;
840 *lo_product = (unsigned long)lo; 849 *lo_product = (unsigned long)lo;
841 } 850 }
851
842 int /* private */ 852 int /* private */
843 png_check_cHRM_fixed(png_structp png_ptr, 853 png_check_cHRM_fixed(png_structp png_ptr,
844 png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, 854 png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x,
845 png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, 855 png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,
846 png_fixed_point blue_x, png_fixed_point blue_y) 856 png_fixed_point blue_x, png_fixed_point blue_y)
847 { 857 {
848 int ret = 1; 858 int ret = 1;
849 unsigned long xy_hi,xy_lo,yx_hi,yx_lo; 859 unsigned long xy_hi,xy_lo,yx_hi,yx_lo;
850 860
851 png_debug(1, "in function png_check_cHRM_fixed"); 861 png_debug(1, "in function png_check_cHRM_fixed");
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 png_warning(png_ptr, 913 png_warning(png_ptr,
904 "Ignoring attempt to set cHRM RGB triangle with zero area"); 914 "Ignoring attempt to set cHRM RGB triangle with zero area");
905 ret = 0; 915 ret = 0;
906 } 916 }
907 917
908 return ret; 918 return ret;
909 } 919 }
910 #endif /* NO_PNG_CHECK_cHRM */ 920 #endif /* NO_PNG_CHECK_cHRM */
911 #endif /* PNG_cHRM_SUPPORTED */ 921 #endif /* PNG_cHRM_SUPPORTED */
912 #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ 922 #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
OLDNEW
« no previous file with comments | « third_party/libpng/png.h ('k') | third_party/libpng/pngconf.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698