Remove top-level const from function-scope variables
As per the const correctness rules, top-level const-ness of data in automatic scopes does not propagate outside of these scopes (unlike const-ness at lower levels, such as pointers to const data). Previously, const was used liberally, but inconsistently across the libpng codebase. Using const wherever applicable is not incorrect. However, _consistent_ use of const is difficult to maintain in such conditions. In conclusion, we shall continue to use const only where doing so is strictly necessary: 1. If a function guarantees that it will not modify an argument passed by pointer, the corresponding function parameter should be a pointer-to-const (const T *). 2. Static data should not be modified, therefore it should be const. Reference: Google C++ Style Guide https://google.github.io/styleguide/cppguide.html#Use_of_const
This commit is contained in:
parent
1ef8882814
commit
ceb327789b
@ -73,7 +73,7 @@ static void
|
||||
print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||
png_uint_32 x)
|
||||
{
|
||||
const unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
||||
unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
||||
|
||||
switch (png_get_color_type(png_ptr, info_ptr))
|
||||
{
|
||||
@ -87,7 +87,7 @@ print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||
*/
|
||||
case PNG_COLOR_TYPE_PALETTE:
|
||||
{
|
||||
const int index = component(row, x, 0, bit_depth, 1);
|
||||
int index = component(row, x, 0, bit_depth, 1);
|
||||
png_colorp palette = NULL;
|
||||
int num_palette = 0;
|
||||
|
||||
|
@ -661,7 +661,7 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
const png_uint_32 luma = colors[1];
|
||||
png_uint_32 luma = colors[1];
|
||||
png_uint_32 x;
|
||||
|
||||
for (x=0; x<=size_max; ++x)
|
||||
@ -672,8 +672,8 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
|
||||
case 2:
|
||||
{
|
||||
const png_uint_32 luma = colors[1];
|
||||
const png_uint_32 alpha = colors[2];
|
||||
png_uint_32 luma = colors[1];
|
||||
png_uint_32 alpha = colors[2];
|
||||
png_uint_32 x;
|
||||
|
||||
for (x=0; x<size_max; ++x)
|
||||
@ -688,9 +688,9 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
|
||||
case 3:
|
||||
{
|
||||
const png_uint_32 red = colors[1];
|
||||
const png_uint_32 green = colors[2];
|
||||
const png_uint_32 blue = colors[3];
|
||||
png_uint_32 red = colors[1];
|
||||
png_uint_32 green = colors[2];
|
||||
png_uint_32 blue = colors[3];
|
||||
png_uint_32 x;
|
||||
|
||||
for (x=0; x<=size_max; ++x)
|
||||
@ -707,10 +707,10 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
|
||||
case 4:
|
||||
{
|
||||
const png_uint_32 red = colors[1];
|
||||
const png_uint_32 green = colors[2];
|
||||
const png_uint_32 blue = colors[3];
|
||||
const png_uint_32 alpha = colors[4];
|
||||
png_uint_32 red = colors[1];
|
||||
png_uint_32 green = colors[2];
|
||||
png_uint_32 blue = colors[3];
|
||||
png_uint_32 alpha = colors[4];
|
||||
png_uint_32 x;
|
||||
|
||||
for (x=0; x<=size_max; ++x)
|
||||
@ -812,7 +812,7 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
png_error(png_ptr, "OOM allocating info structure");
|
||||
|
||||
{
|
||||
const unsigned int size =
|
||||
unsigned int size =
|
||||
image_size_of_type(color_type, bit_depth, colors, small);
|
||||
unsigned int ysize;
|
||||
png_fixed_point real_gamma = 45455; /* For sRGB */
|
||||
@ -824,7 +824,7 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
*/
|
||||
if (small)
|
||||
{
|
||||
const unsigned int pixel_depth =
|
||||
unsigned int pixel_depth =
|
||||
pixel_depth_of_type(color_type, bit_depth);
|
||||
|
||||
if (pixel_depth <= 8U)
|
||||
@ -1378,10 +1378,10 @@ static void
|
||||
insert_sBIT(png_structp png_ptr, png_infop info_ptr, int nparams,
|
||||
png_charpp params)
|
||||
{
|
||||
const int ct = png_get_color_type(png_ptr, info_ptr);
|
||||
const int c = (ct & PNG_COLOR_MASK_COLOR ? 3 : 1) +
|
||||
int ct = png_get_color_type(png_ptr, info_ptr);
|
||||
int c = (ct & PNG_COLOR_MASK_COLOR ? 3 : 1) +
|
||||
(ct & PNG_COLOR_MASK_ALPHA ? 1 : 0);
|
||||
const unsigned int maxval =
|
||||
unsigned int maxval =
|
||||
ct & PNG_COLOR_MASK_PALETTE ? 8U : png_get_bit_depth(png_ptr, info_ptr);
|
||||
png_color_8 sBIT;
|
||||
|
||||
@ -1856,7 +1856,7 @@ main(int argc, char **argv)
|
||||
|
||||
/* Check the colors */
|
||||
{
|
||||
const unsigned int lim = (color_type == PNG_COLOR_TYPE_PALETTE ? 255U :
|
||||
unsigned int lim = (color_type == PNG_COLOR_TYPE_PALETTE ? 255U :
|
||||
(1U<<bit_depth)-1);
|
||||
unsigned int i;
|
||||
|
||||
|
@ -1446,7 +1446,7 @@ test_one_file(struct display *dp, const char *filename)
|
||||
* unsigned, because some transforms are negative on a 16-bit system.
|
||||
*/
|
||||
unsigned int active = dp->active_transforms;
|
||||
const int exhaustive = (dp->options & EXHAUSTIVE) != 0;
|
||||
int exhaustive = (dp->options & EXHAUSTIVE) != 0;
|
||||
unsigned int current = first_transform(active);
|
||||
unsigned int bad_transforms = 0;
|
||||
unsigned int bad_combo = ~0U; /* bitwise AND of failing transforms */
|
||||
@ -1572,7 +1572,7 @@ do_test(struct display *dp, const char *file)
|
||||
}
|
||||
|
||||
int
|
||||
main(const int argc, const char * const * const argv)
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
/* For each file on the command line test it with a range of transforms */
|
||||
int option_end, ilog = 0;
|
||||
@ -1674,7 +1674,7 @@ main(const int argc, const char * const * const argv)
|
||||
/* Here on any return, including failures, except user/internal issues
|
||||
*/
|
||||
{
|
||||
const int pass = (d.options & STRICT) ?
|
||||
int pass = (d.options & STRICT) ?
|
||||
RESULT_STRICT(d.results) : RESULT_RELAXED(d.results);
|
||||
|
||||
if (!pass)
|
||||
|
@ -2346,8 +2346,8 @@ static int
|
||||
logpixel(const Transform *transform, png_uint_32 x, png_uint_32 y,
|
||||
const Pixel *in, const Pixel *calc, const Pixel *out, const char *reason)
|
||||
{
|
||||
const png_uint_32 in_format = transform->in_image->image.format;
|
||||
const png_uint_32 out_format = transform->out_image->image.format;
|
||||
png_uint_32 in_format = transform->in_image->image.format;
|
||||
png_uint_32 out_format = transform->out_image->image.format;
|
||||
|
||||
png_uint_32 back_format = out_format & ~PNG_FORMAT_FLAG_ALPHA;
|
||||
const char *via_linear = "";
|
||||
@ -2602,12 +2602,12 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
||||
ptrdiff_t strideb = b->stride;
|
||||
png_const_bytep rowa = a->buffer+16;
|
||||
png_const_bytep rowb = b->buffer+16;
|
||||
const png_uint_32 width = a->image.width;
|
||||
const png_uint_32 height = a->image.height;
|
||||
const png_uint_32 formata = a->image.format;
|
||||
const png_uint_32 formatb = b->image.format;
|
||||
const unsigned int a_sample = PNG_IMAGE_SAMPLE_SIZE(formata);
|
||||
const unsigned int b_sample = PNG_IMAGE_SAMPLE_SIZE(formatb);
|
||||
png_uint_32 width = a->image.width;
|
||||
png_uint_32 height = a->image.height;
|
||||
png_uint_32 formata = a->image.format;
|
||||
png_uint_32 formatb = b->image.format;
|
||||
unsigned int a_sample = PNG_IMAGE_SAMPLE_SIZE(formata);
|
||||
unsigned int b_sample = PNG_IMAGE_SAMPLE_SIZE(formatb);
|
||||
int alpha_added, alpha_removed;
|
||||
int bchannels;
|
||||
png_uint_32 y;
|
||||
@ -2790,8 +2790,7 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
||||
(formata & (formatb ^ PNG_FORMAT_FLAG_COLOR) & PNG_FORMAT_FLAG_COLOR)))
|
||||
{
|
||||
/* Was an alpha channel changed? */
|
||||
const png_uint_32 alpha_changed = (formata ^ formatb) &
|
||||
PNG_FORMAT_FLAG_ALPHA;
|
||||
png_uint_32 alpha_changed = (formata ^ formatb) & PNG_FORMAT_FLAG_ALPHA;
|
||||
|
||||
/* Was an alpha channel removed? (The third test.) If so the direct
|
||||
* comparison is only possible if the input alpha is opaque.
|
||||
@ -3627,7 +3626,7 @@ main(int argc, char **argv)
|
||||
|
||||
if (arg[0] == '-')
|
||||
{
|
||||
const int term = (arg[1] == '0' ? 0 : '\n');
|
||||
int term = (arg[1] == '0' ? 0 : '\n');
|
||||
unsigned int ich = 0;
|
||||
|
||||
/* Loop reading files, use a static buffer to simplify this and just
|
||||
|
@ -2590,7 +2590,7 @@ static double digitize(double value, int depth, int do_round)
|
||||
* rounding and 'do_round' should be 1, if it is 0 the digitized value will
|
||||
* be truncated.
|
||||
*/
|
||||
const unsigned int digitization_factor = (1U << depth) -1;
|
||||
unsigned int digitization_factor = (1U << depth) - 1;
|
||||
|
||||
/* Limiting the range is done as a convenience to the caller - it's easier to
|
||||
* do it once here than every time at the call site.
|
||||
@ -3688,8 +3688,8 @@ init_standard_palette(png_store *ps, png_structp pp, png_infop pi, int npalette,
|
||||
|
||||
#ifdef PNG_WRITE_tRNS_SUPPORTED
|
||||
static void
|
||||
set_random_tRNS(png_structp pp, png_infop pi, const png_byte colour_type,
|
||||
const int bit_depth)
|
||||
set_random_tRNS(png_structp pp, png_infop pi, png_byte colour_type,
|
||||
int bit_depth)
|
||||
{
|
||||
/* To make this useful the tRNS color needs to match at least one pixel.
|
||||
* Random values are fine for gray, including the 16-bit case where we know
|
||||
@ -3697,7 +3697,7 @@ set_random_tRNS(png_structp pp, png_infop pi, const png_byte colour_type,
|
||||
* method as only 65536 different RGB values are generated.
|
||||
*/
|
||||
png_color_16 tRNS;
|
||||
const png_uint_16 mask = (png_uint_16)((1U << bit_depth)-1);
|
||||
png_uint_16 mask = (png_uint_16)((1U << bit_depth)-1);
|
||||
|
||||
R8(tRNS); /* makes unset fields random */
|
||||
|
||||
@ -4338,7 +4338,7 @@ make_size_image(png_store* const ps, png_byte const colour_type,
|
||||
|
||||
/* Make a name and get an appropriate id for the store: */
|
||||
char name[FILE_NAME_SIZE];
|
||||
const png_uint_32 id = FILEID(colour_type, bit_depth, 0/*palette*/,
|
||||
png_uint_32 id = FILEID(colour_type, bit_depth, 0/*palette*/,
|
||||
interlace_type, w, h, do_interlace);
|
||||
|
||||
standard_name_from_id(name, sizeof name, 0, id);
|
||||
@ -4414,7 +4414,7 @@ make_size_image(png_store* const ps, png_byte const colour_type,
|
||||
for (pass=0; pass<npasses; ++pass)
|
||||
{
|
||||
/* The following two are for checking the macros: */
|
||||
const png_uint_32 wPass = PNG_PASS_COLS(w, pass);
|
||||
png_uint_32 wPass = PNG_PASS_COLS(w, pass);
|
||||
|
||||
/* If do_interlace is set we don't call png_write_row for every
|
||||
* row because some of them are empty. In fact, for a 1x1 image,
|
||||
@ -4646,7 +4646,7 @@ make_error(png_store* const ps, png_byte const colour_type,
|
||||
Try
|
||||
{
|
||||
png_infop pi;
|
||||
const png_structp pp = set_store_for_write(ps, &pi, name);
|
||||
png_structp pp = set_store_for_write(ps, &pi, name);
|
||||
png_uint_32 w, h;
|
||||
gnu_volatile(pp)
|
||||
|
||||
@ -5469,14 +5469,14 @@ progressive_row(png_structp ppIn, png_bytep new_row, png_uint_32 y, int pass)
|
||||
|
||||
static void
|
||||
sequential_row(standard_display *dp, png_structp pp, png_infop pi,
|
||||
const int iImage, const int iDisplay)
|
||||
int iImage, int iDisplay)
|
||||
{
|
||||
const int npasses = dp->npasses;
|
||||
const int do_interlace = dp->do_interlace &&
|
||||
int npasses = dp->npasses;
|
||||
int do_interlace = dp->do_interlace &&
|
||||
dp->interlace_type == PNG_INTERLACE_ADAM7;
|
||||
const png_uint_32 height = standard_height(pp, dp->id);
|
||||
const png_uint_32 width = standard_width(pp, dp->id);
|
||||
const png_store* ps = dp->ps;
|
||||
png_uint_32 height = standard_height(pp, dp->id);
|
||||
png_uint_32 width = standard_width(pp, dp->id);
|
||||
const png_store* ps = dp->ps;
|
||||
int pass;
|
||||
|
||||
for (pass=0; pass<npasses; ++pass)
|
||||
@ -5870,7 +5870,7 @@ test_size(png_modifier* const pm, png_byte const colour_type,
|
||||
*/
|
||||
static const png_byte hinc[] = {1, 3, 11, 1, 5};
|
||||
static const png_byte winc[] = {1, 9, 5, 7, 1};
|
||||
const int save_bdlo = bdlo;
|
||||
int save_bdlo = bdlo;
|
||||
|
||||
for (; bdlo <= bdhi; ++bdlo)
|
||||
{
|
||||
@ -6078,12 +6078,12 @@ image_pixel_init(image_pixel *this, png_const_bytep row, png_byte colour_type,
|
||||
png_byte bit_depth, png_uint_32 x, store_palette palette,
|
||||
const image_pixel *format /*from pngvalid transform of input*/)
|
||||
{
|
||||
const png_byte sample_depth = (png_byte)(colour_type ==
|
||||
PNG_COLOR_TYPE_PALETTE ? 8 : bit_depth);
|
||||
const unsigned int max = (1U<<sample_depth)-1;
|
||||
const int swap16 = (format != 0 && format->swap16);
|
||||
const int littleendian = (format != 0 && format->littleendian);
|
||||
const int sig_bits = (format != 0 && format->sig_bits);
|
||||
png_byte sample_depth =
|
||||
(png_byte)(colour_type == PNG_COLOR_TYPE_PALETTE ? 8 : bit_depth);
|
||||
unsigned int max = (1U<<sample_depth)-1;
|
||||
int swap16 = (format != 0 && format->swap16);
|
||||
int littleendian = (format != 0 && format->littleendian);
|
||||
int sig_bits = (format != 0 && format->sig_bits);
|
||||
|
||||
/* Initially just set everything to the same number and the alpha to opaque.
|
||||
* Note that this currently assumes a simple palette where entry x has colour
|
||||
@ -6101,7 +6101,7 @@ image_pixel_init(image_pixel *this, png_const_bytep row, png_byte colour_type,
|
||||
/* This permits the caller to default to the sample value. */
|
||||
if (palette != 0)
|
||||
{
|
||||
const unsigned int i = this->palette_index;
|
||||
unsigned int i = this->palette_index;
|
||||
|
||||
this->red = palette[i].red;
|
||||
this->green = palette[i].green;
|
||||
@ -6432,8 +6432,8 @@ static void
|
||||
image_transform_mod_end(const image_transform *this, image_pixel *that,
|
||||
png_const_structp pp, const transform_display *display)
|
||||
{
|
||||
const unsigned int scale = (1U<<that->sample_depth)-1;
|
||||
const int sig_bits = that->sig_bits;
|
||||
unsigned int scale = (1U<<that->sample_depth)-1;
|
||||
int sig_bits = that->sig_bits;
|
||||
|
||||
UNUSED(this)
|
||||
UNUSED(pp)
|
||||
@ -6756,19 +6756,19 @@ transform_image_validate(transform_display *dp, png_const_structp pp,
|
||||
{
|
||||
/* Constants for the loop below: */
|
||||
const png_store* const ps = dp->this.ps;
|
||||
const png_byte in_ct = dp->this.colour_type;
|
||||
const png_byte in_bd = dp->this.bit_depth;
|
||||
const png_uint_32 w = dp->this.w;
|
||||
const png_uint_32 h = dp->this.h;
|
||||
const png_byte out_ct = dp->output_colour_type;
|
||||
const png_byte out_bd = dp->output_bit_depth;
|
||||
const png_byte sample_depth = (png_byte)(out_ct ==
|
||||
PNG_COLOR_TYPE_PALETTE ? 8 : out_bd);
|
||||
const png_byte red_sBIT = dp->this.red_sBIT;
|
||||
const png_byte green_sBIT = dp->this.green_sBIT;
|
||||
const png_byte blue_sBIT = dp->this.blue_sBIT;
|
||||
const png_byte alpha_sBIT = dp->this.alpha_sBIT;
|
||||
const int have_tRNS = dp->this.is_transparent;
|
||||
png_byte in_ct = dp->this.colour_type;
|
||||
png_byte in_bd = dp->this.bit_depth;
|
||||
png_uint_32 w = dp->this.w;
|
||||
png_uint_32 h = dp->this.h;
|
||||
png_byte out_ct = dp->output_colour_type;
|
||||
png_byte out_bd = dp->output_bit_depth;
|
||||
png_byte sample_depth =
|
||||
(png_byte)(out_ct == PNG_COLOR_TYPE_PALETTE ? 8 : out_bd);
|
||||
png_byte red_sBIT = dp->this.red_sBIT;
|
||||
png_byte green_sBIT = dp->this.green_sBIT;
|
||||
png_byte blue_sBIT = dp->this.blue_sBIT;
|
||||
png_byte alpha_sBIT = dp->this.alpha_sBIT;
|
||||
int have_tRNS = dp->this.is_transparent;
|
||||
double digitization_error;
|
||||
|
||||
store_palette out_palette;
|
||||
@ -6929,7 +6929,7 @@ transform_end(png_structp ppIn, png_infop pi)
|
||||
|
||||
/* A single test run. */
|
||||
static void
|
||||
transform_test(png_modifier *pmIn, const png_uint_32 idIn,
|
||||
transform_test(png_modifier *pmIn, png_uint_32 idIn,
|
||||
const image_transform* transform_listIn, const char * const name)
|
||||
{
|
||||
transform_display d;
|
||||
@ -7764,7 +7764,7 @@ static void
|
||||
image_transform_png_set_rgb_to_gray_set(const image_transform *this,
|
||||
transform_display *that, png_structp pp, png_infop pi)
|
||||
{
|
||||
const int error_action = 1; /* no error, no defines in png.h */
|
||||
int error_action = 1; /* no error, no defines in png.h */
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_set_rgb_to_gray(pp, error_action, data.red_to_set, data.green_to_set);
|
||||
@ -7905,10 +7905,10 @@ image_transform_png_set_rgb_to_gray_mod(const image_transform *this,
|
||||
# if DIGITIZE
|
||||
{
|
||||
png_modifier *pm = display->pm;
|
||||
const unsigned int sample_depth = that->sample_depth;
|
||||
const unsigned int calc_depth = (pm->assume_16_bit_calculations ? 16 :
|
||||
unsigned int sample_depth = that->sample_depth;
|
||||
unsigned int calc_depth = (pm->assume_16_bit_calculations ? 16 :
|
||||
sample_depth);
|
||||
const unsigned int gamma_depth =
|
||||
unsigned int gamma_depth =
|
||||
(sample_depth == 16 ?
|
||||
display->max_gamma_8 :
|
||||
(pm->assume_16_bit_calculations ?
|
||||
@ -8002,7 +8002,7 @@ image_transform_png_set_rgb_to_gray_mod(const image_transform *this,
|
||||
b * data.blue_coefficient;
|
||||
|
||||
{
|
||||
const int do_round = data.gamma != 1 || calc_depth == 16;
|
||||
int do_round = data.gamma != 1 || calc_depth == 16;
|
||||
const double ce = 2. / 32768;
|
||||
|
||||
graylo = DD(rlo * (data.red_coefficient-ce) +
|
||||
@ -8626,7 +8626,7 @@ image_transform_png_set_filler_mod(const image_transform *this,
|
||||
(that->colour_type == PNG_COLOR_TYPE_RGB ||
|
||||
that->colour_type == PNG_COLOR_TYPE_GRAY))
|
||||
{
|
||||
const unsigned int max = (1U << that->bit_depth)-1;
|
||||
unsigned int max = (1U << that->bit_depth)-1;
|
||||
that->alpha = data.filler & max;
|
||||
that->alphaf = ((double)that->alpha) / max;
|
||||
that->alphae = 0;
|
||||
@ -8693,7 +8693,7 @@ image_transform_png_set_add_alpha_mod(const image_transform *this,
|
||||
(that->colour_type == PNG_COLOR_TYPE_RGB ||
|
||||
that->colour_type == PNG_COLOR_TYPE_GRAY))
|
||||
{
|
||||
const unsigned int max = (1U << that->bit_depth)-1;
|
||||
unsigned int max = (1U << that->bit_depth)-1;
|
||||
that->alpha = data.filler & max;
|
||||
that->alphaf = ((double)that->alpha) / max;
|
||||
that->alphae = 0;
|
||||
@ -8884,7 +8884,7 @@ image_transform_png_set_shift_set(const image_transform *this,
|
||||
* field is randomized independently. This acts as a check that
|
||||
* libpng does use the correct field.
|
||||
*/
|
||||
const unsigned int depth = that->this.bit_depth;
|
||||
unsigned int depth = that->this.bit_depth;
|
||||
|
||||
data.red = (png_byte)/*SAFE*/(random_mod(depth)+1);
|
||||
data.green = (png_byte)/*SAFE*/(random_mod(depth)+1);
|
||||
@ -9304,7 +9304,7 @@ gamma_info_imp(gamma_display *dp, png_structp pp, png_infop pi)
|
||||
*/
|
||||
const double sg = dp->screen_gamma;
|
||||
# ifndef PNG_FLOATING_POINT_SUPPORTED
|
||||
const png_fixed_point g = fix(sg);
|
||||
png_fixed_point g = fix(sg);
|
||||
# endif
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
@ -9352,7 +9352,7 @@ gamma_info_imp(gamma_display *dp, png_structp pp, png_infop pi)
|
||||
*/
|
||||
const double bg = dp->background_gamma;
|
||||
# ifndef PNG_FLOATING_POINT_SUPPORTED
|
||||
const png_fixed_point g = fix(bg);
|
||||
png_fixed_point g = fix(bg);
|
||||
# endif
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
@ -9426,7 +9426,7 @@ static void
|
||||
init_validate_info(validate_info *vi, gamma_display *dp, png_const_structp pp,
|
||||
int in_depth, int out_depth)
|
||||
{
|
||||
const unsigned int outmax = (1U<<out_depth)-1;
|
||||
unsigned int outmax = (1U<<out_depth)-1;
|
||||
|
||||
vi->pp = pp;
|
||||
vi->dp = dp;
|
||||
@ -9588,14 +9588,14 @@ gamma_component_compose(int do_background, double input_sample, double alpha,
|
||||
/* This API returns the encoded *input* component, in the range 0..1 */
|
||||
static double
|
||||
gamma_component_validate(const char *name, const validate_info *vi,
|
||||
const unsigned int id, const unsigned int od,
|
||||
unsigned int id, unsigned int od,
|
||||
const double alpha /* <0 for the alpha channel itself */,
|
||||
const double background /* component background value */)
|
||||
{
|
||||
const unsigned int isbit = id >> vi->isbit_shift;
|
||||
const unsigned int sbit_max = vi->sbit_max;
|
||||
const unsigned int outmax = vi->outmax;
|
||||
const int do_background = vi->do_background;
|
||||
unsigned int isbit = id >> vi->isbit_shift;
|
||||
unsigned int sbit_max = vi->sbit_max;
|
||||
unsigned int outmax = vi->outmax;
|
||||
int do_background = vi->do_background;
|
||||
|
||||
double i;
|
||||
|
||||
@ -10161,13 +10161,13 @@ gamma_image_validate(gamma_display *dp, png_const_structp pp,
|
||||
{
|
||||
/* Get some constants derived from the input and output file formats: */
|
||||
const png_store* const ps = dp->this.ps;
|
||||
const png_byte in_ct = dp->this.colour_type;
|
||||
const png_byte in_bd = dp->this.bit_depth;
|
||||
const png_uint_32 w = dp->this.w;
|
||||
const png_uint_32 h = dp->this.h;
|
||||
png_byte in_ct = dp->this.colour_type;
|
||||
png_byte in_bd = dp->this.bit_depth;
|
||||
png_uint_32 w = dp->this.w;
|
||||
png_uint_32 h = dp->this.h;
|
||||
const size_t cbRow = dp->this.cbRow;
|
||||
const png_byte out_ct = png_get_color_type(pp, pi);
|
||||
const png_byte out_bd = png_get_bit_depth(pp, pi);
|
||||
png_byte out_ct = png_get_color_type(pp, pi);
|
||||
png_byte out_bd = png_get_bit_depth(pp, pi);
|
||||
|
||||
/* There are three sources of error, firstly the quantization in the
|
||||
* file encoding, determined by sbit and/or the file depth, secondly
|
||||
@ -10208,11 +10208,11 @@ gamma_image_validate(gamma_display *dp, png_const_structp pp,
|
||||
* The basic tests below do not do this, however if 'use_input_precision'
|
||||
* is set a subsequent test is performed above.
|
||||
*/
|
||||
const unsigned int samples_per_pixel = (out_ct & 2U) ? 3U : 1U;
|
||||
unsigned int samples_per_pixel = (out_ct & 2U) ? 3U : 1U;
|
||||
int processing;
|
||||
png_uint_32 y;
|
||||
const store_palette_entry *in_palette = dp->this.palette;
|
||||
const int in_is_transparent = dp->this.is_transparent;
|
||||
int in_is_transparent = dp->this.is_transparent;
|
||||
int process_tRNS;
|
||||
int out_npalette = -1;
|
||||
int out_is_transparent = 0; /* Just refers to the palette case */
|
||||
@ -10260,9 +10260,9 @@ gamma_image_validate(gamma_display *dp, png_const_structp pp,
|
||||
double alpha = 1; /* serves as a flag value */
|
||||
|
||||
/* Record the palette index for index images. */
|
||||
const unsigned int in_index =
|
||||
unsigned int in_index =
|
||||
in_ct == 3 ? sample(std, 3, in_bd, x, 0, 0, 0) : 256;
|
||||
const unsigned int out_index =
|
||||
unsigned int out_index =
|
||||
out_ct == 3 ? sample(std, 3, out_bd, x, 0, 0, 0) : 256;
|
||||
|
||||
/* Handle input alpha - png_set_background will cause the output
|
||||
@ -10271,7 +10271,7 @@ gamma_image_validate(gamma_display *dp, png_const_structp pp,
|
||||
if ((in_ct & PNG_COLOR_MASK_ALPHA) != 0 ||
|
||||
(in_ct == 3 && in_is_transparent))
|
||||
{
|
||||
const unsigned int input_alpha = in_ct == 3 ?
|
||||
unsigned int input_alpha = in_ct == 3 ?
|
||||
dp->this.palette[in_index].alpha :
|
||||
sample(std, in_ct, in_bd, x, samples_per_pixel, 0, 0);
|
||||
|
||||
@ -10396,14 +10396,14 @@ gamma_end(png_structp ppIn, png_infop pi)
|
||||
* maxpc: maximum percentage error (as a percentage)
|
||||
*/
|
||||
static void
|
||||
gamma_test(png_modifier *pmIn, const png_byte colour_typeIn,
|
||||
const png_byte bit_depthIn, const int palette_numberIn,
|
||||
const int interlace_typeIn,
|
||||
gamma_test(png_modifier *pmIn, png_byte colour_typeIn,
|
||||
png_byte bit_depthIn, int palette_numberIn,
|
||||
int interlace_typeIn,
|
||||
const double file_gammaIn, const double screen_gammaIn,
|
||||
const png_byte sbitIn, const int threshold_testIn,
|
||||
png_byte sbitIn, int threshold_testIn,
|
||||
const char *name,
|
||||
const int use_input_precisionIn, const int scale16In,
|
||||
const int expand16In, const int do_backgroundIn,
|
||||
int use_input_precisionIn, int scale16In,
|
||||
int expand16In, int do_backgroundIn,
|
||||
const png_color_16 *bkgd_colorIn, double bkgd_gammaIn)
|
||||
{
|
||||
gamma_display d;
|
||||
@ -10607,11 +10607,11 @@ perform_gamma_threshold_tests(png_modifier *pm)
|
||||
}
|
||||
|
||||
static void gamma_transform_test(png_modifier *pm,
|
||||
const png_byte colour_type, const png_byte bit_depth,
|
||||
const int palette_number,
|
||||
const int interlace_type, const double file_gamma,
|
||||
const double screen_gamma, const png_byte sbit,
|
||||
const int use_input_precision, const int scale16)
|
||||
png_byte colour_type, png_byte bit_depth,
|
||||
int palette_number,
|
||||
int interlace_type, const double file_gamma,
|
||||
const double screen_gamma, png_byte sbit,
|
||||
int use_input_precision, int scale16)
|
||||
{
|
||||
size_t pos = 0;
|
||||
char name[64];
|
||||
@ -10768,12 +10768,12 @@ static void perform_gamma_scale16_tests(png_modifier *pm)
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
static void gamma_composition_test(png_modifier *pm,
|
||||
const png_byte colour_type, const png_byte bit_depth,
|
||||
const int palette_number,
|
||||
const int interlace_type, const double file_gamma,
|
||||
png_byte colour_type, png_byte bit_depth,
|
||||
int palette_number,
|
||||
int interlace_type, const double file_gamma,
|
||||
const double screen_gamma,
|
||||
const int use_input_precision, const int do_background,
|
||||
const int expand_16)
|
||||
int use_input_precision, int do_background,
|
||||
int expand_16)
|
||||
{
|
||||
size_t pos = 0;
|
||||
png_const_charp base;
|
||||
|
@ -331,8 +331,8 @@ static int check_one_character(checkfp_command *co, checkfp_control c, int ch)
|
||||
*/
|
||||
size_t index = 0;
|
||||
const char test = (char)ch;
|
||||
const int number_is_valid = png_check_fp_number(&test, 1, &c.state, &index);
|
||||
const int character_accepted = (index == 1);
|
||||
int number_is_valid = png_check_fp_number(&test, 1, &c.state, &index);
|
||||
int character_accepted = (index == 1);
|
||||
|
||||
if (c.check_state != exponent && isdigit(ch) && ch != '0')
|
||||
c.is_zero = 0;
|
||||
|
@ -23,14 +23,12 @@
|
||||
static int
|
||||
png_have_vsx(png_structp png_ptr)
|
||||
{
|
||||
|
||||
const unsigned long auxv = getauxval( AT_HWCAP );
|
||||
unsigned long auxv = getauxval(AT_HWCAP);
|
||||
|
||||
PNG_UNUSED(png_ptr)
|
||||
|
||||
if(auxv & (PPC_FEATURE_HAS_ALTIVEC|PPC_FEATURE_HAS_VSX ))
|
||||
if(auxv & (PPC_FEATURE_HAS_ALTIVEC|PPC_FEATURE_HAS_VSX))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -735,7 +735,7 @@ option_index(struct display *dp, const char *opt, size_t len)
|
||||
static int
|
||||
get_option(struct display *dp, const char *opt, int *value)
|
||||
{
|
||||
const png_byte i = option_index(dp, opt, strlen(opt));
|
||||
png_byte i = option_index(dp, opt, strlen(opt));
|
||||
|
||||
if (dp->entry[i]) /* option was set on command line */
|
||||
{
|
||||
@ -789,7 +789,7 @@ record_opt(struct display *dp, png_byte opt, const char *entry_name)
|
||||
* numerical value.
|
||||
*/
|
||||
{
|
||||
const unsigned int sp = dp->csp; /* stack entry of next searched option */
|
||||
unsigned int sp = dp->csp; /* stack entry of next searched option */
|
||||
|
||||
if (sp >= dp->tsp)
|
||||
{
|
||||
@ -797,7 +797,7 @@ record_opt(struct display *dp, png_byte opt, const char *entry_name)
|
||||
* searched entry or the start of the dp->curr buffer if there is nothing
|
||||
* on the stack yet (sp == 0).
|
||||
*/
|
||||
const int offset = set_opt_string_(dp, sp, opt, entry_name);
|
||||
int offset = set_opt_string_(dp, sp, opt, entry_name);
|
||||
|
||||
if (sp > 0)
|
||||
dp->stack[sp-1].opt_string_end = offset;
|
||||
@ -1222,7 +1222,7 @@ advance_opt(struct display *dp, png_byte opt, int search)
|
||||
}
|
||||
|
||||
static int
|
||||
getallopts_(struct display *dp, const png_byte opt, int *value, int record)
|
||||
getallopts_(struct display *dp, png_byte opt, int *value, int record)
|
||||
/* Like getop but iterate over all the values if the option was set to "all".
|
||||
*/
|
||||
{
|
||||
@ -1259,7 +1259,7 @@ getsearchopts(struct display *dp, const char *opt_str, int *value)
|
||||
/* As above except that if the option was not set try a search */
|
||||
{
|
||||
png_byte istrat;
|
||||
const png_byte opt = option_index(dp, opt_str, strlen(opt_str));
|
||||
png_byte opt = option_index(dp, opt_str, strlen(opt_str));
|
||||
int record = options[opt].search;
|
||||
const char *entry_name;
|
||||
|
||||
@ -2302,7 +2302,7 @@ cppng(struct display *dp, const char *file, const char *gv dest)
|
||||
}
|
||||
|
||||
int
|
||||
main(const int argc, const char * const * const argv)
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
/* For each file on the command line test it with a range of transforms */
|
||||
int option_end;
|
||||
@ -2379,7 +2379,7 @@ main(const int argc, const char * const * const argv)
|
||||
/* Here on any return, including failures, except user/internal issues
|
||||
*/
|
||||
{
|
||||
const int pass = (d.options & STRICT) ?
|
||||
int pass = (d.options & STRICT) ?
|
||||
RESULT_STRICT(d.results) : RESULT_RELAXED(d.results);
|
||||
|
||||
if (!pass)
|
||||
|
@ -2514,7 +2514,7 @@ zlib_run(struct zlib *zlib)
|
||||
*/
|
||||
for (;;)
|
||||
{
|
||||
const unsigned int count = list->count;
|
||||
unsigned int count = list->count;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i<count; ++i)
|
||||
@ -2791,7 +2791,7 @@ process_chunk(struct file *file, png_uint_32 file_crc, png_uint_32 next_length,
|
||||
* to read_chunk.
|
||||
*/
|
||||
{
|
||||
const png_uint_32 type = file->type;
|
||||
png_uint_32 type = file->type;
|
||||
|
||||
if (file->global->verbose > 1)
|
||||
{
|
||||
|
2
libpng.3
2
libpng.3
@ -353,7 +353,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.6.36.git
|
||||
|
||||
\fBvoid png_set_eXIf (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fIexif\fP\fB);\fP
|
||||
|
||||
\fBvoid png_set_eXIf_1 (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, const png_uint_32 \fP\fInum_exif\fP\fB, png_bytep \fIexif\fP\fB);\fP
|
||||
\fBvoid png_set_eXIf_1 (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fInum_exif\fP\fB, png_bytep \fIexif\fP\fB);\fP
|
||||
|
||||
\fBvoid png_set_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fIhist\fP\fB);\fP
|
||||
|
||||
|
16
png.c
16
png.c
@ -3970,18 +3970,18 @@ png_gamma_correct(png_structrp png_ptr, unsigned int value,
|
||||
*/
|
||||
static void
|
||||
png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable,
|
||||
const unsigned int shift, const png_fixed_point gamma_val)
|
||||
unsigned int shift, png_fixed_point gamma_val)
|
||||
{
|
||||
/* Various values derived from 'shift': */
|
||||
const unsigned int num = 1U << (8U - shift);
|
||||
unsigned int num = 1U << (8U - shift);
|
||||
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
/* CSE the division and work round wacky GCC warnings (see the comments
|
||||
* in png_gamma_8bit_correct for where these come from.)
|
||||
*/
|
||||
const double fmax = 1./(((png_int_32)1 << (16U - shift))-1);
|
||||
#endif
|
||||
const unsigned int max = (1U << (16U - shift))-1U;
|
||||
const unsigned int max_by_2 = 1U << (15U-shift);
|
||||
unsigned int max = (1U << (16U - shift))-1U;
|
||||
unsigned int max_by_2 = 1U << (15U-shift);
|
||||
unsigned int i;
|
||||
|
||||
png_uint_16pp table = *ptable =
|
||||
@ -4047,10 +4047,10 @@ png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable,
|
||||
*/
|
||||
static void
|
||||
png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable,
|
||||
const unsigned int shift, const png_fixed_point gamma_val)
|
||||
unsigned int shift, png_fixed_point gamma_val)
|
||||
{
|
||||
const unsigned int num = 1U << (8U - shift);
|
||||
const unsigned int max = (1U << (16U - shift))-1U;
|
||||
unsigned int num = 1U << (8U - shift);
|
||||
unsigned int max = (1U << (16U - shift))-1U;
|
||||
unsigned int i;
|
||||
png_uint_32 last;
|
||||
|
||||
@ -4115,7 +4115,7 @@ png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable,
|
||||
*/
|
||||
static void
|
||||
png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable,
|
||||
const png_fixed_point gamma_val)
|
||||
png_fixed_point gamma_val)
|
||||
{
|
||||
unsigned int i;
|
||||
png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256);
|
||||
|
4
png.h
4
png.h
@ -1963,12 +1963,12 @@ PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr,
|
||||
PNG_EXPORT(246, png_uint_32, png_get_eXIf, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, png_bytep *exif));
|
||||
PNG_EXPORT(247, void, png_set_eXIf, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, const png_bytep exif));
|
||||
png_inforp info_ptr, png_bytep exif));
|
||||
|
||||
PNG_EXPORT(248, png_uint_32, png_get_eXIf_1, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_uint_32 *num_exif, png_bytep *exif));
|
||||
PNG_EXPORT(249, void, png_set_eXIf_1, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, const png_uint_32 num_exif, const png_bytep exif));
|
||||
png_inforp info_ptr, png_uint_32 num_exif, png_bytep exif));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
|
@ -885,7 +885,7 @@ PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI
|
||||
png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||
PNG_NORETURN)
|
||||
{
|
||||
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||
png_const_structrp png_ptr = png_nonconst_ptr;
|
||||
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
|
||||
|
||||
/* An error is always logged here, overwriting anything (typically a warning)
|
||||
@ -920,7 +920,7 @@ png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
|
||||
void /* PRIVATE */ PNGCBAPI
|
||||
png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
|
||||
{
|
||||
const png_const_structrp png_ptr = png_nonconst_ptr;
|
||||
png_const_structrp png_ptr = png_nonconst_ptr;
|
||||
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
|
||||
|
||||
/* A warning is only logged if there is no prior warning or error. */
|
||||
|
@ -1537,10 +1537,10 @@ PNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr,
|
||||
#endif
|
||||
|
||||
PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_const_structrp png_ptr,
|
||||
const png_uint_32 chunk_name),PNG_EMPTY);
|
||||
png_uint_32 chunk_name),PNG_EMPTY);
|
||||
|
||||
PNG_INTERNAL_FUNCTION(void,png_check_chunk_length,(png_const_structrp png_ptr,
|
||||
const png_uint_32 chunk_length),PNG_EMPTY);
|
||||
png_uint_32 chunk_length),PNG_EMPTY);
|
||||
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY);
|
||||
|
24
pngread.c
24
pngread.c
@ -1758,9 +1758,9 @@ png_create_colormap_entry(png_image_read_control *display,
|
||||
png_uint_32 alpha, int encoding)
|
||||
{
|
||||
png_imagep image = display->image;
|
||||
const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
|
||||
int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
|
||||
P_LINEAR : P_sRGB;
|
||||
const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
|
||||
int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
|
||||
(red != green || green != blue);
|
||||
|
||||
if (ip > 255)
|
||||
@ -1869,13 +1869,13 @@ png_create_colormap_entry(png_image_read_control *display,
|
||||
/* Store the value. */
|
||||
{
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
const int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
|
||||
int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
|
||||
(image->format & PNG_FORMAT_FLAG_ALPHA) != 0;
|
||||
# else
|
||||
# define afirst 0
|
||||
# endif
|
||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
|
||||
int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
|
||||
# else
|
||||
# define bgr 0
|
||||
# endif
|
||||
@ -2085,11 +2085,11 @@ png_image_read_colormap(png_voidp argument)
|
||||
{
|
||||
png_image_read_control *display =
|
||||
png_voidcast(png_image_read_control*, argument);
|
||||
const png_imagep image = display->image;
|
||||
png_imagep image = display->image;
|
||||
|
||||
const png_structrp png_ptr = image->opaque->png_ptr;
|
||||
const png_uint_32 output_format = image->format;
|
||||
const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
|
||||
png_structrp png_ptr = image->opaque->png_ptr;
|
||||
png_uint_32 output_format = image->format;
|
||||
int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
|
||||
P_LINEAR : P_sRGB;
|
||||
|
||||
unsigned int cmap_entries;
|
||||
@ -2802,7 +2802,7 @@ png_image_read_colormap(png_voidp argument)
|
||||
unsigned int num_trans = png_ptr->num_trans;
|
||||
png_const_bytep trans = num_trans > 0 ? png_ptr->trans_alpha : NULL;
|
||||
png_const_colorp colormap = png_ptr->palette;
|
||||
const int do_background = trans != NULL &&
|
||||
int do_background = trans != NULL &&
|
||||
(output_format & PNG_FORMAT_FLAG_ALPHA) == 0;
|
||||
unsigned int i;
|
||||
|
||||
@ -3946,7 +3946,7 @@ png_image_read_direct(png_voidp argument)
|
||||
*/
|
||||
if (linear != 0)
|
||||
{
|
||||
const png_uint_16 le = 0x0001;
|
||||
png_uint_16 le = 0x0001;
|
||||
|
||||
if ((*(png_const_bytep) & le) != 0)
|
||||
png_set_swap(png_ptr);
|
||||
@ -4108,7 +4108,7 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
||||
* original PNG format because it may not occur in the output PNG format
|
||||
* and libpng deals with the issues of reading the original.
|
||||
*/
|
||||
const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
|
||||
unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
|
||||
|
||||
/* The following checks just the 'row_stride' calculation to ensure it
|
||||
* fits in a signed 32-bit value. Because channels/components can be
|
||||
@ -4119,7 +4119,7 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
||||
if (image->width <= 0x7fffffffU/channels) /* no overflow */
|
||||
{
|
||||
png_uint_32 check;
|
||||
const png_uint_32 png_row_stride = image->width * channels;
|
||||
png_uint_32 png_row_stride = image->width * channels;
|
||||
|
||||
if (row_stride == 0)
|
||||
row_stride = (png_int_32)/*SAFE*/png_row_stride;
|
||||
|
24
pngrtran.c
24
pngrtran.c
@ -2986,7 +2986,6 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
||||
*/
|
||||
static int
|
||||
png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
|
||||
{
|
||||
int rgb_error = 0;
|
||||
|
||||
@ -2995,12 +2994,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_PALETTE) == 0 &&
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
{
|
||||
const png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
|
||||
const png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
|
||||
const png_uint_32 bc = 32768 - rc - gc;
|
||||
const png_uint_32 row_width = row_info->width;
|
||||
const int have_alpha =
|
||||
(row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0;
|
||||
png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
|
||||
png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
|
||||
png_uint_32 bc = 32768 - rc - gc;
|
||||
png_uint_32 row_width = row_info->width;
|
||||
int have_alpha = (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0;
|
||||
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
@ -4143,12 +4141,11 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
{
|
||||
if (row_info->bit_depth == 8)
|
||||
{
|
||||
const png_bytep table = png_ptr->gamma_from_1;
|
||||
png_bytep table = png_ptr->gamma_from_1;
|
||||
|
||||
if (table != NULL)
|
||||
{
|
||||
const int step =
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2;
|
||||
int step = (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2;
|
||||
|
||||
/* The alpha channel is the last component: */
|
||||
row += step - 1;
|
||||
@ -4162,13 +4159,12 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
||||
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
const png_uint_16pp table = png_ptr->gamma_16_from_1;
|
||||
const int gamma_shift = png_ptr->gamma_shift;
|
||||
png_uint_16pp table = png_ptr->gamma_16_from_1;
|
||||
int gamma_shift = png_ptr->gamma_shift;
|
||||
|
||||
if (table != NULL)
|
||||
{
|
||||
const int step =
|
||||
(row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4;
|
||||
int step = (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4;
|
||||
|
||||
/* The alpha channel is the last component: */
|
||||
row += step - 2;
|
||||
|
11
pngrutil.c
11
pngrutil.c
@ -1461,8 +1461,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
{
|
||||
/* We have the ICC profile header; do the basic header checks.
|
||||
*/
|
||||
const png_uint_32 profile_length =
|
||||
png_get_uint_32(profile_header);
|
||||
png_uint_32 profile_length = png_get_uint_32(profile_header);
|
||||
|
||||
if (png_icc_check_length(png_ptr, &png_ptr->colorspace,
|
||||
keyword, profile_length) != 0)
|
||||
@ -1479,8 +1478,8 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
* profile. The header check has already validated
|
||||
* that none of this stuff will overflow.
|
||||
*/
|
||||
const png_uint_32 tag_count = png_get_uint_32(
|
||||
profile_header+128);
|
||||
png_uint_32 tag_count =
|
||||
png_get_uint_32(profile_header + 128);
|
||||
png_bytep profile = png_read_buffer(png_ptr,
|
||||
profile_length, 2/*silent*/);
|
||||
|
||||
@ -3132,7 +3131,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
*/
|
||||
|
||||
void /* PRIVATE */
|
||||
png_check_chunk_name(png_const_structrp png_ptr, const png_uint_32 chunk_name)
|
||||
png_check_chunk_name(png_const_structrp png_ptr, png_uint_32 chunk_name)
|
||||
{
|
||||
int i;
|
||||
png_uint_32 cn=chunk_name;
|
||||
@ -3151,7 +3150,7 @@ png_check_chunk_name(png_const_structrp png_ptr, const png_uint_32 chunk_name)
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_check_chunk_length(png_const_structrp png_ptr, const png_uint_32 length)
|
||||
png_check_chunk_length(png_const_structrp png_ptr, png_uint_32 length)
|
||||
{
|
||||
png_alloc_size_t limit = PNG_UINT_31_MAX;
|
||||
|
||||
|
4
pngset.c
4
pngset.c
@ -137,7 +137,7 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,
|
||||
#ifdef PNG_eXIf_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
const png_bytep eXIf_buf)
|
||||
png_bytep eXIf_buf)
|
||||
{
|
||||
png_warning(png_ptr, "png_set_eXIf does not work; use png_set_eXIf_1");
|
||||
PNG_UNUSED(info_ptr)
|
||||
@ -146,7 +146,7 @@ png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
void PNGAPI
|
||||
png_set_eXIf_1(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
const png_uint_32 num_exif, const png_bytep eXIf_buf)
|
||||
png_uint_32 num_exif, png_bytep eXIf_buf)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
26
pngwrite.c
26
pngwrite.c
@ -1536,7 +1536,7 @@ png_write_image_16bit(png_voidp argument)
|
||||
display->first_row);
|
||||
png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row);
|
||||
png_uint_16p row_end;
|
||||
const unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
|
||||
unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
|
||||
3 : 1;
|
||||
int aindex = 0;
|
||||
png_uint_32 y = image->height;
|
||||
@ -1573,7 +1573,7 @@ png_write_image_16bit(png_voidp argument)
|
||||
|
||||
while (out_ptr < row_end)
|
||||
{
|
||||
const png_uint_16 alpha = in_ptr[aindex];
|
||||
png_uint_16 alpha = in_ptr[aindex];
|
||||
png_uint_32 reciprocal = 0;
|
||||
int c;
|
||||
|
||||
@ -1695,7 +1695,7 @@ png_write_image_8bit(png_voidp argument)
|
||||
display->first_row);
|
||||
png_bytep output_row = png_voidcast(png_bytep, display->local_row);
|
||||
png_uint_32 y = image->height;
|
||||
const unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
|
||||
unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
|
||||
3 : 1;
|
||||
|
||||
if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
@ -1783,25 +1783,25 @@ png_write_image_8bit(png_voidp argument)
|
||||
static void
|
||||
png_image_set_PLTE(png_image_write_control *display)
|
||||
{
|
||||
const png_imagep image = display->image;
|
||||
png_imagep image = display->image;
|
||||
const void *cmap = display->colormap;
|
||||
const int entries = image->colormap_entries > 256 ? 256 :
|
||||
int entries = image->colormap_entries > 256 ? 256 :
|
||||
(int)image->colormap_entries;
|
||||
|
||||
/* NOTE: the caller must check for cmap != NULL and entries != 0 */
|
||||
const png_uint_32 format = image->format;
|
||||
const unsigned int channels = PNG_IMAGE_SAMPLE_CHANNELS(format);
|
||||
png_uint_32 format = image->format;
|
||||
unsigned int channels = PNG_IMAGE_SAMPLE_CHANNELS(format);
|
||||
|
||||
# if defined(PNG_FORMAT_BGR_SUPPORTED) &&\
|
||||
defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED)
|
||||
const int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
|
||||
int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
|
||||
(format & PNG_FORMAT_FLAG_ALPHA) != 0;
|
||||
# else
|
||||
# define afirst 0
|
||||
# endif
|
||||
|
||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
const int bgr = (format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
|
||||
int bgr = (format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
|
||||
# else
|
||||
# define bgr 0
|
||||
# endif
|
||||
@ -1951,12 +1951,12 @@ png_image_write_main(png_voidp argument)
|
||||
* and total image size to ensure that they are within the system limits.
|
||||
*/
|
||||
{
|
||||
const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
|
||||
unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
|
||||
|
||||
if (image->width <= 0x7fffffffU/channels) /* no overflow */
|
||||
{
|
||||
png_uint_32 check;
|
||||
const png_uint_32 png_row_stride = image->width * channels;
|
||||
png_uint_32 png_row_stride = image->width * channels;
|
||||
|
||||
if (display->row_stride == 0)
|
||||
display->row_stride = (png_int_32)/*SAFE*/png_row_stride;
|
||||
@ -2052,7 +2052,7 @@ png_image_write_main(png_voidp argument)
|
||||
*/
|
||||
if (write_16bit != 0)
|
||||
{
|
||||
const png_uint_16 le = 0x0001;
|
||||
png_uint_16 le = 0x0001;
|
||||
|
||||
if ((*(png_const_bytep) & le) != 0)
|
||||
png_set_swap(png_ptr);
|
||||
@ -2166,7 +2166,7 @@ image_memory_write)(png_structp png_ptr, png_bytep/*const*/ data, size_t size)
|
||||
{
|
||||
png_image_write_control *display = png_voidcast(png_image_write_control*,
|
||||
png_ptr->io_ptr/*backdoor: png_get_io_ptr(png_ptr)*/);
|
||||
const png_alloc_size_t ob = display->output_bytes;
|
||||
png_alloc_size_t ob = display->output_bytes;
|
||||
|
||||
/* Check for overflow; this should never happen: */
|
||||
if (size <= ((png_alloc_size_t)-1) - ob)
|
||||
|
@ -254,8 +254,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
|
||||
for (i = 0; i < istop; i++, bp++)
|
||||
{
|
||||
|
||||
const unsigned int c = i%channels;
|
||||
unsigned int c = i%channels;
|
||||
int j;
|
||||
unsigned int v, out;
|
||||
|
||||
@ -283,7 +282,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
||||
|
||||
for (bp = row, i = 0; i < istop; i++)
|
||||
{
|
||||
const unsigned int c = i%channels;
|
||||
unsigned int c = i%channels;
|
||||
int j;
|
||||
unsigned int value, v;
|
||||
|
||||
|
14
pngwutil.c
14
pngwutil.c
@ -2101,7 +2101,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
||||
static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
||||
|
||||
/* Offset to next interlace block */
|
||||
static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
|
||||
png_debug(1, "in png_do_write_interlace");
|
||||
|
||||
@ -2276,7 +2276,7 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
|
||||
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
static size_t /* PRIVATE */
|
||||
png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
png_setup_sub_row(png_structrp png_ptr, png_uint_32 bpp,
|
||||
size_t row_bytes, size_t lmins)
|
||||
{
|
||||
png_bytep rp, dp, lp;
|
||||
@ -2315,7 +2315,7 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
}
|
||||
|
||||
static void /* PRIVATE */
|
||||
png_setup_sub_row_only(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
png_setup_sub_row_only(png_structrp png_ptr, png_uint_32 bpp,
|
||||
size_t row_bytes)
|
||||
{
|
||||
png_bytep rp, dp, lp;
|
||||
@ -2380,7 +2380,7 @@ png_setup_up_row_only(png_structrp png_ptr, size_t row_bytes)
|
||||
}
|
||||
|
||||
static size_t /* PRIVATE */
|
||||
png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
png_setup_avg_row(png_structrp png_ptr, png_uint_32 bpp,
|
||||
size_t row_bytes, size_t lmins)
|
||||
{
|
||||
png_bytep rp, dp, pp, lp;
|
||||
@ -2420,7 +2420,7 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
return (sum);
|
||||
}
|
||||
static void /* PRIVATE */
|
||||
png_setup_avg_row_only(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
png_setup_avg_row_only(png_structrp png_ptr, png_uint_32 bpp,
|
||||
size_t row_bytes)
|
||||
{
|
||||
png_bytep rp, dp, pp, lp;
|
||||
@ -2442,7 +2442,7 @@ png_setup_avg_row_only(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
}
|
||||
|
||||
static size_t /* PRIVATE */
|
||||
png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
png_setup_paeth_row(png_structrp png_ptr, png_uint_32 bpp,
|
||||
size_t row_bytes, size_t lmins)
|
||||
{
|
||||
png_bytep rp, dp, pp, cp, lp;
|
||||
@ -2503,7 +2503,7 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
return (sum);
|
||||
}
|
||||
static void /* PRIVATE */
|
||||
png_setup_paeth_row_only(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
png_setup_paeth_row_only(png_structrp png_ptr, png_uint_32 bpp,
|
||||
size_t row_bytes)
|
||||
{
|
||||
png_bytep rp, dp, pp, cp, lp;
|
||||
|
@ -173,7 +173,7 @@ static const vector unsigned char VSX_SHORT_TO_CHAR4_3 = {16,16,16,16,16,16,16,1
|
||||
void png_read_filter_row_sub4_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 4;
|
||||
png_byte bpp = 4;
|
||||
|
||||
vector unsigned char rp_vec;
|
||||
vector unsigned char part_vec;
|
||||
@ -230,7 +230,7 @@ void png_read_filter_row_sub4_vsx(png_row_infop row_info, png_bytep row,
|
||||
void png_read_filter_row_sub3_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 3;
|
||||
png_byte bpp = 3;
|
||||
|
||||
vector unsigned char rp_vec;
|
||||
vector unsigned char part_vec;
|
||||
@ -294,7 +294,7 @@ void png_read_filter_row_sub3_vsx(png_row_infop row_info, png_bytep row,
|
||||
void png_read_filter_row_avg4_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 4;
|
||||
png_byte bpp = 4;
|
||||
|
||||
vector unsigned char rp_vec;
|
||||
vector unsigned char pp_vec;
|
||||
@ -381,7 +381,7 @@ void png_read_filter_row_avg4_vsx(png_row_infop row_info, png_bytep row,
|
||||
void png_read_filter_row_avg3_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 3;
|
||||
png_byte bpp = 3;
|
||||
|
||||
vector unsigned char rp_vec;
|
||||
vector unsigned char pp_vec;
|
||||
@ -499,7 +499,7 @@ void png_read_filter_row_avg3_vsx(png_row_infop row_info, png_bytep row,
|
||||
void png_read_filter_row_paeth4_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 4;
|
||||
png_byte bpp = 4;
|
||||
|
||||
int a, b, c, pa, pb, pc, p;
|
||||
vector unsigned char rp_vec;
|
||||
@ -619,7 +619,7 @@ void png_read_filter_row_paeth4_vsx(png_row_infop row_info, png_bytep row,
|
||||
void png_read_filter_row_paeth3_vsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
const png_byte bpp = 3;
|
||||
png_byte bpp = 3;
|
||||
|
||||
int a, b, c, pa, pb, pc, p;
|
||||
vector unsigned char rp_vec;
|
||||
|
Loading…
Reference in New Issue
Block a user