Prusa MINI Firmware overview
|
|
#define | PNG_FIXED_ERROR (-1) |
|
#define | PNG_LSR(x, s) ((x)>>((s) & 0x1f)) |
|
#define | PNG_LSL(x, s) ((x)<<((s) & 0x1f)) |
|
#define | S_COPY(p, x) |
|
#define | B_COPY(p, x) |
|
#define | PIXEL_MASK(p, x, d, s) (PNG_LSL(((PNG_LSL(1U,(d)))-1),(((x)*(d))^((s)?8-(d):0)))) |
|
#define | S_MASKx(p, x, d, s) (S_COPY(p,x)?PIXEL_MASK(p,x,d,s):0) |
|
#define | B_MASKx(p, x, d, s) (B_COPY(p,x)?PIXEL_MASK(p,x,d,s):0) |
|
#define | MASK_EXPAND(m, d) ((m)*((d)==1?0x01010101:((d)==2?0x00010001:1))) |
|
#define | S_MASK(p, d, s) |
|
#define | B_MASK(p, d, s) |
|
#define | S_MASKS(d, s) |
|
#define | B_MASKS(d, s) { B_MASK(1,d,s), B_MASK(3,d,s), B_MASK(5,d,s) } |
|
#define | DEPTH_INDEX(d) ((d)==1?0:((d)==2?1:2)) |
|
#define | MASK(pass, depth, display, png) |
|
|
png_uint_32 PNGAPI | png_get_uint_31 (png_const_structrp png_ptr, png_const_bytep buf) |
|
static png_fixed_point | png_get_fixed_point (png_structrp png_ptr, png_const_bytep buf) |
|
| png_uint_32 (PNGAPI png_get_uint_32)(png_const_bytep buf) |
|
| png_int_32 (PNGAPI png_get_int_32)(png_const_bytep buf) |
|
| png_uint_16 (PNGAPI png_get_uint_16)(png_const_bytep buf) |
|
void | png_read_sig (png_structrp png_ptr, png_inforp info_ptr) |
|
png_uint_32 | png_read_chunk_header (png_structrp png_ptr) |
|
void | png_crc_read (png_structrp png_ptr, png_bytep buf, png_uint_32 length) |
|
int | png_crc_finish (png_structrp png_ptr, png_uint_32 skip) |
|
int | png_crc_error (png_structrp png_ptr) |
|
static png_bytep | png_read_buffer (png_structrp png_ptr, png_alloc_size_t new_size, int warn) |
|
static int | png_inflate_claim (png_structrp png_ptr, png_uint_32 owner) |
|
static int | png_inflate (png_structrp png_ptr, png_uint_32 owner, int finish, png_const_bytep input, png_uint_32p input_size_ptr, png_bytep output, png_alloc_size_t *output_size_ptr) |
|
static int | png_decompress_chunk (png_structrp png_ptr, png_uint_32 chunklength, png_uint_32 prefix_size, png_alloc_size_t *newlength, int terminate) |
|
static int | png_inflate_read (png_structrp png_ptr, png_bytep read_buffer, uInt read_size, png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size, int finish) |
|
void | png_handle_IHDR (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_PLTE (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_IEND (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_gAMA (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_sBIT (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_cHRM (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_sRGB (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_iCCP (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_sPLT (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_tRNS (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_bKGD (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_eXIf (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_hIST (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_pHYs (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_oFFs (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_pCAL (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_sCAL (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_tIME (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_tEXt (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_zTXt (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
void | png_handle_iTXt (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) |
|
static int | png_cache_unknown_chunk (png_structrp png_ptr, png_uint_32 length) |
|
void | png_handle_unknown (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length, int keep) |
|
void | png_check_chunk_name (png_const_structrp png_ptr, png_uint_32 chunk_name) |
|
void | png_check_chunk_length (png_const_structrp png_ptr, png_uint_32 length) |
|
void | png_combine_row (png_const_structrp png_ptr, png_bytep dp, int display) |
|
void | png_do_read_interlace (png_row_infop row_info, png_bytep row, int pass, png_uint_32 transformations) |
|
static void | png_read_filter_row_sub (png_row_infop row_info, png_bytep row, png_const_bytep prev_row) |
|
static void | png_read_filter_row_up (png_row_infop row_info, png_bytep row, png_const_bytep prev_row) |
|
static void | png_read_filter_row_avg (png_row_infop row_info, png_bytep row, png_const_bytep prev_row) |
|
static void | png_read_filter_row_paeth_1byte_pixel (png_row_infop row_info, png_bytep row, png_const_bytep prev_row) |
|
static void | png_read_filter_row_paeth_multibyte_pixel (png_row_infop row_info, png_bytep row, png_const_bytep prev_row) |
|
static void | png_init_filter_functions (png_structrp pp) |
|
void | png_read_filter_row (png_structrp pp, png_row_infop row_info, png_bytep row, png_const_bytep prev_row, int filter) |
|
void | png_read_IDAT_data (png_structrp png_ptr, png_bytep output, png_alloc_size_t avail_out) |
|
void | png_read_finish_IDAT (png_structrp png_ptr) |
|
void | png_read_finish_row (png_structrp png_ptr) |
|
void | png_read_start_row (png_structrp png_ptr) |
|
◆ PNG_FIXED_ERROR
#define PNG_FIXED_ERROR (-1) |
◆ PNG_LSR
#define PNG_LSR |
( |
|
x, |
|
|
|
s |
|
) |
| ((x)>>((s) & 0x1f)) |
◆ PNG_LSL
#define PNG_LSL |
( |
|
x, |
|
|
|
s |
|
) |
| ((x)<<((s) & 0x1f)) |
◆ S_COPY
Value:(((p)<4 ?
PNG_LSR(0x80088822,(3-(p))*8+(7-(x))) :\
PNG_LSR(0xaa55ff00,(7-(p))*8+(7-(x)))) & 1)
◆ B_COPY
Value:(((p)<4 ?
PNG_LSR(0xff0fff33,(3-(p))*8+(7-(x))) :\
PNG_LSR(0xff55ff00,(7-(p))*8+(7-(x)))) & 1)
◆ PIXEL_MASK
#define PIXEL_MASK |
( |
|
p, |
|
|
|
x, |
|
|
|
d, |
|
|
|
s |
|
) |
| (PNG_LSL(((PNG_LSL(1U,(d)))-1),(((x)*(d))^((s)?8-(d):0)))) |
◆ S_MASKx
◆ B_MASKx
◆ MASK_EXPAND
#define MASK_EXPAND |
( |
|
m, |
|
|
|
d |
|
) |
| ((m)*((d)==1?0x01010101:((d)==2?0x00010001:1))) |
◆ S_MASK
#define S_MASK |
( |
|
p, |
|
|
|
d, |
|
|
|
s |
|
) |
| |
Value:
S_MASKx(p,5,d,s) +
S_MASKx(p,6,d,s) +
S_MASKx(p,7,d,s), d)
◆ B_MASK
#define B_MASK |
( |
|
p, |
|
|
|
d, |
|
|
|
s |
|
) |
| |
Value:
B_MASKx(p,5,d,s) +
B_MASKx(p,6,d,s) +
B_MASKx(p,7,d,s), d)
◆ S_MASKS
◆ B_MASKS
◆ DEPTH_INDEX
#define DEPTH_INDEX |
( |
|
d | ) |
((d)==1?0:((d)==2?1:2)) |
◆ MASK
#define MASK |
( |
|
pass, |
|
|
|
depth, |
|
|
|
display, |
|
|
|
png |
|
) |
| |
◆ png_get_uint_31()
◆ png_get_fixed_point()
◆ png_uint_32()
◆ png_int_32()
png_int_32 |
( |
PNGAPI |
png_get_int_32 | ) |
|
88 if ((uval & 0x80000000) == 0)
91 uval = (uval ^ 0xffffffff) + 1;
92 if ((uval & 0x80000000) == 0)
◆ png_uint_16()
png_uint_16 |
( |
PNGAPI |
png_get_uint_16 | ) |
|
111 ((
unsigned int)(*buf) << 8) +
112 ((
unsigned int)(*(buf + 1)));
◆ png_read_sig()
123 size_t num_checked, num_to_check;
129 num_checked =
png_ptr->sig_bytes;
130 num_to_check = 8 - num_checked;
132 #ifdef PNG_IO_STATE_SUPPORTED
142 if (num_checked < 4 &&
◆ png_read_chunk_header()
161 #ifdef PNG_IO_STATE_SUPPORTED
174 png_debug2(0,
"Reading %lx chunk, length = %lu",
187 #ifdef PNG_IO_STATE_SUPPORTED
◆ png_crc_read()
◆ png_crc_finish()
221 len = (
sizeof tmpbuf);
239 png_chunk_error(
png_ptr,
"CRC error");
◆ png_crc_error()
253 png_byte crc_bytes[4];
270 #ifdef PNG_IO_STATE_SUPPORTED
◆ png_read_buffer()
302 if (buffer !=
NULL && new_size >
png_ptr->read_buffer_size)
317 memset(buffer, 0, new_size);
319 png_ptr->read_buffer_size = new_size;
328 png_chunk_error(
png_ptr,
"insufficient memory to read chunk");
◆ png_inflate_claim()
354 #if PNG_RELEASE_BUILD
377 #if ZLIB_VERNUM >= 0x1240
380 # if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW)
402 png_ptr->zstream.avail_out = 0;
406 #if ZLIB_VERNUM >= 0x1240
415 #if ZLIB_VERNUM >= 0x1240
425 #if ZLIB_VERNUM >= 0x1290 && \
426 defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_IGNORE_ADLER32)
◆ png_inflate()
507 png_ptr->zstream.avail_out = 0;
513 png_ptr->zstream.next_out = output;
528 avail_in +=
png_ptr->zstream.avail_in;
532 if (avail_in < avail)
533 avail = (
uInt)avail_in;
536 png_ptr->zstream.avail_in = avail;
539 avail_out +=
png_ptr->zstream.avail_out;
548 png_ptr->zstream.next_out = local_buffer;
549 if ((
sizeof local_buffer) < avail)
550 avail = (
sizeof local_buffer);
553 if (avail_out < avail)
554 avail = (
uInt)avail_out;
556 png_ptr->zstream.avail_out = avail;
567 }
while (ret ==
Z_OK);
574 avail_in +=
png_ptr->zstream.avail_in;
575 avail_out +=
png_ptr->zstream.avail_out;
581 *output_size_ptr -= avail_out;
584 *input_size_ptr -= avail_in;
◆ png_decompress_chunk()
624 # ifdef PNG_SET_USER_LIMITS_SUPPORTED
625 if (
png_ptr->user_chunk_malloc_max > 0 &&
626 png_ptr->user_chunk_malloc_max < limit)
627 limit =
png_ptr->user_chunk_malloc_max;
628 # elif PNG_USER_CHUNK_MALLOC_MAX > 0
633 if (limit >= prefix_size + (terminate != 0))
637 limit -= prefix_size + (terminate != 0);
639 if (limit < *newlength)
650 png_ptr->read_buffer + prefix_size, &lzsize,
677 memset(text, 0, buffer_size);
680 png_ptr->read_buffer + prefix_size, &lzsize,
681 text + prefix_size, newlength);
685 if (new_size == *newlength)
688 text[prefix_size + *newlength] = 0;
691 memcpy(text,
png_ptr->read_buffer, prefix_size);
697 png_ptr->read_buffer_size = buffer_size;
714 else if (ret ==
Z_OK)
726 chunklength - prefix_size != lzsize)
746 else if (ret ==
Z_OK)
◆ png_inflate_read()
783 png_ptr->zstream.next_out = next_out;
784 png_ptr->zstream.avail_out = 0;
788 if (
png_ptr->zstream.avail_in == 0)
790 if (read_size > *chunk_bytes)
791 read_size = (
uInt)*chunk_bytes;
792 *chunk_bytes -= read_size;
797 png_ptr->zstream.next_in = read_buffer;
798 png_ptr->zstream.avail_in = read_size;
801 if (
png_ptr->zstream.avail_out == 0)
804 if (avail > *out_size)
805 avail = (
uInt)*out_size;
808 png_ptr->zstream.avail_out = avail;
818 while (ret ==
Z_OK && (*out_size > 0 ||
png_ptr->zstream.avail_out > 0));
820 *out_size +=
png_ptr->zstream.avail_out;
821 png_ptr->zstream.avail_out = 0;
◆ png_handle_IHDR()
843 int bit_depth, color_type, compression_type, filter_type;
849 png_chunk_error(
png_ptr,
"out of place");
853 png_chunk_error(
png_ptr,
"invalid");
864 compression_type = buf[10];
865 filter_type = buf[11];
866 interlace_type = buf[12];
871 png_ptr->bit_depth = (png_byte)bit_depth;
872 png_ptr->interlaced = (png_byte)interlace_type;
873 png_ptr->color_type = (png_byte)color_type;
874 #ifdef PNG_MNG_FEATURES_SUPPORTED
875 png_ptr->filter_type = (png_byte)filter_type;
877 png_ptr->compression_type = (png_byte)compression_type;
908 color_type, interlace_type, compression_type, filter_type);
◆ png_handle_PLTE()
916 int max_palette_length, num,
i;
917 #ifdef PNG_POINTER_INDEXING_SUPPORTED
924 png_chunk_error(
png_ptr,
"missing IHDR");
932 png_chunk_error(
png_ptr,
"duplicate");
953 #ifndef PNG_READ_OPT_PLTE_SUPPORTED
969 png_chunk_error(
png_ptr,
"invalid");
983 max_palette_length = (1 <<
png_ptr->bit_depth);
987 if (num > max_palette_length)
988 num = max_palette_length;
990 #ifdef PNG_POINTER_INDEXING_SUPPORTED
991 for (
i = 0, pal_ptr = palette;
i < num;
i++, pal_ptr++)
996 pal_ptr->
red = buf[0];
997 pal_ptr->
green = buf[1];
998 pal_ptr->
blue = buf[2];
1001 for (
i = 0;
i < num;
i++)
1007 palette[
i].
red = buf[0];
1008 palette[
i].
green = buf[1];
1009 palette[
i].
blue = buf[2];
1018 #ifndef PNG_READ_OPT_PLTE_SUPPORTED
1025 #ifndef PNG_READ_OPT_PLTE_SUPPORTED
1043 png_chunk_error(
png_ptr,
"CRC error");
1071 #ifdef PNG_READ_tRNS_SUPPORTED
1088 #ifdef PNG_READ_hIST_SUPPORTED
1093 #ifdef PNG_READ_bKGD_SUPPORTED
◆ png_handle_IEND()
1106 png_chunk_error(
png_ptr,
"out of place");
◆ png_handle_gAMA()
1128 png_chunk_error(
png_ptr,
"missing IHDR");
◆ png_handle_sBIT()
1160 unsigned int truelen,
i;
1161 png_byte sample_depth;
1167 png_chunk_error(
png_ptr,
"missing IHDR");
1192 sample_depth =
png_ptr->bit_depth;
1202 buf[0] = buf[1] = buf[2] = buf[3] = sample_depth;
1208 for (
i=0;
i<truelen; ++
i)
1210 if (buf[
i] == 0 || buf[
i] > sample_depth)
1219 png_ptr->sig_bit.red = buf[0];
1220 png_ptr->sig_bit.green = buf[1];
1221 png_ptr->sig_bit.blue = buf[2];
1222 png_ptr->sig_bit.alpha = buf[3];
1227 png_ptr->sig_bit.gray = buf[0];
1228 png_ptr->sig_bit.red = buf[0];
1229 png_ptr->sig_bit.green = buf[0];
1230 png_ptr->sig_bit.blue = buf[0];
1231 png_ptr->sig_bit.alpha = buf[1];
◆ png_handle_cHRM()
1248 png_chunk_error(
png_ptr,
"missing IHDR");
1292 if ((
png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0)
1295 if ((
png_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0)
1297 png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;
1303 png_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
◆ png_handle_sRGB()
1319 png_chunk_error(
png_ptr,
"missing IHDR");
1341 if ((
png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0)
1347 if ((
png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT) != 0)
1349 png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;
◆ png_handle_iCCP()
1371 png_chunk_error(
png_ptr,
"missing IHDR");
1398 if ((
png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0)
1407 if ((
png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT) == 0)
1409 uInt read_length, keyword_length;
1416 if (read_length >
length)
1433 while (keyword_length < 80 && keyword_length < read_length &&
1434 keyword[keyword_length] != 0)
1438 if (keyword_length >= 1 && keyword_length <= 79)
1443 if (keyword_length+1 < read_length &&
1446 read_length -= keyword_length+2;
1450 Byte profile_header[132]={0};
1454 png_ptr->zstream.next_in = (
Bytef*)keyword + (keyword_length+2);
1455 png_ptr->zstream.avail_in = read_length;
1457 (
sizeof local_buffer), &
length, profile_header, &
size,
1467 keyword, profile_length) != 0)
1473 keyword, profile_length, profile_header,
1486 if (profile !=
NULL)
1488 memcpy(profile, profile_header,
1489 (
sizeof profile_header));
1491 size = 12 * tag_count;
1494 (
sizeof local_buffer), &
length,
1495 profile + (
sizeof profile_header), &
size, 0);
1503 &
png_ptr->colorspace, keyword, profile_length,
1509 size = profile_length - (
sizeof profile_header)
1513 (
sizeof local_buffer), &
length,
1514 profile + (
sizeof profile_header) +
1515 12 * tag_count, &
size, 1);
1519 errmsg =
"extra compressed data";
1530 "extra compressed data");
1536 # if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
1539 &
png_ptr->colorspace, profile,
1554 memcpy(
info_ptr->iccp_name, keyword,
1567 PNG_COLORSPACE_INVALID;
1568 errmsg =
"out of memory";
1587 errmsg =
png_ptr->zstream.msg;
1592 errmsg =
png_ptr->zstream.msg;
1596 errmsg =
"out of memory";
1606 errmsg =
png_ptr->zstream.msg;
1613 errmsg =
png_ptr->zstream.msg;
1617 errmsg =
"bad compression method";
1621 errmsg =
"bad keyword";
1625 errmsg =
"too many profiles";
1631 png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;
◆ png_handle_sPLT()
1654 #ifdef PNG_USER_LIMITS_SUPPORTED
1655 if (
png_ptr->user_chunk_cache_max != 0)
1657 if (
png_ptr->user_chunk_cache_max == 1)
1663 if (--
png_ptr->user_chunk_cache_max == 1)
1673 png_chunk_error(
png_ptr,
"missing IHDR");
1682 #ifdef PNG_MAX_MALLOC_64K
1711 for (entry_start = buffer; *entry_start; entry_start++)
1717 if (length < 2U || entry_start > buffer + (
length - 2U))
1723 new_palette.
depth = *entry_start++;
1724 entry_size = (new_palette.
depth == 8 ? 6 : 10);
1731 if ((data_length % (
unsigned int)entry_size) != 0)
1737 dl = (
png_uint_32)(data_length / (
unsigned int)entry_size);
1757 #ifdef PNG_POINTER_INDEXING_SUPPORTED
1762 if (new_palette.
depth == 8)
1764 pp->
red = *entry_start++;
1765 pp->
green = *entry_start++;
1766 pp->
blue = *entry_start++;
1767 pp->
alpha = *entry_start++;
1786 if (new_palette.
depth == 8)
1788 pp[
i].
red = *entry_start++;
1789 pp[
i].
green = *entry_start++;
1790 pp[
i].
blue = *entry_start++;
1791 pp[
i].
alpha = *entry_start++;
◆ png_handle_tRNS()
1824 png_chunk_error(
png_ptr,
"missing IHDR");
◆ png_handle_bKGD()
1923 unsigned int truelen;
1930 png_chunk_error(
png_ptr,
"missing IHDR");
1976 background.
index = buf[0];
1980 if (buf[0] >=
info_ptr->num_palette)
1992 background.
red = background.
green = background.
blue = 0;
1994 background.
gray = 0;
2001 if (buf[0] != 0 || buf[1] >= (
unsigned int)(1 <<
png_ptr->bit_depth))
2008 background.
index = 0;
2019 if (buf[0] != 0 || buf[2] != 0 || buf[4] != 0)
2026 background.
index = 0;
2030 background.
gray = 0;
◆ png_handle_eXIf()
2046 png_chunk_error(
png_ptr,
"missing IHDR");
2079 if (
i == 1 && buf[0] !=
'M' && buf[0] !=
'I'
2080 &&
info_ptr->eXIf_buf[0] != buf[0])
◆ png_handle_hIST()
2104 unsigned int num,
i;
2110 png_chunk_error(
png_ptr,
"missing IHDR");
2129 if (num != (
unsigned int)
png_ptr->num_palette ||
2137 for (
i = 0;
i < num;
i++)
◆ png_handle_pHYs()
2163 png_chunk_error(
png_ptr,
"missing IHDR");
◆ png_handle_oFFs()
2209 png_chunk_error(
png_ptr,
"missing IHDR");
◆ png_handle_pCAL()
2250 png_byte
type, nparams;
2258 png_chunk_error(
png_ptr,
"missing IHDR");
2274 png_debug1(2,
"Allocating and reading pCAL chunk data (%u bytes)",
2293 png_debug(3,
"Finding end of pCAL purpose string");
2294 for (buf = buffer; *buf; buf++)
2297 endptr = buffer +
length;
2302 if (endptr - buf <= 12)
2308 png_debug(3,
"Reading pCAL X0, X1, type, nparams, and units");
2315 png_debug(3,
"Checking pCAL equation type and number of parameters");
2333 for (buf = units; *buf; buf++)
2336 png_debug(3,
"Allocating pCAL parameters array");
2348 for (
i = 0;
i < nparams;
i++)
2354 for (params[
i] = (
png_charp)buf; buf <= endptr && *buf != 0; buf++)
◆ png_handle_sCAL()
2385 png_chunk_error(
png_ptr,
"missing IHDR");
2409 png_debug1(2,
"Allocating and reading sCAL chunk data (%u bytes)",
2428 if (buffer[0] != 1 && buffer[0] != 2)
◆ png_handle_tIME()
2477 png_chunk_error(
png_ptr,
"missing IHDR");
2501 mod_time.
second = buf[6];
2502 mod_time.
minute = buf[5];
2503 mod_time.
hour = buf[4];
2504 mod_time.
day = buf[3];
2505 mod_time.
month = buf[2];
◆ png_handle_tEXt()
2525 #ifdef PNG_USER_LIMITS_SUPPORTED
2526 if (
png_ptr->user_chunk_cache_max != 0)
2528 if (
png_ptr->user_chunk_cache_max == 1)
2534 if (--
png_ptr->user_chunk_cache_max == 1)
2544 png_chunk_error(
png_ptr,
"missing IHDR");
2549 #ifdef PNG_MAX_MALLOC_64K
2574 for (text = key; *text; text++)
2577 if (text != key +
length)
2581 text_info.
key = key;
2585 text_info.
text = text;
◆ png_handle_zTXt()
2604 #ifdef PNG_USER_LIMITS_SUPPORTED
2605 if (
png_ptr->user_chunk_cache_max != 0)
2607 if (
png_ptr->user_chunk_cache_max == 1)
2613 if (--
png_ptr->user_chunk_cache_max == 1)
2623 png_chunk_error(
png_ptr,
"missing IHDR");
2646 for (keyword_length = 0;
2647 keyword_length <
length && buffer[keyword_length] != 0;
2651 if (keyword_length > 79 || keyword_length < 1)
2652 errmsg =
"bad keyword";
2658 else if (keyword_length + 3 >
length)
2659 errmsg =
"truncated";
2662 errmsg =
"unknown compression type";
2678 errmsg=
"Read failure in png_handle_zTXt";
2685 buffer =
png_ptr->read_buffer;
2686 buffer[uncompressed_length+(keyword_length+2)] = 0;
2697 errmsg =
"insufficient memory";
2702 errmsg =
png_ptr->zstream.msg;
◆ png_handle_iTXt()
2721 #ifdef PNG_USER_LIMITS_SUPPORTED
2722 if (
png_ptr->user_chunk_cache_max != 0)
2724 if (
png_ptr->user_chunk_cache_max == 1)
2730 if (--
png_ptr->user_chunk_cache_max == 1)
2740 png_chunk_error(
png_ptr,
"missing IHDR");
2760 for (prefix_length=0;
2761 prefix_length <
length && buffer[prefix_length] != 0;
2766 if (prefix_length > 79 || prefix_length < 1)
2767 errmsg =
"bad keyword";
2773 else if (prefix_length + 5 >
length)
2774 errmsg =
"truncated";
2776 else if (buffer[prefix_length+1] == 0 ||
2777 (buffer[prefix_length+1] == 1 &&
2780 int compressed = buffer[prefix_length+1] != 0;
2781 png_uint_32 language_offset, translated_keyword_offset;
2786 language_offset = prefix_length;
2788 for (; prefix_length <
length && buffer[prefix_length] != 0;
2793 translated_keyword_offset = ++prefix_length;
2795 for (; prefix_length <
length && buffer[prefix_length] != 0;
2806 if (compressed == 0 && prefix_length <=
length)
2807 uncompressed_length =
length - prefix_length;
2809 else if (compressed != 0 && prefix_length <
length)
2819 buffer =
png_ptr->read_buffer;
2822 errmsg =
png_ptr->zstream.msg;
2826 errmsg =
"truncated";
2832 buffer[uncompressed_length+prefix_length] = 0;
2834 if (compressed == 0)
2848 errmsg =
"insufficient memory";
2853 errmsg =
"bad compression info";
◆ png_cache_unknown_chunk()
2873 # ifdef PNG_SET_USER_LIMITS_SUPPORTED
2874 if (
png_ptr->user_chunk_malloc_max > 0 &&
2875 png_ptr->user_chunk_malloc_max < limit)
2876 limit =
png_ptr->user_chunk_malloc_max;
2878 # elif PNG_USER_CHUNK_MALLOC_MAX > 0
◆ png_handle_unknown()
2929 #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
2941 # ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
2942 # ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
2951 # ifdef PNG_READ_USER_CHUNKS_SUPPORTED
2973 png_chunk_error(
png_ptr,
"error in user chunk");
2990 # ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
2995 "forcing save of an unhandled chunk;"
2996 " please call png_set_keep_unknown_chunks");
3020 # ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
3028 keep =
png_ptr->unknown_default;
3042 # ifndef PNG_READ_USER_CHUNKS_SUPPORTED
3043 # error no method to support READ_UNKNOWN_CHUNKS
3060 # ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
3068 # ifdef PNG_USER_LIMITS_SUPPORTED
3069 switch (
png_ptr->user_chunk_cache_max)
3072 png_ptr->user_chunk_cache_max = 1;
3082 --(
png_ptr->user_chunk_cache_max);
3092 # ifdef PNG_USER_LIMITS_SUPPORTED
3118 png_chunk_error(
png_ptr,
"unhandled critical chunk");
◆ png_check_chunk_name()
3139 png_debug(1,
"in png_check_chunk_name");
3141 for (
i=1;
i<=4; ++
i)
3145 if (c < 65 || c > 122 || (c > 90 && c < 97))
3146 png_chunk_error(
png_ptr,
"invalid chunk type");
◆ png_check_chunk_length()
3157 # ifdef PNG_SET_USER_LIMITS_SUPPORTED
3158 if (
png_ptr->user_chunk_malloc_max > 0 &&
3159 png_ptr->user_chunk_malloc_max < limit)
3160 limit =
png_ptr->user_chunk_malloc_max;
3161 # elif PNG_USER_CHUNK_MALLOC_MAX > 0
3171 * (
png_ptr->bit_depth > 8? 2: 1)
3173 + (
png_ptr->interlaced? 6: 0);
3177 idat_limit =
png_ptr->height * row_factor;
3178 row_factor = row_factor > 32566? 32566 : row_factor;
3179 idat_limit += 6 + 5*(idat_limit/row_factor+1);
3181 limit = limit < idat_limit? idat_limit : limit;
3187 (
unsigned long)
length,(
unsigned long)limit);
3188 png_chunk_error(
png_ptr,
"chunk data is too large");
◆ png_combine_row()
3202 unsigned int pixel_depth =
png_ptr->transformed_pixel_depth;
3205 unsigned int pass =
png_ptr->pass;
3207 png_byte end_byte = 0;
3208 unsigned int end_mask;
3215 if (pixel_depth == 0)
3234 end_mask = (pixel_depth * row_width) & 7;
3238 end_ptr = dp +
PNG_ROWBYTES(pixel_depth, row_width) - 1;
3239 end_byte = *end_ptr;
3240 # ifdef PNG_READ_PACKSWAP_SUPPORTED
3243 end_mask = (
unsigned int)(0xff << end_mask);
3247 end_mask = 0xff >> end_mask;
3257 #ifdef PNG_READ_INTERLACING_SUPPORTED
3258 if (
png_ptr->interlaced != 0 &&
3262 (
display == 1 && (pass & 1) != 0)))
3270 if (pixel_depth < 8)
3309 # if PNG_USE_COMPILE_TIME_MASKS
3310 # define PNG_LSR(x,s) ((x)>>((s) & 0x1f))
3311 # define PNG_LSL(x,s) ((x)<<((s) & 0x1f))
3313 # define PNG_LSR(x,s) ((x)>>(s))
3314 # define PNG_LSL(x,s) ((x)<<(s))
3316 # define S_COPY(p,x) (((p)<4 ? PNG_LSR(0x80088822,(3-(p))*8+(7-(x))) :\
3317 PNG_LSR(0xaa55ff00,(7-(p))*8+(7-(x)))) & 1)
3318 # define B_COPY(p,x) (((p)<4 ? PNG_LSR(0xff0fff33,(3-(p))*8+(7-(x))) :\
3319 PNG_LSR(0xff55ff00,(7-(p))*8+(7-(x)))) & 1)
3327 # define PIXEL_MASK(p,x,d,s) \
3328 (PNG_LSL(((PNG_LSL(1U,(d)))-1),(((x)*(d))^((s)?8-(d):0))))
3332 # define S_MASKx(p,x,d,s) (S_COPY(p,x)?PIXEL_MASK(p,x,d,s):0)
3333 # define B_MASKx(p,x,d,s) (B_COPY(p,x)?PIXEL_MASK(p,x,d,s):0)
3339 # define MASK_EXPAND(m,d) ((m)*((d)==1?0x01010101:((d)==2?0x00010001:1)))
3341 # define S_MASK(p,d,s) MASK_EXPAND(S_MASKx(p,0,d,s) + S_MASKx(p,1,d,s) +\
3342 S_MASKx(p,2,d,s) + S_MASKx(p,3,d,s) + S_MASKx(p,4,d,s) +\
3343 S_MASKx(p,5,d,s) + S_MASKx(p,6,d,s) + S_MASKx(p,7,d,s), d)
3345 # define B_MASK(p,d,s) MASK_EXPAND(B_MASKx(p,0,d,s) + B_MASKx(p,1,d,s) +\
3346 B_MASKx(p,2,d,s) + B_MASKx(p,3,d,s) + B_MASKx(p,4,d,s) +\
3347 B_MASKx(p,5,d,s) + B_MASKx(p,6,d,s) + B_MASKx(p,7,d,s), d)
3349 #if PNG_USE_COMPILE_TIME_MASKS
3355 # define S_MASKS(d,s) { S_MASK(0,d,s), S_MASK(1,d,s), S_MASK(2,d,s),\
3356 S_MASK(3,d,s), S_MASK(4,d,s), S_MASK(5,d,s) }
3358 # define B_MASKS(d,s) { B_MASK(1,d,s), B_MASK(3,d,s), B_MASK(5,d,s) }
3360 # define DEPTH_INDEX(d) ((d)==1?0:((d)==2?1:2))
3384 # define MASK(pass,depth,display,png)\
3385 ((display)?display_mask[png][DEPTH_INDEX(depth)][pass>>1]:\
3386 row_mask[png][DEPTH_INDEX(depth)][pass])
3392 # define MASK(pass,depth,display,png)\
3393 ((display)?B_MASK(pass,depth,png):S_MASK(pass,depth,png))
3404 # ifdef PNG_READ_PACKSWAP_SUPPORTED
3421 mask = (m >> 8) | (m << 24);
3427 *dp = (png_byte)((*dp & ~m) | (*sp & m));
3436 if (row_width <= pixels_per_byte)
3439 row_width -= pixels_per_byte;
3447 unsigned int bytes_to_copy, bytes_to_jump;
3450 if (pixel_depth & 7)
3454 row_width *= pixel_depth;
3463 row_width -= offset;
3475 bytes_to_copy = (1<<((6-pass)>>1)) * pixel_depth;
3478 if (bytes_to_copy > row_width)
3479 bytes_to_copy = (
unsigned int)row_width;
3483 bytes_to_copy = pixel_depth;
3496 switch (bytes_to_copy)
3503 if (row_width <= bytes_to_jump)
3506 dp += bytes_to_jump;
3507 sp += bytes_to_jump;
3508 row_width -= bytes_to_jump;
3517 dp[0] = sp[0]; dp[1] = sp[1];
3519 if (row_width <= bytes_to_jump)
3522 sp += bytes_to_jump;
3523 dp += bytes_to_jump;
3524 row_width -= bytes_to_jump;
3526 while (row_width > 1);
3538 dp[0] = sp[0]; dp[1] = sp[1]; dp[2] = sp[2];
3540 if (row_width <= bytes_to_jump)
3543 sp += bytes_to_jump;
3544 dp += bytes_to_jump;
3545 row_width -= bytes_to_jump;
3549 #if PNG_ALIGN_TYPE != PNG_ALIGN_NONE
3555 if (bytes_to_copy < 16 &&
3572 size_t skip = (bytes_to_jump-bytes_to_copy) /
3577 size_t c = bytes_to_copy;
3585 if (row_width <= bytes_to_jump)
3590 row_width -= bytes_to_jump;
3592 while (bytes_to_copy <= row_width);
3602 while (--row_width > 0);
3614 size_t skip = (bytes_to_jump-bytes_to_copy) /
3619 size_t c = bytes_to_copy;
3627 if (row_width <= bytes_to_jump)
3632 row_width -= bytes_to_jump;
3634 while (bytes_to_copy <= row_width);
3641 while (--row_width > 0);
3650 memcpy(dp, sp, bytes_to_copy);
3652 if (row_width <= bytes_to_jump)
3655 sp += bytes_to_jump;
3656 dp += bytes_to_jump;
3657 row_width -= bytes_to_jump;
3658 if (bytes_to_copy > row_width)
3659 bytes_to_copy = (
unsigned int)row_width;
3678 if (end_ptr !=
NULL)
3679 *end_ptr = (png_byte)((end_byte & end_mask) | (*end_ptr & ~end_mask));
◆ png_do_read_interlace()
3689 static const unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
3691 png_debug(1,
"in png_do_read_interlace");
3692 if (row !=
NULL && row_info !=
NULL)
3696 final_width = row_info->
width * png_pass_inc[pass];
3703 png_bytep dp = row + (size_t)((final_width - 1) >> 3);
3704 unsigned int sshift, dshift;
3705 unsigned int s_start, s_end;
3707 int jstop = (
int)png_pass_inc[pass];
3712 #ifdef PNG_READ_PACKSWAP_SUPPORTED
3715 sshift = ((row_info->
width + 7) & 0x07);
3716 dshift = ((final_width + 7) & 0x07);
3725 sshift = 7 - ((row_info->
width + 7) & 0x07);
3726 dshift = 7 - ((final_width + 7) & 0x07);
3732 for (
i = 0;
i < row_info->
width;
i++)
3734 v = (png_byte)((*sp >> sshift) & 0x01);
3735 for (j = 0; j < jstop; j++)
3737 unsigned int tmp = *dp & (0x7f7f >> (7 - dshift));
3738 tmp |= (
unsigned int)(v << dshift);
3739 *dp = (png_byte)(tmp & 0xff);
3741 if (dshift == s_end)
3748 dshift = (
unsigned int)((
int)dshift + s_inc);
3751 if (sshift == s_end)
3758 sshift = (
unsigned int)((
int)sshift + s_inc);
3767 unsigned int sshift, dshift;
3768 unsigned int s_start, s_end;
3770 int jstop = (
int)png_pass_inc[pass];
3773 #ifdef PNG_READ_PACKSWAP_SUPPORTED
3776 sshift = (((row_info->
width + 3) & 0x03) << 1);
3777 dshift = (((final_width + 3) & 0x03) << 1);
3786 sshift = ((3 - ((row_info->
width + 3) & 0x03)) << 1);
3787 dshift = ((3 - ((final_width + 3) & 0x03)) << 1);
3793 for (
i = 0;
i < row_info->
width;
i++)
3798 v = (png_byte)((*sp >> sshift) & 0x03);
3799 for (j = 0; j < jstop; j++)
3801 unsigned int tmp = *dp & (0x3f3f >> (6 - dshift));
3802 tmp |= (
unsigned int)(v << dshift);
3803 *dp = (png_byte)(tmp & 0xff);
3805 if (dshift == s_end)
3812 dshift = (
unsigned int)((
int)dshift + s_inc);
3815 if (sshift == s_end)
3822 sshift = (
unsigned int)((
int)sshift + s_inc);
3830 png_bytep dp = row + (size_t)((final_width - 1) >> 1);
3831 unsigned int sshift, dshift;
3832 unsigned int s_start, s_end;
3835 int jstop = (
int)png_pass_inc[pass];
3837 #ifdef PNG_READ_PACKSWAP_SUPPORTED
3840 sshift = (((row_info->
width + 1) & 0x01) << 2);
3841 dshift = (((final_width + 1) & 0x01) << 2);
3850 sshift = ((1 - ((row_info->
width + 1) & 0x01)) << 2);
3851 dshift = ((1 - ((final_width + 1) & 0x01)) << 2);
3857 for (
i = 0;
i < row_info->
width;
i++)
3859 png_byte v = (png_byte)((*sp >> sshift) & 0x0f);
3862 for (j = 0; j < jstop; j++)
3864 unsigned int tmp = *dp & (0xf0f >> (4 - dshift));
3865 tmp |= (
unsigned int)(v << dshift);
3866 *dp = (png_byte)(tmp & 0xff);
3868 if (dshift == s_end)
3875 dshift = (
unsigned int)((
int)dshift + s_inc);
3878 if (sshift == s_end)
3885 sshift = (
unsigned int)((
int)sshift + s_inc);
3892 size_t pixel_bytes = (row_info->
pixel_depth >> 3);
3897 png_bytep dp = row + (size_t)(final_width - 1) * pixel_bytes;
3899 int jstop = (
int)png_pass_inc[pass];
3902 for (
i = 0;
i < row_info->
width;
i++)
3907 memcpy(v, sp, pixel_bytes);
3909 for (j = 0; j < jstop; j++)
3911 memcpy(dp, v, pixel_bytes);
3921 row_info->
width = final_width;
3924 #ifndef PNG_READ_PACKSWAP_SUPPORTED
◆ png_read_filter_row_sub()
3936 unsigned int bpp = (row_info->
pixel_depth + 7) >> 3;
3941 for (
i = bpp;
i < istop;
i++)
3943 *rp = (png_byte)(((
int)(*rp) + (
int)(*(rp-bpp))) & 0xff);
◆ png_read_filter_row_up()
3957 for (
i = 0;
i < istop;
i++)
3959 *rp = (png_byte)(((
int)(*rp) + (
int)(*pp++)) & 0xff);
◆ png_read_filter_row_avg()
3971 unsigned int bpp = (row_info->
pixel_depth + 7) >> 3;
3972 size_t istop = row_info->
rowbytes - bpp;
3974 for (
i = 0;
i < bpp;
i++)
3976 *rp = (png_byte)(((
int)(*rp) +
3977 ((
int)(*pp++) / 2 )) & 0xff);
3982 for (
i = 0;
i < istop;
i++)
3984 *rp = (png_byte)(((
int)(*rp) +
3985 (
int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);
◆ png_read_filter_row_paeth_1byte_pixel()
4001 *row++ = (png_byte)
a;
4004 while (row < rp_end)
4006 int b, pa, pb, pc, p;
4019 pa = p < 0 ? -p : p;
4020 pb = pc < 0 ? -pc : pc;
4021 pc = (p + pc) < 0 ? -(p + pc) : p + pc;
4038 *row++ = (png_byte)
a;
◆ png_read_filter_row_paeth_multibyte_pixel()
4046 unsigned int bpp = (row_info->
pixel_depth + 7) >> 3;
4052 while (row < rp_end)
4054 int a = *row + *prev_row++;
4055 *row++ = (png_byte)
a;
4059 rp_end = rp_end + (row_info->
rowbytes - bpp);
4061 while (row < rp_end)
4063 int a,
b, c, pa, pb, pc, p;
4065 c = *(prev_row - bpp);
4077 pa = p < 0 ? -p : p;
4078 pb = pc < 0 ? -pc : pc;
4079 pc = (p + pc) < 0 ? -(p + pc) : p + pc;
4089 *row++ = (png_byte)
a;
◆ png_init_filter_functions()
4105 unsigned int bpp = (pp->pixel_depth + 7) >> 3;
4117 #ifdef PNG_FILTER_OPTIMIZATIONS
4126 PNG_FILTER_OPTIMIZATIONS(pp, bpp);
◆ png_read_filter_row()
4140 if (pp->read_filter[0] ==
NULL)
4143 pp->read_filter[filter-1](row_info, row, prev_row);
◆ png_read_IDAT_data()
4153 png_ptr->zstream.next_out = output;
4154 png_ptr->zstream.avail_out = 0;
4164 if (
png_ptr->zstream.avail_in == 0)
4169 while (
png_ptr->idat_size == 0)
4181 avail_in =
png_ptr->IDAT_read_size;
4183 if (avail_in >
png_ptr->idat_size)
4194 png_ptr->idat_size -= avail_in;
4196 png_ptr->zstream.next_in = buffer;
4197 png_ptr->zstream.avail_in = avail_in;
4205 if (out > avail_out)
4206 out = (
uInt)avail_out;
4209 png_ptr->zstream.avail_out = out;
4214 png_ptr->zstream.next_out = tmpbuf;
4215 png_ptr->zstream.avail_out = (
sizeof tmpbuf);
4229 avail_out +=
png_ptr->zstream.avail_out;
4232 avail_out += (
sizeof tmpbuf) -
png_ptr->zstream.avail_out;
4234 png_ptr->zstream.avail_out = 0;
4262 }
while (avail_out > 0);
◆ png_read_finish_IDAT()
4311 png_ptr->zstream.avail_in = 0;
◆ png_read_finish_row()
4331 static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
4334 static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
4337 static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
4340 static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
4364 png_pass_inc[
png_ptr->pass] - 1 -
4365 png_pass_start[
png_ptr->pass]) /
4371 png_pass_yinc[
png_ptr->pass] - 1 -
4372 png_pass_ystart[
png_ptr->pass]) /
◆ png_read_start_row()
4396 static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
4399 static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
4402 static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
4405 static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
4407 unsigned int max_pixel_depth;
4412 #ifdef PNG_READ_TRANSFORMS_SUPPORTED
4419 png_pass_ystart[0]) / png_pass_yinc[0];
4425 png_pass_inc[
png_ptr->pass] - 1 -
4426 png_pass_start[
png_ptr->pass]) /
4436 max_pixel_depth = (
unsigned int)
png_ptr->pixel_depth;
4450 max_pixel_depth = 8;
4453 #ifdef PNG_READ_EXPAND_SUPPORTED
4459 max_pixel_depth = 32;
4462 max_pixel_depth = 24;
4467 if (max_pixel_depth < 8)
4468 max_pixel_depth = 8;
4471 max_pixel_depth *= 2;
4478 max_pixel_depth *= 4;
4479 max_pixel_depth /= 3;
4485 #ifdef PNG_READ_EXPAND_16_SUPPORTED
4488 # ifdef PNG_READ_EXPAND_SUPPORTED
4495 max_pixel_depth *= 2;
4503 #ifdef PNG_READ_FILLER_SUPPORTED
4508 if (max_pixel_depth <= 8)
4509 max_pixel_depth = 16;
4512 max_pixel_depth = 32;
4518 if (max_pixel_depth <= 32)
4519 max_pixel_depth = 32;
4522 max_pixel_depth = 64;
4527 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
4540 if (max_pixel_depth <= 16)
4541 max_pixel_depth = 32;
4544 max_pixel_depth = 64;
4549 if (max_pixel_depth <= 8)
4552 max_pixel_depth = 32;
4555 max_pixel_depth = 24;
4559 max_pixel_depth = 64;
4562 max_pixel_depth = 48;
4567 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \
4568 defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
4571 unsigned int user_pixel_depth =
png_ptr->user_transform_depth *
4572 png_ptr->user_transform_channels;
4574 if (user_pixel_depth > max_pixel_depth)
4575 max_pixel_depth = user_pixel_depth;
4582 png_ptr->maximum_pixel_depth = (png_byte)max_pixel_depth;
4583 png_ptr->transformed_pixel_depth = 0;
4593 1 + ((max_pixel_depth + 7) >> 3U);
4595 #ifdef PNG_MAX_MALLOC_64K
4600 if (row_bytes + 48 >
png_ptr->old_big_row_buf_size)
4614 #ifdef PNG_ALIGNED_MEMORY_SUPPORTED
4625 png_ptr->row_buf = temp - extra - 1;
4627 temp =
png_ptr->big_prev_row + 32;
4629 png_ptr->prev_row = temp - extra - 1;
4637 png_ptr->old_big_row_buf_size = row_bytes + 48;
4640 #ifdef PNG_MAX_MALLOC_64K
4641 if (
png_ptr->rowbytes > 65535)
4666 png_ptr->read_buffer_size = 0;
#define Z_MEM_ERROR
Definition: zlib.h:183
Byte FAR Bytef
Definition: zconf.h:400
void PNGAPI png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color)
Definition: pngset.c:994
int ZEXPORT inflateValidate(z_streamp strm, int check)
Definition: inflate.c:1526
void png_read_finish_IDAT(png_structrp png_ptr)
Definition: pngrutil.c:4278
png_uint_32 crc
Definition: png.c:2247
const typedef png_byte * png_const_bytep
Definition: pngconf.h:580
#define PNG_CHUNK_ANCILLARY(c)
Definition: pngpriv.h:897
#define PNG_AFTER_IDAT
Definition: png.h:646
#define B_MASKx(p, x, d, s)
#define PNG_TEXT_COMPRESSION_zTXt
Definition: png.h:589
png_uint_32(PNGAPI png_get_uint_32)(png_const_bytep buf)
Definition: pngrutil.c:67
#define PNG_EXPAND
Definition: pngpriv.h:654
#define PNG_UNUSED(param)
Definition: pngpriv.h:438
#define MASK_EXPAND(m, d)
#define PNG_HANDLE_CHUNK_IF_SAFE
Definition: png.h:2347
static int png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish, png_const_bytep input, png_uint_32p input_size_ptr, png_bytep output, png_alloc_size_t *output_size_ptr)
Definition: pngrutil.c:485
png_byte second
Definition: png.h:607
#define PNG_INFO_tIME
Definition: png.h:741
png_uint_16 blue
Definition: png.h:493
#define PNG_UINT_31_MAX
Definition: png.h:649
offset_y
Definition: g29_auto.py:163
#define PNG_HAVE_PLTE
Definition: png.h:645
#define PNG_READ_PACK_SUPPORTED
Definition: pnglibconf.h:69
#define PNG_IO_READING
Definition: png.h:2423
#define PNG_INFO_tRNS
Definition: png.h:736
void PNGAPI png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_const_colorp palette, int num_palette)
Definition: pngset.c:572
void PNGAPI png_set_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)
Definition: pngset.c:1200
static int png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size, png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size, int finish)
Definition: pngrutil.c:774
#define PNG_OPTION_ON
Definition: png.h:3217
static void png_init_filter_functions(png_structrp pp)
Definition: pngrutil.c:4094
#define PNG_FIXED_ERROR
Definition: pngrutil.c:38
void PNGAPI png_free(png_const_structrp png_ptr, png_voidp ptr)
Definition: pngmem.c:232
static int png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)
Definition: pngrutil.c:2863
struct png_sPLT_entry_struct png_sPLT_entry
#define PNG_INFO_pCAL
Definition: png.h:742
static void png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row, png_const_bytep prev_row)
Definition: pngrutil.c:4043
#define PNG_INFO_oFFs
Definition: png.h:740
#define png_aligncastconst(type, value)
Definition: pngpriv.h:506
char * png_charp
Definition: pngconf.h:589
#define PNG_IO_CHUNK_CRC
Definition: png.h:2428
#define PNG_UNEXPECTED_ZLIB_RETURN
Definition: pngpriv.h:973
void png_init_read_transformations(png_structrp png_ptr)
Definition: pngrtran.c:1291
#define PNG_GRAY_TO_RGB
Definition: pngpriv.h:656
static void png_read_filter_row_up(png_row_infop row_info, png_bytep row, png_const_bytep prev_row)
Definition: pngrutil.c:3949
png_uint_16 frequency
Definition: png.h:522
#define PNG_EQUATION_HYPERBOLIC
Definition: png.h:700
png_sPLT_entryp entries
Definition: png.h:537
uint8_t type
Definition: UsbCore.h:184
#define Z_FINISH
Definition: zlib.h:172
#define abs(x)
Definition: wiring_constants.h:32
#define PNG_FLAG_ROW_INIT
Definition: pngpriv.h:685
#define Z_STREAM_ERROR
Definition: zlib.h:181
#define PNG_FP_IS_POSITIVE(state)
Definition: pngpriv.h:1939
#define PNG_EQUATION_LAST
Definition: png.h:701
png_charp name
Definition: png.h:535
png_uint_32 PNGAPI png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf)
Definition: pngrutil.c:22
#define PNG_UINT_32_MAX
Definition: png.h:650
png_uint_16 gray
Definition: png.h:494
png_byte * png_bytep
Definition: pngconf.h:579
uint8_t i
Definition: screen_test_graph.c:72
int png_crc_error(png_structrp png_ptr)
Definition: pngrutil.c:251
static void png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row, png_const_bytep prev_row)
Definition: pngrutil.c:3992
static volatile fsensor_t state
Definition: filament_sensor.c:23
#define PNG_READ_FILLER_SUPPORTED
Definition: pnglibconf.h:59
void PNGAPI png_set_sBIT(png_const_structrp png_ptr, png_inforp info_ptr, png_const_color_8p sig_bit)
Definition: pngset.c:638
#define PNG_COLOR_TYPE_RGB_ALPHA
Definition: png.h:671
void png_check_chunk_name(png_const_structrp png_ptr, png_uint_32 chunk_name)
Definition: pngrutil.c:3134
png_const_structrp png_const_inforp int png_fixed_point * width
Definition: png.h:2161
#define PNG_CHUNK_CRITICAL(c)
Definition: pngpriv.h:898
#define PNG_FLAG_CRC_CRITICAL_IGNORE
Definition: pngpriv.h:690
#define PNG_READ_EXPAND_SUPPORTED
Definition: pnglibconf.h:58
#define png_debug2(l, m, p1, p2)
Definition: pngdebug.h:151
#define PNG_SIZE_MAX
Definition: png.h:651
#define png_iCCP
Definition: pngpriv.h:861
#define inflateInit(strm)
Definition: zlib.h:1795
void PNGAPI png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_const_charp units, png_charpp params)
Definition: pngset.c:312
#define png_voidcast(type, value)
Definition: pngpriv.h:494
#define PNG_IO_SIGNATURE
Definition: png.h:2425
#define NULL
Definition: usbd_def.h:53
png_uint_32 width
Definition: png.h:756
png_sPLT_entry * png_sPLT_entryp
Definition: png.h:524
png_structrp png_ptr
Definition: png.h:1083
int png_check_fp_number(png_const_charp string, size_t size, int *statep, png_size_tp whereami)
Definition: png.c:2712
#define PNG_COLOR_TYPE_RGB
Definition: png.h:670
png_const_structrp png_const_inforp info_ptr
Definition: png.h:1939
int ZEXPORT inflateReset2(z_streamp strm, int windowBits)
Definition: inflate.c:157
size_t text_length
Definition: png.h:572
png_uint_16 year
Definition: png.h:602
static png_bytep png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn)
Definition: pngrutil.c:298
png_byte month
Definition: png.h:603
#define PNG_INFO_bKGD
Definition: png.h:737
unsigned int png_uint_32
Definition: pngconf.h:511
#define png_aligncast(type, value)
Definition: pngpriv.h:505
#define PNG_INFO_eXIf
Definition: png.h:748
#define PNG_TEXT_COMPRESSION_NONE
Definition: png.h:588
#define PNG_EQUATION_ARBITRARY
Definition: png.h:699
#define inflateInit2(strm, windowBits)
Definition: zlib.h:1800
png_uint_16(PNGAPI png_get_uint_16)(png_const_bytep buf)
Definition: pngrutil.c:102
#define PNG_FREE_EXIF
Definition: png.h:1761
#define PNG_MAX_PALETTE_LENGTH
Definition: png.h:725
const typedef png_uint_16 * png_const_uint_16p
Definition: pngconf.h:586
unsigned char Byte
Definition: zconf.h:391
#define PNG_HAVE_IHDR
Definition: png.h:644
#define PNG_USER_CHUNK_MALLOC_MAX
Definition: pnglibconf.h:208
#define PNG_PACKSWAP
Definition: pngpriv.h:658
#define PNG_EQUATION_LINEAR
Definition: png.h:697
void PNGAPI png_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr, png_const_uint_16p hist)
Definition: pngset.c:210
#define PNG_HAVE_IDAT
Definition: pngpriv.h:626
#define PNG_FLAG_CRC_ANCILLARY_USE
Definition: pngpriv.h:687
#define Z_NO_FLUSH
Definition: zlib.h:168
#define PNG_FREE_ICCP
Definition: png.h:1749
void PNGAPI png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:497
#define PNG_ITXT_COMPRESSION_zTXt
Definition: png.h:591
#define PNG_PASS_START_COL(pass)
Definition: png.h:2444
#define PNGZ_MSG_CAST(s)
Definition: pngstruct.h:40
void png_crc_read(png_structrp png_ptr, png_bytep buf, png_uint_32 length)
Definition: pngrutil.c:196
void png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, size_t length)
Definition: png.c:139
png_uint_16 green
Definition: png.h:492
#define ZLIB_IO_MAX
Definition: pngstruct.h:56
#define PNG_COLOR_TYPE_GRAY
Definition: png.h:668
#define PNG_HANDLE_CHUNK_ALWAYS
Definition: png.h:2348
#define PNG_HANDLE_CHUNK_NEVER
Definition: png.h:2346
png_byte blue
Definition: png.h:482
static void png_read_filter_row_sub(png_row_infop row_info, png_bytep row, png_const_bytep prev_row)
Definition: pngrutil.c:3931
png_charp key
Definition: png.h:569
png_charp text
Definition: png.h:570
#define png_debug(l, m)
Definition: pngdebug.h:145
void PNGAPI png_set_IHDR(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_type, int compression_type, int filter_type)
Definition: pngset.c:254
png_byte green
Definition: png.h:481
png_uint_16 alpha
Definition: png.h:521
void PNGAPI png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, int num)
Definition: png.c:471
#define PNG_ITXT_COMPRESSION_NONE
Definition: png.h:590
#define PNG_INTERLACE
Definition: pngpriv.h:643
#define PNG_CHUNK_FROM_STRING(s)
Definition: pngpriv.h:879
void png_icc_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, png_const_bytep profile, uLong adler)
Definition: png.c:2428
#define png_IDAT
Definition: pngpriv.h:848
#define PNG_FILLER
Definition: pngpriv.h:657
void
Definition: png.h:1083
#define png_get_uint_16(buf)
Definition: png.h:2599
png_int_32 png_fixed_point
Definition: pngconf.h:574
void png_read_IDAT_data(png_structrp png_ptr, png_bytep output, png_alloc_size_t avail_out)
Definition: pngrutil.c:4149
const typedef char * png_const_charp
Definition: pngconf.h:590
#define PNG_COMPRESSION_TYPE_BASE
Definition: png.h:678
#define Z_OK
Definition: zlib.h:177
#define PNG_FILTER_VALUE_NONE
Definition: png.h:1476
#define Z_SYNC_FLUSH
Definition: zlib.h:170
int png_colorspace_set_chromaticities(png_const_structrp png_ptr, png_colorspacerp colorspace, const png_xy *xy, int preferred)
Definition: png.c:1720
static void png_read_filter_row_avg(png_row_infop row_info, png_bytep row, png_const_bytep prev_row)
Definition: pngrutil.c:3965
#define PNG_FILTER_VALUE_LAST
Definition: png.h:1481
void PNGAPI png_set_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, png_const_color_16p background)
Definition: pngset.c:25
#define PNG_INFO_sCAL
Definition: png.h:746
size_t itxt_length
Definition: png.h:573
#define PNG_FILTER_VALUE_AVG
Definition: png.h:1479
#define PNG_HANDLE_CHUNK_AS_DEFAULT
Definition: png.h:2345
if(size<=((png_alloc_size_t) -1) - ob)
Definition: pngwrite.c:2176
list a
Definition: createSpeedLookupTable.py:29
#define PNG_FILTER_VALUE_PAETH
Definition: png.h:1480
#define L(CODE)
Definition: macros.h:76
#define PNG_HAVE_IEND
Definition: pngpriv.h:628
void png_zstream_error(png_structrp png_ptr, int ret)
Definition: png.c:998
#define png_get_uint_32(buf)
Definition: png.h:2598
#define PNG_MAXIMUM_INFLATE_WINDOW
Definition: png.h:3202
png_charp lang_key
Definition: png.h:576
void PNGAPI png_set_eXIf_1(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 num_exif, png_bytep eXIf_buf)
Definition: pngset.c:148
png_byte depth
Definition: png.h:536
#define PNG_FILTER_VALUE_UP
Definition: png.h:1478
#define Z_STREAM_END
Definition: zlib.h:178
png_byte pixel_depth
Definition: png.h:761
png_uint_16 green
Definition: png.h:519
void png_reset_crc(png_structrp png_ptr)
Definition: png.c:127
png_uint_32 * png_uint_32p
Definition: pngconf.h:581
#define PNG_PASS_COL_OFFSET(pass)
Definition: png.h:2452
void png_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr)
Definition: png.c:1215
#define PNG_IO_CHUNK_DATA
Definition: png.h:2427
#define MASK(pass, depth, display, png)
void PNGAPI png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_const_charp swidth, png_const_charp sheight)
Definition: pngset.c:430
int png_crc_finish(png_structrp png_ptr, png_uint_32 skip)
Definition: pngrutil.c:211
char ** png_charpp
Definition: pngconf.h:612
int png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, png_const_charp name, png_uint_32 profile_length, png_const_bytep profile, int color_type)
Definition: png.c:2014
int png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace, png_const_charp name, png_uint_32 profile_length)
Definition: png.c:1981
display_t * display
Definition: display.c:6
static png_fixed_point png_get_fixed_point(png_structrp png_ptr, png_const_bytep buf)
Definition: pngrutil.c:41
static int png_decompress_chunk(png_structrp png_ptr, png_uint_32 chunklength, png_uint_32 prefix_size, png_alloc_size_t *newlength, int terminate)
Definition: pngrutil.c:610
#define PNG_FLAG_CRC_CRITICAL_USE
Definition: pngpriv.h:689
#define PNG_INFO_pHYs
Definition: png.h:739
#define PNG_FILTER_VALUE_SUB
Definition: png.h:1477
const typedef png_uint_32 * png_const_uint_32p
Definition: pngconf.h:582
png_int_32 nentries
Definition: png.h:538
png_uint_16 blue
Definition: png.h:520
else png_error(png_ptr, "png_image_write_to_memory: PNG too big")
#define PNG_INFLATE(pp, flush)
Definition: pngpriv.h:1398
png_uint_16 * png_uint_16p
Definition: pngconf.h:585
#define png_debug1(l, m, p1)
Definition: pngdebug.h:148
#define S_MASKx(p, x, d, s)
#define PNG_FLAG_ZSTREAM_INITIALIZED
Definition: pngpriv.h:680
void PNGAPI png_set_pHYs(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)
Definition: pngset.c:556
#define PNG_FLAG_BENIGN_ERRORS_WARN
Definition: pngpriv.h:699
size_t png_alloc_size_t
Definition: pngconf.h:557
#define PNG_FLAG_CRC_ANCILLARY_NOWARN
Definition: pngpriv.h:688
png_byte minute
Definition: png.h:606
png_byte index
Definition: png.h:490
#define PNG_ROWBYTES(pixel_bits, width)
Definition: pngpriv.h:738
png_uint_16 red
Definition: png.h:518
#define PNG_COLOR_MASK_COLOR
Definition: png.h:664
void PNGAPI png_set_oFFs(png_const_structrp png_ptr, png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y, int unit_type)
Definition: pngset.c:295
#define PNG_HAVE_PNG_SIGNATURE
Definition: pngpriv.h:636
#define PNG_CSTRING_FROM_CHUNK(s, c)
Definition: pngpriv.h:893
png_byte red
Definition: png.h:480
int
Definition: createSpeedLookupTable.py:15
int png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace, png_const_charp name, png_uint_32 profile_length, png_const_bytep profile)
Definition: png.c:2197
#define PNG_FLAG_ZSTREAM_ENDED
Definition: pngpriv.h:682
#define PNG_PACK
Definition: pngpriv.h:644
void png_read_data(png_structrp png_ptr, png_bytep data, size_t length)
Definition: pngrio.c:32
#define PNG_FLAG_CRC_ANCILLARY_MASK
Definition: pngpriv.h:711
#define PNG_INFO_sBIT
Definition: png.h:733
int png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, int intent)
Definition: png.c:1872
#define png_get_int_32(buf)
Definition: png.h:2600
void PNGAPI png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:514
#define png_isaligned(ptr, type)
Definition: pngpriv.h:605
unsigned int uInt
Definition: zconf.h:393
size_t png_safecat(png_charp buffer, size_t bufsize, size_t pos, png_const_charp string)
Definition: pngerror.c:112
png_uint_32 length
Definition: png.c:2247
#define PNG_EQUATION_BASE_E
Definition: png.h:698
#define PNG_INFO_hIST
Definition: png.h:738
png_uint_32 png_read_chunk_header(png_structrp png_ptr)
Definition: pngrutil.c:156
png_byte day
Definition: png.h:604
void png_check_chunk_length(png_const_structrp png_ptr, png_uint_32 length)
Definition: pngrutil.c:3153
int png_chunk_unknown_handling(png_const_structrp png_ptr, png_uint_32 chunk_name)
Definition: png.c:961
png_charp lang
Definition: png.h:574
void png_app_warning(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:392
size_t rowbytes
Definition: png.h:757
void png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:405
#define PNG_INFO_iCCP
Definition: png.h:744
list b
Definition: createSpeedLookupTable.py:30
static int png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
Definition: pngrutil.c:342
#define PNGZ_INPUT_CAST(b)
Definition: pngstruct.h:41
#define PNG_COLOR_TYPE_GRAY_ALPHA
Definition: png.h:672
#define PNG_INFLATE_BUF_SIZE
Definition: pnglibconf.h:196
png_uint_16 red
Definition: png.h:491
png_byte hour
Definition: png.h:605
int ZEXPORT inflateReset(z_streamp strm)
Definition: inflate.c:144
int png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, png_const_textp text_ptr, int num_text)
Definition: pngset.c:773
void PNGAPI png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
png_int_32(PNGAPI png_get_int_32)(png_const_bytep buf)
Definition: pngrutil.c:84
#define PNG_EXPAND_16
Definition: pngpriv.h:651
int compression
Definition: png.h:564
void PNGAPI png_set_sPLT(png_const_structrp png_ptr, png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)
Definition: pngset.c:1062
#define PNG_STRING_FROM_CHUNK(s, c)
Definition: pngpriv.h:886
void PNGAPI png_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr, png_const_timep mod_time)
Definition: pngset.c:968
int PNGAPI png_sig_cmp(png_const_bytep sig, size_t start, size_t num_to_check)
Definition: png.c:74
#define PNG_COLOR_TYPE_PALETTE
Definition: png.h:669
#define PNG_USER_TRANSFORM
Definition: pngpriv.h:662
offset_x
Definition: g29_auto.py:158
static png_bytep size_t size
Definition: pngwrite.c:2170
void png_colorspace_set_gamma(png_const_structrp png_ptr, png_colorspacerp colorspace, png_fixed_point gAMA)
Definition: png.c:1114
#define PNG_IO_CHUNK_HDR
Definition: png.h:2426
png_uint_16 intent
Definition: png.c:2251
#define PNG_IGNORE_ADLER32
Definition: png.h:3207