zstd-ruby 1.3.4.0 → 1.3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/ext/zstdruby/libzstd/Makefile +56 -10
  4. data/ext/zstdruby/libzstd/README.md +4 -0
  5. data/ext/zstdruby/libzstd/common/bitstream.h +6 -19
  6. data/ext/zstdruby/libzstd/common/compiler.h +3 -3
  7. data/ext/zstdruby/libzstd/common/cpu.h +1 -2
  8. data/ext/zstdruby/libzstd/common/debug.c +44 -0
  9. data/ext/zstdruby/libzstd/common/debug.h +123 -0
  10. data/ext/zstdruby/libzstd/common/entropy_common.c +16 -1
  11. data/ext/zstdruby/libzstd/common/fse.h +45 -41
  12. data/ext/zstdruby/libzstd/common/fse_decompress.c +1 -1
  13. data/ext/zstdruby/libzstd/common/huf.h +34 -27
  14. data/ext/zstdruby/libzstd/common/pool.c +89 -32
  15. data/ext/zstdruby/libzstd/common/pool.h +29 -19
  16. data/ext/zstdruby/libzstd/common/zstd_common.c +0 -5
  17. data/ext/zstdruby/libzstd/common/zstd_internal.h +3 -37
  18. data/ext/zstdruby/libzstd/compress/fse_compress.c +28 -163
  19. data/ext/zstdruby/libzstd/compress/hist.c +195 -0
  20. data/ext/zstdruby/libzstd/compress/hist.h +92 -0
  21. data/ext/zstdruby/libzstd/compress/huf_compress.c +14 -6
  22. data/ext/zstdruby/libzstd/compress/zstd_compress.c +798 -350
  23. data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +120 -34
  24. data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +247 -87
  25. data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +4 -1
  26. data/ext/zstdruby/libzstd/compress/zstd_fast.c +177 -56
  27. data/ext/zstdruby/libzstd/compress/zstd_fast.h +4 -1
  28. data/ext/zstdruby/libzstd/compress/zstd_lazy.c +331 -65
  29. data/ext/zstdruby/libzstd/compress/zstd_lazy.h +13 -0
  30. data/ext/zstdruby/libzstd/compress/zstd_ldm.c +15 -20
  31. data/ext/zstdruby/libzstd/compress/zstd_ldm.h +1 -2
  32. data/ext/zstdruby/libzstd/compress/zstd_opt.c +503 -300
  33. data/ext/zstdruby/libzstd/compress/zstd_opt.h +7 -0
  34. data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +122 -47
  35. data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +5 -5
  36. data/ext/zstdruby/libzstd/decompress/huf_decompress.c +325 -325
  37. data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +80 -43
  38. data/ext/zstdruby/libzstd/dictBuilder/cover.c +9 -2
  39. data/ext/zstdruby/libzstd/dictBuilder/zdict.c +5 -5
  40. data/ext/zstdruby/libzstd/legacy/zstd_v04.c +12 -61
  41. data/ext/zstdruby/libzstd/zstd.h +137 -69
  42. data/lib/zstd-ruby/version.rb +1 -1
  43. metadata +7 -3
