Loading src/lib/deflate.cc +27 −69 Original line number Diff line number Diff line Loading @@ -6,10 +6,6 @@ #include "lib/deflate.h" #ifdef DEFLATE_DEBUG #include "driver/stdout.h" #endif /* * The compressed (inflated) input data. */ Loading Loading @@ -150,9 +146,6 @@ static uint16_t deflate_get_word() deflate_bitmask(deflate_bit_offset)) << (16 - deflate_bit_offset); } #ifdef DEFLATE_DEBUG kout << "get_word = " << bin << ret << dec << endl; #endif return ret; } Loading Loading @@ -190,15 +183,6 @@ static void deflate_build_alphabet(uint8_t * lengths, uint16_t size, code = (code + bl_count[i - 1]) << 1; next_code[i] = code; } #ifdef DEFLATE_DEBUG for (i = 0; i < 12; i++) { kout << "bl_count[" << i << "] = " << bl_count[i] << endl; } for (i = 0; i < 12; i++) { kout << "next_code[" << i << "] = " << next_code[i] << endl; } #endif } static uint16_t deflate_huff(uint8_t * lengths, uint16_t size, Loading @@ -209,10 +193,6 @@ static uint16_t deflate_huff(uint8_t * lengths, uint16_t size, uint16_t next_bits = deflate_rev_word(next_word, num_bits); if (bl_count[num_bits] && next_bits >= next_code[num_bits] && next_bits < next_code[num_bits] + bl_count[num_bits]) { #ifdef DEFLATE_DEBUG kout << "found huffman code, length = " << num_bits << endl; #endif deflate_bit_offset += num_bits; while (deflate_bit_offset >= 8) { deflate_input_now++; Loading Loading @@ -242,9 +222,6 @@ static int8_t deflate_huffman(uint8_t * ll_lengths, uint16_t ll_size, code = deflate_huff(ll_lengths, ll_size, deflate_bl_count_ll, deflate_next_code_ll); #ifdef DEFLATE_DEBUG kout << "code " << code << endl; #endif if (code < 256) { if (deflate_output_now == deflate_output_end) { return DEFLATE_ERR_OUTPUT_LENGTH; Loading Loading @@ -340,12 +317,6 @@ static int8_t deflate_dynamic_huffman() uint8_t hdist = 1 + deflate_get_bits(5); uint8_t hclen = 4 + deflate_get_bits(4); #ifdef DEFLATE_DEBUG kout << "hlit=" << hlit << endl; kout << "hdist=" << hdist << endl; kout << "hclen=" << hclen << endl; #endif for (i = 0; i < hclen; i++) { deflate_hc_lengths[deflate_hclen_index[i]] = deflate_get_bits(3); Loading @@ -363,9 +334,6 @@ static int8_t deflate_dynamic_huffman() uint8_t code = deflate_huff(deflate_hc_lengths, 19, deflate_bl_count_ll, deflate_next_code_ll); #ifdef DEFLATE_DEBUG kout << "code = " << code << endl; #endif if (code == 16) { uint8_t copy_count = 3 + deflate_get_bits(2); for (uint8_t i = 0; i < copy_count; i++) { Loading Loading @@ -406,9 +374,6 @@ int16_t deflate(unsigned char *input_buf, uint16_t input_len, uint8_t is_final = input_buf[0] & 0x01; uint8_t block_type = (input_buf[0] & 0x06) >> 1; int8_t ret; #ifdef DEFLATE_DEBUG kout << "is_final=" << is_final << " block_type=" << block_type << endl; #endif deflate_input_now = input_buf; deflate_input_end = input_buf + input_len; Loading Loading @@ -447,13 +412,6 @@ int16_t deflate_zlib(unsigned char *input_buf, uint16_t input_len, uint8_t zlib_method = input_buf[0] & 0x0f; uint8_t zlib_flags = input_buf[1]; #ifdef DEFLATE_DEBUG kout << "zlib_method=" << zlib_method << endl; kout << "zlib_window_size=" << ((uint16_t) 1 << (8 + ((input_buf[0] & 0xf0) >> 4))) << endl; #endif if (zlib_method != 8) { return DEFLATE_ERR_METHOD; } Loading Loading
src/lib/deflate.cc +27 −69 Original line number Diff line number Diff line Loading @@ -6,10 +6,6 @@ #include "lib/deflate.h" #ifdef DEFLATE_DEBUG #include "driver/stdout.h" #endif /* * The compressed (inflated) input data. */ Loading Loading @@ -150,9 +146,6 @@ static uint16_t deflate_get_word() deflate_bitmask(deflate_bit_offset)) << (16 - deflate_bit_offset); } #ifdef DEFLATE_DEBUG kout << "get_word = " << bin << ret << dec << endl; #endif return ret; } Loading Loading @@ -190,15 +183,6 @@ static void deflate_build_alphabet(uint8_t * lengths, uint16_t size, code = (code + bl_count[i - 1]) << 1; next_code[i] = code; } #ifdef DEFLATE_DEBUG for (i = 0; i < 12; i++) { kout << "bl_count[" << i << "] = " << bl_count[i] << endl; } for (i = 0; i < 12; i++) { kout << "next_code[" << i << "] = " << next_code[i] << endl; } #endif } static uint16_t deflate_huff(uint8_t * lengths, uint16_t size, Loading @@ -209,10 +193,6 @@ static uint16_t deflate_huff(uint8_t * lengths, uint16_t size, uint16_t next_bits = deflate_rev_word(next_word, num_bits); if (bl_count[num_bits] && next_bits >= next_code[num_bits] && next_bits < next_code[num_bits] + bl_count[num_bits]) { #ifdef DEFLATE_DEBUG kout << "found huffman code, length = " << num_bits << endl; #endif deflate_bit_offset += num_bits; while (deflate_bit_offset >= 8) { deflate_input_now++; Loading Loading @@ -242,9 +222,6 @@ static int8_t deflate_huffman(uint8_t * ll_lengths, uint16_t ll_size, code = deflate_huff(ll_lengths, ll_size, deflate_bl_count_ll, deflate_next_code_ll); #ifdef DEFLATE_DEBUG kout << "code " << code << endl; #endif if (code < 256) { if (deflate_output_now == deflate_output_end) { return DEFLATE_ERR_OUTPUT_LENGTH; Loading Loading @@ -340,12 +317,6 @@ static int8_t deflate_dynamic_huffman() uint8_t hdist = 1 + deflate_get_bits(5); uint8_t hclen = 4 + deflate_get_bits(4); #ifdef DEFLATE_DEBUG kout << "hlit=" << hlit << endl; kout << "hdist=" << hdist << endl; kout << "hclen=" << hclen << endl; #endif for (i = 0; i < hclen; i++) { deflate_hc_lengths[deflate_hclen_index[i]] = deflate_get_bits(3); Loading @@ -363,9 +334,6 @@ static int8_t deflate_dynamic_huffman() uint8_t code = deflate_huff(deflate_hc_lengths, 19, deflate_bl_count_ll, deflate_next_code_ll); #ifdef DEFLATE_DEBUG kout << "code = " << code << endl; #endif if (code == 16) { uint8_t copy_count = 3 + deflate_get_bits(2); for (uint8_t i = 0; i < copy_count; i++) { Loading Loading @@ -406,9 +374,6 @@ int16_t deflate(unsigned char *input_buf, uint16_t input_len, uint8_t is_final = input_buf[0] & 0x01; uint8_t block_type = (input_buf[0] & 0x06) >> 1; int8_t ret; #ifdef DEFLATE_DEBUG kout << "is_final=" << is_final << " block_type=" << block_type << endl; #endif deflate_input_now = input_buf; deflate_input_end = input_buf + input_len; Loading Loading @@ -447,13 +412,6 @@ int16_t deflate_zlib(unsigned char *input_buf, uint16_t input_len, uint8_t zlib_method = input_buf[0] & 0x0f; uint8_t zlib_flags = input_buf[1]; #ifdef DEFLATE_DEBUG kout << "zlib_method=" << zlib_method << endl; kout << "zlib_window_size=" << ((uint16_t) 1 << (8 + ((input_buf[0] & 0xf0) >> 4))) << endl; #endif if (zlib_method != 8) { return DEFLATE_ERR_METHOD; } Loading