diff options
Diffstat (limited to 'Build/source/libs/libpng/png.c')
-rw-r--r-- | Build/source/libs/libpng/png.c | 123 |
1 files changed, 30 insertions, 93 deletions
diff --git a/Build/source/libs/libpng/png.c b/Build/source/libs/libpng/png.c index 9665c2c1c3b..4d25559cf1d 100644 --- a/Build/source/libs/libpng/png.c +++ b/Build/source/libs/libpng/png.c @@ -1,7 +1,7 @@ /* png.c - location for general purpose libpng functions * - * Last changed in libpng 1.2.17 May 15, 2007 + * Last changed in libpng 1.2.21 October 4, 2007 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2007 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -13,20 +13,20 @@ #include "png.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_2_18 Your_png_h_is_not_version_1_2_18; +typedef version_1_2_24 Your_png_h_is_not_version_1_2_24; /* Version information for C files. This had better match the version * string defined in png.h. */ #ifdef PNG_USE_GLOBAL_ARRAYS /* png_libpng_ver was changed to a function in version 1.0.5c */ -const char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING; +PNG_CONST char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING; #ifdef PNG_READ_SUPPORTED /* png_sig was changed to a function in version 1.0.5c */ /* Place to hold the signature string for a PNG file. */ -const png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; +PNG_CONST png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; #endif /* PNG_READ_SUPPORTED */ /* Invoke global declarations for constant strings for known chunk types */ @@ -56,32 +56,27 @@ PNG_zTXt; /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* start of interlace block */ -const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; +PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; /* offset to next interlace block */ -const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; +PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; /* start of interlace block in the y direction */ -const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; +PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; /* offset to next interlace block in the y direction */ -const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; - -/* width of interlace block (used in assembler routines only) */ -#ifdef PNG_HAVE_MMX_COMBINE_ROW -const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; -#endif +PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; /* Height of interlace block. This is not currently used - if you need * it, uncomment it here and in png.h -const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; +PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; */ /* Mask to determine which pixels are valid in a pass */ -const int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; +PNG_CONST int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; /* Mask to determine which pixels to overwrite while displaying */ -const int FARDATA png_pass_dsp_mask[] +PNG_CONST int FARDATA png_pass_dsp_mask[] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; #endif /* PNG_READ_SUPPORTED */ @@ -134,7 +129,7 @@ png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check) #if defined(PNG_1_0_X) || defined(PNG_1_2_X) /* (Obsolete) function to check signature bytes. It does not allow one * to check a partial signature. This function might be removed in the - * future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG. + * future - use png_sig_cmp(). Returns true (nonzero) if the file is PNG. */ int PNGAPI png_check_sig(png_bytep sig, int num) @@ -674,7 +669,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) #ifdef USE_FAR_KEYWORD { char near_time_buf[29]; - sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000", + png_snprintf6(near_time_buf,29,"%d %s %d %02d:%02d:%02d +0000", ptime->day % 32, short_months[(ptime->month - 1) % 12], ptime->year, ptime->hour % 24, ptime->minute % 60, ptime->second % 61); @@ -682,7 +677,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) 29*png_sizeof(char)); } #else - sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000", + png_snprintf6(png_ptr->time_buffer,29,"%d %s %d %02d:%02d:%02d +0000", ptime->day % 32, short_months[(ptime->month - 1) % 12], ptime->year, ptime->hour % 24, ptime->minute % 60, ptime->second % 61); @@ -692,25 +687,16 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) } #endif /* PNG_TIME_RFC1123_SUPPORTED */ -#if 0 -/* Signature string for a PNG file. */ -png_bytep PNGAPI -png_sig_bytes(void) -{ - return ((png_bytep)"\211\120\116\107\015\012\032\012"); -} -#endif #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ png_charp PNGAPI png_get_copyright(png_structp png_ptr) { - if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return ((png_charp) "\n libpng version 1.2.18 - May 15, 2007\n\ + png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ + return ((png_charp) "\n libpng version 1.2.24 - December 14, 2007\n\ Copyright (c) 1998-2007 Glenn Randers-Pehrson\n\ Copyright (c) 1996-1997 Andreas Dilger\n\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); - return ((png_charp) ""); } /* The following return the library version as a short string in the @@ -725,27 +711,28 @@ png_charp PNGAPI png_get_libpng_ver(png_structp png_ptr) { /* Version of *.c files used when building libpng */ - if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return ((png_charp) PNG_LIBPNG_VER_STRING); - return ((png_charp) ""); + png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ + return ((png_charp) PNG_LIBPNG_VER_STRING); } png_charp PNGAPI png_get_header_ver(png_structp png_ptr) { /* Version of *.h files used when building libpng */ - if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return ((png_charp) PNG_LIBPNG_VER_STRING); - return ((png_charp) ""); + png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ + return ((png_charp) PNG_LIBPNG_VER_STRING); } png_charp PNGAPI png_get_header_version(png_structp png_ptr) { /* Returns longer string containing both version and date */ - if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return ((png_charp) PNG_HEADER_VERSION_STRING); - return ((png_charp) ""); + png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ + return ((png_charp) PNG_HEADER_VERSION_STRING +#ifndef PNG_READ_SUPPORTED + " (NO READ SUPPORT)" +#endif + "\n"); } #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) @@ -756,7 +743,7 @@ png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) /* check chunk_name and return "keep" value if it's on the list, else 0 */ int i; png_bytep p; - if((png_ptr == NULL && chunk_name == NULL) || png_ptr->num_chunk_list<=0) + if(png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0) return 0; p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5; for (i = png_ptr->num_chunk_list; i; i--, p-=5) @@ -786,65 +773,15 @@ png_access_version_number(void) #if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) #if !defined(PNG_1_0_X) -#if defined(PNG_MMX_CODE_SUPPORTED) -/* this INTERNAL function was added to libpng 1.2.0 */ -void /* PRIVATE */ -png_init_mmx_flags (png_structp png_ptr) -{ - if(png_ptr == NULL) return; - png_ptr->mmx_rowbytes_threshold = 0; - png_ptr->mmx_bitdepth_threshold = 0; - -# if (defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD)) - - png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_COMPILED; - - if (png_mmx_support() > 0) { - png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU -# ifdef PNG_HAVE_MMX_COMBINE_ROW - | PNG_ASM_FLAG_MMX_READ_COMBINE_ROW -# endif -# ifdef PNG_HAVE_MMX_READ_INTERLACE - | PNG_ASM_FLAG_MMX_READ_INTERLACE -# endif -# ifndef PNG_HAVE_MMX_READ_FILTER_ROW - ; -# else - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB - | PNG_ASM_FLAG_MMX_READ_FILTER_UP - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; - - png_ptr->mmx_rowbytes_threshold = PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT; - png_ptr->mmx_bitdepth_threshold = PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT; -# endif - } else { - png_ptr->asm_flags &= ~( PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU - | PNG_MMX_READ_FLAGS - | PNG_MMX_WRITE_FLAGS ); - } - -# else /* !(PNGVCRD || PNGGCCRD) */ - - /* clear all MMX flags; no support is compiled in */ - png_ptr->asm_flags &= ~( PNG_MMX_FLAGS ); - -# endif /* ?(PNGVCRD || PNGGCCRD) */ -} - -#endif /* !(PNG_MMX_CODE_SUPPORTED) */ - /* this function was added to libpng 1.2.0 */ -#if !defined(PNG_USE_PNGGCCRD) && \ - !(defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD)) int PNGAPI png_mmx_support(void) { + /* obsolete, to be removed from libpng-1.4.0 */ return -1; } -#endif -#endif /* PNG_1_0_X && PNG_ASSEMBLER_CODE_SUPPORTED */ -#endif /* PNG_READ_SUPPORTED */ +#endif /* PNG_1_0_X */ +#endif /* PNG_READ_SUPPORTED && PNG_ASSEMBLER_CODE_SUPPORTED */ #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #ifdef PNG_SIZE_T |