@@ -59,7 +59,7 @@ extern "C" {
59
59
  /*------ Version ------*/
60
60
  #define ZSTD_VERSION_MAJOR 1
61
61
  #define ZSTD_VERSION_MINOR 3
62
- #define ZSTD_VERSION_RELEASE 4
62
+ #define ZSTD_VERSION_RELEASE 5
63
63
 
64
64
  #define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
65
65
  ZSTDLIB_API unsigned ZSTD_versionNumber(void); /**< useful to check dll version */
@@ -70,6 +70,12 @@ ZSTDLIB_API unsigned ZSTD_versionNumber(void); /**< useful to check dll versio
70
70
  #define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_LIB_VERSION)
71
71
  ZSTDLIB_API const char* ZSTD_versionString(void); /* added in v1.3.0 */
72
72
 
73
+ /***************************************
74
+ * Default constant
75
+ ***************************************/
76
+ #ifndef ZSTD_CLEVEL_DEFAULT
77
+ # define ZSTD_CLEVEL_DEFAULT 3
78
+ #endif
73
79
 
74
80
  /***************************************
75
81
  * Simple API
@@ -96,7 +102,7 @@ ZSTDLIB_API size_t ZSTD_decompress( void* dst, size_t dstCapacity,
96
102
  * `src` should point to the start of a ZSTD encoded frame.
97
103
  * `srcSize` must be at least as large as the frame header.
98
104
  * hint : any size >= `ZSTD_frameHeaderSize_max` is large enough.
99
- * @return : - decompressed size of the frame in `src`, if known
105
+ * @return : - decompressed size of `src` frame content, if known
100
106
  * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined
101
107
  * - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small)
102
108
  * note 1 : a 0 return value means the frame is valid but "empty".
@@ -106,7 +112,8 @@ ZSTDLIB_API size_t ZSTD_decompress( void* dst, size_t dstCapacity,
106
112
  * Optionally, application can rely on some implicit limit,
107
113
  * as ZSTD_decompress() only needs an upper bound of decompressed size.
108
114
  * (For example, data could be necessarily cut into blocks <= 16 KB).
109
- * note 3 : decompressed size is always present when compression is done with ZSTD_compress()
115
+ * note 3 : decompressed size is always present when compression is completed using single-pass functions,
116
+ * such as ZSTD_compress(), ZSTD_compressCCtx() ZSTD_compress_usingDict() or ZSTD_compress_usingCDict().
110
117
  * note 4 : decompressed size can be very large (64-bits value),
111
118
  * potentially larger than what local system can handle as a single memory segment.
112
119
  * In which case, it's necessary to use streaming mode to decompress data.
@@ -123,8 +130,7 @@ ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t
123
130
  * Both functions work the same way, but ZSTD_getDecompressedSize() blends
124
131
  * "empty", "unknown" and "error" results to the same return value (0),
125
132
  * while ZSTD_getFrameContentSize() gives them separate return values.
126
- * `src` is the start of a zstd compressed frame.
127
- * @return : content size to be decompressed, as a 64-bits value _if known and not empty_, 0 otherwise. */
133
+ * @return : decompressed size of `src` frame content _if known and not empty_, 0 otherwise. */
128
134
  ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize);
129
135
 
130
136
 
