提交 168a4333 编写于 作者: J John Bowler 提交者: Glenn Randers-Pehrson

[devel] Eliminate more GCC shadow warnings

上级 1408c2af
...@@ -61,7 +61,7 @@ Version 1.5.1beta05 [January 16, 2011] ...@@ -61,7 +61,7 @@ Version 1.5.1beta05 [January 16, 2011]
Version 1.5.1beta06 [January 16, 2011] Version 1.5.1beta06 [January 16, 2011]
Prevent png_push_crc_skip() from hanging while reading an unknown chunk Prevent png_push_crc_skip() from hanging while reading an unknown chunk
or an over-large compressed zTXT chunk with the progressive reader. or an over-large compressed zTXt chunk with the progressive reader.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net: Send comments/corrections/commendations to png-mng-implement at lists.sf.net:
(subscription required; visit (subscription required; visit
......
...@@ -3177,7 +3177,7 @@ Version 1.5.1beta05 [January 16, 2011] ...@@ -3177,7 +3177,7 @@ Version 1.5.1beta05 [January 16, 2011]
Version 1.5.1beta06 [January 16, 2011] Version 1.5.1beta06 [January 16, 2011]
Prevent png_push_crc_skip() from hanging while reading an unknown chunk Prevent png_push_crc_skip() from hanging while reading an unknown chunk
or an over-large compressed zTXT chunk with the progressive reader. or an over-large compressed zTXt chunk with the progressive reader.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit
......
...@@ -1792,7 +1792,7 @@ png_8bit_l2[128] = ...@@ -1792,7 +1792,7 @@ png_8bit_l2[128] =
static png_int_32 static png_int_32
png_log8bit(unsigned int x) 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, /* 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 * 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 * returned value thus has the range 0 (for 255 input) to 7.994 (for 1
...@@ -1803,16 +1803,16 @@ png_log8bit(unsigned int x) ...@@ -1803,16 +1803,16 @@ png_log8bit(unsigned int x)
return 0xffffffff; return 0xffffffff;
if ((x & 0xf0) == 0) if ((x & 0xf0) == 0)
log = 4, x <<= 4; lg2 = 4, x <<= 4;
if ((x & 0xc0) == 0) if ((x & 0xc0) == 0)
log += 2, x <<= 2; lg2 += 2, x <<= 2;
if ((x & 0x80) == 0) if ((x & 0x80) == 0)
log += 1, x <<= 1; lg2 += 1, x <<= 1;
/* result is at most 19 bits, so this cast is safe: */ /* 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, /* The above gives exact (to 16 binary places) log2 values for 8 bit images,
...@@ -1848,29 +1848,29 @@ png_log8bit(unsigned int x) ...@@ -1848,29 +1848,29 @@ png_log8bit(unsigned int x)
static png_int_32 static png_int_32
png_log16bit(png_uint_32 x) png_log16bit(png_uint_32 x)
{ {
unsigned int log = 0; unsigned int lg2 = 0;
/* As above, but now the input has 16 bits. */ /* As above, but now the input has 16 bits. */
if ((x &= 0xffff) == 0) if ((x &= 0xffff) == 0)
return 0xffffffff; return 0xffffffff;
if ((x & 0xff00) == 0) if ((x & 0xff00) == 0)
log = 8, x <<= 8; lg2 = 8, x <<= 8;
if ((x & 0xf000) == 0) if ((x & 0xf000) == 0)
log += 4, x <<= 4; lg2 += 4, x <<= 4;
if ((x & 0xc000) == 0) if ((x & 0xc000) == 0)
log += 2, x <<= 2; lg2 += 2, x <<= 2;
if ((x & 0x8000) == 0) 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 /* Calculate the base logarithm from the top 8 bits as a 28 bit fractional
* value. * value.
*/ */
log <<= 28; lg2 <<= 28;
log += (png_8bit_l2[(x>>8)-128]+8) >> 4; lg2 += (png_8bit_l2[(x>>8)-128]+8) >> 4;
/* Now we need to interpolate the factor, this requires a division by the top /* Now we need to interpolate the factor, this requires a division by the top
* 8 bits. Do this with maximum precision. * 8 bits. Do this with maximum precision.
...@@ -1881,19 +1881,19 @@ png_log16bit(png_uint_32 x) ...@@ -1881,19 +1881,19 @@ png_log16bit(png_uint_32 x)
* the value at 1<<16 (ignoring this) will be 0 or 1; this gives us exactly * 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 * 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 * 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. * the overall scaling by 6-12. Round at every step.
*/ */
x -= 1U << 24; x -= 1U << 24;
if (x <= 65536U) /* <= '257' */ 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 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: */ /* 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 /* The 'exp()' case must invert the above, taking a 20 bit fixed point
...@@ -1988,10 +1988,10 @@ png_exp(png_fixed_point x) ...@@ -1988,10 +1988,10 @@ png_exp(png_fixed_point x)
} }
static png_byte static png_byte
png_exp8bit(png_fixed_point log) png_exp8bit(png_fixed_point lg2)
{ {
/* Get a 32 bit value: */ /* 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 /* 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, * second, rounding, step can't overflow because of the first, subtraction,
...@@ -2002,10 +2002,10 @@ png_exp8bit(png_fixed_point log) ...@@ -2002,10 +2002,10 @@ png_exp8bit(png_fixed_point log)
} }
static png_uint_16 static png_uint_16
png_exp16bit(png_fixed_point log) png_exp16bit(png_fixed_point lg2)
{ {
/* Get a 32 bit value: */ /* 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: */ /* Convert the 32 bit value to 0..65535 by multiplying by 65536-1: */
x -= x >> 16; x -= x >> 16;
...@@ -2022,10 +2022,10 @@ png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val) ...@@ -2022,10 +2022,10 @@ png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val)
double r = floor(255*pow(value/255.,gamma_val*.00001)+.5); double r = floor(255*pow(value/255.,gamma_val*.00001)+.5);
return (png_byte)r; return (png_byte)r;
# else # else
png_int_32 log = png_log8bit(value); png_int_32 lg2 = png_log8bit(value);
png_fixed_point res; png_fixed_point res;
if (png_muldiv(&res, gamma_val, log, PNG_FP_1)) if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1))
return png_exp8bit(res); return png_exp8bit(res);
/* Overflow. */ /* Overflow. */
...@@ -2045,10 +2045,10 @@ png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val) ...@@ -2045,10 +2045,10 @@ png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val)
double r = floor(65535*pow(value/65535.,gamma_val*.00001)+.5); double r = floor(65535*pow(value/65535.,gamma_val*.00001)+.5);
return (png_uint_16)r; return (png_uint_16)r;
# else # else
png_int_32 log = png_log16bit(value); png_int_32 lg2 = png_log16bit(value);
png_fixed_point res; png_fixed_point res;
if (png_muldiv(&res, gamma_val, log, PNG_FP_1)) if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1))
return png_exp16bit(res); return png_exp16bit(res);
/* Overflow. */ /* Overflow. */
......
...@@ -585,7 +585,7 @@ png_push_crc_finish(png_structp png_ptr) ...@@ -585,7 +585,7 @@ png_push_crc_finish(png_structp png_ptr)
png_size_t save_size = png_ptr->save_buffer_size; png_size_t save_size = png_ptr->save_buffer_size;
png_uint_32 skip_length = png_ptr->skip_length; 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 * 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 * 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 * the larger - this cannot overflow. Do not cast in the following test
...@@ -609,10 +609,8 @@ png_push_crc_finish(png_structp png_ptr) ...@@ -609,10 +609,8 @@ png_push_crc_finish(png_structp png_ptr)
png_size_t save_size = png_ptr->current_buffer_size; png_size_t save_size = png_ptr->current_buffer_size;
png_uint_32 skip_length = png_ptr->skip_length; 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 'current_buffer_size', here,
* they are of different types and we don't know which variable has the * the same problem exists as above and the same solution.
* fewest bits. Carefully select the smaller and cast it to the type of
* the larger - this cannot overflow.
*/ */
if (skip_length < save_size) if (skip_length < save_size)
save_size = (png_size_t)skip_length; save_size = (png_size_t)skip_length;
......
...@@ -1962,7 +1962,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) ...@@ -1962,7 +1962,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void /* PRIVATE */ void /* PRIVATE */
png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) 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; int state;
png_debug(1, "in png_handle_sCAL"); png_debug(1, "in png_handle_sCAL");
...@@ -2019,21 +2019,21 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) ...@@ -2019,21 +2019,21 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
/* Validate the ASCII numbers, need two ASCII numbers separated by /* Validate the ASCII numbers, need two ASCII numbers separated by
* a '\0' and they need to fit exactly in the chunk data. * a '\0' and they need to fit exactly in the chunk data.
*/ */
index = 0; i = 0;
state = 0; state = 0;
if (png_ptr->chunkdata[1] == 45 /* negative width */ || if (png_ptr->chunkdata[1] == 45 /* negative width */ ||
!png_check_fp_number(png_ptr->chunkdata, slength, &state, &index) || !png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||
index >= slength || png_ptr->chunkdata[index++] != 0) i >= slength || png_ptr->chunkdata[i++] != 0)
png_warning(png_ptr, "Invalid sCAL chunk ignored: bad width format"); png_warning(png_ptr, "Invalid sCAL chunk ignored: bad width format");
else else
{ {
png_size_t heighti = index; png_size_t heighti = i;
if (png_ptr->chunkdata[index] == 45 /* negative height */ || if (png_ptr->chunkdata[i] == 45 /* negative height */ ||
!png_check_fp_number(png_ptr->chunkdata, slength, &state, &index) || !png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||
index != slength) i != slength)
png_warning(png_ptr, "Invalid sCAL chunk ignored: bad height format"); png_warning(png_ptr, "Invalid sCAL chunk ignored: bad height format");
else else
......
...@@ -87,7 +87,7 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr, ...@@ -87,7 +87,7 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_gAMA_SUPPORTED #ifdef PNG_gAMA_SUPPORTED
void PNGFAPI void PNGFAPI
png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point 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"); png_debug1(1, "in %s storage function", "gAMA");
...@@ -98,15 +98,15 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point ...@@ -98,15 +98,15 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
* wrong, therefore storing them (and setting PNG_INFO_gAMA) * wrong, therefore storing them (and setting PNG_INFO_gAMA)
* must be wrong too. * 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"); 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"); png_warning(png_ptr, "Negative or zero gamma ignored");
else else
{ {
info_ptr->gamma = gamma; info_ptr->gamma = file_gamma;
info_ptr->valid |= PNG_INFO_gAMA; info_ptr->valid |= PNG_INFO_gAMA;
} }
} }
......
...@@ -238,28 +238,28 @@ next_format(png_bytep colour_type, png_bytep bit_depth) ...@@ -238,28 +238,28 @@ next_format(png_bytep colour_type, png_bytep bit_depth)
static unsigned int static unsigned int
sample(png_const_bytep row, png_byte colour_type, png_byte bit_depth, 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: */ /* Find a sample index for the desired sample: */
x *= bit_depth; x *= bit_depth;
index = x; bit_index = x;
if ((colour_type & 1) == 0) /* !palette */ if ((colour_type & 1) == 0) /* !palette */
{ {
if (colour_type & 2) if (colour_type & 2)
index *= 3; bit_index *= 3;
if (colour_type & 4) if (colour_type & 4)
index += x; /* Alpha channel */ bit_index += x; /* Alpha channel */
if (colour_type & (2+4)) if (colour_type & (2+4))
index += sample * bit_depth; /* Multiple channels: select one */ bit_index += sample_index * bit_depth; /* Multiple channels: select one */
} }
/* Return the sample from the row as an integer. */ /* Return the sample from the row as an integer. */
row += index >> 3; row += bit_index >> 3;
result = *row; result = *row;
if (bit_depth == 8) if (bit_depth == 8)
...@@ -269,8 +269,8 @@ sample(png_const_bytep row, png_byte colour_type, png_byte bit_depth, ...@@ -269,8 +269,8 @@ sample(png_const_bytep row, png_byte colour_type, png_byte bit_depth,
return (result << 8) + *++row; return (result << 8) + *++row;
/* Less than 8 bits per sample. */ /* Less than 8 bits per sample. */
index &= 7; bit_index &= 7;
return (result >> (8-index-bit_depth)) & ((1U<<bit_depth)-1); return (result >> (8-bit_index-bit_depth)) & ((1U<<bit_depth)-1);
} }
/* Copy a single pixel, of a given size, from one buffer to another - /* Copy a single pixel, of a given size, from one buffer to another -
...@@ -2493,6 +2493,8 @@ make_error(png_store* volatile ps, png_byte PNG_CONST colour_type, ...@@ -2493,6 +2493,8 @@ make_error(png_store* volatile ps, png_byte PNG_CONST colour_type,
/* Time for a few errors, these are in various optional chunks, the /* Time for a few errors, these are in various optional chunks, the
* standard tests test the standard chunks pretty well. * standard tests test the standard chunks pretty well.
*/ */
# define exception__prev exception_prev_1
# define exception__env exception_env_1
Try Try
{ {
/* Expect this to throw: */ /* Expect this to throw: */
...@@ -2516,6 +2518,8 @@ make_error(png_store* volatile ps, png_byte PNG_CONST colour_type, ...@@ -2516,6 +2518,8 @@ make_error(png_store* volatile ps, png_byte PNG_CONST colour_type,
Catch (fault) Catch (fault)
ps = fault; /* expected exit, make sure ps is not clobbered */ ps = fault; /* expected exit, make sure ps is not clobbered */
#undef exception__prev
#undef exception__env
/* And clear these flags */ /* And clear these flags */
ps->expect_error = 0; ps->expect_error = 0;
...@@ -3236,7 +3240,7 @@ gamma_modify(png_modifier *pm, png_modification *me, int add) ...@@ -3236,7 +3240,7 @@ gamma_modify(png_modifier *pm, png_modification *me, int add)
} }
static void 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; double g;
...@@ -3244,7 +3248,7 @@ gamma_modification_init(gamma_modification *me, png_modifier *pm, double gamma) ...@@ -3244,7 +3248,7 @@ gamma_modification_init(gamma_modification *me, png_modifier *pm, double gamma)
me->this.chunk = CHUNK_gAMA; me->this.chunk = CHUNK_gAMA;
me->this.modify_fn = gamma_modify; me->this.modify_fn = gamma_modify;
me->this.add = CHUNK_PLTE; me->this.add = CHUNK_PLTE;
g = floor(gamma * 100000 + .5); g = floor(gammad * 100000 + .5);
me->gamma = (png_fixed_point)g; me->gamma = (png_fixed_point)g;
me->this.next = pm->modifications; me->this.next = pm->modifications;
pm->modifications = &me->this; pm->modifications = &me->this;
...@@ -3501,7 +3505,7 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi, ...@@ -3501,7 +3505,7 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi,
PNG_CONST unsigned int samples_per_pixel = (out_ct & 2U) ? 3U : 1U; 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; double maxerrout = 0, maxerrabs = 0, maxerrpc = 0;
png_uint_32 y; png_uint_32 y;
...@@ -3527,7 +3531,8 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi, ...@@ -3527,7 +3531,8 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi,
PNG_CONST unsigned int PNG_CONST unsigned int
isbit = id >> (in_bd-sbit); 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; double es_lo, es_hi;
/* First check on the 'perfect' result obtained from the /* First check on the 'perfect' result obtained from the
...@@ -3546,7 +3551,7 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi, ...@@ -3546,7 +3551,7 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi,
* value (nevertheless the error is still recorded - it's * value (nevertheless the error is still recorded - it's
* interesting ;-) * interesting ;-)
*/ */
encoded_sample = pow(i, gamma) * outmax; encoded_sample = pow(i, gamma_correction) * outmax;
encoded_error = fabs(od-encoded_sample); encoded_error = fabs(od-encoded_sample);
if (encoded_error > maxerrout) if (encoded_error > maxerrout)
...@@ -3564,7 +3569,7 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi, ...@@ -3564,7 +3569,7 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi,
* know what it is - so assume the unencoded value is * know what it is - so assume the unencoded value is
* perceptually linear. * 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 = od;
output /= outmax; output /= outmax;
output = pow(output, screen_gamma); output = pow(output, screen_gamma);
...@@ -3572,7 +3577,7 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi, ...@@ -3572,7 +3577,7 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi,
/* Now we have the numbers for real errors, both absolute /* Now we have the numbers for real errors, both absolute
* values as as a percentage of the correct value (output): * values as as a percentage of the correct value (output):
*/ */
error = fabs(sample-output); error = fabs(input_sample-output);
if (error > maxerrabs) if (error > maxerrabs)
maxerrabs = error; maxerrabs = error;
...@@ -3581,10 +3586,10 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi, ...@@ -3581,10 +3586,10 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi,
* quantization to dominate the percentage errors for low * quantization to dominate the percentage errors for low
* output sample values: * output sample values:
*/ */
if (sample*maxpc > .5+maxabs) if (input_sample*maxpc > .5+maxabs)
{ {
double pcerr = error/sample; double percentage_error = error/input_sample;
if (pcerr > maxerrpc) maxerrpc = pcerr; if (percentage_error > maxerrpc) maxerrpc = percentage_error;
} }
/* Now calculate the digitization limits for /* Now calculate the digitization limits for
...@@ -3596,16 +3601,17 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi, ...@@ -3596,16 +3601,17 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi,
* range 0..1: * range 0..1:
*/ */
{ {
double tmp = sample * maxpc; double tmp = input_sample * maxpc;
if (tmp < maxabs) tmp = maxabs; if (tmp < maxabs) tmp = maxabs;
/* Low bound - the minimum of the three: */ /* Low bound - the minimum of the three: */
es_lo = encoded_sample - maxout; 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); double low_value = outmax * pow(input_sample-tmp,
if (l < es_lo) es_lo = l; 1/screen_gamma);
if (low_value < es_lo) es_lo = low_value;
} }
else else
...@@ -3613,10 +3619,11 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi, ...@@ -3613,10 +3619,11 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi,
es_hi = encoded_sample + maxout; 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); double high_value = outmax * pow(input_sample+tmp,
if (h > es_hi) es_hi = h; 1/screen_gamma);
if (high_value > es_hi) es_hi = high_value;
} }
else else
...@@ -3645,7 +3652,7 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi, ...@@ -3645,7 +3652,7 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi,
if (tmp > 0) if (tmp > 0)
{ {
is_lo = outmax * pow(tmp, gamma) - maxout; is_lo = outmax * pow(tmp, gamma_correction) - maxout;
if (is_lo < 0) is_lo = 0; if (is_lo < 0) is_lo = 0;
} }
...@@ -3656,7 +3663,7 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi, ...@@ -3656,7 +3663,7 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi,
if (tmp < 1) if (tmp < 1)
{ {
is_hi = outmax * pow(tmp, gamma) + maxout; is_hi = outmax * pow(tmp, gamma_correction) + maxout;
if (is_hi > outmax) is_hi = outmax; if (is_hi > outmax) is_hi = outmax;
} }
...@@ -3883,15 +3890,15 @@ perform_gamma_threshold_tests(png_modifier *pm) ...@@ -3883,15 +3890,15 @@ perform_gamma_threshold_tests(png_modifier *pm)
while (next_format(&colour_type, &bit_depth)) while (next_format(&colour_type, &bit_depth))
{ {
double gamma = 1.0; double test_gamma = 1.0;
while (gamma >= .4) while (test_gamma >= .4)
{ {
/* There's little point testing the interlacing vs non-interlacing, /* There's little point testing the interlacing vs non-interlacing,
* but this can be set from the command line. * but this can be set from the command line.
*/ */
gamma_threshold_test(pm, colour_type, bit_depth, pm->interlace_type, gamma_threshold_test(pm, colour_type, bit_depth, pm->interlace_type,
gamma, 1/gamma); test_gamma, 1/test_gamma);
gamma *= .95; test_gamma *= .95;
} }
/* And a special test for sRGB */ /* And a special test for sRGB */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册