[libpng16] Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived)

compiler issues slightly different warnings from those issued by the
current vesions of GCC. This eliminates those warnings by
adding/removing casts and small code rewrites.
This commit is contained in:
John Bowler 2012-01-25 07:47:44 -06:00 committed by Glenn Randers-Pehrson
parent 9c7f99c9cb
commit 8fb6c6a9b3
9 changed files with 125 additions and 104 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.6.0beta07 - January 24, 2012 Libpng 1.6.0beta07 - January 25, 2012
This is not intended to be a public release. It will be replaced This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version. within a few weeks by a public version or by another test version.
@ -118,7 +118,11 @@ Version 1.6.0beta06 [January 24, 2012]
review; the documentation has not yet been updated. review; the documentation has not yet been updated.
Fixed Min/GW uninstall to remove libpng.dll.a Fixed Min/GW uninstall to remove libpng.dll.a
Version 1.6.0beta07 [January 24, 2012] Version 1.6.0beta07 [January 25, 2012]
Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived)
compiler issues slightly different warnings from those issued by the
current vesions of GCC. This eliminates those warnings by
adding/removing casts and small code rewrites.
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

View File

@ -3869,7 +3869,11 @@ Version 1.6.0beta06 [January 24, 2012]
review; the documentation has not yet been updated. review; the documentation has not yet been updated.
Fixed Min/GW uninstall to remove libpng.dll.a Fixed Min/GW uninstall to remove libpng.dll.a
Version 1.6.0beta07 [January 24, 2012] Version 1.6.0beta07 [January 25, 2012]
Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived)
compiler issues slightly different warnings from those issued by the
current vesions of GCC. This eliminates those warnings by
adding/removing casts and small code rewrites.
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

View File