@@ -272,33 +278,38 @@ typedef struct ZSTD_outBuffer_s {
272
278
  * since it will play nicer with system's memory, by re-using already allocated memory.
273
279
  * Use one separate ZSTD_CStream per thread for parallel execution.
274
280
  *
275
- * Start a new compression by initializing ZSTD_CStream.
281
+ * Start a new compression by initializing ZSTD_CStream context.
276
282
  * Use ZSTD_initCStream() to start a new compression operation.
277
- * Use ZSTD_initCStream_usingDict() or ZSTD_initCStream_usingCDict() for a compression which requires a dictionary (experimental section)
283
+ * Use variants ZSTD_initCStream_usingDict() or ZSTD_initCStream_usingCDict() for streaming with dictionary (experimental section)
278
284
  *
279
- * Use ZSTD_compressStream() repetitively to consume input stream.
280
- * The function will automatically update both `pos` fields.
281
- * Note that it may not consume the entire input, in which case `pos < size`,
282
- * and it's up to the caller to present again remaining data.
285
+ * Use ZSTD_compressStream() as many times as necessary to consume input stream.
286
+ * The function will automatically update both `pos` fields within `input` and `output`.
287
+ * Note that the function may not consume the entire input,
288
+ * for example, because the output buffer is already full,
289
+ * in which case `input.pos < input.size`.
290
+ * The caller must check if input has been entirely consumed.
291
+ * If not, the caller must make some room to receive more compressed data,
292
+ * typically by emptying output buffer, or allocating a new output buffer,
293
+ * and then present again remaining input data.
283
294
  * @return : a size hint, preferred nb of bytes to use as input for next function call
284
295
  * or an error code, which can be tested using ZSTD_isError().
285
296
  * Note 1 : it's just a hint, to help latency a little, any other value will work fine.
286
297
  * Note 2 : size hint is guaranteed to be <= ZSTD_CStreamInSize()
287
298
  *
288
- * At any moment, it's possible to flush whatever data remains within internal buffer, using ZSTD_flushStream().
289
- * `output->pos` will be updated.
290
- * Note that some content might still be left within internal buffer if `output->size` is too small.
291
- * @return : nb of bytes still present within internal buffer (0 if it's empty)
299
+ * At any moment, it's possible to flush whatever data might remain stuck within internal buffer,
300
+ * using ZSTD_flushStream(). `output->pos` will be updated.
301
+ * Note that, if `output->size` is too small, a single invocation of ZSTD_flushStream() might not be enough (return code > 0).
302
+ * In which case, make some room to receive more compressed data, and call again ZSTD_flushStream().
303
+ * @return : 0 if internal buffers are entirely flushed,
304
+ * >0 if some data still present within internal buffer (the value is minimal estimation of remaining size),
292
305
  * or an error code, which can be tested using ZSTD_isError().
293
306
  *
294
307
  * ZSTD_endStream() instructs to finish a frame.
295
308
  * It will perform a flush and write frame epilogue.
296
309
  * The epilogue is required for decoders to consider a frame completed.
297
- * ZSTD_endStream() may not be able to flush full data if `output->size` is too small.
298
- * In which case, call again ZSTD_endStream() to complete the flush.
310
+ * flush() operation is the same, and follows same rules as ZSTD_flushStream().
299
311
  * @return : 0 if frame fully completed and fully flushed,
300
- or >0 if some data is still present within internal buffer
301
- (value is minimum size estimation for remaining data to flush, but it could be more)
312
+ * >0 if some data still present within internal buffer (the value is minimal estimation of remaining size),
302
313
  * or an error code, which can be tested using ZSTD_isError().
303
314
  *
304
315
  * *******************************************************************/
@@ -390,7 +401,6 @@ ZSTDLIB_API size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output
390
401
  #define ZSTD_SEARCHLOG_MIN 1
391
402
  #define ZSTD_SEARCHLENGTH_MAX 7 /* only for ZSTD_fast, other strategies are limited to 6 */
392
403
  #define ZSTD_SEARCHLENGTH_MIN 3 /* only for ZSTD_btopt, other strategies are limited to 4 */
393
- #define ZSTD_TARGETLENGTH_MIN 1 /* only used by btopt, btultra and btfast */
394
404
  #define ZSTD_LDM_MINMATCH_MIN 4
395
405
  #define ZSTD_LDM_MINMATCH_MAX 4096
396
406
  #define ZSTD_LDM_BUCKETSIZELOG_MAX 8
@@ -479,10 +489,10 @@ ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize)
479
489
  * however it does mean that all frame data must be present and valid. */
480
490
  ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize);
481
491
 
482
- /*! ZSTD_frameHeaderSize() :
483
- * `src` should point to the start of a ZSTD frame
484
- * `srcSize` must be >= ZSTD_frameHeaderSize_prefix.
485
- * @return : size of the Frame Header */
492
+ /** ZSTD_frameHeaderSize() :
493
+ * srcSize must be >= ZSTD_frameHeaderSize_prefix.
494
+ * @return : size of the Frame Header,
495
+ * or an error code (if srcSize is too small) */
486
496
  ZSTDLIB_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
487
497
 
488
498
 
@@ -880,6 +890,11 @@ typedef struct {
880
890
  unsigned dictID;
881
891
  unsigned checksumFlag;
882
892
  } ZSTD_frameHeader;
893
+ /** ZSTD_getFrameHeader() :
894
+ * decode Frame Header, or requires larger `srcSize`.
895
+ * @return : 0, `zfhPtr` is correctly filled,
896
+ * >0, `srcSize` is too small, value is wanted `srcSize` amount,
897
+ * or an error code, which can be tested using ZSTD_isError() */
883
898
  ZSTDLIB_API size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize); /**< doesn't consume input */
884
899
  ZSTDLIB_API size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize); /**< when frame content size is not known, pass in frameContentSize == ZSTD_CONTENTSIZE_UNKNOWN */
885
900
 
@@ -901,23 +916,15 @@ ZSTDLIB_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx);
901
916
  /** New advanced API (experimental) */
902
917
  /* ============================================ */
903
918
 
