| 2993 | #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && \ |
| 2994 | MINIZ_HAS_64BIT_REGISTERS |
| 2995 | static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) { |
| 2996 | mz_uint flags; |
| 2997 | mz_uint8 *pLZ_codes; |
| 2998 | mz_uint8 *pOutput_buf = d->m_pOutput_buf; |
| 2999 | mz_uint8 *pLZ_code_buf_end = d->m_pLZ_code_buf; |
| 3000 | mz_uint64 bit_buffer = d->m_bit_buffer; |
| 3001 | mz_uint bits_in = d->m_bits_in; |
| 3002 | |
| 3003 | #define TDEFL_PUT_BITS_FAST(b, l) \ |
| 3004 | { \ |
| 3005 | bit_buffer |= (((mz_uint64)(b)) << bits_in); \ |
| 3006 | bits_in += (l); \ |
| 3007 | } |
| 3008 | |
| 3009 | flags = 1; |
| 3010 | for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < pLZ_code_buf_end; |
| 3011 | flags >>= 1) { |
| 3012 | if (flags == 1) |
| 3013 | flags = *pLZ_codes++ | 0x100; |
| 3014 | |
| 3015 | if (flags & 1) { |
| 3016 | mz_uint s0, s1, n0, n1, sym, num_extra_bits; |
| 3017 | mz_uint match_len = pLZ_codes[0], |
| 3018 | match_dist = *(const mz_uint16 *)(pLZ_codes + 1); |
| 3019 | pLZ_codes += 3; |
| 3020 | |
| 3021 | MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); |
| 3022 | TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], |
| 3023 | d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); |
| 3024 | TDEFL_PUT_BITS_FAST(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], |
| 3025 | s_tdefl_len_extra[match_len]); |
| 3026 | |
| 3027 | // This sequence coaxes MSVC into using cmov's vs. jmp's. |
| 3028 | s0 = s_tdefl_small_dist_sym[match_dist & 511]; |
| 3029 | n0 = s_tdefl_small_dist_extra[match_dist & 511]; |
| 3030 | s1 = s_tdefl_large_dist_sym[match_dist >> 8]; |
| 3031 | n1 = s_tdefl_large_dist_extra[match_dist >> 8]; |
| 3032 | sym = (match_dist < 512) ? s0 : s1; |
| 3033 | num_extra_bits = (match_dist < 512) ? n0 : n1; |
| 3034 | |
| 3035 | MZ_ASSERT(d->m_huff_code_sizes[1][sym]); |
| 3036 | TDEFL_PUT_BITS_FAST(d->m_huff_codes[1][sym], |
| 3037 | d->m_huff_code_sizes[1][sym]); |
| 3038 | TDEFL_PUT_BITS_FAST(match_dist & mz_bitmasks[num_extra_bits], |
| 3039 | num_extra_bits); |
| 3040 | } else { |
| 3041 | mz_uint lit = *pLZ_codes++; |
| 3042 | MZ_ASSERT(d->m_huff_code_sizes[0][lit]); |
| 3043 | TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], |
| 3044 | d->m_huff_code_sizes[0][lit]); |
| 3045 | |
| 3046 | if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) { |
| 3047 | flags >>= 1; |
| 3048 | lit = *pLZ_codes++; |
| 3049 | MZ_ASSERT(d->m_huff_code_sizes[0][lit]); |
| 3050 | TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], |
| 3051 | d->m_huff_code_sizes[0][lit]); |
| 3052 |
no outgoing calls
no test coverage detected