ReactOS  0.4.15-dev-5463-g138eb58
zstd.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2020, 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)
11 extern "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_VISIBILITY
24 # if defined(__GNUC__) && (__GNUC__ >= 4)
25 # define ZSTDLIB_VISIBILITY __attribute__ ((visibility ("default")))
26 # else
27 # define ZSTDLIB_VISIBILITY
28 # endif
29 #endif
30 #if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
31 # define ZSTDLIB_API __declspec(dllexport) ZSTDLIB_VISIBILITY
32 #elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
33 # define ZSTDLIB_API __declspec(dllimport) ZSTDLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
34 #else
35 # define ZSTDLIB_API ZSTDLIB_VISIBILITY
36 #endif
37 
38 
39 /*******************************************************************************
40  Introduction
41 
42  zstd, short for Zstandard, is a fast lossless compression algorithm, targeting
43  real-time compression scenarios at zlib-level and better compression ratios.
44  The zstd compression library provides in-memory compression and decompression
45  functions.
46 
47  The library supports regular compression levels from 1 up to ZSTD_maxCLevel(),
48  which is currently 22. Levels >= 20, labeled `--ultra`, should be used with
49  caution, as they require more memory. The library also offers negative
50  compression levels, which extend the range of speed vs. ratio preferences.
51  The lower the level, the faster the speed (at the cost of compression).
52 
53  Compression can be done in:
54  - a single step (described as Simple API)
55  - a single step, reusing a context (described as Explicit context)
56  - unbounded multiple steps (described as Streaming compression)
57 
58  The compression ratio achievable on small data can be highly improved using
59  a dictionary. Dictionary compression can be performed in:
60  - a single step (described as Simple dictionary API)
61  - a single step, reusing a dictionary (described as Bulk-processing
62  dictionary API)
63 
64  Advanced experimental functions can be accessed using
65  `#define ZSTD_STATIC_LINKING_ONLY` before including zstd.h.
66 
67  Advanced experimental APIs should never be used with a dynamically-linked
68  library. They are not "stable"; their definitions or signatures may change in
69  the future. Only static linking is allowed.
70 *******************************************************************************/
71 
72 /*------ Version ------*/
73 #define ZSTD_VERSION_MAJOR 1
74 #define ZSTD_VERSION_MINOR 4
75 #define ZSTD_VERSION_RELEASE 5
76 
77 #define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
78 ZSTDLIB_API unsigned ZSTD_versionNumber(void);
80 #define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE
81 #define ZSTD_QUOTE(str) #str
82 #define ZSTD_EXPAND_AND_QUOTE(str) ZSTD_QUOTE(str)
83 #define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_LIB_VERSION)
84 ZSTDLIB_API const char* ZSTD_versionString(void); /* requires v1.3.0+ */
85 
86 /* *************************************
87  * Default constant
88  ***************************************/
89 #ifndef ZSTD_CLEVEL_DEFAULT
90 # define ZSTD_CLEVEL_DEFAULT 3
91 #endif
92 
93 /* *************************************
94  * Constants
95  ***************************************/
96 
97 /* All magic numbers are supposed read/written to/from files/memory using little-endian convention */
98 #define ZSTD_MAGICNUMBER 0xFD2FB528 /* valid since v0.8.0 */
99 #define ZSTD_MAGIC_DICTIONARY 0xEC30A437 /* valid since v0.7.0 */
100 #define ZSTD_MAGIC_SKIPPABLE_START 0x184D2A50 /* all 16 values, from 0x184D2A50 to 0x184D2A5F, signal the beginning of a skippable frame */
101 #define ZSTD_MAGIC_SKIPPABLE_MASK 0xFFFFFFF0
102 
103 #define ZSTD_BLOCKSIZELOG_MAX 17
104 #define ZSTD_BLOCKSIZE_MAX (1<<ZSTD_BLOCKSIZELOG_MAX)
105 
106 
107 
108 /***************************************
109 * Simple API
110 ***************************************/
116 ZSTDLIB_API size_t ZSTD_compress( void* dst, size_t dstCapacity,
117  const void* src, size_t srcSize,
118  int compressionLevel);
119 
126 ZSTDLIB_API size_t ZSTD_decompress( void* dst, size_t dstCapacity,
127  const void* src, size_t compressedSize);
128 
152 #define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
153 #define ZSTD_CONTENTSIZE_ERROR (0ULL - 2)
154 ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize);
155 
162 ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize);
163 
170 ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize);
171 
172 
173 /*====== Helper functions ======*/
174 #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 */
175 ZSTDLIB_API size_t ZSTD_compressBound(size_t srcSize);
176 ZSTDLIB_API unsigned ZSTD_isError(size_t code);
177 ZSTDLIB_API const char* ZSTD_getErrorName(size_t code);
178 ZSTDLIB_API int ZSTD_minCLevel(void);
179 ZSTDLIB_API int ZSTD_maxCLevel(void);
182 /***************************************
183 * Explicit context
184 ***************************************/
185 /*= Compression context
186  * When compressing many times,
187  * it is recommended to allocate a context just once,
188  * and re-use it for each successive compression operation.
189  * This will make workload friendlier for system's memory.
190  * Note : re-using context is just a speed / resource optimization.
191  * It doesn't change the compression ratio, which remains identical.
192  * Note 2 : In multi-threaded environments,
193  * use one different context per thread for parallel execution.
194  */
195 typedef struct ZSTD_CCtx_s ZSTD_CCtx;
197 ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx);
198 
208  void* dst, size_t dstCapacity,
209  const void* src, size_t srcSize,
210  int compressionLevel);
211 
212 /*= Decompression context
213  * When decompressing many times,
214  * it is recommended to allocate a context only once,
215  * and re-use it for each successive compression operation.
216  * This will make workload friendlier for system's memory.
217  * Use one context per thread for parallel execution. */
218 typedef struct ZSTD_DCtx_s ZSTD_DCtx;
220 ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);
221 
228  void* dst, size_t dstCapacity,
229  const void* src, size_t srcSize);
230 
231 
232 /***************************************
233 * Advanced compression API
234 ***************************************/
235 
236 /* API design :
237  * Parameters are pushed one by one into an existing context,
238  * using ZSTD_CCtx_set*() functions.
239  * Pushed parameters are sticky : they are valid for next compressed frame, and any subsequent frame.
240  * "sticky" parameters are applicable to `ZSTD_compress2()` and `ZSTD_compressStream*()` !
241  * __They do not apply to "simple" one-shot variants such as ZSTD_compressCCtx()__ .
242  *
243  * It's possible to reset all parameters to "default" using ZSTD_CCtx_reset().
244  *
245  * This API supercedes all other "advanced" API entry points in the experimental section.
246  * In the future, we expect to remove from experimental API entry points which are redundant with this API.
247  */
248 
249 
250 /* Compression strategies, listed from fastest to strongest */
251 typedef enum { ZSTD_fast=1,
260  /* note : new strategies _might_ be added in the future.
261  Only the order (from fast to strong) is guaranteed */
262 } ZSTD_strategy;
263 
264 
265 typedef enum {
266 
267  /* compression parameters
268  * Note: When compressing with a ZSTD_CDict these parameters are superseded
269  * by the parameters used to construct the ZSTD_CDict.
270  * See ZSTD_CCtx_refCDict() for more info (superseded-by-cdict). */
271  ZSTD_c_compressionLevel=100, /* Set compression parameters according to pre-defined cLevel table.
272  * Note that exact compression parameters are dynamically determined,
273  * depending on both compression level and srcSize (when known).
274  * Default level is ZSTD_CLEVEL_DEFAULT==3.
275  * Special: value 0 means default, which is controlled by ZSTD_CLEVEL_DEFAULT.
276  * Note 1 : it's possible to pass a negative compression level.
277  * Note 2 : setting a level does not automatically set all other compression parameters
278  * to default. Setting this will however eventually dynamically impact the compression
279  * parameters which have not been manually set. The manually set
280  * ones will 'stick'. */
281  /* Advanced compression parameters :
282  * It's possible to pin down compression parameters to some specific values.
283  * In which case, these values are no longer dynamically selected by the compressor */
284  ZSTD_c_windowLog=101, /* Maximum allowed back-reference distance, expressed as power of 2.
285  * This will set a memory budget for streaming decompression,
286  * with larger values requiring more memory
287  * and typically compressing more.
288  * Must be clamped between ZSTD_WINDOWLOG_MIN and ZSTD_WINDOWLOG_MAX.
289  * Special: value 0 means "use default windowLog".
290  * Note: Using a windowLog greater than ZSTD_WINDOWLOG_LIMIT_DEFAULT
291  * requires explicitly allowing such size at streaming decompression stage. */
292  ZSTD_c_hashLog=102, /* Size of the initial probe table, as a power of 2.
293  * Resulting memory usage is (1 << (hashLog+2)).
294  * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX.
295  * Larger tables improve compression ratio of strategies <= dFast,
296  * and improve speed of strategies > dFast.
297  * Special: value 0 means "use default hashLog". */
298  ZSTD_c_chainLog=103, /* Size of the multi-probe search table, as a power of 2.
299  * Resulting memory usage is (1 << (chainLog+2)).
300  * Must be clamped between ZSTD_CHAINLOG_MIN and ZSTD_CHAINLOG_MAX.
301  * Larger tables result in better and slower compression.
302  * This parameter is useless for "fast" strategy.
303  * It's still useful when using "dfast" strategy,
304  * in which case it defines a secondary probe table.
305  * Special: value 0 means "use default chainLog". */
306  ZSTD_c_searchLog=104, /* Number of search attempts, as a power of 2.
307  * More attempts result in better and slower compression.
308  * This parameter is useless for "fast" and "dFast" strategies.
309  * Special: value 0 means "use default searchLog". */
310  ZSTD_c_minMatch=105, /* Minimum size of searched matches.
311  * Note that Zstandard can still find matches of smaller size,
312  * it just tweaks its search algorithm to look for this size and larger.
313  * Larger values increase compression and decompression speed, but decrease ratio.
314  * Must be clamped between ZSTD_MINMATCH_MIN and ZSTD_MINMATCH_MAX.
315  * Note that currently, for all strategies < btopt, effective minimum is 4.
316  * , for all strategies > fast, effective maximum is 6.
317  * Special: value 0 means "use default minMatchLength". */
318  ZSTD_c_targetLength=106, /* Impact of this field depends on strategy.
319  * For strategies btopt, btultra & btultra2:
320  * Length of Match considered "good enough" to stop search.
321  * Larger values make compression stronger, and slower.
322  * For strategy fast:
323  * Distance between match sampling.
324  * Larger values make compression faster, and weaker.
325  * Special: value 0 means "use default targetLength". */
326  ZSTD_c_strategy=107, /* See ZSTD_strategy enum definition.
327  * The higher the value of selected strategy, the more complex it is,
328  * resulting in stronger and slower compression.
329  * Special: value 0 means "use default strategy". */
330 
331  /* LDM mode parameters */
332  ZSTD_c_enableLongDistanceMatching=160, /* Enable long distance matching.
333  * This parameter is designed to improve compression ratio
334  * for large inputs, by finding large matches at long distance.
335  * It increases memory usage and window size.
336  * Note: enabling this parameter increases default ZSTD_c_windowLog to 128 MB
337  * except when expressly set to a different value. */
338  ZSTD_c_ldmHashLog=161, /* Size of the table for long distance matching, as a power of 2.
339  * Larger values increase memory usage and compression ratio,
340  * but decrease compression speed.
341  * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX
342  * default: windowlog - 7.
343  * Special: value 0 means "automatically determine hashlog". */
344  ZSTD_c_ldmMinMatch=162, /* Minimum match size for long distance matcher.
345  * Larger/too small values usually decrease compression ratio.
346  * Must be clamped between ZSTD_LDM_MINMATCH_MIN and ZSTD_LDM_MINMATCH_MAX.
347  * Special: value 0 means "use default value" (default: 64). */
348  ZSTD_c_ldmBucketSizeLog=163, /* Log size of each bucket in the LDM hash table for collision resolution.
349  * Larger values improve collision resolution but decrease compression speed.
350  * The maximum value is ZSTD_LDM_BUCKETSIZELOG_MAX.
351  * Special: value 0 means "use default value" (default: 3). */
352  ZSTD_c_ldmHashRateLog=164, /* Frequency of inserting/looking up entries into the LDM hash table.
353  * Must be clamped between 0 and (ZSTD_WINDOWLOG_MAX - ZSTD_HASHLOG_MIN).
354  * Default is MAX(0, (windowLog - ldmHashLog)), optimizing hash table usage.
355  * Larger values improve compression speed.
356  * Deviating far from default value will likely result in a compression ratio decrease.
357  * Special: value 0 means "automatically determine hashRateLog". */
358 
359  /* frame parameters */
360  ZSTD_c_contentSizeFlag=200, /* Content size will be written into frame header _whenever known_ (default:1)
361  * Content size must be known at the beginning of compression.
362  * This is automatically the case when using ZSTD_compress2(),
363  * For streaming scenarios, content size must be provided with ZSTD_CCtx_setPledgedSrcSize() */
364  ZSTD_c_checksumFlag=201, /* A 32-bits checksum of content is written at end of frame (default:0) */
365  ZSTD_c_dictIDFlag=202, /* When applicable, dictionary's ID is written into frame header (default:1) */
366 
367  /* multi-threading parameters */
368  /* These parameters are only useful if multi-threading is enabled (compiled with build macro ZSTD_MULTITHREAD).
369  * They return an error otherwise. */
370  ZSTD_c_nbWorkers=400, /* Select how many threads will be spawned to compress in parallel.
371  * When nbWorkers >= 1, triggers asynchronous mode when used with ZSTD_compressStream*() :
372  * ZSTD_compressStream*() consumes input and flush output if possible, but immediately gives back control to caller,
373  * while compression work is performed in parallel, within worker threads.
374  * (note : a strong exception to this rule is when first invocation of ZSTD_compressStream2() sets ZSTD_e_end :
375  * in which case, ZSTD_compressStream2() delegates to ZSTD_compress2(), which is always a blocking call).
376  * More workers improve speed, but also increase memory usage.
377  * Default value is `0`, aka "single-threaded mode" : no worker is spawned, compression is performed inside Caller's thread, all invocations are blocking */
378  ZSTD_c_jobSize=401, /* Size of a compression job. This value is enforced only when nbWorkers >= 1.
379  * Each compression job is completed in parallel, so this value can indirectly impact the nb of active threads.
380  * 0 means default, which is dynamically determined based on compression parameters.
381  * Job size must be a minimum of overlap size, or 1 MB, whichever is largest.
382  * The minimum size is automatically and transparently enforced. */
383  ZSTD_c_overlapLog=402, /* Control the overlap size, as a fraction of window size.
384  * The overlap size is an amount of data reloaded from previous job at the beginning of a new job.
385  * It helps preserve compression ratio, while each job is compressed in parallel.
386  * This value is enforced only when nbWorkers >= 1.
387  * Larger values increase compression ratio, but decrease speed.
388  * Possible values range from 0 to 9 :
389  * - 0 means "default" : value will be determined by the library, depending on strategy
390  * - 1 means "no overlap"
391  * - 9 means "full overlap", using a full window size.
392  * Each intermediate rank increases/decreases load size by a factor 2 :
393  * 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
394  * default value varies between 6 and 9, depending on strategy */
395 
396  /* note : additional experimental parameters are also available
397  * within the experimental section of the API.
398  * At the time of this writing, they include :
399  * ZSTD_c_rsyncable
400  * ZSTD_c_format
401  * ZSTD_c_forceMaxWindow
402  * ZSTD_c_forceAttachDict
403  * ZSTD_c_literalCompressionMode
404  * ZSTD_c_targetCBlockSize
405  * ZSTD_c_srcSizeHint
406  * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
407  * note : never ever use experimentalParam? names directly;
408  * also, the enums values themselves are unstable and can still change.
409  */
418 
419 typedef struct {
420  size_t error;
423 } ZSTD_bounds;
424 
433 
446 
462 ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize);
463 
464 typedef enum {
469 
485 
496 ZSTDLIB_API size_t ZSTD_compress2( ZSTD_CCtx* cctx,
497  void* dst, size_t dstCapacity,
498  const void* src, size_t srcSize);
499 
500 
501 /***************************************
502 * Advanced decompression API
503 ***************************************/
504 
505 /* The advanced API pushes parameters one by one into an existing DCtx context.
506  * Parameters are sticky, and remain valid for all following frames
507  * using the same DCtx context.
508  * It's possible to reset parameters to default values using ZSTD_DCtx_reset().
509  * Note : This API is compatible with existing ZSTD_decompressDCtx() and ZSTD_decompressStream().
510  * Therefore, no new decompression function is necessary.
511  */
512 
513 typedef enum {
514 
515  ZSTD_d_windowLogMax=100, /* Select a size limit (in power of 2) beyond which
516  * the streaming API will refuse to allocate memory buffer
517  * in order to protect the host from unreasonable memory requirements.
518  * This parameter is only useful in streaming mode, since no internal buffer is allocated in single-pass mode.
519  * By default, a decompression context accepts window sizes <= (1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT).
520  * Special: value 0 means "use default maximum windowLog". */
521 
522  /* note : additional experimental parameters are also available
523  * within the experimental section of the API.
524  * At the time of this writing, they include :
525  * ZSTD_d_format
526  * ZSTD_d_stableOutBuffer
527  * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
528  * note : never ever use experimentalParam? names directly
529  */
532 
534 
543 
552 
560 
561 
562 /****************************
563 * Streaming
564 ****************************/
565 
566 typedef struct ZSTD_inBuffer_s {
567  const void* src;
568  size_t size;
569  size_t pos;
570 } ZSTD_inBuffer;
571 
572 typedef struct ZSTD_outBuffer_s {
573  void* dst;
574  size_t size;
575  size_t pos;
577 
578 
579 
580 /*-***********************************************************************
581 * Streaming compression - HowTo
582 *
583 * A ZSTD_CStream object is required to track streaming operation.
584 * Use ZSTD_createCStream() and ZSTD_freeCStream() to create/release resources.
585 * ZSTD_CStream objects can be reused multiple times on consecutive compression operations.
586 * It is recommended to re-use ZSTD_CStream since it will play nicer with system's memory, by re-using already allocated memory.
587 *
588 * For parallel execution, use one separate ZSTD_CStream per thread.
589 *
590 * note : since v1.3.0, ZSTD_CStream and ZSTD_CCtx are the same thing.
591 *
592 * Parameters are sticky : when starting a new compression on the same context,
593 * it will re-use the same sticky parameters as previous compression session.
594 * When in doubt, it's recommended to fully initialize the context before usage.
595 * Use ZSTD_CCtx_reset() to reset the context and ZSTD_CCtx_setParameter(),
596 * ZSTD_CCtx_setPledgedSrcSize(), or ZSTD_CCtx_loadDictionary() and friends to
597 * set more specific parameters, the pledged source size, or load a dictionary.
598 *
599 * Use ZSTD_compressStream2() with ZSTD_e_continue as many times as necessary to
600 * consume input stream. The function will automatically update both `pos`
601 * fields within `input` and `output`.
602 * Note that the function may not consume the entire input, for example, because
603 * the output buffer is already full, in which case `input.pos < input.size`.
604 * The caller must check if input has been entirely consumed.
605 * If not, the caller must make some room to receive more compressed data,
606 * and then present again remaining input data.
607 * note: ZSTD_e_continue is guaranteed to make some forward progress when called,
608 * but doesn't guarantee maximal forward progress. This is especially relevant
609 * when compressing with multiple threads. The call won't block if it can
610 * consume some input, but if it can't it will wait for some, but not all,
611 * output to be flushed.
612 * @return : provides a minimum amount of data remaining to be flushed from internal buffers
613 * or an error code, which can be tested using ZSTD_isError().
614 *
615 * At any moment, it's possible to flush whatever data might remain stuck within internal buffer,
616 * using ZSTD_compressStream2() with ZSTD_e_flush. `output->pos` will be updated.
617 * Note that, if `output->size` is too small, a single invocation with ZSTD_e_flush might not be enough (return code > 0).
618 * In which case, make some room to receive more compressed data, and call again ZSTD_compressStream2() with ZSTD_e_flush.
619 * You must continue calling ZSTD_compressStream2() with ZSTD_e_flush until it returns 0, at which point you can change the
620 * operation.
621 * note: ZSTD_e_flush will flush as much output as possible, meaning when compressing with multiple threads, it will
622 * block until the flush is complete or the output buffer is full.
623 * @return : 0 if internal buffers are entirely flushed,
624 * >0 if some data still present within internal buffer (the value is minimal estimation of remaining size),
625 * or an error code, which can be tested using ZSTD_isError().
626 *
627 * Calling ZSTD_compressStream2() with ZSTD_e_end instructs to finish a frame.
628 * It will perform a flush and write frame epilogue.
629 * The epilogue is required for decoders to consider a frame completed.
630 * flush operation is the same, and follows same rules as calling ZSTD_compressStream2() with ZSTD_e_flush.
631 * You must continue calling ZSTD_compressStream2() with ZSTD_e_end until it returns 0, at which point you are free to
632 * start a new frame.
633 * note: ZSTD_e_end will flush as much output as possible, meaning when compressing with multiple threads, it will
634 * block until the flush is complete or the output buffer is full.
635 * @return : 0 if frame fully completed and fully flushed,
636 * >0 if some data still present within internal buffer (the value is minimal estimation of remaining size),
637 * or an error code, which can be tested using ZSTD_isError().
638 *
639 * *******************************************************************/
640 
642  /* Continue to distinguish them for compatibility with older versions <= v1.2.0 */
643 /*===== ZSTD_CStream management functions =====*/
646 
647 /*===== Streaming compression functions =====*/
648 typedef enum {
649  ZSTD_e_continue=0, /* collect more data, encoder decides when to output compressed result, for optimal compression ratio */
650  ZSTD_e_flush=1, /* flush any data provided so far,
651  * it creates (at least) one new block, that can be decoded immediately on reception;
652  * frame will continue: any future data can still reference previously compressed data, improving compression.
653  * note : multithreaded compression will block to flush as much output as possible. */
654  ZSTD_e_end=2 /* flush any remaining data _and_ close current frame.
655  * note that frame is only closed after compressed data is fully flushed (return value == 0).
656  * After that point, any additional data starts a new frame.
657  * note : each frame is independent (does not reference any content from previous frame).
658  : note : multithreaded compression will block to flush as much output as possible. */
660 
683  ZSTD_outBuffer* output,
685  ZSTD_EndDirective endOp);
686 
687 
688 /* These buffer sizes are softly recommended.
689  * They are not required : ZSTD_compressStream*() happily accepts any buffer size, for both input and output.
690  * Respecting the recommended size just makes it a bit easier for ZSTD_compressStream*(),
691  * reducing the amount of memory shuffling and buffering, resulting in minor performance savings.
692  *
693  * However, note that these recommendations are from the perspective of a C caller program.
694  * If the streaming interface is invoked from some other language,
695  * especially managed ones such as Java or Go, through a foreign function interface such as jni or cgo,
696  * a major performance rule is to reduce crossing such interface to an absolute minimum.
697  * It's not rare that performance ends being spent more into the interface, rather than compression itself.
698  * In which cases, prefer using large buffers, as large as practical,
699  * for both input and output, to reduce the nb of roundtrips.
700  */
701 ZSTDLIB_API size_t ZSTD_CStreamInSize(void);
702 ZSTDLIB_API size_t ZSTD_CStreamOutSize(void);
705 /* *****************************************************************************
706  * This following is a legacy streaming API.
707  * It can be replaced by ZSTD_CCtx_reset() and ZSTD_compressStream2().
708  * It is redundant, but remains fully supported.
709  * Advanced parameters and dictionary compression can only be used through the
710  * new API.
711  ******************************************************************************/
712 
720 ZSTDLIB_API size_t ZSTD_initCStream(ZSTD_CStream* zcs, int compressionLevel);
732 
733 
734 /*-***************************************************************************
735 * Streaming decompression - HowTo
736 *
737 * A ZSTD_DStream object is required to track streaming operations.
738 * Use ZSTD_createDStream() and ZSTD_freeDStream() to create/release resources.
739 * ZSTD_DStream objects can be re-used multiple times.
740 *
741 * Use ZSTD_initDStream() to start a new decompression operation.
742 * @return : recommended first input size
743 * Alternatively, use advanced API to set specific properties.
744 *
745 * Use ZSTD_decompressStream() repetitively to consume your input.
746 * The function will update both `pos` fields.
747 * If `input.pos < input.size`, some input has not been consumed.
748 * It's up to the caller to present again remaining data.
749 * The function tries to flush all data decoded immediately, respecting output buffer size.
750 * If `output.pos < output.size`, decoder has flushed everything it could.
751 * But if `output.pos == output.size`, there might be some data left within internal buffers.,
752 * In which case, call ZSTD_decompressStream() again to flush whatever remains in the buffer.
753 * Note : with no additional input provided, amount of data flushed is necessarily <= ZSTD_BLOCKSIZE_MAX.
754 * @return : 0 when a frame is completely decoded and fully flushed,
755 * or an error code, which can be tested using ZSTD_isError(),
756 * or any other value > 0, which means there is still some decoding or flushing to do to complete current frame :
757 * the return value is a suggested next input size (just a hint for better latency)
758 * that will never request more than the remaining frame size.
759 * *******************************************************************************/
760 
762  /* For compatibility with versions <= v1.2.0, prefer differentiating them. */
763 /*===== ZSTD_DStream management functions =====*/
766 
767 /*===== Streaming decompression functions =====*/
768 
769 /* This function is redundant with the advanced API and equivalent to:
770  *
771  * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
772  * ZSTD_DCtx_refDDict(zds, NULL);
773  */
775 
777 
778 ZSTDLIB_API size_t ZSTD_DStreamInSize(void);
779 ZSTDLIB_API size_t ZSTD_DStreamOutSize(void);
782 /**************************
783 * Simple dictionary API
784 ***************************/
793  void* dst, size_t dstCapacity,
794  const void* src, size_t srcSize,
795  const void* dict,size_t dictSize,
796  int compressionLevel);
797 
805  void* dst, size_t dstCapacity,
806  const void* src, size_t srcSize,
807  const void* dict,size_t dictSize);
808 
809 
810 /***********************************
811  * Bulk processing dictionary API
812  **********************************/
813 typedef struct ZSTD_CDict_s ZSTD_CDict;
814 
827 ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize,
828  int compressionLevel);
829 
832 ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict* CDict);
833 
840  void* dst, size_t dstCapacity,
841  const void* src, size_t srcSize,
842  const ZSTD_CDict* cdict);
843 
844 
845 typedef struct ZSTD_DDict_s ZSTD_DDict;
846 
851 
854 ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict* ddict);
855 
860  void* dst, size_t dstCapacity,
861  const void* src, size_t srcSize,
862  const ZSTD_DDict* ddict);
863 
864 
865 /********************************
866  * Dictionary helper functions
867  *******************************/
868 
873 ZSTDLIB_API unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize);
874 
879 ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict);
880 
891 ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
892 
893 
894 /*******************************************************************************
895  * Advanced dictionary and prefix API
896  *
897  * This API allows dictionaries to be used with ZSTD_compress2(),
898  * ZSTD_compressStream2(), and ZSTD_decompress(). Dictionaries are sticky, and
899  * only reset with the context is reset with ZSTD_reset_parameters or
900  * ZSTD_reset_session_and_parameters. Prefixes are single-use.
901  ******************************************************************************/
902 
903 
921 ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
922 
935 ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
936 
956  const void* prefix, size_t prefixSize);
957 
973 ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
974 
984 ZSTDLIB_API size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
985 
1003  const void* prefix, size_t prefixSize);
1004 
1005 /* === Memory management === */
1006 
1010 ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx);
1011 ZSTDLIB_API size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx* dctx);
1012 ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs);
1013 ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds);
1014 ZSTDLIB_API size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict);
1015 ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
1016 
1017 #endif /* ZSTD_H_235446 */
1018 
1019 
1020 /* **************************************************************************************
1021  * ADVANCED AND EXPERIMENTAL FUNCTIONS
1022  ****************************************************************************************
1023  * The definitions in the following section are considered experimental.
1024  * They are provided for advanced scenarios.
1025  * They should never be used with a dynamic library, as prototypes may change in the future.
1026  * Use them only in association with static linking.
1027  * ***************************************************************************************/
1028 
1029 #if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY)
1030 #define ZSTD_H_ZSTD_STATIC_LINKING_ONLY
1031 
1032 /****************************************************************************************
1033  * experimental API (static linking only)
1034  ****************************************************************************************
1035  * The following symbols and constants
1036  * are not planned to join "stable API" status in the near future.
1037  * They can still change in future versions.
1038  * Some of them are planned to remain in the static_only section indefinitely.
1039  * Some of them might be removed in the future (especially when redundant with existing stable functions)
1040  * ***************************************************************************************/
1041 
1042 #define ZSTD_FRAMEHEADERSIZE_PREFIX(format) ((format) == ZSTD_f_zstd1 ? 5 : 1) /* minimum input size required to query frame header size */
1043 #define ZSTD_FRAMEHEADERSIZE_MIN(format) ((format) == ZSTD_f_zstd1 ? 6 : 2)
1044 #define ZSTD_FRAMEHEADERSIZE_MAX 18 /* can be useful for static allocation */
1045 #define ZSTD_SKIPPABLEHEADERSIZE 8
1046 
1047 /* compression parameter bounds */
1048 #define ZSTD_WINDOWLOG_MAX_32 30
1049 #define ZSTD_WINDOWLOG_MAX_64 31
1050 #define ZSTD_WINDOWLOG_MAX ((int)(sizeof(size_t) == 4 ? ZSTD_WINDOWLOG_MAX_32 : ZSTD_WINDOWLOG_MAX_64))
1051 #define ZSTD_WINDOWLOG_MIN 10
1052 #define ZSTD_HASHLOG_MAX ((ZSTD_WINDOWLOG_MAX < 30) ? ZSTD_WINDOWLOG_MAX : 30)
1053 #define ZSTD_HASHLOG_MIN 6
1054 #define ZSTD_CHAINLOG_MAX_32 29
1055 #define ZSTD_CHAINLOG_MAX_64 30
1056 #define ZSTD_CHAINLOG_MAX ((int)(sizeof(size_t) == 4 ? ZSTD_CHAINLOG_MAX_32 : ZSTD_CHAINLOG_MAX_64))
1057 #define ZSTD_CHAINLOG_MIN ZSTD_HASHLOG_MIN
1058 #define ZSTD_SEARCHLOG_MAX (ZSTD_WINDOWLOG_MAX-1)
1059 #define ZSTD_SEARCHLOG_MIN 1
1060 #define ZSTD_MINMATCH_MAX 7 /* only for ZSTD_fast, other strategies are limited to 6 */
1061 #define ZSTD_MINMATCH_MIN 3 /* only for ZSTD_btopt+, faster strategies are limited to 4 */
1062 #define ZSTD_TARGETLENGTH_MAX ZSTD_BLOCKSIZE_MAX
1063 #define ZSTD_TARGETLENGTH_MIN 0 /* note : comparing this constant to an unsigned results in a tautological test */
1064 #define ZSTD_STRATEGY_MIN ZSTD_fast
1065 #define ZSTD_STRATEGY_MAX ZSTD_btultra2
1066 
1067 
1068 #define ZSTD_OVERLAPLOG_MIN 0
1069 #define ZSTD_OVERLAPLOG_MAX 9
1070 
1071 #define ZSTD_WINDOWLOG_LIMIT_DEFAULT 27 /* by default, the streaming decoder will refuse any frame
1072  * requiring larger than (1<<ZSTD_WINDOWLOG_LIMIT_DEFAULT) window size,
1073  * to preserve host's memory from unreasonable requirements.
1074  * This limit can be overridden using ZSTD_DCtx_setParameter(,ZSTD_d_windowLogMax,).
1075  * The limit does not apply for one-pass decoders (such as ZSTD_decompress()), since no additional memory is allocated */
1076 
1077 
1078 /* LDM parameter bounds */
1079 #define ZSTD_LDM_HASHLOG_MIN ZSTD_HASHLOG_MIN
1080 #define ZSTD_LDM_HASHLOG_MAX ZSTD_HASHLOG_MAX
1081 #define ZSTD_LDM_MINMATCH_MIN 4
1082 #define ZSTD_LDM_MINMATCH_MAX 4096
1083 #define ZSTD_LDM_BUCKETSIZELOG_MIN 1
1084 #define ZSTD_LDM_BUCKETSIZELOG_MAX 8
1085 #define ZSTD_LDM_HASHRATELOG_MIN 0
1086 #define ZSTD_LDM_HASHRATELOG_MAX (ZSTD_WINDOWLOG_MAX - ZSTD_HASHLOG_MIN)
1087 
1088 /* Advanced parameter bounds */
1089 #define ZSTD_TARGETCBLOCKSIZE_MIN 64
1090 #define ZSTD_TARGETCBLOCKSIZE_MAX ZSTD_BLOCKSIZE_MAX
1091 #define ZSTD_SRCSIZEHINT_MIN 0
1092 #define ZSTD_SRCSIZEHINT_MAX INT_MAX
1093 
1094 /* internal */
1095 #define ZSTD_HASHLOG3_MAX 17
1096 
1097 
1098 /* --- Advanced types --- */
1099 
1100 typedef struct ZSTD_CCtx_params_s ZSTD_CCtx_params;
1101 
1102 typedef struct {
1103  unsigned int matchPos; /* Match pos in dst */
1104  /* If seqDef.offset > 3, then this is seqDef.offset - 3
1105  * If seqDef.offset < 3, then this is the corresponding repeat offset
1106  * But if seqDef.offset < 3 and litLength == 0, this is the
1107  * repeat offset before the corresponding repeat offset
1108  * And if seqDef.offset == 3 and litLength == 0, this is the
1109  * most recent repeat offset - 1
1110  */
1111  unsigned int offset;
1112  unsigned int litLength; /* Literal length */
1113  unsigned int matchLength; /* Match length */
1114  /* 0 when seq not rep and seqDef.offset otherwise
1115  * when litLength == 0 this will be <= 4, otherwise <= 3 like normal
1116  */
1117  unsigned int rep;
1118 } ZSTD_Sequence;
1119 
1120 typedef struct {
1121  unsigned windowLog;
1122  unsigned chainLog;
1123  unsigned hashLog;
1124  unsigned searchLog;
1125  unsigned minMatch;
1126  unsigned targetLength;
1127  ZSTD_strategy strategy;
1128 } ZSTD_compressionParameters;
1129 
1130 typedef struct {
1131  int contentSizeFlag;
1132  int checksumFlag;
1133  int noDictIDFlag;
1134 } ZSTD_frameParameters;
1135 
1136 typedef struct {
1137  ZSTD_compressionParameters cParams;
1138  ZSTD_frameParameters fParams;
1139 } ZSTD_parameters;
1140 
1141 typedef enum {
1142  ZSTD_dct_auto = 0, /* dictionary is "full" when starting with ZSTD_MAGIC_DICTIONARY, otherwise it is "rawContent" */
1143  ZSTD_dct_rawContent = 1, /* ensures dictionary is always loaded as rawContent, even if it starts with ZSTD_MAGIC_DICTIONARY */
1144  ZSTD_dct_fullDict = 2 /* refuses to load a dictionary if it does not respect Zstandard's specification, starting with ZSTD_MAGIC_DICTIONARY */
1145 } ZSTD_dictContentType_e;
1146 
1147 typedef enum {
1148  ZSTD_dlm_byCopy = 0,
1149  ZSTD_dlm_byRef = 1
1150 } ZSTD_dictLoadMethod_e;
1151 
1152 typedef enum {
1153  ZSTD_f_zstd1 = 0, /* zstd frame format, specified in zstd_compression_format.md (default) */
1154  ZSTD_f_zstd1_magicless = 1 /* Variant of zstd frame format, without initial 4-bytes magic number.
1155  * Useful to save 4 bytes per generated frame.
1156  * Decoder cannot recognise automatically this format, requiring this instruction. */
1157 } ZSTD_format_e;
1158 
1159 typedef enum {
1160  /* Note: this enum and the behavior it controls are effectively internal
1161  * implementation details of the compressor. They are expected to continue
1162  * to evolve and should be considered only in the context of extremely
1163  * advanced performance tuning.
1164  *
1165  * Zstd currently supports the use of a CDict in three ways:
1166  *
1167  * - The contents of the CDict can be copied into the working context. This
1168  * means that the compression can search both the dictionary and input
1169  * while operating on a single set of internal tables. This makes
1170  * the compression faster per-byte of input. However, the initial copy of
1171  * the CDict's tables incurs a fixed cost at the beginning of the
1172  * compression. For small compressions (< 8 KB), that copy can dominate
1173  * the cost of the compression.
1174  *
1175  * - The CDict's tables can be used in-place. In this model, compression is
1176  * slower per input byte, because the compressor has to search two sets of
1177  * tables. However, this model incurs no start-up cost (as long as the
1178  * working context's tables can be reused). For small inputs, this can be
1179  * faster than copying the CDict's tables.
1180  *
1181  * - The CDict's tables are not used at all, and instead we use the working
1182  * context alone to reload the dictionary and use params based on the source
1183  * size. See ZSTD_compress_insertDictionary() and ZSTD_compress_usingDict().
1184  * This method is effective when the dictionary sizes are very small relative
1185  * to the input size, and the input size is fairly large to begin with.
1186  *
1187  * Zstd has a simple internal heuristic that selects which strategy to use
1188  * at the beginning of a compression. However, if experimentation shows that
1189  * Zstd is making poor choices, it is possible to override that choice with
1190  * this enum.
1191  */
1192  ZSTD_dictDefaultAttach = 0, /* Use the default heuristic. */
1193  ZSTD_dictForceAttach = 1, /* Never copy the dictionary. */
1194  ZSTD_dictForceCopy = 2, /* Always copy the dictionary. */
1195  ZSTD_dictForceLoad = 3 /* Always reload the dictionary */
1196 } ZSTD_dictAttachPref_e;
1197 
1198 typedef enum {
1199  ZSTD_lcm_auto = 0,
1202  ZSTD_lcm_huffman = 1,
1204  ZSTD_lcm_uncompressed = 2
1205 } ZSTD_literalCompressionMode_e;
1206 
1207 
1208 /***************************************
1209 * Frame size functions
1210 ***************************************/
1211 
1233 ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize);
1234 
1248 ZSTDLIB_API unsigned long long ZSTD_decompressBound(const void* src, size_t srcSize);
1249 
1254 ZSTDLIB_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
1255 
1262 ZSTDLIB_API size_t ZSTD_getSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
1263  size_t outSeqsSize, const void* src, size_t srcSize);
1264 
1265 
1266 /***************************************
1267 * Memory management
1268 ***************************************/
1269 
1293 ZSTDLIB_API size_t ZSTD_estimateCCtxSize(int compressionLevel);
1294 ZSTDLIB_API size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams);
1295 ZSTDLIB_API size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params* params);
1296 ZSTDLIB_API size_t ZSTD_estimateDCtxSize(void);
1297 
1311 ZSTDLIB_API size_t ZSTD_estimateCStreamSize(int compressionLevel);
1312 ZSTDLIB_API size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams);
1313 ZSTDLIB_API size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params* params);
1314 ZSTDLIB_API size_t ZSTD_estimateDStreamSize(size_t windowSize);
1315 ZSTDLIB_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize);
1316 
1322 ZSTDLIB_API size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel);
1323 ZSTDLIB_API size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, ZSTD_dictLoadMethod_e dictLoadMethod);
1324 ZSTDLIB_API size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod);
1325 
1347 ZSTDLIB_API ZSTD_CCtx* ZSTD_initStaticCCtx(void* workspace, size_t workspaceSize);
1348 ZSTDLIB_API ZSTD_CStream* ZSTD_initStaticCStream(void* workspace, size_t workspaceSize);
1350 ZSTDLIB_API ZSTD_DCtx* ZSTD_initStaticDCtx(void* workspace, size_t workspaceSize);
1351 ZSTDLIB_API ZSTD_DStream* ZSTD_initStaticDStream(void* workspace, size_t workspaceSize);
1354  void* workspace, size_t workspaceSize,
1355  const void* dict, size_t dictSize,
1356  ZSTD_dictLoadMethod_e dictLoadMethod,
1357  ZSTD_dictContentType_e dictContentType,
1358  ZSTD_compressionParameters cParams);
1359 
1361  void* workspace, size_t workspaceSize,
1362  const void* dict, size_t dictSize,
1363  ZSTD_dictLoadMethod_e dictLoadMethod,
1364  ZSTD_dictContentType_e dictContentType);
1365 
1366 
1372 typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size);
1373 typedef void (*ZSTD_freeFunction) (void* opaque, void* address);
1374 typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem;
1375 static ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL };
1377 ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem);
1378 ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem);
1379 ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem);
1380 ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem);
1381 
1382 ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictSize,
1383  ZSTD_dictLoadMethod_e dictLoadMethod,
1384  ZSTD_dictContentType_e dictContentType,
1385  ZSTD_compressionParameters cParams,
1386  ZSTD_customMem customMem);
1387 
1388 ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictSize,
1389  ZSTD_dictLoadMethod_e dictLoadMethod,
1390  ZSTD_dictContentType_e dictContentType,
1391  ZSTD_customMem customMem);
1392 
1393 
1394 
1395 /***************************************
1396 * Advanced compression functions
1397 ***************************************/
1398 
1405 ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_byReference(const void* dictBuffer, size_t dictSize, int compressionLevel);
1406 
1410 ZSTDLIB_API ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
1411 
1415 ZSTDLIB_API ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
1416 
1420 ZSTDLIB_API size_t ZSTD_checkCParams(ZSTD_compressionParameters params);
1421 
1428 ZSTDLIB_API ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize);
1429 
1435  void* dst, size_t dstCapacity,
1436  const void* src, size_t srcSize,
1437  const void* dict,size_t dictSize,
1438  ZSTD_parameters params);
1439 
1445  void* dst, size_t dstCapacity,
1446  const void* src, size_t srcSize,
1447  const ZSTD_CDict* cdict,
1448  ZSTD_frameParameters fParams);
1449 
1450 
1454 ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary_byReference(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
1455 
1460 ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
1461 
1465 ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
1466 
1467 /* === experimental parameters === */
1468 /* these parameters can be used with ZSTD_setParameter()
1469  * they are not guaranteed to remain supported in the future */
1470 
1471  /* Enables rsyncable mode,
1472  * which makes compressed files more rsync friendly
1473  * by adding periodic synchronization points to the compressed data.
1474  * The target average block size is ZSTD_c_jobSize / 2.
1475  * It's possible to modify the job size to increase or decrease
1476  * the granularity of the synchronization point.
1477  * Once the jobSize is smaller than the window size,
1478  * it will result in compression ratio degradation.
1479  * NOTE 1: rsyncable mode only works when multithreading is enabled.
1480  * NOTE 2: rsyncable performs poorly in combination with long range mode,
1481  * since it will decrease the effectiveness of synchronization points,
1482  * though mileage may vary.
1483  * NOTE 3: Rsyncable mode limits maximum compression speed to ~400 MB/s.
1484  * If the selected compression level is already running significantly slower,
1485  * the overall speed won't be significantly impacted.
1486  */
1487  #define ZSTD_c_rsyncable ZSTD_c_experimentalParam1
1488 
1489 /* Select a compression format.
1490  * The value must be of type ZSTD_format_e.
1491  * See ZSTD_format_e enum definition for details */
1492 #define ZSTD_c_format ZSTD_c_experimentalParam2
1493 
1494 /* Force back-reference distances to remain < windowSize,
1495  * even when referencing into Dictionary content (default:0) */
1496 #define ZSTD_c_forceMaxWindow ZSTD_c_experimentalParam3
1497 
1498 /* Controls whether the contents of a CDict
1499  * are used in place, or copied into the working context.
1500  * Accepts values from the ZSTD_dictAttachPref_e enum.
1501  * See the comments on that enum for an explanation of the feature. */
1502 #define ZSTD_c_forceAttachDict ZSTD_c_experimentalParam4
1503 
1504 /* Controls how the literals are compressed (default is auto).
1505  * The value must be of type ZSTD_literalCompressionMode_e.
1506  * See ZSTD_literalCompressionMode_t enum definition for details.
1507  */
1508 #define ZSTD_c_literalCompressionMode ZSTD_c_experimentalParam5
1509 
1510 /* Tries to fit compressed block size to be around targetCBlockSize.
1511  * No target when targetCBlockSize == 0.
1512  * There is no guarantee on compressed block size (default:0) */
1513 #define ZSTD_c_targetCBlockSize ZSTD_c_experimentalParam6
1514 
1515 /* User's best guess of source size.
1516  * Hint is not valid when srcSizeHint == 0.
1517  * There is no guarantee that hint is close to actual source size,
1518  * but compression ratio may regress significantly if guess considerably underestimates */
1519 #define ZSTD_c_srcSizeHint ZSTD_c_experimentalParam7
1520 
1527 
1528 
1546 ZSTDLIB_API ZSTD_CCtx_params* ZSTD_createCCtxParams(void);
1547 ZSTDLIB_API size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params);
1548 
1552 ZSTDLIB_API size_t ZSTD_CCtxParams_reset(ZSTD_CCtx_params* params);
1553 
1558 ZSTDLIB_API size_t ZSTD_CCtxParams_init(ZSTD_CCtx_params* cctxParams, int compressionLevel);
1559 
1564 ZSTDLIB_API size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params);
1565 
1573 
1580 
1589  ZSTD_CCtx* cctx, const ZSTD_CCtx_params* params);
1590 
1598  ZSTD_CCtx* cctx,
1599  void* dst, size_t dstCapacity, size_t* dstPos,
1600  const void* src, size_t srcSize, size_t* srcPos,
1601  ZSTD_EndDirective endOp);
1602 
1603 
1604 /***************************************
1605 * Advanced decompression functions
1606 ***************************************/
1607 
1613 ZSTDLIB_API unsigned ZSTD_isFrame(const void* buffer, size_t size);
1614 
1620 ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize);
1621 
1627 ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
1628 
1634 ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
1635 
1639 ZSTDLIB_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
1640 
1648 ZSTDLIB_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize);
1649 
1650 /* ZSTD_d_format
1651  * experimental parameter,
1652  * allowing selection between ZSTD_format_e input compression formats
1653  */
1654 #define ZSTD_d_format ZSTD_d_experimentalParam1
1655 /* ZSTD_d_stableOutBuffer
1656  * Experimental parameter.
1657  * Default is 0 == disabled. Set to 1 to enable.
1658  *
1659  * Tells the decompressor that the ZSTD_outBuffer will ALWAYS be the same
1660  * between calls, except for the modifications that zstd makes to pos (the
1661  * caller must not modify pos). This is checked by the decompressor, and
1662  * decompression will fail if it ever changes. Therefore the ZSTD_outBuffer
1663  * MUST be large enough to fit the entire decompressed frame. This will be
1664  * checked when the frame content size is known. The data in the ZSTD_outBuffer
1665  * in the range [dst, dst + pos) MUST not be modified during decompression
1666  * or you will get data corruption.
1667  *
1668  * When this flags is enabled zstd won't allocate an output buffer, because
1669  * it can write directly to the ZSTD_outBuffer, but it will still allocate
1670  * an input buffer large enough to fit any compressed block. This will also
1671  * avoid the memcpy() from the internal output buffer to the ZSTD_outBuffer.
1672  * If you need to avoid the input buffer allocation use the buffer-less
1673  * streaming API.
1674  *
1675  * NOTE: So long as the ZSTD_outBuffer always points to valid memory, using
1676  * this flag is ALWAYS memory safe, and will never access out-of-bounds
1677  * memory. However, decompression WILL fail if you violate the preconditions.
1678  *
1679  * WARNING: The data in the ZSTD_outBuffer in the range [dst, dst + pos) MUST
1680  * not be modified during decompression or you will get data corruption. This
1681  * is because zstd needs to reference data in the ZSTD_outBuffer to regenerate
1682  * matches. Normally zstd maintains its own buffer for this purpose, but passing
1683  * this flag tells zstd to use the user provided buffer.
1684  */
1685 #define ZSTD_d_stableOutBuffer ZSTD_d_experimentalParam2
1686 
1692 ZSTDLIB_API size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format);
1693 
1701  ZSTD_DCtx* dctx,
1702  void* dst, size_t dstCapacity, size_t* dstPos,
1703  const void* src, size_t srcSize, size_t* srcPos);
1704 
1705 
1706 /********************************************************************
1707 * Advanced streaming functions
1708 * Warning : most of these functions are now redundant with the Advanced API.
1709 * Once Advanced API reaches "stable" status,
1710 * redundant functions will be deprecated, and then at some point removed.
1711 ********************************************************************/
1712 
1713 /*===== Advanced Streaming compression functions =====*/
1726 ZSTDLIB_API size_t
1728  int compressionLevel,
1729  unsigned long long pledgedSrcSize);
1730 
1743 ZSTDLIB_API size_t
1745  const void* dict, size_t dictSize,
1746  int compressionLevel);
1747 
1763 ZSTDLIB_API size_t
1765  const void* dict, size_t dictSize,
1766  ZSTD_parameters params,
1767  unsigned long long pledgedSrcSize);
1768 
1778 
1794 ZSTDLIB_API size_t
1796  const ZSTD_CDict* cdict,
1797  ZSTD_frameParameters fParams,
1798  unsigned long long pledgedSrcSize);
1799 
1815 ZSTDLIB_API size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize);
1816 
1817 
1818 typedef struct {
1819  unsigned long long ingested; /* nb input bytes read and buffered */
1820  unsigned long long consumed; /* nb input bytes actually compressed */
1821  unsigned long long produced; /* nb of compressed bytes generated and buffered */
1822  unsigned long long flushed; /* nb of compressed bytes flushed : not provided; can be tracked from caller side */
1823  unsigned currentJobID; /* MT only : latest started job nb */
1824  unsigned nbActiveWorkers; /* MT only : nb of workers actively compressing at probe time */
1825 } ZSTD_frameProgression;
1826 
1827 /* ZSTD_getFrameProgression() :
1828  * tells how much data has been ingested (read from input)
1829  * consumed (input actually compressed) and produced (output) for current frame.
1830  * Note : (ingested - consumed) is amount of input data buffered internally, not yet compressed.
1831  * Aggregates progression inside active worker threads.
1832  */
1833 ZSTDLIB_API ZSTD_frameProgression ZSTD_getFrameProgression(const ZSTD_CCtx* cctx);
1834 
1848 ZSTDLIB_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx);
1849 
1850 
1851 /*===== Advanced Streaming decompression functions =====*/
1861 ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize);
1862 
1873 
1883 
1884 
1885 /*********************************************************************
1886 * Buffer-less and synchronous inner streaming functions
1887 *
1888 * This is an advanced API, giving full control over buffer management, for users which need direct control over memory.
1889 * But it's also a complex one, with several restrictions, documented below.
1890 * Prefer normal streaming API for an easier experience.
1891 ********************************************************************* */
1892 
1924 /*===== Buffer-less streaming compression functions =====*/
1925 ZSTDLIB_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
1926 ZSTDLIB_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
1927 ZSTDLIB_API size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize);
1928 ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
1929 ZSTDLIB_API size_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 */
1930 ZSTDLIB_API size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize);
1932 ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
1933 ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
1934 
1935 
1936 /*-
1937  Buffer-less streaming decompression (synchronous mode)
1938 
1939  A ZSTD_DCtx object is required to track streaming operations.
1940  Use ZSTD_createDCtx() / ZSTD_freeDCtx() to manage it.
1941  A ZSTD_DCtx object can be re-used multiple times.
1942 
1943  First typical operation is to retrieve frame parameters, using ZSTD_getFrameHeader().
1944  Frame header is extracted from the beginning of compressed frame, so providing only the frame's beginning is enough.
1945  Data fragment must be large enough to ensure successful decoding.
1946  `ZSTD_frameHeaderSize_max` bytes is guaranteed to always be large enough.
1947  @result : 0 : successful decoding, the `ZSTD_frameHeader` structure is correctly filled.
1948  >0 : `srcSize` is too small, please provide at least @result bytes on next attempt.
1949  errorCode, which can be tested using ZSTD_isError().
1950 
1951  It fills a ZSTD_frameHeader structure with important information to correctly decode the frame,
1952  such as the dictionary ID, content size, or maximum back-reference distance (`windowSize`).
1953  Note that these values could be wrong, either because of data corruption, or because a 3rd party deliberately spoofs false information.
1954  As a consequence, check that values remain within valid application range.
1955  For example, do not allocate memory blindly, check that `windowSize` is within expectation.
1956  Each application can set its own limits, depending on local restrictions.
1957  For extended interoperability, it is recommended to support `windowSize` of at least 8 MB.
1958 
1959  ZSTD_decompressContinue() needs previous data blocks during decompression, up to `windowSize` bytes.
1960  ZSTD_decompressContinue() is very sensitive to contiguity,
1961  if 2 blocks don't follow each other, make sure that either the compressor breaks contiguity at the same place,
1962  or that previous contiguous segment is large enough to properly handle maximum back-reference distance.
1963  There are multiple ways to guarantee this condition.
1964 
1965  The most memory efficient way is to use a round buffer of sufficient size.
1966  Sufficient size is determined by invoking ZSTD_decodingBufferSize_min(),
1967  which can @return an error code if required value is too large for current system (in 32-bits mode).
1968  In a round buffer methodology, ZSTD_decompressContinue() decompresses each block next to previous one,
1969  up to the moment there is not enough room left in the buffer to guarantee decoding another full block,
1970  which maximum size is provided in `ZSTD_frameHeader` structure, field `blockSizeMax`.
1971  At which point, decoding can resume from the beginning of the buffer.
1972  Note that already decoded data stored in the buffer should be flushed before being overwritten.
1973 
1974  There are alternatives possible, for example using two or more buffers of size `windowSize` each, though they consume more memory.
1975 
1976  Finally, if you control the compression process, you can also ignore all buffer size rules,
1977  as long as the encoder and decoder progress in "lock-step",
1978  aka use exactly the same buffer sizes, break contiguity at the same place, etc.
1979 
1980  Once buffers are setup, start decompression, with ZSTD_decompressBegin().
1981  If decompression requires a dictionary, use ZSTD_decompressBegin_usingDict() or ZSTD_decompressBegin_usingDDict().
1982 
1983  Then use ZSTD_nextSrcSizeToDecompress() and ZSTD_decompressContinue() alternatively.
1984  ZSTD_nextSrcSizeToDecompress() tells how many bytes to provide as 'srcSize' to ZSTD_decompressContinue().
1985  ZSTD_decompressContinue() requires this _exact_ amount of bytes, or it will fail.
1986 
1987  @result of ZSTD_decompressContinue() is the number of bytes regenerated within 'dst' (necessarily <= dstCapacity).
1988  It can be zero : it just means ZSTD_decompressContinue() has decoded some metadata item.
1989  It can also be an error code, which can be tested with ZSTD_isError().
1990 
1991  A frame is fully decoded when ZSTD_nextSrcSizeToDecompress() returns zero.
1992  Context can then be reset to start a new decompression.
1993 
1994  Note : it's possible to know if next input to present is a header or a block, using ZSTD_nextInputType().
1995  This information is not required to properly decode a frame.
1996 
1997  == Special case : skippable frames ==
1998 
1999  Skippable frames allow integration of user-defined data into a flow of concatenated frames.
2000  Skippable frames will be ignored (skipped) by decompressor.
2001  The format of skippable frames is as follows :
2002  a) Skippable frame ID - 4 Bytes, Little endian format, any value from 0x184D2A50 to 0x184D2A5F
2003  b) Frame Size - 4 Bytes, Little endian format, unsigned 32-bits
2004  c) Frame Content - any content (User Data) of length equal to Frame Size
2005  For skippable frames ZSTD_getFrameHeader() returns zfhPtr->frameType==ZSTD_skippableFrame.
2006  For skippable frames ZSTD_decompressContinue() always returns 0 : it only skips the content.
2007 */
2008 
2009 /*===== Buffer-less streaming decompression functions =====*/
2010 typedef enum { ZSTD_frame, ZSTD_skippableFrame } ZSTD_frameType_e;
2011 typedef struct {
2012  unsigned long long frameContentSize; /* if == ZSTD_CONTENTSIZE_UNKNOWN, it means this field is not available. 0 means "empty" */
2013  unsigned long long windowSize; /* can be very large, up to <= frameContentSize */
2014  unsigned blockSizeMax;
2015  ZSTD_frameType_e frameType; /* if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */
2016  unsigned headerSize;
2017  unsigned dictID;
2018  unsigned checksumFlag;
2019 } ZSTD_frameHeader;
2020 
2026 ZSTDLIB_API size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize);
2030 ZSTDLIB_API size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize, ZSTD_format_e format);
2031 ZSTDLIB_API size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize);
2034 ZSTDLIB_API size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
2036 
2038 ZSTDLIB_API size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
2039 
2040 /* misc */
2041 ZSTDLIB_API void ZSTD_copyDCtx(ZSTD_DCtx* dctx, const ZSTD_DCtx* preparedDCtx);
2042 typedef enum { ZSTDnit_frameHeader, ZSTDnit_blockHeader, ZSTDnit_block, ZSTDnit_lastBlock, ZSTDnit_checksum, ZSTDnit_skippableFrame } ZSTD_nextInputType_e;
2043 ZSTDLIB_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx);
2044 
2045 
2046 
2047 
2048 /* ============================ */
2050 /* ============================ */
2051 
2079 /*===== Raw zstd block functions =====*/
2080 ZSTDLIB_API size_t ZSTD_getBlockSize (const ZSTD_CCtx* cctx);
2081 ZSTDLIB_API size_t ZSTD_compressBlock (ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
2082 ZSTDLIB_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
2083 ZSTDLIB_API size_t ZSTD_insertBlock (ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize);
2086 #endif /* ZSTD_H_ZSTD_STATIC_LINKING_ONLY */
2087 
2088 #if defined (__cplusplus)
2089 }
2090 #endif
size_t ZSTD_initCStream_srcSize(ZSTD_CStream *zcs, int compressionLevel, unsigned long long pss)
ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict *ddict)
Definition: zstd_ddict.c:230
size_t ZSTD_decompressBlock(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
ZSTDLIB_API const char * ZSTD_getErrorName(size_t code)
Definition: zstd_common.c:41
size_t size
Definition: zstd.h:574
ZSTD_CCtx ZSTD_CStream
Definition: zstd.h:641
Definition: pdh_main.c:93
size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx *dctx, const void *prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType)
ZSTDLIB_API size_t ZSTD_DCtx_setParameter(ZSTD_DCtx *dctx, ZSTD_dParameter param, int value)
size_t ZSTD_initCStream_usingDict(ZSTD_CStream *zcs, const void *dict, size_t dictSize, int compressionLevel)
ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void *src, size_t srcSize)
ZSTDLIB_API size_t ZSTD_DStreamInSize(void)
ZSTDLIB_API size_t ZSTD_compressStream2(ZSTD_CCtx *cctx, ZSTD_outBuffer *output, ZSTD_inBuffer *input, ZSTD_EndDirective endOp)
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
ZSTDLIB_API size_t ZSTD_CStreamOutSize(void)
ZSTD_CCtx_params * ZSTD_createCCtxParams(void)
size_t ZSTD_initDStream_usingDict(ZSTD_DStream *zds, const void *dict, size_t dictSize)
ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx *dctx)
size_t ZSTD_DCtx_setFormat(ZSTD_DCtx *dctx, ZSTD_format_e format)
ZSTD_DStream * ZSTD_initStaticDStream(void *workspace, size_t workspaceSize)
ZSTDLIB_API ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter cParam)
size_t ZSTD_estimateCCtxSize(int compressionLevel)
size_t ZSTD_frameHeaderSize(const void *src, size_t srcSize)
ZSTDLIB_API size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx *dctx)
struct ZSTD_inBuffer_s ZSTD_inBuffer
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
size_t ZSTD_compressBlock(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
size_t ZSTD_compressContinue(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, int compressionLevel)
size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel)
ZSTDLIB_API ZSTD_DCtx * ZSTD_createDCtx(void)
ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void *src, size_t srcSize)
size_t ZSTD_initCStream_usingCDict(ZSTD_CStream *zcs, const ZSTD_CDict *cdict)
size_t ZSTD_decompressBegin(ZSTD_DCtx *dctx)
ZSTDLIB_API size_t ZSTD_compressStream(ZSTD_CStream *zcs, ZSTD_outBuffer *output, ZSTD_inBuffer *input)
ZSTDLIB_API int ZSTD_minCLevel(void)
ZSTD_DDict * ZSTD_createDDict_byReference(const void *dictBuffer, size_t dictSize)
Definition: zstd_ddict.c:180
ZSTDLIB_API size_t ZSTD_flushStream(ZSTD_CStream *zcs, ZSTD_outBuffer *output)
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)
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
ZSTD_DCtx ZSTD_DStream
Definition: zstd.h:761
GLuint buffer
Definition: glext.h:5915
size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx *cctx, const void *dict, size_t dictSize, int compressionLevel)
size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params *params)
void * dictBuffer
Definition: zstd_ddict.c:37
ZSTD_dParameter
Definition: zstd.h:513
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)
size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx *cctx, const void *prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType)
ZSTD_CDict * ZSTD_createCDict_byReference(const void *dict, size_t dictSize, int compressionLevel)
ZSTD_DCtx * ZSTD_initStaticDCtx(void *workspace, size_t workspaceSize)
ZSTD_ResetDirective
Definition: zstd.h:464
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
size_t ZSTD_resetCStream(ZSTD_CStream *zcs, unsigned long long pss)
size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx *dctx, const void *dict, size_t dictSize)
unsigned long long ZSTD_decompressBound(const void *src, size_t srcSize)
size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, ZSTD_dictLoadMethod_e dictLoadMethod)
size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams)
int upperBound
Definition: zstd.h:422
size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx *dctx)
ZSTDLIB_API ZSTD_CCtx * ZSTD_createCCtx(void)
Definition: zstd_compress.c:64
GLenum const GLfloat * params
Definition: glext.h:5645
size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params *params)
ZSTDLIB_API size_t ZSTD_compress2(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream *zds)
ZSTDLIB_API size_t ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inBuffer *input)
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)
ZSTDLIB_API size_t ZSTD_CCtx_setParameter(ZSTD_CCtx *cctx, ZSTD_cParameter param, int value)
size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params *params)
size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader *zfhPtr, const void *src, size_t srcSize, ZSTD_format_e format)
size_t ZSTD_estimateDCtxSize(void)
size_t error
Definition: zstd.h:420
size_t ZSTD_initCStream_advanced(ZSTD_CStream *zcs, const void *dict, size_t dictSize, ZSTD_parameters params, unsigned long long pss)
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)
size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx *dctx, const void *dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType)
ZSTDLIB_API ZSTD_DStream * ZSTD_createDStream(void)
size_t ZSTD_compressBegin(ZSTD_CCtx *cctx, int compressionLevel)
ZSTD_DStream * ZSTD_createDStream_advanced(ZSTD_customMem customMem)
size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx *dctx, const ZSTD_DDict *ddict)
size_t ZSTD_resetDStream(ZSTD_DStream *dctx)
ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx *cctx, const void *dict, size_t dictSize)
size_t ZSTD_insertBlock(ZSTD_DCtx *dctx, const void *blockStart, size_t blockSize)
ZSTDLIB_API size_t ZSTD_DStreamOutSize(void)
size_t ZSTD_CCtx_getParameter(ZSTD_CCtx *cctx, ZSTD_cParameter param, int *value)
ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx *cctx)
size_t ZSTD_estimateDStreamSize(size_t windowSize)
ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long srcSizeHint, size_t dictSize)
ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void *src, size_t srcSize)
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)
ZSTDLIB_API size_t ZSTD_sizeof_CDict(const ZSTD_CDict *cdict)
size_t ZSTD_compressBegin_advanced(ZSTD_CCtx *cctx, const void *dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize)
size_t ZSTD_copyCCtx(ZSTD_CCtx *dstCCtx, const ZSTD_CCtx *srcCCtx, unsigned long long pledgedSrcSize)
ZSTDLIB_API size_t ZSTD_CStreamInSize(void)
GLsizeiptr size
Definition: glext.h:5919
size_t ZSTD_compressBegin_usingCDict_advanced(ZSTD_CCtx *const cctx, const ZSTD_CDict *const cdict, ZSTD_frameParameters const fParams, unsigned long long const pledgedSrcSize)
size_t dictSize
Definition: zstd_ddict.c:39
GLintptr offset
Definition: glext.h:5920
ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream *zcs)
ZSTDLIB_API unsigned ZSTD_isError(size_t code)
Definition: zstd_common.c:37
size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams)
GLfloat param
Definition: glext.h:5796
size_t ZSTD_getSequences(ZSTD_CCtx *zc, ZSTD_Sequence *outSeqs, size_t outSeqsSize, const void *src, size_t srcSize)
size_t pos
Definition: zstd.h:569
ZSTDLIB_API int ZSTD_maxCLevel(void)
ZSTDLIB_API ZSTD_DDict * ZSTD_createDDict(const void *dictBuffer, size_t dictSize)
Definition: zstd_ddict.c:170
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)
GLuint address
Definition: glext.h:9393
ZSTDLIB_API size_t ZSTD_decompress(void *dst, size_t dstCapacity, const void *src, size_t compressedSize)
ZSTD_CCtx * ZSTD_createCCtx_advanced(ZSTD_customMem customMem)
Definition: zstd_compress.c:81
size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams)
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)
unsigned long long ZSTD_findDecompressedSize(const void *src, size_t srcSize)
ZSTD_CStream * ZSTD_initStaticCStream(void *workspace, size_t workspaceSize)
ZSTDLIB_API const char * ZSTD_versionString(void)
Definition: zstd_common.c:27
ZSTDLIB_API size_t ZSTD_compressBound(size_t srcSize)
Definition: zstd_compress.c:44
ZSTDLIB_API size_t ZSTD_DCtx_refDDict(ZSTD_DCtx *dctx, const ZSTD_DDict *ddict)
size_t ZSTD_CCtx_loadDictionary_advanced(ZSTD_CCtx *cctx, const void *dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType)
ZSTDLIB_API ZSTD_CStream * ZSTD_createCStream(void)
size_t ZSTD_getFrameHeader(ZSTD_frameHeader *zfhPtr, const void *src, size_t srcSize)
ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx *dctx, const void *dict, size_t dictSize)
ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict *CDict)
GLenum src
Definition: glext.h:6340
Definition: inflate.c:139
size_t ZSTD_CCtxParams_getParameter(ZSTD_CCtx_params *CCtxParams, ZSTD_cParameter param, int *value)
ZSTDLIB_API ZSTD_bounds ZSTD_dParam_getBounds(ZSTD_dParameter dParam)
size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream *zcs, const ZSTD_CDict *cdict, ZSTD_frameParameters fParams, unsigned long long pledgedSrcSize)
size_t ZSTD_toFlushNow(ZSTD_CCtx *cctx)
ZSTDLIB_API unsigned ZSTD_getDictID_fromDict(const void *dict, size_t dictSize)
size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params *cctxParams, ZSTD_parameters params)
unsigned ZSTD_isFrame(const void *buffer, size_t size)
ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
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)
size_t pos
Definition: zstd.h:575
size_t ZSTD_initDStream_usingDDict(ZSTD_DStream *dctx, const ZSTD_DDict *ddict)
ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx *cctx, unsigned long long pledgedSrcSize)
ZSTDLIB_API size_t ZSTD_compress(void *dst, size_t dstCapacity, const void *src, size_t srcSize, int compressionLevel)
size_t size
Definition: zstd.h:568
ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize)
ZSTDLIB_API size_t ZSTD_initCStream(ZSTD_CStream *zcs, int compressionLevel)
ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream *zcs)
ZSTD_DCtx * ZSTD_createDCtx_advanced(ZSTD_customMem customMem)
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)
size_t ZSTD_decompressContinue(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
size_t ZSTD_estimateCStreamSize(int compressionLevel)
GLenum GLenum GLenum input
Definition: glext.h:9031
GLboolean reset
Definition: glext.h:5666
size_t ZSTD_CCtx_setParametersUsingCCtxParams(ZSTD_CCtx *cctx, const ZSTD_CCtx_params *params)
ZSTDLIB_API size_t ZSTD_DCtx_reset(ZSTD_DCtx *dctx, ZSTD_ResetDirective reset)
int consumed
Definition: scanf.h:134
ZSTDLIB_API unsigned ZSTD_versionNumber(void)
Definition: zstd_common.c:25
size_t ZSTD_CCtxParams_reset(ZSTD_CCtx_params *params)
ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict *ddict)
Definition: zstd_ddict.c:240
void * dst
Definition: zstd.h:573
size_t ZSTD_estimateDStreamSize_fromFrame(const void *src, size_t srcSize)
ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict *ddict)
Definition: zstd_ddict.c:212
GLenum GLenum dst
Definition: glext.h:6340
int lowerBound
Definition: zstd.h:421
int compressionLevel
Definition: zstd_compress.c:61
size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params *CCtxParams, ZSTD_cParameter param, int value)
#define NULL
Definition: types.h:112
ZSTDLIB_API size_t ZSTD_CCtx_reset(ZSTD_CCtx *cctx, ZSTD_ResetDirective reset)
ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize)
ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx *dctx)
ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream *zds)
size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx *dctx, const void *dict, size_t dictSize)
ZSTD_cParameter
Definition: zstd.h:265
const void * src
Definition: zstd.h:567
size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize)
size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx *dctx, size_t maxWindowSize)
size_t ZSTD_compressEnd(ZSTD_CCtx *cctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize)
ZSTD_CStream * ZSTD_createCStream_advanced(ZSTD_customMem customMem)
ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long srcSizeHint, size_t dictSize)
ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx *cctx, const ZSTD_CDict *cdict)
ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary_byReference(ZSTD_CCtx *cctx, const void *dict, size_t dictSize)
ZSTD_EndDirective
Definition: zstd.h:648
size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx *cctx, const ZSTD_CDict *cdict)
ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx *cctx)
void ZSTD_copyDCtx(ZSTD_DCtx *dstDCtx, const ZSTD_DCtx *srcDCtx)
ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx *cctx, const void *prefix, size_t prefixSize)
size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod)
Definition: zstd_ddict.c:225
ZSTD_CCtx * ZSTD_initStaticCCtx(void *workspace, size_t workspaceSize)
Definition: zstd_compress.c:93
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)
ZSTD_strategy
Definition: zstd.h:251
ZSTDLIB_API ZSTD_CDict * ZSTD_createCDict(const void *dictBuffer, size_t dictSize, int compressionLevel)
ZSTDLIB_API size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx *dctx, const void *prefix, size_t prefixSize)
size_t ZSTD_getBlockSize(const ZSTD_CCtx *cctx)
ZSTD_frameProgression ZSTD_getFrameProgression(const ZSTD_CCtx *cctx)
ZSTDLIB_API size_t ZSTD_endStream(ZSTD_CStream *zcs, ZSTD_outBuffer *output)
ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream *zds)
#define ZSTDLIB_API
Definition: zstd.h:35
struct ZSTD_outBuffer_s ZSTD_outBuffer
size_t ZSTD_CCtxParams_init(ZSTD_CCtx_params *cctxParams, int compressionLevel)