904
- /* notes on API design :
905
- * In this proposal, parameters are pushed one by one into an existing context,
906
- * and then applied on all subsequent compression jobs.
907
- * When no parameter is ever provided, CCtx is created with compression level ZSTD_CLEVEL_DEFAULT.
919
+ /* API design :
920
+ * In this advanced API, parameters are pushed one by one into an existing context,
921
+ * using ZSTD_CCtx_set*() functions.
922
+ * Pushed parameters are sticky : they are applied to next job, and any subsequent job.
923
+ * It's possible to reset parameters to "default" using ZSTD_CCtx_reset().
924
+ * Important : "sticky" parameters only work with `ZSTD_compress_generic()` !
925
+ * For any other entry point, "sticky" parameters are ignored !
908
926
  *
909
927
  * This API is intended to replace all others advanced / experimental API entry points.
910
- * But it stands a reasonable chance to become "stable", after a reasonable testing period.
911
- */
912
-
913
- /* note on naming convention :
914
- * Initially, the API favored names like ZSTD_setCCtxParameter() .
915
- * In this proposal, convention is changed towards ZSTD_CCtx_setParameter() .
916
- * The main driver is that it identifies more clearly the target object type.
917
- * It feels clearer when considering multiple targets :
918
- * ZSTD_CDict_setParameter() (rather than ZSTD_setCDictParameter())
919
- * ZSTD_CCtxParams_setParameter() (rather than ZSTD_setCCtxParamsParameter() )
920
- * etc...
921
928
  */
922
929
 
923
930
  /* note on enum design :
@@ -947,7 +954,7 @@ typedef enum {
947
954
  /* compression parameters */
948
955
  ZSTD_p_compressionLevel=100, /* Update all compression parameters according to pre-defined cLevel table
949
956
  * Default level is ZSTD_CLEVEL_DEFAULT==3.
950
- * Special: value 0 means "do not change cLevel".
957
+ * Special: value 0 means default, which is controlled by ZSTD_CLEVEL_DEFAULT.
951
958
  * Note 1 : it's possible to pass a negative compression level by casting it to unsigned type.
952
959
  * Note 2 : setting a level sets all default values of other compression parameters.
953
960
  * Note 3 : setting compressionLevel automatically updates ZSTD_p_compressLiterals. */
@@ -956,16 +963,19 @@ typedef enum {
956
963
  * Special: value 0 means "use default windowLog".
957
964
  * Note: Using a window size greater than ZSTD_MAXWINDOWSIZE_DEFAULT (default: 2^27)
958
965
  * requires explicitly allowing such window size during decompression stage. */
959
- ZSTD_p_hashLog, /* Size of the probe table, as a power of 2.
966
+ ZSTD_p_hashLog, /* Size of the initial probe table, as a power of 2.
960
967
  * Resulting table size is (1 << (hashLog+2)).
961
968
  * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX.
962
969
  * Larger tables improve compression ratio of strategies <= dFast,
963
970
  * and improve speed of strategies > dFast.
964
971
  * Special: value 0 means "use default hashLog". */
965
- ZSTD_p_chainLog, /* Size of the full-search table, as a power of 2.
972
+ ZSTD_p_chainLog, /* Size of the multi-probe search table, as a power of 2.
966
973
  * Resulting table size is (1 << (chainLog+2)).
974
+ * Must be clamped between ZSTD_CHAINLOG_MIN and ZSTD_CHAINLOG_MAX.
967
975
  * Larger tables result in better and slower compression.
968
976
  * This parameter is useless when using "fast" strategy.
977
+ * Note it's still useful when using "dfast" strategy,
978
+ * in which case it defines a secondary probe table.
969
979
  * Special: value 0 means "use default chainLog". */
970
980
  ZSTD_p_searchLog, /* Number of search attempts, as a power of 2.
971
981
  * More attempts result in better and slower compression.
@@ -1047,27 +1057,52 @@ typedef enum {
1047
1057
  /* experimental parameters - no stability guaranteed */
1048
1058
  /* =================================================================== */
1049
1059
 
1050
- ZSTD_p_compressLiterals=1000, /* control huffman compression of literals (enabled) by default.
1051
- * disabling it improves speed and decreases compression ratio by a large amount.
1052
- * note : this setting is automatically updated when changing compression level.
1053
- * positive compression levels set ZSTD_p_compressLiterals to 1.
1054
- * negative compression levels set ZSTD_p_compressLiterals to 0. */
1055
-
1056
1060
  ZSTD_p_forceMaxWindow=1100, /* Force back-reference distances to remain < windowSize,
1057
1061
  * even when referencing into Dictionary content (default:0) */
1062
+ ZSTD_p_forceAttachDict, /* ZSTD supports usage of a CDict in-place
1063
+ * (avoiding having to copy the compression tables
1064
+ * from the CDict into the working context). Using
1065
+ * a CDict in this way saves an initial setup step,
1066
+ * but comes at the cost of more work per byte of
1067
+ * input. ZSTD has a simple internal heuristic that
1068
+ * guesses which strategy will be faster. You can
1069
+ * use this flag to override that guess.
1070
+ *
1071
+ * Note that the by-reference, in-place strategy is
1072
+ * only used when reusing a compression context
1073
+ * with compatible compression parameters. (If
1074
+ * incompatible / uninitialized, the working
1075
+ * context needs to be cleared anyways, which is
1076
+ * about as expensive as overwriting it with the
1077
+ * dictionary context, so there's no savings in
1078
+ * using the CDict by-ref.)
1079
+ *
1080
+ * Values greater than 0 force attaching the dict.
1081
+ * Values less than 0 force copying the dict.
1082
+ * 0 selects the default heuristic-guided behavior.
1083
+ */
1058
1084
 
1059
1085
  } ZSTD_cParameter;
