[libpng16] Added pngvalid.c compile time checks for const APIs.

This commit is contained in:
John Bowler 2011-12-24 08:29:20 -06:00 committed by Glenn Randers-Pehrson
parent 939310bac1
commit d7c22fb7ec

View File

@ -78,6 +78,13 @@ typedef png_byte *png_const_bytep;
((png_fixed_point)(PNG_GAMMA_THRESHOLD * PNG_FP_1)) ((png_fixed_point)(PNG_GAMMA_THRESHOLD * PNG_FP_1))
#endif #endif
#if PNG_LIBPNG_VER < 10600
/* 1.6.0 constifies many APIs, the following exists to allow pngvalid to be
* compiled against earlier versions.
*/
# define png_const_strutp png_structp
#endif
#include "zlib.h" /* For crc32 */ #include "zlib.h" /* For crc32 */
#include <float.h> /* For floating point constants */ #include <float.h> /* For floating point constants */
@ -782,7 +789,7 @@ store_storefile(png_store *ps, png_uint_32 id)
/* Generate an error message (in the given buffer) */ /* Generate an error message (in the given buffer) */
static size_t static size_t
store_message(png_store *ps, png_structp pp, char *buffer, size_t bufsize, store_message(png_store *ps, png_const_structp pp, char *buffer, size_t bufsize,
size_t pos, PNG_CONST char *msg) size_t pos, PNG_CONST char *msg)
{ {
if (pp != NULL && pp == ps->pread) if (pp != NULL && pp == ps->pread)
@ -822,7 +829,7 @@ store_message(png_store *ps, png_structp pp, char *buffer, size_t bufsize,
/* Verbose output to the error stream: */ /* Verbose output to the error stream: */
static void static void
store_verbose(png_store *ps, png_structp pp, png_const_charp prefix, store_verbose(png_store *ps, png_const_structp pp, png_const_charp prefix,
png_const_charp message) png_const_charp message)
{ {
char buffer[512]; char buffer[512];
@ -837,7 +844,8 @@ store_verbose(png_store *ps, png_structp pp, png_const_charp prefix,
/* Log an error or warning - the relevant count is always incremented. */ /* Log an error or warning - the relevant count is always incremented. */
static void static void
store_log(png_store* ps, png_structp pp, png_const_charp message, int is_error) store_log(png_store* ps, png_const_structp pp, png_const_charp message,
int is_error)
{ {
/* The warning is copied to the error buffer if there are no errors and it is /* The warning is copied to the error buffer if there are no errors and it is
* the first warning. The error is copied to the error buffer if it is the * the first warning. The error is copied to the error buffer if it is the
@ -866,8 +874,9 @@ internal_error(png_store *ps, png_const_charp message)
/* Functions to use as PNG callbacks. */ /* Functions to use as PNG callbacks. */
static void static void
store_error(png_structp pp, png_const_charp message) /* PNG_NORETURN */ store_error(png_structp ppIn, png_const_charp message) /* PNG_NORETURN */
{ {
png_const_structp pp = ppIn;
png_store *ps = voidcast(png_store*, png_get_error_ptr(pp)); png_store *ps = voidcast(png_store*, png_get_error_ptr(pp));
if (!ps->expect_error) if (!ps->expect_error)
@ -881,8 +890,9 @@ store_error(png_structp pp, png_const_charp message) /* PNG_NORETURN */
} }
static void static void
store_warning(png_structp pp, png_const_charp message) store_warning(png_structp ppIn, png_const_charp message)
{ {
png_const_structp pp = ppIn;
png_store *ps = voidcast(png_store*, png_get_error_ptr(pp)); png_store *ps = voidcast(png_store*, png_get_error_ptr(pp));
if (!ps->expect_warning) if (!ps->expect_warning)
@ -896,7 +906,7 @@ store_warning(png_structp pp, png_const_charp message)
*/ */
/* Return a single row from the correct image. */ /* Return a single row from the correct image. */
static png_bytep static png_bytep
store_image_row(PNG_CONST png_store* ps, png_structp pp, int nImage, store_image_row(PNG_CONST png_store* ps, png_const_structp pp, int nImage,
png_uint_32 y) png_uint_32 y)
{ {
png_size_t coffset = (nImage * ps->image_h + y) * (ps->cb_row + 5) + 2; png_size_t coffset = (nImage * ps->image_h + y) * (ps->cb_row + 5) + 2;
@ -911,7 +921,7 @@ store_image_row(PNG_CONST png_store* ps, png_structp pp, int nImage,
} }
static void static void
store_image_free(png_store *ps, png_structp pp) store_image_free(png_store *ps, png_const_structp pp)
{ {
if (ps->image != NULL) if (ps->image != NULL)
{ {
@ -933,8 +943,8 @@ store_image_free(png_store *ps, png_structp pp)
} }
static void static void
store_ensure_image(png_store *ps, png_structp pp, int nImages, png_size_t cbRow, store_ensure_image(png_store *ps, png_const_structp pp, int nImages,
png_uint_32 cRows) png_size_t cbRow, png_uint_32 cRows)
{ {
png_size_t cb = nImages * cRows * (cbRow + 5); png_size_t cb = nImages * cRows * (cbRow + 5);
@ -999,7 +1009,7 @@ store_ensure_image(png_store *ps, png_structp pp, int nImages, png_size_t cbRow,
} }
static void static void
store_image_check(PNG_CONST png_store* ps, png_structp pp, int iImage) store_image_check(PNG_CONST png_store* ps, png_const_structp pp, int iImage)
{ {
png_const_bytep image = ps->image; png_const_bytep image = ps->image;
@ -1029,8 +1039,9 @@ store_image_check(PNG_CONST png_store* ps, png_structp pp, int iImage)
} }
static void static void
store_write(png_structp pp, png_bytep pb, png_size_t st) store_write(png_structp ppIn, png_bytep pb, png_size_t st)
{ {
png_const_structp pp = ppIn;
png_store *ps = voidcast(png_store*, png_get_io_ptr(pp)); png_store *ps = voidcast(png_store*, png_get_io_ptr(pp));
if (ps->pwrite != pp) if (ps->pwrite != pp)
@ -1056,9 +1067,9 @@ store_write(png_structp pp, png_bytep pb, png_size_t st)
} }
static void static void
store_flush(png_structp pp) store_flush(png_structp ppIn)
{ {
UNUSED(pp) /*DOES NOTHING*/ UNUSED(ppIn) /*DOES NOTHING*/
} }
static size_t static size_t
@ -1149,8 +1160,9 @@ store_read_imp(png_store *ps, png_bytep pb, png_size_t st)
} }
static void static void
store_read(png_structp pp, png_bytep pb, png_size_t st) store_read(png_structp ppIn, png_bytep pb, png_size_t st)
{ {
png_const_structp pp = ppIn;
png_store *ps = voidcast(png_store*, png_get_io_ptr(pp)); png_store *ps = voidcast(png_store*, png_get_io_ptr(pp));
if (ps == NULL || ps->pread != pp) if (ps == NULL || ps->pread != pp)
@ -1238,7 +1250,7 @@ typedef struct store_memory
* all the memory. * all the memory.
*/ */
static void static void
store_pool_error(png_store *ps, png_structp pp, PNG_CONST char *msg) store_pool_error(png_store *ps, png_const_structp pp, PNG_CONST char *msg)
{ {
if (pp != NULL) if (pp != NULL)
png_error(pp, msg); png_error(pp, msg);
@ -1251,7 +1263,7 @@ store_pool_error(png_store *ps, png_structp pp, PNG_CONST char *msg)
} }
static void static void
store_memory_free(png_structp pp, store_pool *pool, store_memory *memory) store_memory_free(png_const_structp pp, store_pool *pool, store_memory *memory)
{ {
/* Note that pp may be NULL (see store_pool_delete below), the caller has /* Note that pp may be NULL (see store_pool_delete below), the caller has
* found 'memory' in pool->list *and* unlinked this entry, so this is a valid * found 'memory' in pool->list *and* unlinked this entry, so this is a valid
@ -1337,8 +1349,9 @@ store_pool_delete(png_store *ps, store_pool *pool)
/* The memory callbacks: */ /* The memory callbacks: */
static png_voidp static png_voidp
store_malloc(png_structp pp, png_alloc_size_t cb) store_malloc(png_structp ppIn, png_alloc_size_t cb)
{ {
png_const_structp pp = ppIn;
store_pool *pool = voidcast(store_pool*, png_get_mem_ptr(pp)); store_pool *pool = voidcast(store_pool*, png_get_mem_ptr(pp));
store_memory *new = voidcast(store_memory*, malloc(cb + (sizeof *new) + store_memory *new = voidcast(store_memory*, malloc(cb + (sizeof *new) +
(sizeof pool->mark))); (sizeof pool->mark)));
@ -1385,8 +1398,9 @@ store_malloc(png_structp pp, png_alloc_size_t cb)
} }
static void static void
store_free(png_structp pp, png_voidp memory) store_free(png_structp ppIn, png_voidp memory)
{ {
png_const_structp pp = ppIn;
store_pool *pool = voidcast(store_pool*, png_get_mem_ptr(pp)); store_pool *pool = voidcast(store_pool*, png_get_mem_ptr(pp));
store_memory *this = voidcast(store_memory*, memory), **test; store_memory *this = voidcast(store_memory*, memory), **test;
@ -2540,8 +2554,9 @@ modifier_read_imp(png_modifier *pm, png_bytep pb, png_size_t st)
/* The callback: */ /* The callback: */
static void static void
modifier_read(png_structp pp, png_bytep pb, png_size_t st) modifier_read(png_structp ppIn, png_bytep pb, png_size_t st)
{ {
png_const_structp pp = ppIn;
png_modifier *pm = voidcast(png_modifier*, png_get_io_ptr(pp)); png_modifier *pm = voidcast(png_modifier*, png_get_io_ptr(pp));
if (pm == NULL || pm->this.pread != pp) if (pm == NULL || pm->this.pread != pp)
@ -2974,6 +2989,7 @@ make_standard_palette(png_store* ps, int npalette, int do_tRNS)
/* Initialize a standard palette on a write stream. The 'do_tRNS' argument /* Initialize a standard palette on a write stream. The 'do_tRNS' argument
* indicates whether or not to also set the tRNS chunk. * indicates whether or not to also set the tRNS chunk.
*/ */
/* TODO: the png_structp here can probably be 'const' in the future */
static void static void
init_standard_palette(png_store *ps, png_structp pp, png_infop pi, int npalette, init_standard_palette(png_store *ps, png_structp pp, png_infop pi, int npalette,
int do_tRNS) int do_tRNS)
@ -3022,7 +3038,7 @@ init_standard_palette(png_store *ps, png_structp pp, png_infop pi, int npalette,
* API to determine this prior to 1.5, so we need an inquiry function: * API to determine this prior to 1.5, so we need an inquiry function:
*/ */
static int static int
npasses_from_interlace_type(png_structp pp, int interlace_type) npasses_from_interlace_type(png_const_structp pp, int interlace_type)
{ {
switch (interlace_type) switch (interlace_type)
{ {
@ -3038,7 +3054,7 @@ npasses_from_interlace_type(png_structp pp, int interlace_type)
} }
static unsigned int static unsigned int
bit_size(png_structp pp, png_byte colour_type, png_byte bit_depth) bit_size(png_const_structp pp, png_byte colour_type, png_byte bit_depth)
{ {
switch (colour_type) switch (colour_type)
{ {
@ -3063,7 +3079,8 @@ bit_size(png_structp pp, png_byte colour_type, png_byte bit_depth)
#define SIZE_HEIGHTMAX 16 /* Maximum range of size images */ #define SIZE_HEIGHTMAX 16 /* Maximum range of size images */
static size_t static size_t
transform_rowsize(png_structp pp, png_byte colour_type, png_byte bit_depth) transform_rowsize(png_const_structp pp, png_byte colour_type,
png_byte bit_depth)
{ {
return (TRANSFORM_WIDTH * bit_size(pp, colour_type, bit_depth)) / 8; return (TRANSFORM_WIDTH * bit_size(pp, colour_type, bit_depth)) / 8;
} }
@ -3074,7 +3091,7 @@ transform_rowsize(png_structp pp, png_byte colour_type, png_byte bit_depth)
#define transform_width(pp, colour_type, bit_depth) TRANSFORM_WIDTH #define transform_width(pp, colour_type, bit_depth) TRANSFORM_WIDTH
static png_uint_32 static png_uint_32
transform_height(png_structp pp, png_byte colour_type, png_byte bit_depth) transform_height(png_const_structp pp, png_byte colour_type, png_byte bit_depth)
{ {
switch (bit_size(pp, colour_type, bit_depth)) switch (bit_size(pp, colour_type, bit_depth))
{ {
@ -3107,7 +3124,7 @@ transform_height(png_structp pp, png_byte colour_type, png_byte bit_depth)
* of the transform image sizes. * of the transform image sizes.
*/ */
static png_uint_32 static png_uint_32
standard_width(png_structp pp, png_uint_32 id) standard_width(png_const_structp pp, png_uint_32 id)
{ {
png_uint_32 width = WIDTH_FROM_ID(id); png_uint_32 width = WIDTH_FROM_ID(id);
UNUSED(pp) UNUSED(pp)
@ -3119,7 +3136,7 @@ standard_width(png_structp pp, png_uint_32 id)
} }
static png_uint_32 static png_uint_32
standard_height(png_structp pp, png_uint_32 id) standard_height(png_const_structp pp, png_uint_32 id)
{ {
png_uint_32 height = HEIGHT_FROM_ID(id); png_uint_32 height = HEIGHT_FROM_ID(id);
@ -3130,7 +3147,7 @@ standard_height(png_structp pp, png_uint_32 id)
} }
static png_uint_32 static png_uint_32
standard_rowsize(png_structp pp, png_uint_32 id) standard_rowsize(png_const_structp pp, png_uint_32 id)
{ {
png_uint_32 width = standard_width(pp, id); png_uint_32 width = standard_width(pp, id);
@ -3140,7 +3157,7 @@ standard_rowsize(png_structp pp, png_uint_32 id)
} }
static void static void
transform_row(png_structp pp, png_byte buffer[TRANSFORM_ROWMAX], transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
png_byte colour_type, png_byte bit_depth, png_uint_32 y) png_byte colour_type, png_byte bit_depth, png_uint_32 y)
{ {
png_uint_32 v = y << 7; png_uint_32 v = y << 7;
@ -3656,8 +3673,8 @@ make_size_images(png_store *ps)
/* Return a row based on image id and 'y' for checking: */ /* Return a row based on image id and 'y' for checking: */
static void static void
standard_row(png_structp pp, png_byte std[STANDARD_ROWMAX], png_uint_32 id, standard_row(png_const_structp pp, png_byte std[STANDARD_ROWMAX],
png_uint_32 y) png_uint_32 id, png_uint_32 y)
{ {
if (WIDTH_FROM_ID(id) == 0) if (WIDTH_FROM_ID(id) == 0)
transform_row(pp, std, COL_FROM_ID(id), DEPTH_FROM_ID(id), y); transform_row(pp, std, COL_FROM_ID(id), DEPTH_FROM_ID(id), y);
@ -3671,6 +3688,9 @@ standard_row(png_structp pp, png_byte std[STANDARD_ROWMAX], png_uint_32 id,
* to ensure that they get detected - it should not be possible to write an * to ensure that they get detected - it should not be possible to write an
* invalid image with libpng! * invalid image with libpng!
*/ */
/* TODO: the 'set' functions can probably all be made to take a
* png_const_structp rather than a modifiable one.
*/
#ifdef PNG_WARNINGS_SUPPORTED #ifdef PNG_WARNINGS_SUPPORTED
static void static void
sBIT0_error_fn(png_structp pp, png_infop pi) sBIT0_error_fn(png_structp pp, png_infop pi)
@ -4074,7 +4094,8 @@ standard_palette_init(standard_display *dp)
* palette (it does not check for a transparent colour in the non-palette case.) * palette (it does not check for a transparent colour in the non-palette case.)
*/ */
static int static int
read_palette(store_palette palette, int *npalette, png_structp pp, png_infop pi) read_palette(store_palette palette, int *npalette, png_const_structp pp,
png_infop pi)
{ {
png_colorp pal; png_colorp pal;
png_bytep trans_alpha; png_bytep trans_alpha;
@ -4165,7 +4186,8 @@ read_palette(store_palette palette, int *npalette, png_structp pp, png_infop pi)
* non-transform case). * non-transform case).
*/ */
static void static void
standard_palette_validate(standard_display *dp, png_structp pp, png_infop pi) standard_palette_validate(standard_display *dp, png_const_structp pp,
png_infop pi)
{ {
int npalette; int npalette;
store_palette palette; store_palette palette;
@ -4359,8 +4381,8 @@ standard_info_part1(standard_display *dp, png_structp pp, png_infop pi)
* image. * image.
*/ */
static void static void
standard_info_part2(standard_display *dp, png_structp pp, png_infop pi, standard_info_part2(standard_display *dp, png_const_structp pp,
int nImages) png_const_infop pi, int nImages)
{ {
/* Record cbRow now that it can be found. */ /* Record cbRow now that it can be found. */
dp->pixel_size = bit_size(pp, png_get_color_type(pp, pi), dp->pixel_size = bit_size(pp, png_get_color_type(pp, pi),
@ -4418,8 +4440,9 @@ standard_info(png_structp pp, png_infop pi)
} }
static void static void
progressive_row(png_structp pp, png_bytep new_row, png_uint_32 y, int pass) progressive_row(png_structp ppIn, png_bytep new_row, png_uint_32 y, int pass)
{ {
png_const_structp pp = ppIn;
PNG_CONST standard_display *dp = voidcast(standard_display*, PNG_CONST standard_display *dp = voidcast(standard_display*,
png_get_progressive_ptr(pp)); png_get_progressive_ptr(pp));
@ -4538,7 +4561,7 @@ sequential_row(standard_display *dp, png_structp pp, png_infop pi,
} }
static void static void
standard_row_validate(standard_display *dp, png_structp pp, standard_row_validate(standard_display *dp, png_const_structp pp,
int iImage, int iDisplay, png_uint_32 y) int iImage, int iDisplay, png_uint_32 y)
{ {
int where; int where;
@ -4594,7 +4617,7 @@ standard_row_validate(standard_display *dp, png_structp pp,
} }
static void static void
standard_image_validate(standard_display *dp, png_structp pp, int iImage, standard_image_validate(standard_display *dp, png_const_structp pp, int iImage,
int iDisplay) int iDisplay)
{ {
png_uint_32 y; png_uint_32 y;
@ -4613,8 +4636,9 @@ standard_image_validate(standard_display *dp, png_structp pp, int iImage,
} }
static void static void
standard_end(png_structp pp, png_infop pi) standard_end(png_structp ppIn, png_infop pi)
{ {
png_const_structp pp = ppIn;
standard_display *dp = voidcast(standard_display*, standard_display *dp = voidcast(standard_display*,
png_get_progressive_ptr(pp)); png_get_progressive_ptr(pp));
@ -5121,7 +5145,7 @@ typedef struct image_transform
* reporting via png_error and png_warning. * reporting via png_error and png_warning.
*/ */
void (*mod)(PNG_CONST struct image_transform *this, image_pixel *that, void (*mod)(PNG_CONST struct image_transform *this, image_pixel *that,
png_structp pp, PNG_CONST struct transform_display *display); png_const_structp pp, PNG_CONST struct transform_display *display);
/* Add this transform to the list and return true if the transform is /* Add this transform to the list and return true if the transform is
* meaningful for this colour type and bit depth - if false then the * meaningful for this colour type and bit depth - if false then the
@ -5216,7 +5240,7 @@ sample_scale(double sample_value, unsigned int scale)
static void static void
image_transform_mod_end(PNG_CONST image_transform *this, image_pixel *that, image_transform_mod_end(PNG_CONST image_transform *this, image_pixel *that,
png_structp pp, PNG_CONST transform_display *display) png_const_structp pp, PNG_CONST transform_display *display)
{ {
PNG_CONST unsigned int scale = (1U<<that->sample_depth)-1; PNG_CONST unsigned int scale = (1U<<that->sample_depth)-1;
@ -5445,7 +5469,7 @@ transform_info(png_structp pp, png_infop pi)
} }
static void static void
transform_range_check(png_structp pp, unsigned int r, unsigned int g, transform_range_check(png_const_structp pp, unsigned int r, unsigned int g,
unsigned int b, unsigned int a, unsigned int in_digitized, double in, unsigned int b, unsigned int a, unsigned int in_digitized, double in,
unsigned int out, png_byte sample_depth, double err, double limit, unsigned int out, png_byte sample_depth, double err, double limit,
PNG_CONST char *name, double digitization_error) PNG_CONST char *name, double digitization_error)
@ -5488,7 +5512,8 @@ transform_range_check(png_structp pp, unsigned int r, unsigned int g,
} }
static void static void
transform_image_validate(transform_display *dp, png_structp pp, png_infop pi) transform_image_validate(transform_display *dp, png_const_structp pp,
png_infop pi)
{ {
/* Constants for the loop below: */ /* Constants for the loop below: */
PNG_CONST png_store* PNG_CONST ps = dp->this.ps; PNG_CONST png_store* PNG_CONST ps = dp->this.ps;
@ -5646,8 +5671,9 @@ transform_image_validate(transform_display *dp, png_structp pp, png_infop pi)
} }
static void static void
transform_end(png_structp pp, png_infop pi) transform_end(png_structp ppIn, png_infop pi)
{ {
png_const_structp pp = ppIn;
transform_display *dp = voidcast(transform_display*, transform_display *dp = voidcast(transform_display*,
png_get_progressive_ptr(pp)); png_get_progressive_ptr(pp));
@ -5793,7 +5819,8 @@ image_transform_png_set_palette_to_rgb_set(PNG_CONST image_transform *this,
static void static void
image_transform_png_set_palette_to_rgb_mod(PNG_CONST image_transform *this, image_transform_png_set_palette_to_rgb_mod(PNG_CONST image_transform *this,
image_pixel *that, png_structp pp, PNG_CONST transform_display *display) image_pixel *that, png_const_structp pp,
PNG_CONST transform_display *display)
{ {
if (that->colour_type == PNG_COLOR_TYPE_PALETTE) if (that->colour_type == PNG_COLOR_TYPE_PALETTE)
image_pixel_convert_PLTE(that); image_pixel_convert_PLTE(that);
@ -5830,7 +5857,8 @@ image_transform_png_set_tRNS_to_alpha_set(PNG_CONST image_transform *this,
static void static void
image_transform_png_set_tRNS_to_alpha_mod(PNG_CONST image_transform *this, image_transform_png_set_tRNS_to_alpha_mod(PNG_CONST image_transform *this,
image_pixel *that, png_structp pp, PNG_CONST transform_display *display) image_pixel *that, png_const_structp pp,
PNG_CONST transform_display *display)
{ {
/* LIBPNG BUG: this always forces palette images to RGB. */ /* LIBPNG BUG: this always forces palette images to RGB. */
if (that->colour_type == PNG_COLOR_TYPE_PALETTE) if (that->colour_type == PNG_COLOR_TYPE_PALETTE)
@ -5887,7 +5915,8 @@ image_transform_png_set_gray_to_rgb_set(PNG_CONST image_transform *this,
static void static void
image_transform_png_set_gray_to_rgb_mod(PNG_CONST image_transform *this, image_transform_png_set_gray_to_rgb_mod(PNG_CONST image_transform *this,
image_pixel *that, png_structp pp, PNG_CONST transform_display *display) image_pixel *that, png_const_structp pp,
PNG_CONST transform_display *display)
{ {
/* NOTE: we can actually pend the tRNS processing at this point because we /* NOTE: we can actually pend the tRNS processing at this point because we
* can correctly recognize the original pixel value even though we have * can correctly recognize the original pixel value even though we have
@ -5945,7 +5974,8 @@ image_transform_png_set_expand_set(PNG_CONST image_transform *this,
static void static void
image_transform_png_set_expand_mod(PNG_CONST image_transform *this, image_transform_png_set_expand_mod(PNG_CONST image_transform *this,
image_pixel *that, png_structp pp, PNG_CONST transform_display *display) image_pixel *that, png_const_structp pp,
PNG_CONST transform_display *display)
{ {
/* The general expand case depends on what the colour type is: */ /* The general expand case depends on what the colour type is: */
if (that->colour_type == PNG_COLOR_TYPE_PALETTE) if (that->colour_type == PNG_COLOR_TYPE_PALETTE)
@ -5994,7 +6024,7 @@ image_transform_png_set_expand_gray_1_2_4_to_8_set(
static void static void
image_transform_png_set_expand_gray_1_2_4_to_8_mod( image_transform_png_set_expand_gray_1_2_4_to_8_mod(
PNG_CONST image_transform *this, image_pixel *that, png_structp pp, PNG_CONST image_transform *this, image_pixel *that, png_const_structp pp,
PNG_CONST transform_display *display) PNG_CONST transform_display *display)
{ {
image_transform_png_set_expand_mod(this, that, pp, display); image_transform_png_set_expand_mod(this, that, pp, display);
@ -6025,7 +6055,8 @@ image_transform_png_set_expand_16_set(PNG_CONST image_transform *this,
static void static void
image_transform_png_set_expand_16_mod(PNG_CONST image_transform *this, image_transform_png_set_expand_16_mod(PNG_CONST image_transform *this,
image_pixel *that, png_structp pp, PNG_CONST transform_display *display) image_pixel *that, png_const_structp pp,
PNG_CONST transform_display *display)
{ {
/* Expect expand_16 to expand everything to 16 bits as a result of also /* Expect expand_16 to expand everything to 16 bits as a result of also
* causing 'expand' to happen. * causing 'expand' to happen.
@ -6072,7 +6103,8 @@ image_transform_png_set_scale_16_set(PNG_CONST image_transform *this,
static void static void
image_transform_png_set_scale_16_mod(PNG_CONST image_transform *this, image_transform_png_set_scale_16_mod(PNG_CONST image_transform *this,
image_pixel *that, png_structp pp, PNG_CONST transform_display *display) image_pixel *that, png_const_structp pp,
PNG_CONST transform_display *display)
{ {
if (that->bit_depth == 16) if (that->bit_depth == 16)
{ {
@ -6115,7 +6147,8 @@ image_transform_png_set_strip_16_set(PNG_CONST image_transform *this,
static void static void
image_transform_png_set_strip_16_mod(PNG_CONST image_transform *this, image_transform_png_set_strip_16_mod(PNG_CONST image_transform *this,
image_pixel *that, png_structp pp, PNG_CONST transform_display *display) image_pixel *that, png_const_structp pp,
PNG_CONST transform_display *display)
{ {
if (that->bit_depth == 16) if (that->bit_depth == 16)
{ {
@ -6181,7 +6214,8 @@ image_transform_png_set_strip_alpha_set(PNG_CONST image_transform *this,
static void static void
image_transform_png_set_strip_alpha_mod(PNG_CONST image_transform *this, image_transform_png_set_strip_alpha_mod(PNG_CONST image_transform *this,
image_pixel *that, png_structp pp, PNG_CONST transform_display *display) image_pixel *that, png_const_structp pp,
PNG_CONST transform_display *display)
{ {
if (that->colour_type == PNG_COLOR_TYPE_GRAY_ALPHA) if (that->colour_type == PNG_COLOR_TYPE_GRAY_ALPHA)
that->colour_type = PNG_COLOR_TYPE_GRAY; that->colour_type = PNG_COLOR_TYPE_GRAY;
@ -6513,7 +6547,8 @@ image_transform_png_set_rgb_to_gray_set(PNG_CONST image_transform *this,
static void static void
image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this, image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
image_pixel *that, png_structp pp, PNG_CONST transform_display *display) image_pixel *that, png_const_structp pp,
PNG_CONST transform_display *display)
{ {
if ((that->colour_type & PNG_COLOR_MASK_COLOR) != 0) if ((that->colour_type & PNG_COLOR_MASK_COLOR) != 0)
{ {
@ -6764,7 +6799,8 @@ image_transform_png_set_background_set(PNG_CONST image_transform *this,
static void static void
image_transform_png_set_background_mod(PNG_CONST image_transform *this, image_transform_png_set_background_mod(PNG_CONST image_transform *this,
image_pixel *that, png_structp pp, PNG_CONST transform_display *display) image_pixel *that, png_const_structp pp,
PNG_CONST transform_display *display)
{ {
/* Check for tRNS first: */ /* Check for tRNS first: */
if (that->have_tRNS && that->colour_type != PNG_COLOR_TYPE_PALETTE) if (that->have_tRNS && that->colour_type != PNG_COLOR_TYPE_PALETTE)
@ -7014,7 +7050,8 @@ image_transform_png_set_@_set(PNG_CONST image_transform *this,
static void static void
image_transform_png_set_@_mod(PNG_CONST image_transform *this, image_transform_png_set_@_mod(PNG_CONST image_transform *this,
image_pixel *that, png_structp pp, PNG_CONST transform_display *display) image_pixel *that, png_const_structp pp,
PNG_CONST transform_display *display)
{ {
this->next->mod(this->next, that, pp, display); this->next->mod(this->next, that, pp, display);
} }
@ -7317,7 +7354,7 @@ gamma_info(png_structp pp, png_infop pi)
*/ */
typedef struct validate_info typedef struct validate_info
{ {
png_structp pp; png_const_structp pp;
gamma_display *dp; gamma_display *dp;
png_byte sbit; png_byte sbit;
int use_input_precision; int use_input_precision;
@ -7347,7 +7384,7 @@ typedef struct validate_info
validate_info; validate_info;
static void static void
init_validate_info(validate_info *vi, gamma_display *dp, png_struct *pp, init_validate_info(validate_info *vi, gamma_display *dp, png_const_structp pp,
int in_depth, int out_depth) int in_depth, int out_depth)
{ {
PNG_CONST unsigned int outmax = (1U<<out_depth)-1; PNG_CONST unsigned int outmax = (1U<<out_depth)-1;
@ -8060,7 +8097,8 @@ gamma_component_validate(PNG_CONST char *name, PNG_CONST validate_info *vi,
} }
static void static void
gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi) gamma_image_validate(gamma_display *dp, png_const_structp pp,
png_infop pi)
{ {
/* Get some constants derived from the input and output file formats: */ /* Get some constants derived from the input and output file formats: */
PNG_CONST png_store* PNG_CONST ps = dp->this.ps; PNG_CONST png_store* PNG_CONST ps = dp->this.ps;
@ -8249,8 +8287,9 @@ gamma_image_validate(gamma_display *dp, png_structp pp, png_infop pi)
} }
static void static void
gamma_end(png_structp pp, png_infop pi) gamma_end(png_structp ppIn, png_infop pi)
{ {
png_const_structp pp = ppIn;
gamma_display *dp = voidcast(gamma_display*, png_get_progressive_ptr(pp)); gamma_display *dp = voidcast(gamma_display*, png_get_progressive_ptr(pp));
if (!dp->this.speed) if (!dp->this.speed)