@ -1530,7 +1530,10 @@ compare_two_images(Image *a, Image *b, int via_linear)
png_byte bstart = 0; png_byte bstart = 0;
/* Set to the actual number of channels in 'a' */ /* Set to the actual number of channels in 'a' */
channels = (formata & PNG_FORMAT_FLAG_COLOR) ? 3 : 1; if (formata & PNG_FORMAT_FLAG_COLOR)
channels = 3U;
else
channels = 1U;
if (formata & PNG_FORMAT_FLAG_ALPHA) if (formata & PNG_FORMAT_FLAG_ALPHA)
{ {
@ -2282,7 +2285,7 @@ testimage(Image *image, png_uint_32 opts, format_list *pf)
} }
int int
main(int argc, const char **argv) main(int argc, char **argv)
{ {
png_uint_32 opts = 0; png_uint_32 opts = 0;
format_list formats; format_list formats;

View File

@ -2903,9 +2903,9 @@ make_standard_palette(png_store* ps, int npalette, int do_tRNS)
*/ */
for (; i<8; ++i) for (; i<8; ++i)
{ {
values[i][1] = (i&1) ? 255 : 0; values[i][1] = (png_byte)((i&1) ? 255U : 0U);
values[i][2] = (i&2) ? 255 : 0; values[i][2] = (png_byte)((i&2) ? 255U : 0U);
values[i][3] = (i&4) ? 255 : 0; values[i][3] = (png_byte)((i&4) ? 255U : 0U);
} }
/* Then add 62 grays (one quarter of the remaining 256 slots). */ /* Then add 62 grays (one quarter of the remaining 256 slots). */
@ -3166,20 +3166,20 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
switch (bit_size(pp, colour_type, bit_depth)) switch (bit_size(pp, colour_type, bit_depth))
{ {
case 1: case 1:
while (i<128/8) buffer[i] = v & 0xff, v += 17, ++i; while (i<128/8) buffer[i] = (png_byte)(v & 0xff), v += 17, ++i;
return; return;
case 2: case 2:
while (i<128/4) buffer[i] = v & 0xff, v += 33, ++i; while (i<128/4) buffer[i] = (png_byte)(v & 0xff), v += 33, ++i;
return; return;
case 4: case 4:
while (i<128/2) buffer[i] = v & 0xff, v += 65, ++i; while (i<128/2) buffer[i] = (png_byte)(v & 0xff), v += 65, ++i;
return; return;
case 8: case 8:
/* 256 bytes total, 128 bytes in each row set as follows: */ /* 256 bytes total, 128 bytes in each row set as follows: */
while (i<128) buffer[i] = v & 0xff, ++v, ++i; while (i<128) buffer[i] = (png_byte)(v & 0xff), ++v, ++i;
return; return;
case 16: case 16:
@ -3187,7 +3187,12 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
* GA case as well as the 16 bit G case. * GA case as well as the 16 bit G case.
*/ */
while (i<128) while (i<128)
buffer[2*i] = (v>>8) & 0xff, buffer[2*i+1] = v & 0xff, ++v, ++i; {
buffer[2*i] = (png_byte)((v>>8) & 0xff);
buffer[2*i+1] = (png_byte)(v & 0xff);
++v;
++i;
}
return; return;
@ -3196,9 +3201,9 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
while (i<128) while (i<128)
{ {
/* Three bytes per pixel, r, g, b, make b by r^g */ /* Three bytes per pixel, r, g, b, make b by r^g */
buffer[3*i+0] = (v >> 8) & 0xff; buffer[3*i+0] = (png_byte)((v >> 8) & 0xff);
buffer[3*i+1] = v & 0xff; buffer[3*i+1] = (png_byte)(v & 0xff);
buffer[3*i+2] = ((v >> 8) ^ v) & 0xff; buffer[3*i+2] = (png_byte)(((v >> 8) ^ v) & 0xff);
++v; ++v;
++i; ++i;
} }
@ -3209,10 +3214,10 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
/* 65535 pixels, r, g, b, a; just replicate */ /* 65535 pixels, r, g, b, a; just replicate */
while (i<128) while (i<128)
{ {
buffer[4*i+0] = (v >> 8) & 0xff; buffer[4*i+0] = (png_byte)((v >> 8) & 0xff);
buffer[4*i+1] = v & 0xff; buffer[4*i+1] = (png_byte)(v & 0xff);
buffer[4*i+2] = (v >> 8) & 0xff; buffer[4*i+2] = (png_byte)((v >> 8) & 0xff);
buffer[4*i+3] = v & 0xff; buffer[4*i+3] = (png_byte)(v & 0xff);
++v; ++v;
++i; ++i;
} }
@ -3226,14 +3231,14 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
while (i<128) while (i<128)
{ {
png_uint_32 t = v++; png_uint_32 t = v++;
buffer[6*i+0] = (t >> 8) & 0xff; buffer[6*i+0] = (png_byte)((t >> 8) & 0xff);
buffer[6*i+1] = t & 0xff; buffer[6*i+1] = (png_byte)(t & 0xff);
t *= 257; t *= 257;
buffer[6*i+2] = (t >> 8) & 0xff; buffer[6*i+2] = (png_byte)((t >> 8) & 0xff);
buffer[6*i+3] = t & 0xff; buffer[6*i+3] = (png_byte)(t & 0xff);
t *= 17; t *= 17;
buffer[6*i+4] = (t >> 8) & 0xff; buffer[6*i+4] = (png_byte)((t >> 8) & 0xff);
buffer[6*i+5] = t & 0xff; buffer[6*i+5] = (png_byte)(t & 0xff);
++i; ++i;
} }
@ -3244,15 +3249,15 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
while (i<128) while (i<128)
{ {
png_uint_32 t = v++; png_uint_32 t = v++;
buffer[8*i+0] = (t >> 8) & 0xff; buffer[8*i+0] = (png_byte)((t >> 8) & 0xff);
buffer[8*i+1] = t & 0xff; buffer[8*i+1] = (png_byte)(t & 0xff);
buffer[8*i+4] = (t >> 8) & 0xff; buffer[8*i+4] = (png_byte)((t >> 8) & 0xff);
buffer[8*i+5] = t & 0xff; buffer[8*i+5] = (png_byte)(t & 0xff);
t *= 257; t *= 257;
buffer[8*i+2] = (t >> 8) & 0xff; buffer[8*i+2] = (png_byte)((t >> 8) & 0xff);
buffer[8*i+3] = t & 0xff; buffer[8*i+3] = (png_byte)(t & 0xff);
buffer[8*i+6] = (t >> 8) & 0xff; buffer[8*i+6] = (png_byte)((t >> 8) & 0xff);
buffer[8*i+7] = t & 0xff; buffer[8*i+7] = (png_byte)(t & 0xff);
++i; ++i;
} }
return; return;
@ -4591,8 +4596,8 @@ standard_row_validate(standard_display *dp, png_const_structp pp,
dp->bit_width)) != 0) dp->bit_width)) != 0)
{ {
char msg[64]; char msg[64];
sprintf(msg, "PNG image row[%d][%d] changed from %.2x to %.2x", y, sprintf(msg, "PNG image row[%lu][%d] changed from %.2x to %.2x",
where-1, std[where-1], (unsigned long)y, where-1, std[where-1],
store_image_row(dp->ps, pp, iImage, y)[where-1]); store_image_row(dp->ps, pp, iImage, y)[where-1]);
png_error(pp, msg); png_error(pp, msg);
} }
@ -4609,8 +4614,8 @@ standard_row_validate(standard_display *dp, png_const_structp pp,
dp->bit_width)) != 0) dp->bit_width)) != 0)
{ {
char msg[64]; char msg[64];
sprintf(msg, "display row[%d][%d] changed from %.2x to %.2x", y, sprintf(msg, "display row[%lu][%d] changed from %.2x to %.2x",
where-1, std[where-1], (unsigned long)y, where-1, std[where-1],
store_image_row(dp->ps, pp, iDisplay, y)[where-1]); store_image_row(dp->ps, pp, iDisplay, y)[where-1]);
png_error(pp, msg); png_error(pp, msg);
} }
@ -8277,7 +8282,8 @@ gamma_image_validate(gamma_display *dp, png_const_structp pp,
char msg[64]; char msg[64];
/* No transform is expected on the threshold tests. */ /* No transform is expected on the threshold tests. */
sprintf(msg, "gamma: below threshold row %d changed", y); sprintf(msg, "gamma: below threshold row %lu changed",
(unsigned long)y);
png_error(pp, msg); png_error(pp, msg);
} }
@ -9425,7 +9431,7 @@ static void signal_handler(int signum)
} }
/* main program */ /* main program */
int main(int argc, PNG_CONST char **argv) int main(int argc, char **argv)
{ {
volatile int summary = 1; /* Print the error summary at the end */ volatile int summary = 1; /* Print the error summary at the end */
volatile int memstats = 0; /* Print memory statistics at the end */ volatile int memstats = 0; /* Print memory statistics at the end */

View File

@ -3508,8 +3508,9 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
if ((png_uint_16)((*sp >> shift) & 0x01) if ((png_uint_16)((*sp >> shift) & 0x01)
== png_ptr->trans_color.gray) == png_ptr->trans_color.gray)
{ {
*sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); unsigned int tmp = *sp & (0x7f7f >> (7 - shift));
*sp |= (png_byte)(png_ptr->background.gray << shift); tmp |= png_ptr->background.gray << shift;
*sp = (png_byte)(tmp & 0xff);
} }
if (!shift) if (!shift)
@ -3536,17 +3537,19 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
if ((png_uint_16)((*sp >> shift) & 0x03) if ((png_uint_16)((*sp >> shift) & 0x03)
== png_ptr->trans_color.gray) == png_ptr->trans_color.gray)
{ {
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
*sp |= (png_byte)(png_ptr->background.gray << shift); tmp |= png_ptr->background.gray << shift;
*sp = (png_byte)(tmp & 0xff);
} }
else else
{ {
png_byte p = (png_byte)((*sp >> shift) & 0x03); unsigned int p = (*sp >> shift) & 0x03;
png_byte g = (png_byte)((gamma_table [p | (p << 2) | unsigned int g = (gamma_table [p | (p << 2) |
(p << 4) | (p << 6)] >> 6) & 0x03); (p << 4) | (p << 6)] >> 6) & 0x03;
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
*sp |= (png_byte)(g << shift); tmp |= g << shift;
*sp = (png_byte)(tmp & 0xff);
} }
if (!shift) if (!shift)
@ -3570,8 +3573,9 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
if ((png_uint_16)((*sp >> shift) & 0x03) if ((png_uint_16)((*sp >> shift) & 0x03)
== png_ptr->trans_color.gray) == png_ptr->trans_color.gray)
{ {
*sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
*sp |= (png_byte)(png_ptr->background.gray << shift); tmp |= png_ptr->background.gray << shift;
*sp = (png_byte)(tmp & 0xff);
} }
if (!shift) if (!shift)
@ -3599,17 +3603,19 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
if ((png_uint_16)((*sp >> shift) & 0x0f) if ((png_uint_16)((*sp >> shift) & 0x0f)
== png_ptr->trans_color.gray) == png_ptr->trans_color.gray)
{ {
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); unsigned int tmp = *sp & (0xf0f >> (4 - shift));
*sp |= (png_byte)(png_ptr->background.gray << shift); tmp |= png_ptr->background.gray << shift;
*sp = (png_byte)(tmp & 0xff);
} }
else else
{ {
png_byte p = (png_byte)((*sp >> shift) & 0x0f); unsigned int p = (*sp >> shift) & 0x0f;
png_byte g = (png_byte)((gamma_table[p | unsigned int g = (gamma_table[p | (p << 4)] >> 4) &
(p << 4)] >> 4) & 0x0f); 0x0f;
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); unsigned int tmp = *sp & (0xf0f >> (4 - shift));
*sp |= (png_byte)(g << shift); tmp |= g << shift;
*sp = (png_byte)(tmp & 0xff);
} }
if (!shift) if (!shift)
@ -3633,8 +3639,9 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
if ((png_uint_16)((*sp >> shift) & 0x0f) if ((png_uint_16)((*sp >> shift) & 0x0f)
== png_ptr->trans_color.gray) == png_ptr->trans_color.gray)
{ {
*sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); unsigned int tmp = *sp & (0xf0f >> (4 - shift));
*sp |= (png_byte)(png_ptr->background.gray << shift); tmp |= png_ptr->background.gray << shift;
*sp = (png_byte)(tmp & 0xff);
} }
if (!shift) if (!shift)
@ -4617,7 +4624,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
{ {
if (row_info->color_type == PNG_COLOR_TYPE_GRAY) if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
{ {
png_uint_16 gray = (png_uint_16)(trans_color ? trans_color->gray : 0); unsigned int gray = trans_color ? trans_color->gray : 0;
if (row_info->bit_depth < 8) if (row_info->bit_depth < 8)
{ {
@ -4625,7 +4632,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
{ {
case 1: case 1:
{ {
gray = (png_uint_16)((gray & 0x01) * 0xff); gray = (gray & 0x01) * 0xff;
sp = row + (png_size_t)((row_width - 1) >> 3); sp = row + (png_size_t)((row_width - 1) >> 3);
dp = row + (png_size_t)row_width - 1; dp = row + (png_size_t)row_width - 1;
shift = 7 - (int)((row_width + 7) & 0x07); shift = 7 - (int)((row_width + 7) & 0x07);
@ -4653,7 +4660,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
case 2: case 2:
{ {
gray = (png_uint_16)((gray & 0x03) * 0x55); gray = (gray & 0x03) * 0x55;
sp = row + (png_size_t)((row_width - 1) >> 2); sp = row + (png_size_t)((row_width - 1) >> 2);
dp = row + (png_size_t)row_width - 1; dp = row + (png_size_t)row_width - 1;
shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
@ -4678,7 +4685,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
case 4: case 4:
{ {
gray = (png_uint_16)((gray & 0x0f) * 0x11); gray = (gray & 0x0f) * 0x11;
sp = row + (png_size_t)((row_width - 1) >> 1); sp = row + (png_size_t)((row_width - 1) >> 1);
dp = row + (png_size_t)row_width - 1; dp = row + (png_size_t)row_width - 1;
shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
@ -4731,8 +4738,8 @@ png_do_expand(png_row_infop row_info, png_bytep row,
else if (row_info->bit_depth == 16) else if (row_info->bit_depth == 16)
{ {
png_byte gray_high = (png_byte)((gray >> 8) & 0xff); unsigned int gray_high = (gray >> 8) & 0xff;
png_byte gray_low = (png_byte)(gray & 0xff); unsigned int gray_low = gray & 0xff;
sp = row + row_info->rowbytes - 1; sp = row + row_info->rowbytes - 1;
dp = row + (row_info->rowbytes << 1) - 1; dp = row + (row_info->rowbytes << 1) - 1;
for (i = 0; i < row_width; i++) for (i = 0; i < row_width; i++)

View File

@ -3315,8 +3315,9 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
v = (png_byte)((*sp >> sshift) & 0x01); v = (png_byte)((*sp >> sshift) & 0x01);
for (j = 0; j < jstop; j++) for (j = 0; j < jstop; j++)
{ {
*dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); unsigned int tmp = *dp & (0x7f7f >> (7 - dshift));
*dp |= (png_byte)(v << dshift); tmp |= v << dshift;
*dp = (png_byte)(tmp & 0xff);
if (dshift == s_end) if (dshift == s_end)
{ {
@ -3377,8 +3378,9 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
v = (png_byte)((*sp >> sshift) & 0x03); v = (png_byte)((*sp >> sshift) & 0x03);
for (j = 0; j < jstop; j++) for (j = 0; j < jstop; j++)
{ {
*dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); unsigned int tmp = *dp & (0x3f3f >> (6 - dshift));
*dp |= (png_byte)(v << dshift); tmp |= v << dshift;
*dp = (png_byte)(tmp & 0xff);
if (dshift == s_end) if (dshift == s_end)
{ {
@ -3438,8 +3440,9 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
for (j = 0; j < jstop; j++) for (j = 0; j < jstop; j++)
{ {
*dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); unsigned int tmp = *dp & (0xf0f >> (4 - dshift));
*dp |= (png_byte)(v << dshift); tmp |= v << dshift;
*dp = (png_byte)(tmp & 0xff);
if (dshift == s_end) if (dshift == s_end)
{ {

View File

@ -89,8 +89,6 @@ static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present";
static int verbose = 0; static int verbose = 0;
static int strict = 0; static int strict = 0;
int test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname));
#ifdef __TURBOC__ #ifdef __TURBOC__
#include <mem.h> #include <mem.h>
#endif #endif
@ -109,9 +107,7 @@ static int status_pass = 1;
static int status_dots_requested = 0; static int status_dots_requested = 0;
static int status_dots = 1; static int status_dots = 1;
void PNGCBAPI static void PNGCBAPI
read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);
void PNGCBAPI
read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
{ {
if (png_ptr == NULL || row_number > PNG_UINT_31_MAX) if (png_ptr == NULL || row_number > PNG_UINT_31_MAX)
@ -135,9 +131,7 @@ read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
fprintf(stdout, "r"); fprintf(stdout, "r");
} }
void PNGCBAPI static void PNGCBAPI
write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);
void PNGCBAPI
write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
{ {
if (png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7) if (png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7)
@ -153,9 +147,7 @@ write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
* 5 in case illegal filter values are present.) * 5 in case illegal filter values are present.)
*/ */
static png_uint_32 filters_used[256]; static png_uint_32 filters_used[256];
void PNGCBAPI static void PNGCBAPI
count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data);
void PNGCBAPI
count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data) count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)
{ {
if (png_ptr != NULL && row_info != NULL) if (png_ptr != NULL && row_info != NULL)
@ -170,9 +162,7 @@ count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)
static png_uint_32 zero_samples; static png_uint_32 zero_samples;
void PNGCBAPI static void PNGCBAPI
count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data);
void PNGCBAPI
count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
{ {
png_bytep dp = data; png_bytep dp = data;
@ -636,7 +626,7 @@ static int PNGCBAPI read_user_chunk_callback(png_struct *png_ptr,
/* END of code to demonstrate user chunk support */ /* END of code to demonstrate user chunk support */
/* Test one file */ /* Test one file */
int static int
test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
{ {
static png_FILE_p fpin; static png_FILE_p fpin;

View File

@ -648,7 +648,7 @@ png_get_user_transform_ptr(png_const_structrp png_ptr)
if (png_ptr == NULL) if (png_ptr == NULL)
return (NULL); return (NULL);
return ((png_voidp)png_ptr->user_transform_ptr); return png_ptr->user_transform_ptr;
} }
#endif #endif

View File

@ -287,7 +287,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
{ {
png_bytep bp = row; png_bytep bp = row;
png_size_t i; png_size_t i;
png_byte mask; unsigned int mask;
png_size_t row_bytes = row_info->rowbytes; png_size_t row_bytes = row_info->rowbytes;
if (bit_depth->gray == 1 && row_info->bit_depth == 2) if (bit_depth->gray == 1 && row_info->bit_depth == 2)
@ -301,20 +301,22 @@ png_do_shift(png_row_infop row_info, png_bytep row,
for (i = 0; i < row_bytes; i++, bp++) for (i = 0; i < row_bytes; i++, bp++)
{ {
png_uint_16 v;
int j; int j;
unsigned int v, out;
v = *bp; v = *bp;
*bp = 0; out = 0;
for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0]) for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])
{ {
if (j > 0) if (j > 0)
*bp |= (png_byte)((v << j) & 0xff); out |= v << j;
else else
*bp |= (png_byte)((v >> (-j)) & mask); out |= (v >> (-j)) & mask;
} }
*bp = (png_byte)(out & 0xff);
} }
} }
@ -327,21 +329,23 @@ png_do_shift(png_row_infop row_info, png_bytep row,
for (i = 0; i < istop; i++, bp++) for (i = 0; i < istop; i++, bp++)
{ {
png_uint_16 v; const unsigned int c = i%channels;
int j; int j;
int c = (int)(i%channels); unsigned int v, out;
v = *bp; v = *bp;
*bp = 0; out = 0;
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
{ {
if (j > 0) if (j > 0)
*bp |= (png_byte)((v << j) & 0xff); out |= v << j;
else else
*bp |= (png_byte)((v >> (-j)) & 0xff); out |= v >> (-j);
} }
*bp = (png_byte)(out & 0xff);
} }
} }
@ -353,22 +357,22 @@ png_do_shift(png_row_infop row_info, png_bytep row,
for (bp = row, i = 0; i < istop; i++) for (bp = row, i = 0; i < istop; i++)
{ {
int c = (int)(i%channels); const unsigned int c = i%channels;
png_uint_16 value, v;
int j; int j;
unsigned int value, v;
v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1)); v = png_get_uint_16(bp);
value = 0; value = 0;
for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])
{ {
if (j > 0) if (j > 0)
value |= (png_uint_16)((v << j) & (png_uint_16)0xffff); value |= v << j;
else else
value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff); value |= v >> (-j);
} }
*bp++ = (png_byte)(value >> 8); *bp++ = (png_byte)((value >> 8) & 0xff);
*bp++ = (png_byte)(value & 0xff); *bp++ = (png_byte)(value & 0xff);
} }
} }