| Index: third_party/libpng/pngread.c
|
| ===================================================================
|
| --- third_party/libpng/pngread.c (revision 18910)
|
| +++ third_party/libpng/pngread.c (working copy)
|
| @@ -1,7 +1,7 @@
|
|
|
| /* pngread.c - read a PNG file
|
| *
|
| - * Last changed in libpng 1.2.35 [February 14, 2009]
|
| + * Last changed in libpng 1.2.37 [June 4, 2009]
|
| * For conditions of distribution and use, see copyright notice in png.h
|
| * Copyright (c) 1998-2009 Glenn Randers-Pehrson
|
| * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
| @@ -57,7 +57,7 @@
|
| if (png_ptr == NULL)
|
| return (NULL);
|
|
|
| - /* added at libpng-1.2.6 */
|
| + /* Added at libpng-1.2.6 */
|
| #ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
| png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
|
| png_ptr->user_height_max=PNG_USER_HEIGHT_MAX;
|
| @@ -137,7 +137,7 @@
|
| }
|
| }
|
|
|
| - /* initialize zbuf - compression buffer */
|
| + /* Initialize zbuf - compression buffer */
|
| png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
| png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
| (png_uint_32)png_ptr->zbuf_size);
|
| @@ -192,7 +192,8 @@
|
| png_size_t png_struct_size, png_size_t png_info_size)
|
| {
|
| /* We only come here via pre-1.0.12-compiled applications */
|
| - if (png_ptr == NULL) return;
|
| + if (png_ptr == NULL)
|
| + return;
|
| #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
| if (png_sizeof(png_struct) > png_struct_size ||
|
| png_sizeof(png_info) > png_info_size)
|
| @@ -246,7 +247,8 @@
|
|
|
| png_structp png_ptr=*ptr_ptr;
|
|
|
| - if (png_ptr == NULL) return;
|
| + if (png_ptr == NULL)
|
| + return;
|
|
|
| do
|
| {
|
| @@ -266,7 +268,7 @@
|
| png_debug(1, "in png_read_init_3");
|
|
|
| #ifdef PNG_SETJMP_SUPPORTED
|
| - /* save jump buffer and error functions */
|
| + /* Save jump buffer and error functions */
|
| png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));
|
| #endif
|
|
|
| @@ -277,21 +279,21 @@
|
| png_ptr = *ptr_ptr;
|
| }
|
|
|
| - /* reset all variables to 0 */
|
| + /* Reset all variables to 0 */
|
| png_memset(png_ptr, 0, png_sizeof(png_struct));
|
|
|
| #ifdef PNG_SETJMP_SUPPORTED
|
| - /* restore jump buffer */
|
| + /* Restore jump buffer */
|
| png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
|
| #endif
|
|
|
| - /* added at libpng-1.2.6 */
|
| + /* Added at libpng-1.2.6 */
|
| #ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
| png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
|
| png_ptr->user_height_max=PNG_USER_HEIGHT_MAX;
|
| #endif
|
|
|
| - /* initialize zbuf - compression buffer */
|
| + /* Initialize zbuf - compression buffer */
|
| png_ptr->zbuf_size = PNG_ZBUF_SIZE;
|
| png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
|
| (png_uint_32)png_ptr->zbuf_size);
|
| @@ -326,7 +328,8 @@
|
| void PNGAPI
|
| png_read_info(png_structp png_ptr, png_infop info_ptr)
|
| {
|
| - if (png_ptr == NULL || info_ptr == NULL) return;
|
| + if (png_ptr == NULL || info_ptr == NULL)
|
| + return;
|
| png_debug(1, "in png_read_info");
|
| /* If we haven't checked all of the PNG signature bytes, do so now. */
|
| if (png_ptr->sig_bytes < 8)
|
| @@ -529,12 +532,13 @@
|
| }
|
| #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
|
|
|
| -/* optional call to update the users info_ptr structure */
|
| +/* Optional call to update the users info_ptr structure */
|
| void PNGAPI
|
| png_read_update_info(png_structp png_ptr, png_infop info_ptr)
|
| {
|
| png_debug(1, "in png_read_update_info");
|
| - if (png_ptr == NULL) return;
|
| + if (png_ptr == NULL)
|
| + return;
|
| if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
| png_read_start_row(png_ptr);
|
| else
|
| @@ -553,7 +557,8 @@
|
| png_start_read_image(png_structp png_ptr)
|
| {
|
| png_debug(1, "in png_start_read_image");
|
| - if (png_ptr == NULL) return;
|
| + if (png_ptr == NULL)
|
| + return;
|
| if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
| png_read_start_row(png_ptr);
|
| }
|
| @@ -570,14 +575,15 @@
|
| PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
| #endif
|
| int ret;
|
| - if (png_ptr == NULL) return;
|
| + if (png_ptr == NULL)
|
| + return;
|
| png_debug2(1, "in png_read_row (row %lu, pass %d)",
|
| png_ptr->row_number, png_ptr->pass);
|
| if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
| png_read_start_row(png_ptr);
|
| if (png_ptr->row_number == 0 && png_ptr->pass == 0)
|
| {
|
| - /* 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_READ_INVERT_SUPPORTED is not defined.");
|
| @@ -609,7 +615,7 @@
|
| }
|
|
|
| #if defined(PNG_READ_INTERLACING_SUPPORTED)
|
| - /* if interlaced and we do not need a new row, combine row and return */
|
| + /* If interlaced and we do not need a new row, combine row and return */
|
| if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
|
| {
|
| switch (png_ptr->pass)
|
| @@ -756,15 +762,15 @@
|
| png_do_read_transformations(png_ptr);
|
|
|
| #if defined(PNG_READ_INTERLACING_SUPPORTED)
|
| - /* blow up interlaced rows to full size */
|
| + /* Blow up interlaced rows to full size */
|
| if (png_ptr->interlaced &&
|
| (png_ptr->transformations & PNG_INTERLACE))
|
| {
|
| if (png_ptr->pass < 6)
|
| -/* old interface (pre-1.0.9):
|
| - png_do_read_interlace(&(png_ptr->row_info),
|
| - png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations);
|
| - */
|
| + /* Old interface (pre-1.0.9):
|
| + * png_do_read_interlace(&(png_ptr->row_info),
|
| + * png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations);
|
| + */
|
| png_do_read_interlace(png_ptr);
|
|
|
| if (dsp_row != NULL)
|
| @@ -823,7 +829,8 @@
|
| png_bytepp dp;
|
|
|
| png_debug(1, "in png_read_rows");
|
| - if (png_ptr == NULL) return;
|
| + if (png_ptr == NULL)
|
| + return;
|
| rp = row;
|
| dp = display_row;
|
| if (rp != NULL && dp != NULL)
|
| @@ -872,7 +879,8 @@
|
| png_bytepp rp;
|
|
|
| png_debug(1, "in png_read_image");
|
| - if (png_ptr == NULL) return;
|
| + if (png_ptr == NULL)
|
| + return;
|
|
|
| #ifdef PNG_READ_INTERLACING_SUPPORTED
|
| pass = png_set_interlace_handling(png_ptr);
|
| @@ -908,7 +916,8 @@
|
| png_read_end(png_structp png_ptr, png_infop info_ptr)
|
| {
|
| png_debug(1, "in png_read_end");
|
| - if (png_ptr == NULL) return;
|
| + if (png_ptr == NULL)
|
| + return;
|
| png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
|
|
|
| do
|
| @@ -1075,7 +1084,7 @@
|
| }
|
| #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
|
|
|
| -/* free all memory used by the read */
|
| +/* Free all memory used by the read */
|
| void PNGAPI
|
| png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
| png_infopp end_info_ptr_ptr)
|
| @@ -1147,7 +1156,7 @@
|
| }
|
| }
|
|
|
| -/* free all memory used by the read (old method) */
|
| +/* Free all memory used by the read (old method) */
|
| void /* PRIVATE */
|
| png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr)
|
| {
|
| @@ -1296,7 +1305,8 @@
|
| void PNGAPI
|
| png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
|
| {
|
| - if (png_ptr == NULL) return;
|
| + if (png_ptr == NULL)
|
| + return;
|
| png_ptr->read_row_fn = read_row_fn;
|
| }
|
|
|
| @@ -1310,9 +1320,10 @@
|
| {
|
| int row;
|
|
|
| - if (png_ptr == NULL) return;
|
| + if (png_ptr == NULL)
|
| + return;
|
| #if defined(PNG_READ_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);
|
| @@ -1328,10 +1339,10 @@
|
| /* -------------- image transformations start here ------------------- */
|
|
|
| #if defined(PNG_READ_16_TO_8_SUPPORTED)
|
| - /* tell libpng to strip 16 bit/color files down to 8 bits per color
|
| + /* Tell libpng to strip 16 bit/color files down to 8 bits per color.
|
| */
|
| if (transforms & PNG_TRANSFORM_STRIP_16)
|
| - png_set_strip_16(png_ptr);
|
| + png_set_strip_16(png_ptr);
|
| #endif
|
|
|
| #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
|
| @@ -1339,7 +1350,7 @@
|
| * the background (not recommended).
|
| */
|
| if (transforms & PNG_TRANSFORM_STRIP_ALPHA)
|
| - png_set_strip_alpha(png_ptr);
|
| + png_set_strip_alpha(png_ptr);
|
| #endif
|
|
|
| #if defined(PNG_READ_PACK_SUPPORTED) && !defined(PNG_READ_EXPAND_SUPPORTED)
|
| @@ -1347,7 +1358,7 @@
|
| * byte into separate bytes (useful for paletted and grayscale images).
|
| */
|
| if (transforms & PNG_TRANSFORM_PACKING)
|
| - png_set_packing(png_ptr);
|
| + png_set_packing(png_ptr);
|
| #endif
|
|
|
| #if defined(PNG_READ_PACKSWAP_SUPPORTED)
|
| @@ -1355,7 +1366,7 @@
|
| * (not useful if you are using png_set_packing).
|
| */
|
| if (transforms & PNG_TRANSFORM_PACKSWAP)
|
| - png_set_packswap(png_ptr);
|
| + png_set_packswap(png_ptr);
|
| #endif
|
|
|
| #if defined(PNG_READ_EXPAND_SUPPORTED)
|
| @@ -1365,9 +1376,9 @@
|
| * channels so the data will be available as RGBA quartets.
|
| */
|
| if (transforms & PNG_TRANSFORM_EXPAND)
|
| - if ((png_ptr->bit_depth < 8) ||
|
| - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ||
|
| - (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)))
|
| + if ((png_ptr->bit_depth < 8) ||
|
| + (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ||
|
| + (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)))
|
| png_set_expand(png_ptr);
|
| #endif
|
|
|
| @@ -1375,10 +1386,10 @@
|
| */
|
|
|
| #if defined(PNG_READ_INVERT_SUPPORTED)
|
| - /* invert monochrome files to have 0 as white and 1 as black
|
| + /* Invert monochrome files to have 0 as white and 1 as black
|
| */
|
| if (transforms & PNG_TRANSFORM_INVERT_MONO)
|
| - png_set_invert_mono(png_ptr);
|
| + png_set_invert_mono(png_ptr);
|
| #endif
|
|
|
| #if defined(PNG_READ_SHIFT_SUPPORTED)
|
| @@ -1397,24 +1408,24 @@
|
| #endif
|
|
|
| #if defined(PNG_READ_BGR_SUPPORTED)
|
| - /* flip the RGB pixels to BGR (or RGBA to BGRA)
|
| + /* Flip the RGB pixels to BGR (or RGBA to BGRA)
|
| */
|
| if (transforms & PNG_TRANSFORM_BGR)
|
| - png_set_bgr(png_ptr);
|
| + png_set_bgr(png_ptr);
|
| #endif
|
|
|
| #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
|
| - /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR)
|
| + /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR)
|
| */
|
| if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
|
| png_set_swap_alpha(png_ptr);
|
| #endif
|
|
|
| #if defined(PNG_READ_SWAP_SUPPORTED)
|
| - /* swap bytes of 16 bit files to least significant byte first
|
| + /* Swap bytes of 16 bit files to least significant byte first
|
| */
|
| if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
|
| - png_set_swap(png_ptr);
|
| + png_set_swap(png_ptr);
|
| #endif
|
|
|
| /* We don't handle adding filler bytes */
|
| @@ -1447,10 +1458,10 @@
|
| png_read_image(png_ptr, info_ptr->row_pointers);
|
| info_ptr->valid |= PNG_INFO_IDAT;
|
|
|
| - /* read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
| + /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
| png_read_end(png_ptr, info_ptr);
|
|
|
| - transforms = transforms; /* quiet compiler warnings */
|
| + transforms = transforms; /* Quiet compiler warnings */
|
| params = params;
|
|
|
| }
|
|
|