43 Commits

Author SHA1 Message Date
Jeffrey Bush a0fcab84a7 Merge pull request #34 from nemequ/master
Fix some warnings
2020-01-05 14:12:32 -05:00
Jeffrey Bush f3cc32fa1f More fixes for the trailing null-byte support for LZNT1. Now works when output buffer is larger than needed and during streaming. 2017-06-23 17:30:29 -04:00
Jeffrey Bush bbe5176e76 Allow LZNT1 compressed data to end with a single trailing null-byte and still work. 2017-06-23 16:51:14 -04:00
Evan Nemerson 4811c1b567 Fix a warning from GCC about using a possibly uninitialized variable
The variable could be used uninitialized when in_len <= 0.
2017-03-21 12:53:28 -07:00
Jeffrey Bush d70aefea63 Fixed #31. Was using the ReadBits_Fast method instead of ReadBits in the full bounds-checking loop. 2016-06-21 14:12:27 -07:00
Jeffrey Bush bda1423f7f Decided to have Xpress compression also use a minimal amount of stack memory. 2016-01-19 22:05:51 -08:00
Jeffrey Bush 805467dd07 Now the Xpress Dictionary uses an array that chooses to be either stack-based or heap-based, reducing the stack memory usage of Xpress Huffman compression by up to 1.25 MB when MSCOMP_WITHOUT_LARGE_STACK is defined.
The Xpress compressor tells the dictionary to always use the stack since it uses only much less memory.
2016-01-19 22:00:50 -08:00
Jeffrey Bush e2f37457b4 Added LARGE_STACK feature that when disabled (using #define MSCOMP_WITHOUT_LARGE_STACK) will cause various large variables to be heap-based instead of stack-based. Now in use by LZNT1Dictionary (512-768 kb reduction in stack usage) and HuffmanEncoder::CreateCodesSlow (512 kb reduction in stack usage, but only in very rare cases).
Also fixed some code to not produce warnings in MSVC.
2016-01-19 21:46:42 -08:00
Jeffrey Bush 0afd4775e0 Increased the Xpress Huffman max compressed size just slightly, it is the final necessary increase. Fixes #27. 2016-01-19 12:19:53 -08:00
Jeffrey Bush 8fe5ffdd36 Merge branch 'master' of github.com:coderforlife/ms-compress
# Conflicts:
#	src/xpress_compress.cpp
2016-01-19 11:53:52 -08:00
Jeffrey Bush 60ef3852db Fixed the calculation for the max compressed size of Xpress Huffman for the last chunk. 2016-01-19 11:49:53 -08:00
Jeffrey Bush 461ede1050 Added a needed cast. 2016-01-19 11:48:49 -08:00
Evan Nemerson 8e45dbf200 Don't compare a signed value with an unsigned one
This triggers a warning on MSVC (C4018) at level 3, as well as GCC with
-Wsign-compare (enabled with -Wextra).
2015-11-14 22:28:30 -08:00
Evan Nemerson 303a7d5e2e Fix types for debug builds which were broken by 778e8bbb 2015-11-04 14:54:37 -08:00
Evan Nemerson 778e8bbbf4 Avoid ODR violations.
GCC 5.2 with LTO will emit warnings when linking due to ODR violations
which occur across translation units.
2015-11-04 12:51:04 -08:00
Jeffrey Bush 39f51004b8 Added restrict to many pointers in LZNT1. Does not seem to have helped or hurt performance with GCC so leaving them in. May try to add them to other algorithms eventually. 2015-05-25 16:32:25 -07:00
Jeffrey Bush 73af8f022c Fixed problems with non-unaligned access methods that produced the wrong byte order and updated Xpress Huffman compression to be able to use non-unaligned accesses. 2015-04-17 16:24:02 -07:00
Jeffrey Bush 1cfac269a8 Finally fixed #4. The problem is that on Windows the stack is 4-byte aligned and GCC assumes (for some optimizations) 16-byte alignment. A GCC stack alignment fix was added to functions that needed it.
Also increased XPRESS Huffman max compressed size which helps #14.
2015-03-19 20:52:50 -07:00
Jeffrey Bush 1095f73d1e Addressed some bugs with XPRESS Huffman compression of uncompromisable data and decompression of invalid data. This partially helps #14. 2015-03-18 14:25:54 -07:00
Jeffrey Bush 66e93e7581 Fixing some warnings with gcc -Wextra -pedantic -Wuninitialized. The remaining warnings are mostly about variadic macros. 2015-03-18 12:56:44 -07:00
Jeffrey Bush e877ca5554 Corrected XPRESS Huffman compression to max size and added checks to make sure it always stays under the max size. In addition many other changes were made for improved performance. 2015-03-17 22:39:05 -07:00
Jeffrey Bush dce8c3ac6a Played around with SSE optimizations like prefetch and 128-bit copies. I couldn't get prefetching to really help during decompression but 128-bit copies helped in XPRESS (Huffman) decompression. 2015-03-16 15:11:55 -07:00
Jeffrey Bush e99e328faf Removing Peek_Not0 and updating Peek to work really fast for 0 and non-0. Few other minor Huffman decoder changes. 2015-03-13 18:34:09 -07:00
Jeffrey Bush 345d9752b4 Improved the package-merge algorithm on the Huffman Encoder to use stack memory (its a lot of it - 519 kb now!). This improves its speed quite a bit (compression speed increases by 25%). 2015-03-13 18:20:07 -07:00
Jeffrey Bush c65aaf2bdb Very minor changes. 2015-03-13 00:44:19 -07:00
Jeffrey Bush 511e1215ae More improvements to XPRESS Huffman decompression speed. 2015-03-13 00:43:59 -07:00
Jeffrey Bush 2f995338d1 Added xpress_huff_max_compressed_size function.
It is untested but logically makes sense. However, it may require catching really poorly compressed chunks (if the compressed data is larger than the uncompressed data, not counting the 256 byte Huffman data). I am unsure if this situation can ever occur though.
2015-03-12 22:47:45 -07:00
Jeffrey Bush 5308b1b2f8 Made FAST_COPY a little more compatible and fixed a new bug in XPRESS decompression. 2015-03-12 21:06:55 -07:00
Jeffrey Bush b4264bb650 Improved the speed of the XPRESS Huffman decompressor, mainly by adding a fast decompression loop, along improving HuffmanDecoder and InputBitstream. 2015-03-12 20:43:14 -07:00
Jeffrey Bush 3dfd9a2fd1 Changed XPRESS to only switch to checked-lengths after maxed out full-byte length (instead of half-byte). Also updated OUT_NEAR_END to use the FAST_COPY_ROOM constant. 2015-03-12 20:39:55 -07:00
Jeffrey Bush 34bffc992f Fix bug in Xpress-Huffman compression that was taking the log2 of 0 (only showed up after PGO!). 2015-03-12 20:38:25 -07:00
Jeffrey Bush 6fa0409de5 Generalized the fast-copy routine used by decompressors (along with fixing some length-checks). Also added ASSERT_ALWAYS which does both assert and ALWAYS on the given command. 2015-03-12 17:55:24 -07:00
Jeffrey Bush bb8562fe8b Made highbit/log2 function use compiler intrinsics if available. If not available it uses a slower method than before (but no static table). 2015-03-11 21:54:48 -07:00
Jeffrey Bush 32a8ce209b Found which loop was causing the access violation with GCC tree-vectorization and put it into the source so tree-vectorization is not disabled globally. Also improved Huffman encoder slightly, mainly by changing merge sort to use insertion sort when "small". 2015-03-11 20:01:04 -07:00
Jeffrey Bush 4fea9774b9 Fixed #10. 2015-03-05 23:40:39 -08:00
Jeffrey Bush b24b7b8bf4 Improved XpressDictionary to skip pathological cases (hoping to find a match after searching a bunch) and a new hash function. These were inspired by zlib. 2015-03-05 16:25:01 -08:00
Jeffrey Bush 84c3d91db6 Updated default LZNT1 dictionary to be simpler, match the API of the new SA LZNT1 dictionary (except returns indicating memory allocation problems), and even slightly faster. Updated comments. 2015-03-04 21:45:55 -08:00
Jeffrey Bush 7df6abf11a Added a new dictionary for LZNT1. It is slower than the old one (which is still default) but uses significantly less memory and no dynamic allocations. It is still being worked on and may get "up to speed" one day. 2015-03-03 20:40:47 -08:00
Jeffrey Bush b3381fb014 Fixed bugs with the new streamable interface (never returning STREAM_END) and the testing framework not setting the right flag along with various other small bug fixes and optimizations.
Also added detailed descriptions to mscomp.h about when the various return codes are used, etc.

Note: LZNT1 compression streaming is still bugged due to an experimental dictionary in development.
2015-03-03 17:41:17 -08:00
Jeffrey Bush 2418d0979e Fixed some small errors. 2015-02-12 17:09:44 -08:00
Jeffrey Bush 8c2b0a8c6b Removed xxx_uncompressed_size functions (since they were not constant-time and basically did decompression without writing).
Removed finish argument from xxx_inflate as it is not used in frameworks like this and was only being used for error detection (which was moved to xxx_inflate_end).

Changed finish argument of xxx_deflate to flush, which supports MSCOMP_NO_FLUSH (equivilent to old finish=false), MSCOMP_FINISH (equivilent to old finish=true), and MSCOMP_FLUSH which will try to get all current read input into the output and not buffer it (similar to finishing except the stream is not terminated).
2015-02-12 17:01:30 -08:00
Jeffrey Bush da2673ccaf Minor clarification. 2015-02-12 13:22:07 -08:00
Jeffrey Bush 62e73cc836 Reorganized code some more to allow it to be easier to bundle into other libraries and fixed some includes. 2015-02-12 12:29:53 -08:00