[libpng16] Fixed build warnings (MSVC, GCC, GCC v3). Cygwin GCC with default
options declares 'index' as a global, causing a warning if it is used as a local variable. GCC 64-bit warns about assigning a (size_t) (unsigned 64-bit) to an (int) (signed 32-bit). MSVC, however, warns about using the unary '-' operator on an unsigned value (even though it is well defined by ANSI-C to be ~x+1). The padding calculation was changed to use a different method. Removed the tests on png_ptr->pass.
This commit is contained in:
parent
434801a39c
commit
29a6ba01a7
11
ANNOUNCE
11
ANNOUNCE
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Libpng 1.6.0beta16 - March 3, 2012
|
Libpng 1.6.0beta16 - March 4, 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.
|
||||||
@ -258,9 +258,16 @@ Version 1.6.0beta15 [March 2, 2012]
|
|||||||
without the necessary color data.
|
without the necessary color data.
|
||||||
Removed whitespace from the end of lines in all source files and scripts.
|
Removed whitespace from the end of lines in all source files and scripts.
|
||||||
|
|
||||||
Version 1.6.0beta16 [March 3, 2012]
|
Version 1.6.0beta16 [March 4, 2012]
|
||||||
Relocated palette-index checking function from pngrutil.c to pngtrans.c
|
Relocated palette-index checking function from pngrutil.c to pngtrans.c
|
||||||
Added palette-index checking while writing.
|
Added palette-index checking while writing.
|
||||||
|
Fixed build warnings (MSVC, GCC, GCC v3). Cygwin GCC with default options
|
||||||
|
declares 'index' as a global, causing a warning if it is used as a local
|
||||||
|
variable. GCC 64-bit warns about assigning a (size_t) (unsigned 64-bit)
|
||||||
|
to an (int) (signed 32-bit). MSVC, however, warns about using the
|
||||||
|
unary '-' operator on an unsigned value (even though it is well defined
|
||||||
|
by ANSI-C to be ~x+1). The padding calculation was changed to use a
|
||||||
|
different method. Removed the tests on png_ptr->pass.
|
||||||
|
|
||||||
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
|
||||||
|
9
CHANGES
9
CHANGES
@ -4009,9 +4009,16 @@ Version 1.6.0beta15 [March 2, 2012]
|
|||||||
without the necessary color data.
|
without the necessary color data.
|
||||||
Removed whitespace from the end of lines in all source files and scripts.
|
Removed whitespace from the end of lines in all source files and scripts.
|
||||||
|
|
||||||
Version 1.6.0beta16 [March 3, 2012]
|
Version 1.6.0beta16 [March 4, 2012]
|
||||||
Relocated palette-index checking function from pngrutil.c to pngtrans.c
|
Relocated palette-index checking function from pngrutil.c to pngtrans.c
|
||||||
Added palette-index checking while writing.
|
Added palette-index checking while writing.
|
||||||
|
Fixed build warnings (MSVC, GCC, GCC v3). Cygwin GCC with default options
|
||||||
|
declares 'index' as a global, causing a warning if it is used as a local
|
||||||
|
variable. GCC 64-bit warns about assigning a (size_t) (unsigned 64-bit)
|
||||||
|
to an (int) (signed 32-bit). MSVC, however, warns about using the
|
||||||
|
unary '-' operator on an unsigned value (even though it is well defined
|
||||||
|
by ANSI-C to be ~x+1). The padding calculation was changed to use a
|
||||||
|
different method. Removed the tests on png_ptr->pass.
|
||||||
|
|
||||||
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
|
||||||
|
58
pngtrans.c
58
pngtrans.c
@ -625,11 +625,16 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
|||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
||||||
{
|
{
|
||||||
if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
|
if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
|
||||||
png_ptr->num_palette_max >= 0 &&
|
png_ptr->num_palette_max >= 0)
|
||||||
((png_ptr->interlaced && png_ptr->pass == 6) ||
|
|
||||||
(!png_ptr->interlaced && png_ptr->pass == 0)))
|
|
||||||
{
|
{
|
||||||
|
/* Calculations moved outside switch in an attempt to stop different
|
||||||
|
* compiler warnings. 'padding' is in *bits* within the last byte, it is
|
||||||
|
* an 'int' because pixel_depth becomes an 'int' in the expression below,
|
||||||
|
* and this calculation is used because it avoids warnings that other
|
||||||
|
* forms produced on either GCC or MSVC.
|
||||||
|
*/
|
||||||
|
int padding = (-row_info->pixel_depth * row_info->width) & 7;
|
||||||
png_bytep rp = png_ptr->row_buf + 1 + row_info->rowbytes;
|
png_bytep rp = png_ptr->row_buf + 1 + row_info->rowbytes;
|
||||||
|
|
||||||
switch (row_info->bit_depth)
|
switch (row_info->bit_depth)
|
||||||
@ -639,8 +644,6 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
/* in this case, all bytes must be 0 so we don't need
|
/* in this case, all bytes must be 0 so we don't need
|
||||||
* to unpack the pixels except for the rightmost one.
|
* to unpack the pixels except for the rightmost one.
|
||||||
*/
|
*/
|
||||||
int padding = 8*row_info->rowbytes - png_ptr->width;
|
|
||||||
|
|
||||||
for (; rp > png_ptr->row_buf; rp--)
|
for (; rp > png_ptr->row_buf; rp--)
|
||||||
{
|
{
|
||||||
if (*rp >> padding != 0)
|
if (*rp >> padding != 0)
|
||||||
@ -653,29 +656,27 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
int padding = 2*(4*row_info->rowbytes - png_ptr->width);
|
|
||||||
|
|
||||||
for (; rp > png_ptr->row_buf; rp--)
|
for (; rp > png_ptr->row_buf; rp--)
|
||||||
{
|
{
|
||||||
int index = ((*rp >> padding) & 0x03);
|
int i = ((*rp >> padding) & 0x03);
|
||||||
|
|
||||||
if (index > png_ptr->num_palette_max)
|
if (i > png_ptr->num_palette_max)
|
||||||
png_ptr->num_palette_max = index;
|
png_ptr->num_palette_max = i;
|
||||||
|
|
||||||
index = (((*rp >> padding) >> 2) & 0x03);
|
i = (((*rp >> padding) >> 2) & 0x03);
|
||||||
|
|
||||||
if (index > png_ptr->num_palette_max)
|
if (i > png_ptr->num_palette_max)
|
||||||
png_ptr->num_palette_max = index;
|
png_ptr->num_palette_max = i;
|
||||||
|
|
||||||
index = (((*rp >> padding) >> 4) & 0x03);
|
i = (((*rp >> padding) >> 4) & 0x03);
|
||||||
|
|
||||||
if (index > png_ptr->num_palette_max)
|
if (i > png_ptr->num_palette_max)
|
||||||
png_ptr->num_palette_max = index;
|
png_ptr->num_palette_max = i;
|
||||||
|
|
||||||
index = (((*rp >> padding) >> 6) & 0x03);
|
i = (((*rp >> padding) >> 6) & 0x03);
|
||||||
|
|
||||||
if (index > png_ptr->num_palette_max)
|
if (i > png_ptr->num_palette_max)
|
||||||
png_ptr->num_palette_max = index;
|
png_ptr->num_palette_max = i;
|
||||||
|
|
||||||
padding = 0;
|
padding = 0;
|
||||||
}
|
}
|
||||||
@ -685,19 +686,17 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
int padding = 4*(2*row_info->rowbytes - png_ptr->width);
|
|
||||||
|
|
||||||
for (; rp > png_ptr->row_buf; rp--)
|
for (; rp > png_ptr->row_buf; rp--)
|
||||||
{
|
{
|
||||||
int index = ((*rp >> padding) & 0x0f);
|
int i = ((*rp >> padding) & 0x0f);
|
||||||
|
|
||||||
if (index > png_ptr->num_palette_max)
|
if (i > png_ptr->num_palette_max)
|
||||||
png_ptr->num_palette_max = index;
|
png_ptr->num_palette_max = i;
|
||||||
|
|
||||||
index = (((*rp >> padding) >> 4) & 0x0f);
|
i = (((*rp >> padding) >> 4) & 0x0f);
|
||||||
|
|
||||||
if (index > png_ptr->num_palette_max)
|
if (i > png_ptr->num_palette_max)
|
||||||
png_ptr->num_palette_max = index;
|
png_ptr->num_palette_max = i;
|
||||||
|
|
||||||
padding = 0;
|
padding = 0;
|
||||||
}
|
}
|
||||||
@ -715,6 +714,9 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user