Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
zstd.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Yann Collet, Facebook, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under both the BSD-style license (found in the
6 * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7 * in the COPYING file in the root directory of this source tree).
8 * You may select, at your option, one of the above-listed licenses.
9 */
10#if defined (__cplusplus)
11extern "C" {
12#endif
13
14#ifndef ZSTD_H_235446
15#define ZSTD_H_235446
16
17/* ====== Dependency ======*/
18#include <limits.h> /* INT_MAX */
19#include <stddef.h> /* size_t */
20
21
22/* ===== ZSTDLIB_API : control library symbols visibility ===== */
23#ifndef ZSTDLIB_VISIBLE
24# if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
25# define ZSTDLIB_VISIBLE __attribute__ ((visibility ("default")))
26# define ZSTDLIB_HIDDEN __attribute__ ((visibility ("hidden")))
27# else
28# define ZSTDLIB_VISIBLE
29# define ZSTDLIB_HIDDEN
30# endif
31#endif
32#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
33# define ZSTDLIB_API __declspec(dllexport) ZSTDLIB_VISIBLE
34#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
35# define ZSTDLIB_API __declspec(dllimport) ZSTDLIB_VISIBLE /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
36#else
37# define ZSTDLIB_API ZSTDLIB_VISIBLE
38#endif
39
40
41/*******************************************************************************
42 Introduction
43
44 zstd, short for Zstandard, is a fast lossless compression algorithm, targeting
45 real-time compression scenarios at zlib-level and better compression ratios.
46 The zstd compression library provides in-memory compression and decompression
47 functions.
48
49 The library supports regular compression levels from 1 up to ZSTD_maxCLevel(),
50 which is currently 22. Levels >= 20, labeled `--ultra`, should be used with
51 caution, as they require more memory. The library also offers negative
52 compression levels, which extend the range of speed vs. ratio preferences.
53 The lower the level, the faster the speed (at the cost of compression).
54
55 Compression can be done in:
56 - a single step (described as Simple API)
57 - a single step, reusing a context (described as Explicit context)
58 - unbounded multiple steps (described as Streaming compression)
59
60 The compression ratio achievable on small data can be highly improved using
61 a dictionary. Dictionary compression can be performed in:
62 - a single step (described as Simple dictionary API)
63 - a single step, reusing a dictionary (described as Bulk-processing
64 dictionary API)
65
66 Advanced experimental functions can be accessed using
67 `#define ZSTD_STATIC_LINKING_ONLY` before including zstd.h.
68
69 Advanced experimental APIs should never be used with a dynamically-linked
70 library. They are not "stable"; their definitions or signatures may change in
71 the future. Only static linking is allowed.
72*******************************************************************************/
73
74/*------ Version ------*/
75#define ZSTD_VERSION_MAJOR 1
76#define ZSTD_VERSION_MINOR 5
77#define ZSTD_VERSION_RELEASE 2
78#define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
79
82ZSTDLIB_API unsigned ZSTD_versionNumber(void);
83
84#define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE
85#define ZSTD_QUOTE(str) #str
86#define ZSTD_EXPAND_AND_QUOTE(str) ZSTD_QUOTE(str)
87#define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_LIB_VERSION)
88
91ZSTDLIB_API const char* ZSTD_versionString(void);
92
93/* *************************************
94 * Default constant
95 ***************************************/
96#ifndef ZSTD_CLEVEL_DEFAULT
97# define ZSTD_CLEVEL_DEFAULT 3
98#endif
99
100/* *************************************
101 * Constants
102 ***************************************/
103
104/* All magic numbers are supposed read/written to/from files/memory using little-endian convention */
105#define ZSTD_MAGICNUMBER 0xFD2FB528 /* valid since v0.8.0 */
106#define ZSTD_MAGIC_DICTIONARY 0xEC30A437 /* valid since v0.7.0 */
107#define ZSTD_MAGIC_SKIPPABLE_START 0x184D2A50 /* all 16 values, from 0x184D2A50 to 0x184D2A5F, signal the beginning of a skippable frame */
108#define ZSTD_MAGIC_SKIPPABLE_MASK 0xFFFFFFF0
109
110#define ZSTD_BLOCKSIZELOG_MAX 17
111#define ZSTD_BLOCKSIZE_MAX (1<<ZSTD_BLOCKSIZELOG_MAX)
112
113
114/***************************************
115* Simple API
116***************************************/
122ZSTDLIB_API size_t ZSTD_compress( void* dst, size_t dstCapacity,
123 const void* src, size_t srcSize,
124 int compressionLevel);
125
132ZSTDLIB_API size_t ZSTD_decompress( void* dst, size_t dstCapacity,
133 const void* src, size_t compressedSize);
134
158#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
159#define ZSTD_CONTENTSIZE_ERROR (0ULL - 2)
160ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize);
161
168ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize);
169
176ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize);
177
178
179/*====== Helper functions ======*/
180#define ZSTD_COMPRESSBOUND(srcSize) ((srcSize) + ((srcSize)>>8) + (((srcSize) < (128<<10)) ? (((128<<10) - (srcSize)) >> 11) /* margin, from 64 to 0 */ : 0)) /* this formula ensures that bound(A) + bound(B) <= bound(A+B) as long as A and B >= 128 KB */
182ZSTDLIB_API unsigned ZSTD_isError(size_t code);
183ZSTDLIB_API const char* ZSTD_getErrorName(size_t code);
184ZSTDLIB_API int ZSTD_minCLevel(void);
185ZSTDLIB_API int ZSTD_maxCLevel(void);
189/***************************************
190* Explicit context
191***************************************/
192/*= Compression context
193 * When compressing many times,
194 * it is recommended to allocate a context just once,
195 * and re-use it for each successive compression operation.
196 * This will make workload friendlier for system's memory.
197 * Note : re-using context is just a speed / resource optimization.
198 * It doesn't change the compression ratio, which remains identical.
199 * Note 2 : In multi-threaded environments,
200 * use one different context per thread for parallel execution.
201 */
202typedef struct ZSTD_CCtx_s ZSTD_CCtx;
204ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); /* accept NULL pointer */
205
215 void* dst, size_t dstCapacity,
216 const void* src, size_t srcSize,
217 int compressionLevel);
218
219/*= Decompression context
220 * When decompressing many times,
221 * it is recommended to allocate a context only once,
222 * and re-use it for each successive compression operation.
223 * This will make workload friendlier for system's memory.
224 * Use one context per thread for parallel execution. */
225typedef struct ZSTD_DCtx_s ZSTD_DCtx;
227ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); /* accept NULL pointer */
228
235 void* dst, size_t dstCapacity,
236 const void* src, size_t srcSize);
237
238
239/*********************************************
240* Advanced compression API (Requires v1.4.0+)
241**********************************************/
242
243/* API design :
244 * Parameters are pushed one by one into an existing context,
245 * using ZSTD_CCtx_set*() functions.
246 * Pushed parameters are sticky : they are valid for next compressed frame, and any subsequent frame.
247 * "sticky" parameters are applicable to `ZSTD_compress2()` and `ZSTD_compressStream*()` !
248 * __They do not apply to "simple" one-shot variants such as ZSTD_compressCCtx()__ .
249 *
250 * It's possible to reset all parameters to "default" using ZSTD_CCtx_reset().
251 *
252 * This API supersedes all other "advanced" API entry points in the experimental section.
253 * In the future, we expect to remove from experimental API entry points which are redundant with this API.
254 */
255
256
257/* Compression strategies, listed from fastest to strongest */
258typedef enum { ZSTD_fast=1,
267 /* note : new strategies _might_ be added in the future.
268 Only the order (from fast to strong) is guaranteed */
270
271typedef enum {
272
273 /* compression parameters
274 * Note: When compressing with a ZSTD_CDict these parameters are superseded
275 * by the parameters used to construct the ZSTD_CDict.
276 * See ZSTD_CCtx_refCDict() for more info (superseded-by-cdict). */
277 ZSTD_c_compressionLevel=100, /* Set compression parameters according to pre-defined cLevel table.
278 * Note that exact compression parameters are dynamically determined,
279 * depending on both compression level and srcSize (when known).
280 * Default level is ZSTD_CLEVEL_DEFAULT==3.
281 * Special: value 0 means default, which is controlled by ZSTD_CLEVEL_DEFAULT.
282 * Note 1 : it's possible to pass a negative compression level.
283 * Note 2 : setting a level does not automatically set all other compression parameters
284 * to default. Setting this will however eventually dynamically impact the compression
285 * parameters which have not been manually set. The manually set
286 * ones will 'stick'. */
287 /* Advanced compression parameters :
288 * It's possible to pin down compression parameters to some specific values.
289 * In which case, these values are no longer dynamically selected by the compressor */
290 ZSTD_c_windowLog=101, /* Maximum allowed back-reference distance, expressed as power of 2.
291 * This will set a memory budget for streaming decompression,
292 * with larger values requiring more memory
293 * and typically compressing more.
294 * Must be clamped between ZSTD_WINDOWLOG_MIN and ZSTD_WINDOWLOG_MAX.
295 * Special: value 0 means "use default windowLog".
296 * Note: Using a windowLog greater than ZSTD_WINDOWLOG_LIMIT_DEFAULT
297 * requires explicitly allowing such size at streaming decompression stage. */
298 ZSTD_c_hashLog=102, /* Size of the initial probe table, as a power of 2.
299 * Resulting memory usage is (1 << (hashLog+2)).
300 * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX.
301 * Larger tables improve compression ratio of strategies <= dFast,
302 * and improve speed of strategies > dFast.
303 * Special: value 0 means "use default hashLog". */
304 ZSTD_c_chainLog=103, /* Size of the multi-probe search table, as a power of 2.
305 * Resulting memory usage is (1 << (chainLog+2)).
306 * Must be clamped between ZSTD_CHAINLOG_MIN and ZSTD_CHAINLOG_MAX.
307 * Larger tables result in better and slower compression.
308 * This parameter is useless for "fast" strategy.
309 * It's still useful when using "dfast" strategy,
310 * in which case it defines a secondary probe table.
311 * Special: value 0 means "use default chainLog". */
312 ZSTD_c_searchLog=104, /* Number of search attempts, as a power of 2.
313 * More attempts result in better and slower compression.
314 * This parameter is useless for "fast" and "dFast" strategies.
315 * Special: value 0 means "use default searchLog". */
316 ZSTD_c_minMatch=105, /* Minimum size of searched matches.
317 * Note that Zstandard can still find matches of smaller size,
318 * it just tweaks its search algorithm to look for this size and larger.
319 * Larger values increase compression and decompression speed, but decrease ratio.
320 * Must be clamped between ZSTD_MINMATCH_MIN and ZSTD_MINMATCH_MAX.
321 * Note that currently, for all strategies < btopt, effective minimum is 4.
322 * , for all strategies > fast, effective maximum is 6.
323 * Special: value 0 means "use default minMatchLength". */
324 ZSTD_c_targetLength=106, /* Impact of this field depends on strategy.
325 * For strategies btopt, btultra & btultra2:
326 * Length of Match considered "good enough" to stop search.
327 * Larger values make compression stronger, and slower.
328 * For strategy fast:
329 * Distance between match sampling.
330 * Larger values make compression faster, and weaker.
331 * Special: value 0 means "use default targetLength". */
332 ZSTD_c_strategy=107, /* See ZSTD_strategy enum definition.
333 * The higher the value of selected strategy, the more complex it is,
334 * resulting in stronger and slower compression.
335 * Special: value 0 means "use default strategy". */
336 /* LDM mode parameters */
337 ZSTD_c_enableLongDistanceMatching=160, /* Enable long distance matching.
338 * This parameter is designed to improve compression ratio
339 * for large inputs, by finding large matches at long distance.
340 * It increases memory usage and window size.
341 * Note: enabling this parameter increases default ZSTD_c_windowLog to 128 MB
342 * except when expressly set to a different value.
343 * Note: will be enabled by default if ZSTD_c_windowLog >= 128 MB and
344 * compression strategy >= ZSTD_btopt (== compression level 16+) */
345 ZSTD_c_ldmHashLog=161, /* Size of the table for long distance matching, as a power of 2.
346 * Larger values increase memory usage and compression ratio,
347 * but decrease compression speed.
348 * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX
349 * default: windowlog - 7.
350 * Special: value 0 means "automatically determine hashlog". */
351 ZSTD_c_ldmMinMatch=162, /* Minimum match size for long distance matcher.
352 * Larger/too small values usually decrease compression ratio.
353 * Must be clamped between ZSTD_LDM_MINMATCH_MIN and ZSTD_LDM_MINMATCH_MAX.
354 * Special: value 0 means "use default value" (default: 64). */
355 ZSTD_c_ldmBucketSizeLog=163, /* Log size of each bucket in the LDM hash table for collision resolution.
356 * Larger values improve collision resolution but decrease compression speed.
357 * The maximum value is ZSTD_LDM_BUCKETSIZELOG_MAX.
358 * Special: value 0 means "use default value" (default: 3). */
359 ZSTD_c_ldmHashRateLog=164, /* Frequency of inserting/looking up entries into the LDM hash table.
360 * Must be clamped between 0 and (ZSTD_WINDOWLOG_MAX - ZSTD_HASHLOG_MIN).
361 * Default is MAX(0, (windowLog - ldmHashLog)), optimizing hash table usage.
362 * Larger values improve compression speed.
363 * Deviating far from default value will likely result in a compression ratio decrease.
364 * Special: value 0 means "automatically determine hashRateLog". */
365
366 /* frame parameters */
367 ZSTD_c_contentSizeFlag=200, /* Content size will be written into frame header _whenever known_ (default:1)
368 * Content size must be known at the beginning of compression.
369 * This is automatically the case when using ZSTD_compress2(),
370 * For streaming scenarios, content size must be provided with ZSTD_CCtx_setPledgedSrcSize() */
371 ZSTD_c_checksumFlag=201, /* A 32-bits checksum of content is written at end of frame (default:0) */
372 ZSTD_c_dictIDFlag=202, /* When applicable, dictionary's ID is written into frame header (default:1) */
373
374 /* multi-threading parameters */
375 /* These parameters are only active if multi-threading is enabled (compiled with build macro ZSTD_MULTITHREAD).
376 * Otherwise, trying to set any other value than default (0) will be a no-op and return an error.
377 * In a situation where it's unknown if the linked library supports multi-threading or not,
378 * setting ZSTD_c_nbWorkers to any value >= 1 and consulting the return value provides a quick way to check this property.
379 */
380 ZSTD_c_nbWorkers=400, /* Select how many threads will be spawned to compress in parallel.
381 * When nbWorkers >= 1, triggers asynchronous mode when invoking ZSTD_compressStream*() :
382 * ZSTD_compressStream*() consumes input and flush output if possible, but immediately gives back control to caller,
383 * while compression is performed in parallel, within worker thread(s).
384 * (note : a strong exception to this rule is when first invocation of ZSTD_compressStream2() sets ZSTD_e_end :
385 * in which case, ZSTD_compressStream2() delegates to ZSTD_compress2(), which is always a blocking call).
386 * More workers improve speed, but also increase memory usage.
387 * Default value is `0`, aka "single-threaded mode" : no worker is spawned,
388 * compression is performed inside Caller's thread, and all invocations are blocking */
389 ZSTD_c_jobSize=401, /* Size of a compression job. This value is enforced only when nbWorkers >= 1.
390 * Each compression job is completed in parallel, so this value can indirectly impact the nb of active threads.
391 * 0 means default, which is dynamically determined based on compression parameters.
392 * Job size must be a minimum of overlap size, or ZSTDMT_JOBSIZE_MIN (= 512 KB), whichever is largest.
393 * The minimum size is automatically and transparently enforced. */
394 ZSTD_c_overlapLog=402, /* Control the overlap size, as a fraction of window size.
395 * The overlap size is an amount of data reloaded from previous job at the beginning of a new job.
396 * It helps preserve compression ratio, while each job is compressed in parallel.
397 * This value is enforced only when nbWorkers >= 1.
398 * Larger values increase compression ratio, but decrease speed.
399 * Possible values range from 0 to 9 :
400 * - 0 means "default" : value will be determined by the library, depending on strategy
401 * - 1 means "no overlap"
402 * - 9 means "full overlap", using a full window size.
403 * Each intermediate rank increases/decreases load size by a factor 2 :
404 * 9: full window; 8: w/2; 7: w/4; 6: w/8; 5:w/16; 4: w/32; 3:w/64; 2:w/128; 1:no overlap; 0:default
405 * default value varies between 6 and 9, depending on strategy */
406
407 /* note : additional experimental parameters are also available
408 * within the experimental section of the API.
409 * At the time of this writing, they include :
410 * ZSTD_c_rsyncable
411 * ZSTD_c_format
412 * ZSTD_c_forceMaxWindow
413 * ZSTD_c_forceAttachDict
414 * ZSTD_c_literalCompressionMode
415 * ZSTD_c_targetCBlockSize
416 * ZSTD_c_srcSizeHint
417 * ZSTD_c_enableDedicatedDictSearch
418 * ZSTD_c_stableInBuffer
419 * ZSTD_c_stableOutBuffer
420 * ZSTD_c_blockDelimiters
421 * ZSTD_c_validateSequences
422 * ZSTD_c_useBlockSplitter
423 * ZSTD_c_useRowMatchFinder
424 * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
425 * note : never ever use experimentalParam? names directly;
426 * also, the enums values themselves are unstable and can still change.
427 */
444
445typedef struct {
446 size_t error;
450
459
471ZSTDLIB_API size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int value);
472
488ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize);
489
495
511
523 void* dst, size_t dstCapacity,
524 const void* src, size_t srcSize);
525
526
527/***********************************************
528* Advanced decompression API (Requires v1.4.0+)
529************************************************/
530
531/* The advanced API pushes parameters one by one into an existing DCtx context.
532 * Parameters are sticky, and remain valid for all following frames
533 * using the same DCtx context.
534 * It's possible to reset parameters to default values using ZSTD_DCtx_reset().
535 * Note : This API is compatible with existing ZSTD_decompressDCtx() and ZSTD_decompressStream().
536 * Therefore, no new decompression function is necessary.
537 */
538
539typedef enum {
540
541 ZSTD_d_windowLogMax=100, /* Select a size limit (in power of 2) beyond which
542 * the streaming API will refuse to allocate memory buffer
543 * in order to protect the host from unreasonable memory requirements.
544 * This parameter is only useful in streaming mode, since no internal buffer is allocated in single-pass mode.
545 * By default, a decompression context accepts window sizes <= (1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT).
546 * Special: value 0 means "use default maximum windowLog". */
547
548 /* note : additional experimental parameters are also available
549 * within the experimental section of the API.
550 * At the time of this writing, they include :
551 * ZSTD_d_format
552 * ZSTD_d_stableOutBuffer
553 * ZSTD_d_forceIgnoreChecksum
554 * ZSTD_d_refMultipleDDicts
555 * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
556 * note : never ever use experimentalParam? names directly
557 */
562
564
573
581ZSTDLIB_API size_t ZSTD_DCtx_setParameter(ZSTD_DCtx* dctx, ZSTD_dParameter param, int value);
582
590
591
592/****************************
593* Streaming
594****************************/
595
596typedef struct ZSTD_inBuffer_s {
597 const void* src;
598 size_t size;
599 size_t pos;
601
602typedef struct ZSTD_outBuffer_s {
603 void* dst;
604 size_t size;
605 size_t pos;
607
608
609
610/*-***********************************************************************
611* Streaming compression - HowTo
612*
613* A ZSTD_CStream object is required to track streaming operation.
614* Use ZSTD_createCStream() and ZSTD_freeCStream() to create/release resources.
615* ZSTD_CStream objects can be reused multiple times on consecutive compression operations.
616* It is recommended to re-use ZSTD_CStream since it will play nicer with system's memory, by re-using already allocated memory.
617*
618* For parallel execution, use one separate ZSTD_CStream per thread.
619*
620* note : since v1.3.0, ZSTD_CStream and ZSTD_CCtx are the same thing.
621*
622* Parameters are sticky : when starting a new compression on the same context,
623* it will re-use the same sticky parameters as previous compression session.
624* When in doubt, it's recommended to fully initialize the context before usage.
625* Use ZSTD_CCtx_reset() to reset the context and ZSTD_CCtx_setParameter(),
626* ZSTD_CCtx_setPledgedSrcSize(), or ZSTD_CCtx_loadDictionary() and friends to
627* set more specific parameters, the pledged source size, or load a dictionary.
628*
629* Use ZSTD_compressStream2() with ZSTD_e_continue as many times as necessary to
630* consume input stream. The function will automatically update both `pos`
631* fields within `input` and `output`.
632* Note that the function may not consume the entire input, for example, because
633* the output buffer is already full, in which case `input.pos < input.size`.
634* The caller must check if input has been entirely consumed.
635* If not, the caller must make some room to receive more compressed data,
636* and then present again remaining input data.
637* note: ZSTD_e_continue is guaranteed to make some forward progress when called,
638* but doesn't guarantee maximal forward progress. This is especially relevant
639* when compressing with multiple threads. The call won't block if it can
640* consume some input, but if it can't it will wait for some, but not all,
641* output to be flushed.
642* @return : provides a minimum amount of data remaining to be flushed from internal buffers
643* or an error code, which can be tested using ZSTD_isError().
644*
645* At any moment, it's possible to flush whatever data might remain stuck within internal buffer,
646* using ZSTD_compressStream2() with ZSTD_e_flush. `output->pos` will be updated.
647* Note that, if `output->size` is too small, a single invocation with ZSTD_e_flush might not be enough (return code > 0).
648* In which case, make some room to receive more compressed data, and call again ZSTD_compressStream2() with ZSTD_e_flush.
649* You must continue calling ZSTD_compressStream2() with ZSTD_e_flush until it returns 0, at which point you can change the
650* operation.
651* note: ZSTD_e_flush will flush as much output as possible, meaning when compressing with multiple threads, it will
652* block until the flush is complete or the output buffer is full.
653* @return : 0 if internal buffers are entirely flushed,
654* >0 if some data still present within internal buffer (the value is minimal estimation of remaining size),
655* or an error code, which can be tested using ZSTD_isError().
656*
657* Calling ZSTD_compressStream2() with ZSTD_e_end instructs to finish a frame.
658* It will perform a flush and write frame epilogue.
659* The epilogue is required for decoders to consider a frame completed.
660* flush operation is the same, and follows same rules as calling ZSTD_compressStream2() with ZSTD_e_flush.
661* You must continue calling ZSTD_compressStream2() with ZSTD_e_end until it returns 0, at which point you are free to
662* start a new frame.
663* note: ZSTD_e_end will flush as much output as possible, meaning when compressing with multiple threads, it will
664* block until the flush is complete or the output buffer is full.
665* @return : 0 if frame fully completed and fully flushed,
666* >0 if some data still present within internal buffer (the value is minimal estimation of remaining size),
667* or an error code, which can be tested using ZSTD_isError().
668*
669* *******************************************************************/
670
672 /* Continue to distinguish them for compatibility with older versions <= v1.2.0 */
673/*===== ZSTD_CStream management functions =====*/
675ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream* zcs); /* accept NULL pointer */
676
677/*===== Streaming compression functions =====*/
678typedef enum {
679 ZSTD_e_continue=0, /* collect more data, encoder decides when to output compressed result, for optimal compression ratio */
680 ZSTD_e_flush=1, /* flush any data provided so far,
681 * it creates (at least) one new block, that can be decoded immediately on reception;
682 * frame will continue: any future data can still reference previously compressed data, improving compression.
683 * note : multithreaded compression will block to flush as much output as possible. */
684 ZSTD_e_end=2 /* flush any remaining data _and_ close current frame.
685 * note that frame is only closed after compressed data is fully flushed (return value == 0).
686 * After that point, any additional data starts a new frame.
687 * note : each frame is independent (does not reference any content from previous frame).
688 : note : multithreaded compression will block to flush as much output as possible. */
690
716 ZSTD_EndDirective endOp);
717
718
719/* These buffer sizes are softly recommended.
720 * They are not required : ZSTD_compressStream*() happily accepts any buffer size, for both input and output.
721 * Respecting the recommended size just makes it a bit easier for ZSTD_compressStream*(),
722 * reducing the amount of memory shuffling and buffering, resulting in minor performance savings.
723 *
724 * However, note that these recommendations are from the perspective of a C caller program.
725 * If the streaming interface is invoked from some other language,
726 * especially managed ones such as Java or Go, through a foreign function interface such as jni or cgo,
727 * a major performance rule is to reduce crossing such interface to an absolute minimum.
728 * It's not rare that performance ends being spent more into the interface, rather than compression itself.
729 * In which cases, prefer using large buffers, as large as practical,
730 * for both input and output, to reduce the nb of roundtrips.
731 */
732ZSTDLIB_API size_t ZSTD_CStreamInSize(void);
733ZSTDLIB_API size_t ZSTD_CStreamOutSize(void);
736/* *****************************************************************************
737 * This following is a legacy streaming API, available since v1.0+ .
738 * It can be replaced by ZSTD_CCtx_reset() and ZSTD_compressStream2().
739 * It is redundant, but remains fully supported.
740 * Streaming in combination with advanced parameters and dictionary compression
741 * can only be used through the new API.
742 ******************************************************************************/
743
763
764
765/*-***************************************************************************
766* Streaming decompression - HowTo
767*
768* A ZSTD_DStream object is required to track streaming operations.
769* Use ZSTD_createDStream() and ZSTD_freeDStream() to create/release resources.
770* ZSTD_DStream objects can be re-used multiple times.
771*
772* Use ZSTD_initDStream() to start a new decompression operation.
773* @return : recommended first input size
774* Alternatively, use advanced API to set specific properties.
775*
776* Use ZSTD_decompressStream() repetitively to consume your input.
777* The function will update both `pos` fields.
778* If `input.pos < input.size`, some input has not been consumed.
779* It's up to the caller to present again remaining data.
780* The function tries to flush all data decoded immediately, respecting output buffer size.
781* If `output.pos < output.size`, decoder has flushed everything it could.
782* But if `output.pos == output.size`, there might be some data left within internal buffers.,
783* In which case, call ZSTD_decompressStream() again to flush whatever remains in the buffer.
784* Note : with no additional input provided, amount of data flushed is necessarily <= ZSTD_BLOCKSIZE_MAX.
785* @return : 0 when a frame is completely decoded and fully flushed,
786* or an error code, which can be tested using ZSTD_isError(),
787* or any other value > 0, which means there is still some decoding or flushing to do to complete current frame :
788* the return value is a suggested next input size (just a hint for better latency)
789* that will never request more than the remaining frame size.
790* *******************************************************************************/
791
793 /* For compatibility with versions <= v1.2.0, prefer differentiating them. */
794/*===== ZSTD_DStream management functions =====*/
796ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream* zds); /* accept NULL pointer */
797
798/*===== Streaming decompression functions =====*/
799
800/* This function is redundant with the advanced API and equivalent to:
801 *
802 * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
803 * ZSTD_DCtx_refDDict(zds, NULL);
804 */
806
808
809ZSTDLIB_API size_t ZSTD_DStreamInSize(void);
810ZSTDLIB_API size_t ZSTD_DStreamOutSize(void);
813/**************************
814* Simple dictionary API
815***************************/
824 void* dst, size_t dstCapacity,
825 const void* src, size_t srcSize,
826 const void* dict,size_t dictSize,
827 int compressionLevel);
828
836 void* dst, size_t dstCapacity,
837 const void* src, size_t srcSize,
838 const void* dict,size_t dictSize);
839
840
841/***********************************
842 * Bulk processing dictionary API
843 **********************************/
845
858ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize,
859 int compressionLevel);
860
865
872 void* dst, size_t dstCapacity,
873 const void* src, size_t srcSize,
874 const ZSTD_CDict* cdict);
875
876
878
883
888
893 void* dst, size_t dstCapacity,
894 const void* src, size_t srcSize,
895 const ZSTD_DDict* ddict);
896
897
898/********************************
899 * Dictionary helper functions
900 *******************************/
901
906ZSTDLIB_API unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize);
907
912ZSTDLIB_API unsigned ZSTD_getDictID_fromCDict(const ZSTD_CDict* cdict);
913
918ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict);
919
930ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
931
932
933/*******************************************************************************
934 * Advanced dictionary and prefix API (Requires v1.4.0+)
935 *
936 * This API allows dictionaries to be used with ZSTD_compress2(),
937 * ZSTD_compressStream2(), and ZSTD_decompressDCtx(). Dictionaries are sticky, and
938 * only reset with the context is reset with ZSTD_reset_parameters or
939 * ZSTD_reset_session_and_parameters. Prefixes are single-use.
940 ******************************************************************************/
941
942
960ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
961
974ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
975
995 const void* prefix, size_t prefixSize);
996
1012ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
1013
1030ZSTDLIB_API size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
1031
1049 const void* prefix, size_t prefixSize);
1050
1051/* === Memory management === */
1052
1056ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx);
1057ZSTDLIB_API size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx* dctx);
1060ZSTDLIB_API size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict);
1061ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
1062
1063#endif /* ZSTD_H_235446 */
1064
1065
1066/* **************************************************************************************
1067 * ADVANCED AND EXPERIMENTAL FUNCTIONS
1068 ****************************************************************************************
1069 * The definitions in the following section are considered experimental.
1070 * They are provided for advanced scenarios.
1071 * They should never be used with a dynamic library, as prototypes may change in the future.
1072 * Use them only in association with static linking.
1073 * ***************************************************************************************/
1074
1075#if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY)
1076#define ZSTD_H_ZSTD_STATIC_LINKING_ONLY
1077
1078/* This can be overridden externally to hide static symbols. */
1079#ifndef ZSTDLIB_STATIC_API
1080# if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
1081# define ZSTDLIB_STATIC_API __declspec(dllexport) ZSTDLIB_VISIBLE
1082# elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
1083# define ZSTDLIB_STATIC_API __declspec(dllimport) ZSTDLIB_VISIBLE
1084# else
1085# define ZSTDLIB_STATIC_API ZSTDLIB_VISIBLE
1086# endif
1087#endif
1088
1089/* Deprecation warnings :
1090 * Should these warnings be a problem, it is generally possible to disable them,
1091 * typically with -Wno-deprecated-declarations for gcc or _CRT_SECURE_NO_WARNINGS in Visual.
1092 * Otherwise, it's also possible to define ZSTD_DISABLE_DEPRECATE_WARNINGS.
1093 */
1094#ifdef ZSTD_DISABLE_DEPRECATE_WARNINGS
1095# define ZSTD_DEPRECATED(message) ZSTDLIB_STATIC_API /* disable deprecation warnings */
1096#else
1097# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
1098# define ZSTD_DEPRECATED(message) [[deprecated(message)]] ZSTDLIB_STATIC_API
1099# elif (defined(GNUC) && (GNUC > 4 || (GNUC == 4 && GNUC_MINOR >= 5))) || defined(__clang__)
1100# define ZSTD_DEPRECATED(message) ZSTDLIB_STATIC_API __attribute__((deprecated(message)))
1101# elif defined(__GNUC__) && (__GNUC__ >= 3)
1102# define ZSTD_DEPRECATED(message) ZSTDLIB_STATIC_API __attribute__((deprecated))
1103# elif defined(_MSC_VER)
1104# define ZSTD_DEPRECATED(message) ZSTDLIB_STATIC_API __declspec(deprecated(message))
1105# else
1106# pragma message("WARNING: You need to implement ZSTD_DEPRECATED for this compiler")
1107# define ZSTD_DEPRECATED(message) ZSTDLIB_STATIC_API
1108# endif
1109#endif /* ZSTD_DISABLE_DEPRECATE_WARNINGS */
1110
1111/****************************************************************************************
1112 * experimental API (static linking only)
1113 ****************************************************************************************
1114 * The following symbols and constants
1115 * are not planned to join "stable API" status in the near future.
1116 * They can still change in future versions.
1117 * Some of them are planned to remain in the static_only section indefinitely.
1118 * Some of them might be removed in the future (especially when redundant with existing stable functions)
1119 * ***************************************************************************************/
1120
1121#define ZSTD_FRAMEHEADERSIZE_PREFIX(format) ((format) == ZSTD_f_zstd1 ? 5 : 1) /* minimum input size required to query frame header size */
1122#define ZSTD_FRAMEHEADERSIZE_MIN(format) ((format) == ZSTD_f_zstd1 ? 6 : 2)
1123#define ZSTD_FRAMEHEADERSIZE_MAX 18 /* can be useful for static allocation */
1124#define ZSTD_SKIPPABLEHEADERSIZE 8
1125
1126/* compression parameter bounds */
1127#define ZSTD_WINDOWLOG_MAX_32 30
1128#define ZSTD_WINDOWLOG_MAX_64 31
1129#define ZSTD_WINDOWLOG_MAX ((int)(sizeof(size_t) == 4 ? ZSTD_WINDOWLOG_MAX_32 : ZSTD_WINDOWLOG_MAX_64))
1130#define ZSTD_WINDOWLOG_MIN 10
1131#define ZSTD_HASHLOG_MAX ((ZSTD_WINDOWLOG_MAX < 30) ? ZSTD_WINDOWLOG_MAX : 30)
1132#define ZSTD_HASHLOG_MIN 6
1133#define ZSTD_CHAINLOG_MAX_32 29
1134#define ZSTD_CHAINLOG_MAX_64 30
1135#define ZSTD_CHAINLOG_MAX ((int)(sizeof(size_t) == 4 ? ZSTD_CHAINLOG_MAX_32 : ZSTD_CHAINLOG_MAX_64))
1136#define ZSTD_CHAINLOG_MIN ZSTD_HASHLOG_MIN
1137#define ZSTD_SEARCHLOG_MAX (ZSTD_WINDOWLOG_MAX-1)
1138#define ZSTD_SEARCHLOG_MIN 1
1139#define ZSTD_MINMATCH_MAX 7 /* only for ZSTD_fast, other strategies are limited to 6 */
1140#define ZSTD_MINMATCH_MIN 3 /* only for ZSTD_btopt+, faster strategies are limited to 4 */
1141#define ZSTD_TARGETLENGTH_MAX ZSTD_BLOCKSIZE_MAX
1142#define ZSTD_TARGETLENGTH_MIN 0 /* note : comparing this constant to an unsigned results in a tautological test */
1143#define ZSTD_STRATEGY_MIN ZSTD_fast
1144#define ZSTD_STRATEGY_MAX ZSTD_btultra2
1145
1146
1147#define ZSTD_OVERLAPLOG_MIN 0
1148#define ZSTD_OVERLAPLOG_MAX 9
1149
1150#define ZSTD_WINDOWLOG_LIMIT_DEFAULT 27 /* by default, the streaming decoder will refuse any frame
1151 * requiring larger than (1<<ZSTD_WINDOWLOG_LIMIT_DEFAULT) window size,
1152 * to preserve host's memory from unreasonable requirements.
1153 * This limit can be overridden using ZSTD_DCtx_setParameter(,ZSTD_d_windowLogMax,).
1154 * The limit does not apply for one-pass decoders (such as ZSTD_decompress()), since no additional memory is allocated */
1155
1156
1157/* LDM parameter bounds */
1158#define ZSTD_LDM_HASHLOG_MIN ZSTD_HASHLOG_MIN
1159#define ZSTD_LDM_HASHLOG_MAX ZSTD_HASHLOG_MAX
1160#define ZSTD_LDM_MINMATCH_MIN 4
1161#define ZSTD_LDM_MINMATCH_MAX 4096
1162#define ZSTD_LDM_BUCKETSIZELOG_MIN 1
1163#define ZSTD_LDM_BUCKETSIZELOG_MAX 8
1164#define ZSTD_LDM_HASHRATELOG_MIN 0
1165#define ZSTD_LDM_HASHRATELOG_MAX (ZSTD_WINDOWLOG_MAX - ZSTD_HASHLOG_MIN)
1166
1167/* Advanced parameter bounds */
1168#define ZSTD_TARGETCBLOCKSIZE_MIN 64
1169#define ZSTD_TARGETCBLOCKSIZE_MAX ZSTD_BLOCKSIZE_MAX
1170#define ZSTD_SRCSIZEHINT_MIN 0
1171#define ZSTD_SRCSIZEHINT_MAX INT_MAX
1172
1173
1174/* --- Advanced types --- */
1175
1176typedef struct ZSTD_CCtx_params_s ZSTD_CCtx_params;
1177
1178typedef struct {
1179 unsigned int offset; /* The offset of the match. (NOT the same as the offset code)
1180 * If offset == 0 and matchLength == 0, this sequence represents the last
1181 * literals in the block of litLength size.
1182 */
1183
1184 unsigned int litLength; /* Literal length of the sequence. */
1185 unsigned int matchLength; /* Match length of the sequence. */
1186
1187 /* Note: Users of this API may provide a sequence with matchLength == litLength == offset == 0.
1188 * In this case, we will treat the sequence as a marker for a block boundary.
1189 */
1190
1191 unsigned int rep; /* Represents which repeat offset is represented by the field 'offset'.
1192 * Ranges from [0, 3].
1193 *
1194 * Repeat offsets are essentially previous offsets from previous sequences sorted in
1195 * recency order. For more detail, see doc/zstd_compression_format.md
1196 *
1197 * If rep == 0, then 'offset' does not contain a repeat offset.
1198 * If rep > 0:
1199 * If litLength != 0:
1200 * rep == 1 --> offset == repeat_offset_1
1201 * rep == 2 --> offset == repeat_offset_2
1202 * rep == 3 --> offset == repeat_offset_3
1203 * If litLength == 0:
1204 * rep == 1 --> offset == repeat_offset_2
1205 * rep == 2 --> offset == repeat_offset_3
1206 * rep == 3 --> offset == repeat_offset_1 - 1
1207 *
1208 * Note: This field is optional. ZSTD_generateSequences() will calculate the value of
1209 * 'rep', but repeat offsets do not necessarily need to be calculated from an external
1210 * sequence provider's perspective. For example, ZSTD_compressSequences() does not
1211 * use this 'rep' field at all (as of now).
1212 */
1213} ZSTD_Sequence;
1214
1215typedef struct {
1216 unsigned windowLog;
1217 unsigned chainLog;
1218 unsigned hashLog;
1219 unsigned searchLog;
1220 unsigned minMatch;
1221 unsigned targetLength;
1222 ZSTD_strategy strategy;
1223} ZSTD_compressionParameters;
1224
1225typedef struct {
1226 int contentSizeFlag;
1227 int checksumFlag;
1228 int noDictIDFlag;
1229} ZSTD_frameParameters;
1230
1231typedef struct {
1232 ZSTD_compressionParameters cParams;
1233 ZSTD_frameParameters fParams;
1235
1236typedef enum {
1237 ZSTD_dct_auto = 0, /* dictionary is "full" when starting with ZSTD_MAGIC_DICTIONARY, otherwise it is "rawContent" */
1238 ZSTD_dct_rawContent = 1, /* ensures dictionary is always loaded as rawContent, even if it starts with ZSTD_MAGIC_DICTIONARY */
1239 ZSTD_dct_fullDict = 2 /* refuses to load a dictionary if it does not respect Zstandard's specification, starting with ZSTD_MAGIC_DICTIONARY */
1240} ZSTD_dictContentType_e;
1241
1242typedef enum {
1243 ZSTD_dlm_byCopy = 0,
1244 ZSTD_dlm_byRef = 1
1245} ZSTD_dictLoadMethod_e;
1246
1247typedef enum {
1248 ZSTD_f_zstd1 = 0, /* zstd frame format, specified in zstd_compression_format.md (default) */
1249 ZSTD_f_zstd1_magicless = 1 /* Variant of zstd frame format, without initial 4-bytes magic number.
1250 * Useful to save 4 bytes per generated frame.
1251 * Decoder cannot recognise automatically this format, requiring this instruction. */
1252} ZSTD_format_e;
1253
1254typedef enum {
1255 /* Note: this enum controls ZSTD_d_forceIgnoreChecksum */
1256 ZSTD_d_validateChecksum = 0,
1257 ZSTD_d_ignoreChecksum = 1
1258} ZSTD_forceIgnoreChecksum_e;
1259
1260typedef enum {
1261 /* Note: this enum controls ZSTD_d_refMultipleDDicts */
1262 ZSTD_rmd_refSingleDDict = 0,
1263 ZSTD_rmd_refMultipleDDicts = 1
1264} ZSTD_refMultipleDDicts_e;
1265
1266typedef enum {
1267 /* Note: this enum and the behavior it controls are effectively internal
1268 * implementation details of the compressor. They are expected to continue
1269 * to evolve and should be considered only in the context of extremely
1270 * advanced performance tuning.
1271 *
1272 * Zstd currently supports the use of a CDict in three ways:
1273 *
1274 * - The contents of the CDict can be copied into the working context. This
1275 * means that the compression can search both the dictionary and input
1276 * while operating on a single set of internal tables. This makes
1277 * the compression faster per-byte of input. However, the initial copy of
1278 * the CDict's tables incurs a fixed cost at the beginning of the
1279 * compression. For small compressions (< 8 KB), that copy can dominate
1280 * the cost of the compression.
1281 *
1282 * - The CDict's tables can be used in-place. In this model, compression is
1283 * slower per input byte, because the compressor has to search two sets of
1284 * tables. However, this model incurs no start-up cost (as long as the
1285 * working context's tables can be reused). For small inputs, this can be
1286 * faster than copying the CDict's tables.
1287 *
1288 * - The CDict's tables are not used at all, and instead we use the working
1289 * context alone to reload the dictionary and use params based on the source
1290 * size. See ZSTD_compress_insertDictionary() and ZSTD_compress_usingDict().
1291 * This method is effective when the dictionary sizes are very small relative
1292 * to the input size, and the input size is fairly large to begin with.
1293 *
1294 * Zstd has a simple internal heuristic that selects which strategy to use
1295 * at the beginning of a compression. However, if experimentation shows that
1296 * Zstd is making poor choices, it is possible to override that choice with
1297 * this enum.
1298 */
1299 ZSTD_dictDefaultAttach = 0, /* Use the default heuristic. */
1300 ZSTD_dictForceAttach = 1, /* Never copy the dictionary. */
1301 ZSTD_dictForceCopy = 2, /* Always copy the dictionary. */
1302 ZSTD_dictForceLoad = 3 /* Always reload the dictionary */
1303} ZSTD_dictAttachPref_e;
1304
1305typedef enum {
1306 ZSTD_lcm_auto = 0,
1309 ZSTD_lcm_huffman = 1,
1311 ZSTD_lcm_uncompressed = 2
1312} ZSTD_literalCompressionMode_e;
1313
1314typedef enum {
1315 /* Note: This enum controls features which are conditionally beneficial. Zstd typically will make a final
1316 * decision on whether or not to enable the feature (ZSTD_ps_auto), but setting the switch to ZSTD_ps_enable
1317 * or ZSTD_ps_disable allow for a force enable/disable the feature.
1318 */
1319 ZSTD_ps_auto = 0, /* Let the library automatically determine whether the feature shall be enabled */
1320 ZSTD_ps_enable = 1, /* Force-enable the feature */
1321 ZSTD_ps_disable = 2 /* Do not use the feature */
1322} ZSTD_paramSwitch_e;
1323
1324/***************************************
1325* Frame size functions
1326***************************************/
1327
1349ZSTDLIB_STATIC_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize);
1350
1364ZSTDLIB_STATIC_API unsigned long long ZSTD_decompressBound(const void* src, size_t srcSize);
1365
1370ZSTDLIB_STATIC_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
1371
1372typedef enum {
1373 ZSTD_sf_noBlockDelimiters = 0, /* Representation of ZSTD_Sequence has no block delimiters, sequences only */
1374 ZSTD_sf_explicitBlockDelimiters = 1 /* Representation of ZSTD_Sequence contains explicit block delimiters */
1375} ZSTD_sequenceFormat_e;
1376
1393ZSTDLIB_STATIC_API size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
1394 size_t outSeqsSize, const void* src, size_t srcSize);
1395
1407ZSTDLIB_STATIC_API size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence* sequences, size_t seqsSize);
1408
1437ZSTDLIB_STATIC_API size_t ZSTD_compressSequences(ZSTD_CCtx* const cctx, void* dst, size_t dstSize,
1438 const ZSTD_Sequence* inSeqs, size_t inSeqsSize,
1439 const void* src, size_t srcSize);
1440
1441
1455ZSTDLIB_STATIC_API size_t ZSTD_writeSkippableFrame(void* dst, size_t dstCapacity,
1456 const void* src, size_t srcSize, unsigned magicVariant);
1457
1469ZSTDLIB_API size_t ZSTD_readSkippableFrame(void* dst, size_t dstCapacity, unsigned* magicVariant,
1470 const void* src, size_t srcSize);
1471
1475ZSTDLIB_API unsigned ZSTD_isSkippableFrame(const void* buffer, size_t size);
1476
1477
1478
1479/***************************************
1480* Memory management
1481***************************************/
1482
1506ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize(int compressionLevel);
1507ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams);
1508ZSTDLIB_STATIC_API size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params* params);
1509ZSTDLIB_STATIC_API size_t ZSTD_estimateDCtxSize(void);
1510
1524ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize(int compressionLevel);
1525ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams);
1526ZSTDLIB_STATIC_API size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params* params);
1527ZSTDLIB_STATIC_API size_t ZSTD_estimateDStreamSize(size_t windowSize);
1528ZSTDLIB_STATIC_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize);
1529
1535ZSTDLIB_STATIC_API size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel);
1536ZSTDLIB_STATIC_API size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, ZSTD_dictLoadMethod_e dictLoadMethod);
1537ZSTDLIB_STATIC_API size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod);
1538
1560ZSTDLIB_STATIC_API ZSTD_CCtx* ZSTD_initStaticCCtx(void* workspace, size_t workspaceSize);
1561ZSTDLIB_STATIC_API ZSTD_CStream* ZSTD_initStaticCStream(void* workspace, size_t workspaceSize);
1563ZSTDLIB_STATIC_API ZSTD_DCtx* ZSTD_initStaticDCtx(void* workspace, size_t workspaceSize);
1564ZSTDLIB_STATIC_API ZSTD_DStream* ZSTD_initStaticDStream(void* workspace, size_t workspaceSize);
1566ZSTDLIB_STATIC_API const ZSTD_CDict* ZSTD_initStaticCDict(
1567 void* workspace, size_t workspaceSize,
1568 const void* dict, size_t dictSize,
1569 ZSTD_dictLoadMethod_e dictLoadMethod,
1570 ZSTD_dictContentType_e dictContentType,
1571 ZSTD_compressionParameters cParams);
1572
1573ZSTDLIB_STATIC_API const ZSTD_DDict* ZSTD_initStaticDDict(
1574 void* workspace, size_t workspaceSize,
1575 const void* dict, size_t dictSize,
1576 ZSTD_dictLoadMethod_e dictLoadMethod,
1577 ZSTD_dictContentType_e dictContentType);
1578
1579
1585typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size);
1586typedef void (*ZSTD_freeFunction) (void* opaque, void* address);
1587typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem;
1588static
1589#ifdef __GNUC__
1590__attribute__((__unused__))
1591#endif
1592ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL };
1594ZSTDLIB_STATIC_API ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem);
1595ZSTDLIB_STATIC_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem);
1596ZSTDLIB_STATIC_API ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem);
1597ZSTDLIB_STATIC_API ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem);
1598
1599ZSTDLIB_STATIC_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictSize,
1600 ZSTD_dictLoadMethod_e dictLoadMethod,
1601 ZSTD_dictContentType_e dictContentType,
1602 ZSTD_compressionParameters cParams,
1603 ZSTD_customMem customMem);
1604
1615typedef struct POOL_ctx_s ZSTD_threadPool;
1616ZSTDLIB_STATIC_API ZSTD_threadPool* ZSTD_createThreadPool(size_t numThreads);
1617ZSTDLIB_STATIC_API void ZSTD_freeThreadPool (ZSTD_threadPool* pool); /* accept NULL pointer */
1618ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refThreadPool(ZSTD_CCtx* cctx, ZSTD_threadPool* pool);
1619
1620
1621/*
1622 * This API is temporary and is expected to change or disappear in the future!
1623 */
1624ZSTDLIB_STATIC_API ZSTD_CDict* ZSTD_createCDict_advanced2(
1625 const void* dict, size_t dictSize,
1626 ZSTD_dictLoadMethod_e dictLoadMethod,
1627 ZSTD_dictContentType_e dictContentType,
1628 const ZSTD_CCtx_params* cctxParams,
1629 ZSTD_customMem customMem);
1630
1631ZSTDLIB_STATIC_API ZSTD_DDict* ZSTD_createDDict_advanced(
1632 const void* dict, size_t dictSize,
1633 ZSTD_dictLoadMethod_e dictLoadMethod,
1634 ZSTD_dictContentType_e dictContentType,
1635 ZSTD_customMem customMem);
1636
1637
1638/***************************************
1639* Advanced compression functions
1640***************************************/
1641
1648ZSTDLIB_STATIC_API ZSTD_CDict* ZSTD_createCDict_byReference(const void* dictBuffer, size_t dictSize, int compressionLevel);
1649
1653ZSTDLIB_STATIC_API ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
1654
1658ZSTDLIB_STATIC_API ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
1659
1663ZSTDLIB_STATIC_API size_t ZSTD_checkCParams(ZSTD_compressionParameters params);
1664
1671ZSTDLIB_STATIC_API ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize);
1672
1677ZSTD_DEPRECATED("use ZSTD_compress2")
1679 void* dst, size_t dstCapacity,
1680 const void* src, size_t srcSize,
1681 const void* dict,size_t dictSize,
1682 ZSTD_parameters params);
1683
1690 void* dst, size_t dstCapacity,
1691 const void* src, size_t srcSize,
1692 const ZSTD_CDict* cdict,
1693 ZSTD_frameParameters fParams);
1694
1695
1699ZSTDLIB_STATIC_API size_t ZSTD_CCtx_loadDictionary_byReference(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
1700
1705ZSTDLIB_STATIC_API size_t ZSTD_CCtx_loadDictionary_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
1706
1710ZSTDLIB_STATIC_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
1711
1712/* === experimental parameters === */
1713/* these parameters can be used with ZSTD_setParameter()
1714 * they are not guaranteed to remain supported in the future */
1715
1716 /* Enables rsyncable mode,
1717 * which makes compressed files more rsync friendly
1718 * by adding periodic synchronization points to the compressed data.
1719 * The target average block size is ZSTD_c_jobSize / 2.
1720 * It's possible to modify the job size to increase or decrease
1721 * the granularity of the synchronization point.
1722 * Once the jobSize is smaller than the window size,
1723 * it will result in compression ratio degradation.
1724 * NOTE 1: rsyncable mode only works when multithreading is enabled.
1725 * NOTE 2: rsyncable performs poorly in combination with long range mode,
1726 * since it will decrease the effectiveness of synchronization points,
1727 * though mileage may vary.
1728 * NOTE 3: Rsyncable mode limits maximum compression speed to ~400 MB/s.
1729 * If the selected compression level is already running significantly slower,
1730 * the overall speed won't be significantly impacted.
1731 */
1732 #define ZSTD_c_rsyncable ZSTD_c_experimentalParam1
1733
1734/* Select a compression format.
1735 * The value must be of type ZSTD_format_e.
1736 * See ZSTD_format_e enum definition for details */
1737#define ZSTD_c_format ZSTD_c_experimentalParam2
1738
1739/* Force back-reference distances to remain < windowSize,
1740 * even when referencing into Dictionary content (default:0) */
1741#define ZSTD_c_forceMaxWindow ZSTD_c_experimentalParam3
1742
1743/* Controls whether the contents of a CDict
1744 * are used in place, or copied into the working context.
1745 * Accepts values from the ZSTD_dictAttachPref_e enum.
1746 * See the comments on that enum for an explanation of the feature. */
1747#define ZSTD_c_forceAttachDict ZSTD_c_experimentalParam4
1748
1749/* Controlled with ZSTD_paramSwitch_e enum.
1750 * Default is ZSTD_ps_auto.
1751 * Set to ZSTD_ps_disable to never compress literals.
1752 * Set to ZSTD_ps_enable to always compress literals. (Note: uncompressed literals
1753 * may still be emitted if huffman is not beneficial to use.)
1754 *
1755 * By default, in ZSTD_ps_auto, the library will decide at runtime whether to use
1756 * literals compression based on the compression parameters - specifically,
1757 * negative compression levels do not use literal compression.
1758 */
1759#define ZSTD_c_literalCompressionMode ZSTD_c_experimentalParam5
1760
1761/* Tries to fit compressed block size to be around targetCBlockSize.
1762 * No target when targetCBlockSize == 0.
1763 * There is no guarantee on compressed block size (default:0) */
1764#define ZSTD_c_targetCBlockSize ZSTD_c_experimentalParam6
1765
1766/* User's best guess of source size.
1767 * Hint is not valid when srcSizeHint == 0.
1768 * There is no guarantee that hint is close to actual source size,
1769 * but compression ratio may regress significantly if guess considerably underestimates */
1770#define ZSTD_c_srcSizeHint ZSTD_c_experimentalParam7
1771
1772/* Controls whether the new and experimental "dedicated dictionary search
1773 * structure" can be used. This feature is still rough around the edges, be
1774 * prepared for surprising behavior!
1775 *
1776 * How to use it:
1777 *
1778 * When using a CDict, whether to use this feature or not is controlled at
1779 * CDict creation, and it must be set in a CCtxParams set passed into that
1780 * construction (via ZSTD_createCDict_advanced2()). A compression will then
1781 * use the feature or not based on how the CDict was constructed; the value of
1782 * this param, set in the CCtx, will have no effect.
1783 *
1784 * However, when a dictionary buffer is passed into a CCtx, such as via
1785 * ZSTD_CCtx_loadDictionary(), this param can be set on the CCtx to control
1786 * whether the CDict that is created internally can use the feature or not.
1787 *
1788 * What it does:
1789 *
1790 * Normally, the internal data structures of the CDict are analogous to what
1791 * would be stored in a CCtx after compressing the contents of a dictionary.
1792 * To an approximation, a compression using a dictionary can then use those
1793 * data structures to simply continue what is effectively a streaming
1794 * compression where the simulated compression of the dictionary left off.
1795 * Which is to say, the search structures in the CDict are normally the same
1796 * format as in the CCtx.
1797 *
1798 * It is possible to do better, since the CDict is not like a CCtx: the search
1799 * structures are written once during CDict creation, and then are only read
1800 * after that, while the search structures in the CCtx are both read and
1801 * written as the compression goes along. This means we can choose a search
1802 * structure for the dictionary that is read-optimized.
1803 *
1804 * This feature enables the use of that different structure.
1805 *
1806 * Note that some of the members of the ZSTD_compressionParameters struct have
1807 * different semantics and constraints in the dedicated search structure. It is
1808 * highly recommended that you simply set a compression level in the CCtxParams
1809 * you pass into the CDict creation call, and avoid messing with the cParams
1810 * directly.
1811 *
1812 * Effects:
1813 *
1814 * This will only have any effect when the selected ZSTD_strategy
1815 * implementation supports this feature. Currently, that's limited to
1816 * ZSTD_greedy, ZSTD_lazy, and ZSTD_lazy2.
1817 *
1818 * Note that this means that the CDict tables can no longer be copied into the
1819 * CCtx, so the dict attachment mode ZSTD_dictForceCopy will no longer be
1820 * usable. The dictionary can only be attached or reloaded.
1821 *
1822 * In general, you should expect compression to be faster--sometimes very much
1823 * so--and CDict creation to be slightly slower. Eventually, we will probably
1824 * make this mode the default.
1825 */
1826#define ZSTD_c_enableDedicatedDictSearch ZSTD_c_experimentalParam8
1827
1828/* ZSTD_c_stableInBuffer
1829 * Experimental parameter.
1830 * Default is 0 == disabled. Set to 1 to enable.
1831 *
1832 * Tells the compressor that the ZSTD_inBuffer will ALWAYS be the same
1833 * between calls, except for the modifications that zstd makes to pos (the
1834 * caller must not modify pos). This is checked by the compressor, and
1835 * compression will fail if it ever changes. This means the only flush
1836 * mode that makes sense is ZSTD_e_end, so zstd will error if ZSTD_e_end
1837 * is not used. The data in the ZSTD_inBuffer in the range [src, src + pos)
1838 * MUST not be modified during compression or you will get data corruption.
1839 *
1840 * When this flag is enabled zstd won't allocate an input window buffer,
1841 * because the user guarantees it can reference the ZSTD_inBuffer until
1842 * the frame is complete. But, it will still allocate an output buffer
1843 * large enough to fit a block (see ZSTD_c_stableOutBuffer). This will also
1844 * avoid the memcpy() from the input buffer to the input window buffer.
1845 *
1846 * NOTE: ZSTD_compressStream2() will error if ZSTD_e_end is not used.
1847 * That means this flag cannot be used with ZSTD_compressStream().
1848 *
1849 * NOTE: So long as the ZSTD_inBuffer always points to valid memory, using
1850 * this flag is ALWAYS memory safe, and will never access out-of-bounds
1851 * memory. However, compression WILL fail if you violate the preconditions.
1852 *
1853 * WARNING: The data in the ZSTD_inBuffer in the range [dst, dst + pos) MUST
1854 * not be modified during compression or you will get data corruption. This
1855 * is because zstd needs to reference data in the ZSTD_inBuffer to find
1856 * matches. Normally zstd maintains its own window buffer for this purpose,
1857 * but passing this flag tells zstd to use the user provided buffer.
1858 */
1859#define ZSTD_c_stableInBuffer ZSTD_c_experimentalParam9
1860
1861/* ZSTD_c_stableOutBuffer
1862 * Experimental parameter.
1863 * Default is 0 == disabled. Set to 1 to enable.
1864 *
1865 * Tells he compressor that the ZSTD_outBuffer will not be resized between
1866 * calls. Specifically: (out.size - out.pos) will never grow. This gives the
1867 * compressor the freedom to say: If the compressed data doesn't fit in the
1868 * output buffer then return ZSTD_error_dstSizeTooSmall. This allows us to
1869 * always decompress directly into the output buffer, instead of decompressing
1870 * into an internal buffer and copying to the output buffer.
1871 *
1872 * When this flag is enabled zstd won't allocate an output buffer, because
1873 * it can write directly to the ZSTD_outBuffer. It will still allocate the
1874 * input window buffer (see ZSTD_c_stableInBuffer).
1875 *
1876 * Zstd will check that (out.size - out.pos) never grows and return an error
1877 * if it does. While not strictly necessary, this should prevent surprises.
1878 */
1879#define ZSTD_c_stableOutBuffer ZSTD_c_experimentalParam10
1880
1881/* ZSTD_c_blockDelimiters
1882 * Default is 0 == ZSTD_sf_noBlockDelimiters.
1883 *
1884 * For use with sequence compression API: ZSTD_compressSequences().
1885 *
1886 * Designates whether or not the given array of ZSTD_Sequence contains block delimiters
1887 * and last literals, which are defined as sequences with offset == 0 and matchLength == 0.
1888 * See the definition of ZSTD_Sequence for more specifics.
1889 */
1890#define ZSTD_c_blockDelimiters ZSTD_c_experimentalParam11
1891
1892/* ZSTD_c_validateSequences
1893 * Default is 0 == disabled. Set to 1 to enable sequence validation.
1894 *
1895 * For use with sequence compression API: ZSTD_compressSequences().
1896 * Designates whether or not we validate sequences provided to ZSTD_compressSequences()
1897 * during function execution.
1898 *
1899 * Without validation, providing a sequence that does not conform to the zstd spec will cause
1900 * undefined behavior, and may produce a corrupted block.
1901 *
1902 * With validation enabled, a if sequence is invalid (see doc/zstd_compression_format.md for
1903 * specifics regarding offset/matchlength requirements) then the function will bail out and
1904 * return an error.
1905 *
1906 */
1907#define ZSTD_c_validateSequences ZSTD_c_experimentalParam12
1908
1909/* ZSTD_c_useBlockSplitter
1910 * Controlled with ZSTD_paramSwitch_e enum.
1911 * Default is ZSTD_ps_auto.
1912 * Set to ZSTD_ps_disable to never use block splitter.
1913 * Set to ZSTD_ps_enable to always use block splitter.
1914 *
1915 * By default, in ZSTD_ps_auto, the library will decide at runtime whether to use
1916 * block splitting based on the compression parameters.
1917 */
1918#define ZSTD_c_useBlockSplitter ZSTD_c_experimentalParam13
1919
1920/* ZSTD_c_useRowMatchFinder
1921 * Controlled with ZSTD_paramSwitch_e enum.
1922 * Default is ZSTD_ps_auto.
1923 * Set to ZSTD_ps_disable to never use row-based matchfinder.
1924 * Set to ZSTD_ps_enable to force usage of row-based matchfinder.
1925 *
1926 * By default, in ZSTD_ps_auto, the library will decide at runtime whether to use
1927 * the row-based matchfinder based on support for SIMD instructions and the window log.
1928 * Note that this only pertains to compression strategies: greedy, lazy, and lazy2
1929 */
1930#define ZSTD_c_useRowMatchFinder ZSTD_c_experimentalParam14
1931
1932/* ZSTD_c_deterministicRefPrefix
1933 * Default is 0 == disabled. Set to 1 to enable.
1934 *
1935 * Zstd produces different results for prefix compression when the prefix is
1936 * directly adjacent to the data about to be compressed vs. when it isn't.
1937 * This is because zstd detects that the two buffers are contiguous and it can
1938 * use a more efficient match finding algorithm. However, this produces different
1939 * results than when the two buffers are non-contiguous. This flag forces zstd
1940 * to always load the prefix in non-contiguous mode, even if it happens to be
1941 * adjacent to the data, to guarantee determinism.
1942 *
1943 * If you really care about determinism when using a dictionary or prefix,
1944 * like when doing delta compression, you should select this option. It comes
1945 * at a speed penalty of about ~2.5% if the dictionary and data happened to be
1946 * contiguous, and is free if they weren't contiguous. We don't expect that
1947 * intentionally making the dictionary and data contiguous will be worth the
1948 * cost to memcpy() the data.
1949 */
1950#define ZSTD_c_deterministicRefPrefix ZSTD_c_experimentalParam15
1951
1957ZSTDLIB_STATIC_API size_t ZSTD_CCtx_getParameter(const ZSTD_CCtx* cctx, ZSTD_cParameter param, int* value);
1958
1959
1977ZSTDLIB_STATIC_API ZSTD_CCtx_params* ZSTD_createCCtxParams(void);
1978ZSTDLIB_STATIC_API size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params); /* accept NULL pointer */
1979
1983ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_reset(ZSTD_CCtx_params* params);
1984
1989ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_init(ZSTD_CCtx_params* cctxParams, int compressionLevel);
1990
1995ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params);
1996
2005ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, int value);
2006
2012ZSTDLIB_STATIC_API size_t ZSTD_CCtxParams_getParameter(const ZSTD_CCtx_params* params, ZSTD_cParameter param, int* value);
2013
2021ZSTDLIB_STATIC_API size_t ZSTD_CCtx_setParametersUsingCCtxParams(
2022 ZSTD_CCtx* cctx, const ZSTD_CCtx_params* params);
2023
2030ZSTDLIB_STATIC_API size_t ZSTD_compressStream2_simpleArgs (
2031 ZSTD_CCtx* cctx,
2032 void* dst, size_t dstCapacity, size_t* dstPos,
2033 const void* src, size_t srcSize, size_t* srcPos,
2034 ZSTD_EndDirective endOp);
2035
2036
2037/***************************************
2038* Advanced decompression functions
2039***************************************/
2040
2046ZSTDLIB_STATIC_API unsigned ZSTD_isFrame(const void* buffer, size_t size);
2047
2053ZSTDLIB_STATIC_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize);
2054
2060ZSTDLIB_STATIC_API size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
2061
2067ZSTDLIB_STATIC_API size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
2068
2072ZSTDLIB_STATIC_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
2073
2081ZSTDLIB_STATIC_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize);
2082
2088ZSTDLIB_STATIC_API size_t ZSTD_DCtx_getParameter(ZSTD_DCtx* dctx, ZSTD_dParameter param, int* value);
2089
2090/* ZSTD_d_format
2091 * experimental parameter,
2092 * allowing selection between ZSTD_format_e input compression formats
2093 */
2094#define ZSTD_d_format ZSTD_d_experimentalParam1
2095/* ZSTD_d_stableOutBuffer
2096 * Experimental parameter.
2097 * Default is 0 == disabled. Set to 1 to enable.
2098 *
2099 * Tells the decompressor that the ZSTD_outBuffer will ALWAYS be the same
2100 * between calls, except for the modifications that zstd makes to pos (the
2101 * caller must not modify pos). This is checked by the decompressor, and
2102 * decompression will fail if it ever changes. Therefore the ZSTD_outBuffer
2103 * MUST be large enough to fit the entire decompressed frame. This will be
2104 * checked when the frame content size is known. The data in the ZSTD_outBuffer
2105 * in the range [dst, dst + pos) MUST not be modified during decompression
2106 * or you will get data corruption.
2107 *
2108 * When this flags is enabled zstd won't allocate an output buffer, because
2109 * it can write directly to the ZSTD_outBuffer, but it will still allocate
2110 * an input buffer large enough to fit any compressed block. This will also
2111 * avoid the memcpy() from the internal output buffer to the ZSTD_outBuffer.
2112 * If you need to avoid the input buffer allocation use the buffer-less
2113 * streaming API.
2114 *
2115 * NOTE: So long as the ZSTD_outBuffer always points to valid memory, using
2116 * this flag is ALWAYS memory safe, and will never access out-of-bounds
2117 * memory. However, decompression WILL fail if you violate the preconditions.
2118 *
2119 * WARNING: The data in the ZSTD_outBuffer in the range [dst, dst + pos) MUST
2120 * not be modified during decompression or you will get data corruption. This
2121 * is because zstd needs to reference data in the ZSTD_outBuffer to regenerate
2122 * matches. Normally zstd maintains its own buffer for this purpose, but passing
2123 * this flag tells zstd to use the user provided buffer.
2124 */
2125#define ZSTD_d_stableOutBuffer ZSTD_d_experimentalParam2
2126
2127/* ZSTD_d_forceIgnoreChecksum
2128 * Experimental parameter.
2129 * Default is 0 == disabled. Set to 1 to enable
2130 *
2131 * Tells the decompressor to skip checksum validation during decompression, regardless
2132 * of whether checksumming was specified during compression. This offers some
2133 * slight performance benefits, and may be useful for debugging.
2134 * Param has values of type ZSTD_forceIgnoreChecksum_e
2135 */
2136#define ZSTD_d_forceIgnoreChecksum ZSTD_d_experimentalParam3
2137
2138/* ZSTD_d_refMultipleDDicts
2139 * Experimental parameter.
2140 * Default is 0 == disabled. Set to 1 to enable
2141 *
2142 * If enabled and dctx is allocated on the heap, then additional memory will be allocated
2143 * to store references to multiple ZSTD_DDict. That is, multiple calls of ZSTD_refDDict()
2144 * using a given ZSTD_DCtx, rather than overwriting the previous DDict reference, will instead
2145 * store all references. At decompression time, the appropriate dictID is selected
2146 * from the set of DDicts based on the dictID in the frame.
2147 *
2148 * Usage is simply calling ZSTD_refDDict() on multiple dict buffers.
2149 *
2150 * Param has values of byte ZSTD_refMultipleDDicts_e
2151 *
2152 * WARNING: Enabling this parameter and calling ZSTD_DCtx_refDDict(), will trigger memory
2153 * allocation for the hash table. ZSTD_freeDCtx() also frees this memory.
2154 * Memory is allocated as per ZSTD_DCtx::customMem.
2155 *
2156 * Although this function allocates memory for the table, the user is still responsible for
2157 * memory management of the underlying ZSTD_DDict* themselves.
2158 */
2159#define ZSTD_d_refMultipleDDicts ZSTD_d_experimentalParam4
2160
2161
2168ZSTD_DEPRECATED("use ZSTD_DCtx_setParameter() instead")
2169size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format);
2170
2177ZSTDLIB_STATIC_API size_t ZSTD_decompressStream_simpleArgs (
2178 ZSTD_DCtx* dctx,
2179 void* dst, size_t dstCapacity, size_t* dstPos,
2180 const void* src, size_t srcSize, size_t* srcPos);
2181
2182
2183/********************************************************************
2184* Advanced streaming functions
2185* Warning : most of these functions are now redundant with the Advanced API.
2186* Once Advanced API reaches "stable" status,
2187* redundant functions will be deprecated, and then at some point removed.
2188********************************************************************/
2189
2190/*===== Advanced Streaming compression functions =====*/
2191
2204ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
2206 int compressionLevel,
2207 unsigned long long pledgedSrcSize);
2208
2221ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
2223 const void* dict, size_t dictSize,
2224 int compressionLevel);
2225
2241ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
2243 const void* dict, size_t dictSize,
2244 ZSTD_parameters params,
2245 unsigned long long pledgedSrcSize);
2246
2255ZSTD_DEPRECATED("use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions")
2257
2273ZSTD_DEPRECATED("use ZSTD_CCtx_reset and ZSTD_CCtx_refCDict, see zstd.h for detailed instructions")
2275 const ZSTD_CDict* cdict,
2276 ZSTD_frameParameters fParams,
2277 unsigned long long pledgedSrcSize);
2278
2297ZSTD_DEPRECATED("use ZSTD_CCtx_reset, see zstd.h for detailed instructions")
2298size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize);
2299
2300
2301typedef struct {
2302 unsigned long long ingested; /* nb input bytes read and buffered */
2303 unsigned long long consumed; /* nb input bytes actually compressed */
2304 unsigned long long produced; /* nb of compressed bytes generated and buffered */
2305 unsigned long long flushed; /* nb of compressed bytes flushed : not provided; can be tracked from caller side */
2306 unsigned currentJobID; /* MT only : latest started job nb */
2307 unsigned nbActiveWorkers; /* MT only : nb of workers actively compressing at probe time */
2308} ZSTD_frameProgression;
2309
2310/* ZSTD_getFrameProgression() :
2311 * tells how much data has been ingested (read from input)
2312 * consumed (input actually compressed) and produced (output) for current frame.
2313 * Note : (ingested - consumed) is amount of input data buffered internally, not yet compressed.
2314 * Aggregates progression inside active worker threads.
2315 */
2316ZSTDLIB_STATIC_API ZSTD_frameProgression ZSTD_getFrameProgression(const ZSTD_CCtx* cctx);
2317
2331ZSTDLIB_STATIC_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx);
2332
2333
2334/*===== Advanced Streaming decompression functions =====*/
2335
2345ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize);
2346
2356ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict);
2357
2366ZSTDLIB_STATIC_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
2367
2368
2369/*********************************************************************
2370* Buffer-less and synchronous inner streaming functions
2371*
2372* This is an advanced API, giving full control over buffer management, for users which need direct control over memory.
2373* But it's also a complex one, with several restrictions, documented below.
2374* Prefer normal streaming API for an easier experience.
2375********************************************************************* */
2376
2407/*===== Buffer-less streaming compression functions =====*/
2408ZSTDLIB_STATIC_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
2409ZSTDLIB_STATIC_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
2410ZSTDLIB_STATIC_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
2411ZSTDLIB_STATIC_API size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize);
2413ZSTDLIB_STATIC_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
2414ZSTDLIB_STATIC_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
2415
2416/* The ZSTD_compressBegin_advanced() and ZSTD_compressBegin_usingCDict_advanced() are now DEPRECATED and will generate a compiler warning */
2417ZSTD_DEPRECATED("use advanced API to access custom parameters")
2418size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize);
2419ZSTD_DEPRECATED("use advanced API to access custom parameters")
2420size_t ZSTD_compressBegin_usingCDict_advanced(ZSTD_CCtx* const cctx, const ZSTD_CDict* const cdict, ZSTD_frameParameters const fParams, unsigned long long const pledgedSrcSize); /* compression parameters are already set within cdict. pledgedSrcSize must be correct. If srcSize is not known, use macro ZSTD_CONTENTSIZE_UNKNOWN */
2494/*===== Buffer-less streaming decompression functions =====*/
2495typedef enum { ZSTD_frame, ZSTD_skippableFrame } ZSTD_frameType_e;
2496typedef struct {
2497 unsigned long long frameContentSize; /* if == ZSTD_CONTENTSIZE_UNKNOWN, it means this field is not available. 0 means "empty" */
2498 unsigned long long windowSize; /* can be very large, up to <= frameContentSize */
2499 unsigned blockSizeMax;
2500 ZSTD_frameType_e frameType; /* if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */
2501 unsigned headerSize;
2502 unsigned dictID;
2503 unsigned checksumFlag;
2504} ZSTD_frameHeader;
2505
2511ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize);
2515ZSTDLIB_STATIC_API size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize, ZSTD_format_e format);
2516ZSTDLIB_STATIC_API size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize);
2518ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx);
2519ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
2520ZSTDLIB_STATIC_API size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
2521
2522ZSTDLIB_STATIC_API size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx);
2523ZSTDLIB_STATIC_API size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
2524
2525/* misc */
2526ZSTDLIB_STATIC_API void ZSTD_copyDCtx(ZSTD_DCtx* dctx, const ZSTD_DCtx* preparedDCtx);
2527typedef enum { ZSTDnit_frameHeader, ZSTDnit_blockHeader, ZSTDnit_block, ZSTDnit_lastBlock, ZSTDnit_checksum, ZSTDnit_skippableFrame } ZSTD_nextInputType_e;
2528ZSTDLIB_STATIC_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx);
2529
2530
2531
2532
2533/* ============================ */
2535/* ============================ */
2536
2564/*===== Raw zstd block functions =====*/
2565ZSTDLIB_STATIC_API size_t ZSTD_getBlockSize (const ZSTD_CCtx* cctx);
2566ZSTDLIB_STATIC_API size_t ZSTD_compressBlock (ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
2567ZSTDLIB_STATIC_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
2568ZSTDLIB_STATIC_API size_t ZSTD_insertBlock (ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize);
2571#endif /* ZSTD_H_ZSTD_STATIC_LINKING_ONLY */
2572
2573#if defined (__cplusplus)
2574}
2575#endif
char * dst
Definition lz4.h:833
char int srcSize
Definition lz4.h:806
char int compressedSize
Definition lz4.h:833
const char * src
Definition lz4.h:866
char int int compressionLevel
Definition lz4hc.h:286
#define __attribute__(unused_ric_since_2004)
Definition main_cr.c:84
#define input(b, o, c, n, m)
Definition compress42.c:610
#define output(b, o, c, n)
Definition compress42.c:592
Definition pool.c:310
Definition zstd_compress_internal.h:278
Definition zstd_compress_internal.h:358
Definition zstd_compress.c:75
Definition zstd_decompress_internal.h:126
Definition zstd_ddict.c:36
void * dictBuffer
Definition zstd_ddict.c:37
Definition zstd.h:445
int upperBound
Definition zstd.h:448
int lowerBound
Definition zstd.h:447
size_t error
Definition zstd.h:446
Definition zstd.h:596
const void * src
Definition zstd.h:597
size_t pos
Definition zstd.h:599
size_t size
Definition zstd.h:598
Definition zstd.h:602
void * dst
Definition zstd.h:603
size_t pos
Definition zstd.h:605
size_t size
Definition zstd.h:604
Definition zstd_v04.c:255
Definition inftrees.h:24
size_t size
Definition platform.h:559
#define const
Definition zconf.h:230
#define h(i)
Definition sha256.c:48
#define NULL
Definition getopt1.c:37
for(;;)
Definition zlib_interface.c:93
md5_starts & ctx
Definition zlib_interface.c:41
#define ZSTD_isError
Definition zstd_internal.h:49
size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx *cctx, const void *dict, size_t dictSize, int compressionLevel)
Definition zstd_compress.c:4568
size_t ZSTD_compressStream2_simpleArgs(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, size_t *dstPos, const void *src, size_t srcSize, size_t *srcPos, ZSTD_EndDirective endOp)
Definition zstd_compress.c:5707
size_t ZSTD_initCStream_usingCDict(ZSTD_CStream *zcs, const ZSTD_CDict *cdict)
Definition zstd_compress.c:5251
size_t ZSTD_getBlockSize(const ZSTD_CCtx *cctx)
Definition zstd_compress.c:4181
size_t ZSTD_writeSkippableFrame(void *dst, size_t dstCapacity, const void *src, size_t srcSize, unsigned magicVariant)
Definition zstd_compress.c:4066
ZSTD_CCtx * ZSTD_createCCtx_advanced(ZSTD_customMem customMem)
Definition zstd_compress.c:109
size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams)
Definition zstd_compress.c:1518
size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params *params)
Definition zstd_compress.c:319
size_t ZSTD_compressBegin(ZSTD_CCtx *cctx, int compressionLevel)
Definition zstd_compress.c:4580
size_t ZSTD_compressBlock(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
Definition zstd_compress.c:4188
size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams)
Definition zstd_compress.c:1232
size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx *cctx, const ZSTD_CDict *cdict)
Definition zstd_compress.c:5107
ZSTD_CStream * ZSTD_initStaticCStream(void *workspace, size_t workspaceSize)
Definition zstd_compress.c:5162
size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params *params)
Definition zstd_compress.c:1560
size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence *sequences, size_t seqsSize)
Definition zstd_compress.c:2979
ZSTD_CDict * ZSTD_createCDict_byReference(const void *dict, size_t dictSize, int compressionLevel)
Definition zstd_compress.c:4955
size_t ZSTD_estimateCCtxSize(int compressionLevel)
Definition zstd_compress.c:1548
size_t ZSTD_CCtxParams_getParameter(ZSTD_CCtx_params const *CCtxParams, ZSTD_cParameter param, int *value)
Definition zstd_compress.c:929
ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long srcSizeHint, size_t dictSize)
Definition zstd_compress.c:6300
ZSTD_CCtx * ZSTD_initStaticCCtx(void *workspace, size_t workspaceSize)
Definition zstd_compress.c:121
size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream *zcs, const ZSTD_CDict *cdict, ZSTD_frameParameters fParams, unsigned long long pledgedSrcSize)
Definition zstd_compress.c:5237
size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, ZSTD_dictLoadMethod_e dictLoadMethod)
Definition zstd_compress.c:4758
size_t ZSTD_CCtxParams_init(ZSTD_CCtx_params *cctxParams, int compressionLevel)
Definition zstd_compress.c:331
size_t ZSTD_compressSequences(ZSTD_CCtx *const cctx, void *dst, size_t dstCapacity, const ZSTD_Sequence *inSeqs, size_t inSeqsSize, const void *src, size_t srcSize)
Definition zstd_compress.c:6114
ZSTD_CCtx_params * ZSTD_createCCtxParams(void)
Definition zstd_compress.c:314
size_t ZSTD_CCtx_loadDictionary_byReference(ZSTD_CCtx *cctx, const void *dict, size_t dictSize)
Definition zstd_compress.c:1158
size_t ZSTD_toFlushNow(ZSTD_CCtx *cctx)
Definition zstd_compress.c:1642
size_t ZSTD_compressEnd(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
Definition zstd_compress.c:4652
ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize)
Definition zstd_compress.c:1376
ZSTD_CStream * ZSTD_createCStream_advanced(ZSTD_customMem customMem)
Definition zstd_compress.c:5167
size_t ZSTD_initCStream_usingDict(ZSTD_CStream *zcs, const void *dict, size_t dictSize, int compressionLevel)
Definition zstd_compress.c:5282
size_t ZSTD_compressBegin_advanced(ZSTD_CCtx *cctx, const void *dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize)
Definition zstd_compress.c:4556
size_t ZSTD_CCtx_setParametersUsingCCtxParams(ZSTD_CCtx *cctx, const ZSTD_CCtx_params *params)
Definition zstd_compress.c:1064
size_t ZSTD_compressContinue(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
Definition zstd_compress.c:4172
size_t ZSTD_initCStream_srcSize(ZSTD_CStream *zcs, int compressionLevel, unsigned long long pss)
Definition zstd_compress.c:5291
ZSTD_frameProgression ZSTD_getFrameProgression(const ZSTD_CCtx *cctx)
Definition zstd_compress.c:1618
size_t ZSTD_generateSequences(ZSTD_CCtx *zc, ZSTD_Sequence *outSeqs, size_t outSeqsSize, const void *src, size_t srcSize)
Definition zstd_compress.c:2959
size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams)
Definition zstd_compress.c:1580
size_t ZSTD_compress_advanced(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const void *dict, size_t dictSize, ZSTD_parameters params)
Definition zstd_compress.c:4678
size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params *CCtxParams, ZSTD_cParameter param, int value)
Definition zstd_compress.c:701
size_t ZSTD_CCtx_refThreadPool(ZSTD_CCtx *cctx, ZSTD_threadPool *pool)
Definition zstd_compress.c:1182
size_t ZSTD_copyCCtx(ZSTD_CCtx *dstCCtx, const ZSTD_CCtx *srcCCtx, unsigned long long pledgedSrcSize)
Definition zstd_compress.c:2286
size_t ZSTD_estimateCStreamSize(int compressionLevel)
Definition zstd_compress.c:1603
size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params *params)
Definition zstd_compress.c:1503
ZSTD_CDict * ZSTD_createCDict_advanced(const void *dictBuffer, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType, ZSTD_compressionParameters cParams, ZSTD_customMem customMem)
Definition zstd_compress.c:4877
ZSTD_CDict * ZSTD_createCDict_advanced2(const void *dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType, const ZSTD_CCtx_params *originalCctxParams, ZSTD_customMem customMem)
Definition zstd_compress.c:4894
size_t ZSTD_CCtxParams_reset(ZSTD_CCtx_params *params)
Definition zstd_compress.c:326
size_t ZSTD_resetCStream(ZSTD_CStream *zcs, unsigned long long pss)
Definition zstd_compress.c:5198
size_t ZSTD_CCtx_getParameter(ZSTD_CCtx const *cctx, ZSTD_cParameter param, int *value)
Definition zstd_compress.c:924
size_t ZSTD_CCtx_loadDictionary_advanced(ZSTD_CCtx *cctx, const void *dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType)
Definition zstd_compress.c:1131
size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx *cctx, const void *prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType)
Definition zstd_compress.c:1195
size_t ZSTD_compressBegin_usingCDict_advanced(ZSTD_CCtx *const cctx, const ZSTD_CDict *const cdict, ZSTD_frameParameters const fParams, unsigned long long const pledgedSrcSize)
Definition zstd_compress.c:5098
const ZSTD_CDict * ZSTD_initStaticCDict(void *workspace, size_t workspaceSize, const void *dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType, ZSTD_compressionParameters cParams)
Definition zstd_compress.c:4992
size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel)
Definition zstd_compress.c:4773
size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const ZSTD_CDict *cdict, ZSTD_frameParameters fParams)
Definition zstd_compress.c:5128
ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long srcSizeHint, size_t dictSize)
Definition zstd_compress.c:6324
size_t ZSTD_initCStream_advanced(ZSTD_CStream *zcs, const void *dict, size_t dictSize, ZSTD_parameters params, unsigned long long pss)
Definition zstd_compress.c:5264
size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params *cctxParams, ZSTD_parameters params)
Definition zstd_compress.c:362
ZSTD_DDict * ZSTD_createDDict_advanced(const void *dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType, ZSTD_customMem customMem)
Definition zstd_ddict.c:145
size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod)
Definition zstd_ddict.c:225
const ZSTD_DDict * ZSTD_initStaticDDict(void *sBuffer, size_t sBufferSize, const void *dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType)
Definition zstd_ddict.c:187
ZSTD_DDict * ZSTD_createDDict_byReference(const void *dictBuffer, size_t dictSize)
Definition zstd_ddict.c:180
size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx *dctx, const void *dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType)
Definition zstd_decompress.c:1576
size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize)
Definition zstd_decompress.c:1819
size_t ZSTD_DCtx_getParameter(ZSTD_DCtx *dctx, ZSTD_dParameter param, int *value)
Definition zstd_decompress.c:1741
size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx *dctx, const void *dict, size_t dictSize)
Definition zstd_decompress.c:1592
size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx *dctx, const ZSTD_DDict *ddict)
Definition zstd_decompress.c:1478
ZSTD_DCtx * ZSTD_initStaticDCtx(void *workspace, size_t workspaceSize)
Definition zstd_decompress.c:272
size_t ZSTD_estimateDStreamSize_fromFrame(const void *src, size_t srcSize)
Definition zstd_decompress.c:1839
ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx *dctx)
Definition zstd_decompress.c:1124
size_t ZSTD_decompressBegin(ZSTD_DCtx *dctx)
Definition zstd_decompress.c:1438
size_t ZSTD_estimateDCtxSize(void)
Definition zstd_decompress.c:223
ZSTD_DStream * ZSTD_createDStream_advanced(ZSTD_customMem customMem)
Definition zstd_decompress.c:1560
size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx *dctx)
Definition zstd_decompress.c:1104
ZSTDLIB_API size_t ZSTD_readSkippableFrame(void *dst, size_t dstCapacity, unsigned *magicVariant, const void *src, size_t srcSize)
Definition zstd_decompress.c:580
size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader *zfhPtr, const void *src, size_t srcSize, ZSTD_format_e format)
Definition zstd_decompress.c:438
ZSTD_DStream * ZSTD_initStaticDStream(void *workspace, size_t workspaceSize)
Definition zstd_decompress.c:1555
void ZSTD_copyDCtx(ZSTD_DCtx *dstDCtx, const ZSTD_DCtx *srcDCtx)
Definition zstd_decompress.c:337
size_t ZSTD_decompressContinue(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
Definition zstd_decompress.c:1155
size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx *dctx, const void *prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType)
Definition zstd_decompress.c:1602
size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx *dctx, const void *dict, size_t dictSize)
Definition zstd_decompress.c:1465
size_t ZSTD_resetDStream(ZSTD_DStream *dctx)
Definition zstd_decompress.c:1646
unsigned ZSTD_isSkippableFrame(const void *buffer, size_t size)
Definition zstd_decompress.c:393
size_t ZSTD_DCtx_setFormat(ZSTD_DCtx *dctx, ZSTD_format_e format)
Definition zstd_decompress.c:1689
size_t ZSTD_frameHeaderSize(const void *src, size_t srcSize)
Definition zstd_decompress.c:426
size_t ZSTD_estimateDStreamSize(size_t windowSize)
Definition zstd_decompress.c:1831
unsigned long long ZSTD_findDecompressedSize(const void *src, size_t srcSize)
Definition zstd_decompress.c:605
size_t ZSTD_initDStream_usingDDict(ZSTD_DStream *dctx, const ZSTD_DDict *ddict)
Definition zstd_decompress.c:1636
size_t ZSTD_getFrameHeader(ZSTD_frameHeader *zfhPtr, const void *src, size_t srcSize)
Definition zstd_decompress.c:524
size_t ZSTD_initDStream_usingDict(ZSTD_DStream *zds, const void *dict, size_t dictSize)
Definition zstd_decompress.c:1618
unsigned ZSTD_isFrame(const void *buffer, size_t size)
Definition zstd_decompress.c:376
size_t ZSTD_decompressStream_simpleArgs(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, size_t *dstPos, const void *src, size_t srcSize, size_t *srcPos)
Definition zstd_decompress.c:2214
size_t ZSTD_insertBlock(ZSTD_DCtx *dctx, const void *blockStart, size_t blockSize)
Definition zstd_decompress.c:806
unsigned long long ZSTD_decompressBound(const void *src, size_t srcSize)
Definition zstd_decompress.c:781
ZSTD_DCtx * ZSTD_createDCtx_advanced(ZSTD_customMem customMem)
Definition zstd_decompress.c:296
size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx *dctx, size_t maxWindowSize)
Definition zstd_decompress.c:1677
size_t ZSTD_decompressBlock(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
Definition zstd_decompress_block.c:2063
const void * dict
Definition zbuff.h:76
const void size_t dictSize
Definition zbuff.h:76
ZSTD_strategy
Definition zstd_v04.c:252
ZSTDLIB_API size_t ZSTD_decompress(void *dst, size_t dstCapacity, const void *src, size_t compressedSize)
Definition emscripten.c:316
ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void *src, size_t srcSize)
Definition zstd_decompress.c:654
ZSTDLIB_API size_t ZSTD_compressBound(size_t srcSize)
Definition roundtrip.c:2766
ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
Definition zstd_decompress.c:1077
ZSTDLIB_API size_t ZSTD_initCStream(ZSTD_CStream *zcs, int compressionLevel)
Definition zstd_compress.c:5306
ZSTDLIB_API size_t ZSTD_decompress_usingDDict(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const ZSTD_DDict *ddict)
Definition zstd_decompress.c:1533
ZSTDLIB_API size_t ZSTD_compress(void *dst, size_t dstCapacity, const void *src, size_t srcSize, int compressionLevel)
Definition roundtrip.c:2772
struct ZSTD_inBuffer_s ZSTD_inBuffer
ZSTDLIB_API size_t ZSTD_DCtx_setParameter(ZSTD_DCtx *dctx, ZSTD_dParameter param, int value)
Definition zstd_decompress.c:1764
ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream *zds)
Definition zstd_decompress.c:1627
ZSTDLIB_API ZSTD_DDict * ZSTD_createDDict(const void *dictBuffer, size_t dictSize)
Definition zstd_ddict.c:170
ZSTDLIB_API size_t ZSTD_CStreamInSize(void)
Definition zstd_compress.c:5181
ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, int compressionLevel)
Definition zstd_compress.c:4724
ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx *cctx, const void *dict, size_t dictSize)
Definition zstd_compress.c:1165
ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream *zcs)
Definition zstd_compress.c:212
ZSTDLIB_API size_t ZSTD_compress2(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
Definition zstd_compress.c:5722
ZSTD_cParameter
Definition zstd.h:271
@ ZSTD_c_ldmHashRateLog
Definition zstd.h:359
@ ZSTD_c_checksumFlag
Definition zstd.h:371
@ ZSTD_c_ldmHashLog
Definition zstd.h:345
@ ZSTD_c_experimentalParam2
Definition zstd.h:429
@ ZSTD_c_jobSize
Definition zstd.h:389
@ ZSTD_c_experimentalParam8
Definition zstd.h:435
@ ZSTD_c_chainLog
Definition zstd.h:304
@ ZSTD_c_hashLog
Definition zstd.h:298
@ ZSTD_c_dictIDFlag
Definition zstd.h:372
@ ZSTD_c_strategy
Definition zstd.h:332
@ ZSTD_c_windowLog
Definition zstd.h:290
@ ZSTD_c_experimentalParam14
Definition zstd.h:441
@ ZSTD_c_experimentalParam4
Definition zstd.h:431
@ ZSTD_c_experimentalParam1
Definition zstd.h:428
@ ZSTD_c_experimentalParam3
Definition zstd.h:430
@ ZSTD_c_experimentalParam11
Definition zstd.h:438
@ ZSTD_c_experimentalParam12
Definition zstd.h:439
@ ZSTD_c_contentSizeFlag
Definition zstd.h:367
@ ZSTD_c_overlapLog
Definition zstd.h:394
@ ZSTD_c_enableLongDistanceMatching
Definition zstd.h:337
@ ZSTD_c_searchLog
Definition zstd.h:312
@ ZSTD_c_compressionLevel
Definition zstd.h:277
@ ZSTD_c_targetLength
Definition zstd.h:324
@ ZSTD_c_minMatch
Definition zstd.h:316
@ ZSTD_c_nbWorkers
Definition zstd.h:380
@ ZSTD_c_experimentalParam9
Definition zstd.h:436
@ ZSTD_c_experimentalParam5
Definition zstd.h:432
@ ZSTD_c_experimentalParam6
Definition zstd.h:433
@ ZSTD_c_ldmBucketSizeLog
Definition zstd.h:355
@ ZSTD_c_experimentalParam7
Definition zstd.h:434
@ ZSTD_c_experimentalParam13
Definition zstd.h:440
@ ZSTD_c_experimentalParam15
Definition zstd.h:442
@ ZSTD_c_experimentalParam10
Definition zstd.h:437
@ ZSTD_c_ldmMinMatch
Definition zstd.h:351
ZSTDLIB_API size_t ZSTD_compressStream2(ZSTD_CCtx *cctx, ZSTD_outBuffer *output, ZSTD_inBuffer *input, ZSTD_EndDirective endOp)
Definition zstd_compress.c:5634
ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream *zds)
Definition zstd_decompress.c:1814
ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx *dctx)
Definition zstd_decompress.c:315
ZSTDLIB_API size_t ZSTD_DStreamOutSize(void)
Definition zstd_decompress.c:1574
ZSTDLIB_API size_t ZSTD_DStreamInSize(void)
Definition zstd_decompress.c:1573
ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize)
Definition zstd_decompress.c:534
ZSTDLIB_API size_t ZSTD_compress_usingCDict(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const ZSTD_CDict *cdict)
Definition zstd_compress.c:5141
ZSTDLIB_API int ZSTD_minCLevel(void)
Definition zstd_compress.c:6187
ZSTDLIB_API size_t ZSTD_compressStream(ZSTD_CStream *zcs, ZSTD_outBuffer *output, ZSTD_inBuffer *input)
Definition zstd_compress.c:5507
ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx *cctx)
Definition zstd_compress.c:175
ZSTDLIB_API size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx *dctx, const void *prefix, size_t prefixSize)
Definition zstd_decompress.c:1609
ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void *src, size_t srcSize)
Definition zstd_decompress.c:769
ZSTDLIB_API size_t ZSTD_compress_usingDict(ZSTD_CCtx *ctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const void *dict, size_t dictSize, int compressionLevel)
Definition zstd_compress.c:4709
ZSTDLIB_API ZSTD_DCtx * ZSTD_createDCtx(void)
Definition zstd_decompress.c:301
ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict *CDict)
Definition zstd_compress.c:4966
ZSTD_CCtx ZSTD_CStream
Definition zstd.h:671
ZSTDLIB_API int ZSTD_defaultCLevel(void)
Definition zstd_compress.c:6188
ZSTD_dParameter
Definition zstd.h:539
@ ZSTD_d_experimentalParam1
Definition zstd.h:558
@ ZSTD_d_experimentalParam3
Definition zstd.h:560
@ ZSTD_d_windowLogMax
Definition zstd.h:541
@ ZSTD_d_experimentalParam2
Definition zstd.h:559
@ ZSTD_d_experimentalParam4
Definition zstd.h:561
ZSTDLIB_API size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx *dctx)
Definition zstd_decompress.c:215
ZSTD_EndDirective
Definition zstd.h:678
@ ZSTD_e_flush
Definition zstd.h:680
@ ZSTD_e_continue
Definition zstd.h:679
@ ZSTD_e_end
Definition zstd.h:684
ZSTDLIB_API size_t ZSTD_sizeof_CDict(const ZSTD_CDict *cdict)
Definition zstd_compress.c:4779
ZSTD_strategy
Definition zstd.h:258
@ ZSTD_btlazy2
Definition zstd.h:263
@ ZSTD_lazy
Definition zstd.h:261
@ ZSTD_btultra
Definition zstd.h:265
@ ZSTD_greedy
Definition zstd.h:260
@ ZSTD_dfast
Definition zstd.h:259
@ ZSTD_fast
Definition zstd.h:258
@ ZSTD_lazy2
Definition zstd.h:262
@ ZSTD_btopt
Definition zstd.h:264
@ ZSTD_btultra2
Definition zstd.h:266
ZSTDLIB_API unsigned ZSTD_getDictID_fromCDict(const ZSTD_CDict *cdict)
Definition zstd_compress.c:5048
ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream *zcs)
Definition zstd_compress.c:5172
struct ZSTD_outBuffer_s ZSTD_outBuffer
ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx *dctx, const void *dict, size_t dictSize)
Definition zstd_decompress.c:1597
ZSTDLIB_API size_t ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inBuffer *input)
Definition zstd_decompress.c:1924
ZSTDLIB_API size_t ZSTD_DCtx_reset(ZSTD_DCtx *dctx, ZSTD_ResetDirective reset)
Definition zstd_decompress.c:1797
ZSTDLIB_API ZSTD_CDict * ZSTD_createCDict(const void *dictBuffer, size_t dictSize, int compressionLevel)
Definition zstd_compress.c:4944
ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict *ddict)
Definition zstd_ddict.c:212
ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx *cctx)
Definition zstd_compress.c:202
ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx *cctx, const void *prefix, size_t prefixSize)
Definition zstd_compress.c:1190
#define ZSTDLIB_API
Definition zstd.h:37
ZSTDLIB_API size_t ZSTD_CCtx_setParameter(ZSTD_CCtx *cctx, ZSTD_cParameter param, int value)
Definition zstd_compress.c:644
ZSTDLIB_API size_t ZSTD_flushStream(ZSTD_CStream *zcs, ZSTD_outBuffer *output)
Definition zstd_compress.c:6160
ZSTDLIB_API unsigned ZSTD_getDictID_fromDict(const void *dict, size_t dictSize)
Definition zstd_decompress.c:1501
ZSTDLIB_API const char * ZSTD_getErrorName(size_t code)
Definition zstd_common.c:41
ZSTDLIB_API ZSTD_DStream * ZSTD_createDStream(void)
Definition zstd_decompress.c:1549
ZSTDLIB_API size_t ZSTD_decompress_usingDict(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const void *dict, size_t dictSize)
Definition zstd_decompress.c:1051
ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void *src, size_t srcSize)
Definition zstd_decompress.c:1521
ZSTDLIB_API ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter cParam)
Definition zstd_compress.c:386
ZSTD_DCtx ZSTD_DStream
Definition zstd.h:792
ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict *ddict)
Definition zstd_ddict.c:240
ZSTDLIB_API size_t ZSTD_CCtx_reset(ZSTD_CCtx *cctx, ZSTD_ResetDirective reset)
Definition zstd_compress.c:1211
ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx *cctx, const ZSTD_CDict *cdict)
Definition zstd_compress.c:1172
ZSTDLIB_API ZSTD_CStream * ZSTD_createCStream(void)
Definition zstd_compress.c:5156
ZSTDLIB_API size_t ZSTD_endStream(ZSTD_CStream *zcs, ZSTD_outBuffer *output)
Definition zstd_compress.c:6167
ZSTDLIB_API ZSTD_bounds ZSTD_dParam_getBounds(ZSTD_dParameter dParam)
Definition zstd_decompress.c:1694
ZSTD_ResetDirective
Definition zstd.h:490
@ ZSTD_reset_session_only
Definition zstd.h:491
@ ZSTD_reset_parameters
Definition zstd.h:492
@ ZSTD_reset_session_and_parameters
Definition zstd.h:493
ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream *zds)
Definition zstd_decompress.c:1565
ZSTDLIB_API const char * ZSTD_versionString(void)
Definition zstd_common.c:27
ZSTDLIB_API unsigned ZSTD_versionNumber(void)
Definition zstd_common.c:25
ZSTDLIB_API size_t ZSTD_CStreamOutSize(void)
Definition zstd_compress.c:5183
ZSTDLIB_API size_t ZSTD_DCtx_refDDict(ZSTD_DCtx *dctx, const ZSTD_DDict *ddict)
Definition zstd_decompress.c:1653
ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict *ddict)
Definition zstd_ddict.c:230
ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx *cctx, unsigned long long pledgedSrcSize)
Definition zstd_compress.c:1078
ZSTDLIB_API ZSTD_CCtx * ZSTD_createCCtx(void)
Definition zstd_compress.c:92
ZSTDLIB_API int ZSTD_maxCLevel(void)
Definition roundtrip.c:2769
#define ZSTD_DEPRECATED(message)
Definition zstd.h:68