Loading include/lib/deflate.h→include/lib/inflate.h +4 −2 Original line number Diff line number Diff line /* * zlib-deflate-nostdlib * * Copyright 2021 Daniel Friesel * * SPDX-License-Identifier: BSD-2-Clause Loading @@ -15,7 +17,7 @@ #define DEFLATE_ERR_FCHECK (-7) #define DEFLATE_ERR_NLEN (-8) int16_t deflate(unsigned char *input_buf, uint16_t input_len, int16_t inflate(unsigned char *input_buf, uint16_t input_len, unsigned char *output_buf, uint16_t output_len); int16_t deflate_zlib(unsigned char *input_buf, uint16_t input_len, int16_t inflate_zlib(unsigned char *input_buf, uint16_t input_len, unsigned char *output_buf, uint16_t output_len); src/app/deflatetest/Makefile.inc +1 −1 Original line number Diff line number Diff line Loading @@ -10,4 +10,4 @@ ifdef app override arch_drivers += ,counter endif CXX_TARGETS += src/lib/deflate.cc CXX_TARGETS += src/lib/inflate.cc src/app/deflatetest/main.cc +4 −7 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ #include "driver/uptime.h" #include "driver/counter.h" #include "lib/deflate.h" #include "lib/inflate.h" /* Loading @@ -28,10 +28,7 @@ unsigned char const deflate_input[] = { unsigned char const deflate_input[] = { 120, 1, 5, 193, 193, 13, 192, 32, 16, 3, 193, 86, 182, 182, 196, 68, 220, 135, 147, 12, 86, 218, 103, 102, 198, 70, 133, 98, 147, 37, 118, 243, 143, 58, 195, 100, 137, 221, 124, 237, 195, 140, 141, 10, 197, 102, 191, 51, 79, 41, 23, 153, 255, 22, 11 120, 156, 243, 72, 205, 201, 201, 215, 81, 8, 207, 47, 202, 73, 177, 87, 240, 64, 226, 41, 2, 0, 128, 125, 9, 17 }; Loading @@ -51,9 +48,9 @@ int main(void) for (uint8_t i = 0; i < 5; i++) { counter.start(); int16_t ret = deflate_zlib((unsigned char*)deflate_input, sizeof(deflate_input), deflate_output, sizeof(deflate_output)); int16_t ret = inflate_zlib((unsigned char*)deflate_input, sizeof(deflate_input), deflate_output, sizeof(deflate_output)); counter.stop(); kout << "deflate returned " << ret << endl; kout << "inflate returned " << ret << endl; kout << "Output: " << (char*)deflate_output << endl; kout << "took " << counter.value << "/" << counter.overflow << " cycles" << endl; } Loading src/lib/deflate.cc→src/lib/inflate.cc +7 −5 Original line number Diff line number Diff line /* * zlib-deflate-nostdlib * * Copyright 2021 Daniel Friesel * * SPDX-License-Identifier: BSD-2-Clause */ #include "lib/deflate.h" #include "lib/inflate.h" /* * The compressed (inflated) input data. Loading Loading @@ -368,10 +370,10 @@ static int8_t deflate_dynamic_huffman() deflate_lld_lengths + hlit, hdist); } int16_t deflate(unsigned char *input_buf, uint16_t input_len, int16_t inflate(unsigned char *input_buf, uint16_t input_len, unsigned char *output_buf, uint16_t output_len) { uint8_t is_final = input_buf[0] & 0x01; //uint8_t is_final = input_buf[0] & 0x01; uint8_t block_type = (input_buf[0] & 0x06) >> 1; int8_t ret; Loading Loading @@ -403,7 +405,7 @@ int16_t deflate(unsigned char *input_buf, uint16_t input_len, return deflate_output_now - output_buf; } int16_t deflate_zlib(unsigned char *input_buf, uint16_t input_len, int16_t inflate_zlib(unsigned char *input_buf, uint16_t input_len, unsigned char *output_buf, uint16_t output_len) { if (input_len < 4) { Loading @@ -425,7 +427,7 @@ int16_t deflate_zlib(unsigned char *input_buf, uint16_t input_len, } int16_t ret = deflate(input_buf + 2, input_len - 2, output_buf, output_len); inflate(input_buf + 2, input_len - 2, output_buf, output_len); #ifdef DEFLATE_CHECKSUM if (ret >= 0) { Loading Loading
include/lib/deflate.h→include/lib/inflate.h +4 −2 Original line number Diff line number Diff line /* * zlib-deflate-nostdlib * * Copyright 2021 Daniel Friesel * * SPDX-License-Identifier: BSD-2-Clause Loading @@ -15,7 +17,7 @@ #define DEFLATE_ERR_FCHECK (-7) #define DEFLATE_ERR_NLEN (-8) int16_t deflate(unsigned char *input_buf, uint16_t input_len, int16_t inflate(unsigned char *input_buf, uint16_t input_len, unsigned char *output_buf, uint16_t output_len); int16_t deflate_zlib(unsigned char *input_buf, uint16_t input_len, int16_t inflate_zlib(unsigned char *input_buf, uint16_t input_len, unsigned char *output_buf, uint16_t output_len);
src/app/deflatetest/Makefile.inc +1 −1 Original line number Diff line number Diff line Loading @@ -10,4 +10,4 @@ ifdef app override arch_drivers += ,counter endif CXX_TARGETS += src/lib/deflate.cc CXX_TARGETS += src/lib/inflate.cc
src/app/deflatetest/main.cc +4 −7 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ #include "driver/uptime.h" #include "driver/counter.h" #include "lib/deflate.h" #include "lib/inflate.h" /* Loading @@ -28,10 +28,7 @@ unsigned char const deflate_input[] = { unsigned char const deflate_input[] = { 120, 1, 5, 193, 193, 13, 192, 32, 16, 3, 193, 86, 182, 182, 196, 68, 220, 135, 147, 12, 86, 218, 103, 102, 198, 70, 133, 98, 147, 37, 118, 243, 143, 58, 195, 100, 137, 221, 124, 237, 195, 140, 141, 10, 197, 102, 191, 51, 79, 41, 23, 153, 255, 22, 11 120, 156, 243, 72, 205, 201, 201, 215, 81, 8, 207, 47, 202, 73, 177, 87, 240, 64, 226, 41, 2, 0, 128, 125, 9, 17 }; Loading @@ -51,9 +48,9 @@ int main(void) for (uint8_t i = 0; i < 5; i++) { counter.start(); int16_t ret = deflate_zlib((unsigned char*)deflate_input, sizeof(deflate_input), deflate_output, sizeof(deflate_output)); int16_t ret = inflate_zlib((unsigned char*)deflate_input, sizeof(deflate_input), deflate_output, sizeof(deflate_output)); counter.stop(); kout << "deflate returned " << ret << endl; kout << "inflate returned " << ret << endl; kout << "Output: " << (char*)deflate_output << endl; kout << "took " << counter.value << "/" << counter.overflow << " cycles" << endl; } Loading
src/lib/deflate.cc→src/lib/inflate.cc +7 −5 Original line number Diff line number Diff line /* * zlib-deflate-nostdlib * * Copyright 2021 Daniel Friesel * * SPDX-License-Identifier: BSD-2-Clause */ #include "lib/deflate.h" #include "lib/inflate.h" /* * The compressed (inflated) input data. Loading Loading @@ -368,10 +370,10 @@ static int8_t deflate_dynamic_huffman() deflate_lld_lengths + hlit, hdist); } int16_t deflate(unsigned char *input_buf, uint16_t input_len, int16_t inflate(unsigned char *input_buf, uint16_t input_len, unsigned char *output_buf, uint16_t output_len) { uint8_t is_final = input_buf[0] & 0x01; //uint8_t is_final = input_buf[0] & 0x01; uint8_t block_type = (input_buf[0] & 0x06) >> 1; int8_t ret; Loading Loading @@ -403,7 +405,7 @@ int16_t deflate(unsigned char *input_buf, uint16_t input_len, return deflate_output_now - output_buf; } int16_t deflate_zlib(unsigned char *input_buf, uint16_t input_len, int16_t inflate_zlib(unsigned char *input_buf, uint16_t input_len, unsigned char *output_buf, uint16_t output_len) { if (input_len < 4) { Loading @@ -425,7 +427,7 @@ int16_t deflate_zlib(unsigned char *input_buf, uint16_t input_len, } int16_t ret = deflate(input_buf + 2, input_len - 2, output_buf, output_len); inflate(input_buf + 2, input_len - 2, output_buf, output_len); #ifdef DEFLATE_CHECKSUM if (ret >= 0) { Loading