[libpng16] More cosmetic changes

This commit is contained in:
Glenn Randers-Pehrson 2014-11-01 13:18:36 -05:00
parent f2d4167fee
commit b963feeec6
8 changed files with 37 additions and 32 deletions

5
png.c
View File

@ -1634,14 +1634,15 @@ png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr,
png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ, png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ,
int preferred) int preferred)
{ {
if (colorspace->flags & PNG_COLORSPACE_INVALID) if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
return 0; return 0;
/* The consistency check is performed on the chromaticities; this factors out /* The consistency check is performed on the chromaticities; this factors out
* variations because of the normalization (or not) of the end point Y * variations because of the normalization (or not) of the end point Y
* values. * values.
*/ */
if (preferred < 2 && (colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) if (preferred < 2 &&
(colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{ {
/* The end points must be reasonably close to any we already have. The /* The end points must be reasonably close to any we already have. The
* following allows an error of up to +/-.001 * following allows an error of up to +/-.001

View File

@ -182,7 +182,8 @@ png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp
info_ptr) info_ptr)
{ {
#ifdef PNG_READ_pHYs_SUPPORTED #ifdef PNG_READ_pHYs_SUPPORTED
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0)
{ {
png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");

View File

@ -232,7 +232,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
png_error(png_ptr, "Missing IHDR before IDAT"); png_error(png_ptr, "Missing IHDR before IDAT");
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
!(png_ptr->mode & PNG_HAVE_PLTE)) (png_ptr->mode & PNG_HAVE_PLTE) == 0)
png_error(png_ptr, "Missing PLTE before IDAT"); png_error(png_ptr, "Missing PLTE before IDAT");
png_ptr->mode |= PNG_HAVE_IDAT; png_ptr->mode |= PNG_HAVE_IDAT;

View File

@ -126,7 +126,7 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
png_ptr->mode |= PNG_HAVE_IDAT; png_ptr->mode |= PNG_HAVE_IDAT;
} }
else if (png_ptr->mode & PNG_HAVE_IDAT) else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
png_ptr->mode |= PNG_AFTER_IDAT; png_ptr->mode |= PNG_AFTER_IDAT;
/* This should be a binary subdivision search or a hash for /* This should be a binary subdivision search or a hash for
@ -315,7 +315,7 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
png_debug(1, "in png_do_read_intrapixel"); png_debug(1, "in png_do_read_intrapixel");
if ( if (
(row_info->color_type & PNG_COLOR_MASK_COLOR)) (row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
{ {
int bytes_per_pixel; int bytes_per_pixel;
png_uint_32 row_width = row_info->width; png_uint_32 row_width = row_info->width;
@ -401,38 +401,38 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
{ {
/* Check for transforms that have been set but were defined out */ /* Check for transforms that have been set but were defined out */
#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED) #if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED)
if (png_ptr->transformations & PNG_INVERT_MONO) if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined"); png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined");
#endif #endif
#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED) #if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED)
if (png_ptr->transformations & PNG_FILLER) if ((png_ptr->transformations & PNG_FILLER) != 0)
png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined"); png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined");
#endif #endif
#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \ #if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \
!defined(PNG_READ_PACKSWAP_SUPPORTED) !defined(PNG_READ_PACKSWAP_SUPPORTED)
if (png_ptr->transformations & PNG_PACKSWAP) if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined"); png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined");
#endif #endif
#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED) #if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED)
if (png_ptr->transformations & PNG_PACK) if ((png_ptr->transformations & PNG_PACK) != 0)
png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined"); png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined");
#endif #endif
#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) #if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED)
if (png_ptr->transformations & PNG_SHIFT) if ((png_ptr->transformations & PNG_SHIFT) != 0)
png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined"); png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined");
#endif #endif
#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED) #if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED)
if (png_ptr->transformations & PNG_BGR) if ((png_ptr->transformations & PNG_BGR) != 0)
png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined"); png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined");
#endif #endif
#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED) #if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED)
if (png_ptr->transformations & PNG_SWAP_BYTES) if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined"); png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined");
#endif #endif
} }
@ -445,7 +445,8 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
* untransformed) and, because of the libpng API for interlaced images, this * untransformed) and, because of the libpng API for interlaced images, this
* means we must transform before de-interlacing. * means we must transform before de-interlacing.
*/ */
if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) if (png_ptr->interlaced != 0 &&
(png_ptr->transformations & PNG_INTERLACE) != 0)
{ {
switch (png_ptr->pass) switch (png_ptr->pass)
{ {
@ -549,7 +550,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1); memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
#ifdef PNG_MNG_FEATURES_SUPPORTED #ifdef PNG_MNG_FEATURES_SUPPORTED
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
(png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
{ {
/* Intrapixel differencing */ /* Intrapixel differencing */
@ -575,8 +576,8 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
#ifdef PNG_READ_INTERLACING_SUPPORTED #ifdef PNG_READ_INTERLACING_SUPPORTED
/* Expand interlaced rows to full size */ /* Expand interlaced rows to full size */
if (png_ptr->interlaced && if (png_ptr->interlaced != 0 &&
(png_ptr->transformations & PNG_INTERLACE)) (png_ptr->transformations & PNG_INTERLACE) != 0)
{ {
if (png_ptr->pass < 6) if (png_ptr->pass < 6)
png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass, png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,
@ -707,7 +708,8 @@ png_read_image(png_structrp png_ptr, png_bytepp image)
} }
else else
{ {
if (png_ptr->interlaced && !(png_ptr->transformations & PNG_INTERLACE)) if (png_ptr->interlaced != 0 &&
(png_ptr->transformations & PNG_INTERLACE) == 0)
{ {
/* Caller called png_start_read_image or png_read_update_info without /* Caller called png_start_read_image or png_read_update_info without
* first turning on the PNG_INTERLACE transform. We can fix this here, * first turning on the PNG_INTERLACE transform. We can fix this here,
@ -909,7 +911,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
else else
png_handle_unknown(png_ptr, info_ptr, length, png_handle_unknown(png_ptr, info_ptr, length,
PNG_HANDLE_CHUNK_AS_DEFAULT); PNG_HANDLE_CHUNK_AS_DEFAULT);
} while (!(png_ptr->mode & PNG_HAVE_IEND)); } while ((png_ptr->mode & PNG_HAVE_IEND) == 0);
} }
#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ #endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
@ -1734,7 +1736,7 @@ png_create_colormap_entry(png_image_read_control *display,
png_uint_32 alpha, int encoding) png_uint_32 alpha, int encoding)
{ {
png_imagep image = display->image; png_imagep image = display->image;
const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) ? const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
P_LINEAR : P_sRGB; P_LINEAR : P_sRGB;
const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 && const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
(red != green || green != blue); (red != green || green != blue);
@ -1850,7 +1852,7 @@ png_create_colormap_entry(png_image_read_control *display,
# define afirst 0 # define afirst 0
# endif # endif
# ifdef PNG_FORMAT_BGR_SUPPORTED # ifdef PNG_FORMAT_BGR_SUPPORTED
const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) ? 2 : 0; const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
# else # else
# define bgr 0 # define bgr 0
# endif # endif
@ -2062,7 +2064,7 @@ png_image_read_colormap(png_voidp argument)
const png_structrp png_ptr = image->opaque->png_ptr; const png_structrp png_ptr = image->opaque->png_ptr;
const png_uint_32 output_format = image->format; const png_uint_32 output_format = image->format;
const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) ? const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
P_LINEAR : P_sRGB; P_LINEAR : P_sRGB;
unsigned int cmap_entries; unsigned int cmap_entries;
@ -3243,7 +3245,8 @@ png_image_read_composite(png_voidp argument)
png_uint_32 height = image->height; png_uint_32 height = image->height;
png_uint_32 width = image->width; png_uint_32 width = image->width;
ptrdiff_t step_row = display->row_bytes; ptrdiff_t step_row = display->row_bytes;
unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1; unsigned int channels =
(image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
int pass; int pass;
for (pass = 0; pass < passes; ++pass) for (pass = 0; pass < passes; ++pass)
@ -3542,7 +3545,7 @@ png_image_read_background(png_voidp argument)
# ifdef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED # ifdef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
if (preserve_alpha != 0 && if (preserve_alpha != 0 &&
(image->format & PNG_FORMAT_FLAG_AFIRST)) (image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
swap_alpha = 1; swap_alpha = 1;
# endif # endif

View File

@ -4838,7 +4838,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
*/ */
!((png_ptr->transformations & PNG_COMPOSE) && !((png_ptr->transformations & PNG_COMPOSE) &&
((png_ptr->num_trans != 0) || ((png_ptr->num_trans != 0) ||
(png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)) &&
#endif #endif
/* Because png_init_read_transformations transforms the palette, unless /* Because png_init_read_transformations transforms the palette, unless
* RGB_TO_GRAY will do the transform. * RGB_TO_GRAY will do the transform.

View File

@ -220,8 +220,8 @@ png_crc_finish(png_structrp png_ptr, png_uint_32 skip)
if (png_crc_error(png_ptr) != 0) if (png_crc_error(png_ptr) != 0)
{ {
if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0 ? if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0 ?
!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) : (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) == 0 :
(png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE)) (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE) != 0)
{ {
png_chunk_warning(png_ptr, "CRC error"); png_chunk_warning(png_ptr, "CRC error");
} }

View File

@ -1750,7 +1750,7 @@ png_write_image_16bit(png_voidp argument)
display->first_row); display->first_row);
png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row); png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row);
png_uint_16p row_end; png_uint_16p row_end;
const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1; const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
int aindex = 0; int aindex = 0;
png_uint_32 y = image->height; png_uint_32 y = image->height;
@ -1907,7 +1907,7 @@ png_write_image_8bit(png_voidp argument)
display->first_row); display->first_row);
png_bytep output_row = png_voidcast(png_bytep, display->local_row); png_bytep output_row = png_voidcast(png_bytep, display->local_row);
png_uint_32 y = image->height; png_uint_32 y = image->height;
const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1; const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0) if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
{ {
@ -2012,7 +2012,7 @@ png_image_set_PLTE(png_image_write_control *display)
# endif # endif
# ifdef PNG_FORMAT_BGR_SUPPORTED # ifdef PNG_FORMAT_BGR_SUPPORTED
const int bgr = (format & PNG_FORMAT_FLAG_BGR) ? 2 : 0; const int bgr = (format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
# else # else
# define bgr 0 # define bgr 0
# endif # endif

View File

@ -848,7 +848,7 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
*/ */
if ( if (
#ifdef PNG_MNG_FEATURES_SUPPORTED #ifdef PNG_MNG_FEATURES_SUPPORTED
!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) && ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) &&
(color_type == PNG_COLOR_TYPE_RGB || (color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA) && color_type == PNG_COLOR_TYPE_RGB_ALPHA) &&