Commit Graph

2810 Commits (c4a40dbf650ec7137b7548ff55c3d85477e043b0)

Author SHA1 Message Date
shakeelrao 95dfd48143 update formatting 2019-03-01 23:11:15 -08:00
shakeelrao 1e08c49f75 add stylistic changes 2019-03-01 18:29:35 -08:00
shakeelrao 2bb5eec711 update missing error case to CONTENTSIZE_ERROR 2019-03-01 00:12:16 -08:00
shakeelrao 44ae395b3e change nbBlocks to size_t for consistency 2019-03-01 00:05:59 -08:00
shakeelrao 03026c3b1d change compressedBound to ULL 2019-03-01 00:03:50 -08:00
shakeelrao 8930c3c79b implement API-level changes 2019-02-28 22:55:18 -08:00
shakeelrao dce9a09772 initialize local vars in decompressBound 2019-02-28 03:01:21 -08:00
shakeelrao 515c506b4c switch frameBound type to ULL 2019-02-28 02:10:17 -08:00
shakeelrao d0a3f25697 change return type to ULL 2019-02-28 01:52:01 -08:00
shakeelrao c9d674b60d Remove autogenerated test file 2019-02-28 01:29:04 -08:00
shakeelrao 97d3d28dab Fix decl-after-stmnt build error 2019-02-28 01:24:54 -08:00
shakeelrao 820af1e078 Provide an API function to estimate decompressed size.
Introduces a new utility function `ZSTD_findFrameCompressedSize_internal` which
is equivalent to `ZSTD_findFrameCompressSize`, but accepts an additional output
parameter `bound` that computes an upper-bound for the compressed data in the frame.

The new API function is named `ZSTD_decompressBound` to be consistent with
`zstd_compressBound` (the inverse operation). Clients will now be able to compute an upper-bound for
their compressed payloads instead of guessing a large size.

Implements https://github.com/facebook/zstd/issues/1536.
2019-02-28 00:42:49 -08:00
Nick Terrell be3bd70c57
Merge pull request #1532 from terrelln/cctx-params
[libzstd] Rename ZSTD_CCtxParam_* to ZSTD_CCtxParams_*
2019-02-20 10:46:46 -08:00
Nick Terrell 7ad7ba3178 [libzstd] Rename ZSTD_CCtxParam_* to ZSTD_CCtxParams_* 2019-02-19 17:44:52 -08:00
Nick Terrell 9f9630f455 [Windows] Don't use a .def file 2019-02-19 16:52:38 -08:00
Nick Terrell 0c86d23467 [Windows] Move public headers to include/ 2019-02-19 15:49:48 -08:00
Nick Terrell f4abba02ba [libzstd] Clean up parameter code
* Move all ZSTDMT parameter setting code to ZSTD_CCtxParams_*Parameter().
  ZSTDMT now calls these functions, so we can keep all the logic in the
  same place.
* Clean up `ZSTD_CCtx_setParameter()` to only add extra checks where needed.
* Clean up `ZSTDMT_initJobCCtxParams()` by copying all parameters by default,
  and then zeroing the ones that need to be zeroed. We've missed adding several
  parameters here, and it makes more sense to only have to update it if you
  change something in ZSTDMT.
* Add `ZSTDMT_cParam_clampBounds()` to clamp a parameter into its valid
  range. Use this to keep backwards compatibility when setting ZSTDMT parameters,
  which clamp into the valid range.
