chore: Add, relocate or rephrase debug statements, for better clarity

This commit is contained in:
Cosmin Truta 2024-01-23 02:33:54 +02:00
parent 6159bad8a9
commit 92b2128a75
8 changed files with 89 additions and 58 deletions

View File

@ -1,7 +1,7 @@
/* pngget.c - retrieval of values from info struct /* pngget.c - retrieval of values from info struct
* *
* Copyright (c) 2018-2023 Cosmin Truta * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@ -127,12 +127,11 @@ png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
info_ptr) info_ptr)
{ {
#ifdef PNG_pHYs_SUPPORTED #ifdef PNG_pHYs_SUPPORTED
png_debug(1, "in png_get_x_pixels_per_meter");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0) (info_ptr->valid & PNG_INFO_pHYs) != 0)
{ {
png_debug1(1, "in %s retrieval function",
"png_get_x_pixels_per_meter");
if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
return (info_ptr->x_pixels_per_unit); return (info_ptr->x_pixels_per_unit);
} }
@ -149,12 +148,11 @@ png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
info_ptr) info_ptr)
{ {
#ifdef PNG_pHYs_SUPPORTED #ifdef PNG_pHYs_SUPPORTED
png_debug(1, "in png_get_y_pixels_per_meter");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0) (info_ptr->valid & PNG_INFO_pHYs) != 0)
{ {
png_debug1(1, "in %s retrieval function",
"png_get_y_pixels_per_meter");
if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
return (info_ptr->y_pixels_per_unit); return (info_ptr->y_pixels_per_unit);
} }
@ -170,11 +168,11 @@ png_uint_32 PNGAPI
png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr) png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
{ {
#ifdef PNG_pHYs_SUPPORTED #ifdef PNG_pHYs_SUPPORTED
png_debug(1, "in png_get_pixels_per_meter");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0) (info_ptr->valid & PNG_INFO_pHYs) != 0)
{ {
png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER && if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER &&
info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit) info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit)
return (info_ptr->x_pixels_per_unit); return (info_ptr->x_pixels_per_unit);
@ -193,11 +191,11 @@ 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
png_debug(1, "in png_get_pixel_aspect_ratio");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0) (info_ptr->valid & PNG_INFO_pHYs) != 0)
{ {
png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
if (info_ptr->x_pixels_per_unit != 0) if (info_ptr->x_pixels_per_unit != 0)
return ((float)((float)info_ptr->y_pixels_per_unit return ((float)((float)info_ptr->y_pixels_per_unit
/(float)info_ptr->x_pixels_per_unit)); /(float)info_ptr->x_pixels_per_unit));
@ -217,6 +215,8 @@ png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
png_const_inforp info_ptr) png_const_inforp info_ptr)
{ {
#ifdef PNG_READ_pHYs_SUPPORTED #ifdef PNG_READ_pHYs_SUPPORTED
png_debug(1, "in png_get_pixel_aspect_ratio_fixed");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0 && (info_ptr->valid & PNG_INFO_pHYs) != 0 &&
info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 && info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 &&
@ -225,8 +225,6 @@ png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
{ {
png_fixed_point res; png_fixed_point res;
png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed");
/* The following casts work because a PNG 4 byte integer only has a valid /* The following casts work because a PNG 4 byte integer only has a valid
* range of 0..2^31-1; otherwise the cast might overflow. * range of 0..2^31-1; otherwise the cast might overflow.
*/ */
@ -247,11 +245,11 @@ png_int_32 PNGAPI
png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
{ {
#ifdef PNG_oFFs_SUPPORTED #ifdef PNG_oFFs_SUPPORTED
png_debug(1, "in png_get_x_offset_microns");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_oFFs) != 0) (info_ptr->valid & PNG_INFO_oFFs) != 0)
{ {
png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
return (info_ptr->x_offset); return (info_ptr->x_offset);
} }
@ -267,11 +265,11 @@ png_int_32 PNGAPI
png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
{ {
#ifdef PNG_oFFs_SUPPORTED #ifdef PNG_oFFs_SUPPORTED
png_debug(1, "in png_get_y_offset_microns");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_oFFs) != 0) (info_ptr->valid & PNG_INFO_oFFs) != 0)
{ {
png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
return (info_ptr->y_offset); return (info_ptr->y_offset);
} }
@ -287,11 +285,11 @@ png_int_32 PNGAPI
png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
{ {
#ifdef PNG_oFFs_SUPPORTED #ifdef PNG_oFFs_SUPPORTED
png_debug(1, "in png_get_x_offset_pixels");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_oFFs) != 0) (info_ptr->valid & PNG_INFO_oFFs) != 0)
{ {
png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels");
if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
return (info_ptr->x_offset); return (info_ptr->x_offset);
} }
@ -307,11 +305,11 @@ png_int_32 PNGAPI
png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
{ {
#ifdef PNG_oFFs_SUPPORTED #ifdef PNG_oFFs_SUPPORTED
png_debug(1, "in png_get_y_offset_pixels");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_oFFs) != 0) (info_ptr->valid & PNG_INFO_oFFs) != 0)
{ {
png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels");
if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
return (info_ptr->y_offset); return (info_ptr->y_offset);
} }
@ -434,11 +432,11 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
{ {
png_uint_32 retval = 0; png_uint_32 retval = 0;
png_debug1(1, "in %s retrieval function", "pHYs");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0) (info_ptr->valid & PNG_INFO_pHYs) != 0)
{ {
png_debug1(1, "in %s retrieval function", "pHYs");
if (res_x != NULL) if (res_x != NULL)
{ {
*res_x = info_ptr->x_pixels_per_unit; *res_x = info_ptr->x_pixels_per_unit;
@ -499,12 +497,12 @@ png_uint_32 PNGAPI
png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
png_color_16p *background) png_color_16p *background)
{ {
png_debug1(1, "in %s retrieval function", "bKGD");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_bKGD) != 0 && (info_ptr->valid & PNG_INFO_bKGD) != 0 &&
background != NULL) background != NULL)
{ {
png_debug1(1, "in %s retrieval function", "bKGD");
*background = &(info_ptr->background); *background = &(info_ptr->background);
return (PNG_INFO_bKGD); return (PNG_INFO_bKGD);
} }
@ -524,6 +522,8 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
double *white_x, double *white_y, double *red_x, double *red_y, double *white_x, double *white_y, double *red_x, double *red_y,
double *green_x, double *green_y, double *blue_x, double *blue_y) double *green_x, double *green_y, double *blue_x, double *blue_y)
{ {
png_debug1(1, "in %s retrieval function", "cHRM");
/* Quiet API change: this code used to only return the end points if a cHRM /* Quiet API change: this code used to only return the end points if a cHRM
* chunk was present, but the end points can also come from iCCP or sRGB * chunk was present, but the end points can also come from iCCP or sRGB
* chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and * chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and
@ -533,8 +533,6 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{ {
png_debug1(1, "in %s retrieval function", "cHRM");
if (white_x != NULL) if (white_x != NULL)
*white_x = png_float(png_ptr, *white_x = png_float(png_ptr,
info_ptr->colorspace.end_points_xy.whitex, "cHRM white X"); info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
@ -571,11 +569,11 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
double *green_Y, double *green_Z, double *blue_X, double *blue_Y, double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
double *blue_Z) double *blue_Z)
{ {
png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{ {
png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
if (red_X != NULL) if (red_X != NULL)
*red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X, *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
"cHRM red X"); "cHRM red X");
@ -619,11 +617,11 @@ png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
png_fixed_point *int_blue_Z) png_fixed_point *int_blue_Z)
{ {
png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{ {
png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
if (int_red_X != NULL) if (int_red_X != NULL)
*int_red_X = info_ptr->colorspace.end_points_XYZ.red_X; *int_red_X = info_ptr->colorspace.end_points_XYZ.red_X;
if (int_red_Y != NULL) if (int_red_Y != NULL)
@ -775,6 +773,8 @@ int PNGAPI
png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr, png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
png_sPLT_tpp spalettes) png_sPLT_tpp spalettes)
{ {
png_debug1(1, "in %s retrieval function", "sPLT");
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
{ {
*spalettes = info_ptr->splt_palettes; *spalettes = info_ptr->splt_palettes;
@ -932,6 +932,8 @@ png_uint_32 PNGAPI
png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, png_fixed_point *width, png_fixed_point *height) int *unit, png_fixed_point *width, png_fixed_point *height)
{ {
png_debug1(1, "in %s retrieval function", "sCAL");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_sCAL) != 0) (info_ptr->valid & PNG_INFO_sCAL) != 0)
{ {
@ -955,6 +957,8 @@ png_uint_32 PNGAPI
png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr, png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, double *width, double *height) int *unit, double *width, double *height)
{ {
png_debug1(1, "in %s retrieval function", "sCAL(float)");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_sCAL) != 0) (info_ptr->valid & PNG_INFO_sCAL) != 0)
{ {
@ -971,6 +975,8 @@ png_uint_32 PNGAPI
png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr, png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, png_charpp width, png_charpp height) int *unit, png_charpp width, png_charpp height)
{ {
png_debug1(1, "in %s retrieval function", "sCAL(str)");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_sCAL) != 0) (info_ptr->valid & PNG_INFO_sCAL) != 0)
{ {
@ -1062,7 +1068,7 @@ png_get_text(png_const_structrp png_ptr, png_inforp info_ptr,
{ {
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
{ {
png_debug1(1, "in 0x%lx retrieval function", png_debug1(1, "in text retrieval function, chunk typeid = 0x%lx",
(unsigned long)png_ptr->chunk_name); (unsigned long)png_ptr->chunk_name);
if (text_ptr != NULL) if (text_ptr != NULL)
@ -1105,11 +1111,12 @@ png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color) png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
{ {
png_uint_32 retval = 0; png_uint_32 retval = 0;
png_debug1(1, "in %s retrieval function", "tRNS");
if (png_ptr != NULL && info_ptr != NULL && if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_tRNS) != 0) (info_ptr->valid & PNG_INFO_tRNS) != 0)
{ {
png_debug1(1, "in %s retrieval function", "tRNS");
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{ {
if (trans_alpha != NULL) if (trans_alpha != NULL)

View File

@ -1,7 +1,7 @@
/* pngread.c - read a PNG file /* pngread.c - read a PNG file
* *
* Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@ -1049,6 +1049,8 @@ void PNGAPI
png_read_png(png_structrp png_ptr, png_inforp info_ptr, png_read_png(png_structrp png_ptr, png_inforp info_ptr,
int transforms, voidp params) int transforms, voidp params)
{ {
png_debug(1, "in png_read_png");
if (png_ptr == NULL || info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;

View File

@ -1,7 +1,7 @@
/* pngrtran.c - transforms the data in a row for PNG readers /* pngrtran.c - transforms the data in a row for PNG readers
* *
* Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@ -290,7 +290,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
int compose = 0; int compose = 0;
png_fixed_point file_gamma; png_fixed_point file_gamma;
png_debug(1, "in png_set_alpha_mode"); png_debug(1, "in png_set_alpha_mode_fixed");
if (png_rtran_ok(png_ptr, 0) == 0) if (png_rtran_ok(png_ptr, 0) == 0)
return; return;
@ -970,7 +970,7 @@ void PNGFAPI
png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
png_fixed_point red, png_fixed_point green) png_fixed_point red, png_fixed_point green)
{ {
png_debug(1, "in png_set_rgb_to_gray"); png_debug(1, "in png_set_rgb_to_gray_fixed");
/* Need the IHDR here because of the check on color_type below. */ /* Need the IHDR here because of the check on color_type below. */
/* TODO: fix this */ /* TODO: fix this */

View File

@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file /* pngrutil.c - utilities to read a PNG file
* *
* Copyright (c) 2018-2022 Cosmin Truta * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@ -171,7 +171,7 @@ png_read_chunk_header(png_structrp png_ptr)
/* Put the chunk name into png_ptr->chunk_name. */ /* Put the chunk name into png_ptr->chunk_name. */
png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(buf+4); png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(buf+4);
png_debug2(0, "Reading %lx chunk, length = %lu", png_debug2(0, "Reading chunk typeid = 0x%lx, length = %lu",
(unsigned long)png_ptr->chunk_name, (unsigned long)length); (unsigned long)png_ptr->chunk_name, (unsigned long)length);
/* Reset the crc and run it over the chunk name. */ /* Reset the crc and run it over the chunk name. */

View File

@ -1,7 +1,7 @@
/* pngset.c - storage of image information into info struct /* pngset.c - storage of image information into info struct
* *
* Copyright (c) 2018-2023 Cosmin Truta * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@ -763,8 +763,8 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
{ {
int i; int i;
png_debug1(1, "in %lx storage function", png_ptr == NULL ? 0xabadca11U : png_debug1(1, "in text storage function, chunk typeid = 0x%lx",
(unsigned long)png_ptr->chunk_name); png_ptr == NULL ? 0xabadca11UL : (unsigned long)png_ptr->chunk_name);
if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL)
return(0); return(0);
@ -1063,6 +1063,8 @@ png_set_sPLT(png_const_structrp png_ptr,
{ {
png_sPLT_tp np; png_sPLT_tp np;
png_debug1(1, "in %s storage function", "sPLT");
if (png_ptr == NULL || info_ptr == NULL || nentries <= 0 || entries == NULL) if (png_ptr == NULL || info_ptr == NULL || nentries <= 0 || entries == NULL)
return; return;
@ -1537,7 +1539,7 @@ void PNGAPI
png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr, png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr,
png_bytepp row_pointers) png_bytepp row_pointers)
{ {
png_debug1(1, "in %s storage function", "rows"); png_debug(1, "in png_set_rows");
if (png_ptr == NULL || info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
@ -1556,6 +1558,8 @@ png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr,
void PNGAPI void PNGAPI
png_set_compression_buffer_size(png_structrp png_ptr, size_t size) png_set_compression_buffer_size(png_structrp png_ptr, size_t size)
{ {
png_debug(1, "in png_set_compression_buffer_size");
if (png_ptr == NULL) if (png_ptr == NULL)
return; return;
@ -1627,6 +1631,8 @@ void PNGAPI
png_set_user_limits(png_structrp png_ptr, png_uint_32 user_width_max, png_set_user_limits(png_structrp png_ptr, png_uint_32 user_width_max,
png_uint_32 user_height_max) png_uint_32 user_height_max)
{ {
png_debug(1, "in png_set_user_limits");
/* Images with dimensions larger than these limits will be /* Images with dimensions larger than these limits will be
* rejected by png_set_IHDR(). To accept any PNG datastream * rejected by png_set_IHDR(). To accept any PNG datastream
* regardless of dimensions, set both limits to 0x7fffffff. * regardless of dimensions, set both limits to 0x7fffffff.
@ -1642,6 +1648,8 @@ png_set_user_limits(png_structrp png_ptr, png_uint_32 user_width_max,
void PNGAPI void PNGAPI
png_set_chunk_cache_max(png_structrp png_ptr, png_uint_32 user_chunk_cache_max) png_set_chunk_cache_max(png_structrp png_ptr, png_uint_32 user_chunk_cache_max)
{ {
png_debug(1, "in png_set_chunk_cache_max");
if (png_ptr != NULL) if (png_ptr != NULL)
png_ptr->user_chunk_cache_max = user_chunk_cache_max; png_ptr->user_chunk_cache_max = user_chunk_cache_max;
} }
@ -1651,6 +1659,8 @@ void PNGAPI
png_set_chunk_malloc_max(png_structrp png_ptr, png_set_chunk_malloc_max(png_structrp png_ptr,
png_alloc_size_t user_chunk_malloc_max) png_alloc_size_t user_chunk_malloc_max)
{ {
png_debug(1, "in png_set_chunk_malloc_max");
if (png_ptr != NULL) if (png_ptr != NULL)
png_ptr->user_chunk_malloc_max = user_chunk_malloc_max; png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;
} }

View File

@ -1,7 +1,7 @@
/* pngtest.c - a simple test program to test libpng /* pngtest.c - a simple test program to test libpng
* *
* Copyright (c) 2018-2023 Cosmin Truta * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@ -1656,16 +1656,16 @@ test_one_file(const char *inname, const char *outname)
pngtest_debug("Destroying data structs"); pngtest_debug("Destroying data structs");
#ifdef SINGLE_ROWBUF_ALLOC #ifdef SINGLE_ROWBUF_ALLOC
pngtest_debug("destroying row_buf for read_ptr"); pngtest_debug("Destroying row_buf for read_ptr");
png_free(read_ptr, row_buf); png_free(read_ptr, row_buf);
row_buf = NULL; row_buf = NULL;
#endif /* SINGLE_ROWBUF_ALLOC */ #endif /* SINGLE_ROWBUF_ALLOC */
pngtest_debug("destroying read_ptr, read_info_ptr, end_info_ptr"); pngtest_debug("Destroying read_ptr, read_info_ptr, end_info_ptr");
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
#ifdef PNG_WRITE_SUPPORTED #ifdef PNG_WRITE_SUPPORTED
pngtest_debug("destroying write_end_info_ptr"); pngtest_debug("Destroying write_end_info_ptr");
png_destroy_info_struct(write_ptr, &write_end_info_ptr); png_destroy_info_struct(write_ptr, &write_end_info_ptr);
pngtest_debug("destroying write_ptr, write_info_ptr"); pngtest_debug("Destroying write_ptr, write_info_ptr");
png_destroy_write_struct(&write_ptr, &write_info_ptr); png_destroy_write_struct(&write_ptr, &write_info_ptr);
#endif #endif
pngtest_debug("Destruction complete."); pngtest_debug("Destruction complete.");

View File

@ -1,7 +1,7 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers) /* pngtrans.c - transforms the data in a row (used by both readers and writers)
* *
* Copyright (c) 2018 Cosmin Truta * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@ -498,6 +498,8 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
png_bytep dp = row; /* destination pointer */ png_bytep dp = row; /* destination pointer */
png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */ png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */
png_debug(1, "in png_do_strip_channel");
/* At the start sp will point to the first byte to copy and dp to where /* At the start sp will point to the first byte to copy and dp to where
* it is copied to. ep always points just beyond the end of the row, so * it is copied to. ep always points just beyond the end of the row, so
* the loop simply copies (channels-1) channels until sp reaches ep. * the loop simply copies (channels-1) channels until sp reaches ep.
@ -698,6 +700,8 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
void /* PRIVATE */ void /* PRIVATE */
png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info) png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
{ {
png_debug(1, "in png_do_check_palette_indexes");
if (png_ptr->num_palette < (1 << row_info->bit_depth) && if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */ png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */
{ {

View File

@ -1,7 +1,7 @@
/* pngwrite.c - general routines to write a PNG file /* pngwrite.c - general routines to write a PNG file
* *
* Copyright (c) 2018-2023 Cosmin Truta * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@ -715,12 +715,12 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
/* 1.5.6: moved from png_struct to be a local structure: */ /* 1.5.6: moved from png_struct to be a local structure: */
png_row_info row_info; png_row_info row_info;
if (png_ptr == NULL)
return;
png_debug2(1, "in png_write_row (row %u, pass %d)", png_debug2(1, "in png_write_row (row %u, pass %d)",
png_ptr->row_number, png_ptr->pass); png_ptr->row_number, png_ptr->pass);
if (png_ptr == NULL)
return;
/* Initialize transformations and other stuff if first time */ /* Initialize transformations and other stuff if first time */
if (png_ptr->row_number == 0 && png_ptr->pass == 0) if (png_ptr->row_number == 0 && png_ptr->pass == 0)
{ {
@ -1211,6 +1211,8 @@ png_set_compression_strategy(png_structrp png_ptr, int strategy)
void PNGAPI void PNGAPI
png_set_compression_window_bits(png_structrp png_ptr, int window_bits) png_set_compression_window_bits(png_structrp png_ptr, int window_bits)
{ {
png_debug(1, "in png_set_compression_window_bits");
if (png_ptr == NULL) if (png_ptr == NULL)
return; return;
@ -1294,6 +1296,8 @@ png_set_text_compression_strategy(png_structrp png_ptr, int strategy)
void PNGAPI void PNGAPI
png_set_text_compression_window_bits(png_structrp png_ptr, int window_bits) png_set_text_compression_window_bits(png_structrp png_ptr, int window_bits)
{ {
png_debug(1, "in png_set_text_compression_window_bits");
if (png_ptr == NULL) if (png_ptr == NULL)
return; return;
@ -1331,6 +1335,8 @@ png_set_text_compression_method(png_structrp png_ptr, int method)
void PNGAPI void PNGAPI
png_set_write_status_fn(png_structrp png_ptr, png_write_status_ptr write_row_fn) png_set_write_status_fn(png_structrp png_ptr, png_write_status_ptr write_row_fn)
{ {
png_debug(1, "in png_set_write_status_fn");
if (png_ptr == NULL) if (png_ptr == NULL)
return; return;
@ -1358,6 +1364,8 @@ void PNGAPI
png_write_png(png_structrp png_ptr, png_inforp info_ptr, png_write_png(png_structrp png_ptr, png_inforp info_ptr,
int transforms, voidp params) int transforms, voidp params)
{ {
png_debug(1, "in png_write_png");
if (png_ptr == NULL || info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;