1060
1086
 
1061
1087
 
1062
1088
  /*! ZSTD_CCtx_setParameter() :
1063
1089
  * Set one compression parameter, selected by enum ZSTD_cParameter.
1064
- * Setting a parameter is generally only possible during frame initialization (before starting compression),
1065
- * except for a few exceptions which can be updated during compression: compressionLevel, hashLog, chainLog, searchLog, minMatch, targetLength and strategy.
1066
- * Note : when `value` is an enum, cast it to unsigned for proper type checking.
1067
- * @result : informational value (typically, value being set clamped correctly),
1090
+ * Setting a parameter is generally only possible during frame initialization (before starting compression).
1091
+ * Exception : when using multi-threading mode (nbThreads >= 1),
1092
+ * following parameters can be updated _during_ compression (within same frame):
1093
+ * => compressionLevel, hashLog, chainLog, searchLog, minMatch, targetLength and strategy.
1094
+ * new parameters will be active on next job, or after a flush().
1095
+ * Note : when `value` type is not unsigned (int, or enum), cast it to unsigned for proper type checking.
1096
+ * @result : informational value (typically, value being set, correctly clamped),
1068
1097
  * or an error code (which can be tested with ZSTD_isError()). */
1069
1098
  ZSTDLIB_API size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned value);
1070
1099
 
1100
+ /*! ZSTD_CCtx_getParameter() :
1101
+ * Get the requested value of one compression parameter, selected by enum ZSTD_cParameter.
1102
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
1103
+ */
1104
+ ZSTDLIB_API size_t ZSTD_CCtx_getParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned* value);
1105
+
1071
1106
  /*! ZSTD_CCtx_setPledgedSrcSize() :
1072
1107
  * Total input data size to be compressed as a single frame.
1073
1108
  * This value will be controlled at the end, and result in error if not respected.
@@ -1115,29 +1150,39 @@ ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
1115
1150
  /*! ZSTD_CCtx_refPrefix() :
1116
1151
  * Reference a prefix (single-usage dictionary) for next compression job.
1117
1152
  * Decompression need same prefix to properly regenerate data.
1118
- * Prefix is **only used once**. Tables are discarded at end of compression job.
1119
- * Subsequent compression jobs will be done without prefix (if none is explicitly referenced).
1120
- * If there is a need to use same prefix multiple times, consider embedding it into a ZSTD_CDict instead.
1153
+ * Prefix is **only used once**. Tables are discarded at end of compression job (ZSTD_e_end).
1121
1154
  * @result : 0, or an error code (which can be tested with ZSTD_isError()).
1122
1155
  * Special: Adding any prefix (including NULL) invalidates any previous prefix or dictionary
1123
- * Note 1 : Prefix buffer is referenced. It must outlive compression job.
1156
+ * Note 1 : Prefix buffer is referenced. It **must** outlive compression job.
1157
+ * Its contain must remain unmodified up to end of compression (ZSTD_e_end).
1124
1158
  * Note 2 : Referencing a prefix involves building tables, which are dependent on compression parameters.
1125
1159
  * It's a CPU consuming operation, with non-negligible impact on latency.
1160
+ * If there is a need to use same prefix multiple times, consider loadDictionary instead.
1126
1161
  * Note 3 : By default, the prefix is treated as raw content (ZSTD_dm_rawContent).
1127
1162
  * Use ZSTD_CCtx_refPrefix_advanced() to alter dictMode. */
