43 size_t block_len = buf_len % 5552;
48 for (
i = 0;
i + 7 < block_len;
i += 8, ptr += 8)
50 s1 += ptr[0], s2 += s1;
51 s1 += ptr[1], s2 += s1;
52 s1 += ptr[2], s2 += s1;
53 s1 += ptr[3], s2 += s1;
54 s1 += ptr[4], s2 += s1;
55 s1 += ptr[5], s2 += s1;
56 s1 += ptr[6], s2 += s1;
57 s1 += ptr[7], s2 += s1;
59 for (;
i < block_len; ++
i)
60 s1 += *ptr++, s2 += s1;
61 s1 %= 65521U, s2 %= 65521U;
65 return (s2 << 16) + s1;
72 static const mz_uint32 s_crc32[16] = { 0, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
73 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c };
81 crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (
b & 0xF)];
82 crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (
b >> 4)];
86 #elif defined(USE_EXTERNAL_MZCRC)
99 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535,
100 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD,
101 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D,
102 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
103 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4,
104 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C,
105 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC,
106 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
107 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB,
108 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F,
109 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB,
110 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
111 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA,
112 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE,
113 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A,
114 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
115 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409,
116 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81,
117 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739,
118 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
119 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268,
120 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0,
121 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8,
122 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
123 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF,
124 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703,
125 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7,
126 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
127 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE,
128 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242,
129 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6,
130 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
131 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D,
132 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5,
133 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605,
134 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
135 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
169 (void)opaque, (
void)items, (void)
size;
174 (void)opaque, (
void)address;
179 (void)opaque, (
void)address, (void)items, (
void)
size;
188 #ifndef MINIZ_NO_ZLIB_APIS
220 pStream->
state = (
struct mz_internal_state *)pComp;
233 if ((!pStream) || (!pStream->
state) || (!pStream->
zalloc) || (!pStream->
zfree))
242 size_t in_bytes, out_bytes;
243 mz_ulong orig_total_in, orig_total_out;
244 int mz_status =
MZ_OK;
289 if ((flush) || (pStream->
total_in != orig_total_in) || (pStream->
total_out != orig_total_out))
314 return MZ_MAX(128 + (source_len * 110) / 100, 128 + source_len + ((source_len / (31 * 1024)) + 1) * 5);
321 memset(&stream, 0,
sizeof(stream));
324 if ((source_len | *pDest_len) > 0xFFFFFFFFU)
360 mz_uint m_dict_ofs, m_dict_avail, m_first_call, m_has_flushed;
389 pStream->
state = (
struct mz_internal_state *)pDecomp;
392 pDecomp->m_dict_ofs = 0;
393 pDecomp->m_dict_avail = 0;
395 pDecomp->m_first_call = 1;
396 pDecomp->m_has_flushed = 0;
397 pDecomp->m_window_bits = window_bits;
423 pDecomp->m_dict_ofs = 0;
424 pDecomp->m_dict_avail = 0;
426 pDecomp->m_first_call = 1;
427 pDecomp->m_has_flushed = 0;
437 size_t in_bytes, out_bytes, orig_avail_in;
440 if ((!pStream) || (!pStream->
state))
448 if (pState->m_window_bits > 0)
452 first_call = pState->m_first_call;
453 pState->m_first_call = 0;
454 if (pState->m_last_status < 0)
457 if (pState->m_has_flushed && (flush !=
MZ_FINISH))
459 pState->m_has_flushed |= (flush ==
MZ_FINISH);
461 if ((flush ==
MZ_FINISH) && (first_call))
468 pState->m_last_status = status;
490 if (pState->m_dict_avail)
493 memcpy(pStream->
next_out, pState->m_dict + pState->m_dict_ofs,
n);
497 pState->m_dict_avail -=
n;
507 status =
tinfl_decompress(&pState->m_decomp, pStream->
next_in, &in_bytes, pState->m_dict, pState->m_dict + pState->m_dict_ofs, &out_bytes, decomp_flags);
508 pState->m_last_status = status;
515 pState->m_dict_avail = (
mz_uint)out_bytes;
518 memcpy(pStream->
next_out, pState->m_dict + pState->m_dict_ofs,
n);
522 pState->m_dict_avail -=
n;
560 memset(&stream, 0,
sizeof(stream));
563 if ((*pSource_len | *pDest_len) > 0xFFFFFFFFU)
576 *pSource_len = *pSource_len - stream.
avail_in;
600 {
MZ_OK,
"" }, {
MZ_STREAM_END,
"stream end" }, {
MZ_NEED_DICT,
"need dictionary" }, {
MZ_ERRNO,
"file error" }, {
MZ_STREAM_ERROR,
"stream error" }, {
MZ_DATA_ERROR,
"data error" }, {
MZ_MEM_ERROR,
"out of memory" }, {
MZ_BUF_ERROR,
"buf error" }, {
MZ_VERSION_ERROR,
"version error" }, {
MZ_PARAM_ERROR,
"parameter error" }
603 for (
i = 0;
i <
sizeof(s_error_descs) /
sizeof(s_error_descs[0]); ++
i)
604 if (s_error_descs[
i].m_err == err)
605 return s_error_descs[
i].m_pDesc;
678 257, 258, 259, 260, 261, 262, 263, 264, 265, 265, 266, 266, 267, 267, 268, 268, 269, 269, 269, 269, 270, 270, 270, 270, 271, 271, 271, 271, 272, 272, 272, 272,
679 273, 273, 273, 273, 273, 273, 273, 273, 274, 274, 274, 274, 274, 274, 274, 274, 275, 275, 275, 275, 275, 275, 275, 275, 276, 276, 276, 276, 276, 276, 276, 276,
680 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
681 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280,
682 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281,
683 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282,
684 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283,
685 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 285
690 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
691 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
692 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
693 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0
698 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11,
699 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13,
700 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
701 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
702 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
703 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
704 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
705 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
706 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
707 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
708 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
709 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17
714 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
715 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
716 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
717 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
718 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
719 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
720 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
721 7, 7, 7, 7, 7, 7, 7, 7
726 0, 0, 18, 19, 20, 20, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
727 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
728 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
733 0, 0, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
734 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
735 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13
745 mz_uint32 total_passes = 2, pass_shift, pass,
i, hist[256 * 2];
748 for (
i = 0;
i < num_syms;
i++)
752 hist[256 + ((freq >> 8) & 0xFF)]++;
754 while ((total_passes > 1) && (num_syms == hist[(total_passes - 1) * 256]))
756 for (pass_shift = 0, pass = 0; pass < total_passes; pass++, pass_shift += 8)
758 const mz_uint32 *pHist = &hist[pass << 8];
760 for (
i = 0;
i < 256;
i++)
765 for (
i = 0;
i < num_syms;
i++)
766 pNew_syms[
offsets[(pCur_syms[
i].m_key >> pass_shift) & 0xFF]++] = pCur_syms[
i];
769 pCur_syms = pNew_syms;
779 int root,
leaf,
next, avbl, used, dpth;
787 A[0].m_key +=
A[1].m_key;
794 A[
next].m_key =
A[root].m_key;
816 while (root >= 0 && (
int)
A[root].m_key == dpth)
841 if (code_list_len <= 1)
844 pNum_codes[max_code_size] += pNum_codes[
i];
845 for (
i = max_code_size;
i > 0;
i--)
846 total += (((
mz_uint32)pNum_codes[
i]) << (max_code_size -
i));
847 while (total != (1UL << max_code_size))
849 pNum_codes[max_code_size]--;
850 for (
i = max_code_size - 1;
i > 0;
i--)
854 pNum_codes[
i + 1] += 2;
868 for (
i = 0;
i < table_len;
i++)
874 int num_used_syms = 0;
876 for (
i = 0;
i < table_len;
i++)
886 for (
i = 0;
i < num_used_syms;
i++)
887 num_codes[pSyms[
i].m_key]++;
893 for (
i = 1, j = num_used_syms;
i <= code_size_limit;
i++)
894 for (
l = num_codes[
i];
l > 0;
l--)
899 for (j = 0,
i = 2;
i <= code_size_limit;
i++)
900 next_code[
i] = j = ((j + num_codes[
i - 1]) << 1);
902 for (
i = 0;
i < table_len;
i++)
907 code = next_code[code_size]++;
908 for (
l = code_size;
l > 0;
l--,
code >>= 1)
909 rev_code = (rev_code << 1) | (
code & 1);
914 #define TDEFL_PUT_BITS(b, l) \
919 MZ_ASSERT(bits <= ((1U << len) - 1U)); \
920 d->m_bit_buffer |= (bits << d->m_bits_in); \
921 d->m_bits_in += len; \
922 while (d->m_bits_in >= 8) \
924 if (d->m_pOutput_buf < d->m_pOutput_buf_end) \
925 *d->m_pOutput_buf++ = (mz_uint8)(d->m_bit_buffer); \
926 d->m_bit_buffer >>= 8; \
932 #define TDEFL_RLE_PREV_CODE_SIZE() \
934 if (rle_repeat_count) \
936 if (rle_repeat_count < 3) \
938 d->m_huff_count[2][prev_code_size] = (mz_uint16)(d->m_huff_count[2][prev_code_size] + rle_repeat_count); \
939 while (rle_repeat_count--) \
940 packed_code_sizes[num_packed_code_sizes++] = prev_code_size; \
944 d->m_huff_count[2][16] = (mz_uint16)(d->m_huff_count[2][16] + 1); \
945 packed_code_sizes[num_packed_code_sizes++] = 16; \
946 packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_repeat_count - 3); \
948 rle_repeat_count = 0; \
952 #define TDEFL_RLE_ZERO_CODE_SIZE() \
956 if (rle_z_count < 3) \
958 d->m_huff_count[2][0] = (mz_uint16)(d->m_huff_count[2][0] + rle_z_count); \
959 while (rle_z_count--) \
960 packed_code_sizes[num_packed_code_sizes++] = 0; \
962 else if (rle_z_count <= 10) \
964 d->m_huff_count[2][17] = (mz_uint16)(d->m_huff_count[2][17] + 1); \
965 packed_code_sizes[num_packed_code_sizes++] = 17; \
966 packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 3); \
970 d->m_huff_count[2][18] = (mz_uint16)(d->m_huff_count[2][18] + 1); \
971 packed_code_sizes[num_packed_code_sizes++] = 18; \
972 packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 11); \
978 static mz_uint8 s_tdefl_packed_code_size_syms_swizzle[] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
982 int num_lit_codes, num_dist_codes, num_bit_lengths;
983 mz_uint i, total_code_sizes_to_pack, num_packed_code_sizes, rle_z_count, rle_repeat_count, packed_code_sizes_index;
991 for (num_lit_codes = 286; num_lit_codes > 257; num_lit_codes--)
994 for (num_dist_codes = 30; num_dist_codes > 1; num_dist_codes--)
999 memcpy(code_sizes_to_pack + num_lit_codes, &d->
m_huff_code_sizes[1][0], num_dist_codes);
1000 total_code_sizes_to_pack = num_lit_codes + num_dist_codes;
1001 num_packed_code_sizes = 0;
1003 rle_repeat_count = 0;
1006 for (
i = 0;
i < total_code_sizes_to_pack;
i++)
1008 mz_uint8 code_size = code_sizes_to_pack[
i];
1012 if (++rle_z_count == 138)
1020 if (code_size != prev_code_size)
1024 packed_code_sizes[num_packed_code_sizes++] = code_size;
1026 else if (++rle_repeat_count == 6)
1031 prev_code_size = code_size;
1033 if (rle_repeat_count)
1049 for (num_bit_lengths = 18; num_bit_lengths >= 0; num_bit_lengths--)
1052 num_bit_lengths =
MZ_MAX(4, (num_bit_lengths + 1));
1054 for (
i = 0; (
int)
i < num_bit_lengths;
i++)
1057 for (packed_code_sizes_index = 0; packed_code_sizes_index < num_packed_code_sizes;)
1059 mz_uint code = packed_code_sizes[packed_code_sizes_index++];
1063 TDEFL_PUT_BITS(packed_code_sizes[packed_code_sizes_index++],
"\02\03\07"[
code - 16]);
1072 for (
i = 0;
i <= 143; ++
i)
1074 for (;
i <= 255; ++
i)
1076 for (;
i <= 279; ++
i)
1078 for (;
i <= 287; ++
i)
1089 static const mz_uint mz_bitmasks[17] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF };
1091 #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS
1101 #define TDEFL_PUT_BITS_FAST(b, l) \
1103 bit_buffer |= (((mz_uint64)(b)) << bits_in); \
1108 for (pLZ_codes = d->
m_lz_code_buf; pLZ_codes < pLZ_code_buf_end; flags >>= 1)
1111 flags = *pLZ_codes++ | 0x100;
1115 mz_uint s0, s1, n0, n1, sym, num_extra_bits;
1116 mz_uint match_len = pLZ_codes[0], match_dist = *(
const mz_uint16 *)(pLZ_codes + 1);
1128 sym = (match_dist < 512) ? s0 : s1;
1129 num_extra_bits = (match_dist < 512) ? n0 : n1;
1133 TDEFL_PUT_BITS_FAST(match_dist &
mz_bitmasks[num_extra_bits], num_extra_bits);
1141 if (((
flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end))
1148 if (((
flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end))
1162 pOutput_buf += (bits_in >> 3);
1163 bit_buffer >>= (bits_in & ~7);
1167 #undef TDEFL_PUT_BITS_FAST
1195 flags = *pLZ_codes++ | 0x100;
1199 mz_uint match_len = pLZ_codes[0], match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8));
1206 if (match_dist < 512)
1245 mz_uint saved_bit_buf, saved_bits_in;
1298 else if (!comp_block_succeeded)
1316 for (
i = 0;
i < 4;
i++)
1331 for (
i = 2;
i; --
i, z ^= 0xFFFF)
1363 if ((
n -= bytes_to_copy) != 0)
1378 #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES
1379 #ifdef MINIZ_UNALIGNED_USE_MEMCPY
1393 #define TDEFL_READ_UNALIGNED_WORD(p) *(const mz_uint16 *)(p)
1394 #define TDEFL_READ_UNALIGNED_WORD2(p) *(const mz_uint16 *)(p)
1401 mz_uint16 c01 = TDEFL_READ_UNALIGNED_WORD(&d->
m_dict[pos + match_len - 1]), s01 = TDEFL_READ_UNALIGNED_WORD2(s);
1403 if (max_match_len <= match_len)
1409 if (--num_probes_left == 0)
1411 #define TDEFL_PROBE \
1412 next_probe_pos = d->m_next[probe_pos]; \
1413 if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) \
1415 probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \
1416 if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) \
1425 if (TDEFL_READ_UNALIGNED_WORD2(q) != s01)
1431 }
while ((TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) &&
1432 (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (--probe_len > 0));
1435 *pMatch_dist = dist;
1441 *pMatch_dist = dist;
1442 if ((*pMatch_len = match_len =
MZ_MIN(max_match_len, probe_len)) == max_match_len)
1444 c01 = TDEFL_READ_UNALIGNED_WORD(&d->
m_dict[pos + match_len - 1]);
1456 if (max_match_len <= match_len)
1462 if (--num_probes_left == 0)
1464 #define TDEFL_PROBE \
1465 next_probe_pos = d->m_next[probe_pos]; \
1466 if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) \
1468 probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \
1469 if ((d->m_dict[probe_pos + match_len] == c0) && (d->m_dict[probe_pos + match_len - 1] == c1)) \
1478 q = d->
m_dict + probe_pos;
1479 for (probe_len = 0; probe_len < max_match_len; probe_len++)
1482 if (probe_len > match_len)
1484 *pMatch_dist = dist;
1485 if ((*pMatch_len = match_len = probe_len) == max_match_len)
1487 c0 = d->
m_dict[pos + match_len];
1488 c1 = d->
m_dict[pos + match_len - 1];
1494 #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
1495 #ifdef MINIZ_UNALIGNED_USE_MEMCPY
1503 #define TDEFL_READ_UNALIGNED_WORD32(p) *(const mz_uint32 *)(p)
1514 const mz_uint TDEFL_COMP_FAST_LOOKAHEAD_SIZE = 4096;
1518 lookahead_size += num_bytes_to_process;
1520 while (num_bytes_to_process)
1528 num_bytes_to_process -=
n;
1532 if ((!d->
m_flush) && (lookahead_size < TDEFL_COMP_FAST_LOOKAHEAD_SIZE))
1535 while (lookahead_size >= 4)
1537 mz_uint cur_match_dist, cur_match_len = 1;
1539 mz_uint first_trigram = TDEFL_READ_UNALIGNED_WORD32(pCur_dict) & 0xFFFFFF;
1544 if (((cur_match_dist = (
mz_uint16)(lookahead_pos - probe_pos)) <= dict_size) && ((TDEFL_READ_UNALIGNED_WORD32(d->
m_dict + (probe_pos &=
TDEFL_LZ_DICT_SIZE_MASK)) & 0xFFFFFF) == first_trigram))
1551 }
while ((TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) &&
1552 (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (--probe_len > 0));
1560 *pLZ_code_buf++ = (
mz_uint8)first_trigram;
1561 *pLZ_flags = (
mz_uint8)(*pLZ_flags >> 1);
1567 cur_match_len =
MZ_MIN(cur_match_len, lookahead_size);
1574 #ifdef MINIZ_UNALIGNED_USE_MEMCPY
1575 memcpy(&pLZ_code_buf[1], &cur_match_dist,
sizeof(cur_match_dist));
1580 *pLZ_flags = (
mz_uint8)((*pLZ_flags >> 1) | 0x80);
1584 d->
m_huff_count[1][(cur_match_dist < 512) ? s0 : s1]++;
1591 *pLZ_code_buf++ = (
mz_uint8)first_trigram;
1592 *pLZ_flags = (
mz_uint8)(*pLZ_flags >> 1);
1596 if (--num_flags_left == 0)
1599 pLZ_flags = pLZ_code_buf++;
1602 total_lz_bytes += cur_match_len;
1603 lookahead_pos += cur_match_len;
1606 MZ_ASSERT(lookahead_size >= cur_match_len);
1607 lookahead_size -= cur_match_len;
1628 while (lookahead_size)
1633 *pLZ_code_buf++ = lit;
1634 *pLZ_flags = (
mz_uint8)(*pLZ_flags >> 1);
1635 if (--num_flags_left == 0)
1638 pLZ_flags = pLZ_code_buf++;
1728 mz_uint len_to_move, cur_match_dist, cur_match_len, cur_pos;
1735 const mz_uint8 *pSrc_end = pSrc + num_bytes_to_process;
1736 src_buf_left -= num_bytes_to_process;
1738 while (pSrc != pSrc_end)
1785 while (cur_match_len < d->m_lookahead_size)
1787 if (d->
m_dict[cur_pos + cur_match_len] != c)
1803 cur_match_dist = cur_match_len = 0;
1810 if (cur_match_len >= 128)
1814 len_to_move = cur_match_len;
1830 else if (!cur_match_dist)
1835 len_to_move = cur_match_len;
1907 (d->
m_wants_to_finish && (flush !=
TDEFL_FINISH)) || (pIn_buf_size && *pIn_buf_size && !pIn_buf) || (pOut_buf_size && *pOut_buf_size && !pOut_buf))
1920 #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
1925 if (!tdefl_compress_fast(d))
2010 if (((buf_len) && (!pBuf)) || (!pPut_buf_func))
2040 new_capacity =
MZ_MAX(128U, new_capacity << 1U);
2041 }
while (new_size > new_capacity);
2064 *pOut_len = out_buf.
m_size;
2081 static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
2087 if (window_bits > 0)
2105 #pragma warning(push)
2106 #pragma warning(disable : 4204)
2115 static const mz_uint s_tdefl_png_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
2118 int i, bpl = w * num_chans, y, z;
2132 for (z = 41; z; --z)
2136 for (y = 0; y < h; ++y)
2148 *pLen_out = out_buf.
m_size - 41;
2150 static const mz_uint8 chans[] = { 0x00, 0x00, 0x04, 0x02, 0x06 };
2151 mz_uint8 pnghdr[41] = { 0x89, 0x50, 0x4e, 0x47, 0x0d,
2152 0x0a, 0x1a, 0x0a, 0x00, 0x00,
2153 0x00, 0x0d, 0x49, 0x48, 0x44,
2154 0x52, 0x00, 0x00, 0x00, 0x00,
2155 0x00, 0x00, 0x00, 0x00, 0x08,
2156 0x00, 0x00, 0x00, 0x00, 0x00,
2157 0x00, 0x00, 0x00, 0x00, 0x00,
2158 0x00, 0x00, 0x49, 0x44, 0x41,
2164 pnghdr[25] = chans[num_chans];
2165 pnghdr[33] = (
mz_uint8)(*pLen_out >> 24);
2166 pnghdr[34] = (
mz_uint8)(*pLen_out >> 16);
2167 pnghdr[35] = (
mz_uint8)(*pLen_out >> 8);
2170 for (
i = 0;
i < 4; ++
i, c <<= 8)
2172 memcpy(out_buf.
m_pBuf, pnghdr, 41);
2183 for (
i = 0;
i < 4; ++
i, c <<= 8)
2196 #ifndef MINIZ_NO_MALLOC
2212 #pragma warning(pop)
2252 #define TINFL_MEMCPY(d, s, l) memcpy(d, s, l)
2253 #define TINFL_MEMSET(p, c, l) memset(p, c, l)
2255 #define TINFL_CR_BEGIN \
2256 switch (r->m_state) \
2259 #define TINFL_CR_RETURN(state_index, result) \
2263 r->m_state = state_index; \
2265 case state_index:; \
2268 #define TINFL_CR_RETURN_FOREVER(state_index, result) \
2273 TINFL_CR_RETURN(state_index, result); \
2277 #define TINFL_CR_FINISH }
2279 #define TINFL_GET_BYTE(state_index, c) \
2282 while (pIn_buf_cur >= pIn_buf_end) \
2284 TINFL_CR_RETURN(state_index, (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) ? TINFL_STATUS_NEEDS_MORE_INPUT : TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS); \
2286 c = *pIn_buf_cur++; \
2290 #define TINFL_NEED_BITS(state_index, n) \
2294 TINFL_GET_BYTE(state_index, c); \
2295 bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); \
2297 } while (num_bits < (mz_uint)(n))
2298 #define TINFL_SKIP_BITS(state_index, n) \
2301 if (num_bits < (mz_uint)(n)) \
2303 TINFL_NEED_BITS(state_index, n); \
2309 #define TINFL_GET_BITS(state_index, b, n) \
2312 if (num_bits < (mz_uint)(n)) \
2314 TINFL_NEED_BITS(state_index, n); \
2316 b = bit_buf & ((1 << (n)) - 1); \
2326 #define TINFL_HUFF_BITBUF_FILL(state_index, pHuff) \
2329 temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]; \
2332 code_len = temp >> 9; \
2333 if ((code_len) && (num_bits >= code_len)) \
2336 else if (num_bits > TINFL_FAST_LOOKUP_BITS) \
2338 code_len = TINFL_FAST_LOOKUP_BITS; \
2341 temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \
2342 } while ((temp < 0) && (num_bits >= (code_len + 1))); \
2346 TINFL_GET_BYTE(state_index, c); \
2347 bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); \
2349 } while (num_bits < 15);
2357 #define TINFL_HUFF_DECODE(state_index, sym, pHuff) \
2361 mz_uint code_len, c; \
2362 if (num_bits < 15) \
2364 if ((pIn_buf_end - pIn_buf_cur) < 2) \
2366 TINFL_HUFF_BITBUF_FILL(state_index, pHuff); \
2370 bit_buf |= (((tinfl_bit_buf_t)pIn_buf_cur[0]) << num_bits) | (((tinfl_bit_buf_t)pIn_buf_cur[1]) << (num_bits + 8)); \
2375 if ((temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) \
2376 code_len = temp >> 9, temp &= 511; \
2379 code_len = TINFL_FAST_LOOKUP_BITS; \
2382 temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \
2383 } while (temp < 0); \
2386 bit_buf >>= code_len; \
2387 num_bits -= code_len; \
2393 static const int s_length_base[31] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 };
2394 static const int s_length_extra[31] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0 };
2395 static const int s_dist_base[32] = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0 };
2396 static const int s_dist_extra[32] = { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 };
2397 static const mz_uint8 s_length_dezigzag[19] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
2398 static const int s_min_table_sizes[3] = { 257, 1, 4 };
2401 mz_uint32 num_bits, dist, counter, num_extra;
2403 const mz_uint8 *pIn_buf_cur = pIn_buf_next, *
const pIn_buf_end = pIn_buf_next + *pIn_buf_size;
2404 mz_uint8 *pOut_buf_cur = pOut_buf_next, *
const pOut_buf_end = pOut_buf_next + *pOut_buf_size;
2408 if (((out_buf_size_mask + 1) & out_buf_size_mask) || (pOut_buf_next < pOut_buf_start))
2410 *pIn_buf_size = *pOut_buf_size = 0;
2414 num_bits =
r->m_num_bits;
2415 bit_buf =
r->m_bit_buf;
2417 counter =
r->m_counter;
2418 num_extra =
r->m_num_extra;
2419 dist_from_out_buf_start =
r->m_dist_from_out_buf_start;
2422 bit_buf = num_bits = dist = counter = num_extra =
r->m_zhdr0 =
r->m_zhdr1 = 0;
2423 r->m_z_adler32 =
r->m_check_adler32 = 1;
2428 counter = (((
r->m_zhdr0 * 256 +
r->m_zhdr1) % 31 != 0) || (
r->m_zhdr1 & 32) || ((
r->m_zhdr0 & 15) != 8));
2432 counter |= (((1U << (8U + (
r->m_zhdr0 >> 4))) > 32768U) || ((out_buf_size_mask + 1) < (size_t)(1U << (8U + (
r->m_zhdr0 >> 4)))));
2437 counter |= ((
t > 32768U) || ((out_buf_size_mask + 1) < (size_t)(
t)));
2449 r->m_type =
r->m_final >> 1;
2453 for (counter = 0; counter < 4; ++counter)
2460 if ((counter = (
r->m_raw_header[0] | (
r->m_raw_header[1] << 8))) != (
mz_uint)(0xFFFF ^ (
r->m_raw_header[2] | (
r->m_raw_header[3] << 8))))
2464 while ((counter) && (num_bits))
2467 while (pOut_buf_cur >= pOut_buf_end)
2477 while (pOut_buf_cur >= pOut_buf_end)
2481 while (pIn_buf_cur >= pIn_buf_end)
2485 n =
MZ_MIN(
MZ_MIN((
size_t)(pOut_buf_end - pOut_buf_cur), (
size_t)(pIn_buf_end - pIn_buf_cur)), counter);
2492 else if (
r->m_type == 3)
2500 mz_uint8 *p =
r->m_tables[0].m_code_size;
2502 r->m_table_sizes[0] = 288;
2503 r->m_table_sizes[1] = 32;
2505 for (
i = 0;
i <= 143; ++
i)
2507 for (;
i <= 255; ++
i)
2509 for (;
i <= 279; ++
i)
2511 for (;
i <= 287; ++
i)
2516 for (counter = 0; counter < 3; counter++)
2519 r->m_table_sizes[counter] += s_min_table_sizes[counter];
2522 for (counter = 0; counter <
r->m_table_sizes[2]; counter++)
2526 r->m_tables[2].m_code_size[s_length_dezigzag[counter]] = (
mz_uint8)s;
2528 r->m_table_sizes[2] = 19;
2530 for (; (
int)
r->m_type >= 0;
r->m_type--)
2532 int tree_next, tree_cur;
2534 mz_uint i, j, used_syms, total, sym_index, next_code[17], total_syms[16];
2535 pTable = &
r->m_tables[
r->m_type];
2539 for (
i = 0;
i <
r->m_table_sizes[
r->m_type]; ++
i)
2541 used_syms = 0, total = 0;
2542 next_code[0] = next_code[1] = 0;
2543 for (
i = 1;
i <= 15; ++
i)
2545 used_syms += total_syms[
i];
2546 next_code[
i + 1] = (total = ((total + total_syms[
i]) << 1));
2548 if ((65536 != total) && (used_syms > 1))
2552 for (tree_next = -1, sym_index = 0; sym_index <
r->m_table_sizes[
r->m_type]; ++sym_index)
2557 cur_code = next_code[code_size]++;
2558 for (
l = code_size;
l > 0;
l--, cur_code >>= 1)
2559 rev_code = (rev_code << 1) | (cur_code & 1);
2566 rev_code += (1 << code_size);
2573 tree_cur = tree_next;
2579 tree_cur -= ((rev_code >>= 1) & 1);
2580 if (!pTable->
m_tree[-tree_cur - 1])
2583 tree_cur = tree_next;
2587 tree_cur = pTable->
m_tree[-tree_cur - 1];
2589 tree_cur -= ((rev_code >>= 1) & 1);
2594 for (counter = 0; counter < (
r->m_table_sizes[0] +
r->m_table_sizes[1]);)
2600 r->m_len_codes[counter++] = (
mz_uint8)dist;
2603 if ((dist == 16) && (!counter))
2607 num_extra =
"\02\03\07"[dist - 16];
2609 s +=
"\03\03\013"[dist - 16];
2610 TINFL_MEMSET(
r->m_len_codes + counter, (dist == 16) ?
r->m_len_codes[counter - 1] : 0, s);
2613 if ((
r->m_table_sizes[0] +
r->m_table_sizes[1]) != counter)
2617 TINFL_MEMCPY(
r->m_tables[0].m_code_size,
r->m_len_codes,
r->m_table_sizes[0]);
2618 TINFL_MEMCPY(
r->m_tables[1].m_code_size,
r->m_len_codes +
r->m_table_sizes[0],
r->m_table_sizes[1]);
2626 if (((pIn_buf_end - pIn_buf_cur) < 4) || ((pOut_buf_end - pOut_buf_cur) < 2))
2631 while (pOut_buf_cur >= pOut_buf_end)
2635 *pOut_buf_cur++ = (
mz_uint8)counter;
2641 #if TINFL_USE_64BIT_BITBUF
2657 code_len = sym2 >> 9;
2663 sym2 =
r->m_tables[0].m_tree[~sym2 + ((bit_buf >> code_len++) & 1)];
2667 bit_buf >>= code_len;
2668 num_bits -= code_len;
2672 #if !TINFL_USE_64BIT_BITBUF
2681 code_len = sym2 >> 9;
2687 sym2 =
r->m_tables[0].m_tree[~sym2 + ((bit_buf >> code_len++) & 1)];
2690 bit_buf >>= code_len;
2691 num_bits -= code_len;
2693 pOut_buf_cur[0] = (
mz_uint8)counter;
2704 if ((counter &= 511) == 256)
2707 num_extra = s_length_extra[counter - 257];
2708 counter = s_length_base[counter - 257];
2713 counter += extra_bits;
2717 num_extra = s_dist_extra[dist];
2718 dist = s_dist_base[dist];
2726 dist_from_out_buf_start = pOut_buf_cur - pOut_buf_start;
2732 pSrc = pOut_buf_start + ((dist_from_out_buf_start - dist) & out_buf_size_mask);
2734 if ((
MZ_MAX(pOut_buf_cur, pSrc) + counter) > pOut_buf_end)
2738 while (pOut_buf_cur >= pOut_buf_end)
2742 *pOut_buf_cur++ = pOut_buf_start[(dist_from_out_buf_start++ - dist) & out_buf_size_mask];
2746 #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES
2747 else if ((counter >= 9) && (counter <= dist))
2749 const mz_uint8 *pSrc_end = pSrc + (counter & ~7);
2752 #ifdef MINIZ_UNALIGNED_USE_MEMCPY
2753 memcpy(pOut_buf_cur, pSrc,
sizeof(
mz_uint32)*2);
2759 }
while ((pSrc += 8) < pSrc_end);
2760 if ((counter &= 7) < 3)
2764 pOut_buf_cur[0] = pSrc[0];
2766 pOut_buf_cur[1] = pSrc[1];
2767 pOut_buf_cur += counter;
2775 pOut_buf_cur[0] = pSrc[0];
2776 pOut_buf_cur[1] = pSrc[1];
2777 pOut_buf_cur[2] = pSrc[2];
2784 pOut_buf_cur[0] = pSrc[0];
2786 pOut_buf_cur[1] = pSrc[1];
2787 pOut_buf_cur += counter;
2791 }
while (!(
r->m_final & 1));
2796 while ((pIn_buf_cur > pIn_buf_next) && (num_bits >= 8))
2806 for (counter = 0; counter < 4; ++counter)
2813 r->m_z_adler32 = (
r->m_z_adler32 << 8) | s;
2826 while ((pIn_buf_cur > pIn_buf_next) && (num_bits >= 8))
2832 r->m_num_bits = num_bits;
2835 r->m_counter = counter;
2836 r->m_num_extra = num_extra;
2837 r->m_dist_from_out_buf_start = dist_from_out_buf_start;
2838 *pIn_buf_size = pIn_buf_cur - pIn_buf_next;
2839 *pOut_buf_size = pOut_buf_cur - pOut_buf_next;
2842 const mz_uint8 *ptr = pOut_buf_next;
2843 size_t buf_len = *pOut_buf_size;
2844 mz_uint32 i, s1 =
r->m_check_adler32 & 0xffff, s2 =
r->m_check_adler32 >> 16;
2845 size_t block_len = buf_len % 5552;
2848 for (
i = 0;
i + 7 < block_len;
i += 8, ptr += 8)
2850 s1 += ptr[0], s2 += s1;
2851 s1 += ptr[1], s2 += s1;
2852 s1 += ptr[2], s2 += s1;
2853 s1 += ptr[3], s2 += s1;
2854 s1 += ptr[4], s2 += s1;
2855 s1 += ptr[5], s2 += s1;
2856 s1 += ptr[6], s2 += s1;
2857 s1 += ptr[7], s2 += s1;
2859 for (;
i < block_len; ++
i)
2860 s1 += *ptr++, s2 += s1;
2861 s1 %= 65521U, s2 %= 65521U;
2862 buf_len -= block_len;
2865 r->m_check_adler32 = (s2 << 16) + s1;
2876 void *pBuf =
NULL, *pNew_buf;
2877 size_t src_buf_ofs = 0, out_buf_capacity = 0;
2882 size_t src_buf_size = src_buf_len - src_buf_ofs, dst_buf_size = out_buf_capacity - *pOut_len, new_out_buf_capacity;
2891 src_buf_ofs += src_buf_size;
2892 *pOut_len += dst_buf_size;
2895 new_out_buf_capacity = out_buf_capacity * 2;
2896 if (new_out_buf_capacity < 128)
2897 new_out_buf_capacity = 128;
2898 pNew_buf =
MZ_REALLOC(pBuf, new_out_buf_capacity);
2906 out_buf_capacity = new_out_buf_capacity;
2925 size_t in_buf_ofs = 0, dict_ofs = 0;
2931 size_t in_buf_size = *pIn_buf_size - in_buf_ofs, dst_buf_size =
TINFL_LZ_DICT_SIZE - dict_ofs;
2934 in_buf_ofs += in_buf_size;
2935 if ((dst_buf_size) && (!(*pPut_buf_func)(pDict + dict_ofs, (
int)dst_buf_size, pPut_buf_user)))
2945 *pIn_buf_size = in_buf_ofs;
2949 #ifndef MINIZ_NO_MALLOC
2995 #ifndef MINIZ_NO_ARCHIVE_APIS
3003 #ifdef MINIZ_NO_STDIO
3004 #define MZ_FILE void *
3006 #include <sys/stat.h>
3008 #if defined(_MSC_VER) || defined(__MINGW64__)
3009 static FILE *mz_fopen(
const char *pFilename,
const char *pMode)
3012 fopen_s(&pFile, pFilename, pMode);
3015 static FILE *mz_freopen(
const char *pPath,
const char *pMode, FILE *pStream)
3018 if (freopen_s(&pFile, pPath, pMode, pStream))
3022 #ifndef MINIZ_NO_TIME
3023 #include <sys/utime.h>
3025 #define MZ_FOPEN mz_fopen
3026 #define MZ_FCLOSE fclose
3027 #define MZ_FREAD fread
3028 #define MZ_FWRITE fwrite
3029 #define MZ_FTELL64 _ftelli64
3030 #define MZ_FSEEK64 _fseeki64
3031 #define MZ_FILE_STAT_STRUCT _stat64
3032 #define MZ_FILE_STAT _stat64
3033 #define MZ_FFLUSH fflush
3034 #define MZ_FREOPEN mz_freopen
3035 #define MZ_DELETE_FILE remove
3036 #elif defined(__MINGW32__)
3037 #ifndef MINIZ_NO_TIME
3038 #include <sys/utime.h>
3040 #define MZ_FOPEN(f, m) fopen(f, m)
3041 #define MZ_FCLOSE fclose
3042 #define MZ_FREAD fread
3043 #define MZ_FWRITE fwrite
3044 #define MZ_FTELL64 ftello64
3045 #define MZ_FSEEK64 fseeko64
3046 #define MZ_FILE_STAT_STRUCT _stat
3047 #define MZ_FILE_STAT _stat
3048 #define MZ_FFLUSH fflush
3049 #define MZ_FREOPEN(f, m, s) freopen(f, m, s)
3050 #define MZ_DELETE_FILE remove
3051 #elif defined(__TINYC__)
3052 #ifndef MINIZ_NO_TIME
3053 #include <sys/utime.h>
3055 #define MZ_FOPEN(f, m) fopen(f, m)
3056 #define MZ_FCLOSE fclose
3057 #define MZ_FREAD fread
3058 #define MZ_FWRITE fwrite
3059 #define MZ_FTELL64 ftell
3060 #define MZ_FSEEK64 fseek
3061 #define MZ_FILE_STAT_STRUCT stat
3062 #define MZ_FILE_STAT stat
3063 #define MZ_FFLUSH fflush
3064 #define MZ_FREOPEN(f, m, s) freopen(f, m, s)
3065 #define MZ_DELETE_FILE remove
3066 #elif defined(__USE_LARGEFILE64)
3067 #ifndef MINIZ_NO_TIME
3070 #define MZ_FOPEN(f, m) fopen64(f, m)
3071 #define MZ_FCLOSE fclose
3072 #define MZ_FREAD fread
3073 #define MZ_FWRITE fwrite
3074 #define MZ_FTELL64 ftello64
3075 #define MZ_FSEEK64 fseeko64
3076 #define MZ_FILE_STAT_STRUCT stat64
3077 #define MZ_FILE_STAT stat64
3078 #define MZ_FFLUSH fflush
3079 #define MZ_FREOPEN(p, m, s) freopen64(p, m, s)
3080 #define MZ_DELETE_FILE remove
3081 #elif defined(__APPLE__)
3082 #ifndef MINIZ_NO_TIME
3085 #define MZ_FOPEN(f, m) fopen(f, m)
3086 #define MZ_FCLOSE fclose
3087 #define MZ_FREAD fread
3088 #define MZ_FWRITE fwrite
3089 #define MZ_FTELL64 ftello
3090 #define MZ_FSEEK64 fseeko
3091 #define MZ_FILE_STAT_STRUCT stat
3092 #define MZ_FILE_STAT stat
3093 #define MZ_FFLUSH fflush
3094 #define MZ_FREOPEN(p, m, s) freopen(p, m, s)
3095 #define MZ_DELETE_FILE remove
3098 #pragma message("Using fopen, ftello, fseeko, stat() etc. path for file I/O - this path may not support large files.")
3099 #ifndef MINIZ_NO_TIME
3102 #define MZ_FOPEN(f, m) fopen(f, m)
3103 #define MZ_FCLOSE fclose
3104 #define MZ_FREAD fread
3105 #define MZ_FWRITE fwrite
3106 #ifdef __STRICT_ANSI__
3107 #define MZ_FTELL64 ftell
3108 #define MZ_FSEEK64 fseek
3110 #define MZ_FTELL64 ftello
3111 #define MZ_FSEEK64 fseeko
3113 #define MZ_FILE_STAT_STRUCT stat
3114 #define MZ_FILE_STAT stat
3115 #define MZ_FFLUSH fflush
3116 #define MZ_FREOPEN(f, m, s) freopen(f, m, s)
3117 #define MZ_DELETE_FILE remove
3121 #define MZ_TOLOWER(c) ((((c) >= 'A') && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c))
3244 #define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size) (array_ptr)->m_element_size = element_size
3246 #if defined(DEBUG) || defined(_DEBUG)
3252 #define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) ((element_type *)((array_ptr)->m_p))[mz_zip_array_range_check(array_ptr, index)]
3254 #define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) ((element_type *)((array_ptr)->m_p))[index]
3272 size_t new_capacity = min_new_capacity;
3279 while (new_capacity < min_new_capacity)
3284 pArray->
m_p = pNew_p;
3306 pArray->
m_size = new_size;
3317 size_t orig_size = pArray->
m_size;
3325 #ifndef MINIZ_NO_TIME
3329 memset(&tm, 0,
sizeof(tm));
3331 tm.tm_year = ((dos_date >> 9) & 127) + 1980 - 1900;
3332 tm.tm_mon = ((dos_date >> 5) & 15) - 1;
3333 tm.tm_mday = dos_date & 31;
3334 tm.tm_hour = (dos_time >> 11) & 31;
3335 tm.tm_min = (dos_time >> 5) & 63;
3336 tm.tm_sec = (dos_time << 1) & 62;
3340 #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
3344 struct tm tm_struct;
3345 struct tm *tm = &tm_struct;
3346 errno_t err = localtime_s(tm, &time);
3354 struct tm *tm = localtime(&time);
3357 *pDOS_time = (
mz_uint16)(((tm->tm_hour) << 11) + ((tm->tm_min) << 5) + ((tm->tm_sec) >> 1));
3358 *pDOS_date = (
mz_uint16)(((tm->tm_year + 1900 - 1980) << 9) + ((tm->tm_mon + 1) << 5) + tm->tm_mday);
3362 #ifndef MINIZ_NO_STDIO
3363 #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
3372 *pTime = file_stat.st_mtime;
3382 memset(&
t, 0,
sizeof(
t));
3383 t.actime = access_time;
3384 t.modtime = modified_time;
3386 return !utime(pFilename, &
t);
3440 pE = pL +
MZ_MIN(l_len, r_len);
3448 return (pL == pE) ? (l_len < r_len) : (
l <
r);
3451 #define MZ_SWAP_UINT32(a, b) \
3475 start = (
size - 2U) >> 1U;
3481 if ((child = (root << 1U) + 1U) >=
size)
3501 if ((child = (root << 1U) + 1U) >= end)
3503 child += (((child + 1U) < end) &&
mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1U]));
3532 for (
i =
n - 4;
i >= 0; --
i)
3535 if (s == record_sig)
3552 cur_file_ofs =
MZ_MAX(cur_file_ofs - (
sizeof(buf_u32) - 3), 0);
3555 *pOfs = cur_file_ofs;
3561 mz_uint cdir_size = 0, cdir_entries_on_this_disk = 0, num_this_disk = 0, cdir_disk_index = 0;
3570 mz_uint8 *pZip64_locator = (
mz_uint8 *)zip64_end_of_central_dir_locator_u32;
3573 mz_uint8 *pZip64_end_of_central_dir = (
mz_uint8 *)zip64_end_of_central_dir_header_u32;
3575 mz_uint64 zip64_end_of_central_dir_ofs = 0;
3630 if (zip64_total_num_of_disks != 1U)
3642 cdir_entries_on_this_disk = (
mz_uint32)zip64_cdir_total_entries_on_this_disk;
3648 cdir_size = (
mz_uint32)zip64_size_of_central_directory;
3660 if (((num_this_disk | cdir_disk_index) != 0) && ((num_this_disk != 1) || (cdir_disk_index != 1)))
3679 if (sort_central_dir)
3692 mz_uint total_header_size, disk_index, bit_flags, filename_size, ext_data_size;
3693 mz_uint64 comp_size, decomp_size, local_header_ofs;
3700 if (sort_central_dir)
3714 mz_uint32 extra_size_remaining = ext_data_size;
3716 if (extra_size_remaining)
3745 if (extra_size_remaining < (
sizeof(
mz_uint16) * 2))
3754 if ((field_data_size +
sizeof(
mz_uint16) * 2) > extra_size_remaining)
3768 pExtra_data +=
sizeof(
mz_uint16) * 2 + field_data_size;
3769 extra_size_remaining = extra_size_remaining -
sizeof(
mz_uint16) * 2 - field_data_size;
3770 }
while (extra_size_remaining);
3784 if ((disk_index ==
MZ_UINT16_MAX) || ((disk_index != num_this_disk) && (disk_index != 1)))
3800 n -= total_header_size;
3801 p += total_header_size;
3805 if (sort_central_dir)
3841 #ifndef MINIZ_NO_STDIO
3870 if ((!pZip) || (!pZip->
m_pRead))
3930 #ifndef MINIZ_NO_STDIO
3961 file_size = archive_size;
4007 if ((!pZip) || (!pFile))
4017 archive_size =
MZ_FTELL64(pFile) - cur_file_ofs;
4104 mz_uint filename_len, attribute_mapping_id, external_attr;
4123 (void)attribute_mapping_id;
4137 const mz_uint8 *p = pCentral_dir_header;
4139 if (pFound_zip64_extra_data)
4140 *pFound_zip64_extra_data =
MZ_FALSE;
4142 if ((!p) || (!pStat))
4152 #ifndef MINIZ_NO_TIME
4186 if (extra_size_remaining)
4195 if (extra_size_remaining < (
sizeof(
mz_uint16) * 2))
4201 if ((field_data_size +
sizeof(
mz_uint16) * 2) > extra_size_remaining)
4207 mz_uint32 field_data_remaining = field_data_size;
4209 if (pFound_zip64_extra_data)
4210 *pFound_zip64_extra_data =
MZ_TRUE;
4214 if (field_data_remaining <
sizeof(
mz_uint64))
4219 field_data_remaining -=
sizeof(
mz_uint64);
4224 if (field_data_remaining <
sizeof(
mz_uint64))
4229 field_data_remaining -=
sizeof(
mz_uint64);
4234 if (field_data_remaining <
sizeof(
mz_uint64))
4239 field_data_remaining -=
sizeof(
mz_uint64);
4245 pExtra_data +=
sizeof(
mz_uint16) * 2 + field_data_size;
4246 extra_size_remaining = extra_size_remaining -
sizeof(
mz_uint16) * 2 - field_data_size;
4247 }
while (extra_size_remaining);
4258 return 0 == memcmp(pA, pB,
len);
4259 for (
i = 0;
i <
len; ++
i)
4271 pE = pL +
MZ_MIN(l_len, r_len);
4279 return (pL == pE) ? (
int)(l_len - r_len) : (
l -
r);
4309 *pIndex = file_index;
4334 size_t name_len, comment_len;
4339 if ((!pZip) || (!pZip->
m_pState) || (!pName))
4351 name_len = strlen(pName);
4355 comment_len = pComment ? strlen(pComment) : 0;
4359 for (file_index = 0; file_index < pZip->
m_total_files; file_index++)
4364 if (filename_len < name_len)
4369 const char *pFile_comment = pFilename + filename_len + file_extra_len;
4375 int ofs = filename_len - 1;
4378 if ((pFilename[ofs] ==
'/') || (pFilename[ofs] ==
'\\') || (pFilename[ofs] ==
':'))
4380 }
while (--ofs >= 0);
4383 filename_len -= ofs;
4388 *pIndex = file_index;
4399 mz_uint64 needed_size, cur_file_ofs, comp_remaining, out_buf_ofs = 0, read_buf_size, read_buf_ofs = 0, read_buf_avail;
4406 if ((!pZip) || (!pZip->
m_pState) || ((buf_size) && (!pBuf)) || ((user_read_buf_size) && (!pUser_read_buf)) || (!pZip->
m_pRead))
4426 if (buf_size < needed_size)
4444 if (pZip->
m_pRead(pZip->
m_pIO_opaque, cur_file_ofs, pBuf, (
size_t)needed_size) != needed_size)
4447 #ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
4465 read_buf_size = read_buf_avail = file_stat.
m_comp_size;
4468 else if (pUser_read_buf)
4471 if (!user_read_buf_size)
4473 pRead_buf = (
mz_uint8 *)pUser_read_buf;
4474 read_buf_size = user_read_buf_size;
4482 if (((
sizeof(
size_t) ==
sizeof(
mz_uint32))) && (read_buf_size > 0x7FFFFFFF))
4495 size_t in_buf_size, out_buf_size = (size_t)(file_stat.
m_uncomp_size - out_buf_ofs);
4498 read_buf_avail =
MZ_MIN(read_buf_size, comp_remaining);
4499 if (pZip->
m_pRead(pZip->
m_pIO_opaque, cur_file_ofs, pRead_buf, (
size_t)read_buf_avail) != read_buf_avail)
4505 cur_file_ofs += read_buf_avail;
4506 comp_remaining -= read_buf_avail;
4509 in_buf_size = (size_t)read_buf_avail;
4511 read_buf_avail -= in_buf_size;
4512 read_buf_ofs += in_buf_size;
4513 out_buf_ofs += out_buf_size;
4524 #ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
4559 mz_uint64 comp_size, uncomp_size, alloc_size;
4576 if (((
sizeof(
size_t) ==
sizeof(
mz_uint32))) && (alloc_size > 0x7FFFFFFF))
4595 *pSize = (size_t)alloc_size;
4614 #ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
4617 mz_uint64 read_buf_size, read_buf_ofs = 0, read_buf_avail, comp_remaining, out_buf_ofs = 0, cur_file_ofs;
4619 void *pRead_buf =
NULL;
4620 void *pWrite_buf =
NULL;
4658 read_buf_size = read_buf_avail = file_stat.
m_comp_size;
4686 #ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
4697 while (comp_remaining)
4699 read_buf_avail =
MZ_MIN(read_buf_size, comp_remaining);
4700 if (pZip->
m_pRead(pZip->
m_pIO_opaque, cur_file_ofs, pRead_buf, (
size_t)read_buf_avail) != read_buf_avail)
4707 #ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
4714 if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (
size_t)read_buf_avail) != read_buf_avail)
4721 cur_file_ofs += read_buf_avail;
4722 out_buf_ofs += read_buf_avail;
4723 comp_remaining -= read_buf_avail;
4745 read_buf_avail =
MZ_MIN(read_buf_size, comp_remaining);
4746 if (pZip->
m_pRead(pZip->
m_pIO_opaque, cur_file_ofs, pRead_buf, (
size_t)read_buf_avail) != read_buf_avail)
4752 cur_file_ofs += read_buf_avail;
4753 comp_remaining -= read_buf_avail;
4757 in_buf_size = (size_t)read_buf_avail;
4759 read_buf_avail -= in_buf_size;
4760 read_buf_ofs += in_buf_size;
4764 if (pCallback(pOpaque, out_buf_ofs, pWrite_buf_cur, out_buf_size) != out_buf_size)
4771 #ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
4774 if ((out_buf_ofs += out_buf_size) > file_stat.
m_uncomp_size)
4793 #ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
4794 else if (file_crc32 != file_stat.
m_crc32)