diff -ru4NwbB libpng-1.2.33/png.c libpng-1.2.34beta04/png.c --- libpng-1.2.33/png.c 2008-10-31 08:42:01.879516574 -0500 +++ libpng-1.2.34beta04/png.c 2008-12-01 11:56:05.848098684 -0600 @@ -92,9 +92,9 @@ void PNGAPI png_set_sig_bytes(png_structp png_ptr, int num_bytes) { if (png_ptr == NULL) return; - png_debug(1, "in png_set_sig_bytes\n"); + png_debug(1, "in png_set_sig_bytes"); if (num_bytes > 8) png_error(png_ptr, "Too many bytes for PNG signature."); png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes); @@ -239,9 +239,9 @@ png_create_info_struct(png_structp png_ptr) { png_infop info_ptr; - png_debug(1, "in png_create_info_struct\n"); + png_debug(1, "in png_create_info_struct"); if (png_ptr == NULL) return (NULL); #ifdef PNG_USER_MEM_SUPPORTED info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, png_ptr->malloc_fn, png_ptr->mem_ptr); @@ -264,9 +264,9 @@ { png_infop info_ptr = NULL; if (png_ptr == NULL) return; - png_debug(1, "in png_destroy_info_struct\n"); + png_debug(1, "in png_destroy_info_struct"); if (info_ptr_ptr != NULL) info_ptr = *info_ptr_ptr; if (info_ptr != NULL) @@ -303,9 +303,9 @@ png_infop info_ptr = *ptr_ptr; if (info_ptr == NULL) return; - png_debug(1, "in png_info_init_3\n"); + png_debug(1, "in png_info_init_3"); if (png_sizeof(png_info) > png_info_struct_size) { png_destroy_struct(info_ptr); @@ -321,9 +321,9 @@ void PNGAPI png_data_freer(png_structp png_ptr, png_infop info_ptr, int freer, png_uint_32 mask) { - png_debug(1, "in png_data_freer\n"); + png_debug(1, "in png_data_freer"); if (png_ptr == NULL || info_ptr == NULL) return; if (freer == PNG_DESTROY_WILL_FREE_DATA) info_ptr->free_me |= mask; @@ -338,9 +338,9 @@ void PNGAPI png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, int num) { - png_debug(1, "in png_free_data\n"); + png_debug(1, "in png_free_data"); if (png_ptr == NULL || info_ptr == NULL) return; #if defined(PNG_TEXT_SUPPORTED) @@ -592,9 +592,9 @@ */ void /* PRIVATE */ png_info_destroy(png_structp png_ptr, png_infop info_ptr) { - png_debug(1, "in png_info_destroy\n"); + png_debug(1, "in png_info_destroy"); png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) @@ -631,9 +631,9 @@ */ void PNGAPI png_init_io(png_structp png_ptr, png_FILE_p fp) { - png_debug(1, "in png_init_io\n"); + png_debug(1, "in png_init_io"); if (png_ptr == NULL) return; png_ptr->io_ptr = (png_voidp)fp; } #endif @@ -795,5 +795,117 @@ PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */ return ((png_size_t)size); } #endif /* PNG_SIZE_T */ + +/* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */ +#if defined(PNG_cHRM_SUPPORTED) +#if !defined(PNG_NO_CHECK_cHRM) +/* + Multiply two 32-bit numbers, V1 and V2, using 32-bit + arithmetic, to produce a 64 bit result in the HI/LO words. + + A B + x C D + ------ + AD || BD +AC || CB || 0 + + where A and B are the high and low 16-bit words of V1, + C and D are the 16-bit words of V2, AD is the product of + A and D, and X || Y is (X << 16) + Y. +*/ + +void png_64bit_product (long v1, long v2, unsigned long *hi_product, + unsigned long *lo_product) +{ + int a, b, c, d; + long lo, hi, x, y; + + a = (v1 >> 16) & 0xffff; + b = v1 & 0xffff; + c = (v2 >> 16) & 0xffff; + d = v2 & 0xffff; + + lo = b * d; /* BD */ + x = a * d + c * b; /* AD + CB */ + y = ((lo >> 16) & 0xffff) + x; + + lo = (lo & 0xffff) | ((y & 0xffff) << 16); + hi = (y >> 16) & 0xffff; + + hi += a * c; /* AC */ + + *hi_product = (unsigned long)hi; + *lo_product = (unsigned long)lo; +} +int /* private */ +png_check_cHRM_fixed(png_structp png_ptr, + png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, + png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, + png_fixed_point blue_x, png_fixed_point blue_y) +{ + int ret = 1; + unsigned long xy_hi,xy_lo,yx_hi,yx_lo; + + png_debug(1, "in function png_check_cHRM_fixed"); + if (png_ptr == NULL) + return 0; + + if (white_x < 0 || white_y <= 0 || + red_x < 0 || red_y < 0 || + green_x < 0 || green_y < 0 || + blue_x < 0 || blue_y < 0) + { + png_warning(png_ptr, + "Ignoring attempt to set negative chromaticity value"); + ret = 0; + } + if (white_x > (png_fixed_point) PNG_UINT_31_MAX || + white_y > (png_fixed_point) PNG_UINT_31_MAX || + red_x > (png_fixed_point) PNG_UINT_31_MAX || + red_y > (png_fixed_point) PNG_UINT_31_MAX || + green_x > (png_fixed_point) PNG_UINT_31_MAX || + green_y > (png_fixed_point) PNG_UINT_31_MAX || + blue_x > (png_fixed_point) PNG_UINT_31_MAX || + blue_y > (png_fixed_point) PNG_UINT_31_MAX ) + { + png_warning(png_ptr, + "Ignoring attempt to set chromaticity value exceeding 21474.83"); + ret = 0; + } + if (white_x > 100000L - white_y) + { + png_warning(png_ptr, "Invalid cHRM white point"); + ret = 0; + } + if (red_x > 100000L - red_y) + { + png_warning(png_ptr, "Invalid cHRM red point"); + ret = 0; + } + if (green_x > 100000L - green_y) + { + png_warning(png_ptr, "Invalid cHRM green point"); + ret = 0; + } + if (blue_x > 100000L - blue_y) + { + png_warning(png_ptr, "Invalid cHRM blue point"); + ret = 0; + } + + png_64bit_product(green_x - red_x, blue_y - red_y, &xy_hi, &xy_lo); + png_64bit_product(green_y - red_y, blue_x - red_x, &yx_hi, &yx_lo); + + if (xy_hi == yx_hi && xy_lo == yx_lo) + { + png_warning(png_ptr, + "Ignoring attempt to set cHRM RGB triangle with zero area"); + ret = 0; + } + + return ret; +} +#endif /* NO_PNG_CHECK_cHRM */ +#endif /* PNG_cHRM_SUPPORTED */ #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ diff -ru4NwbB libpng-1.2.33/png.h libpng-1.2.34beta04/png.h --- libpng-1.2.33/png.h 2008-10-31 08:42:01.856878980 -0500 +++ libpng-1.2.34beta04/png.h 2008-12-01 11:56:05.825380176 -0600 @@ -211,8 +211,9 @@ * 1.2.33rc01-02 13 10233 12.so.0.33[.0] * 1.0.41rc01 10 10041 10.so.0.41[.0] * 1.2.33 13 10233 12.so.0.33[.0] * 1.0.41 10 10041 10.so.0.41[.0] + * 1.2.34beta01-04 13 10234 12.so.0.34[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be * used for changes in backward compatibility, as it is intended. The @@ -2525,35 +2526,82 @@ #if (PNG_DEBUG > 0) #if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) #include #if (PNG_DEBUG > 1) -#define png_debug(l,m) _RPT0(_CRT_WARN,m) -#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1) -#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2) +#ifndef _DEBUG +# define _DEBUG +#endif +#ifndef png_debug +#define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE) +#endif +#ifndef png_debug1 +#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1) +#endif +#ifndef png_debug2 +#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2) +#endif #endif #else /* PNG_DEBUG_FILE || !_MSC_VER */ #ifndef PNG_DEBUG_FILE #define PNG_DEBUG_FILE stderr #endif /* PNG_DEBUG_FILE */ #if (PNG_DEBUG > 1) +#ifndef png_debug +/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on + * non-ISO compilers */ +#ifdef __STDC__ #define png_debug(l,m) \ { \ int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ } +#endif +#ifndef png_debug1 #define png_debug1(l,m,p1) \ { \ int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ } +#endif +#ifndef png_debug2 #define png_debug2(l,m,p1,p2) \ { \ int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ } +#endif +#else /* __STDC __ */ +#ifndef png_debug +#define png_debug(l,m) \ + int num_tabs=l; \ + char format[256]; \ + snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ + m,PNG_STRING_NEWLINE); \ + fprintf(PNG_DEBUG_FILE,format); +#endif +#ifndef png_debug1 +#define png_debug1(l,m,p1) \ + int num_tabs=l; \ + char format[256]; \ + snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ + m,PNG_STRING_NEWLINE); \ + fprintf(PNG_DEBUG_FILE,format,p1); +#endif +#ifndef png_debug2 +#define png_debug2(l,m,p1,p2) \ + int num_tabs=l; \ + char format[256]; \ + snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ + m,PNG_STRING_NEWLINE); \ + fprintf(PNG_DEBUG_FILE,format,p1,p2); +#endif +#endif /* __STDC __ */ #endif /* (PNG_DEBUG > 1) */ #endif /* _MSC_VER */ #endif /* (PNG_DEBUG > 0) */ #endif /* PNG_DEBUG */ @@ -3583,8 +3631,17 @@ /* Read the chunk header (length + type name) */ PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr)); +/* Added at libpng version 1.2.34 */ +#if defined(PNG_cHRM_SUPPORTED) +PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr, + png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif + /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ #endif /* PNG_INTERNAL */ diff -ru4NwbB libpng-1.2.33/pngconf.h libpng-1.2.34beta04/pngconf.h --- libpng-1.2.33/pngconf.h 2008-10-31 08:42:01.865260942 -0500 +++ libpng-1.2.34beta04/pngconf.h 2008-12-01 11:56:05.833872152 -0600 @@ -797,8 +797,14 @@ #ifndef PNG_USER_HEIGHT_MAX # define PNG_USER_HEIGHT_MAX 1000000L #endif + +/* Added at libpng-1.2.34 and 1.4.0 */ +#ifndef PNG_STRING_NEWLINE +#define PNG_STRING_NEWLINE "\n" +#endif + /* These are currently experimental features, define them if you want */ /* very little testing */ /* diff -ru4NwbB libpng-1.2.33/pngerror.c libpng-1.2.34beta04/pngerror.c --- libpng-1.2.33/pngerror.c 2008-10-31 08:42:01.884871838 -0500 +++ libpng-1.2.34beta04/pngerror.c 2008-12-01 11:56:05.853368544 -0600 @@ -1,8 +1,8 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * Last changed in libpng 1.2.30 [August 15, 2008] + * Last changed in libpng 1.2.34 [December 1, 2008] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -115,11 +115,11 @@ if (warning_message[offset] == ' ') break; } } + } if (png_ptr != NULL && png_ptr->warning_fn != NULL) (*(png_ptr->warning_fn))(png_ptr, warning_message + offset); - } else png_default_warning(png_ptr, warning_message + offset); } #endif /* PNG_NO_WARNINGS */ diff -ru4NwbB libpng-1.2.33/pngget.c libpng-1.2.34beta04/pngget.c --- libpng-1.2.33/pngget.c 2008-10-31 08:42:01.896270766 -0500 +++ libpng-1.2.34beta04/pngget.c 2008-12-01 11:56:05.864956546 -0600 @@ -119,9 +119,9 @@ if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_pHYs_SUPPORTED) if (info_ptr->valid & PNG_INFO_pHYs) { - png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter"); + png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter"); if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER) return (0); else return (info_ptr->x_pixels_per_unit); } @@ -137,9 +137,9 @@ if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_pHYs_SUPPORTED) if (info_ptr->valid & PNG_INFO_pHYs) { - png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); + png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter"); if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER) return (0); else return (info_ptr->y_pixels_per_unit); } @@ -155,9 +155,9 @@ if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_pHYs_SUPPORTED) if (info_ptr->valid & PNG_INFO_pHYs) { - png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter"); + png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter"); if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER || info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) return (0); else return (info_ptr->x_pixels_per_unit); @@ -175,9 +175,9 @@ if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_pHYs_SUPPORTED) if (info_ptr->valid & PNG_INFO_pHYs) { - png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio"); + png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); if (info_ptr->x_pixels_per_unit == 0) return ((float)0.0); else return ((float)((float)info_ptr->y_pixels_per_unit @@ -196,9 +196,9 @@ if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_oFFs_SUPPORTED) if (info_ptr->valid & PNG_INFO_oFFs) { - png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); + png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) return (0); else return (info_ptr->x_offset); } @@ -214,9 +214,9 @@ if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_oFFs_SUPPORTED) if (info_ptr->valid & PNG_INFO_oFFs) { - png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); + png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) return (0); else return (info_ptr->y_offset); } @@ -232,9 +232,9 @@ if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_oFFs_SUPPORTED) if (info_ptr->valid & PNG_INFO_oFFs) { - png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); + png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) return (0); else return (info_ptr->x_offset); } @@ -250,9 +250,9 @@ if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_oFFs_SUPPORTED) if (info_ptr->valid & PNG_INFO_oFFs) { - png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); + png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) return (0); else return (info_ptr->y_offset); } @@ -306,9 +306,9 @@ png_uint_32 retval = 0; if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) { - png_debug1(1, "in %s retrieval function\n", "pHYs"); + png_debug1(1, "in %s retrieval function", "pHYs"); if (res_x != NULL) { *res_x = info_ptr->x_pixels_per_unit; retval |= PNG_INFO_pHYs; @@ -363,9 +363,9 @@ { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) && background != NULL) { - png_debug1(1, "in %s retrieval function\n", "bKGD"); + png_debug1(1, "in %s retrieval function", "bKGD"); *background = &(info_ptr->background); return (PNG_INFO_bKGD); } return (0); @@ -380,9 +380,9 @@ double *green_x, double *green_y, double *blue_x, double *blue_y) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) { - png_debug1(1, "in %s retrieval function\n", "cHRM"); + png_debug1(1, "in %s retrieval function", "cHRM"); if (white_x != NULL) *white_x = (double)info_ptr->x_white; if (white_y != NULL) *white_y = (double)info_ptr->y_white; @@ -411,9 +411,9 @@ png_fixed_point *blue_x, png_fixed_point *blue_y) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) { - png_debug1(1, "in %s retrieval function\n", "cHRM"); + png_debug1(1, "in %s retrieval function", "cHRM"); if (white_x != NULL) *white_x = info_ptr->int_x_white; if (white_y != NULL) *white_y = info_ptr->int_y_white; @@ -443,9 +443,9 @@ { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) && file_gamma != NULL) { - png_debug1(1, "in %s retrieval function\n", "gAMA"); + png_debug1(1, "in %s retrieval function", "gAMA"); *file_gamma = (double)info_ptr->gamma; return (PNG_INFO_gAMA); } return (0); @@ -458,9 +458,9 @@ { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) && int_file_gamma != NULL) { - png_debug1(1, "in %s retrieval function\n", "gAMA"); + png_debug1(1, "in %s retrieval function", "gAMA"); *int_file_gamma = info_ptr->int_gamma; return (PNG_INFO_gAMA); } return (0); @@ -474,9 +474,9 @@ { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) && file_srgb_intent != NULL) { - png_debug1(1, "in %s retrieval function\n", "sRGB"); + png_debug1(1, "in %s retrieval function", "sRGB"); *file_srgb_intent = (int)info_ptr->srgb_intent; return (PNG_INFO_sRGB); } return (0); @@ -491,9 +491,9 @@ { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) && name != NULL && profile != NULL && proflen != NULL) { - png_debug1(1, "in %s retrieval function\n", "iCCP"); + png_debug1(1, "in %s retrieval function", "iCCP"); *name = info_ptr->iccp_name; *profile = info_ptr->iccp_profile; /* compression_type is a dummy so the API won't have to change if we introduce multiple compression types later. */ @@ -525,9 +525,9 @@ { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) && hist != NULL) { - png_debug1(1, "in %s retrieval function\n", "hIST"); + png_debug1(1, "in %s retrieval function", "hIST"); *hist = info_ptr->hist; return (PNG_INFO_hIST); } return (0); @@ -543,9 +543,9 @@ { if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && bit_depth != NULL && color_type != NULL) { - png_debug1(1, "in %s retrieval function\n", "IHDR"); + png_debug1(1, "in %s retrieval function", "IHDR"); *width = info_ptr->width; *height = info_ptr->height; *bit_depth = info_ptr->bit_depth; if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) @@ -587,9 +587,9 @@ { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) && offset_x != NULL && offset_y != NULL && unit_type != NULL) { - png_debug1(1, "in %s retrieval function\n", "oFFs"); + png_debug1(1, "in %s retrieval function", "oFFs"); *offset_x = info_ptr->x_offset; *offset_y = info_ptr->y_offset; *unit_type = (int)info_ptr->offset_unit_type; return (PNG_INFO_oFFs); @@ -607,9 +607,9 @@ if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && nparams != NULL && units != NULL && params != NULL) { - png_debug1(1, "in %s retrieval function\n", "pCAL"); + png_debug1(1, "in %s retrieval function", "pCAL"); *purpose = info_ptr->pcal_purpose; *X0 = info_ptr->pcal_X0; *X1 = info_ptr->pcal_X1; *type = (int)info_ptr->pcal_type; @@ -667,9 +667,9 @@ if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) { - png_debug1(1, "in %s retrieval function\n", "pHYs"); + png_debug1(1, "in %s retrieval function", "pHYs"); if (res_x != NULL) { *res_x = info_ptr->x_pixels_per_unit; retval |= PNG_INFO_pHYs; @@ -695,12 +695,12 @@ { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) && palette != NULL) { - png_debug1(1, "in %s retrieval function\n", "PLTE"); + png_debug1(1, "in %s retrieval function", "PLTE"); *palette = info_ptr->palette; *num_palette = info_ptr->num_palette; - png_debug1(3, "num_palette = %d\n", *num_palette); + png_debug1(3, "num_palette = %d", *num_palette); return (PNG_INFO_PLTE); } return (0); } @@ -711,9 +711,9 @@ { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) && sig_bit != NULL) { - png_debug1(1, "in %s retrieval function\n", "sBIT"); + png_debug1(1, "in %s retrieval function", "sBIT"); *sig_bit = &(info_ptr->sig_bit); return (PNG_INFO_sBIT); } return (0); @@ -726,9 +726,9 @@ int *num_text) { if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) { - png_debug1(1, "in %s retrieval function\n", + png_debug1(1, "in %s retrieval function", (png_ptr->chunk_name[0] == '\0' ? "text" : (png_const_charp)png_ptr->chunk_name)); if (text_ptr != NULL) *text_ptr = info_ptr->text; @@ -748,9 +748,9 @@ { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) && mod_time != NULL) { - png_debug1(1, "in %s retrieval function\n", "tIME"); + png_debug1(1, "in %s retrieval function", "tIME"); *mod_time = &(info_ptr->mod_time); return (PNG_INFO_tIME); } return (0); @@ -764,9 +764,9 @@ { png_uint_32 retval = 0; if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) { - png_debug1(1, "in %s retrieval function\n", "tRNS"); + png_debug1(1, "in %s retrieval function", "tRNS"); if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { if (trans != NULL) { diff -ru4NwbB libpng-1.2.33/pngread.c libpng-1.2.34beta04/pngread.c --- libpng-1.2.33/pngread.c 2008-10-31 08:42:01.918024689 -0500 +++ libpng-1.2.34beta04/pngread.c 2008-12-01 11:56:05.886390716 -0600 @@ -46,9 +46,9 @@ #endif int i; - png_debug(1, "in png_create_read_struct\n"); + png_debug(1, "in png_create_read_struct"); #ifdef PNG_USER_MEM_SUPPORTED png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); #else @@ -262,9 +262,9 @@ #endif } } while (png_libpng_ver[i++]); - png_debug(1, "in png_read_init_3\n"); + png_debug(1, "in png_read_init_3"); #ifdef PNG_SETJMP_SUPPORTED /* save jump buffer and error functions */ png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf)); @@ -326,9 +326,9 @@ void PNGAPI png_read_info(png_structp png_ptr, png_infop info_ptr) { if (png_ptr == NULL || info_ptr == NULL) return; - png_debug(1, "in png_read_info\n"); + png_debug(1, "in png_read_info"); /* If we haven't checked all of the PNG signature bytes, do so now. */ if (png_ptr->sig_bytes < 8) { png_size_t num_checked = png_ptr->sig_bytes, @@ -532,9 +532,9 @@ /* optional call to update the users info_ptr structure */ void PNGAPI png_read_update_info(png_structp png_ptr, png_infop info_ptr) { - png_debug(1, "in png_read_update_info\n"); + png_debug(1, "in png_read_update_info"); if (png_ptr == NULL) return; if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); else @@ -551,9 +551,9 @@ */ void PNGAPI png_start_read_image(png_structp png_ptr) { - png_debug(1, "in png_start_read_image\n"); + png_debug(1, "in png_start_read_image"); if (png_ptr == NULL) return; if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); } @@ -570,9 +570,9 @@ PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; #endif int ret; if (png_ptr == NULL) return; - png_debug2(1, "in png_read_row (row %lu, pass %d)\n", + png_debug2(1, "in png_read_row (row %lu, pass %d)", png_ptr->row_number, png_ptr->pass); if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); if (png_ptr->row_number == 0 && png_ptr->pass == 0) @@ -821,9 +821,9 @@ png_uint_32 i; png_bytepp rp; png_bytepp dp; - png_debug(1, "in png_read_rows\n"); + png_debug(1, "in png_read_rows"); if (png_ptr == NULL) return; rp = row; dp = display_row; if (rp != NULL && dp != NULL) @@ -870,9 +870,9 @@ png_uint_32 i, image_height; int pass, j; png_bytepp rp; - png_debug(1, "in png_read_image\n"); + png_debug(1, "in png_read_image"); if (png_ptr == NULL) return; #ifdef PNG_READ_INTERLACING_SUPPORTED pass = png_set_interlace_handling(png_ptr); @@ -906,9 +906,9 @@ */ void PNGAPI png_read_end(png_structp png_ptr, png_infop info_ptr) { - png_debug(1, "in png_read_end\n"); + png_debug(1, "in png_read_end"); if (png_ptr == NULL) return; png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ do @@ -1086,9 +1086,9 @@ png_free_ptr free_fn = NULL; png_voidp mem_ptr = NULL; #endif - png_debug(1, "in png_destroy_read_struct\n"); + png_debug(1, "in png_destroy_read_struct"); if (png_ptr_ptr != NULL) png_ptr = *png_ptr_ptr; if (png_ptr == NULL) return; @@ -1160,9 +1160,9 @@ #ifdef PNG_USER_MEM_SUPPORTED png_free_ptr free_fn; #endif - png_debug(1, "in png_read_destroy\n"); + png_debug(1, "in png_read_destroy"); if (info_ptr != NULL) png_info_destroy(png_ptr, info_ptr); if (end_info_ptr != NULL) diff -ru4NwbB libpng-1.2.33/pngrio.c libpng-1.2.34beta04/pngrio.c --- libpng-1.2.33/pngrio.c 2008-10-31 08:42:01.923301645 -0500 +++ libpng-1.2.34beta04/pngrio.c 2008-12-01 11:56:05.891486483 -0600 @@ -26,9 +26,9 @@ to read more then 64K on a 16 bit machine. */ void /* PRIVATE */ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { - png_debug1(4, "reading %d bytes\n", (int)length); + png_debug1(4, "reading %d bytes", (int)length); if (png_ptr->read_data_fn != NULL) (*(png_ptr->read_data_fn))(png_ptr, data, length); else png_error(png_ptr, "Call to NULL read function"); diff -ru4NwbB libpng-1.2.33/pngrtran.c libpng-1.2.34beta04/pngrtran.c --- libpng-1.2.33/pngrtran.c 2008-10-31 08:42:01.936847609 -0500 +++ libpng-1.2.34beta04/pngrtran.c 2008-12-01 11:56:05.905045679 -0600 @@ -20,9 +20,9 @@ /* Set the action on getting a CRC error for an ancillary or critical chunk. */ void PNGAPI png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) { - png_debug(1, "in png_set_crc_action\n"); + png_debug(1, "in png_set_crc_action"); /* Tell libpng how we react to CRC errors in critical chunks */ if (png_ptr == NULL) return; switch (crit_action) { @@ -79,9 +79,9 @@ png_set_background(png_structp png_ptr, png_color_16p background_color, int background_gamma_code, int need_expand, double background_gamma) { - png_debug(1, "in png_set_background\n"); + png_debug(1, "in png_set_background"); if (png_ptr == NULL) return; if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN) { png_warning(png_ptr, "Application must supply a known background gamma"); @@ -101,9 +101,9 @@ /* strip 16 bit depth files to 8 bit depth */ void PNGAPI png_set_strip_16(png_structp png_ptr) { - png_debug(1, "in png_set_strip_16\n"); + png_debug(1, "in png_set_strip_16"); if (png_ptr == NULL) return; png_ptr->transformations |= PNG_16_TO_8; } #endif @@ -111,9 +111,9 @@ #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) void PNGAPI png_set_strip_alpha(png_structp png_ptr) { - png_debug(1, "in png_set_strip_alpha\n"); + png_debug(1, "in png_set_strip_alpha"); if (png_ptr == NULL) return; png_ptr->flags |= PNG_FLAG_STRIP_ALPHA; } #endif @@ -141,9 +141,9 @@ png_set_dither(png_structp png_ptr, png_colorp palette, int num_palette, int maximum_colors, png_uint_16p histogram, int full_dither) { - png_debug(1, "in png_set_dither\n"); + png_debug(1, "in png_set_dither"); if (png_ptr == NULL) return; png_ptr->transformations |= PNG_DITHER; if (!full_dither) @@ -525,9 +525,9 @@ */ void PNGAPI png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) { - png_debug(1, "in png_set_gamma\n"); + png_debug(1, "in png_set_gamma"); if (png_ptr == NULL) return; if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) || (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) || (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) @@ -544,9 +544,9 @@ */ void PNGAPI png_set_expand(png_structp png_ptr) { - png_debug(1, "in png_set_expand\n"); + png_debug(1, "in png_set_expand"); if (png_ptr == NULL) return; png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); png_ptr->flags &= ~PNG_FLAG_ROW_INIT; } @@ -571,9 +571,9 @@ /* Expand paletted images to RGB. */ void PNGAPI png_set_palette_to_rgb(png_structp png_ptr) { - png_debug(1, "in png_set_palette_to_rgb\n"); + png_debug(1, "in png_set_palette_to_rgb"); if (png_ptr == NULL) return; png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); png_ptr->flags &= ~PNG_FLAG_ROW_INIT; } @@ -582,9 +582,9 @@ /* Expand grayscale images of less than 8-bit depth to 8 bits. */ void PNGAPI png_set_expand_gray_1_2_4_to_8(png_structp png_ptr) { - png_debug(1, "in png_set_expand_gray_1_2_4_to_8\n"); + png_debug(1, "in png_set_expand_gray_1_2_4_to_8"); if (png_ptr == NULL) return; png_ptr->transformations |= PNG_EXPAND; png_ptr->flags &= ~PNG_FLAG_ROW_INIT; } @@ -595,9 +595,9 @@ /* Deprecated as of libpng-1.2.9 */ void PNGAPI png_set_gray_1_2_4_to_8(png_structp png_ptr) { - png_debug(1, "in png_set_gray_1_2_4_to_8\n"); + png_debug(1, "in png_set_gray_1_2_4_to_8"); if (png_ptr == NULL) return; png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); } #endif @@ -606,9 +606,9 @@ /* Expand tRNS chunks to alpha channels. */ void PNGAPI png_set_tRNS_to_alpha(png_structp png_ptr) { - png_debug(1, "in png_set_tRNS_to_alpha\n"); + png_debug(1, "in png_set_tRNS_to_alpha"); png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); png_ptr->flags &= ~PNG_FLAG_ROW_INIT; } #endif /* defined(PNG_READ_EXPAND_SUPPORTED) */ @@ -616,9 +616,9 @@ #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) void PNGAPI png_set_gray_to_rgb(png_structp png_ptr) { - png_debug(1, "in png_set_gray_to_rgb\n"); + png_debug(1, "in png_set_gray_to_rgb"); png_ptr->transformations |= PNG_GRAY_TO_RGB; png_ptr->flags &= ~PNG_FLAG_ROW_INIT; } #endif @@ -643,9 +643,9 @@ void PNGAPI png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, png_fixed_point red, png_fixed_point green) { - png_debug(1, "in png_set_rgb_to_gray\n"); + png_debug(1, "in png_set_rgb_to_gray"); if (png_ptr == NULL) return; switch(error_action) { case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY; @@ -696,9 +696,9 @@ void PNGAPI png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr read_user_transform_fn) { - png_debug(1, "in png_set_read_user_transform_fn\n"); + png_debug(1, "in png_set_read_user_transform_fn"); if (png_ptr == NULL) return; #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) png_ptr->transformations |= PNG_USER_TRANSFORM; png_ptr->read_user_transform_fn = read_user_transform_fn; @@ -716,9 +716,9 @@ */ void /* PRIVATE */ png_init_read_transformations(png_structp png_ptr) { - png_debug(1, "in png_init_read_transformations\n"); + png_debug(1, "in png_init_read_transformations"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (png_ptr != NULL) #endif { @@ -1123,9 +1123,9 @@ */ void /* PRIVATE */ png_read_transform_info(png_structp png_ptr, png_infop info_ptr) { - png_debug(1, "in png_read_transform_info\n"); + png_debug(1, "in png_read_transform_info"); #if defined(PNG_READ_EXPAND_SUPPORTED) if (png_ptr->transformations & PNG_EXPAND) { if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) @@ -1267,9 +1267,9 @@ */ void /* PRIVATE */ png_do_read_transformations(png_structp png_ptr) { - png_debug(1, "in png_do_read_transformations\n"); + png_debug(1, "in png_do_read_transformations"); if (png_ptr->row_buf == NULL) { #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) char msg[50]; @@ -1513,9 +1513,9 @@ */ void /* PRIVATE */ png_do_unpack(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_unpack\n"); + png_debug(1, "in png_do_unpack"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL && row_info->bit_depth < 8) #else if (row_info->bit_depth < 8) @@ -1603,9 +1603,9 @@ */ void /* PRIVATE */ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) { - png_debug(1, "in png_do_unshift\n"); + png_debug(1, "in png_do_unshift"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && sig_bits != NULL && #endif @@ -1709,9 +1709,9 @@ /* chop rows of bit depth 16 down to 8 */ void /* PRIVATE */ png_do_chop(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_chop\n"); + png_debug(1, "in png_do_chop"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL && row_info->bit_depth == 16) #else if (row_info->bit_depth == 16) @@ -1763,9 +1763,9 @@ #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) void /* PRIVATE */ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_read_swap_alpha\n"); + png_debug(1, "in png_do_read_swap_alpha"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif { @@ -1855,9 +1855,9 @@ #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) void /* PRIVATE */ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_read_invert_alpha\n"); + png_debug(1, "in png_do_read_invert_alpha"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif { @@ -1961,9 +1961,9 @@ png_byte hi_filler = (png_byte)((filler>>8) & 0xff); png_byte lo_filler = (png_byte)(filler & 0xff); - png_debug(1, "in png_do_read_filler\n"); + png_debug(1, "in png_do_read_filler"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif @@ -2133,9 +2133,9 @@ { png_uint_32 i; png_uint_32 row_width = row_info->width; - png_debug(1, "in png_do_gray_to_rgb\n"); + png_debug(1, "in png_do_gray_to_rgb"); if (row_info->bit_depth >= 8 && #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif @@ -2239,9 +2239,9 @@ png_uint_32 row_width = row_info->width; int rgb_error = 0; - png_debug(1, "in png_do_rgb_to_gray\n"); + png_debug(1, "in png_do_rgb_to_gray"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif @@ -2477,9 +2477,9 @@ int color_inc; int i; int v; - png_debug(1, "in png_do_build_grayscale_palette\n"); + png_debug(1, "in png_do_build_grayscale_palette"); if (palette == NULL) return; switch (bit_depth) @@ -2519,9 +2519,9 @@ void /* PRIVATE */ png_correct_palette(png_structp png_ptr, png_colorp palette, int num_palette) { - png_debug(1, "in png_correct_palette\n"); + png_debug(1, "in png_correct_palette"); #if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND)) { @@ -2716,9 +2716,9 @@ png_uint_32 i; png_uint_32 row_width=row_info->width; int shift; - png_debug(1, "in png_do_background\n"); + png_debug(1, "in png_do_background"); if (background != NULL && #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif @@ -3398,9 +3398,9 @@ png_bytep sp; png_uint_32 i; png_uint_32 row_width=row_info->width; - png_debug(1, "in png_do_gamma\n"); + png_debug(1, "in png_do_gamma"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif @@ -3580,9 +3580,9 @@ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width=row_info->width; - png_debug(1, "in png_do_expand_palette\n"); + png_debug(1, "in png_do_expand_palette"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif @@ -3723,9 +3723,9 @@ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width=row_info->width; - png_debug(1, "in png_do_expand\n"); + png_debug(1, "in png_do_expand"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif { @@ -3929,9 +3929,9 @@ png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width=row_info->width; - png_debug(1, "in png_do_dither\n"); + png_debug(1, "in png_do_dither"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif { @@ -4024,9 +4024,9 @@ */ void /* PRIVATE */ png_build_gamma_table(png_structp png_ptr) { - png_debug(1, "in png_build_gamma_table\n"); + png_debug(1, "in png_build_gamma_table"); if (png_ptr->bit_depth <= 8) { int i; @@ -4237,9 +4237,9 @@ /* undoes intrapixel differencing */ void /* PRIVATE */ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_read_intrapixel\n"); + png_debug(1, "in png_do_read_intrapixel"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif diff -ru4NwbB libpng-1.2.33/pngrutil.c libpng-1.2.34beta04/pngrutil.c --- libpng-1.2.33/pngrutil.c 2008-10-31 08:42:01.948395150 -0500 +++ libpng-1.2.34beta04/pngrutil.c 2008-12-01 11:56:05.916871462 -0600 @@ -1,8 +1,8 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.2.33 [December 1, 2008] + * Last changed in libpng 1.2.34 [December 1, 2008] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -114,9 +114,9 @@ /* put the chunk name into png_ptr->chunk_name */ png_memcpy(png_ptr->chunk_name, buf + 4, 4); - png_debug2(0, "Reading %s chunk, length = %lu\n", + png_debug2(0, "Reading %s chunk, length = %lu", png_ptr->chunk_name, length); /* reset the crc and run it over the chunk name */ png_reset_crc(png_ptr); @@ -391,9 +391,9 @@ png_uint_32 width, height; int bit_depth, color_type, compression_type, filter_type; int interlace_type; - png_debug(1, "in png_handle_IHDR\n"); + png_debug(1, "in png_handle_IHDR"); if (png_ptr->mode & PNG_HAVE_IHDR) png_error(png_ptr, "Out of place IHDR"); @@ -446,11 +446,11 @@ /* set up other useful info */ png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * png_ptr->channels); png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width); - png_debug1(3, "bit_depth = %d\n", png_ptr->bit_depth); - png_debug1(3, "channels = %d\n", png_ptr->channels); - png_debug1(3, "rowbytes = %lu\n", png_ptr->rowbytes); + png_debug1(3, "bit_depth = %d", png_ptr->bit_depth); + png_debug1(3, "channels = %d", png_ptr->channels); + png_debug1(3, "rowbytes = %lu", png_ptr->rowbytes); png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, color_type, interlace_type, compression_type, filter_type); } @@ -463,9 +463,9 @@ #ifndef PNG_NO_POINTER_INDEXING png_colorp pal_ptr; #endif - png_debug(1, "in png_handle_PLTE\n"); + png_debug(1, "in png_handle_PLTE"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before PLTE"); else if (png_ptr->mode & PNG_HAVE_IDAT) @@ -595,9 +595,9 @@ void /* PRIVATE */ png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_debug(1, "in png_handle_IEND\n"); + png_debug(1, "in png_handle_IEND"); if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT)) { png_error(png_ptr, "No image in file"); @@ -623,9 +623,9 @@ float file_gamma; #endif png_byte buf[4]; - png_debug(1, "in png_handle_gAMA\n"); + png_debug(1, "in png_handle_gAMA"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before gAMA"); else if (png_ptr->mode & PNG_HAVE_IDAT) @@ -675,9 +675,9 @@ { png_warning(png_ptr, "Ignoring incorrect gAMA value when sRGB is also present"); #ifndef PNG_NO_CONSOLE_IO - fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma); + fprintf(stderr, "gamma = (%d/100000)", (int)igamma); #endif return; } #endif /* PNG_READ_sRGB_SUPPORTED */ @@ -701,9 +701,9 @@ { png_size_t truelen; png_byte buf[4]; - png_debug(1, "in png_handle_sBIT\n"); + png_debug(1, "in png_handle_sBIT"); buf[0] = buf[1] = buf[2] = buf[3] = 0; if (!(png_ptr->mode & PNG_HAVE_IHDR)) @@ -773,9 +773,9 @@ int_y_green, int_x_blue, int_y_blue; png_uint_32 uint_x, uint_y; - png_debug(1, "in png_handle_cHRM\n"); + png_debug(1, "in png_handle_cHRM"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before cHRM"); else if (png_ptr->mode & PNG_HAVE_IDAT) @@ -811,44 +811,23 @@ return; uint_x = png_get_uint_32(buf); uint_y = png_get_uint_32(buf + 4); - if (uint_x > 80000L || uint_y > 80000L || - uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM white point"); - return; - } int_x_white = (png_fixed_point)uint_x; int_y_white = (png_fixed_point)uint_y; uint_x = png_get_uint_32(buf + 8); uint_y = png_get_uint_32(buf + 12); - if (uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM red point"); - return; - } int_x_red = (png_fixed_point)uint_x; int_y_red = (png_fixed_point)uint_y; uint_x = png_get_uint_32(buf + 16); uint_y = png_get_uint_32(buf + 20); - if (uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM green point"); - return; - } int_x_green = (png_fixed_point)uint_x; int_y_green = (png_fixed_point)uint_y; uint_x = png_get_uint_32(buf + 24); uint_y = png_get_uint_32(buf + 28); - if (uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM blue point"); - return; - } int_x_blue = (png_fixed_point)uint_x; int_y_blue = (png_fixed_point)uint_y; #ifdef PNG_FLOATING_POINT_SUPPORTED @@ -912,9 +891,9 @@ { int intent; png_byte buf[1]; - png_debug(1, "in png_handle_sRGB\n"); + png_debug(1, "in png_handle_sRGB"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before sRGB"); else if (png_ptr->mode & PNG_HAVE_IDAT) @@ -1015,9 +994,9 @@ png_uint_32 skip = 0; png_uint_32 profile_size, profile_length; png_size_t slength, prefix_length, data_length; - png_debug(1, "in png_handle_iCCP\n"); + png_debug(1, "in png_handle_iCCP"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before iCCP"); else if (png_ptr->mode & PNG_HAVE_IDAT) @@ -1136,9 +1115,9 @@ int data_length, entry_size, i; png_uint_32 skip = 0; png_size_t slength; - png_debug(1, "in png_handle_sPLT\n"); + png_debug(1, "in png_handle_sPLT"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before sPLT"); else if (png_ptr->mode & PNG_HAVE_IDAT) @@ -1272,9 +1251,9 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte readbuf[PNG_MAX_PALETTE_LENGTH]; - png_debug(1, "in png_handle_tRNS\n"); + png_debug(1, "in png_handle_tRNS"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before tRNS"); else if (png_ptr->mode & PNG_HAVE_IDAT) @@ -1368,9 +1347,9 @@ { png_size_t truelen; png_byte buf[6]; - png_debug(1, "in png_handle_bKGD\n"); + png_debug(1, "in png_handle_bKGD"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before bKGD"); else if (png_ptr->mode & PNG_HAVE_IDAT) @@ -1419,9 +1398,9 @@ { png_ptr->background.index = buf[0]; if (info_ptr && info_ptr->num_palette) { - if (buf[0] > info_ptr->num_palette) + if (buf[0] >= info_ptr->num_palette) { png_warning(png_ptr, "Incorrect bKGD chunk index value"); return; } @@ -1457,9 +1436,9 @@ { unsigned int num, i; png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH]; - png_debug(1, "in png_handle_hIST\n"); + png_debug(1, "in png_handle_hIST"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before hIST"); else if (png_ptr->mode & PNG_HAVE_IDAT) @@ -1512,9 +1491,9 @@ png_byte buf[9]; png_uint_32 res_x, res_y; int unit_type; - png_debug(1, "in png_handle_pHYs\n"); + png_debug(1, "in png_handle_pHYs"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before pHYs"); else if (png_ptr->mode & PNG_HAVE_IDAT) @@ -1555,9 +1534,9 @@ png_byte buf[9]; png_int_32 offset_x, offset_y; int unit_type; - png_debug(1, "in png_handle_oFFs\n"); + png_debug(1, "in png_handle_oFFs"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before oFFs"); else if (png_ptr->mode & PNG_HAVE_IDAT) @@ -1602,9 +1581,9 @@ png_charpp params; png_size_t slength; int i; - png_debug(1, "in png_handle_pCAL\n"); + png_debug(1, "in png_handle_pCAL"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before pCAL"); else if (png_ptr->mode & PNG_HAVE_IDAT) @@ -1619,9 +1598,9 @@ png_crc_finish(png_ptr, length); return; } - png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n", + png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)", length + 1); png_free(png_ptr, png_ptr->chunkdata); png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); if (png_ptr->chunkdata == NULL) @@ -1640,9 +1619,9 @@ } png_ptr->chunkdata[slength] = 0x00; /* null terminate the last string */ - png_debug(3, "Finding end of pCAL purpose string\n"); + png_debug(3, "Finding end of pCAL purpose string"); for (buf = png_ptr->chunkdata; *buf; buf++) /* empty loop */ ; endptr = png_ptr->chunkdata + slength; @@ -1656,16 +1635,16 @@ png_ptr->chunkdata = NULL; return; } - png_debug(3, "Reading pCAL X0, X1, type, nparams, and units\n"); + png_debug(3, "Reading pCAL X0, X1, type, nparams, and units"); X0 = png_get_int_32((png_bytep)buf+1); X1 = png_get_int_32((png_bytep)buf+5); type = buf[9]; nparams = buf[10]; units = buf + 11; - png_debug(3, "Checking pCAL equation type and number of parameters\n"); + png_debug(3, "Checking pCAL equation type and number of parameters"); /* Check that we have the right number of parameters for known equation types. */ if ((type == PNG_EQUATION_LINEAR && nparams != 2) || (type == PNG_EQUATION_BASE_E && nparams != 3) || @@ -1684,9 +1663,9 @@ for (buf = units; *buf; buf++) /* Empty loop to move past the units string. */ ; - png_debug(3, "Allocating pCAL parameters array\n"); + png_debug(3, "Allocating pCAL parameters array"); params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams * png_sizeof(png_charp))) ; if (params == NULL) { @@ -1700,9 +1679,9 @@ for (i = 0; i < (int)nparams; i++) { buf++; /* Skip the null string terminator from previous parameter. */ - png_debug1(3, "Reading pCAL parameter %d\n", i); + png_debug1(3, "Reading pCAL parameter %d", i); for (params[i] = buf; buf <= endptr && *buf != 0x00; buf++) /* Empty loop to move past each parameter string */ ; /* Make sure we haven't run out of data yet */ @@ -1740,9 +1719,9 @@ #endif #endif png_size_t slength; - png_debug(1, "in png_handle_sCAL\n"); + png_debug(1, "in png_handle_sCAL"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before sCAL"); else if (png_ptr->mode & PNG_HAVE_IDAT) @@ -1757,9 +1736,9 @@ png_crc_finish(png_ptr, length); return; } - png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n", + png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)", length + 1); png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); if (png_ptr->chunkdata == NULL) { @@ -1874,9 +1853,9 @@ { png_byte buf[7]; png_time mod_time; - png_debug(1, "in png_handle_tIME\n"); + png_debug(1, "in png_handle_tIME"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Out of place tIME chunk"); else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)) @@ -1922,9 +1901,9 @@ png_uint_32 skip = 0; png_size_t slength; int ret; - png_debug(1, "in png_handle_tEXt\n"); + png_debug(1, "in png_handle_tEXt"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before tEXt"); @@ -2005,9 +1984,9 @@ int comp_type; int ret; png_size_t slength, prefix_len, data_len; - png_debug(1, "in png_handle_zTXt\n"); + png_debug(1, "in png_handle_zTXt"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before zTXt"); if (png_ptr->mode & PNG_HAVE_IDAT) @@ -2108,9 +2087,9 @@ int comp_type = 0; int ret; png_size_t slength, prefix_len, data_len; - png_debug(1, "in png_handle_iTXt\n"); + png_debug(1, "in png_handle_iTXt"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before iTXt"); @@ -2234,9 +2213,9 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_uint_32 skip = 0; - png_debug(1, "in png_handle_unknown\n"); + png_debug(1, "in png_handle_unknown"); if (png_ptr->mode & PNG_HAVE_IDAT) { #ifdef PNG_USE_LOCAL_ARRAYS @@ -2329,9 +2308,9 @@ void /* PRIVATE */ png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name) { - png_debug(1, "in png_check_chunk_name\n"); + png_debug(1, "in png_check_chunk_name"); if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) || isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3])) { png_chunk_error(png_ptr, "invalid chunk type"); @@ -2351,9 +2330,9 @@ void /* PRIVATE */ png_combine_row(png_structp png_ptr, png_bytep row, int mask) { - png_debug(1, "in png_combine_row\n"); + png_debug(1, "in png_combine_row"); if (mask == 0xff) { png_memcpy(row, png_ptr->row_buf + 1, PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->width)); @@ -2567,9 +2546,9 @@ /* offset to next interlace block */ PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; #endif - png_debug(1, "in png_do_read_interlace\n"); + png_debug(1, "in png_do_read_interlace"); if (row != NULL && row_info != NULL) { png_uint_32 final_width; @@ -2780,10 +2759,10 @@ void /* PRIVATE */ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter) { - png_debug(1, "in png_read_filter_row\n"); - png_debug2(2, "row = %lu, filter = %d\n", png_ptr->row_number, filter); + png_debug(1, "in png_read_filter_row"); + png_debug2(2, "row = %lu, filter = %d", png_ptr->row_number, filter); switch (filter) { case PNG_FILTER_VALUE_NONE: break; @@ -2920,9 +2899,9 @@ PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif /* PNG_READ_INTERLACING_SUPPORTED */ #endif - png_debug(1, "in png_read_finish_row\n"); + png_debug(1, "in png_read_finish_row"); png_ptr->row_number++; if (png_ptr->row_number < png_ptr->num_rows) return; @@ -3055,9 +3034,9 @@ int max_pixel_depth; png_size_t row_bytes; - png_debug(1, "in png_read_start_row\n"); + png_debug(1, "in png_read_start_row"); png_ptr->zstream.avail_in = 0; png_init_read_transformations(png_ptr); #ifdef PNG_READ_INTERLACING_SUPPORTED if (png_ptr->interlaced) @@ -3221,14 +3200,14 @@ } png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - png_debug1(3, "width = %lu,\n", png_ptr->width); - png_debug1(3, "height = %lu,\n", png_ptr->height); - png_debug1(3, "iwidth = %lu,\n", png_ptr->iwidth); - png_debug1(3, "num_rows = %lu\n", png_ptr->num_rows); - png_debug1(3, "rowbytes = %lu,\n", png_ptr->rowbytes); - png_debug1(3, "irowbytes = %lu,\n", png_ptr->irowbytes); + png_debug1(3, "width = %lu,", png_ptr->width); + png_debug1(3, "height = %lu,", png_ptr->height); + png_debug1(3, "iwidth = %lu,", png_ptr->iwidth); + png_debug1(3, "num_rows = %lu", png_ptr->num_rows); + png_debug1(3, "rowbytes = %lu,", png_ptr->rowbytes); + png_debug1(3, "irowbytes = %lu,", png_ptr->irowbytes); png_ptr->flags |= PNG_FLAG_ROW_INIT; } #endif /* PNG_READ_SUPPORTED */ diff -ru4NwbB libpng-1.2.33/pngset.c libpng-1.2.34beta04/pngset.c --- libpng-1.2.33/pngset.c 2008-10-31 08:42:01.956197102 -0500 +++ libpng-1.2.34beta04/pngset.c 2008-12-01 11:56:05.924566051 -0600 @@ -1,8 +1,8 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.2.30 [August 15, 2008] + * Last changed in libpng 1.2.34 [December 1, 2008] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -20,9 +20,9 @@ #if defined(PNG_bKGD_SUPPORTED) void PNGAPI png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) { - png_debug1(1, "in %s storage function\n", "bKGD"); + png_debug1(1, "in %s storage function", "bKGD"); if (png_ptr == NULL || info_ptr == NULL) return; png_memcpy(&(info_ptr->background), background, png_sizeof(png_color_16)); @@ -36,36 +36,11 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr, double white_x, double white_y, double red_x, double red_y, double green_x, double green_y, double blue_x, double blue_y) { - png_debug1(1, "in %s storage function\n", "cHRM"); + png_debug1(1, "in %s storage function", "cHRM"); if (png_ptr == NULL || info_ptr == NULL) return; - if (!(white_x || white_y || red_x || red_y || green_x || green_y || - blue_x || blue_y)) - { - png_warning(png_ptr, - "Ignoring attempt to set all-zero chromaticity values"); - return; - } - if (white_x < 0.0 || white_y < 0.0 || - red_x < 0.0 || red_y < 0.0 || - green_x < 0.0 || green_y < 0.0 || - blue_x < 0.0 || blue_y < 0.0) - { - png_warning(png_ptr, - "Ignoring attempt to set negative chromaticity value"); - return; - } - if (white_x > 21474.83 || white_y > 21474.83 || - red_x > 21474.83 || red_y > 21474.83 || - green_x > 21474.83 || green_y > 21474.83 || - blue_x > 21474.83 || blue_y > 21474.83) - { - png_warning(png_ptr, - "Ignoring attempt to set chromaticity value exceeding 21474.83"); - return; - } info_ptr->x_white = (float)white_x; info_ptr->y_white = (float)white_y; info_ptr->x_red = (float)red_x; @@ -93,41 +68,17 @@ png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, png_fixed_point blue_y) { - png_debug1(1, "in %s storage function\n", "cHRM"); + png_debug1(1, "in %s storage function", "cHRM fixed"); if (png_ptr == NULL || info_ptr == NULL) return; - if (!(white_x || white_y || red_x || red_y || green_x || green_y || - blue_x || blue_y)) - { - png_warning(png_ptr, - "Ignoring attempt to set all-zero chromaticity values"); - return; - } - if (white_x < 0 || white_y < 0 || - red_x < 0 || red_y < 0 || - green_x < 0 || green_y < 0 || - blue_x < 0 || blue_y < 0) - { - png_warning(png_ptr, - "Ignoring attempt to set negative chromaticity value"); - return; - } - if (white_x > (png_fixed_point) PNG_UINT_31_MAX || - white_y > (png_fixed_point) PNG_UINT_31_MAX || - red_x > (png_fixed_point) PNG_UINT_31_MAX || - red_y > (png_fixed_point) PNG_UINT_31_MAX || - green_x > (png_fixed_point) PNG_UINT_31_MAX || - green_y > (png_fixed_point) PNG_UINT_31_MAX || - blue_x > (png_fixed_point) PNG_UINT_31_MAX || - blue_y > (png_fixed_point) PNG_UINT_31_MAX ) +#if !defined(PNG_NO_CHECK_cHRM) + if (png_check_cHRM_fixed(png_ptr, + white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y)) +#endif { - png_warning(png_ptr, - "Ignoring attempt to set chromaticity value exceeding 21474.83"); - return; - } info_ptr->int_x_white = white_x; info_ptr->int_y_white = white_y; info_ptr->int_x_red = red_x; info_ptr->int_y_red = red_y; @@ -146,18 +97,19 @@ info_ptr->y_blue = (float)( blue_y/100000.); #endif info_ptr->valid |= PNG_INFO_cHRM; } -#endif -#endif +} +#endif /* PNG_FIXED_POINT_SUPPORTED */ +#endif /* PNG_cHRM_SUPPORTED */ #if defined(PNG_gAMA_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED void PNGAPI png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) { double gamma; - png_debug1(1, "in %s storage function\n", "gAMA"); + png_debug1(1, "in %s storage function", "gAMA"); if (png_ptr == NULL || info_ptr == NULL) return; /* Check for overflow */ @@ -182,9 +134,9 @@ int_gamma) { png_fixed_point gamma; - png_debug1(1, "in %s storage function\n", "gAMA"); + png_debug1(1, "in %s storage function", "gAMA"); if (png_ptr == NULL || info_ptr == NULL) return; if (int_gamma > (png_fixed_point) PNG_UINT_31_MAX) @@ -219,9 +171,9 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) { int i; - png_debug1(1, "in %s storage function\n", "hIST"); + png_debug1(1, "in %s storage function", "hIST"); if (png_ptr == NULL || info_ptr == NULL) return; if (info_ptr->num_palette == 0 || info_ptr->num_palette > PNG_MAX_PALETTE_LENGTH) @@ -262,9 +214,9 @@ png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_type, int compression_type, int filter_type) { - png_debug1(1, "in %s storage function\n", "IHDR"); + png_debug1(1, "in %s storage function", "IHDR"); if (png_ptr == NULL || info_ptr == NULL) return; /* check for width and height valid values */ @@ -369,9 +321,9 @@ void PNGAPI png_set_oFFs(png_structp png_ptr, png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, int unit_type) { - png_debug1(1, "in %s storage function\n", "oFFs"); + png_debug1(1, "in %s storage function", "oFFs"); if (png_ptr == NULL || info_ptr == NULL) return; info_ptr->x_offset = offset_x; @@ -389,14 +341,14 @@ { png_uint_32 length; int i; - png_debug1(1, "in %s storage function\n", "pCAL"); + png_debug1(1, "in %s storage function", "pCAL"); if (png_ptr == NULL || info_ptr == NULL) return; length = png_strlen(purpose) + 1; - png_debug1(3, "allocating purpose for info (%lu bytes)\n", + png_debug1(3, "allocating purpose for info (%lu bytes)", (unsigned long)length); info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_purpose == NULL) { @@ -404,16 +356,16 @@ return; } png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); - png_debug(3, "storing X0, X1, type, and nparams in info\n"); + png_debug(3, "storing X0, X1, type, and nparams in info"); info_ptr->pcal_X0 = X0; info_ptr->pcal_X1 = X1; info_ptr->pcal_type = (png_byte)type; info_ptr->pcal_nparams = (png_byte)nparams; length = png_strlen(units) + 1; - png_debug1(3, "allocating units for info (%lu bytes)\n", + png_debug1(3, "allocating units for info (%lu bytes)", (unsigned long)length); info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_units == NULL) { @@ -434,9 +386,9 @@ for (i = 0; i < nparams; i++) { length = png_strlen(params[i]) + 1; - png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, + png_debug2(3, "allocating parameter %d for info (%lu bytes)", i, (unsigned long)length); info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_params[i] == NULL) { @@ -458,9 +410,9 @@ void PNGAPI png_set_sCAL(png_structp png_ptr, png_infop info_ptr, int unit, double width, double height) { - png_debug1(1, "in %s storage function\n", "sCAL"); + png_debug1(1, "in %s storage function", "sCAL"); if (png_ptr == NULL || info_ptr == NULL) return; info_ptr->scal_unit = (png_byte)unit; @@ -476,16 +428,16 @@ int unit, png_charp swidth, png_charp sheight) { png_uint_32 length; - png_debug1(1, "in %s storage function\n", "sCAL"); + png_debug1(1, "in %s storage function", "sCAL"); if (png_ptr == NULL || info_ptr == NULL) return; info_ptr->scal_unit = (png_byte)unit; length = png_strlen(swidth) + 1; - png_debug1(3, "allocating unit for info (%u bytes)\n", + png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)length); info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->scal_s_width == NULL) { @@ -495,9 +447,9 @@ } png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); length = png_strlen(sheight) + 1; - png_debug1(3, "allocating unit for info (%u bytes)\n", + png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)length); info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->scal_s_height == NULL) { @@ -521,9 +473,9 @@ void PNGAPI png_set_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type) { - png_debug1(1, "in %s storage function\n", "pHYs"); + png_debug1(1, "in %s storage function", "pHYs"); if (png_ptr == NULL || info_ptr == NULL) return; info_ptr->x_pixels_per_unit = res_x; @@ -537,9 +489,9 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp palette, int num_palette) { - png_debug1(1, "in %s storage function\n", "PLTE"); + png_debug1(1, "in %s storage function", "PLTE"); if (png_ptr == NULL || info_ptr == NULL) return; if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH) @@ -586,9 +538,9 @@ void PNGAPI png_set_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p sig_bit) { - png_debug1(1, "in %s storage function\n", "sBIT"); + png_debug1(1, "in %s storage function", "sBIT"); if (png_ptr == NULL || info_ptr == NULL) return; png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof(png_color_8)); @@ -599,9 +551,9 @@ #if defined(PNG_sRGB_SUPPORTED) void PNGAPI png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) { - png_debug1(1, "in %s storage function\n", "sRGB"); + png_debug1(1, "in %s storage function", "sRGB"); if (png_ptr == NULL || info_ptr == NULL) return; info_ptr->srgb_intent = (png_byte)intent; @@ -623,14 +575,12 @@ #if defined(PNG_cHRM_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; #endif -#ifdef PNG_FIXED_POINT_SUPPORTED png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, int_blue_x, int_blue_y; #endif -#endif - png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM"); + png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM"); if (png_ptr == NULL || info_ptr == NULL) return; png_set_sRGB(png_ptr, info_ptr, intent); @@ -646,9 +596,8 @@ #endif #endif #if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FIXED_POINT_SUPPORTED int_white_x = 31270L; int_white_y = 32900L; int_red_x = 64000L; int_red_y = 33000L; @@ -656,12 +605,8 @@ int_green_y = 60000L; int_blue_x = 15000L; int_blue_y = 6000L; - png_set_cHRM_fixed(png_ptr, info_ptr, - int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, - int_blue_x, int_blue_y); -#endif #ifdef PNG_FLOATING_POINT_SUPPORTED white_x = (float).3127; white_y = (float).3290; red_x = (float).64; @@ -669,13 +614,27 @@ green_x = (float).30; green_y = (float).60; blue_x = (float).15; blue_y = (float).06; +#endif +#if !defined(PNG_NO_CHECK_cHRM) + if (png_check_cHRM_fixed(png_ptr, + int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, + int_green_y, int_blue_x, int_blue_y)) +#endif + { +#ifdef PNG_FIXED_POINT_SUPPORTED + png_set_cHRM_fixed(png_ptr, info_ptr, + int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, + int_green_y, int_blue_x, int_blue_y); +#endif +#ifdef PNG_FLOATING_POINT_SUPPORTED png_set_cHRM(png_ptr, info_ptr, white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); #endif -#endif + } +#endif /* cHRM */ } #endif @@ -688,9 +647,9 @@ png_charp new_iccp_name; png_charp new_iccp_profile; png_uint_32 length; - png_debug1(1, "in %s storage function\n", "iCCP"); + png_debug1(1, "in %s storage function", "iCCP"); if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) return; length = png_strlen(name)+1; @@ -742,9 +701,9 @@ int num_text) { int i; - png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ? + png_debug1(1, "in %s storage function", (png_ptr->chunk_name[0] == '\0' ? "text" : (png_const_charp)png_ptr->chunk_name)); if (png_ptr == NULL || info_ptr == NULL || num_text == 0) return(0); @@ -784,9 +743,9 @@ #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_TEXT; #endif } - png_debug1(3, "allocated %d entries for info_ptr->text\n", + png_debug1(3, "allocated %d entries for info_ptr->text", info_ptr->max_text); } for (i = 0; i < num_text; i++) { @@ -844,9 +803,9 @@ (png_uint_32) (key_len + text_length + lang_len + lang_key_len + 4)); if (textp->key == NULL) return(1); - png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n", + png_debug2(2, "Allocated %lu bytes at %x in png_set_text", (png_uint_32) (key_len + lang_len + lang_key_len + text_length + 4), (int)textp->key); @@ -892,9 +851,9 @@ textp->itxt_length = 0; #endif } info_ptr->num_text++; - png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text); + png_debug1(3, "transferred text chunk %d", info_ptr->num_text); } return(0); } #endif @@ -902,9 +861,9 @@ #if defined(PNG_tIME_SUPPORTED) void PNGAPI png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) { - png_debug1(1, "in %s storage function\n", "tIME"); + png_debug1(1, "in %s storage function", "tIME"); if (png_ptr == NULL || info_ptr == NULL || (png_ptr->mode & PNG_WROTE_tIME)) return; @@ -917,9 +876,9 @@ void PNGAPI png_set_tRNS(png_structp png_ptr, png_infop info_ptr, png_bytep trans, int num_trans, png_color_16p trans_values) { - png_debug1(1, "in %s storage function\n", "tRNS"); + png_debug1(1, "in %s storage function", "tRNS"); if (png_ptr == NULL || info_ptr == NULL) return; if (trans != NULL) @@ -1122,9 +1081,9 @@ png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) { /* This function is deprecated in favor of png_permit_mng_features() and will be removed from libpng-1.3.0 */ - png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n"); + png_debug(1, "in png_permit_empty_plte, DEPRECATED."); if (png_ptr == NULL) return; png_ptr->mng_features_permitted = (png_byte) ((png_ptr->mng_features_permitted & (~PNG_FLAG_MNG_EMPTY_PLTE)) | @@ -1136,9 +1095,9 @@ #if defined(PNG_MNG_FEATURES_SUPPORTED) png_uint_32 PNGAPI png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) { - png_debug(1, "in png_permit_mng_features\n"); + png_debug(1, "in png_permit_mng_features"); if (png_ptr == NULL) return (png_uint_32)0; png_ptr->mng_features_permitted = (png_byte)(mng_features & PNG_ALL_MNG_FEATURES); @@ -1197,9 +1156,9 @@ void PNGAPI png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn) { - png_debug(1, "in png_set_read_user_chunk_fn\n"); + png_debug(1, "in png_set_read_user_chunk_fn"); if (png_ptr == NULL) return; png_ptr->read_user_chunk_fn = read_user_chunk_fn; png_ptr->user_chunk_ptr = user_chunk_ptr; @@ -1209,9 +1168,9 @@ #if defined(PNG_INFO_IMAGE_SUPPORTED) void PNGAPI png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) { - png_debug1(1, "in %s storage function\n", "rows"); + png_debug1(1, "in %s storage function", "rows"); if (png_ptr == NULL || info_ptr == NULL) return; diff -ru4NwbB libpng-1.2.33/pngtest.c libpng-1.2.34beta04/pngtest.c --- libpng-1.2.33/pngtest.c 2008-10-31 08:42:01.964405779 -0500 +++ libpng-1.2.34beta04/pngtest.c 2008-12-01 11:56:05.932894572 -0600 @@ -716,9 +716,9 @@ FCLOSE(fpin); return (1); } - png_debug(0, "Allocating read and write structures\n"); + png_debug(0, "Allocating read and write structures"); #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, @@ -757,18 +757,18 @@ png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error, pngtest_warning); #endif #endif - png_debug(0, "Allocating read_info, write_info and end_info structures\n"); + png_debug(0, "Allocating read_info, write_info and end_info structures"); read_info_ptr = png_create_info_struct(read_ptr); end_info_ptr = png_create_info_struct(read_ptr); #ifdef PNG_WRITE_SUPPORTED write_info_ptr = png_create_info_struct(write_ptr); write_end_info_ptr = png_create_info_struct(write_ptr); #endif #ifdef PNG_SETJMP_SUPPORTED - png_debug(0, "Setting jmpbuf for read struct\n"); + png_debug(0, "Setting jmpbuf for read struct"); #ifdef USE_FAR_KEYWORD if (setjmp(jmpbuf)) #else if (setjmp(png_jmpbuf(read_ptr))) @@ -790,9 +790,9 @@ png_memcpy(png_jmpbuf(read_ptr), jmpbuf, png_sizeof(jmp_buf)); #endif #ifdef PNG_WRITE_SUPPORTED - png_debug(0, "Setting jmpbuf for write struct\n"); + png_debug(0, "Setting jmpbuf for write struct"); #ifdef USE_FAR_KEYWORD if (setjmp(jmpbuf)) #else if (setjmp(png_jmpbuf(write_ptr))) @@ -813,9 +813,9 @@ #endif #endif #endif - png_debug(0, "Initializing input and output streams\n"); + png_debug(0, "Initializing input and output streams"); #if !defined(PNG_NO_STDIO) png_init_io(read_ptr, fpin); # ifdef PNG_WRITE_SUPPORTED png_init_io(write_ptr, fpout); @@ -873,12 +873,12 @@ png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_IF_SAFE, png_bytep_NULL, 0); #endif - png_debug(0, "Reading info struct\n"); + png_debug(0, "Reading info struct"); png_read_info(read_ptr, read_info_ptr); - png_debug(0, "Transferring info struct\n"); + png_debug(0, "Transferring info struct"); { int interlace_type, compression_type, filter_type; if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth, @@ -1076,9 +1076,9 @@ int num_text; if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0) { - png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text); + png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks", num_text); png_set_text(write_ptr, write_info_ptr, text_ptr, num_text); } } #endif @@ -1144,9 +1144,9 @@ } #endif #ifdef PNG_WRITE_SUPPORTED - png_debug(0, "\nWriting info struct\n"); + png_debug(0, "Writing info struct"); /* If we wanted, we could write info in two steps: png_write_info_before_PLTE(write_ptr, write_info_ptr); */ @@ -1187,14 +1187,14 @@ #endif #endif #ifdef SINGLE_ROWBUF_ALLOC - png_debug(0, "\nAllocating row buffer..."); + png_debug(0, "Allocating row buffer..."); row_buf = (png_bytep)png_malloc(read_ptr, png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug1(0, "0x%08lx\n\n", (unsigned long)row_buf); + png_debug1(0, "0x%08lx", (unsigned long)row_buf); #endif /* SINGLE_ROWBUF_ALLOC */ - png_debug(0, "Writing row data\n"); + png_debug(0, "Writing row data"); #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ defined(PNG_WRITE_INTERLACING_SUPPORTED) num_pass = png_set_interlace_handling(read_ptr); @@ -1211,16 +1211,16 @@ t_start = t_stop; #endif for (pass = 0; pass < num_pass; pass++) { - png_debug1(0, "Writing row data for pass %d\n", pass); + png_debug1(0, "Writing row data for pass %d", pass); for (y = 0; y < height; y++) { #ifndef SINGLE_ROWBUF_ALLOC png_debug2(0, "\nAllocating row buffer (pass %d, y = %ld)...", pass, y); row_buf = (png_bytep)png_malloc(read_ptr, png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug2(0, "0x%08lx (%ld bytes)\n", (unsigned long)row_buf, + png_debug2(0, "0x%08lx (%ld bytes)", (unsigned long)row_buf, png_get_rowbytes(read_ptr, read_info_ptr)); #endif /* !SINGLE_ROWBUF_ALLOC */ png_read_rows(read_ptr, (png_bytepp)&row_buf, png_bytepp_NULL, 1); @@ -1238,9 +1238,9 @@ #endif #endif /* PNG_WRITE_SUPPORTED */ #ifndef SINGLE_ROWBUF_ALLOC - png_debug2(0, "Freeing row buffer (pass %d, y = %ld)\n\n", pass, y); + png_debug2(0, "Freeing row buffer (pass %d, y = %ld)", pass, y); png_free(read_ptr, row_buf); row_buf = NULL; #endif /* !SINGLE_ROWBUF_ALLOC */ } @@ -1252,9 +1252,9 @@ #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1); #endif - png_debug(0, "Reading and writing end_info data\n"); + png_debug(0, "Reading and writing end_info data"); png_read_end(read_ptr, end_info_ptr); #if defined(PNG_TEXT_SUPPORTED) { @@ -1262,9 +1262,9 @@ int num_text; if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0) { - png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text); + png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks", num_text); png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text); } } #endif @@ -1322,28 +1322,28 @@ (unsigned long)iwidth, (unsigned long)iheight); } #endif - png_debug(0, "Destroying data structs\n"); + png_debug(0, "Destroying data structs"); #ifdef SINGLE_ROWBUF_ALLOC - png_debug(1, "destroying row_buf for read_ptr\n"); + png_debug(1, "destroying row_buf for read_ptr"); png_free(read_ptr, row_buf); row_buf = NULL; #endif /* SINGLE_ROWBUF_ALLOC */ - png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr\n"); + png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr"); png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); #ifdef PNG_WRITE_SUPPORTED - png_debug(1, "destroying write_end_info_ptr\n"); + png_debug(1, "destroying write_end_info_ptr"); png_destroy_info_struct(write_ptr, &write_end_info_ptr); - png_debug(1, "destroying write_ptr, write_info_ptr\n"); + png_debug(1, "destroying write_ptr, write_info_ptr"); png_destroy_write_struct(&write_ptr, &write_info_ptr); #endif - png_debug(0, "Destruction complete.\n"); + png_debug(0, "Destruction complete."); FCLOSE(fpin); FCLOSE(fpout); - png_debug(0, "Opening files for comparison\n"); + png_debug(0, "Opening files for comparison"); #if defined(_WIN32_WCE) MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) #else diff -ru4NwbB libpng-1.2.33/pngtrans.c libpng-1.2.34beta04/pngtrans.c --- libpng-1.2.33/pngtrans.c 2008-10-31 08:42:01.971154843 -0500 +++ libpng-1.2.34beta04/pngtrans.c 2008-12-01 11:56:05.939305710 -0600 @@ -16,9 +16,9 @@ /* turn on BGR-to-RGB mapping */ void PNGAPI png_set_bgr(png_structp png_ptr) { - png_debug(1, "in png_set_bgr\n"); + png_debug(1, "in png_set_bgr"); if (png_ptr == NULL) return; png_ptr->transformations |= PNG_BGR; } #endif @@ -27,9 +27,9 @@ /* turn on 16 bit byte swapping */ void PNGAPI png_set_swap(png_structp png_ptr) { - png_debug(1, "in png_set_swap\n"); + png_debug(1, "in png_set_swap"); if (png_ptr == NULL) return; if (png_ptr->bit_depth == 16) png_ptr->transformations |= PNG_SWAP_BYTES; } @@ -39,9 +39,9 @@ /* turn on pixel packing */ void PNGAPI png_set_packing(png_structp png_ptr) { - png_debug(1, "in png_set_packing\n"); + png_debug(1, "in png_set_packing"); if (png_ptr == NULL) return; if (png_ptr->bit_depth < 8) { png_ptr->transformations |= PNG_PACK; @@ -54,9 +54,9 @@ /* turn on packed pixel swapping */ void PNGAPI png_set_packswap(png_structp png_ptr) { - png_debug(1, "in png_set_packswap\n"); + png_debug(1, "in png_set_packswap"); if (png_ptr == NULL) return; if (png_ptr->bit_depth < 8) png_ptr->transformations |= PNG_PACKSWAP; } @@ -65,9 +65,9 @@ #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) void PNGAPI png_set_shift(png_structp png_ptr, png_color_8p true_bits) { - png_debug(1, "in png_set_shift\n"); + png_debug(1, "in png_set_shift"); if (png_ptr == NULL) return; png_ptr->transformations |= PNG_SHIFT; png_ptr->shift = *true_bits; } @@ -77,9 +77,9 @@ defined(PNG_WRITE_INTERLACING_SUPPORTED) int PNGAPI png_set_interlace_handling(png_structp png_ptr) { - png_debug(1, "in png_set_interlace handling\n"); + png_debug(1, "in png_set_interlace handling"); if (png_ptr && png_ptr->interlaced) { png_ptr->transformations |= PNG_INTERLACE; return (7); @@ -97,9 +97,9 @@ */ void PNGAPI png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) { - png_debug(1, "in png_set_filler\n"); + png_debug(1, "in png_set_filler"); if (png_ptr == NULL) return; png_ptr->transformations |= PNG_FILLER; png_ptr->filler = (png_byte)filler; if (filler_loc == PNG_FILLER_AFTER) @@ -130,9 +130,9 @@ /* Added to libpng-1.2.7 */ void PNGAPI png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) { - png_debug(1, "in png_set_add_alpha\n"); + png_debug(1, "in png_set_add_alpha"); if (png_ptr == NULL) return; png_set_filler(png_ptr, filler, filler_loc); png_ptr->transformations |= PNG_ADD_ALPHA; } @@ -144,9 +144,9 @@ defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) void PNGAPI png_set_swap_alpha(png_structp png_ptr) { - png_debug(1, "in png_set_swap_alpha\n"); + png_debug(1, "in png_set_swap_alpha"); if (png_ptr == NULL) return; png_ptr->transformations |= PNG_SWAP_ALPHA; } #endif @@ -155,9 +155,9 @@ defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) void PNGAPI png_set_invert_alpha(png_structp png_ptr) { - png_debug(1, "in png_set_invert_alpha\n"); + png_debug(1, "in png_set_invert_alpha"); if (png_ptr == NULL) return; png_ptr->transformations |= PNG_INVERT_ALPHA; } #endif @@ -165,18 +165,18 @@ #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) void PNGAPI png_set_invert_mono(png_structp png_ptr) { - png_debug(1, "in png_set_invert_mono\n"); + png_debug(1, "in png_set_invert_mono"); if (png_ptr == NULL) return; png_ptr->transformations |= PNG_INVERT_MONO; } /* invert monochrome grayscale data */ void /* PRIVATE */ png_do_invert(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_invert\n"); + png_debug(1, "in png_do_invert"); /* This test removed from libpng version 1.0.13 and 1.2.0: * if (row_info->bit_depth == 1 && */ #if defined(PNG_USELESS_TESTS_SUPPORTED) @@ -229,9 +229,9 @@ /* swaps byte order on 16 bit depth images */ void /* PRIVATE */ png_do_swap(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_swap\n"); + png_debug(1, "in png_do_swap"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif @@ -360,9 +360,9 @@ /* swaps pixel packing order within bytes */ void /* PRIVATE */ png_do_packswap(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_packswap\n"); + png_debug(1, "in png_do_packswap"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif @@ -392,9 +392,9 @@ /* remove filler or alpha byte(s) */ void /* PRIVATE */ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) { - png_debug(1, "in png_do_strip_filler\n"); + png_debug(1, "in png_do_strip_filler"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif { @@ -550,9 +550,9 @@ /* swaps red and blue bytes within a pixel */ void /* PRIVATE */ png_do_bgr(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_bgr\n"); + png_debug(1, "in png_do_bgr"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif @@ -629,9 +629,9 @@ void PNGAPI png_set_user_transform_info(png_structp png_ptr, png_voidp user_transform_ptr, int user_transform_depth, int user_transform_channels) { - png_debug(1, "in png_set_user_transform_info\n"); + png_debug(1, "in png_set_user_transform_info"); if (png_ptr == NULL) return; #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) png_ptr->user_transform_ptr = user_transform_ptr; png_ptr->user_transform_depth = (png_byte)user_transform_depth; diff -ru4NwbB libpng-1.2.33/pngwrite.c libpng-1.2.34beta04/pngwrite.c --- libpng-1.2.33/pngwrite.c 2008-10-31 08:42:01.988445643 -0500 +++ libpng-1.2.34beta04/pngwrite.c 2008-12-01 11:56:05.956742622 -0600 @@ -24,9 +24,9 @@ */ void PNGAPI png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr) { - png_debug(1, "in png_write_info_before_PLTE\n"); + png_debug(1, "in png_write_info_before_PLTE"); if (png_ptr == NULL || info_ptr == NULL) return; if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) { @@ -98,9 +98,9 @@ if (info_ptr->unknown_chunks_num) { png_unknown_chunk *up; - png_debug(5, "writing extra chunks\n"); + png_debug(5, "writing extra chunks"); for (up = info_ptr->unknown_chunks; up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; up++) @@ -129,9 +129,9 @@ #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) int i; #endif - png_debug(1, "in png_write_info\n"); + png_debug(1, "in png_write_info"); if (png_ptr == NULL || info_ptr == NULL) return; @@ -214,9 +214,9 @@ #if defined(PNG_WRITE_TEXT_SUPPORTED) /* Check to see if we need to write text chunks */ for (i = 0; i < info_ptr->num_text; i++) { - png_debug2(2, "Writing header text chunk %d, type %d\n", i, + png_debug2(2, "Writing header text chunk %d, type %d", i, info_ptr->text[i].compression); /* an internationalized chunk? */ if (info_ptr->text[i].compression > 0) { @@ -267,9 +267,9 @@ if (info_ptr->unknown_chunks_num) { png_unknown_chunk *up; - png_debug(5, "writing extra chunks\n"); + png_debug(5, "writing extra chunks"); for (up = info_ptr->unknown_chunks; up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; up++) @@ -295,9 +295,9 @@ */ void PNGAPI png_write_end(png_structp png_ptr, png_infop info_ptr) { - png_debug(1, "in png_write_end\n"); + png_debug(1, "in png_write_end"); if (png_ptr == NULL) return; if (!(png_ptr->mode & PNG_HAVE_IDAT)) png_error(png_ptr, "No IDATs written into file"); @@ -317,9 +317,9 @@ #if defined(PNG_WRITE_TEXT_SUPPORTED) /* loop through comment chunks */ for (i = 0; i < info_ptr->num_text; i++) { - png_debug2(2, "Writing trailer text chunk %d, type %d\n", i, + png_debug2(2, "Writing trailer text chunk %d, type %d", i, info_ptr->text[i].compression); /* an internationalized chunk? */ if (info_ptr->text[i].compression > 0) { @@ -369,9 +369,9 @@ if (info_ptr->unknown_chunks_num) { png_unknown_chunk *up; - png_debug(5, "writing extra chunks\n"); + png_debug(5, "writing extra chunks"); for (up = info_ptr->unknown_chunks; up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; up++) @@ -412,9 +412,9 @@ /* "time.h" functions are not supported on WindowsCE */ void PNGAPI png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime) { - png_debug(1, "in png_convert_from_struct_tm\n"); + png_debug(1, "in png_convert_from_struct_tm"); ptime->year = (png_uint_16)(1900 + ttime->tm_year); ptime->month = (png_byte)(ttime->tm_mon + 1); ptime->day = (png_byte)ttime->tm_mday; ptime->hour = (png_byte)ttime->tm_hour; @@ -426,9 +426,9 @@ png_convert_from_time_t(png_timep ptime, time_t ttime) { struct tm *tbuf; - png_debug(1, "in png_convert_from_time_t\n"); + png_debug(1, "in png_convert_from_time_t"); tbuf = gmtime(&ttime); png_convert_from_struct_tm(ptime, tbuf); } #endif @@ -460,9 +460,9 @@ jmp_buf jmpbuf; #endif #endif int i; - png_debug(1, "in png_create_write_struct\n"); + png_debug(1, "in png_create_write_struct"); #ifdef PNG_USER_MEM_SUPPORTED png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); #else @@ -658,9 +658,9 @@ #endif } } while (png_libpng_ver[i++]); - png_debug(1, "in png_write_init_3\n"); + png_debug(1, "in png_write_init_3"); #ifdef PNG_SETJMP_SUPPORTED /* save jump buffer and error functions */ png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf)); @@ -712,9 +712,9 @@ { png_uint_32 i; /* row counter */ png_bytepp rp; /* row pointer */ - png_debug(1, "in png_write_rows\n"); + png_debug(1, "in png_write_rows"); if (png_ptr == NULL) return; @@ -737,9 +737,9 @@ if (png_ptr == NULL) return; - png_debug(1, "in png_write_image\n"); + png_debug(1, "in png_write_image"); #if defined(PNG_WRITE_INTERLACING_SUPPORTED) /* intialize interlace handling. If image is not interlaced, this will set pass to 1 */ num_pass = png_set_interlace_handling(png_ptr); @@ -762,9 +762,9 @@ png_write_row(png_structp png_ptr, png_bytep row) { if (png_ptr == NULL) return; - png_debug2(1, "in png_write_row (row %ld, pass %d)\n", + png_debug2(1, "in png_write_row (row %ld, pass %d)", png_ptr->row_number, png_ptr->pass); /* initialize transformations and other stuff if first time */ if (png_ptr->row_number == 0 && png_ptr->pass == 0) @@ -876,14 +876,14 @@ png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->row_info.width); - png_debug1(3, "row_info->color_type = %d\n", png_ptr->row_info.color_type); - png_debug1(3, "row_info->width = %lu\n", png_ptr->row_info.width); - png_debug1(3, "row_info->channels = %d\n", png_ptr->row_info.channels); - png_debug1(3, "row_info->bit_depth = %d\n", png_ptr->row_info.bit_depth); - png_debug1(3, "row_info->pixel_depth = %d\n", png_ptr->row_info.pixel_depth); - png_debug1(3, "row_info->rowbytes = %lu\n", png_ptr->row_info.rowbytes); + png_debug1(3, "row_info->color_type = %d", png_ptr->row_info.color_type); + png_debug1(3, "row_info->width = %lu", png_ptr->row_info.width); + png_debug1(3, "row_info->channels = %d", png_ptr->row_info.channels); + png_debug1(3, "row_info->bit_depth = %d", png_ptr->row_info.bit_depth); + png_debug1(3, "row_info->pixel_depth = %d", png_ptr->row_info.pixel_depth); + png_debug1(3, "row_info->rowbytes = %lu", png_ptr->row_info.rowbytes); /* Copy user's row into buffer, leaving room for filter byte. */ png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row, png_ptr->row_info.rowbytes); @@ -937,9 +937,9 @@ /* Set the automatic flush interval or 0 to turn flushing off */ void PNGAPI png_set_flush(png_structp png_ptr, int nrows) { - png_debug(1, "in png_set_flush\n"); + png_debug(1, "in png_set_flush"); if (png_ptr == NULL) return; png_ptr->flush_dist = (nrows < 0 ? 0 : nrows); } @@ -949,9 +949,9 @@ png_write_flush(png_structp png_ptr) { int wrote_IDAT; - png_debug(1, "in png_write_flush\n"); + png_debug(1, "in png_write_flush"); if (png_ptr == NULL) return; /* We have already written out all of the data */ if (png_ptr->row_number >= png_ptr->num_rows) @@ -1009,9 +1009,9 @@ png_free_ptr free_fn = NULL; png_voidp mem_ptr = NULL; #endif - png_debug(1, "in png_destroy_write_struct\n"); + png_debug(1, "in png_destroy_write_struct"); if (png_ptr_ptr != NULL) { png_ptr = *png_ptr_ptr; #ifdef PNG_USER_MEM_SUPPORTED @@ -1083,9 +1083,9 @@ #ifdef PNG_USER_MEM_SUPPORTED png_free_ptr free_fn; #endif - png_debug(1, "in png_write_destroy\n"); + png_debug(1, "in png_write_destroy"); /* free any memory zlib uses */ deflateEnd(&png_ptr->zstream); /* free our memory. png_free checks NULL for us. */ @@ -1140,9 +1140,9 @@ /* Allow the application to select one or more row filters to use. */ void PNGAPI png_set_filter(png_structp png_ptr, int method, int filters) { - png_debug(1, "in png_set_filter\n"); + png_debug(1, "in png_set_filter"); if (png_ptr == NULL) return; #if defined(PNG_MNG_FEATURES_SUPPORTED) if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && @@ -1263,9 +1263,9 @@ png_doublep filter_costs) { int i; - png_debug(1, "in png_set_filter_heuristics\n"); + png_debug(1, "in png_set_filter_heuristics"); if (png_ptr == NULL) return; if (heuristic_method >= PNG_FILTER_HEURISTIC_LAST) { @@ -1377,9 +1377,9 @@ void PNGAPI png_set_compression_level(png_structp png_ptr, int level) { - png_debug(1, "in png_set_compression_level\n"); + png_debug(1, "in png_set_compression_level"); if (png_ptr == NULL) return; png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL; png_ptr->zlib_level = level; @@ -1387,9 +1387,9 @@ void PNGAPI png_set_compression_mem_level(png_structp png_ptr, int mem_level) { - png_debug(1, "in png_set_compression_mem_level\n"); + png_debug(1, "in png_set_compression_mem_level"); if (png_ptr == NULL) return; png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL; png_ptr->zlib_mem_level = mem_level; @@ -1397,9 +1397,9 @@ void PNGAPI png_set_compression_strategy(png_structp png_ptr, int strategy) { - png_debug(1, "in png_set_compression_strategy\n"); + png_debug(1, "in png_set_compression_strategy"); if (png_ptr == NULL) return; png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY; png_ptr->zlib_strategy = strategy; @@ -1428,9 +1428,9 @@ void PNGAPI png_set_compression_method(png_structp png_ptr, int method) { - png_debug(1, "in png_set_compression_method\n"); + png_debug(1, "in png_set_compression_method"); if (png_ptr == NULL) return; if (method != 8) png_warning(png_ptr, "Only compression method 8 is supported by PNG"); @@ -1450,9 +1450,9 @@ void PNGAPI png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr write_user_transform_fn) { - png_debug(1, "in png_set_write_user_transform_fn\n"); + png_debug(1, "in png_set_write_user_transform_fn"); if (png_ptr == NULL) return; png_ptr->transformations |= PNG_USER_TRANSFORM; png_ptr->write_user_transform_fn = write_user_transform_fn; diff -ru4NwbB libpng-1.2.33/pngwtran.c libpng-1.2.34beta04/pngwtran.c --- libpng-1.2.33/pngwtran.c 2008-10-31 08:42:01.994592074 -0500 +++ libpng-1.2.34beta04/pngwtran.c 2008-12-01 11:56:05.963126194 -0600 @@ -17,9 +17,9 @@ */ void /* PRIVATE */ png_do_write_transformations(png_structp png_ptr) { - png_debug(1, "in png_do_write_transformations\n"); + png_debug(1, "in png_do_write_transformations"); if (png_ptr == NULL) return; @@ -85,9 +85,9 @@ */ void /* PRIVATE */ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) { - png_debug(1, "in png_do_pack\n"); + png_debug(1, "in png_do_pack"); if (row_info->bit_depth == 8 && #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif @@ -211,9 +211,9 @@ */ void /* PRIVATE */ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) { - png_debug(1, "in png_do_shift\n"); + png_debug(1, "in png_do_shift"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL && #else if ( @@ -335,9 +335,9 @@ #if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) void /* PRIVATE */ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_write_swap_alpha\n"); + png_debug(1, "in png_do_write_swap_alpha"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif { @@ -423,9 +423,9 @@ #if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) void /* PRIVATE */ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_write_invert_alpha\n"); + png_debug(1, "in png_do_write_invert_alpha"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif { @@ -513,9 +513,9 @@ /* undoes intrapixel differencing */ void /* PRIVATE */ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_write_intrapixel\n"); + png_debug(1, "in png_do_write_intrapixel"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif diff -ru4NwbB libpng-1.2.33/pngwutil.c libpng-1.2.34beta04/pngwutil.c --- libpng-1.2.33/pngwutil.c 2008-10-31 08:42:02.004997503 -0500 +++ libpng-1.2.34beta04/pngwutil.c 2008-12-01 11:56:05.972928391 -0600 @@ -1,8 +1,8 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.2.30 [August 15, 2008] + * Last changed in libpng 1.2.34 [December 1, 2008] * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -95,9 +95,9 @@ png_uint_32 length) { png_byte buf[8]; - png_debug2(0, "Writing %s chunk, length = %lu\n", chunk_name, + png_debug2(0, "Writing %s chunk, length = %lu", chunk_name, (unsigned long)length); if (png_ptr == NULL) return; /* write the length and the chunk name */ @@ -391,9 +391,9 @@ int ret; png_byte buf[13]; /* buffer to store the IHDR info */ - png_debug(1, "in png_write_IHDR\n"); + png_debug(1, "in png_write_IHDR"); /* Check that we have valid input data from the application info */ switch (color_type) { case PNG_COLOR_TYPE_GRAY: @@ -568,9 +568,9 @@ png_uint_32 i; png_colorp pal_ptr; png_byte buf[3]; - png_debug(1, "in png_write_PLTE\n"); + png_debug(1, "in png_write_PLTE"); if (( #if defined(PNG_MNG_FEATURES_SUPPORTED) !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) && #endif @@ -594,9 +594,9 @@ return; } png_ptr->num_palette = (png_uint_16)num_pal; - png_debug1(3, "num_palette = %d\n", png_ptr->num_palette); + png_debug1(3, "num_palette = %d", png_ptr->num_palette); png_write_chunk_start(png_ptr, (png_bytep)png_PLTE, (png_uint_32)(num_pal * 3)); #ifndef PNG_NO_POINTER_INDEXING @@ -628,9 +628,9 @@ { #ifdef PNG_USE_LOCAL_ARRAYS PNG_IDAT; #endif - png_debug(1, "in png_write_IDAT\n"); + png_debug(1, "in png_write_IDAT"); /* Optimize the CMF field in the zlib stream. */ /* This hack of the zlib stream is compliant to the stream specification. */ if (!(png_ptr->mode & PNG_HAVE_IDAT) && @@ -680,9 +680,9 @@ { #ifdef PNG_USE_LOCAL_ARRAYS PNG_IEND; #endif - png_debug(1, "in png_write_IEND\n"); + png_debug(1, "in png_write_IEND"); png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL, (png_size_t)0); png_ptr->mode |= PNG_HAVE_IEND; } @@ -698,9 +698,9 @@ #endif png_uint_32 igamma; png_byte buf[4]; - png_debug(1, "in png_write_gAMA\n"); + png_debug(1, "in png_write_gAMA"); /* file_gamma is saved in 1/100,000ths */ igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5); png_save_uint_32(buf, igamma); png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); @@ -714,9 +714,9 @@ PNG_gAMA; #endif png_byte buf[4]; - png_debug(1, "in png_write_gAMA\n"); + png_debug(1, "in png_write_gAMA"); /* file_gamma is saved in 1/100,000ths */ png_save_uint_32(buf, (png_uint_32)file_gamma); png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); } @@ -732,9 +732,9 @@ PNG_sRGB; #endif png_byte buf[1]; - png_debug(1, "in png_write_sRGB\n"); + png_debug(1, "in png_write_sRGB"); if (srgb_intent >= PNG_sRGB_INTENT_LAST) png_warning(png_ptr, "Invalid sRGB rendering intent specified"); buf[0]=(png_byte)srgb_intent; @@ -755,9 +755,9 @@ png_charp new_name; compression_state comp; int embedded_profile_len = 0; - png_debug(1, "in png_write_iCCP\n"); + png_debug(1, "in png_write_iCCP"); comp.num_output_ptr = 0; comp.max_output_ptr = 0; comp.output_ptr = NULL; @@ -834,9 +834,9 @@ #ifdef PNG_NO_POINTER_INDEXING int i; #endif - png_debug(1, "in png_write_sPLT\n"); + png_debug(1, "in png_write_sPLT"); if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr, spalette->name, &new_name))==0) { png_warning(png_ptr, "Empty keyword in sPLT chunk"); @@ -911,9 +911,9 @@ #endif png_byte buf[4]; png_size_t size; - png_debug(1, "in png_write_sBIT\n"); + png_debug(1, "in png_write_sBIT"); /* make sure we don't depend upon the order of PNG_COLOR_8 */ if (color_type & PNG_COLOR_MASK_COLOR) { png_byte maxbits; @@ -968,58 +968,45 @@ #ifdef PNG_USE_LOCAL_ARRAYS PNG_cHRM; #endif png_byte buf[32]; - png_uint_32 itemp; - png_debug(1, "in png_write_cHRM\n"); - /* each value is saved in 1/100,000ths */ - if (white_x < 0 || white_x > 0.8 || white_y < 0 || white_y > 0.8 || - white_x + white_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM white point specified"); -#if !defined(PNG_NO_CONSOLE_IO) - fprintf(stderr, "white_x=%f, white_y=%f\n", white_x, white_y); -#endif - return; - } - itemp = (png_uint_32)(white_x * 100000.0 + 0.5); - png_save_uint_32(buf, itemp); - itemp = (png_uint_32)(white_y * 100000.0 + 0.5); - png_save_uint_32(buf + 4, itemp); + png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, + int_green_x, int_green_y, int_blue_x, int_blue_y; - if (red_x < 0 || red_y < 0 || red_x + red_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM red point specified"); - return; - } - itemp = (png_uint_32)(red_x * 100000.0 + 0.5); - png_save_uint_32(buf + 8, itemp); - itemp = (png_uint_32)(red_y * 100000.0 + 0.5); - png_save_uint_32(buf + 12, itemp); + png_debug(1, "in png_write_cHRM"); - if (green_x < 0 || green_y < 0 || green_x + green_y > 1.0) + int_white_x = (png_uint_32)(white_x * 100000.0 + 0.5); + int_white_y = (png_uint_32)(white_y * 100000.0 + 0.5); + int_red_x = (png_uint_32)(red_x * 100000.0 + 0.5); + int_red_y = (png_uint_32)(red_y * 100000.0 + 0.5); + int_green_x = (png_uint_32)(green_x * 100000.0 + 0.5); + int_green_y = (png_uint_32)(green_y * 100000.0 + 0.5); + int_blue_x = (png_uint_32)(blue_x * 100000.0 + 0.5); + int_blue_y = (png_uint_32)(blue_y * 100000.0 + 0.5); + +#if !defined(PNG_NO_CHECK_cHRM) + if (png_check_cHRM_fixed(png_ptr, int_white_x, int_white_y, + int_red_x, int_red_y, int_green_x, int_green_y, int_blue_x, int_blue_y)) +#endif { - png_warning(png_ptr, "Invalid cHRM green point specified"); - return; - } - itemp = (png_uint_32)(green_x * 100000.0 + 0.5); - png_save_uint_32(buf + 16, itemp); - itemp = (png_uint_32)(green_y * 100000.0 + 0.5); - png_save_uint_32(buf + 20, itemp); + /* each value is saved in 1/100,000ths */ - if (blue_x < 0 || blue_y < 0 || blue_x + blue_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM blue point specified"); - return; - } - itemp = (png_uint_32)(blue_x * 100000.0 + 0.5); - png_save_uint_32(buf + 24, itemp); - itemp = (png_uint_32)(blue_y * 100000.0 + 0.5); - png_save_uint_32(buf + 28, itemp); + png_save_uint_32(buf, int_white_x); + png_save_uint_32(buf + 4, int_white_y); + + png_save_uint_32(buf + 8, int_red_x); + png_save_uint_32(buf + 12, int_red_y); + + png_save_uint_32(buf + 16, int_green_x); + png_save_uint_32(buf + 20, int_green_y); + + png_save_uint_32(buf + 24, int_blue_x); + png_save_uint_32(buf + 28, int_blue_y); png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); } +} #endif #ifdef PNG_FIXED_POINT_SUPPORTED void /* PRIVATE */ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x, @@ -1031,48 +1018,30 @@ PNG_cHRM; #endif png_byte buf[32]; - png_debug(1, "in png_write_cHRM\n"); + png_debug(1, "in png_write_cHRM"); /* each value is saved in 1/100,000ths */ - if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM white point specified"); -#if !defined(PNG_NO_CONSOLE_IO) - fprintf(stderr, "white_x=%ld, white_y=%ld\n", (unsigned long)white_x, - (unsigned long)white_y); +#if !defined(PNG_NO_CHECK_cHRM) + if (png_check_cHRM_fixed(png_ptr, white_x, white_y, red_x, red_y, + green_x, green_y, blue_x, blue_y)) #endif - return; - } + { png_save_uint_32(buf, (png_uint_32)white_x); png_save_uint_32(buf + 4, (png_uint_32)white_y); - if (red_x + red_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM fixed red point specified"); - return; - } png_save_uint_32(buf + 8, (png_uint_32)red_x); png_save_uint_32(buf + 12, (png_uint_32)red_y); - if (green_x + green_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM green point specified"); - return; - } png_save_uint_32(buf + 16, (png_uint_32)green_x); png_save_uint_32(buf + 20, (png_uint_32)green_y); - if (blue_x + blue_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM blue point specified"); - return; - } png_save_uint_32(buf + 24, (png_uint_32)blue_x); png_save_uint_32(buf + 28, (png_uint_32)blue_y); png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); } +} #endif #endif #if defined(PNG_WRITE_tRNS_SUPPORTED) @@ -1085,9 +1054,9 @@ PNG_tRNS; #endif png_byte buf[6]; - png_debug(1, "in png_write_tRNS\n"); + png_debug(1, "in png_write_tRNS"); if (color_type == PNG_COLOR_TYPE_PALETTE) { if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette) { @@ -1140,17 +1109,17 @@ PNG_bKGD; #endif png_byte buf[6]; - png_debug(1, "in png_write_bKGD\n"); + png_debug(1, "in png_write_bKGD"); if (color_type == PNG_COLOR_TYPE_PALETTE) { if ( #if defined(PNG_MNG_FEATURES_SUPPORTED) (png_ptr->num_palette || (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) && #endif - back->index > png_ptr->num_palette) + back->index >= png_ptr->num_palette) { png_warning(png_ptr, "Invalid background palette index"); return; } @@ -1194,12 +1163,12 @@ #endif int i; png_byte buf[3]; - png_debug(1, "in png_write_hIST\n"); + png_debug(1, "in png_write_hIST"); if (num_hist > (int)png_ptr->num_palette) { - png_debug2(3, "num_hist = %d, num_palette = %d\n", num_hist, + png_debug2(3, "num_hist = %d, num_palette = %d", num_hist, png_ptr->num_palette); png_warning(png_ptr, "Invalid number of histogram entries specified"); return; } @@ -1234,18 +1203,18 @@ png_charp kp, dp; int kflag; int kwarn=0; - png_debug(1, "in png_check_keyword\n"); + png_debug(1, "in png_check_keyword"); *new_key = NULL; if (key == NULL || (key_len = png_strlen(key)) == 0) { png_warning(png_ptr, "zero length keyword"); return ((png_size_t)0); } - png_debug1(2, "Keyword to be checked is '%s'\n", key); + png_debug1(2, "Keyword to be checked is '%s'", key); *new_key = (png_charp)png_malloc_warn(png_ptr, (png_uint_32)(key_len + 2)); if (*new_key == NULL) { @@ -1302,9 +1271,9 @@ key_len--; } } - png_debug1(2, "Checking for multiple internal spaces in '%s'\n", kp); + png_debug1(2, "Checking for multiple internal spaces in '%s'", kp); /* Remove multiple internal spaces. */ for (kflag = 0, dp = *new_key; *kp != '\0'; kp++) { @@ -1337,9 +1306,9 @@ if (key_len > 79) { png_warning(png_ptr, "keyword length must be 1 - 79 characters"); - new_key[79] = '\0'; + (*new_key)[79] = '\0'; key_len = 79; } return (key_len); @@ -1357,9 +1326,9 @@ #endif png_size_t key_len; png_charp new_key; - png_debug(1, "in png_write_tEXt\n"); + png_debug(1, "in png_write_tEXt"); if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) { png_warning(png_ptr, "Empty keyword in tEXt chunk"); return; @@ -1402,9 +1371,9 @@ char buf[1]; png_charp new_key; compression_state comp; - png_debug(1, "in png_write_zTXt\n"); + png_debug(1, "in png_write_zTXt"); comp.num_output_ptr = 0; comp.max_output_ptr = 0; comp.output_ptr = NULL; @@ -1463,9 +1432,9 @@ png_charp new_lang, new_key; png_byte cbuf[2]; compression_state comp; - png_debug(1, "in png_write_iTXt\n"); + png_debug(1, "in png_write_iTXt"); comp.num_output_ptr = 0; comp.max_output_ptr = 0; comp.output_ptr = NULL; @@ -1551,9 +1520,9 @@ PNG_oFFs; #endif png_byte buf[9]; - png_debug(1, "in png_write_oFFs\n"); + png_debug(1, "in png_write_oFFs"); if (unit_type >= PNG_OFFSET_LAST) png_warning(png_ptr, "Unrecognized unit type for oFFs chunk"); png_save_int_32(buf, x_offset); @@ -1577,16 +1546,16 @@ png_byte buf[10]; png_charp new_purpose; int i; - png_debug1(1, "in png_write_pCAL (%d parameters)\n", nparams); + png_debug1(1, "in png_write_pCAL (%d parameters)", nparams); if (type >= PNG_EQUATION_LAST) png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1; - png_debug1(3, "pCAL purpose length = %d\n", (int)purpose_len); + png_debug1(3, "pCAL purpose length = %d", (int)purpose_len); units_len = png_strlen(units) + (nparams == 0 ? 0 : 1); - png_debug1(3, "pCAL units length = %d\n", (int)units_len); + png_debug1(3, "pCAL units length = %d", (int)units_len); total_len = purpose_len + units_len + 10; params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams * png_sizeof(png_uint_32))); @@ -1595,14 +1564,14 @@ null terminator for the last parameter. */ for (i = 0; i < nparams; i++) { params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1); - png_debug2(3, "pCAL parameter %d length = %lu\n", i, + png_debug2(3, "pCAL parameter %d length = %lu", i, (unsigned long) params_len[i]); total_len += (png_size_t)params_len[i]; } - png_debug1(3, "pCAL total length = %d\n", (int)total_len); + png_debug1(3, "pCAL total length = %d", (int)total_len); png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len); png_write_chunk_data(png_ptr, (png_bytep)new_purpose, (png_size_t)purpose_len); png_save_int_32(buf, X0); @@ -1636,9 +1605,9 @@ #endif char buf[64]; png_size_t total_len; - png_debug(1, "in png_write_sCAL\n"); + png_debug(1, "in png_write_sCAL"); buf[0] = (char)unit; #if defined(_WIN32_WCE) /* sprintf() function is not supported on WindowsCE */ @@ -1661,9 +1630,9 @@ png_snprintf(buf + total_len, 64-total_len, "%12.12e", height); total_len += png_strlen(buf + total_len); #endif - png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); + png_debug1(3, "sCAL total length = %u", (unsigned int)total_len); png_write_chunk(png_ptr, (png_bytep)png_sCAL, (png_bytep)buf, total_len); } #else #ifdef PNG_FIXED_POINT_SUPPORTED @@ -1676,9 +1645,9 @@ #endif png_byte buf[64]; png_size_t wlen, hlen, total_len; - png_debug(1, "in png_write_sCAL_s\n"); + png_debug(1, "in png_write_sCAL_s"); wlen = png_strlen(width); hlen = png_strlen(height); total_len = wlen + hlen + 2; @@ -1691,9 +1660,9 @@ buf[0] = (png_byte)unit; png_memcpy(buf + 1, width, wlen + 1); /* append the '\0' here */ png_memcpy(buf + wlen + 2, height, hlen); /* do NOT append the '\0' here */ - png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); + png_debug1(3, "sCAL total length = %u", (unsigned int)total_len); png_write_chunk(png_ptr, (png_bytep)png_sCAL, buf, total_len); } #endif #endif @@ -1710,9 +1679,9 @@ PNG_pHYs; #endif png_byte buf[9]; - png_debug(1, "in png_write_pHYs\n"); + png_debug(1, "in png_write_pHYs"); if (unit_type >= PNG_RESOLUTION_LAST) png_warning(png_ptr, "Unrecognized unit type for pHYs chunk"); png_save_uint_32(buf, x_pixels_per_unit); @@ -1734,9 +1703,9 @@ PNG_tIME; #endif png_byte buf[7]; - png_debug(1, "in png_write_tIME\n"); + png_debug(1, "in png_write_tIME"); if (mod_time->month > 12 || mod_time->month < 1 || mod_time->day > 31 || mod_time->day < 1 || mod_time->hour > 23 || mod_time->second > 60) { @@ -1778,9 +1747,9 @@ #endif png_size_t buf_size; - png_debug(1, "in png_write_start_row\n"); + png_debug(1, "in png_write_start_row"); buf_size = (png_size_t)(PNG_ROWBYTES( png_ptr->usr_channels*png_ptr->usr_bit_depth, png_ptr->width) + 1); /* set up row buffer */ @@ -1878,9 +1847,9 @@ #endif int ret; - png_debug(1, "in png_write_finish_row\n"); + png_debug(1, "in png_write_finish_row"); /* next row */ png_ptr->row_number++; /* see if we are done */ @@ -1987,9 +1956,9 @@ /* offset to next interlace block */ int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; #endif - png_debug(1, "in png_do_write_interlace\n"); + png_debug(1, "in png_do_write_interlace"); /* we don't have to do anything on the last pass (6) */ #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL && pass < 6) #else @@ -2158,9 +2127,9 @@ #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) int num_p_filters = (int)png_ptr->num_prev_filters; #endif - png_debug(1, "in png_write_find_filter\n"); + png_debug(1, "in png_write_find_filter"); /* find out how many bytes offset each pixel is */ bpp = (row_info->pixel_depth + 7) >> 3; prev_row = png_ptr->prev_row; @@ -2767,10 +2736,10 @@ /* Do the actual writing of a previously filtered row. */ void /* PRIVATE */ png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) { - png_debug(1, "in png_write_filtered_row\n"); - png_debug1(2, "filter = %d\n", filtered_row[0]); + png_debug(1, "in png_write_filtered_row"); + png_debug1(2, "filter = %d", filtered_row[0]); /* set up the zlib input buffer */ png_ptr->zstream.next_in = filtered_row; png_ptr->zstream.avail_in = (uInt)png_ptr->row_info.rowbytes + 1;