diff -ru4NwbB libpng-1.5.0/png.c libpng-1.5.1beta06/png.c --- libpng-1.5.0/png.c 2011-01-06 07:02:36.151049472 -0600 +++ libpng-1.5.1beta06/png.c 2011-01-20 15:56:21.011511908 -0600 @@ -1030,12 +1030,12 @@ int png_check_fp_string(png_const_charp string, png_size_t size) { int state=0; - png_size_t index=0; + png_size_t char_index=0; - return png_check_fp_number(string, size, &state, &index) && - (index == size || string[index] == 0); + return png_check_fp_number(string, size, &state, &char_index) && + (char_index == size || string[char_index] == 0); } #endif /* pCAL or sCAL */ #ifdef PNG_READ_sCAL_SUPPORTED @@ -1107,48 +1107,48 @@ } if (fp >= DBL_MIN && fp <= DBL_MAX) { - int exp; /* A base 10 exponent */ - double base; /* 10^exp */ + int exp_b10; /* A base 10 exponent */ + double base; /* 10^exp_b10 */ /* First extract a base 10 exponent of the number, * the calculation below rounds down when converting * from base 2 to base 10 (multiply by log10(2) - - * 0.3010, but 77/256 is 0.3008, so exp needs to + * 0.3010, but 77/256 is 0.3008, so exp_b10 needs to * be increased. Note that the arithmetic shift * performs a floor() unlike C arithmetic - using a * C multiply would break the following for negative * exponents. */ - (void)frexp(fp, &exp); /* exponent to base 2 */ + (void)frexp(fp, &exp_b10); /* exponent to base 2 */ - exp = (exp * 77) >> 8; /* <= exponent to base 10 */ + exp_b10 = (exp_b10 * 77) >> 8; /* <= exponent to base 10 */ /* Avoid underflow here. */ - base = png_pow10(exp); /* May underflow */ + base = png_pow10(exp_b10); /* May underflow */ while (base < DBL_MIN || base < fp) { /* And this may overflow. */ - double test = png_pow10(exp+1); + double test = png_pow10(exp_b10+1); if (test <= DBL_MAX) - ++exp, base = test; + ++exp_b10, base = test; else break; } - /* Normalize fp and correct exp, after this fp is in the - * range [.1,1) and exp is both the exponent and the digit + /* Normalize fp and correct exp_b10, after this fp is in the + * range [.1,1) and exp_b10 is both the exponent and the digit * *before* which the decimal point should be inserted * (starting with 0 for the first digit). Note that this - * works even if 10^exp is out of range because of the + * works even if 10^exp_b10 is out of range because of the * test on DBL_MAX above. */ fp /= base; - while (fp >= 1) fp /= 10, ++exp; + while (fp >= 1) fp /= 10, ++exp_b10; /* Because of the code above fp may, at this point, be * less than .1, this is ok because the code below can * handle the leading zeros this generates, so no attempt @@ -1161,12 +1161,12 @@ /* Allow up to two leading zeros - this will not lengthen * the number compared to using E-n. */ - if (exp < 0 && exp > -3) /* PLUS 3 TOTAL 4 */ + if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */ { - czero = -exp; /* PLUS 2 digits: TOTAL 3 */ - exp = 0; /* Dot added below before first output. */ + czero = -exp_b10; /* PLUS 2 digits: TOTAL 3 */ + exp_b10 = 0; /* Dot added below before first output. */ } else czero = 0; /* No zeros to add */ @@ -1206,19 +1206,19 @@ while (cdigits > 0 && d > 9) { int ch = *--ascii; - if (exp != (-1)) - ++exp; + if (exp_b10 != (-1)) + ++exp_b10; else if (ch == 46) { ch = *--ascii, ++size; - /* Advance exp to '1', so that the + /* Advance exp_b10 to '1', so that the * decimal point happens after the * previous digit. */ - exp = 1; + exp_b10 = 1; } --cdigits; d = ch - 47; /* I.e. 1+(ch-48) */ @@ -1229,25 +1229,25 @@ * decimal point. */ if (d > 9) /* cdigits == 0 */ { - if (exp == (-1)) + if (exp_b10 == (-1)) { /* Leading decimal point (plus zeros?), if * we lose the decimal point here it must * be reentered below. */ int ch = *--ascii; if (ch == 46) - ++size, exp = 1; + ++size, exp_b10 = 1; - /* Else lost a leading zero, so 'exp' is + /* Else lost a leading zero, so 'exp_b10' is * still ok at (-1) */ } else - ++exp; + ++exp_b10; /* In all cases we output a '1' */ d = 1; } @@ -1268,25 +1268,26 @@ clead = 0; while (czero > 0) { - /* exp == (-1) means we just output the decimal - * place - after the DP don't adjust 'exp' any + /* exp_b10 == (-1) means we just output the decimal + * place - after the DP don't adjust 'exp_b10' any * more! */ - if (exp != (-1)) + if (exp_b10 != (-1)) { - if (exp == 0) *ascii++ = 46, --size; + if (exp_b10 == 0) *ascii++ = 46, --size; /* PLUS 1: TOTAL 4 */ - --exp; + --exp_b10; } *ascii++ = 48, --czero; } - if (exp != (-1)) + if (exp_b10 != (-1)) { - if (exp == 0) *ascii++ = 46, --size; /* counted above */ - --exp; + if (exp_b10 == 0) *ascii++ = 46, --size; /* counted + above */ + --exp_b10; } *ascii++ = (char)(48 + (int)d), ++cdigits; } } @@ -1295,23 +1296,23 @@ /* The total output count (max) is now 4+precision */ /* Check for an exponent, if we don't need one we are * done and just need to terminate the string. At - * this point exp==(-1) is effectively if flag - it got + * this point exp_b10==(-1) is effectively if flag - it got * to '-1' because of the decrement after outputing * the decimal point above (the exponent required is * *not* -1!) */ - if (exp >= (-1) && exp <= 2) + if (exp_b10 >= (-1) && exp_b10 <= 2) { /* The following only happens if we didn't output the * leading zeros above for negative exponent, so this * doest add to the digit requirement. Note that the * two zeros here can only be output if the two leading * zeros were *not* output, so this doesn't increase * the output count. */ - while (--exp >= 0) *ascii++ = 48; + while (--exp_b10 >= 0) *ascii++ = 48; *ascii = 0; /* Total buffer requirement (including the '\0') is @@ -1328,20 +1329,20 @@ */ size -= cdigits; *ascii++ = 69, --size; /* 'E': PLUS 1 TOTAL 2+precision*/ - if (exp < 0) + if (exp_b10 < 0) { *ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */ - exp = -exp; + exp_b10 = -exp_b10; } cdigits = 0; - while (exp > 0) + while (exp_b10 > 0) { - exponent[cdigits++] = (char)(48 + exp % 10); - exp /= 10; + exponent[cdigits++] = (char)(48 + exp_b10 % 10); + exp_b10 /= 10; } /* Need another size check here for the exponent digits, so * this need not be considered above. @@ -1458,13 +1459,12 @@ png_fixed(png_structp png_ptr, double fp, png_const_charp text) { double r = floor(100000 * fp + .5); - if (r <= 2147483647. && r >= -2147483648.) - return (png_fixed_point)r; - + if (r > 2147483647. || r < -2147483648.) png_fixed_error(png_ptr, text); - /*NOT REACHED*/ + + return (png_fixed_point)r; } #endif #if defined(PNG_READ_GAMMA_SUPPORTED) || \ @@ -1476,12 +1476,12 @@ * the result, a boolean - true on success, false on overflow. */ int png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times, - png_int_32 div) + png_int_32 divisor) { - /* Return a * times / div, rounded. */ - if (div != 0) + /* Return a * times / divisor, rounded. */ + if (divisor != 0) { if (a == 0 || times == 0) { *res = 0; @@ -1491,9 +1491,9 @@ { #ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED double r = a; r *= times; - r /= div; + r /= divisor; r = floor(r+.5); /* A png_fixed_point is a 32 bit integer. */ if (r <= 2147483647. && r >= -2147483648.) @@ -1515,12 +1515,12 @@ negative = !negative, T = -times; else T = times; - if (div < 0) - negative = !negative, D = -div; + if (divisor < 0) + negative = !negative, D = -divisor; else - D = div; + D = divisor; /* Following can't overflow because the arguments only * have 31 bits each, however the result may be 32 bits. */ @@ -1595,13 +1595,13 @@ * result. */ png_fixed_point png_muldiv_warn(png_structp png_ptr, png_fixed_point a, png_int_32 times, - png_int_32 div) + png_int_32 divisor) { png_fixed_point result; - if (png_muldiv(&result, a, times, div)) + if (png_muldiv(&result, a, times, divisor)) return result; png_warning(png_ptr, "fixed point overflow ignored"); return 0; @@ -1790,9 +1790,9 @@ static png_int_32 png_log8bit(unsigned int x) { - unsigned int log = 0; + unsigned int lg2 = 0; /* Each time 'x' is multiplied by 2, 1 must be subtracted off the final log, * because the log is actually negate that means adding 1. The final * returned value thus has the range 0 (for 255 input) to 7.994 (for 1 * input), return 7.99998 for the overflow (log 0) case - so the result is @@ -1801,18 +1801,18 @@ if ((x &= 0xff) == 0) return 0xffffffff; if ((x & 0xf0) == 0) - log = 4, x <<= 4; + lg2 = 4, x <<= 4; if ((x & 0xc0) == 0) - log += 2, x <<= 2; + lg2 += 2, x <<= 2; if ((x & 0x80) == 0) - log += 1, x <<= 1; + lg2 += 1, x <<= 1; /* result is at most 19 bits, so this cast is safe: */ - return (png_int_32)((log << 16) + ((png_8bit_l2[x-128]+32768)>>16)); + return (png_int_32)((lg2 << 16) + ((png_8bit_l2[x-128]+32768)>>16)); } /* The above gives exact (to 16 binary places) log2 values for 8 bit images, * for 16 bit images we use the most significant 8 bits of the 16 bit value to @@ -1846,31 +1846,31 @@ */ static png_int_32 png_log16bit(png_uint_32 x) { - unsigned int log = 0; + unsigned int lg2 = 0; /* As above, but now the input has 16 bits. */ if ((x &= 0xffff) == 0) return 0xffffffff; if ((x & 0xff00) == 0) - log = 8, x <<= 8; + lg2 = 8, x <<= 8; if ((x & 0xf000) == 0) - log += 4, x <<= 4; + lg2 += 4, x <<= 4; if ((x & 0xc000) == 0) - log += 2, x <<= 2; + lg2 += 2, x <<= 2; if ((x & 0x8000) == 0) - log += 1, x <<= 1; + lg2 += 1, x <<= 1; /* Calculate the base logarithm from the top 8 bits as a 28 bit fractional * value. */ - log <<= 28; - log += (png_8bit_l2[(x>>8)-128]+8) >> 4; + lg2 <<= 28; + lg2 += (png_8bit_l2[(x>>8)-128]+8) >> 4; /* Now we need to interpolate the factor, this requires a division by the top * 8 bits. Do this with maximum precision. */ @@ -1879,21 +1879,21 @@ /* Since we divided by the top 8 bits of 'x' there will be a '1' at 1<<24, * the value at 1<<16 (ignoring this) will be 0 or 1; this gives us exactly * 16 bits to interpolate to get the low bits of the result. Round the * answer. Note that the end point values are scaled by 64 to retain overall - * precision and that 'log' is current scaled by an extra 12 bits, so adjust + * precision and that 'lg2' is current scaled by an extra 12 bits, so adjust * the overall scaling by 6-12. Round at every step. */ x -= 1U << 24; if (x <= 65536U) /* <= '257' */ - log += ((23591U * (65536U-x)) + (1U << (16+6-12-1))) >> (16+6-12); + lg2 += ((23591U * (65536U-x)) + (1U << (16+6-12-1))) >> (16+6-12); else - log -= ((23499U * (x-65536U)) + (1U << (16+6-12-1))) >> (16+6-12); + lg2 -= ((23499U * (x-65536U)) + (1U << (16+6-12-1))) >> (16+6-12); /* Safe, because the result can't have more than 20 bits: */ - return (png_int_32)((log + 2048) >> 12); + return (png_int_32)((lg2 + 2048) >> 12); } /* The 'exp()' case must invert the above, taking a 20 bit fixed point * logarithmic value and returning a 16 or 8 bit number as appropriate. In @@ -1986,12 +1986,12 @@ return 0; } static png_byte -png_exp8bit(png_fixed_point log) +png_exp8bit(png_fixed_point lg2) { /* Get a 32 bit value: */ - png_uint_32 x = png_exp(log); + png_uint_32 x = png_exp(lg2); /* Convert the 32 bit value to 0..255 by multiplying by 256-1, note that the * second, rounding, step can't overflow because of the first, subtraction, * step. @@ -2000,32 +2000,32 @@ return (png_byte)((x + 0x7fffffU) >> 24); } static png_uint_16 -png_exp16bit(png_fixed_point log) +png_exp16bit(png_fixed_point lg2) { /* Get a 32 bit value: */ - png_uint_32 x = png_exp(log); + png_uint_32 x = png_exp(lg2); /* Convert the 32 bit value to 0..65535 by multiplying by 65536-1: */ x -= x >> 16; return (png_uint_16)((x + 32767U) >> 16); } #endif /* FLOATING_ARITHMETIC */ png_byte -png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma) +png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val) { if (value > 0 && value < 255) { # ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - double r = floor(255*pow(value/255.,gamma*.00001)+.5); + double r = floor(255*pow(value/255.,gamma_val*.00001)+.5); return (png_byte)r; # else - png_int_32 log = png_log8bit(value); + png_int_32 lg2 = png_log8bit(value); png_fixed_point res; - if (png_muldiv(&res, gamma, log, PNG_FP_1)) + if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1)) return png_exp8bit(res); /* Overflow. */ value = 0; @@ -2035,20 +2035,20 @@ return (png_byte)value; } png_uint_16 -png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma) +png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val) { if (value > 0 && value < 65535) { # ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - double r = floor(65535*pow(value/65535.,gamma*.00001)+.5); + double r = floor(65535*pow(value/65535.,gamma_val*.00001)+.5); return (png_uint_16)r; # else - png_int_32 log = png_log16bit(value); + png_int_32 lg2 = png_log16bit(value); png_fixed_point res; - if (png_muldiv(&res, gamma, log, PNG_FP_1)) + if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1)) return png_exp16bit(res); /* Overflow. */ value = 0; @@ -2064,25 +2064,25 @@ * 8 bit (as are the arguments.) */ png_uint_16 /* PRIVATE */ png_gamma_correct(png_structp png_ptr, unsigned int value, - png_fixed_point gamma) + png_fixed_point gamma_val) { if (png_ptr->bit_depth == 8) - return png_gamma_8bit_correct(value, gamma); + return png_gamma_8bit_correct(value, gamma_val); else - return png_gamma_16bit_correct(value, gamma); + return png_gamma_16bit_correct(value, gamma_val); } /* This is the shared test on whether a gamma value is 'significant' - whether * it is worth doing gamma correction. */ int /* PRIVATE */ -png_gamma_significant(png_fixed_point gamma) +png_gamma_significant(png_fixed_point gamma_val) { - return gamma < PNG_FP_1 - PNG_GAMMA_THRESHOLD_FIXED || - gamma > PNG_FP_1 + PNG_GAMMA_THRESHOLD_FIXED; + return gamma_val < PNG_FP_1 - PNG_GAMMA_THRESHOLD_FIXED || + gamma_val > PNG_FP_1 + PNG_GAMMA_THRESHOLD_FIXED; } /* Internal function to build a single 16 bit table - the table consists of * 'num' 256 entry subtables, where 'num' is determined by 'shift' - the amount @@ -2093,9 +2093,9 @@ * should be somewhere that will be cleaned. */ static void png_build_16bit_table(png_structp png_ptr, png_uint_16pp *ptable, - PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma) + PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) { /* Various values derived from 'shift': */ PNG_CONST unsigned int num = 1U << (8U - shift); PNG_CONST unsigned int max = (1U << (16U - shift))-1U; @@ -2112,9 +2112,9 @@ /* The 'threshold' test is repeated here because it can arise for one of * the 16 bit tables even if the others don't hit it. */ - if (png_gamma_significant(gamma)) + if (png_gamma_significant(gamma_val)) { /* The old code would overflow at the end and this would cause the * 'pow' function to return a result >1, resulting in an * arithmetic error. This code follows the spec exactly; ig is @@ -2128,15 +2128,15 @@ { png_uint_32 ig = (j << (8-shift)) + i; # ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED /* Inline the 'max' scaling operation: */ - double d = floor(65535*pow(ig/(double)max, gamma*.00001)+.5); + double d = floor(65535*pow(ig/(double)max, gamma_val*.00001)+.5); sub_table[j] = (png_uint_16)d; # else if (shift) ig = (ig * 65535U + max_by_2)/max; - sub_table[j] = png_gamma_16bit_correct(ig, gamma); + sub_table[j] = png_gamma_16bit_correct(ig, gamma_val); # endif } } else @@ -2161,9 +2161,9 @@ * required. */ static void png_build_16to8_table(png_structp png_ptr, png_uint_16pp *ptable, - PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma) + PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) { PNG_CONST unsigned int num = 1U << (8U - shift); PNG_CONST unsigned int max = (1U << (16U - shift))-1U; unsigned int i; @@ -2179,9 +2179,9 @@ for (i = 0; i < num; i++) table[i] = (png_uint_16p)png_malloc(png_ptr, 256 * png_sizeof(png_uint_16)); - /* 'gamma' is set to the reciprocal of the value calculated above, so + /* 'gamma_val' is set to the reciprocal of the value calculated above, so * pow(out,g) is an *input* value. 'last' is the last input value set. * * In the loop 'i' is used to find output values. Since the output is 8 * bit there are only 256 possible values. The tables are set up to @@ -2202,9 +2202,9 @@ /* Find the corresponding maximum input value */ png_uint_16 out = (png_uint_16)(i * 257U); /* 16 bit output value */ /* Find the boundary value in 16 bits: */ - png_uint_32 bound = png_gamma_16bit_correct(out+128U, gamma); + png_uint_32 bound = png_gamma_16bit_correct(out+128U, gamma_val); /* Adjust (round) to (16-shift) bits: */ bound = (bound * max + 32768U)/65535U + 1U; @@ -2228,15 +2228,15 @@ * (apparently contrary to the spec) so a 256 entry table is always generated. */ static void png_build_8bit_table(png_structp png_ptr, png_bytepp ptable, - PNG_CONST png_fixed_point gamma) + PNG_CONST png_fixed_point gamma_val) { unsigned int i; png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256); - if (png_gamma_significant(gamma)) for (i=0; i<256; i++) - table[i] = png_gamma_8bit_correct(i, gamma); + if (png_gamma_significant(gamma_val)) for (i=0; i<256; i++) + table[i] = png_gamma_8bit_correct(i, gamma_val); else for (i=0; i<256; ++i) table[i] = (png_byte)i; } diff -ru4NwbB libpng-1.5.0/png.h libpng-1.5.1beta06/png.h --- libpng-1.5.0/png.h 2011-01-06 07:02:36.101650980 -0600 +++ libpng-1.5.1beta06/png.h 2011-01-20 15:56:20.960900933 -0600 @@ -143,8 +143,9 @@ * 1.4.4 14 10404 14.so.14.4[.0] * 1.5.0beta01-58 15 10500 15.so.15.0[.0] * 1.5.0rc01-07 15 10500 15.so.15.0[.0] * 1.5.0 15 10500 15.so.15.0[.0] + * 1.5.1beta01-06 15 10501 15.so.15.1[.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 diff -ru4NwbB libpng-1.5.0/pngpread.c libpng-1.5.1beta06/pngpread.c --- libpng-1.5.0/pngpread.c 2011-01-06 07:02:36.179681622 -0600 +++ libpng-1.5.1beta06/pngpread.c 2011-01-20 15:56:21.040718606 -0600 @@ -581,12 +581,12 @@ png_push_crc_finish(png_structp png_ptr) { if (png_ptr->skip_length && png_ptr->save_buffer_size) { - png_size_t save_size = png_ptr->current_buffer_size; + png_size_t save_size = png_ptr->save_buffer_size; png_uint_32 skip_length = png_ptr->skip_length; - /* We want the smaller of 'skip_length' and 'current_buffer_size', but + /* We want the smaller of 'skip_length' and 'save_buffer_size', but * they are of different types and we don't know which variable has the * fewest bits. Carefully select the smaller and cast it to the type of * the larger - this cannot overflow. Do not cast in the following test * - it will break on either 16 or 64 bit platforms. @@ -608,12 +608,10 @@ { png_size_t save_size = png_ptr->current_buffer_size; png_uint_32 skip_length = png_ptr->skip_length; - /* We want the smaller of 'skip_length' and 'current_buffer_size', but - * they are of different types and we don't know which variable has the - * fewest bits. Carefully select the smaller and cast it to the type of - * the larger - this cannot overflow. + /* We want the smaller of 'skip_length' and 'current_buffer_size', here, + * the same problem exists as above and the same solution. */ if (skip_length < save_size) save_size = (png_size_t)skip_length; diff -ru4NwbB libpng-1.5.0/pngread.c libpng-1.5.1beta06/pngread.c --- libpng-1.5.0/pngread.c 2011-01-06 07:02:36.187926550 -0600 +++ libpng-1.5.1beta06/pngread.c 2011-01-20 15:56:21.048960129 -0600 @@ -1,8 +1,8 @@ /* pngread.c - read a PNG file * - * Last changed in libpng 1.5.0 [January 6, 2011] + * Last changed in libpng 1.5.1 [$RDATE%] * Copyright (c) 1998-2011 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.) * @@ -840,9 +840,9 @@ png_start_read_image(png_ptr); } else { - if (!(png_ptr->transformations & PNG_INTERLACE)) + if (png_ptr->interlaced && !(png_ptr->transformations & PNG_INTERLACE)) { /* Caller called png_start_read_image or png_read_update_info without * first turning on the PNG_INTERLACE transform. We can fix this here, * but the caller should do it! diff -ru4NwbB libpng-1.5.0/pngrtran.c libpng-1.5.1beta06/pngrtran.c --- libpng-1.5.0/pngrtran.c 2011-01-06 07:02:36.208212217 -0600 +++ libpng-1.5.1beta06/pngrtran.c 2011-01-20 15:56:21.069344819 -0600 @@ -1,8 +1,8 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.5.0 [January 6, 2011] + * Last changed in libpng 1.5.1 [(PENDING RELEASE)] * Copyright (c) 1998-2011 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.) * @@ -2426,9 +2426,9 @@ int rgb_error = 0; png_debug(1, "in png_do_rgb_to_gray"); - if ( + if (!(row_info->color_type & PNG_COLOR_MASK_PALETTE) && (row_info->color_type & PNG_COLOR_MASK_COLOR)) { png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; @@ -3777,9 +3777,9 @@ row_info->pixel_depth = 8; row_info->rowbytes = row_width; } - else if (row_info->bit_depth == 8) + if (row_info->bit_depth == 8) { { if (trans_alpha != NULL) { diff -ru4NwbB libpng-1.5.0/pngrutil.c libpng-1.5.1beta06/pngrutil.c --- libpng-1.5.0/pngrutil.c 2011-01-06 07:02:36.222125010 -0600 +++ libpng-1.5.1beta06/pngrutil.c 2011-01-20 15:56:21.082880222 -0600 @@ -1,8 +1,8 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.5.0 [January 6, 2011] + * Last changed in libpng 1.5.1 [(PENDING RELEASE)] * Copyright (c) 1998-2011 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.) * @@ -607,9 +607,9 @@ png_ptr->channels); png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width); png_debug1(3, "bit_depth = %d", png_ptr->bit_depth); png_debug1(3, "channels = %d", png_ptr->channels); - png_debug1(3, "rowbytes = %u", png_ptr->rowbytes); + png_debug1(3, "rowbytes = %lu", (unsigned long)png_ptr->rowbytes); png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, color_type, interlace_type, compression_type, filter_type); } @@ -1247,9 +1247,11 @@ char umsg[80]; png_snprintf2(umsg, 80, "Ignoring iCCP chunk with declared size = %u " - "and actual length = %u", profile_size, profile_length); + "and actual length = %u", + (unsigned int) profile_size, + (unsigned int) profile_length); png_warning(png_ptr, umsg); } #else png_warning(png_ptr, @@ -1959,9 +1961,9 @@ /* Read the sCAL chunk */ void /* PRIVATE */ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_size_t slength, index; + png_size_t slength, i; int state; png_debug(1, "in png_handle_sCAL"); @@ -2016,23 +2018,23 @@ /* Validate the ASCII numbers, need two ASCII numbers separated by * a '\0' and they need to fit exactly in the chunk data. */ - index = 0; + i = 0; state = 0; if (png_ptr->chunkdata[1] == 45 /* negative width */ || - !png_check_fp_number(png_ptr->chunkdata, slength, &state, &index) || - index >= slength || png_ptr->chunkdata[index++] != 0) + !png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) || + i >= slength || png_ptr->chunkdata[i++] != 0) png_warning(png_ptr, "Invalid sCAL chunk ignored: bad width format"); else { - png_size_t heighti = index; + png_size_t heighti = i; - if (png_ptr->chunkdata[index] == 45 /* negative height */ || - !png_check_fp_number(png_ptr->chunkdata, slength, &state, &index) || - index != slength) + if (png_ptr->chunkdata[i] == 45 /* negative height */ || + !png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) || + i != slength) png_warning(png_ptr, "Invalid sCAL chunk ignored: bad height format"); else /* This is the (only) success case. */ @@ -3604,11 +3606,11 @@ png_debug1(3, "width = %u,", png_ptr->width); png_debug1(3, "height = %u,", png_ptr->height); png_debug1(3, "iwidth = %u,", png_ptr->iwidth); png_debug1(3, "num_rows = %u,", png_ptr->num_rows); - png_debug1(3, "rowbytes = %u,", png_ptr->rowbytes); - png_debug1(3, "irowbytes = %u", - PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1); + png_debug1(3, "rowbytes = %lu,", (unsigned long)png_ptr->rowbytes); + png_debug1(3, "irowbytes = %lu", + (unsigned long)PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1); png_ptr->flags |= PNG_FLAG_ROW_INIT; } #endif /* PNG_READ_SUPPORTED */ diff -ru4NwbB libpng-1.5.0/pngset.c libpng-1.5.1beta06/pngset.c --- libpng-1.5.0/pngset.c 2011-01-06 07:02:36.230603138 -0600 +++ libpng-1.5.1beta06/pngset.c 2011-01-20 15:56:21.091130381 -0600 @@ -1,8 +1,8 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.5.0 [January 6, 2011] + * Last changed in libpng 1.5.1 [(PENDING RELEASE)] * Copyright (c) 1998-2011 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.) * @@ -86,9 +86,9 @@ #ifdef PNG_gAMA_SUPPORTED void PNGFAPI png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point - gamma) + file_gamma) { png_debug1(1, "in %s storage function", "gAMA"); if (png_ptr == NULL || info_ptr == NULL) @@ -97,17 +97,17 @@ /* Previously these values were limited, however they must be * wrong, therefore storing them (and setting PNG_INFO_gAMA) * must be wrong too. */ - if (gamma > (png_fixed_point)PNG_UINT_31_MAX) + if (file_gamma > (png_fixed_point)PNG_UINT_31_MAX) png_warning(png_ptr, "Gamma too large, ignored"); - else if (gamma <= 0) + else if (file_gamma <= 0) png_warning(png_ptr, "Negative or zero gamma ignored"); else { - info_ptr->gamma = gamma; + info_ptr->gamma = file_gamma; info_ptr->valid |= PNG_INFO_gAMA; } } @@ -351,9 +351,9 @@ info_ptr->scal_unit = (png_byte)unit; ++lengthw; - png_debug1(3, "allocating unit for info (%u bytes)", lengthw); + png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthw); info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, lengthw); if (info_ptr->scal_s_width == NULL) @@ -365,9 +365,9 @@ png_memcpy(info_ptr->scal_s_width, swidth, lengthw); ++lengthh; - png_debug1(3, "allocating unit for info (%u bytes)", lengthh); + png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthh); info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, lengthh); if (info_ptr->scal_s_height == NULL) @@ -750,12 +750,12 @@ if (textp->key == NULL) return(1); - png_debug2(2, "Allocated %lu bytes at %x in png_set_text", + png_debug2(2, "Allocated %lu bytes at %p in png_set_text", (unsigned long)(png_uint_32) (key_len + lang_len + lang_key_len + text_length + 4), - (int)textp->key); + textp->key); png_memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len)); *(textp->key + key_len) = '\0'; diff -ru4NwbB libpng-1.5.0/pngvalid.c libpng-1.5.1beta06/pngvalid.c --- libpng-1.5.0/pngvalid.c 2011-01-06 07:02:36.262351046 -0600 +++ libpng-1.5.1beta06/pngvalid.c 2011-01-20 15:56:21.123207496 -0600 @@ -237,27 +237,30 @@ } static unsigned int sample(png_const_bytep row, png_byte colour_type, png_byte bit_depth, - png_uint_32 x, unsigned int sample) + png_uint_32 x, unsigned int sample_index) { - png_uint_32 index, result; + png_uint_32 bit_index, result; /* Find a sample index for the desired sample: */ x *= bit_depth; - index = x; + bit_index = x; if ((colour_type & 1) == 0) /* !palette */ { if (colour_type & 2) - index *= 3, index += sample; /* Colour channels; select one */ + bit_index *= 3; if (colour_type & 4) - index += x; /* Alpha channel */ + bit_index += x; /* Alpha channel */ + + if (colour_type & (2+4)) + bit_index += sample_index * bit_depth; /* Multiple channels: select one */ } /* Return the sample from the row as an integer. */ - row += index >> 3; + row += bit_index >> 3; result = *row; if (bit_depth == 8) return result; @@ -265,10 +268,10 @@ else if (bit_depth > 8) return (result << 8) + *++row; /* Less than 8 bits per sample. */ - index &= 7; - return (result >> (8-index-bit_depth)) & ((1U<> (8-bit_index-bit_depth)) & ((1U<expect_error = !error_test[test].warning; @@ -2512,8 +2517,10 @@ } Catch (fault) ps = fault; /* expected exit, make sure ps is not clobbered */ +#undef exception__prev +#undef exception__env /* And clear these flags */ ps->expect_error = 0; ps->expect_warning = 0; @@ -3232,17 +3239,17 @@ return 1; } static void -gamma_modification_init(gamma_modification *me, png_modifier *pm, double gamma) +gamma_modification_init(gamma_modification *me, png_modifier *pm, double gammad) { double g; modification_init(&me->this); me->this.chunk = CHUNK_gAMA; me->this.modify_fn = gamma_modify; me->this.add = CHUNK_PLTE; - g = floor(gamma * 100000 + .5); + g = floor(gammad * 100000 + .5); me->gamma = (png_fixed_point)g; me->this.next = pm->modifications; pm->modifications = &me->this; } @@ -3497,9 +3504,9 @@ in_bd != out_bd; PNG_CONST unsigned int samples_per_pixel = (out_ct & 2U) ? 3U : 1U; - PNG_CONST double gamma = 1/(file_gamma*screen_gamma); /* Overall */ + PNG_CONST double gamma_correction = 1/(file_gamma*screen_gamma);/* Overall */ double maxerrout = 0, maxerrabs = 0, maxerrpc = 0; png_uint_32 y; @@ -3523,9 +3530,10 @@ PNG_CONST unsigned int isbit = id >> (in_bd-sbit); - double i, sample, encoded_sample, output, encoded_error, error; + double i, input_sample, encoded_sample, output; + double encoded_error, error; double es_lo, es_hi; /* First check on the 'perfect' result obtained from the * digitized input value, id, and compare this against the @@ -3542,9 +3550,9 @@ * quantization of the output value to the nearest digital * value (nevertheless the error is still recorded - it's * interesting ;-) */ - encoded_sample = pow(i, gamma) * outmax; + encoded_sample = pow(i, gamma_correction) * outmax; encoded_error = fabs(od-encoded_sample); if (encoded_error > maxerrout) maxerrout = encoded_error; @@ -3560,29 +3568,29 @@ * image. There's nothing we can do about this - we don't * know what it is - so assume the unencoded value is * perceptually linear. */ - sample = pow(i, 1/file_gamma); /* In range 0..1 */ + input_sample = pow(i, 1/file_gamma); /* In range 0..1 */ output = od; output /= outmax; output = pow(output, screen_gamma); /* Now we have the numbers for real errors, both absolute * values as as a percentage of the correct value (output): */ - error = fabs(sample-output); + error = fabs(input_sample-output); if (error > maxerrabs) maxerrabs = error; /* The following is an attempt to ignore the tendency of * quantization to dominate the percentage errors for low * output sample values: */ - if (sample*maxpc > .5+maxabs) + if (input_sample*maxpc > .5+maxabs) { - double pcerr = error/sample; - if (pcerr > maxerrpc) maxerrpc = pcerr; + double percentage_error = error/input_sample; + if (percentage_error > maxerrpc) maxerrpc = percentage_error; } /* Now calculate the digitization limits for * 'encoded_sample' using the 'max' values. Note that @@ -3592,29 +3600,31 @@ * First find the maximum error in linear light space, * range 0..1: */ { - double tmp = sample * maxpc; + double tmp = input_sample * maxpc; if (tmp < maxabs) tmp = maxabs; /* Low bound - the minimum of the three: */ es_lo = encoded_sample - maxout; - if (es_lo > 0 && sample-tmp > 0) + if (es_lo > 0 && input_sample-tmp > 0) { - double l = outmax * pow(sample-tmp, 1/screen_gamma); - if (l < es_lo) es_lo = l; + double low_value = outmax * pow(input_sample-tmp, + 1/screen_gamma); + if (low_value < es_lo) es_lo = low_value; } else es_lo = 0; es_hi = encoded_sample + maxout; - if (es_hi < outmax && sample+tmp < 1) + if (es_hi < outmax && input_sample+tmp < 1) { - double h = outmax * pow(sample+tmp, 1/screen_gamma); - if (h > es_hi) es_hi = h; + double high_value = outmax * pow(input_sample+tmp, + 1/screen_gamma); + if (high_value > es_hi) es_hi = high_value; } else es_hi = outmax; @@ -3641,9 +3651,9 @@ double tmp = (isbit - .5)/((1U< 0) { - is_lo = outmax * pow(tmp, gamma) - maxout; + is_lo = outmax * pow(tmp, gamma_correction) - maxout; if (is_lo < 0) is_lo = 0; } else @@ -3652,9 +3662,9 @@ tmp = (isbit + .5)/((1U< outmax) is_hi = outmax; } else @@ -3879,17 +3889,17 @@ png_byte bit_depth = 0; while (next_format(&colour_type, &bit_depth)) { - double gamma = 1.0; - while (gamma >= .4) + double test_gamma = 1.0; + while (test_gamma >= .4) { /* There's little point testing the interlacing vs non-interlacing, * but this can be set from the command line. */ gamma_threshold_test(pm, colour_type, bit_depth, pm->interlace_type, - gamma, 1/gamma); - gamma *= .95; + test_gamma, 1/test_gamma); + test_gamma *= .95; } /* And a special test for sRGB */ gamma_threshold_test(pm, colour_type, bit_depth, pm->interlace_type, diff -ru4NwbB libpng-1.5.0/pngwrite.c libpng-1.5.1beta06/pngwrite.c --- libpng-1.5.0/pngwrite.c 2011-01-06 07:02:36.276890364 -0600 +++ libpng-1.5.1beta06/pngwrite.c 2011-01-20 15:56:21.137216420 -0600 @@ -1,8 +1,8 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.5.0 [January 6, 2011] + * Last changed in libpng 1.5.1 [(PENDING RELEASE)] * Copyright (c) 1998-2011 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.) * @@ -782,9 +782,10 @@ png_debug1(3, "row_info->width = %u", 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 = %u", png_ptr->row_info.rowbytes); + png_debug1(3, "row_info->rowbytes = %lu", + (unsigned long)png_ptr->row_info.rowbytes); /* Copy user's row into buffer, leaving room for filter byte. */ png_memcpy(png_ptr->row_buf + 1, row, png_ptr->row_info.rowbytes);