1128
- ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize);
1129
- ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
1163
+ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx,
1164
+ const void* prefix, size_t prefixSize);
1165
+ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx,
1166
+ const void* prefix, size_t prefixSize,
1167
+ ZSTD_dictContentType_e dictContentType);
1130
1168
 
1131
1169
  /*! ZSTD_CCtx_reset() :
1132
1170
  * Return a CCtx to clean state.
1133
1171
  * Useful after an error, or to interrupt an ongoing compression job and start a new one.
1134
1172
  * Any internal data not yet flushed is cancelled.
1135
- * Dictionary (if any) is dropped.
1136
- * All parameters are back to default values.
1137
- * It's possible to modify compression parameters after a reset.
1173
+ * The parameters and dictionary are kept unchanged, to reset them use ZSTD_CCtx_resetParameters().
1138
1174
  */
1139
1175
  ZSTDLIB_API void ZSTD_CCtx_reset(ZSTD_CCtx* cctx);
1140
1176
 
1177
+ /*! ZSTD_CCtx_resetParameters() :
1178
+ * All parameters are back to default values (compression level is ZSTD_CLEVEL_DEFAULT).
1179
+ * Dictionary (if any) is dropped.
1180
+ * Resetting parameters is only possible during frame initialization (before starting compression).
1181
+ * To reset the context use ZSTD_CCtx_reset().
1182
+ * @return 0 or an error code (which can be checked with ZSTD_isError()).
1183
+ */
1184
+ ZSTDLIB_API size_t ZSTD_CCtx_resetParameters(ZSTD_CCtx* cctx);
1185
+
1141
1186
 
1142
1187
 
1143
1188
  typedef enum {
@@ -1235,6 +1280,13 @@ ZSTDLIB_API size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, Z
1235
1280
  */
1236
1281
  ZSTDLIB_API size_t ZSTD_CCtxParam_setParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, unsigned value);
1237
1282
 
1283
+ /*! ZSTD_CCtxParam_getParameter() :
1284
+ * Similar to ZSTD_CCtx_getParameter.
1285
+ * Get the requested value of one compression parameter, selected by enum ZSTD_cParameter.
1286
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
1287
+ */
1288
+ ZSTDLIB_API size_t ZSTD_CCtxParam_getParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, unsigned* value);
1289
+
1238
1290
  /*! ZSTD_CCtx_setParametersUsingCCtxParams() :
1239
1291
  * Apply a set of ZSTD_CCtx_params to the compression context.
1240
1292
  * This can be done even after compression is started,
@@ -1246,10 +1298,13 @@ ZSTDLIB_API size_t ZSTD_CCtx_setParametersUsingCCtxParams(
1246
1298
  ZSTD_CCtx* cctx, const ZSTD_CCtx_params* params);
1247
1299
 
1248
1300
 
1249
- /*=== Advanced parameters for decompression API ===*/
1301
+ /* ==================================== */
1302
+ /*=== Advanced decompression API ===*/
1303
+ /* ==================================== */
1250
1304
 
1251
- /* The following parameters must be set after creating a ZSTD_DCtx* (or ZSTD_DStream*) object,
1252
- * but before starting decompression of a frame.
1305
+ /* The following API works the same way as the advanced compression API :
1306
+ * a context is created, parameters are pushed into it one by one,
1307
+ * then the context can be used to decompress data using an interface similar to the straming API.
1253
1308
  */
1254
1309
 
