Housecleaning: revise identation and comments to meet libpng coding style.

This commit is contained in:
Glenn Randers-Pehrson glennrp@comcast.net
2009-05-15 20:39:34 -05:00
parent 9a692c0769
commit b1c0d33128
19 changed files with 1845 additions and 1390 deletions

View File

@@ -47,8 +47,9 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
#else
0);
#endif
/* the rest of these check to see if the valid field has the appropriate
flag set, and if it does, writes the chunk. */
/* The rest of these check to see if the valid field has the appropriate
* flag set, and if it does, writes the chunk.
*/
#if defined(PNG_WRITE_gAMA_SUPPORTED)
if (info_ptr->valid & PNG_INFO_gAMA)
{
@@ -97,14 +98,14 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
if (info_ptr->unknown_chunks_num)
{
png_unknown_chunk *up;
png_unknown_chunk *up;
png_debug(5, "writing extra chunks");
png_debug(5, "writing extra chunks");
for (up = info_ptr->unknown_chunks;
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
up++)
{
for (up = info_ptr->unknown_chunks;
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
up++)
{
int keep=png_handle_as_unknown(png_ptr, up->name);
if (keep != PNG_HANDLE_CHUNK_NEVER &&
up->location && !(up->location & PNG_HAVE_PLTE) &&
@@ -116,7 +117,7 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
png_warning(png_ptr, "Writing zero-length unknown chunk");
png_write_chunk(png_ptr, up->name, up->data, up->size);
}
}
}
}
#endif
png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE;
@@ -145,20 +146,20 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_WRITE_tRNS_SUPPORTED)
if (info_ptr->valid & PNG_INFO_tRNS)
{
{
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
/* invert the alpha channel (in tRNS) */
if ((png_ptr->transformations & PNG_INVERT_ALPHA) &&
info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
int j;
for (j=0; j<(int)info_ptr->num_trans; j++)
info_ptr->trans[j] = (png_byte)(255 - info_ptr->trans[j]);
}
/* invert the alpha channel (in tRNS) */
if ((png_ptr->transformations & PNG_INVERT_ALPHA) &&
info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
int j;
for (j=0; j<(int)info_ptr->num_trans; j++)
info_ptr->trans[j] = (png_byte)(255 - info_ptr->trans[j]);
}
#endif
png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_color),
info_ptr->num_trans, info_ptr->color_type);
}
}
#endif
#if defined(PNG_WRITE_bKGD_SUPPORTED)
if (info_ptr->valid & PNG_INFO_bKGD)
@@ -179,8 +180,9 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams,
info_ptr->pcal_units, info_ptr->pcal_params);
#endif
#if defined(PNG_WRITE_sCAL_SUPPORTED)
#if defined(PNG_sCAL_SUPPORTED)
if (info_ptr->valid & PNG_INFO_sCAL)
#if defined(PNG_WRITE_sCAL_SUPPORTED)
#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)
png_write_sCAL(png_ptr, (int)info_ptr->scal_unit,
info_ptr->scal_pixel_width, info_ptr->scal_pixel_height);
@@ -188,29 +190,34 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_FIXED_POINT_SUPPORTED
png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit,
info_ptr->scal_s_width, info_ptr->scal_s_height);
#else
#endif /* FIXED_POINT */
#endif /* FLOATING_POINT */
#else /* WRITE_sCAL */
png_warning(png_ptr,
"png_write_sCAL not supported; sCAL chunk not written");
#endif
#endif
#endif
#endif /* WRITE_sCAL */
#endif /* sCAL */
#if defined(PNG_WRITE_pHYs_SUPPORTED)
if (info_ptr->valid & PNG_INFO_pHYs)
png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit,
info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type);
#endif
#endif /* pHYs */
#if defined(PNG_WRITE_tIME_SUPPORTED)
if (info_ptr->valid & PNG_INFO_tIME)
{
png_write_tIME(png_ptr, &(info_ptr->mod_time));
png_ptr->mode |= PNG_WROTE_tIME;
}
#endif
#endif /* tIME */
#if defined(PNG_WRITE_sPLT_SUPPORTED)
if (info_ptr->valid & PNG_INFO_sPLT)
for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
png_write_sPLT(png_ptr, info_ptr->splt_palettes + i);
#endif
#endif /* sPLT */
#if defined(PNG_WRITE_TEXT_SUPPORTED)
/* Check to see if we need to write text chunks */
for (i = 0; i < info_ptr->num_text; i++)
@@ -255,25 +262,27 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
png_write_tEXt(png_ptr, info_ptr->text[i].key,
info_ptr->text[i].text,
0);
#else
png_warning(png_ptr, "Unable to write uncompressed text");
#endif
/* Mark this chunk as written */
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
#else
/* Can't get here */
png_warning(png_ptr, "Unable to write uncompressed text");
#endif
}
}
#endif
#endif /* tEXt */
#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
if (info_ptr->unknown_chunks_num)
{
png_unknown_chunk *up;
png_unknown_chunk *up;
png_debug(5, "writing extra chunks");
png_debug(5, "writing extra chunks");
for (up = info_ptr->unknown_chunks;
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
up++)
{
for (up = info_ptr->unknown_chunks;
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
up++)
{
int keep=png_handle_as_unknown(png_ptr, up->name);
if (keep != PNG_HANDLE_CHUNK_NEVER &&
up->location && (up->location & PNG_HAVE_PLTE) &&
@@ -283,7 +292,7 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
{
png_write_chunk(png_ptr, up->name, up->data, up->size);
}
}
}
}
#endif
}
@@ -324,18 +333,18 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
if (info_ptr->text[i].compression > 0)
{
#if defined(PNG_WRITE_iTXt_SUPPORTED)
/* write international chunk */
png_write_iTXt(png_ptr,
info_ptr->text[i].compression,
info_ptr->text[i].key,
info_ptr->text[i].lang,
info_ptr->text[i].lang_key,
info_ptr->text[i].text);
/* write international chunk */
png_write_iTXt(png_ptr,
info_ptr->text[i].compression,
info_ptr->text[i].key,
info_ptr->text[i].lang,
info_ptr->text[i].lang_key,
info_ptr->text[i].text);
#else
png_warning(png_ptr, "Unable to write international text");
png_warning(png_ptr, "Unable to write international text");
#endif
/* Mark this chunk as written */
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
/* Mark this chunk as written */
info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
}
else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt)
{
@@ -368,14 +377,14 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
if (info_ptr->unknown_chunks_num)
{
png_unknown_chunk *up;
png_unknown_chunk *up;
png_debug(5, "writing extra chunks");
png_debug(5, "writing extra chunks");
for (up = info_ptr->unknown_chunks;
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
up++)
{
for (up = info_ptr->unknown_chunks;
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
up++)
{
int keep=png_handle_as_unknown(png_ptr, up->name);
if (keep != PNG_HANDLE_CHUNK_NEVER &&
up->location && (up->location & PNG_AFTER_IDAT) &&
@@ -384,7 +393,7 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
{
png_write_chunk(png_ptr, up->name, up->data, up->size);
}
}
}
}
#endif
}
@@ -449,7 +458,7 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
#endif /* PNG_USER_MEM_SUPPORTED */
int png_cleanup_needed = 0;
#ifdef PNG_SETJMP_SUPPORTED
volatile
volatile
#endif
png_structp png_ptr;
#ifdef PNG_SETJMP_SUPPORTED
@@ -483,7 +492,7 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
#else
if (setjmp(png_ptr->jmpbuf))
#endif
PNG_ABORT();
PNG_ABORT();
#endif
#ifdef PNG_USER_MEM_SUPPORTED
@@ -493,12 +502,12 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
if (user_png_ver)
{
i=0;
do
{
if (user_png_ver[i] != png_libpng_ver[i])
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
} while (png_libpng_ver[i++]);
i=0;
do
{
if (user_png_ver[i] != png_libpng_ver[i])
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
} while (png_libpng_ver[i++]);
}
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
@@ -516,10 +525,10 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
char msg[80];
if (user_png_ver)
{
png_snprintf(msg, 80,
"Application was compiled with png.h from libpng-%.20s",
user_png_ver);
png_warning(png_ptr, msg);
png_snprintf(msg, 80,
"Application was compiled with png.h from libpng-%.20s",
user_png_ver);
png_warning(png_ptr, msg);
}
png_snprintf(msg, 80,
"Application is running with png.c from libpng-%.20s",
@@ -538,25 +547,25 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
/* initialize zbuf - compression buffer */
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
if (!png_cleanup_needed)
{
png_ptr->zbuf = (png_bytep)png_malloc_warn(png_ptr,
png_ptr->zbuf_size);
if (png_ptr->zbuf == NULL)
png_cleanup_needed = 1;
}
{
png_ptr->zbuf = (png_bytep)png_malloc_warn(png_ptr,
png_ptr->zbuf_size);
if (png_ptr->zbuf == NULL)
png_cleanup_needed = 1;
}
if (png_cleanup_needed)
{
/* Clean up PNG structure and deallocate any memory. */
png_free(png_ptr, png_ptr->zbuf);
png_ptr->zbuf = NULL;
{
/* Clean up PNG structure and deallocate any memory. */
png_free(png_ptr, png_ptr->zbuf);
png_ptr->zbuf = NULL;
#ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)png_ptr,
(png_free_ptr)free_fn, (png_voidp)mem_ptr);
png_destroy_struct_2((png_voidp)png_ptr,
(png_free_ptr)free_fn, (png_voidp)mem_ptr);
#else
png_destroy_struct((png_voidp)png_ptr);
png_destroy_struct((png_voidp)png_ptr);
#endif
return (NULL);
}
return (NULL);
}
png_set_write_fn(png_ptr, NULL, NULL, NULL);
@@ -609,7 +618,8 @@ png_write_image(png_structp png_ptr, png_bytepp image)
png_debug(1, "in png_write_image");
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
/* intialize interlace handling. If image is not interlaced,
this will set pass to 1 */
* this will set pass to 1
*/
num_pass = png_set_interlace_handling(png_ptr);
#else
num_pass = 1;
@@ -637,39 +647,39 @@ png_write_row(png_structp png_ptr, png_bytep row)
/* initialize transformations and other stuff if first time */
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
{
/* make sure we wrote the header info */
if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
png_error(png_ptr,
"png_write_info was never called before png_write_row");
/* make sure we wrote the header info */
if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
png_error(png_ptr,
"png_write_info was never called before png_write_row");
/* check for transforms that have been set but were defined out */
/* check for transforms that have been set but were defined out */
#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED)
if (png_ptr->transformations & PNG_INVERT_MONO)
png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined");
if (png_ptr->transformations & PNG_INVERT_MONO)
png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined");
#endif
#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED)
if (png_ptr->transformations & PNG_FILLER)
png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined");
if (png_ptr->transformations & PNG_FILLER)
png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined");
#endif
#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && defined(PNG_READ_PACKSWAP_SUPPORTED)
if (png_ptr->transformations & PNG_PACKSWAP)
png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined");
if (png_ptr->transformations & PNG_PACKSWAP)
png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined");
#endif
#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED)
if (png_ptr->transformations & PNG_PACK)
png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined");
if (png_ptr->transformations & PNG_PACK)
png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined");
#endif
#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED)
if (png_ptr->transformations & PNG_SHIFT)
png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined");
if (png_ptr->transformations & PNG_SHIFT)
png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined");
#endif
#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED)
if (png_ptr->transformations & PNG_BGR)
png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined");
if (png_ptr->transformations & PNG_BGR)
png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined");
#endif
#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED)
if (png_ptr->transformations & PNG_SWAP_BYTES)
png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined");
if (png_ptr->transformations & PNG_SWAP_BYTES)
png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined");
#endif
png_write_start_row(png_ptr);
@@ -756,13 +766,13 @@ png_write_row(png_structp png_ptr, png_bytep row)
png_memcpy(png_ptr->row_buf + 1, row, png_ptr->row_info.rowbytes);
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
/* handle interlacing */
/* Handle interlacing */
if (png_ptr->interlaced && png_ptr->pass < 6 &&
(png_ptr->transformations & PNG_INTERLACE))
{
png_do_write_interlace(&(png_ptr->row_info),
png_ptr->row_buf + 1, png_ptr->pass);
/* this should always get caught above, but still ... */
/* This should always get caught above, but still ... */
if (!(png_ptr->row_info.width))
{
png_write_finish_row(png_ptr);
@@ -771,7 +781,7 @@ png_write_row(png_structp png_ptr, png_bytep row)
}
#endif
/* handle other transformations */
/* Handle other transformations */
if (png_ptr->transformations)
png_do_write_transformations(png_ptr);
@@ -822,7 +832,7 @@ png_write_flush(png_structp png_ptr)
return;
/* We have already written out all of the data */
if (png_ptr->row_number >= png_ptr->num_rows)
return;
return;
do
{
@@ -866,7 +876,7 @@ png_write_flush(png_structp png_ptr)
}
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
/* free all memory used by the write */
/* Free all memory used by the write */
void PNGAPI
png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
{
@@ -978,7 +988,7 @@ png_write_destroy(png_structp png_ptr)
#endif
#ifdef PNG_SETJMP_SUPPORTED
/* reset structure */
/* Reset structure */
png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));
#endif
@@ -1334,9 +1344,9 @@ png_write_png(png_structp png_ptr, png_infop info_ptr,
if (png_ptr == NULL || info_ptr == NULL)
return;
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
/* invert the alpha channel from opacity to transparency */
/* Invert the alpha channel from opacity to transparency */
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
png_set_invert_alpha(png_ptr);
png_set_invert_alpha(png_ptr);
#endif
/* Write the file header information. */
@@ -1345,9 +1355,9 @@ png_write_png(png_structp png_ptr, png_infop info_ptr,
/* ------ these transformations don't touch the info structure ------- */
#if defined(PNG_WRITE_INVERT_SUPPORTED)
/* invert monochrome pixels */
/* Invert monochrome pixels */
if (transforms & PNG_TRANSFORM_INVERT_MONO)
png_set_invert_mono(png_ptr);
png_set_invert_mono(png_ptr);
#endif
#if defined(PNG_WRITE_SHIFT_SUPPORTED)
@@ -1356,50 +1366,50 @@ png_write_png(png_structp png_ptr, png_infop info_ptr,
*/
if ((transforms & PNG_TRANSFORM_SHIFT)
&& (info_ptr->valid & PNG_INFO_sBIT))
png_set_shift(png_ptr, &info_ptr->sig_bit);
png_set_shift(png_ptr, &info_ptr->sig_bit);
#endif
#if defined(PNG_WRITE_PACK_SUPPORTED)
/* pack pixels into bytes */
/* Pack pixels into bytes */
if (transforms & PNG_TRANSFORM_PACKING)
png_set_packing(png_ptr);
#endif
#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
/* swap location of alpha bytes from ARGB to RGBA */
/* Swap location of alpha bytes from ARGB to RGBA */
if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
png_set_swap_alpha(png_ptr);
png_set_swap_alpha(png_ptr);
#endif
#if defined(PNG_WRITE_FILLER_SUPPORTED)
/* Pack XRGB/RGBX/ARGB/RGBA into * RGB (4 channels -> 3 channels) */
if (transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER)
if (transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER)
png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
else if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE)
else if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE)
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
#endif
#if defined(PNG_WRITE_BGR_SUPPORTED)
/* flip BGR pixels to RGB */
/* Flip BGR pixels to RGB */
if (transforms & PNG_TRANSFORM_BGR)
png_set_bgr(png_ptr);
png_set_bgr(png_ptr);
#endif
#if defined(PNG_WRITE_SWAP_SUPPORTED)
/* swap bytes of 16-bit files to most significant byte first */
/* Swap bytes of 16-bit files to most significant byte first */
if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
png_set_swap(png_ptr);
png_set_swap(png_ptr);
#endif
#if defined(PNG_WRITE_PACKSWAP_SUPPORTED)
/* swap bits of 1, 2, 4 bit packed pixel formats */
/* Swap bits of 1, 2, 4 bit packed pixel formats */
if (transforms & PNG_TRANSFORM_PACKSWAP)
png_set_packswap(png_ptr);
png_set_packswap(png_ptr);
#endif
/* ----------------------- end of transformations ------------------- */
/* write the bits */
/* Write the bits */
if (info_ptr->valid & PNG_INFO_IDAT)
png_write_image(png_ptr, info_ptr->row_pointers);