2019-02-19 13:22:37 -08:00
Nick Terrell 3d7377b874 [libzstd] Handle uncompressed literals 2019-02-15 14:58:11 -08:00
Nick Terrell f9513115e4 [libzstd] Add ZSTD_c_literalCompressionMode flag
It controls the literals compression. It is either
`auto`, `huffman`, or `uncompressed`. It defaults to
`auto`, which is the current behavior.
2019-02-13 14:59:22 -08:00
Nick Terrell 197a5737c8
Merge pull request #1516 from terrelln/dict-doc
[zdict] Improve documentation
2019-02-01 19:04:05 -05:00
Nick Terrell 21616d8a77 [zdict] Improve documentation 2019-02-01 15:19:32 -08:00
Peter (Stig) Edwards 894bbda44c
-Wformat-security not needed with -Wformat=2 2019-02-01 09:31:02 +00:00
W. Felix Handte 501eb25102 Rename FORWARD_ERROR -> FORWARD_IF_ERROR 2019-01-29 12:56:07 -05:00
W. Felix Handte 429987c9a6 Add Comment 2019-01-28 17:35:31 -05:00
W. Felix Handte 2179ce00e1 Remove CHECK_E Macro 2019-01-28 17:33:13 -05:00
W. Felix Handte 03e040a966 Replace Uses of CHECK_E with RETURN_ERROR_IF(*_isError(... 2019-01-28 17:33:01 -05:00
W. Felix Handte 7ebd897157 Remove CHECK_F Macro 2019-01-28 17:16:32 -05:00
W. Felix Handte 64bb6640f2 Replace CHECK_F Uses in zstdmt_compress.c and zstd_ddict.c 2019-01-28 17:15:57 -05:00
W. Felix Handte cafc3b1bcb Also Convert zstd_compress.c 2019-01-28 17:05:18 -05:00
W. Felix Handte 324e9654d3 Add grep-able String to Error Macros 2019-01-28 12:50:36 -05:00
W. Felix Handte 32fed9c7be Switch CHECK_F Calls to FORWARD_ERROR 2019-01-28 12:45:34 -05:00
W. Felix Handte 800c87fed0 Switch Unconditional RETURN_ERROR_IF Calls to RETURN_ERROR 2019-01-28 12:45:34 -05:00
W. Felix Handte a3538bbc6f Add RETURN_ERROR and FORWARD_ERROR Macros 2019-01-28 12:45:26 -05:00
W. Felix Handte c823237d7b Convert Checks in zstd_decompress.c to RETURN_ERROR_IF 2019-01-28 12:23:14 -05:00
W. Felix Handte ea031f4ea2 Convert Checks in zstd_decompress_block.c to RETURN_ERROR_IF 2019-01-28 11:56:39 -05:00
W. Felix Handte 54fa31f03b Add RETURN_ERROR_IF Macro That Logs Debug Information When Check Fails 2019-01-28 11:43:33 -05:00
Yann Collet f9e4f89252 improved comments for adjustCParams() and getCParams() 2019-01-02 12:18:40 -08:00
Yann Collet 0fb4b21d1a updated libzstd documentation 2018-12-25 03:10:07 -08:00
Yann Collet e980ba212f
Merge pull request #1471 from facebook/nofloat
guard functions using floating point for debug mode only
2018-12-23 12:35:51 -08:00
Yann Collet aae5bc538a
Merge pull request #1470 from facebook/U32
fix confusion between unsigned <-> U32
2018-12-23 12:35:39 -08:00
Yann Collet c9dfb7e445 guard functions using floating point for debug mode only
they are only used to print debug messages.
Requested in #1386,
2018-12-22 09:09:40 -08:00
Yann Collet ededcfca57 fix confusion between unsigned <-> U32
as suggested in #1441.

generally U32 and unsigned are the same thing,
except when they are not ...

case : 32-bit compilation for MIPS (uint32_t == unsigned long)

A vast majority of transformation consists in transforming U32 into unsigned.
In rare cases, it's the other way around (typically for internal code, such as seeds).

Among a few issues this patches solves :
- some parameters were declared with type `unsigned` in *.h,
  but with type `U32` in their implementation *.c .
- some parameters have type unsigned*,
  but the caller user a pointer to U32 instead.

These fixes are useful.

However, the bulk of changes is about %u formating,
which requires unsigned type,
but generally receives U32 values instead,
often just for brevity (U32 is shorter than unsigned).
These changes are generally minor, or even annoying.

As a consequence, the amount of code changed is larger than I would expect for such a patch.

Testing is also a pain :
it requires manually modifying `mem.h`,
in order to lie about `U32`
and force it to be an `unsigned long` typically.
On a 64-bit system, this will break the equivalence unsigned == U32.
Unfortunately, it will also break a few static_assert(), controlling structure sizes.
So it also requires modifying `debug.h` to make `static_assert()` a noop.
And then reverting these changes.

So it's inconvenient, and as a consequence,
this property is currently not checked during CI tests.
Therefore, these problems can emerge again in the future.

I wonder if it is worth ensuring proper distinction of U32 != unsigned in CI tests.
It's another restriction for coding, adding more frustration during merge tests,
since most platforms don't need this distinction (hence contributor will not see it),
and while this can matter in theory, the number of platforms impacted seems minimal.

Thoughts ?
2018-12-21 18:09:41 -08:00
Yann Collet c8d1fda982 update aarch64 test to xenial
in an attempt to circumvent the `ld` bug
2018-12-21 15:08:48 -08:00
Yann Collet 8f35c7f94c
Merge pull request #1466 from facebook/noDictPresent
fixed : better error message
2018-12-20 19:01:27 -08:00
Yann Collet 41b45b84a1
Merge pull request #1465 from facebook/noFilePresent
fixed : detection of non-existing file
2018-12-20 17:21:04 -08:00
Yann Collet ed2fb6bd57 fixed : better error message when dictionary missing
during benchmark.
Also : refactored ZSTD_fillHashTable(),
just for readability (it does the same thing)
2018-12-20 17:20:07 -08:00
Yann Collet e4ae24c229
Merge pull request #1420 from felixhandte/zstd-decompress-minimal
Various Macros to Allow Building Extremely Minimal Decoder Library
2018-12-20 15:17:37 -08:00
Yann Collet 95784c654c fixed shadowing of stat variable
some standard lib declares a `stat` variable at global scope
shadowing local declarations ....
2018-12-20 14:56:44 -08:00
Yann Collet ffba142406 fixed file identity detection in 32-bit mode
also :
some library decided to use `index` as a global variable declared in standard header
shadowing the ones used in fastcover.c  :(
2018-12-20 14:30:30 -08:00
W. Felix Handte 91b7309115 Mask Off Unused Functions When ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG 2018-12-20 12:20:34 -08:00
W. Felix Handte 038aabde28 Mask Off Unused Functions When ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT 2018-12-20 12:15:07 -08:00
Yann Collet 2898afab52 fixed OSSfuzz 11849
The problem was already masked,
due to no longer accepting tiny blocks for statistics.

But in case it could still happen with not-so-tiny blocks,
there is a stricter control which ensures that
nothing was already loaded prior to statistics collection.
2018-12-19 16:54:15 -08:00
W. Felix Handte 8e61ac8161 Use Unused Variable in ERR_getErrorString() 2018-12-19 12:36:10 -08:00
Yann Collet 8e0e495ce8 fixed: compression ratio discrepancy
depending on initialization,
the first byte of a new frame was invalidated or not.

As a consequence, one match opportunity was available or not,
resulting in slightly different compressed sizes
(on average, 1 or 2 bytes once every 20 frames).

It impacted ratio comparison between one-shot and streaming modes.

This fix makes the first byte of a new frame always a valid match.
Now compressed size is always the same.
It also improves compressed size by a negligible amount.
2018-12-19 10:11:06 -08:00
Yann Collet d0e15f8d32
Merge pull request #1458 from terrelln/estimate
[libzstd] Fix estimate with negative levels
2018-12-18 15:12:21 -08:00
Yann Collet 04baecaeed
Merge pull request #1457 from facebook/btultra2.1
btultra2 and very small input
2018-12-18 14:46:55 -08:00
Nick Terrell d7def456d8 [libzstd] Fix estimate with negative levels
* Fix `ZSTD_estimateCCtxSize()` with negative levels.
* Fix `ZSTD_estimateCStreamSize()` with negative levels.
* Add a unit test to test for this error.
2018-12-18 14:24:49 -08:00
Yann Collet ef984e7307 fix debug levels
as reported by @terrelln.
2 is reserved for temporary usage only.
2018-12-18 13:40:07 -08:00
W. Felix Handte 0d606ee3db Fix Incorrect assert() 2018-12-18 13:36:39 -08:00
W. Felix Handte bd4afc389f Add Logic to Makefile to Convert Make Vars to Defines 2018-12-18 13:36:39 -08:00
W. Felix Handte ece2c18372 Document Macros in README 2018-12-18 13:36:39 -08:00
W. Felix Handte c2d51637d9 Add Mutual-Exclusion Error 2018-12-18 13:36:39 -08:00
W. Felix Handte c560e34c86 Add HUF_FORCE_DECOMPRESS_X2 2018-12-18 13:36:39 -08:00
W. Felix Handte abd1567d3c Move HUF_DGEN Up Out of X1 Definitions 2018-12-18 13:36:39 -08:00
W. Felix Handte 4a0572b215 Refactor Huffman Decompression Away From Ternary Tree in ZSTD_decodeLiteralsBlock 2018-12-18 13:36:39 -08:00
W. Felix Handte 432314b58a Rename HUF_DECOMPRESS_MINIMAL -> HUF_FORCE_DECOMPRESS_X1 2018-12-18 13:36:39 -08:00
W. Felix Handte 4bbb8a48ad Add ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG
This macro forces behavior in the opposite direction.
2018-12-18 13:36:39 -08:00
W. Felix Handte 64553a0e35 Rename ZSTD_DECOMPRESS_MINIMAL -> ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT 2018-12-18 13:36:39 -08:00
W. Felix Handte 605dd576ee Remove Error Strings with ZSTD_STRIP_ERROR_STRINGS 2018-12-18 13:36:39 -08:00
W. Felix Handte 9d5f3963ff Add Option to Not Request Inlining with ZSTD_NO_INLINE 2018-12-18 13:36:39 -08:00
W. Felix Handte df28e5babd Add ZSTD_DECOMPRESS_MINIMAL Macro, Which Reduces Branching of Decompress Variants 2018-12-18 13:36:39 -08:00
W. Felix Handte f45c9df42e Totally Hide/Disable X2 Variants when HUF_DECOMPRESS_MINIMAL is Defined 2018-12-18 13:36:39 -08:00
W. Felix Handte 36a84b07a8 Load Dictionaries as X1 Tables 2018-12-18 13:36:39 -08:00
W. Felix Handte f9cb348776 Add HUF_DECOMPRESS_MINIMAL Macro, Which Avoids Using X2 Variants 2018-12-18 13:36:39 -08:00
Yann Collet 635783da12 btultra2 and very small srcSize
When srcSize is small,
the nb of symbols produced is likely too small to warrant dedicated probability tables.
In which case, predefined distribution tables will be used instead.

There is a cheap algorithm in btultra initialization :
it presumes default distribution will be used if srcSize <= 1024.

btultra2 now uses the same threshold to shut down probability estimation,
since measured frequencies won't be used at entropy stage,
and therefore relying on them to determine sequence cost is misleading,
resulting in worse compression ratios.

This fixes btultra2 performance issue on very small input.

Note that, a proper way should be
to determine which symbol is going to use predefined probaility
and which symbol is going to use dynamic ones.
But the current algorithm is unable to make a "per-symbol" decision.
So this will require significant modifications.
2018-12-18 12:32:58 -08:00
Yann Collet 517d8c984c
Merge pull request #1449 from facebook/ovlog_def
overlapLog default values
2018-12-18 09:45:53 -08:00
Yann Collet 373ff8b983 play around with rescale weights 2018-12-17 15:48:34 -08:00
Yann Collet 8be145a8c1 fixed default job size 2018-12-13 16:38:08 -08:00
Nick Terrell 75fa3f2eb7
Merge pull request #1446 from terrelln/overflow
[libzstd] Fix infinite loop in decompression
2018-12-13 16:21:15 -08:00
Yann Collet 62180b27d5 zstdmt parameter getter/setter use `int` 2018-12-13 15:47:34 -08:00
Nick Terrell aaea4ef924 [libzstd] Fix infinite loop in decompression
When we switched `ZSTD_SKIPPABLEHEADERSIZE` to a macro, the places where we do:

    MEM_readLE32(ptr) + ZSTD_SKIPPABLEHEADERSIZE

can now overflow `(unsigned)-8` to `0` and we infinite loop. We now check
the frame size and reject sizes that overflow a U32.

Note that this bug never made it into a release, and was only in the dev branch
for a few days.

Credit to OSS-Fuzz
2018-12-13 15:13:19 -08:00
Yann Collet 34f01e600f fixed multiple conversions
from 64-bit to 32-bit
2018-12-13 14:02:22 -08:00
Yann Collet 1993f5d412 fixed ovlog tests
and updated man page
2018-12-12 21:09:14 -08:00
Yann Collet f2f86d369b Merge branch 'btultra2' into ovlog_def 2018-12-12 20:58:14 -08:00
Yann Collet 9a92ed401d updated compression results.csv
and fixed nit
2018-12-12 20:30:09 -08:00
Yann Collet 9792acda3b Merge branch 'dev' into btultra2 2018-12-12 20:18:27 -08:00
Yann Collet 7bb8dfc62f new overlapLog default values
varies between 6 and 9, depending on strategy
2018-12-11 18:10:29 -08:00
Yann Collet eee789b7ea continued: changed to overlapLog
in deeper code layer.
for consistency.
2018-12-11 17:41:42 -08:00
Yann Collet 9b784dec7f changed parameter name to ZSTD_c_overlapLog
from overlapSizeLog.

Reasoning :
`overlapLog` is already used everwhere, in the code, command line and documentation.
`ZSTD_c_overlapSizeLog` feels unnecessarily different.
2018-12-11 16:55:33 -08:00
Yann Collet 52b94f902c add clarification for ZSTD_CCtx_setPledgedSrcSize()
as requested in #1391
2018-12-11 12:08:21 -08:00
Yann Collet 9c3265a53f
Merge pull request #1417 from facebook/advancedAPI
Advanced API
2018-12-10 18:48:15 -08:00
Yann Collet 5e6aaa3abb fixed btultra2 usage with prefix
notably while using multi-threading
2018-12-10 18:45:03 -08:00
Yann Collet 3619c34399 fix assert position within ZSTD_compress2() 2018-12-10 17:42:35 -08:00
Yann Collet 5a1e01e5f1 clarified experimentalParam 2018-12-10 17:36:20 -08:00
Yann Collet c226a7b9f3 fixed ZSTD_compress2()
as suggested by @terrelln
2018-12-10 17:33:49 -08:00
Yann Collet 37e314a68d updated clevel table for large inputs 2018-12-09 22:38:05 -08:00
Yann Collet c9c4c7ec8c update clevel table for 256K 2018-12-08 21:40:08 -08:00
Yann Collet 8075d75f9c update clevel table for 128K 2018-12-08 10:42:55 -08:00
Yann Collet 95b152ab33 updated clevel table for 16K
to introduce btultra2
2018-12-07 20:12:43 -08:00
Yann Collet d613fd9afe linked btultra2 as strategy9
and ensure zstdbench detects out-of-bound parameters
2018-12-06 19:27:37 -08:00