1255
1310
  /*! ZSTD_DCtx_loadDictionary() :
@@ -1286,17 +1341,23 @@ ZSTDLIB_API size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
1286
1341
 
1287
1342
  /*! ZSTD_DCtx_refPrefix() :
1288
1343
  * Reference a prefix (single-usage dictionary) for next compression job.
1289
- * Prefix is **only used once**. It must be explicitly referenced before each frame.
1290
- * If there is a need to use same prefix multiple times, consider embedding it into a ZSTD_DDict instead.
1344
+ * Prefix is **only used once**. Reference is discarded at end of frame.
1345
+ * End of frame is reached when ZSTD_DCtx_decompress_generic() returns 0.
1291
1346
  * @result : 0, or an error code (which can be tested with ZSTD_isError()).
1292
1347
  * Note 1 : Adding any prefix (including NULL) invalidates any previously set prefix or dictionary
1293
- * Note 2 : Prefix buffer is referenced. It must outlive compression job.
1348
+ * Note 2 : Prefix buffer is referenced. It **must** outlive decompression job.
1349
+ * Prefix buffer must remain unmodified up to the end of frame,
1350
+ * reached when ZSTD_DCtx_decompress_generic() returns 0.
1294
1351
  * Note 3 : By default, the prefix is treated as raw content (ZSTD_dm_rawContent).
1295
1352
  * Use ZSTD_CCtx_refPrefix_advanced() to alter dictMode.
1296
1353
  * Note 4 : Referencing a raw content prefix has almost no cpu nor memory cost.
1354
+ * A fulldict prefix is more costly though.
1297
1355
  */
1298
- ZSTDLIB_API size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize);
1299
- ZSTDLIB_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
1356
+ ZSTDLIB_API size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx,
1357
+ const void* prefix, size_t prefixSize);
1358
+ ZSTDLIB_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx,
1359
+ const void* prefix, size_t prefixSize,
1360
+ ZSTD_dictContentType_e dictContentType);
1300
1361
 
1301
1362
 
1302
1363
  /*! ZSTD_DCtx_setMaxWindowSize() :
@@ -1318,6 +1379,13 @@ ZSTDLIB_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowS
1318
1379
  ZSTDLIB_API size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format);
1319
1380
 
1320
1381
 
1382
+ /** ZSTD_getFrameHeader_advanced() :
1383
+ * same as ZSTD_getFrameHeader(),
1384
+ * with added capability to select a format (like ZSTD_f_zstd1_magicless) */
1385
+ ZSTDLIB_API size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr,
1386
+ const void* src, size_t srcSize, ZSTD_format_e format);
1387
+
1388
+
1321
1389
  /*! ZSTD_decompress_generic() :
1322
1390
  * Behave the same as ZSTD_decompressStream.
1323
1391
  * Decompression parameters cannot be changed once decompression is started.
@@ -1,3 +1,3 @@
1
1
  module Zstd
2
- VERSION = "1.3.4.0"
2
+ VERSION = "1.3.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zstd-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4.0
4
+ version: 1.3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SpringMT
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-06 00:00:00.000000000 Z
11
+ date: 2018-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,8 @@ files:
94
94
  - ext/zstdruby/libzstd/common/bitstream.h
95
95
  - ext/zstdruby/libzstd/common/compiler.h
96
96
  - ext/zstdruby/libzstd/common/cpu.h
97
+ - ext/zstdruby/libzstd/common/debug.c
98
+ - ext/zstdruby/libzstd/common/debug.h
97
99
  - ext/zstdruby/libzstd/common/entropy_common.c
98
100
  - ext/zstdruby/libzstd/common/error_private.c
99
101
  - ext/zstdruby/libzstd/common/error_private.h
@@ -111,6 +113,8 @@ files:
111
113
  - ext/zstdruby/libzstd/common/zstd_errors.h
112
114
  - ext/zstdruby/libzstd/common/zstd_internal.h
113
115
  - ext/zstdruby/libzstd/compress/fse_compress.c
116
+ - ext/zstdruby/libzstd/compress/hist.c
117
+ - ext/zstdruby/libzstd/compress/hist.h
114
118
  - ext/zstdruby/libzstd/compress/huf_compress.c
115
119
  - ext/zstdruby/libzstd/compress/zstd_compress.c
116
120
  - ext/zstdruby/libzstd/compress/zstd_compress_internal.h
@@ -185,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
189
  version: '0'
186
190
  requirements: []
187
191
  rubyforge_project:
188
- rubygems_version: 2.6.14
192
+ rubygems_version: 2.7.6
189
193
  signing_key:
190
194
  specification_version: 4
191
195
  summary: Ruby binding for zstd(Zstandard - Fast real-time compression algorithm)