Class ZstdX

java.lang.Object
org.lwjgl.util.zstd.ZstdX

public class ZstdX extends Object
Native bindings to the experimental API of Zstandard (zstd).
  • Field Details

    • ZSTD_dct_auto

      public static final int ZSTD_dct_auto
      ZSTD_dictContentType_e
      Enum values:
      • dct_auto - dictionary is "full" when starting with MAGIC_DICTIONARY, otherwise it is "rawContent"
      • dct_rawContent - ensures dictionary is always loaded as rawContent, even if it starts with ZSTD_MAGIC_DICTIONARY
      • dct_fullDict - refuses to load a dictionary if it does not respect Zstandard's specification, starting with ZSTD_MAGIC_DICTIONARY
      See Also:
    • ZSTD_dct_rawContent

      public static final int ZSTD_dct_rawContent
      ZSTD_dictContentType_e
      Enum values:
      • dct_auto - dictionary is "full" when starting with MAGIC_DICTIONARY, otherwise it is "rawContent"
      • dct_rawContent - ensures dictionary is always loaded as rawContent, even if it starts with ZSTD_MAGIC_DICTIONARY
      • dct_fullDict - refuses to load a dictionary if it does not respect Zstandard's specification, starting with ZSTD_MAGIC_DICTIONARY
      See Also:
    • ZSTD_dct_fullDict

      public static final int ZSTD_dct_fullDict
      ZSTD_dictContentType_e
      Enum values:
      • dct_auto - dictionary is "full" when starting with MAGIC_DICTIONARY, otherwise it is "rawContent"
      • dct_rawContent - ensures dictionary is always loaded as rawContent, even if it starts with ZSTD_MAGIC_DICTIONARY
      • dct_fullDict - refuses to load a dictionary if it does not respect Zstandard's specification, starting with ZSTD_MAGIC_DICTIONARY
      See Also:
    • ZSTD_dlm_byCopy

      public static final int ZSTD_dlm_byCopy
      ZSTD_dictLoadMethod_e
      Enum values:
      • dlm_byCopy - Copy dictionary content internally
      • dlm_byRef - Reference dictionary content -- the dictionary buffer must outlive its users.
      See Also:
    • ZSTD_dlm_byRef

      public static final int ZSTD_dlm_byRef
      ZSTD_dictLoadMethod_e
      Enum values:
      • dlm_byCopy - Copy dictionary content internally
      • dlm_byRef - Reference dictionary content -- the dictionary buffer must outlive its users.
      See Also:
    • ZSTD_f_zstd1

      public static final int ZSTD_f_zstd1
      ZSTD_format_e
      Enum values:
      • f_zstd1 - zstd frame format, specified in zstd_compression_format.md (default)
      • f_zstd1_magicless - Variant of zstd frame format, without initial 4-bytes magic number. Useful to save 4 bytes per generated frame. Decoder cannot recognise automatically this format, requiring this instruction.
      See Also:
    • ZSTD_f_zstd1_magicless

      public static final int ZSTD_f_zstd1_magicless
      ZSTD_format_e
      Enum values:
      • f_zstd1 - zstd frame format, specified in zstd_compression_format.md (default)
      • f_zstd1_magicless - Variant of zstd frame format, without initial 4-bytes magic number. Useful to save 4 bytes per generated frame. Decoder cannot recognise automatically this format, requiring this instruction.
      See Also:
    • ZSTD_d_validateChecksum

      public static final int ZSTD_d_validateChecksum
      This enum controls d_forceIgnoreChecksum. ZSTD_forceIgnoreChecksum_e
      Enum values:
      See Also:
    • ZSTD_d_ignoreChecksum

      public static final int ZSTD_d_ignoreChecksum
      This enum controls d_forceIgnoreChecksum. ZSTD_forceIgnoreChecksum_e
      Enum values:
      See Also:
    • ZSTD_rmd_refSingleDDict

      public static final int ZSTD_rmd_refSingleDDict
      This enum controls d_refMultipleDDicts. ZSTD_refMultipleDDicts_e
      Enum values:
      See Also:
    • ZSTD_rmd_refMultipleDDicts

      public static final int ZSTD_rmd_refMultipleDDicts
      This enum controls d_refMultipleDDicts. ZSTD_refMultipleDDicts_e
      Enum values:
      See Also:
    • ZSTD_dictDefaultAttach

      public static final int ZSTD_dictDefaultAttach
      ZSTD_dictAttachPref_e
      Enum values:
      See Also:
    • ZSTD_dictForceAttach

      public static final int ZSTD_dictForceAttach
      ZSTD_dictAttachPref_e
      Enum values:
      See Also:
    • ZSTD_dictForceCopy

      public static final int ZSTD_dictForceCopy
      ZSTD_dictAttachPref_e
      Enum values:
      See Also:
    • ZSTD_dictForceLoad

      public static final int ZSTD_dictForceLoad
      ZSTD_dictAttachPref_e
      Enum values:
      See Also:
    • ZSTD_frame

      public static final int ZSTD_frame
      ZSTD_frameType_e
      Enum values:
      See Also:
    • ZSTD_skippableFrame

      public static final int ZSTD_skippableFrame
      ZSTD_frameType_e
      Enum values:
      See Also:
    • ZSTDnit_frameHeader

      public static final int ZSTDnit_frameHeader
      See Also:
    • ZSTDnit_blockHeader

      public static final int ZSTDnit_blockHeader
      See Also:
    • ZSTDnit_block

      public static final int ZSTDnit_block
      See Also:
    • ZSTDnit_lastBlock

      public static final int ZSTDnit_lastBlock
      See Also:
    • ZSTDnit_checksum

      public static final int ZSTDnit_checksum
      See Also:
    • ZSTDnit_skippableFrame

      public static final int ZSTDnit_skippableFrame
      See Also:
    • ZSTD_FRAMEHEADERSIZE_MAX

      public static final int ZSTD_FRAMEHEADERSIZE_MAX
      See Also:
    • ZSTD_SKIPPABLEHEADERSIZE

      public static final int ZSTD_SKIPPABLEHEADERSIZE
      See Also:
    • ZSTD_WINDOWLOG_MAX_32

      public static final int ZSTD_WINDOWLOG_MAX_32
      See Also:
    • ZSTD_WINDOWLOG_MAX_64

      public static final int ZSTD_WINDOWLOG_MAX_64
      See Also:
    • ZSTD_WINDOWLOG_MAX

      public static final int ZSTD_WINDOWLOG_MAX
    • ZSTD_WINDOWLOG_MIN

      public static final int ZSTD_WINDOWLOG_MIN
      See Also:
    • ZSTD_HASHLOG_MAX

      public static final int ZSTD_HASHLOG_MAX
    • ZSTD_HASHLOG_MIN

      public static final int ZSTD_HASHLOG_MIN
      See Also:
    • ZSTD_CHAINLOG_MAX_32

      public static final int ZSTD_CHAINLOG_MAX_32
      See Also:
    • ZSTD_CHAINLOG_MAX_64

      public static final int ZSTD_CHAINLOG_MAX_64
      See Also:
    • ZSTD_CHAINLOG_MAX

      public static final int ZSTD_CHAINLOG_MAX
    • ZSTD_CHAINLOG_MIN

      public static final int ZSTD_CHAINLOG_MIN
      See Also:
    • ZSTD_SEARCHLOG_MIN

      public static final int ZSTD_SEARCHLOG_MIN
      See Also:
    • ZSTD_MINMATCH_MAX

      public static final int ZSTD_MINMATCH_MAX
      See Also:
    • ZSTD_MINMATCH_MIN

      public static final int ZSTD_MINMATCH_MIN
      See Also:
    • ZSTD_TARGETLENGTH_MAX

      public static final int ZSTD_TARGETLENGTH_MAX
      See Also:
    • ZSTD_TARGETLENGTH_MIN

      public static final int ZSTD_TARGETLENGTH_MIN
      See Also:
    • ZSTD_STRATEGY_MIN

      public static final int ZSTD_STRATEGY_MIN
      See Also:
    • ZSTD_STRATEGY_MAX

      public static final int ZSTD_STRATEGY_MAX
      See Also:
    • ZSTD_BLOCKSIZE_MAX_MIN

      public static final int ZSTD_BLOCKSIZE_MAX_MIN
      The minimum valid max blocksize. Maximum blocksizes smaller than this make compressBound() inaccurate.
      See Also:
    • ZSTD_OVERLAPLOG_MIN

      public static final int ZSTD_OVERLAPLOG_MIN
      See Also:
    • ZSTD_OVERLAPLOG_MAX

      public static final int ZSTD_OVERLAPLOG_MAX
      See Also:
    • ZSTD_WINDOWLOG_LIMIT_DEFAULT

      public static final int ZSTD_WINDOWLOG_LIMIT_DEFAULT
      See Also:
    • ZSTD_LDM_HASHLOG_MIN

      public static final int ZSTD_LDM_HASHLOG_MIN
      See Also:
    • ZSTD_LDM_HASHLOG_MAX

      public static final int ZSTD_LDM_HASHLOG_MAX
    • ZSTD_LDM_MINMATCH_MIN

      public static final int ZSTD_LDM_MINMATCH_MIN
      See Also:
    • ZSTD_LDM_MINMATCH_MAX

      public static final int ZSTD_LDM_MINMATCH_MAX
      See Also:
    • ZSTD_LDM_BUCKETSIZELOG_MIN

      public static final int ZSTD_LDM_BUCKETSIZELOG_MIN
      See Also:
    • ZSTD_LDM_BUCKETSIZELOG_MAX

      public static final int ZSTD_LDM_BUCKETSIZELOG_MAX
      See Also:
    • ZSTD_LDM_HASHRATELOG_MIN

      public static final int ZSTD_LDM_HASHRATELOG_MIN
      See Also:
    • ZSTD_TARGETCBLOCKSIZE_MIN

      public static final int ZSTD_TARGETCBLOCKSIZE_MIN
      See Also:
    • ZSTD_TARGETCBLOCKSIZE_MAX

      public static final int ZSTD_TARGETCBLOCKSIZE_MAX
      See Also:
    • ZSTD_SRCSIZEHINT_MIN

      public static final int ZSTD_SRCSIZEHINT_MIN
      See Also:
    • ZSTD_SRCSIZEHINT_MAX

      public static final int ZSTD_SRCSIZEHINT_MAX
      See Also:
    • ZSTD_c_rsyncable

      public static final int ZSTD_c_rsyncable
      Enables rsyncable mode, which makes compressed files more rsync friendly by adding periodic synchronization points to the compressed data. The target average block size is c_jobSize / 2. It's possible to modify the job size to increase or decrease the granularity of the synchronization point. Once the jobSize is smaller than the window size, it will result in compression ratio degradation.

      NOTE 1: rsyncable mode only works when multithreading is enabled.

      NOTE 2: rsyncable performs poorly in combination with long range mode, since it will decrease the effectiveness of synchronization points, though mileage may vary.

      NOTE 3: Rsyncable mode limits maximum compression speed to ~400 MB/s. If the selected compression level is already running significantly slower, the overall speed won't be significantly impacted.

      See Also:
    • ZSTD_c_format

      public static final int ZSTD_c_format
      Select a compression format.

      The value must be of type ZSTD_format_e.

      See Also:
    • ZSTD_c_forceMaxWindow

      public static final int ZSTD_c_forceMaxWindow
      Force back-reference distances to remain < windowSize, even when referencing into Dictionary content. (default:0)
      See Also:
    • ZSTD_c_forceAttachDict

      public static final int ZSTD_c_forceAttachDict
      Controls whether the contents of a CDict are used in place, or copied into the working context.

      Accepts values from the ZSTD_dictAttachPref_e enum.

      See Also:
    • ZSTD_c_literalCompressionMode

      public static final int ZSTD_c_literalCompressionMode
      Controlled with ZSTD_paramSwitch_e enum.
      • Default is ps_auto.
      • Set to ps_disable to never compress literals.
      • Set to ps_enable to always compress literals. (Note: uncompressed literals may still be emitted if huffman is not beneficial to use.)

      By default, in ZSTD_ps_auto, the library will decide at runtime whether to use literals compression based on the compression parameters - specifically, negative compression levels do not use literal compression.

      See Also:
    • ZSTD_c_targetCBlockSize

      public static final int ZSTD_c_targetCBlockSize
      Tries to fit compressed block size to be around targetCBlockSize.

      No target when targetCBlockSize == 0. There is no guarantee on compressed block size. (default:0)

      See Also:
    • ZSTD_c_srcSizeHint

      public static final int ZSTD_c_srcSizeHint
      User's best guess of source size.

      Hint is not valid when srcSizeHint == 0. There is no guarantee that hint is close to actual source size, but compression ratio may regress significantly if guess considerably underestimates.

      See Also:
    • ZSTD_c_enableDedicatedDictSearch

      public static final int ZSTD_c_enableDedicatedDictSearch
      Controls whether the new and experimental "dedicated dictionary search structure" can be used. This feature is still rough around the edges, be prepared for surprising behavior!
      How to use it:

      When using a CDict, whether to use this feature or not is controlled at CDict creation, and it must be set in a CCtxParams set passed into that construction (via createCDict_advanced2). A compression will then use the feature or not based on how the CDict was constructed; the value of this param, set in the CCtx, will have no effect.

      However, when a dictionary buffer is passed into a CCtx, such as via CCtx_loadDictionary, this param can be set on the CCtx to control whether the CDict that is created internally can use the feature or not.

      What it does:

      Normally, the internal data structures of the CDict are analogous to what would be stored in a CCtx after compressing the contents of a dictionary. To an approximation, a compression using a dictionary can then use those data structures to simply continue what is effectively a streaming compression where the simulated compression of the dictionary left off. Which is to say, the search structures in the CDict are normally the same format as in the CCtx.

      It is possible to do better, since the CDict is not like a CCtx: the search structures are written once during CDict creation, and then are only read after that, while the search structures in the CCtx are both read and written as the compression goes along. This means we can choose a search structure for the dictionary that is read-optimized.

      This feature enables the use of that different structure.

      Note that some of the members of the ZSTD_compressionParameters struct have different semantics and constraints in the dedicated search structure. It is highly recommended that you simply set a compression level in the CCtxParams you pass into the CDict creation call, and avoid messing with the cParams directly.

      Effects:

      This will only have any effect when the selected ZSTD_strategy implementation supports this feature. Currently, that's limited to greedy, lazy, and lazy2.

      Note that this means that the CDict tables can no longer be copied into the CCtx, so the dict attachment mode dictForceCopy will no longer be usable. The dictionary can only be attached or reloaded.

      In general, you should expect compression to be faster--sometimes very much so--and CDict creation to be slightly slower. Eventually, we will probably make this mode the default.

      See Also:
    • ZSTD_c_stableInBuffer

      public static final int ZSTD_c_stableInBuffer
      Experimental parameter. Default is 0 == disabled. Set to 1 to enable.

      Tells the compressor that input data presented with ZSTD_inBuffer will ALWAYS be the same between calls. Technically, the src pointer must never be changed, and the pos field can only be updated by zstd. However, it's possible to increase the size field, allowing scenarios where more data can be appended after compressions starts. These conditions are checked by the compressor, and compression will fail if they are not respected. Also, data in the ZSTD_inBuffer within the range [src, src + pos) MUST not be modified during compression or it will result in data corruption.

      When this flag is enabled zstd won't allocate an input window buffer, because the user guarantees it can reference the ZSTD_inBuffer until the frame is complete. But, it will still allocate an output buffer large enough to fit a block (see c_stableOutBuffer). This will also avoid the memcpy() from the input buffer to the input window buffer.

      NOTE: So long as the ZSTD_inBuffer always points to valid memory, using this flag is ALWAYS memory safe, and will never access out-of-bounds memory. However, compression WILL fail if conditions are not respected.

      WARNING: The data in the ZSTD_inBuffer in the range [src, src + pos) MUST not be modified during compression or it will result in data corruption. This is because zstd needs to reference data in the ZSTD_inBuffer to find matches. Normally zstd maintains its own window buffer for this purpose, but passing this flag tells zstd to rely on user provided buffer instead.

      See Also:
    • ZSTD_c_stableOutBuffer

      public static final int ZSTD_c_stableOutBuffer
      Experimental parameter. Default is 0 == disabled. Set to 1 to enable.

      Tells he compressor that the ZSTD_outBuffer will not be resized between calls. Specifically: (out.size - out.pos) will never grow. This gives the compressor the freedom to say: If the compressed data doesn't fit in the output buffer then return error_dstSize_tooSmall. This allows us to always decompress directly into the output buffer, instead of decompressing into an internal buffer and copying to the output buffer.

      When this flag is enabled zstd won't allocate an output buffer, because it can write directly to the ZSTD_outBuffer. It will still allocate the input window buffer (see c_stableInBuffer).

      Zstd will check that (out.size - out.pos) never grows and return an error if it does. While not strictly necessary, this should prevent surprises.

      See Also:
    • ZSTD_c_blockDelimiters

      public static final int ZSTD_c_blockDelimiters
      Default is 0 == ZSTD_sf_noBlockDelimiters.

      For use with sequence compression API: compressSequences.

      Designates whether or not the given array of ZSTD_Sequence contains block delimiters and last literals, which are defined as sequences with offset == 0 and matchLength == 0. See the definition of ZSTD_Sequence for more specifics.

      See Also:
    • ZSTD_c_validateSequences

      public static final int ZSTD_c_validateSequences
      Default is 0 == disabled. Set to 1 to enable sequence validation.

      For use with sequence compression API: compressSequences. Designates whether or not we validate sequences provided to ZSTD_compressSequences() during function execution.

      Without validation, providing a sequence that does not conform to the zstd spec will cause undefined behavior, and may produce a corrupted block.

      With validation enabled, if sequence is invalid (see doc/zstd_compression_format.md for specifics regarding offset/matchlength requirements) then the function will bail out and return an error.

      See Also:
    • ZSTD_c_useBlockSplitter

      public static final int ZSTD_c_useBlockSplitter
      Controlled with ZSTD_paramSwitch_e enum.

      By default, in ZSTD_ps_auto, the library will decide at runtime whether to use block splitting based on the compression parameters.

      See Also:
    • ZSTD_c_useRowMatchFinder

      public static final int ZSTD_c_useRowMatchFinder
      Controlled with ZSTD_paramSwitch_e enum.
      • Default is ps_auto.
      • Set to ps_disable to never use row-based matchfinder.
      • Set to ps_enable to force usage of row-based matchfinder.

      By default, in ZSTD_ps_auto, the library will decide at runtime whether to use the row-based matchfinder based on support for SIMD instructions and the window log. Note that this only pertains to compression strategies: greedy, lazy, and lazy2.

      See Also:
    • ZSTD_c_deterministicRefPrefix

      public static final int ZSTD_c_deterministicRefPrefix
      Default is 0 == disabled. Set to 1 to enable.

      Zstd produces different results for prefix compression when the prefix is directly adjacent to the data about to be compressed vs. when it isn't. This is because zstd detects that the two buffers are contiguous and it can use a more efficient match finding algorithm. However, this produces different results than when the two buffers are non-contiguous. This flag forces zstd to always load the prefix in non-contiguous mode, even if it happens to be adjacent to the data, to guarantee determinism.

      If you really care about determinism when using a dictionary or prefix, like when doing delta compression, you should select this option. It comes at a speed penalty of about ~2.5% if the dictionary and data happened to be contiguous, and is free if they weren't contiguous. We don't expect that intentionally making the dictionary and data contiguous will be worth the cost to memcpy() the data.

      See Also:
    • ZSTD_c_prefetchCDictTables

      public static final int ZSTD_c_prefetchCDictTables
      Controlled with ZSTD_paramSwitch_e enum. Default is ZSTD_ps_auto.

      In some situations, zstd uses CDict tables in-place rather than copying them into the working context. (See docs on ZSTD_dictAttachPref_e for details). In such situations, compression speed is seriously impacted when CDict tables are "cold" (outside CPU cache). This parameter instructs zstd to prefetch CDict tables when they are used in-place.

      For sufficiently small inputs, the cost of the prefetch will outweigh the benefit. For sufficiently large inputs, zstd will by default memcpy() CDict tables into the working context, so there is no need to prefetch. This parameter is targeted at a middle range of input sizes, where a prefetch is cheap enough to be useful but memcpy() is too expensive. The exact range of input sizes where this makes sense is best determined by careful experimentation.

      Note: for this parameter, ps_auto is currently equivalent to ps_disable, but in the future zstd may conditionally enable this feature via an auto-detection heuristic for cold CDicts. Use ZSTD_ps_disable to opt out of prefetching under any circumstances.

      See Also:
    • ZSTD_c_enableSeqProducerFallback

      public static final int ZSTD_c_enableSeqProducerFallback
      Allowed values are 0 (disable) and 1 (enable). The default setting is 0.

      Controls whether zstd will fall back to an internal sequence producer if an external sequence producer is registered and returns an error code. This fallback is block-by-block: the internal sequence producer will only be called for blocks where the external sequence producer returns an error code. Fallback parsing will follow any other cParam settings, such as compression level, the same as in a normal (fully-internal) compression operation.

      The user is strongly encouraged to read the full Block-Level Sequence Producer API documentation (below) before setting this parameter.

      See Also:
    • ZSTD_c_maxBlockSize

      public static final int ZSTD_c_maxBlockSize
      Allowed values are between 1KB and BLOCKSIZE_MAX (128KB). The default is ZSTD_BLOCKSIZE_MAX, and setting to 0 will set to the default.

      This parameter can be used to set an upper bound on the blocksize that overrides the default ZSTD_BLOCKSIZE_MAX. It cannot be used to set upper bounds greater than ZSTD_BLOCKSIZE_MAX or bounds lower than 1KB (will make compressBound inaccurate). Only currently meant to be used for testing.

      See Also:
    • ZSTD_c_searchForExternalRepcodes

      public static final int ZSTD_c_searchForExternalRepcodes
      This parameter affects how zstd parses external sequences, such as sequences provided through the compressSequences API or from an external block-level sequence producer.

      If set to ps_enable, the library will check for repeated offsets in external sequences, even if those repcodes are not explicitly indicated in the "rep" field. Note that this is the only way to exploit repcode matches while using compressSequences() or an external sequence producer, since zstd currently ignores the "rep" field of external sequences.

      If set to ps_disable, the library will not exploit repeated offsets in external sequences, regardless of whether the "rep" field has been set. This reduces sequence compression overhead by about 25% while sacrificing some compression ratio.

      The default value is ps_auto, for which the library will enable/disable based on compression level.

      Note: for now, this param only has an effect if c_blockDelimiters is set to sf_explicitBlockDelimiters. That may change in the future.

      See Also:
    • ZSTD_d_format

      public static final int ZSTD_d_format
      Experimental parameter.

      Allows selection between ZSTD_format_e input compression formats.

      See Also:
    • ZSTD_d_stableOutBuffer

      public static final int ZSTD_d_stableOutBuffer
      Experimental parameter. Default is 0 == disabled. Set to 1 to enable.

      Tells the decompressor that the ZSTD_outBuffer will ALWAYS be the same between calls, except for the modifications that zstd makes to pos (the caller must not modify pos). This is checked by the decompressor, and decompression will fail if it ever changes. Therefore the ZSTD_outBuffer MUST be large enough to fit the entire decompressed frame. This will be checked when the frame content size is known. The data in the ZSTD_outBuffer in the range [dst, dst + pos) MUST not be modified during decompression or you will get data corruption.

      When this flag is enabled zstd won't allocate an output buffer, because it can write directly to the ZSTD_outBuffer, but it will still allocate an input buffer large enough to fit any compressed block. This will also avoid the memcpy() from the internal output buffer to the ZSTD_outBuffer. If you need to avoid the input buffer allocation use the buffer-less streaming API.

      NOTE: So long as the ZSTD_outBuffer always points to valid memory, using this flag is ALWAYS memory safe, and will never access out-of-bounds memory. However, decompression WILL fail if you violate the preconditions.

      WARNING: The data in the ZSTD_outBuffer in the range [dst, dst + pos) MUST not be modified during decompression or you will get data corruption. This is because zstd needs to reference data in the ZSTD_outBuffer to regenerate matches. Normally zstd maintains its own buffer for this purpose, but passing this flag tells zstd to use the user provided buffer.

      See Also:
    • ZSTD_d_forceIgnoreChecksum

      public static final int ZSTD_d_forceIgnoreChecksum
      Experimental parameter. Default is 0 == disabled. Set to 1 to enable

      Tells the decompressor to skip checksum validation during decompression, regardless of whether checksumming was specified during compression. This offers some slight performance benefits, and may be useful for debugging. Param has values of type ZSTD_forceIgnoreChecksum_e.

      See Also:
    • ZSTD_d_refMultipleDDicts

      public static final int ZSTD_d_refMultipleDDicts
      Experimental parameter. Default is 0 == disabled. Set to 1 to enable

      If enabled and dctx is allocated on the heap, then additional memory will be allocated to store references to multiple ZSTD_DDict. That is, multiple calls of DCtx_refDDict using a given ZSTD_DCtx, rather than overwriting the previous DDict reference, will instead store all references. At decompression time, the appropriate dictID is selected from the set of DDicts based on the dictID in the frame.

      Usage is simply calling ZSTD_DCtx_refDDict() on multiple dict buffers.

      Param has values of byte ZSTD_refMultipleDDicts_e.

      WARNING: Enabling this parameter and calling ZSTD_DCtx_refDDict(), will trigger memory allocation for the hash table. freeDCtx also frees this memory. Memory is allocated as per ZSTD_DCtx::customMem.

      Although this function allocates memory for the table, the user is still responsible for memory management of the underlying ZSTD_DDict themselves.

      See Also:
    • ZSTD_d_disableHuffmanAssembly

      public static final int ZSTD_d_disableHuffmanAssembly
      Set to 1 to disable the Huffman assembly implementation.

      The default value is 0, which allows zstd to use the Huffman assembly implementation if available.

      This parameter can be used to disable Huffman assembly at runtime. If you want to disable it at compile time you can define the macro ZSTD_DISABLE_ASM.

      See Also:
    • ZSTD_lcm_auto

      public static final int ZSTD_lcm_auto
      ZSTD_literalCompressionMode_e
      Enum values:
      • lcm_auto - Automatically determine the compression mode based on the compression level.

        Negative compression levels will be uncompressed, and positive compression levels will be compressed.

      • lcm_huffman - Always attempt Huffman compression. Uncompressed literals will still be emitted if Huffman compression is not profitable.
      • lcm_uncompressed - Always emit uncompressed literals.
      See Also:
    • ZSTD_lcm_huffman

      public static final int ZSTD_lcm_huffman
      ZSTD_literalCompressionMode_e
      Enum values:
      • lcm_auto - Automatically determine the compression mode based on the compression level.

        Negative compression levels will be uncompressed, and positive compression levels will be compressed.

      • lcm_huffman - Always attempt Huffman compression. Uncompressed literals will still be emitted if Huffman compression is not profitable.
      • lcm_uncompressed - Always emit uncompressed literals.
      See Also:
    • ZSTD_lcm_uncompressed

      public static final int ZSTD_lcm_uncompressed
      ZSTD_literalCompressionMode_e
      Enum values:
      • lcm_auto - Automatically determine the compression mode based on the compression level.

        Negative compression levels will be uncompressed, and positive compression levels will be compressed.

      • lcm_huffman - Always attempt Huffman compression. Uncompressed literals will still be emitted if Huffman compression is not profitable.
      • lcm_uncompressed - Always emit uncompressed literals.
      See Also:
    • ZSTD_ps_auto

      public static final int ZSTD_ps_auto
      ZSTD_paramSwitch_e

      This enum controls features which are conditionally beneficial. Zstd typically will make a final decision on whether or not to enable the feature (ZSTD_ps_auto), but setting the switch to ZSTD_ps_enable or ZSTD_ps_disable allow for a force enable/disable the feature.

      Enum values:
      • ps_auto - Let the library automatically determine whether the feature shall be enabled.
      • ps_enable - Force-enable the feature.
      • ps_disable - Do not use the feature.
      See Also:
    • ZSTD_ps_enable

      public static final int ZSTD_ps_enable
      ZSTD_paramSwitch_e

      This enum controls features which are conditionally beneficial. Zstd typically will make a final decision on whether or not to enable the feature (ZSTD_ps_auto), but setting the switch to ZSTD_ps_enable or ZSTD_ps_disable allow for a force enable/disable the feature.

      Enum values:
      • ps_auto - Let the library automatically determine whether the feature shall be enabled.
      • ps_enable - Force-enable the feature.
      • ps_disable - Do not use the feature.
      See Also:
    • ZSTD_ps_disable

      public static final int ZSTD_ps_disable
      ZSTD_paramSwitch_e

      This enum controls features which are conditionally beneficial. Zstd typically will make a final decision on whether or not to enable the feature (ZSTD_ps_auto), but setting the switch to ZSTD_ps_enable or ZSTD_ps_disable allow for a force enable/disable the feature.

      Enum values:
      • ps_auto - Let the library automatically determine whether the feature shall be enabled.
      • ps_enable - Force-enable the feature.
      • ps_disable - Do not use the feature.
      See Also:
    • ZSTD_sf_noBlockDelimiters

      public static final int ZSTD_sf_noBlockDelimiters
      ZSTD_sequenceFormat_e
      Enum values:
      See Also:
    • ZSTD_sf_explicitBlockDelimiters

      public static final int ZSTD_sf_explicitBlockDelimiters
      ZSTD_sequenceFormat_e
      Enum values:
      See Also:
    • ZSTD_SEQUENCE_PRODUCER_ERROR

      public static final long ZSTD_SEQUENCE_PRODUCER_ERROR
      See Also:
  • Method Details

    • nZSTD_findDecompressedSize

      public static long nZSTD_findDecompressedSize(long src, long srcSize)
      Unsafe version of: findDecompressedSize
      Parameters:
      srcSize - must be the exact size of this series (i.e. there should be a frame boundary exactly at srcSize bytes after src + srcSize)
    • ZSTD_findDecompressedSize

      public static long ZSTD_findDecompressedSize(ByteBuffer src)
      Note 1: decompressed size is an optional field, that may not be present, especially in streaming mode. When return==ZSTD_CONTENTSIZE_UNKNOWN, data to decompress could be any size. In which case, it's necessary to use streaming mode to decompress data.

      Note 2: decompressed size is always present when compression is done with compress.

      Note 3: decompressed size can be very large (64-bits value), potentially larger than what local system can handle as a single memory segment. In which case, it's necessary to use streaming mode to decompress data.

      Note 4: If source is untrusted, decompressed size could be wrong or intentionally modified. Always ensure result fits within application's authorized limits. Each application can set its own limits.

      Note 5: ZSTD_findDecompressedSize handles multiple frames, and so it must traverse the input to read each contained frame header. This is fast as most of the data is skipped, however it does mean that all frame data must be present and valid.

      Parameters:
      src - should point to the start of a series of ZSTD encoded and/or skippable frames
      Returns:
    • nZSTD_decompressBound

      public static long nZSTD_decompressBound(long src, long srcSize)
      Unsafe version of: decompressBound
      Parameters:
      srcSize - must be the exact size of this series (i.e. there should be a frame boundary at src + srcSize)
    • ZSTD_decompressBound

      public static long ZSTD_decompressBound(ByteBuffer src)
      Note 1: an error can occur if src contains an invalid or incorrectly formatted frame.

      Note 2: the upper-bound is exact when the decompressed size field is available in every ZSTD encoded frame of src. In this case, findDecompressedSize and ZSTD_decompressBound return the same value.

      Note 3: when the decompressed size field isn't available, the upper-bound for that frame is calculated by: upper-bound = # blocks * min(128 KB, Window_Size)

      Parameters:
      src - should point to the start of a series of ZSTD encoded and/or skippable frames
      Returns:
      upper-bound for the decompressed size of all data in all successive frames, or CONTENTSIZE_ERROR if an error occurred
    • nZSTD_frameHeaderSize

      public static long nZSTD_frameHeaderSize(long src, long srcSize)
      Unsafe version of: frameHeaderSize
      Parameters:
      srcSize - must be ≥ ZSTD_FRAMEHEADERSIZE_PREFIX(int)
    • ZSTD_frameHeaderSize

      public static long ZSTD_frameHeaderSize(ByteBuffer src)
      Returns:
      : size of the Frame Header, or an error code (if srcSize is too small)
    • nZSTD_getFrameHeader

      public static long nZSTD_getFrameHeader(long zfhPtr, long src, long srcSize)
      Unsafe version of: getFrameHeader
    • ZSTD_getFrameHeader

      public static long ZSTD_getFrameHeader(ZSTDFrameHeader zfhPtr, ByteBuffer src)
      Decode Frame Header, or requires larger srcSize.
      Returns:
      0, zfhPtr is correctly filled, >0, srcSize is too small, value is wanted srcSize amount, or an error code, which can be tested using isError
    • nZSTD_getFrameHeader_advanced

      public static long nZSTD_getFrameHeader_advanced(long zfhPtr, long src, long srcSize, int format)
      Unsafe version of: getFrameHeader_advanced
    • ZSTD_getFrameHeader_advanced

      public static long ZSTD_getFrameHeader_advanced(ZSTDFrameHeader zfhPtr, ByteBuffer src, int format)
      Same as getFrameHeader, with added capability to select a format (like f_zstd1_magicless).
      Parameters:
      format - one of:
      f_zstd1f_zstd1_magicless
    • nZSTD_decompressionMargin

      public static long nZSTD_decompressionMargin(long src, long srcSize)
      Unsafe version of: decompressionMargin
      Parameters:
      srcSize - the size of the compressed frame(s)
    • ZSTD_decompressionMargin

      public static long ZSTD_decompressionMargin(ByteBuffer src)
      Zstd supports in-place decompression, where the input and output buffers overlap. In this case, the output buffer must be at least (Margin + Output_Size) bytes large, and the input buffer must be at the end of the output buffer.
      
       _______________________ Output Buffer ________________________
       |                                                              |
       |                                        ____ Input Buffer ____|
       |                                       |                      |
       v                                       v                      v
       |---------------------------------------|-----------|----------|
       ^                                                   ^          ^
       |___________________ Output_Size ___________________|_ Margin _|

      This applies only to single-pass decompression through decompress or decompressDCtx. This function supports multi-frame input.

      Parameters:
      src - the compressed frame(s)
      Returns:
      the decompression margin or an error that can be checked with isError.
    • ZSTD_sequenceBound

      public static long ZSTD_sequenceBound(long srcSize)
      Parameters:
      srcSize - size of the input buffer
      Returns:
      upper-bound for the number of sequences that can be generated from a buffer of srcSize bytes
    • nZSTD_generateSequences

      public static long nZSTD_generateSequences(long zc, long outSeqs, long outSeqsSize, long src, long srcSize)
      Unsafe version of: generateSequences
    • ZSTD_generateSequences

      public static long ZSTD_generateSequences(long zc, ZSTDSequence.Buffer outSeqs, ByteBuffer src)
      Generate sequences using compress2, given a source buffer.

      Each block will end with a dummy sequence with offset == 0, matchLength == 0, and litLength == length of last literals. litLength may be == 0, and if so, then the sequence of (of: 0 ml: 0 ll: 0) simply acts as a block delimiter.

      zc can be used to insert custom compression params. This function invokes compress2

      The output of this function can be fed into compressSequences with CCtx setting of c_blockDelimiters as sf_explicitBlockDelimiters.

      Returns:
      number of sequences generated
    • nZSTD_mergeBlockDelimiters

      public static long nZSTD_mergeBlockDelimiters(long sequences, long seqsSize)
      Unsafe version of: mergeBlockDelimiters
    • ZSTD_mergeBlockDelimiters

      public static long ZSTD_mergeBlockDelimiters(ZSTDSequence.Buffer sequences)
      Given an array of ZSTD_Sequence, remove all sequences that represent block delimiters/last literals by merging them into the literals of the next sequence.

      As such, the final generated result has no explicit representation of block boundaries, and the final last literals segment is not represented in the sequences.

      The output of this function can be fed into compressSequences with CCtx setting of c_blockDelimiters as sf_noBlockDelimiters.

      Returns:
      number of sequences left after merging
    • nZSTD_compressSequences

      public static long nZSTD_compressSequences(long cctx, long dst, long dstSize, long inSeqs, long inSeqsSize, long src, long srcSize)
      Unsafe version of: compressSequences
    • ZSTD_compressSequences

      public static long ZSTD_compressSequences(long cctx, ByteBuffer dst, ZSTDSequence.Buffer inSeqs, ByteBuffer src)
      Compress an array of ZSTD_Sequence, associated with src buffer, into dst.

      src contains the entire input (not just the literals). If srcSize > sum(sequence.length), the remaining bytes are considered all literals.

      If a dictionary is included, then the cctx should reference the dict. (see: CCtx_refCDict, CCtx_loadDictionary, etc.) The entire source is compressed into a single frame.

      The compression behavior changes based on cctx params. In particular:

      • If ZSTD_c_blockDelimiters == ZSTD_sf_noBlockDelimiters, the array of ZSTD_Sequence is expected to contain no block delimiters (defined in ZSTD_Sequence). Block boundaries are roughly determined based on the block size derived from the cctx, and sequences may be split. This is the default setting.
      • If ZSTD_c_blockDelimiters == ZSTD_sf_explicitBlockDelimiters, the array of ZSTD_Sequence is expected to contain block delimiters (defined in ZSTD_Sequence). Behavior is undefined if no block delimiters are provided.
      • If ZSTD_c_validateSequences == 0, this function will blindly accept the sequences provided. Invalid sequences cause undefined behavior. If ZSTD_c_validateSequences == 1, then if sequence is invalid (see doc/zstd_compression_format.md for specifics regarding offset/matchlength requirements) then the function will bail out and return an error.

      In addition to the two adjustable experimental params, there are other important cctx params.

      • c_minMatch MUST be set as less than or equal to the smallest match generated by the match finder. It has a minimum value of MINMATCH_MIN.
      • c_compressionLevel accordingly adjusts the strength of the entropy coder, as it would in typical compression.
      • c_windowLog affects offset validation: this function will return an error at higher debug levels if a provided offset is larger than what the spec allows for a given window log and dictionary (if present). See: doc/zstd_compression_format.md

      Note: Repcodes are, as of now, always re-calculated within this function, so ZSTD_Sequence::rep is unused.

      Note 2: Once we integrate ability to ingest repcodes, the explicit block delims mode must respect those repcodes exactly, and cannot emit an RLE block that disagrees with the repcode history.

      Returns:
      final compressed size, or a ZSTD error code.
    • nZSTD_writeSkippableFrame

      public static long nZSTD_writeSkippableFrame(long dst, long dstCapacity, long src, long srcSize, int magicVariant)
      Unsafe version of: writeSkippableFrame
    • ZSTD_writeSkippableFrame

      public static long ZSTD_writeSkippableFrame(ByteBuffer dst, ByteBuffer src, int magicVariant)
      Generates a zstd skippable frame containing data given by src, and writes it to dst buffer.

      Skippable frames begin with a 4-byte magic number. There are 16 possible choices of magic number, ranging from MAGIC_SKIPPABLE_START to ZSTD_MAGIC_SKIPPABLE_START+15. As such, the parameter magicVariant controls the exact skippable frame magic number variant used, so the magic number used will be ZSTD_MAGIC_SKIPPABLE_START + magicVariant.

      Returns an error if destination buffer is not large enough, if the source size is not representable with a 4-byte unsigned int, or if the parameter magicVariant is greater than 15 (and therefore invalid).

      Returns:
      number of bytes written or a ZSTD error
    • nZSTD_readSkippableFrame

      public static long nZSTD_readSkippableFrame(long dst, long dstCapacity, long magicVariant, long src, long srcSize)
      Unsafe version of: readSkippableFrame
    • ZSTD_readSkippableFrame

      public static long ZSTD_readSkippableFrame(ByteBuffer dst, @Nullable IntBuffer magicVariant, ByteBuffer src)
      Retrieves a zstd skippable frame containing data given by src, and writes it to dst buffer.

      The parameter magicVariant will receive the magicVariant that was supplied when the frame was written, i.e. magicNumber - ZSTD_MAGIC_SKIPPABLE_START. This can be NULL if the caller is not interested in the magicVariant.

      Returns an error if destination buffer is not large enough, or if the frame is not skippable.

      Returns:
      number of bytes written or a ZSTD error
    • nZSTD_isSkippableFrame

      public static int nZSTD_isSkippableFrame(long buffer, long size)
      Unsafe version of: isSkippableFrame
    • ZSTD_isSkippableFrame

      public static boolean ZSTD_isSkippableFrame(ByteBuffer buffer)
      Tells if the content of buffer starts with a valid Frame Identifier for a skippable frame.
    • ZSTD_estimateCCtxSize

      public static long ZSTD_estimateCCtxSize(int compressionLevel)
      Estimages memory usage of a future CCtx, before its creation.

      ZSTD_estimateCCtxSize() will provide a memory budget large enough for any compression level up to selected one.

      Note: Unlike ZSTD_estimateCStreamSize*(), this estimate does not include space for a window buffer. Therefore, the estimation is only guaranteed for single-shot compressions, not streaming.

      The estimate will assume the input may be arbitrarily large, which is the worst case.

      When srcSize can be bound by a known and rather "small" value, this fact can be used to provide a tighter estimation because the CCtx compression context will need less memory. This tighter estimation can be provided by more advanced functions estimateCCtxSize_usingCParams, which can be used in tandem with getCParams, and estimateCCtxSize_usingCCtxParams, which can be used in tandem with CCtxParams_setParameter. Both can be used to estimate memory using custom compression parameters and arbitrary srcSize limits.

      Note: only single-threaded compression is supported. estimateCCtxSize_usingCCtxParams will return an error code if c_nbWorkers is ≥ 1.

      Note 2: ZSTD_estimateCCtxSize* functions are not compatible with the Block-Level Sequence Producer API at this time. Size estimates assume that no external sequence producer is registered.

    • nZSTD_estimateCCtxSize_usingCParams

      public static long nZSTD_estimateCCtxSize_usingCParams(long cParams)
    • ZSTD_estimateCCtxSize_usingCParams

      public static long ZSTD_estimateCCtxSize_usingCParams(ZSTDCompressionParameters cParams)
    • nZSTD_estimateCCtxSize_usingCCtxParams

      public static long nZSTD_estimateCCtxSize_usingCCtxParams(long params)
    • ZSTD_estimateCCtxSize_usingCCtxParams

      public static long ZSTD_estimateCCtxSize_usingCCtxParams(long params)
    • ZSTD_estimateDCtxSize

      public static long ZSTD_estimateDCtxSize()
    • ZSTD_estimateCStreamSize

      public static long ZSTD_estimateCStreamSize(int compressionLevel)
      Provides a budget large enough for any compression level up to selected one.

      It will also consider src size to be arbitrarily "large", which is worst case. If srcSize is known to always be small, estimateCStreamSize_usingCParams can provide a tighter estimation. ZSTD_estimateCStreamSize_usingCParams() can be used in tandem with getCParams to create cParams from compressionLevel. estimateCStreamSize_usingCCtxParams can be used in tandem with CCtxParams_setParameter. Only single-threaded compression is supported.

      This function will return an error code if c_nbWorkers is ≥ 1.

      Note: CStream size estimation is only correct for single-threaded compression. ZSTD_DStream memory budget depends on window Size. This information can be passed manually, using estimateDStreamSize, or deducted from a valid frame Header, using estimateDStreamSize_fromFrame.

      Note: if streaming is init with function ZSTD_init?Stream_usingDict(), an internal Dict will be created, which additional size is not estimated here. In this case, get total size by adding ZSTD_estimate?DictSize.

      Note 2: only single-threaded compression is supported. estimateCStreamSize_usingCCtxParams will return an error code if c_nbWorkers is ≥ 1.

      Note 3: ZSTD_estimateCStreamSize* functions are not compatible with the Block-Level Sequence Producer API at this time. Size estimates assume that no external sequence producer is registered.

    • nZSTD_estimateCStreamSize_usingCParams

      public static long nZSTD_estimateCStreamSize_usingCParams(long cParams)
    • ZSTD_estimateCStreamSize_usingCParams

      public static long ZSTD_estimateCStreamSize_usingCParams(ZSTDCompressionParameters cParams)
    • nZSTD_estimateCStreamSize_usingCCtxParams

      public static long nZSTD_estimateCStreamSize_usingCCtxParams(long params)
    • ZSTD_estimateCStreamSize_usingCCtxParams

      public static long ZSTD_estimateCStreamSize_usingCCtxParams(long params)
    • ZSTD_estimateDStreamSize

      public static long ZSTD_estimateDStreamSize(long windowSize)
    • nZSTD_estimateDStreamSize_fromFrame

      public static long nZSTD_estimateDStreamSize_fromFrame(long src, long srcSize)
    • ZSTD_estimateDStreamSize_fromFrame

      public static long ZSTD_estimateDStreamSize_fromFrame(ByteBuffer src)
    • ZSTD_estimateCDictSize

      public static long ZSTD_estimateCDictSize(long dictSize, int compressionLevel)
    • nZSTD_estimateCDictSize_advanced

      public static long nZSTD_estimateCDictSize_advanced(long dictSize, long cParams, int dictLoadMethod)
      Unsafe version of: estimateCDictSize_advanced
    • ZSTD_estimateCDictSize_advanced

      public static long ZSTD_estimateCDictSize_advanced(long dictSize, ZSTDCompressionParameters cParams, int dictLoadMethod)
      Parameters:
      dictLoadMethod - one of:
      dlm_byCopydlm_byRef
    • ZSTD_estimateDDictSize

      public static long ZSTD_estimateDDictSize(long dictSize, int dictLoadMethod)
      Parameters:
      dictLoadMethod - one of:
      dlm_byCopydlm_byRef
    • nZSTD_initStaticCCtx

      public static long nZSTD_initStaticCCtx(long workspace, long workspaceSize)
    • ZSTD_initStaticCCtx

      public static long ZSTD_initStaticCCtx(ByteBuffer workspace)
    • nZSTD_initStaticCStream

      public static long nZSTD_initStaticCStream(long workspace, long workspaceSize)
    • ZSTD_initStaticCStream

      public static long ZSTD_initStaticCStream(ByteBuffer workspace)
    • nZSTD_initStaticDCtx

      public static long nZSTD_initStaticDCtx(long workspace, long workspaceSize)
    • ZSTD_initStaticDCtx

      public static long ZSTD_initStaticDCtx(ByteBuffer workspace)
    • nZSTD_initStaticDStream

      public static long nZSTD_initStaticDStream(long workspace, long workspaceSize)
    • ZSTD_initStaticDStream

      public static long ZSTD_initStaticDStream(ByteBuffer workspace)
    • nZSTD_initStaticCDict

      public static long nZSTD_initStaticCDict(long workspace, long workspaceSize, long dict, long dictSize, int dictLoadMethod, int dictContentType, long cParams)
      Unsafe version of: initStaticCDict
    • ZSTD_initStaticCDict

      public static long ZSTD_initStaticCDict(ByteBuffer workspace, ByteBuffer dict, int dictLoadMethod, int dictContentType, ZSTDCompressionParameters cParams)
      Parameters:
      dictLoadMethod - one of:
      dlm_byCopydlm_byRef
      dictContentType - one of:
      dct_autodct_rawContentdct_fullDict
    • nZSTD_initStaticDDict

      public static long nZSTD_initStaticDDict(long workspace, long workspaceSize, long dict, long dictSize, int dictLoadMethod, int dictContentType)
      Unsafe version of: initStaticDDict
    • ZSTD_initStaticDDict

      public static long ZSTD_initStaticDDict(ByteBuffer workspace, ByteBuffer dict, int dictLoadMethod, int dictContentType)
      Parameters:
      dictLoadMethod - one of:
      dlm_byCopydlm_byRef
      dictContentType - one of:
      dct_autodct_rawContentdct_fullDict
    • nZSTD_createCCtx_advanced

      public static long nZSTD_createCCtx_advanced(long customMem)
    • ZSTD_createCCtx_advanced

      public static long ZSTD_createCCtx_advanced(ZSTDCustomMem customMem)
    • nZSTD_createCStream_advanced

      public static long nZSTD_createCStream_advanced(long customMem)
    • ZSTD_createCStream_advanced

      public static long ZSTD_createCStream_advanced(ZSTDCustomMem customMem)
    • nZSTD_createDCtx_advanced

      public static long nZSTD_createDCtx_advanced(long customMem)
    • ZSTD_createDCtx_advanced

      public static long ZSTD_createDCtx_advanced(ZSTDCustomMem customMem)
    • nZSTD_createDStream_advanced

      public static long nZSTD_createDStream_advanced(long customMem)
    • ZSTD_createDStream_advanced

      public static long ZSTD_createDStream_advanced(ZSTDCustomMem customMem)
    • nZSTD_createCDict_advanced

      public static long nZSTD_createCDict_advanced(long dict, long dictSize, int dictLoadMethod, int dictContentType, long cParams, long customMem)
      Unsafe version of: createCDict_advanced
    • ZSTD_createCDict_advanced

      public static long ZSTD_createCDict_advanced(ByteBuffer dict, int dictLoadMethod, int dictContentType, ZSTDCompressionParameters cParams, ZSTDCustomMem customMem)
      Parameters:
      dictLoadMethod - one of:
      dlm_byCopydlm_byRef
      dictContentType - one of:
      dct_autodct_rawContentdct_fullDict
    • ZSTD_createThreadPool

      public static long ZSTD_createThreadPool(long numThreads)
      Creates a new thread pool with a given number of threads.

      Note that the lifetime of such pool must exist while being used.

    • ZSTD_freeThreadPool

      public static void ZSTD_freeThreadPool(long pool)
      Frees a thread pool.
      Parameters:
      pool - accepts NULL pointer
    • nZSTD_CCtx_refThreadPool

      public static long nZSTD_CCtx_refThreadPool(long cctx, long pool)
      Unsafe version of: CCtx_refThreadPool
    • ZSTD_CCtx_refThreadPool

      public static long ZSTD_CCtx_refThreadPool(long cctx, long pool)
      Assigns a thread pool to a context (use NULL argument value to use an internal thread pool).
    • nZSTD_createCDict_advanced2

      public static long nZSTD_createCDict_advanced2(long dict, long dictSize, int dictLoadMethod, int dictContentType, long cctxParams, long customMem)
      Unsafe version of: createCDict_advanced2
    • ZSTD_createCDict_advanced2

      public static long ZSTD_createCDict_advanced2(ByteBuffer dict, int dictLoadMethod, int dictContentType, long cctxParams, ZSTDCustomMem customMem)
      Parameters:
      dictLoadMethod - one of:
      dlm_byCopydlm_byRef
      dictContentType - one of:
      dct_autodct_rawContentdct_fullDict
    • nZSTD_createDDict_advanced

      public static long nZSTD_createDDict_advanced(long dict, long dictSize, int dictLoadMethod, int dictContentType, long customMem)
      Unsafe version of: createDDict_advanced
    • ZSTD_createDDict_advanced

      public static long ZSTD_createDDict_advanced(ByteBuffer dict, int dictLoadMethod, int dictContentType, ZSTDCustomMem customMem)
      Parameters:
      dictLoadMethod - one of:
      dlm_byCopydlm_byRef
      dictContentType - one of:
      dct_autodct_rawContentdct_fullDict
    • nZSTD_createCDict_byReference

      public static long nZSTD_createCDict_byReference(long dictBuffer, long dictSize, int compressionLevel)
      Unsafe version of: createCDict_byReference
    • ZSTD_createCDict_byReference

      public static long ZSTD_createCDict_byReference(ByteBuffer dictBuffer, int compressionLevel)
      Creates a digested dictionary for compression Dictionary content is just referenced, not duplicated.

      As a consequence, dictBuffer must outlive CDict, and its content must remain unmodified throughout the lifetime of CDict.

      Note: equivalent to createCDict_advanced, with dictLoadMethod==ZSTD_dlm_byRef.

    • nZSTD_getCParams

      public static void nZSTD_getCParams(int compressionLevel, long estimatedSrcSize, long dictSize, long __result)
      Unsafe version of: getCParams
    • ZSTD_getCParams

      public static ZSTDCompressionParameters ZSTD_getCParams(int compressionLevel, long estimatedSrcSize, long dictSize, ZSTDCompressionParameters __result)
      Returns ZSTD_compressionParameters structure for a selected compression level and estimated srcSize.
      Parameters:
      estimatedSrcSize - optional, select 0 if not known
    • nZSTD_getParams

      public static void nZSTD_getParams(int compressionLevel, long estimatedSrcSize, long dictSize, long __result)
      Unsafe version of: getParams
    • ZSTD_getParams

      public static ZSTDParameters ZSTD_getParams(int compressionLevel, long estimatedSrcSize, long dictSize, ZSTDParameters __result)
      Same as getCParams(), but returns a full ZSTD_parameters object instead of sub-component ZSTD_compressionParameters.

      All fields of ZSTD_frameParameters are set to default: contentSize=1, checksum=0, noDictID=0.

      Parameters:
      estimatedSrcSize - optional, select 0 if not known
    • nZSTD_checkCParams

      public static long nZSTD_checkCParams(long params)
      Unsafe version of: checkCParams
    • ZSTD_checkCParams

      public static long ZSTD_checkCParams(ZSTDCompressionParameters params)
      Ensures param values remain within authorized range.
      Returns:
      0 on success, or an error code (can be checked with isError)
    • nZSTD_adjustCParams

      public static void nZSTD_adjustCParams(long cPar, long srcSize, long dictSize, long __result)
      Unsafe version of: adjustCParams
    • ZSTD_adjustCParams

      public static ZSTDCompressionParameters ZSTD_adjustCParams(ZSTDCompressionParameters cPar, long srcSize, long dictSize, ZSTDCompressionParameters __result)
      Optimizes params for a given srcSize and dictSize. Both values are optional, select 0 if unknown.
    • nZSTD_CCtx_setCParams

      public static long nZSTD_CCtx_setCParams(long cctx, long cparams)
      Unsafe version of: CCtx_setCParams
    • ZSTD_CCtx_setCParams

      public static long ZSTD_CCtx_setCParams(long cctx, ZSTDCompressionParameters cparams)
      Set all parameters provided within cparams into the working cctx.

      Note: if modifying parameters during compression (MT mode only), note that changes to the .windowLog parameter will be ignored.

      Returns:
      0 on success, or an error code (can be checked with isError). On failure, no parameters are updated.
    • nZSTD_CCtx_setFParams

      public static long nZSTD_CCtx_setFParams(long cctx, long fparams)
      Unsafe version of: CCtx_setFParams
    • ZSTD_CCtx_setFParams

      public static long ZSTD_CCtx_setFParams(long cctx, ZSTDFrameParameters fparams)
      Set all parameters provided within fparams into the working cctx.
    • nZSTD_CCtx_setParams

      public static long nZSTD_CCtx_setParams(long cctx, long params)
      Unsafe version of: CCtx_setParams
    • ZSTD_CCtx_setParams

      public static long ZSTD_CCtx_setParams(long cctx, ZSTDParameters params)
      Set all parameters provided within params into the working cctx.
    • nZSTD_CCtx_loadDictionary_byReference

      public static long nZSTD_CCtx_loadDictionary_byReference(long cctx, long dict, long dictSize)
    • ZSTD_CCtx_loadDictionary_byReference

      public static long ZSTD_CCtx_loadDictionary_byReference(long cctx, ByteBuffer dict)
      Same as CCtx_loadDictionary, but dictionary content is referenced, instead of being copied into CCtx.

      It saves some memory, but also requires that dict outlives its usage within cctx.

    • nZSTD_CCtx_loadDictionary_advanced

      public static long nZSTD_CCtx_loadDictionary_advanced(long cctx, long dict, long dictSize, int dictLoadMethod, int dictContentType)
      Unsafe version of: CCtx_loadDictionary_advanced
    • ZSTD_CCtx_loadDictionary_advanced

      public static long ZSTD_CCtx_loadDictionary_advanced(long cctx, ByteBuffer dict, int dictLoadMethod, int dictContentType)
      Same as CCtx_loadDictionary, but gives finer control over how to load the dictionary (by copy ? by reference ?) and how to interpret it (automatic ? force raw mode ? full mode only ?).
      Parameters:
      dictLoadMethod - one of:
      dlm_byCopydlm_byRef
      dictContentType - one of:
      dct_autodct_rawContentdct_fullDict
    • nZSTD_CCtx_refPrefix_advanced

      public static long nZSTD_CCtx_refPrefix_advanced(long cctx, long prefix, long prefixSize, int dictContentType)
      Unsafe version of: CCtx_refPrefix_advanced
    • ZSTD_CCtx_refPrefix_advanced

      public static long ZSTD_CCtx_refPrefix_advanced(long cctx, ByteBuffer prefix, int dictContentType)
      Same as CCtx_refPrefix, but gives finer control over how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?).
      Parameters:
      dictContentType - one of:
      dct_autodct_rawContentdct_fullDict
    • nZSTD_CCtx_getParameter

      public static long nZSTD_CCtx_getParameter(long cctx, int param, long value)
      Unsafe version of: CCtx_getParameter
    • ZSTD_CCtx_getParameter

      public static long ZSTD_CCtx_getParameter(long cctx, int param, IntBuffer value)
      Gets the requested compression parameter value, selected by enum ZSTD_cParameter, and stores it into int* value.
      Parameters:
      param - one of:
      c_compressionLevelc_windowLogc_hashLogc_chainLog
      c_searchLogc_minMatchc_targetLengthc_strategy
      c_enableLongDistanceMatchingc_ldmHashLogc_ldmMinMatchc_ldmBucketSizeLog
      c_ldmHashRateLogc_contentSizeFlagc_checksumFlagc_dictIDFlag
      c_nbWorkersc_jobSizec_overlapLogc_experimentalParam1
      c_experimentalParam2c_experimentalParam3c_experimentalParam4c_experimentalParam5
      c_experimentalParam6c_experimentalParam7c_experimentalParam8c_experimentalParam9
      c_experimentalParam10c_experimentalParam11c_experimentalParam12c_experimentalParam13
      c_experimentalParam14c_experimentalParam15c_experimentalParam16c_experimentalParam17
      c_experimentalParam18c_experimentalParam19c_rsyncablec_format
      c_forceMaxWindowc_forceAttachDictc_literalCompressionModec_targetCBlockSize
      c_srcSizeHintc_enableDedicatedDictSearchc_stableInBufferc_stableOutBuffer
      c_blockDelimitersc_validateSequencesc_useBlockSplitterc_useRowMatchFinder
      c_deterministicRefPrefixc_prefetchCDictTablesc_enableSeqProducerFallbackc_maxBlockSize
      c_searchForExternalRepcodes
      Returns:
      0, or an error code (which can be tested with isError)
    • ZSTD_createCCtxParams

      public static long ZSTD_createCCtxParams()
      Creates a ZSTD_CCtx_params structure.
    • ZSTD_freeCCtxParams

      public static long ZSTD_freeCCtxParams(long params)
      Parameters:
      params - accepts NULL pointer
    • nZSTD_CCtxParams_reset

      public static long nZSTD_CCtxParams_reset(long params)
      Unsafe version of: CCtxParams_reset
    • ZSTD_CCtxParams_reset

      public static long ZSTD_CCtxParams_reset(long params)
      Resets params to default values.
    • nZSTD_CCtxParams_init

      public static long nZSTD_CCtxParams_init(long cctxParams, int compressionLevel)
      Unsafe version of: CCtxParams_init
    • ZSTD_CCtxParams_init

      public static long ZSTD_CCtxParams_init(long cctxParams, int compressionLevel)
      Initializes the compression parameters of cctxParams according to compression level. All other parameters are reset to their default values.
    • nZSTD_CCtxParams_init_advanced

      public static long nZSTD_CCtxParams_init_advanced(long cctxParams, long params)
      Unsafe version of: CCtxParams_init_advanced
    • ZSTD_CCtxParams_init_advanced

      public static long ZSTD_CCtxParams_init_advanced(long cctxParams, ZSTDParameters params)
      Initializes the compression and frame parameters of cctxParams according to params. All other parameters are reset to their default values.
    • nZSTD_CCtxParams_setParameter

      public static long nZSTD_CCtxParams_setParameter(long params, int param, int value)
      Unsafe version of: CCtxParams_setParameter
    • ZSTD_CCtxParams_setParameter

      public static long ZSTD_CCtxParams_setParameter(long params, int param, int value)
      Similar to CCtx_setParameter. Sets one compression parameter, selected by enum ZSTD_cParameter.

      Parameters must be applied to a ZSTD_CCtx using CCtx_setParametersUsingCCtxParams.

      Parameters:
      param - one of:
      c_compressionLevelc_windowLogc_hashLogc_chainLog
      c_searchLogc_minMatchc_targetLengthc_strategy
      c_enableLongDistanceMatchingc_ldmHashLogc_ldmMinMatchc_ldmBucketSizeLog
      c_ldmHashRateLogc_contentSizeFlagc_checksumFlagc_dictIDFlag
      c_nbWorkersc_jobSizec_overlapLogc_experimentalParam1
      c_experimentalParam2c_experimentalParam3c_experimentalParam4c_experimentalParam5
      c_experimentalParam6c_experimentalParam7c_experimentalParam8c_experimentalParam9
      c_experimentalParam10c_experimentalParam11c_experimentalParam12c_experimentalParam13
      c_experimentalParam14c_experimentalParam15c_experimentalParam16c_experimentalParam17
      c_experimentalParam18c_experimentalParam19c_rsyncablec_format
      c_forceMaxWindowc_forceAttachDictc_literalCompressionModec_targetCBlockSize
      c_srcSizeHintc_enableDedicatedDictSearchc_stableInBufferc_stableOutBuffer
      c_blockDelimitersc_validateSequencesc_useBlockSplitterc_useRowMatchFinder
      c_deterministicRefPrefixc_prefetchCDictTablesc_enableSeqProducerFallbackc_maxBlockSize
      c_searchForExternalRepcodes
      Returns:
      a code representing success or failure (which can be tested with isError)
    • nZSTD_CCtxParams_getParameter

      public static long nZSTD_CCtxParams_getParameter(long params, int param, long value)
      Unsafe version of: CCtxParams_getParameter
    • ZSTD_CCtxParams_getParameter

      public static long ZSTD_CCtxParams_getParameter(long params, int param, IntBuffer value)
      Similar to CCtx_getParameter. Gets the requested value of one compression parameter, selected by enum ZSTD_cParameter.
      Parameters:
      param - one of:
      c_compressionLevelc_windowLogc_hashLogc_chainLog
      c_searchLogc_minMatchc_targetLengthc_strategy
      c_enableLongDistanceMatchingc_ldmHashLogc_ldmMinMatchc_ldmBucketSizeLog
      c_ldmHashRateLogc_contentSizeFlagc_checksumFlagc_dictIDFlag
      c_nbWorkersc_jobSizec_overlapLogc_experimentalParam1
      c_experimentalParam2c_experimentalParam3c_experimentalParam4c_experimentalParam5
      c_experimentalParam6c_experimentalParam7c_experimentalParam8c_experimentalParam9
      c_experimentalParam10c_experimentalParam11c_experimentalParam12c_experimentalParam13
      c_experimentalParam14c_experimentalParam15c_experimentalParam16c_experimentalParam17
      c_experimentalParam18c_experimentalParam19c_rsyncablec_format
      c_forceMaxWindowc_forceAttachDictc_literalCompressionModec_targetCBlockSize
      c_srcSizeHintc_enableDedicatedDictSearchc_stableInBufferc_stableOutBuffer
      c_blockDelimitersc_validateSequencesc_useBlockSplitterc_useRowMatchFinder
      c_deterministicRefPrefixc_prefetchCDictTablesc_enableSeqProducerFallbackc_maxBlockSize
      c_searchForExternalRepcodes
      Returns:
      0, or an error code (which can be tested with isError)
    • nZSTD_CCtx_setParametersUsingCCtxParams

      public static long nZSTD_CCtx_setParametersUsingCCtxParams(long cctx, long params)
    • ZSTD_CCtx_setParametersUsingCCtxParams

      public static long ZSTD_CCtx_setParametersUsingCCtxParams(long cctx, long params)
      Applies a set of ZSTD_CCtx_params to the compression context.

      This can be done even after compression is started, if nbWorkers==0, this will have no impact until a new compression is started. If nbWorkers ≥ 1, new parameters will be picked up at next job, with a few restrictions (windowLog, pledgedSrcSize, nbWorkers, jobSize, and overlapLog are not updated).

    • nZSTD_compressStream2_simpleArgs

      public static long nZSTD_compressStream2_simpleArgs(long cctx, long dst, long dstCapacity, long dstPos, long src, long srcSize, long srcPos, int endOp)
      Unsafe version of: compressStream2_simpleArgs
    • ZSTD_compressStream2_simpleArgs

      public static long ZSTD_compressStream2_simpleArgs(long cctx, ByteBuffer dst, PointerBuffer dstPos, ByteBuffer src, PointerBuffer srcPos, int endOp)
      Same as compressStream2, but using only integral types as arguments.

      This variant might be helpful for binders from dynamic languages which have troubles handling structures containing memory pointers.

      Parameters:
      endOp - one of:
      e_continuee_flushe_end
    • nZSTD_isFrame

      public static int nZSTD_isFrame(long buffer, long size)
      Unsafe version of: isFrame
    • ZSTD_isFrame

      public static boolean ZSTD_isFrame(ByteBuffer buffer)
      Tells if the content of buffer starts with a valid Frame Identifier.

      Notes:

      1. Frame Identifier is 4 bytes. If size < 4, @return will always be 0.
      2. Legacy Frame Identifiers are considered valid only if Legacy Support is enabled.
      3. Skippable Frame Identifiers are considered valid.
    • nZSTD_createDDict_byReference

      public static long nZSTD_createDDict_byReference(long dictBuffer, long dictSize)
      Unsafe version of: createDDict_byReference
    • ZSTD_createDDict_byReference

      public static long ZSTD_createDDict_byReference(ByteBuffer dictBuffer)
      Creates a digested dictionary, ready to start decompression operation without startup delay.

      Dictionary content is referenced, and therefore stays in dictBuffer. It is important that dictBuffer outlives DDict, it must remain read accessible throughout the lifetime of DDict.

    • nZSTD_DCtx_loadDictionary_byReference

      public static long nZSTD_DCtx_loadDictionary_byReference(long dctx, long dict, long dictSize)
    • ZSTD_DCtx_loadDictionary_byReference

      public static long ZSTD_DCtx_loadDictionary_byReference(long dctx, ByteBuffer dict)
      Same as DCtx_loadDictionary, but references dict content instead of copying it into dctx.

      This saves memory if dict remains around. However, it's imperative that dict remains accessible (and unmodified) while being used, so it must outlive decompression.

    • nZSTD_DCtx_loadDictionary_advanced

      public static long nZSTD_DCtx_loadDictionary_advanced(long dctx, long dict, long dictSize, int dictLoadMethod, int dictContentType)
      Unsafe version of: DCtx_loadDictionary_advanced
    • ZSTD_DCtx_loadDictionary_advanced

      public static long ZSTD_DCtx_loadDictionary_advanced(long dctx, ByteBuffer dict, int dictLoadMethod, int dictContentType)
      Same as DCtx_loadDictionary, but gives direct control over how to load the dictionary (by copy ? by reference ?) and how to interpret it (automatic ? force raw mode ? full mode only ?).
      Parameters:
      dictLoadMethod - one of:
      dlm_byCopydlm_byRef
      dictContentType - one of:
      dct_autodct_rawContentdct_fullDict
    • nZSTD_DCtx_refPrefix_advanced

      public static long nZSTD_DCtx_refPrefix_advanced(long dctx, long prefix, long prefixSize, int dictContentType)
      Unsafe version of: DCtx_refPrefix_advanced
    • ZSTD_DCtx_refPrefix_advanced

      public static long ZSTD_DCtx_refPrefix_advanced(long dctx, ByteBuffer prefix, int dictContentType)
      Same as DCtx_refPrefix, but gives finer control over how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?).
      Parameters:
      dictContentType - one of:
      dct_autodct_rawContentdct_fullDict
    • nZSTD_DCtx_setMaxWindowSize

      public static long nZSTD_DCtx_setMaxWindowSize(long dctx, long maxWindowSize)
      Unsafe version of: DCtx_setMaxWindowSize
    • ZSTD_DCtx_setMaxWindowSize

      public static long ZSTD_DCtx_setMaxWindowSize(long dctx, long maxWindowSize)
      Refuses allocating internal buffers for frames requiring a window size larger than provided limit.

      This protects a decoder context from reserving too much memory for itself (potential attack scenario). This parameter is only useful in streaming mode, since no internal buffer is allocated in single-pass mode. By default, a decompression context accepts all window sizes ≤ (1 << WINDOWLOG_LIMIT_DEFAULT).

      Returns:
      0, or an error code (which can be tested using isError)
    • nZSTD_DCtx_getParameter

      public static long nZSTD_DCtx_getParameter(long dctx, int param, long value)
      Unsafe version of: DCtx_getParameter
    • ZSTD_DCtx_getParameter

      public static long ZSTD_DCtx_getParameter(long dctx, int param, IntBuffer value)
      Gets the requested decompression parameter value, selected by enum ZSTD_dParameter, and store it into int* value.
      Returns:
      0, or an error code (which can be tested with isError)
    • nZSTD_decompressStream_simpleArgs

      public static long nZSTD_decompressStream_simpleArgs(long dctx, long dst, long dstCapacity, long dstPos, long src, long srcSize, long srcPos)
      Unsafe version of: decompressStream_simpleArgs
    • ZSTD_decompressStream_simpleArgs

      public static long ZSTD_decompressStream_simpleArgs(long dctx, ByteBuffer dst, PointerBuffer dstPos, ByteBuffer src, PointerBuffer srcPos)
      Same as decompressStream, but using only integral types as arguments.

      This can be helpful for binders from dynamic languages which have troubles handling structures containing memory pointers.

    • nZSTD_getFrameProgression

      public static void nZSTD_getFrameProgression(long cctx, long __result)
      Unsafe version of: getFrameProgression
    • ZSTD_getFrameProgression

      public static ZSTDFrameProgression ZSTD_getFrameProgression(long cctx, ZSTDFrameProgression __result)
      Tells how much data has been ingested (read from input) consumed (input actually compressed) and produced (output) for current frame.

      Note: (ingested - consumed) is amount of input data buffered internally, not yet compressed. Aggregates progression inside active worker threads.

    • nZSTD_toFlushNow

      public static long nZSTD_toFlushNow(long cctx)
      Unsafe version of: toFlushNow
    • ZSTD_toFlushNow

      public static long ZSTD_toFlushNow(long cctx)
      Tells how many bytes are ready to be flushed immediately.

      Useful for multithreading scenarios (nbWorkers ≥ 1). Probe the oldest active job, defined as oldest job not yet entirely flushed, and check its output buffer.

      Returns:
      amount of data stored in oldest job and ready to be flushed immediately. If == 0, it means either:
      • there is no active job (could be checked with getFrameProgression), or
      • oldest job is still actively compressing data, but everything it has produced has also been flushed so far, therefore flush speed is limited by production speed of oldest job irrespective of the speed of concurrent (and newer) jobs.
    • nZSTD_registerSequenceProducer

      public static void nZSTD_registerSequenceProducer(long cctx, long sequenceProducerState, long sequenceProducer)
      Unsafe version of: registerSequenceProducer
    • ZSTD_registerSequenceProducer

      public static void ZSTD_registerSequenceProducer(long cctx, long sequenceProducerState, @Nullable ZSTDSequenceProducerI sequenceProducer)
      Instruct zstd to use a block-level external sequence producer function.

      The sequenceProducerState must be initialized by the caller, and the caller is responsible for managing its lifetime. This parameter is sticky across compressions. It will remain set until the user explicitly resets compression parameters.

      Sequence producer registration is considered to be an "advanced parameter", part of the "advanced API". This means it will only have an effect on compression APIs which respect advanced parameters, such as compress2 and compressStream2. Older compression APIs such as compressCCtx, which predate the introduction of "advanced parameters", will ignore any external sequence producer setting.

      The sequence producer can be "cleared" by registering a NULL function pointer. This removes all limitations described above in the "LIMITATIONS" section of the API docs.

      The user is strongly encouraged to read the full API documentation before calling this function.

    • ZSTD_decodingBufferSize_min

      public static long ZSTD_decodingBufferSize_min(long windowSize, long frameContentSize)
    • nZSTD_decompressBegin

      public static long nZSTD_decompressBegin(long dctx)
    • ZSTD_decompressBegin

      public static long ZSTD_decompressBegin(long dctx)
    • nZSTD_decompressBegin_usingDict

      public static long nZSTD_decompressBegin_usingDict(long dctx, long dict, long dictSize)
    • ZSTD_decompressBegin_usingDict

      public static long ZSTD_decompressBegin_usingDict(long dctx, ByteBuffer dict)
    • nZSTD_decompressBegin_usingDDict

      public static long nZSTD_decompressBegin_usingDDict(long dctx, long ddict)
    • ZSTD_decompressBegin_usingDDict

      public static long ZSTD_decompressBegin_usingDDict(long dctx, long ddict)
    • nZSTD_nextSrcSizeToDecompress

      public static long nZSTD_nextSrcSizeToDecompress(long dctx)
    • ZSTD_nextSrcSizeToDecompress

      public static long ZSTD_nextSrcSizeToDecompress(long dctx)
    • nZSTD_decompressContinue

      public static long nZSTD_decompressContinue(long dctx, long dst, long dstCapacity, long src, long srcSize)
    • ZSTD_decompressContinue

      public static long ZSTD_decompressContinue(long dctx, ByteBuffer dst, ByteBuffer src)
    • nZSTD_nextInputType

      public static int nZSTD_nextInputType(long dctx)
    • ZSTD_nextInputType

      public static int ZSTD_nextInputType(long dctx)
    • ZSTD_FRAMEHEADERSIZE_PREFIX

      public static int ZSTD_FRAMEHEADERSIZE_PREFIX(int format)
    • ZSTD_FRAMEHEADERSIZE_MIN

      public static int ZSTD_FRAMEHEADERSIZE_MIN(int format)
    • ZSTD_DECOMPRESSION_MARGIN

      public static long ZSTD_DECOMPRESSION_MARGIN(long originalSize, long blockSize)
      Similar to decompressionMargin, but instead of computing the margin from the compressed frame, compute it from the original size and the blockSizeLog.

      WARNING: This macro does not support multi-frame input, the input must be a single zstd frame. If you need that support use the function, or implement it yourself.

      Parameters:
      originalSize - the original uncompressed size of the data
      blockSize - the block size == MIN(windowSize, ZSTD_BLOCKSIZE_MAX). Unless you explicitly set the windowLog smaller than ZSTD_BLOCKSIZELOG_MAX you can just use ZSTD_BLOCKSIZE_MAX.