Class LZ4Frame
LZ4F is a stand-alone API to create LZ4-compressed frames conformant with specification v1.6.1. It also offers streaming capabilities. lz4.h is
not required when using lz4frame.h, except to get constant such as VERSION_NUMBER.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSize in bytes of a block checksum footer in little-endian format.static final intSize in bytes of a block header in little-endian format.static final intLZ4F_blockChecksum_tstatic final intLZ4F_blockMode_tstatic final intLZ4F_blockMode_tstatic final intSize in bytes of the content checksum.static final intLZ4F_contentChecksum_tstatic final intLZ4F_blockSizeID_tstatic final LZ4FCustomMemThis constant defers to stdlib's functionsstatic final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intError code.static final intLZ4F_frameType_tstatic final intMaximum header size.static final intMinimum header size.static final intstatic final intstatic final intLZ4F_blockSizeID_tstatic final intLZ4F_blockSizeID_tstatic final intLZ4F_blockSizeID_tstatic final intLZ4F_blockSizeID_tstatic final intstatic final intLZ4F_blockChecksum_tstatic final intLZ4F_contentChecksum_tstatic final intError code.static final intLZ4F_frameType_tstatic final intVersion number. -
Method Summary
Modifier and TypeMethodDescriptionstatic longLZ4F_compressBegin(long cctx, ByteBuffer dstBuffer, @Nullable LZ4FPreferences prefsPtr) Will write the frame header intodstBuffer.static longLZ4F_compressBegin_usingCDict(long cctx, ByteBuffer dstBuffer, long cdict, LZ4FPreferences prefsPtr) Inits streaming dictionary compression, and writes the frame header intodstBuffer.static longLZ4F_compressBegin_usingDict(long cctx, ByteBuffer dstBuffer, ByteBuffer dictBuffer, @Nullable LZ4FPreferences prefsPtr) Inits dictionary compression streaming, and writes the frame header intodstBuffer.static longLZ4F_compressBound(long srcSize, @Nullable LZ4FPreferences prefsPtr) Provides minimumdstCapacityrequired to guarantee success ofcompressUpdate, given asrcSizeand preferences, for a worst case scenario.static longLZ4F_compressEnd(long cctx, ByteBuffer dstBuffer, @Nullable LZ4FCompressOptions cOptPtr) To properly finish an LZ4 frame, invokecompressEnd.static longLZ4F_compressFrame(ByteBuffer dstBuffer, ByteBuffer srcBuffer, @Nullable LZ4FPreferences preferencesPtr) CompresssrcBuffercontent into an LZ4-compressed frame.static longLZ4F_compressFrame_usingCDict(long cctx, ByteBuffer dst, ByteBuffer src, long cdict, LZ4FPreferences preferencesPtr) Compress an entiresrcBufferinto a valid LZ4 frame using a digested Dictionary.static longLZ4F_compressFrameBound(long srcSize, @Nullable LZ4FPreferences preferencesPtr) Returns the maximum possible size of a frame compressed withcompressFramegivensrcSizecontent and preferences.static intstatic longLZ4F_compressUpdate(long cctx, ByteBuffer dstBuffer, ByteBuffer srcBuffer, @Nullable LZ4FCompressOptions cOptPtr) LZ4F_compressUpdate()can be called repetitively to compress as much data as necessary.static longLZ4F_createCDict(ByteBuffer dictBuffer) When compressing multiple messages / blocks with the same dictionary, it's recommended to load it just once.static longLZ4F_createCDict_advanced(LZ4FCustomMem customMem, ByteBuffer dictBuffer) createCDictwith custom allocation/free functions.static longLZ4F_createCompressionContext(org.lwjgl.PointerBuffer cctxPtr, int version) The first thing to do is to create acompressionContextobject, which will keep track of operation state during streaming compression.static longLZ4F_createCompressionContext_advanced(LZ4FCustomMem customMem, int version) createCompressionContextwith custom allocation/free functions.static longLZ4F_createDecompressionContext(org.lwjgl.PointerBuffer dctxPtr, int version) Create anLZ4F_dctxobject, to track all decompression operations.static longLZ4F_createDecompressionContext_advanced(LZ4FCustomMem customMem, int version) createDecompressionContextwith custom allocation/free functions.static longLZ4F_decompress(long dctx, ByteBuffer dstBuffer, org.lwjgl.PointerBuffer dstSizePtr, ByteBuffer srcBuffer, org.lwjgl.PointerBuffer srcSizePtr, LZ4FDecompressOptions dOptPtr) Call this function repetitively to regenerate data compressed insrcBuffer.static longLZ4F_decompress_usingDict(long dctxPtr, ByteBuffer dstBuffer, org.lwjgl.PointerBuffer dstSizePtr, ByteBuffer srcBuffer, org.lwjgl.PointerBuffer srcSizePtr, ByteBuffer dict, LZ4FDecompressOptions decompressOptionsPtr) Same asdecompress, using a predefined dictionary.static longLZ4F_flush(long cctx, ByteBuffer dstBuffer, @Nullable LZ4FCompressOptions cOptPtr) When data must be generated and sent immediately, without waiting for a block to be completely filled, it's possible to callflush.static voidLZ4F_freeCDict(long CDict) static longLZ4F_freeCompressionContext(long cctx) Frees anLZ4F_cctxobject.static longLZ4F_freeDecompressionContext(long dctx) Frees anLZ4F_dctxobject.static longLZ4F_getBlockSize(int blockSizeID) Return, in scalar format (size_t), the maximum block size associated withblockSizeID, or an error code (can be tested usingisError) ifblockSizeIDis invalid.static intLZ4F_getErrorCode(long functionResult) static @Nullable StringLZ4F_getErrorName(long code) Return error code string; for debugging.static longLZ4F_getFrameInfo(long dctx, LZ4FFrameInfo frameInfoPtr, ByteBuffer srcBuffer, org.lwjgl.PointerBuffer srcSizePtr) This function extracts frame parameters (maxblockSize,dictID, etc.).static intstatic longProvide the header size of a frame starting atsrc.static booleanLZ4F_isError(long code) Tells when a function result is an error code.static voidLZ4F_resetDecompressionContext(long dctx) In case of an error, the context is left in "undefined" state.static longLZ4F_uncompressedUpdate(long cctx, ByteBuffer dstBuffer, ByteBuffer srcBuffer, @Nullable LZ4FCompressOptions cOptPtr) Can be called repetitively to add data stored as uncompressed blocks.static longnLZ4F_compressBegin(long cctx, long dstBuffer, long dstCapacity, long prefsPtr) Unsafe version of:compressBeginstatic longnLZ4F_compressBegin_usingCDict(long cctx, long dstBuffer, long dstCapacity, long cdict, long prefsPtr) Unsafe version of:compressBegin_usingCDictstatic longnLZ4F_compressBegin_usingDict(long cctx, long dstBuffer, long dstCapacity, long dictBuffer, long dictSize, long prefsPtr) Unsafe version of:compressBegin_usingDictstatic longnLZ4F_compressBound(long srcSize, long prefsPtr) Unsafe version of:compressBoundstatic longnLZ4F_compressEnd(long cctx, long dstBuffer, long dstCapacity, long cOptPtr) Unsafe version of:compressEndstatic longnLZ4F_compressFrame(long dstBuffer, long dstCapacity, long srcBuffer, long srcSize, long preferencesPtr) Unsafe version of:compressFramestatic longnLZ4F_compressFrame_usingCDict(long cctx, long dst, long dstCapacity, long src, long srcSize, long cdict, long preferencesPtr) Unsafe version of:compressFrame_usingCDictstatic longnLZ4F_compressFrameBound(long srcSize, long preferencesPtr) Unsafe version of:compressFrameBoundstatic longnLZ4F_compressUpdate(long cctx, long dstBuffer, long dstCapacity, long srcBuffer, long srcSize, long cOptPtr) Unsafe version of:compressUpdatestatic longnLZ4F_createCDict(long dictBuffer, long dictSize) Unsafe version of:createCDictstatic longnLZ4F_createCDict_advanced(long customMem, long dictBuffer, long dictSize) Unsafe version of:createCDict_advancedstatic longnLZ4F_createCompressionContext(long cctxPtr, int version) Unsafe version of:createCompressionContextstatic longnLZ4F_createCompressionContext_advanced(long customMem, int version) Unsafe version of:createCompressionContext_advancedstatic longnLZ4F_createDecompressionContext(long dctxPtr, int version) Unsafe version of:createDecompressionContextstatic longnLZ4F_createDecompressionContext_advanced(long customMem, int version) Unsafe version of:createDecompressionContext_advancedstatic longnLZ4F_decompress(long dctx, long dstBuffer, long dstSizePtr, long srcBuffer, long srcSizePtr, long dOptPtr) Unsafe version of:decompressstatic longnLZ4F_decompress_usingDict(long dctxPtr, long dstBuffer, long dstSizePtr, long srcBuffer, long srcSizePtr, long dict, long dictSize, long decompressOptionsPtr) Unsafe version of:decompress_usingDictstatic longnLZ4F_flush(long cctx, long dstBuffer, long dstCapacity, long cOptPtr) Unsafe version of:flushstatic voidnLZ4F_freeCDict(long CDict) static longnLZ4F_freeDecompressionContext(long dctx) Unsafe version of:freeDecompressionContextstatic longnLZ4F_getErrorName(long code) Unsafe version of:getErrorNamestatic longnLZ4F_getFrameInfo(long dctx, long frameInfoPtr, long srcBuffer, long srcSizePtr) Unsafe version of:getFrameInfostatic longnLZ4F_headerSize(long src, long srcSize) Unsafe version of:headerSizestatic intnLZ4F_isError(long code) Unsafe version of:isErrorstatic voidnLZ4F_resetDecompressionContext(long dctx) Unsafe version of:resetDecompressionContextstatic longnLZ4F_uncompressedUpdate(long cctx, long dstBuffer, long dstCapacity, long srcBuffer, long srcSize, long cOptPtr) Unsafe version of:uncompressedUpdate
-
Field Details
-
LZ4F_VERSION
public static final int LZ4F_VERSIONVersion number.This number can be used to check for an incompatible API breaking change.
- See Also:
-
LZ4F_HEADER_SIZE_MIN
public static final int LZ4F_HEADER_SIZE_MINMinimum header size.- See Also:
-
LZ4F_HEADER_SIZE_MAX
public static final int LZ4F_HEADER_SIZE_MAXMaximum header size.- See Also:
-
LZ4F_BLOCK_HEADER_SIZE
public static final int LZ4F_BLOCK_HEADER_SIZESize in bytes of a block header in little-endian format. Highest bit indicates if block data is uncompressed.- See Also:
-
LZ4F_BLOCK_CHECKSUM_SIZE
public static final int LZ4F_BLOCK_CHECKSUM_SIZESize in bytes of a block checksum footer in little-endian format.- See Also:
-
LZ4F_CONTENT_CHECKSUM_SIZE
public static final int LZ4F_CONTENT_CHECKSUM_SIZESize in bytes of the content checksum.- See Also:
-
LZ4F_default
public static final int LZ4F_defaultLZ4F_blockSizeID_tThe larger the block size, the (slightly) better the compression ratio, though there are diminishing returns. Larger blocks also increase memory usage on both compression and decompression sides.
Enum values:
- See Also:
-
LZ4F_max64KB
public static final int LZ4F_max64KBLZ4F_blockSizeID_tThe larger the block size, the (slightly) better the compression ratio, though there are diminishing returns. Larger blocks also increase memory usage on both compression and decompression sides.
Enum values:
- See Also:
-
LZ4F_max256KB
public static final int LZ4F_max256KBLZ4F_blockSizeID_tThe larger the block size, the (slightly) better the compression ratio, though there are diminishing returns. Larger blocks also increase memory usage on both compression and decompression sides.
Enum values:
- See Also:
-
LZ4F_max1MB
public static final int LZ4F_max1MBLZ4F_blockSizeID_tThe larger the block size, the (slightly) better the compression ratio, though there are diminishing returns. Larger blocks also increase memory usage on both compression and decompression sides.
Enum values:
- See Also:
-
LZ4F_max4MB
public static final int LZ4F_max4MBLZ4F_blockSizeID_tThe larger the block size, the (slightly) better the compression ratio, though there are diminishing returns. Larger blocks also increase memory usage on both compression and decompression sides.
Enum values:
- See Also:
-
LZ4F_blockLinked
public static final int LZ4F_blockLinkedLZ4F_blockMode_tLinked blocks sharply reduce inefficiencies when using small blocks, they compress better. However, some LZ4 decoders are only compatible with independent blocks
Enum values:
- See Also:
-
LZ4F_blockIndependent
public static final int LZ4F_blockIndependentLZ4F_blockMode_tLinked blocks sharply reduce inefficiencies when using small blocks, they compress better. However, some LZ4 decoders are only compatible with independent blocks
Enum values:
- See Also:
-
LZ4F_noContentChecksum
public static final int LZ4F_noContentChecksum- See Also:
-
LZ4F_contentChecksumEnabled
public static final int LZ4F_contentChecksumEnabled- See Also:
-
LZ4F_noBlockChecksum
public static final int LZ4F_noBlockChecksum- See Also:
-
LZ4F_blockChecksumEnabled
public static final int LZ4F_blockChecksumEnabled- See Also:
-
LZ4F_frame
public static final int LZ4F_frame- See Also:
-
LZ4F_skippableFrame
public static final int LZ4F_skippableFrame- See Also:
-
LZ4F_MAGICNUMBER
public static final int LZ4F_MAGICNUMBER- See Also:
-
LZ4F_MAGIC_SKIPPABLE_START
public static final int LZ4F_MAGIC_SKIPPABLE_START- See Also:
-
LZ4F_MIN_SIZE_TO_KNOW_HEADER_LENGTH
public static final int LZ4F_MIN_SIZE_TO_KNOW_HEADER_LENGTH- See Also:
-
LZ4F_OK_NoError
public static final int LZ4F_OK_NoErrorError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_GENERIC
public static final int LZ4F_ERROR_GENERICError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_maxBlockSize_invalid
public static final int LZ4F_ERROR_maxBlockSize_invalidError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_blockMode_invalid
public static final int LZ4F_ERROR_blockMode_invalidError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_parameter_invalid
public static final int LZ4F_ERROR_parameter_invalidError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_compressionLevel_invalid
public static final int LZ4F_ERROR_compressionLevel_invalidError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_headerVersion_wrong
public static final int LZ4F_ERROR_headerVersion_wrongError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_blockChecksum_invalid
public static final int LZ4F_ERROR_blockChecksum_invalidError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_reservedFlag_set
public static final int LZ4F_ERROR_reservedFlag_setError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_allocation_failed
public static final int LZ4F_ERROR_allocation_failedError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_srcSize_tooLarge
public static final int LZ4F_ERROR_srcSize_tooLargeError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_dstMaxSize_tooSmall
public static final int LZ4F_ERROR_dstMaxSize_tooSmallError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_frameHeader_incomplete
public static final int LZ4F_ERROR_frameHeader_incompleteError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_frameType_unknown
public static final int LZ4F_ERROR_frameType_unknownError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_frameSize_wrong
public static final int LZ4F_ERROR_frameSize_wrongError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_srcPtr_wrong
public static final int LZ4F_ERROR_srcPtr_wrongError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_decompressionFailed
public static final int LZ4F_ERROR_decompressionFailedError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_headerChecksum_invalid
public static final int LZ4F_ERROR_headerChecksum_invalidError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_contentChecksum_invalid
public static final int LZ4F_ERROR_contentChecksum_invalidError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_frameDecoding_alreadyStarted
public static final int LZ4F_ERROR_frameDecoding_alreadyStartedError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_compressionState_uninitialized
public static final int LZ4F_ERROR_compressionState_uninitializedError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_parameter_null
public static final int LZ4F_ERROR_parameter_nullError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_io_write
public static final int LZ4F_ERROR_io_writeError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_io_read
public static final int LZ4F_ERROR_io_readError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_ERROR_maxCode
public static final int LZ4F_ERROR_maxCodeError code.Enum values:
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_parameter_invalidERROR_compressionLevel_invalidERROR_headerVersion_wrongERROR_blockChecksum_invalidERROR_reservedFlag_setERROR_allocation_failedERROR_srcSize_tooLargeERROR_dstMaxSize_tooSmallERROR_frameHeader_incompleteERROR_frameType_unknownERROR_frameSize_wrongERROR_srcPtr_wrongERROR_decompressionFailedERROR_headerChecksum_invalidERROR_contentChecksum_invalidERROR_frameDecoding_alreadyStartedERROR_compressionState_uninitializedERROR_parameter_nullERROR_io_writeERROR_io_readERROR_maxCode
- See Also:
-
LZ4F_defaultCMem
This constant defers to stdlib's functions
-
-
Method Details
-
nLZ4F_isError
public static int nLZ4F_isError(long code) Unsafe version of:isError -
LZ4F_isError
public static boolean LZ4F_isError(long code) Tells when a function result is an error code. -
nLZ4F_getErrorName
public static long nLZ4F_getErrorName(long code) Unsafe version of:getErrorName -
LZ4F_getErrorName
Return error code string; for debugging. -
nLZ4F_compressFrame
public static long nLZ4F_compressFrame(long dstBuffer, long dstCapacity, long srcBuffer, long srcSize, long preferencesPtr) Unsafe version of:compressFrame- Parameters:
dstCapacity- MUST be ≥compressFrameBound(srcSize, preferencesPtr)
-
LZ4F_compressFrame
public static long LZ4F_compressFrame(ByteBuffer dstBuffer, ByteBuffer srcBuffer, @Nullable LZ4FPreferences preferencesPtr) CompresssrcBuffercontent into an LZ4-compressed frame. It's a one shot operation, all input content is consumed, and all output is\ generated.Note : it's a stateless operation (no
LZ4F_cctxstate needed). In order to reduce load on the allocator,LZ4F_compressFrame(), by default, uses the stack to allocate space for the compression state and some table. If this usage of the stack is too much for your application, consider compilinglz4frame.cwith compile-time macroLZ4F_HEAPMODEset to 1 instead. All state allocations will use the Heap. It also means each invocation ofLZ4F_compressFrame()will trigger several internal alloc/free invocations.- Parameters:
preferencesPtr- optional: one can provideNULL, in which case all preferences are set to default- Returns:
- number of bytes written into
dstBufferor an error code if it fails (can be tested usingisError)
-
nLZ4F_compressFrameBound
public static long nLZ4F_compressFrameBound(long srcSize, long preferencesPtr) Unsafe version of:compressFrameBound -
LZ4F_compressFrameBound
Returns the maximum possible size of a frame compressed withcompressFramegivensrcSizecontent and preferences.Returns the maximum possible compressed size with
compressFramegivensrcSizeand preferences.preferencesPtris optional. It can be replaced byNULL, in which case, the function will assume default preferences.Note
this result is only usable with
compressFrame. It may also be relevant tocompressUpdateonly if noflushoperation is ever performed. -
LZ4F_compressionLevel_max
public static int LZ4F_compressionLevel_max()- Returns:
- maximum allowed compression level (currently: 12)
-
LZ4F_getVersion
public static int LZ4F_getVersion() -
nLZ4F_createCompressionContext
public static long nLZ4F_createCompressionContext(long cctxPtr, int version) Unsafe version of:createCompressionContext -
LZ4F_createCompressionContext
public static long LZ4F_createCompressionContext(org.lwjgl.PointerBuffer cctxPtr, int version) The first thing to do is to create acompressionContextobject, which will keep track of operation state during streaming compression. This is achieved usingLZ4F_createCompressionContext(), which takes as argument a version, and a pointer toLZ4F_cctx*, to write the resulting pointer into.The function provides a pointer to a fully allocated
LZ4F_cctxobject.A created compression context can be employed multiple times for consecutive streaming operations. Once all streaming compression jobs are completed, the state object can be released using
freeCompressionContext. -
LZ4F_freeCompressionContext
public static long LZ4F_freeCompressionContext(long cctx) Frees anLZ4F_cctxobject. Notes:LZ4F_freeCompressionContext()is always successful. Its return value can be ignored.LZ4F_freeCompressionContext()works fine withNULLinput pointers (do nothing).
-
nLZ4F_compressBegin
public static long nLZ4F_compressBegin(long cctx, long dstBuffer, long dstCapacity, long prefsPtr) Unsafe version of:compressBegin- Parameters:
dstCapacity- must be ≥HEADER_SIZE_MAXbytes
-
LZ4F_compressBegin
public static long LZ4F_compressBegin(long cctx, ByteBuffer dstBuffer, @Nullable LZ4FPreferences prefsPtr) Will write the frame header intodstBuffer.- Parameters:
prefsPtr- optional: NULL can be provided to set all preferences to default- Returns:
- number of bytes written into
dstBufferfor the header or an error code (which can be tested usingisError)
-
nLZ4F_compressBound
public static long nLZ4F_compressBound(long srcSize, long prefsPtr) Unsafe version of:compressBound -
LZ4F_compressBound
Provides minimumdstCapacityrequired to guarantee success ofcompressUpdate, given asrcSizeand preferences, for a worst case scenario.When
srcSize==0,LZ4F_compressBound()provides an upper bound forflushandcompressEndinstead. Note that the result is only valid for a single invocation ofLZ4F_compressUpdate(). When invokingLZ4F_compressUpdate()multiple times, if the output buffer is gradually filled up instead of emptied and re-used from its start, one must check if there is enough remaining capacity before each invocation, usingLZ4F_compressBound().Result is always the same for a
srcSizeandprefsPtr. If automatic flushing is not enabled, includes the possibility that internal buffer might already be filled by up to(blockSize-1)bytes. It also includes frame footer(ending + checksum), since it might be generated byLZ4F_compressEnd(). The result doesn't include frame header, as it was already generated byLZ4F_compressBegin().- Parameters:
prefsPtr- optional: whenNULLis provided, preferences will be set to cover worst case scenario
-
nLZ4F_compressUpdate
public static long nLZ4F_compressUpdate(long cctx, long dstBuffer, long dstCapacity, long srcBuffer, long srcSize, long cOptPtr) Unsafe version of:compressUpdate -
LZ4F_compressUpdate
public static long LZ4F_compressUpdate(long cctx, ByteBuffer dstBuffer, ByteBuffer srcBuffer, @Nullable LZ4FCompressOptions cOptPtr) LZ4F_compressUpdate()can be called repetitively to compress as much data as necessary.Important rule:
dstCapacityMUST be large enough to ensure operation success even in worst case situations. This value is provided bycompressBound. If this condition is not respected,LZ4F_compress()will fail (result is anerrorCode).After an error, the state is left in a UB state, and must be re-initialized or freed. If previously an uncompressed block was written, buffered data is flushed before appending compressed data is continued.
- Parameters:
cOptPtr- optional:NULLcan be provided, in which case all options are set to default- Returns:
- number of bytes written into
dstBuffer(it can be zero, meaning input data was just buffered) or an error code if it fails (which can be tested usingisError)
-
nLZ4F_flush
public static long nLZ4F_flush(long cctx, long dstBuffer, long dstCapacity, long cOptPtr) Unsafe version of:flush- Parameters:
dstCapacity- must be large enough to ensure the operation will be successful
-
LZ4F_flush
public static long LZ4F_flush(long cctx, ByteBuffer dstBuffer, @Nullable LZ4FCompressOptions cOptPtr) When data must be generated and sent immediately, without waiting for a block to be completely filled, it's possible to callflush. It will immediately compress any data buffered withincctx.- Parameters:
cOptPtr- optional: it's possible to provideNULL, all options will be set to default- Returns:
- nb of bytes written into
dstBuffer(can be zero, when there is no data stored withincctx) or an error code if it fails (which can be tested usingisError)
-
nLZ4F_compressEnd
public static long nLZ4F_compressEnd(long cctx, long dstBuffer, long dstCapacity, long cOptPtr) Unsafe version of:compressEnd -
LZ4F_compressEnd
public static long LZ4F_compressEnd(long cctx, ByteBuffer dstBuffer, @Nullable LZ4FCompressOptions cOptPtr) To properly finish an LZ4 frame, invokecompressEnd. It will flush whatever data remained withincctx(likeflush) and properly finalize the frame, with anendMarkand achecksum.- Parameters:
cOptPtr- optional:NULLcan be provided, in which case all options will be set to default- Returns:
- nb of bytes written into
dstBuffer, necessarily ≥ 4 (endMark), or an error code if it fails (which can be tested usingisError).A successful call to
compressEndmakescctxavailable again for another compression task.
-
nLZ4F_createDecompressionContext
public static long nLZ4F_createDecompressionContext(long dctxPtr, int version) Unsafe version of:createDecompressionContext -
LZ4F_createDecompressionContext
public static long LZ4F_createDecompressionContext(org.lwjgl.PointerBuffer dctxPtr, int version) Create anLZ4F_dctxobject, to track all decompression operations.The function fills
dctxPtrwith the value of a pointer to an allocated and initializedLZ4F_dctxobject.dctxmemory can be released usingfreeDecompressionContext. -
nLZ4F_freeDecompressionContext
public static long nLZ4F_freeDecompressionContext(long dctx) Unsafe version of:freeDecompressionContext -
LZ4F_freeDecompressionContext
public static long LZ4F_freeDecompressionContext(long dctx) Frees anLZ4F_dctxobject.- Returns:
- an errorCode, which can be tested using
isError.Result of
LZ4F_freeDecompressionContext()indicates current state ofdecompressionContextwhen being released. That is, it should be== 0if decompression has been completed fully and correctly.
-
nLZ4F_headerSize
public static long nLZ4F_headerSize(long src, long srcSize) Unsafe version of:headerSize- Parameters:
srcSize- must be ≥MIN_SIZE_TO_KNOW_HEADER_LENGTH, which is enough to decode the header length
-
LZ4F_headerSize
Provide the header size of a frame starting atsrc.Note: Frame header size is variable, but is guaranteed to be ≥
HEADER_SIZE_MINbytes, and ≤HEADER_SIZE_MAXbytes.- Returns:
- size of frame header or an error code, which can be tested using
isError
-
nLZ4F_getFrameInfo
public static long nLZ4F_getFrameInfo(long dctx, long frameInfoPtr, long srcBuffer, long srcSizePtr) Unsafe version of:getFrameInfo -
LZ4F_getFrameInfo
public static long LZ4F_getFrameInfo(long dctx, LZ4FFrameInfo frameInfoPtr, ByteBuffer srcBuffer, org.lwjgl.PointerBuffer srcSizePtr) This function extracts frame parameters (maxblockSize,dictID, etc.). Its usage is optional: user can also invokedecompressdirectly.Extracted information is typically useful for allocation and dictionary. This function works in 2 situations:
- At the beginning of a new frame, in which case it will decode information from
srcBuffer, starting the decoding process.Input size must be large enough to successfully decode the entire frame header. Frame header size is variable, but is guaranteed to be ≤
HEADER_SIZE_MAXbytes. It's allowed to provide more input data than this minimum. - After decoding has been started. In which case, no input is read, frame parameters are extracted from
dctx. - If decoding has barely started, but not yet extracted information from header,
LZ4F_getFrameInfo()will fail.
The number of bytes consumed from
srcBufferwill be updated within*srcSizePtr(necessarily ≤ original value). Decompression must resume from(srcBuffer + *srcSizePtr).Notes:
- in case of error,
dctxis not modified. Decoding operation can resume from beginning safely - frame parameters are copied into an already allocated
LZ4F_frameInfo_tstructure
- Returns:
- an hint about how many srcSize bytes LZ4F_decompress() expects for next call, or an error code which can be tested using LZ4F_isError()
- At the beginning of a new frame, in which case it will decode information from
-
nLZ4F_decompress
public static long nLZ4F_decompress(long dctx, long dstBuffer, long dstSizePtr, long srcBuffer, long srcSizePtr, long dOptPtr) Unsafe version of:decompress -
LZ4F_decompress
public static long LZ4F_decompress(long dctx, ByteBuffer dstBuffer, org.lwjgl.PointerBuffer dstSizePtr, ByteBuffer srcBuffer, org.lwjgl.PointerBuffer srcSizePtr, LZ4FDecompressOptions dOptPtr) Call this function repetitively to regenerate data compressed insrcBuffer.The function requires a valid
dctxstate. It will read up to*srcSizePtrbytes fromsrcBuffer, and decompress data intodstBuffer, of capacity*dstSizePtr.The nb of bytes consumed from
srcBufferwill be written into*srcSizePtr(necessarily ≤ original value). The number of bytes decompressed intodstBufferwill be written into*dstSizePtr(necessarily ≤ original value).The nb of bytes regenerated into
dstBufferis provided within*dstSizePtr(necessarily ≤ original value).The function does not necessarily read all input bytes, so always check value in
*srcSizePtr. Unconsumed source data must be presented again in subsequent invocations.dstBuffercan freely change between each consecutive function invocation.dstBuffercontent will be overwritten.Note: if
getFrameInfois called beforeLZ4F_decompress(),srcBuffermust be updated to reflect the number of bytes consumed after reading the frame header. Failure to updatesrcBufferbefore callingLZ4F_decompress()will cause decompression failure or, even worse, successful but incorrect decompression. See theLZ4F_getFrameInfo()docs for details.After a frame is fully decoded,
dctxcan be used again to decompress another frame.After a decompression error, use
resetDecompressionContextbefore re-usingdctx, to return to clean state.- Returns:
- a hint of how many
srcSizebytesLZ4F_decompress()expects for next call.Schematically, it's the size of the current (or remaining) compressed block + header of next block. Respecting the hint provides some small speed benefit, because it skips intermediate buffers. This is just a hint though, it's always possible to provide any
srcSize.When a frame is fully decoded, return will be 0 (no more data expected). When provided with more bytes than necessary to decode a frame,
LZ4F_decompress()will stop reading exactly at end of current frame, and return 0.If decompression failed, return is an error code, which can be tested using
isError. After a decompression error, thedctxcontext is not resumable. UseresetDecompressionContextto return to clean state.
-
nLZ4F_resetDecompressionContext
public static void nLZ4F_resetDecompressionContext(long dctx) Unsafe version of:resetDecompressionContext -
LZ4F_resetDecompressionContext
public static void LZ4F_resetDecompressionContext(long dctx) In case of an error, the context is left in "undefined" state. In which case, it's necessary to reset it, before re-using it.This method can also be used to abruptly stop an unfinished decompression, and start a new one using the same context resources.
- Since:
- 1.8.0
-
LZ4F_getErrorCode
public static int LZ4F_getErrorCode(long functionResult) -
nLZ4F_compressBegin_usingDict
public static long nLZ4F_compressBegin_usingDict(long cctx, long dstBuffer, long dstCapacity, long dictBuffer, long dictSize, long prefsPtr) Unsafe version of:compressBegin_usingDict- Parameters:
dstCapacity- must be ≥HEADER_SIZE_MAXbytesdictSize- must outlive the compression session
-
LZ4F_compressBegin_usingDict
public static long LZ4F_compressBegin_usingDict(long cctx, ByteBuffer dstBuffer, ByteBuffer dictBuffer, @Nullable LZ4FPreferences prefsPtr) Inits dictionary compression streaming, and writes the frame header intodstBuffer.NOTE: The
LZ4Framespec allows each independent block to be compressed with the dictionary, but this entry supports a more limited scenario, where only the first block uses the dictionary. This is still useful for small data, which only need one block anyway. For larger inputs, one may be more interested incompressFrame_usingCDict.- Parameters:
prefsPtr- optional: one may provideNULLas argument, however, it's the only way to providedictIDin the frame header.- Returns:
- number of bytes written into
dstBufferfor the header, or an error code (which can be tested usingisError)
-
nLZ4F_decompress_usingDict
public static long nLZ4F_decompress_usingDict(long dctxPtr, long dstBuffer, long dstSizePtr, long srcBuffer, long srcSizePtr, long dict, long dictSize, long decompressOptionsPtr) Unsafe version of:decompress_usingDict -
LZ4F_decompress_usingDict
public static long LZ4F_decompress_usingDict(long dctxPtr, ByteBuffer dstBuffer, org.lwjgl.PointerBuffer dstSizePtr, ByteBuffer srcBuffer, org.lwjgl.PointerBuffer srcSizePtr, ByteBuffer dict, LZ4FDecompressOptions decompressOptionsPtr) Same asdecompress, using a predefined dictionary.Dictionary is used "in place", without any preprocessing. It must remain accessible throughout the entire frame decoding.
-
nLZ4F_createCDict
public static long nLZ4F_createCDict(long dictBuffer, long dictSize) Unsafe version of:createCDict -
LZ4F_createCDict
When compressing multiple messages / blocks with the same dictionary, it's recommended to load it just once.LZ4_createCDict()will create a digested dictionary, ready to start future compression operations without startup delay.LZ4_CDictcan be created once and shared by multiple threads concurrently, since its usage is read-only.dictBuffercan be released afterLZ4_CDictcreation, since its content is copied withinCDict. -
nLZ4F_freeCDict
public static void nLZ4F_freeCDict(long CDict) -
LZ4F_freeCDict
public static void LZ4F_freeCDict(long CDict) -
nLZ4F_compressFrame_usingCDict
public static long nLZ4F_compressFrame_usingCDict(long cctx, long dst, long dstCapacity, long src, long srcSize, long cdict, long preferencesPtr) Unsafe version of:compressFrame_usingCDict -
LZ4F_compressFrame_usingCDict
public static long LZ4F_compressFrame_usingCDict(long cctx, ByteBuffer dst, ByteBuffer src, long cdict, LZ4FPreferences preferencesPtr) Compress an entiresrcBufferinto a valid LZ4 frame using a digested Dictionary.dstMUST be ≥compressFrameBound(srcSize, preferencesPtr). If this condition is not respected, function will fail (return anerrorCode).- Parameters:
cctx- must point to a context created bycreateCompressionContext.cdict- ifNULL, compress without a dictionarypreferencesPtr- optional: you may provideNULLas argument, but it's not recommended, as it's the only way to providedictIDin the frame header- Returns:
- number of bytes written into
dstBufferor an error code if it fails (can be tested usingisError)
-
nLZ4F_compressBegin_usingCDict
public static long nLZ4F_compressBegin_usingCDict(long cctx, long dstBuffer, long dstCapacity, long cdict, long prefsPtr) Unsafe version of:compressBegin_usingCDict- Parameters:
dstCapacity- must be ≥HEADER_SIZE_MAXbytes
-
LZ4F_compressBegin_usingCDict
public static long LZ4F_compressBegin_usingCDict(long cctx, ByteBuffer dstBuffer, long cdict, LZ4FPreferences prefsPtr) Inits streaming dictionary compression, and writes the frame header intodstBuffer.- Parameters:
cdict- must outlive the compression sessionprefsPtr- optional: you may provideNULLas argument, however, it's the only way to providedictIDin the frame header- Returns:
- number of bytes written into
dstBufferfor the header, or an error code (which can be tested usingisError)
-
LZ4F_getBlockSize
public static long LZ4F_getBlockSize(int blockSizeID) Return, in scalar format (size_t), the maximum block size associated withblockSizeID, or an error code (can be tested usingisError) ifblockSizeIDis invalid. -
nLZ4F_uncompressedUpdate
public static long nLZ4F_uncompressedUpdate(long cctx, long dstBuffer, long dstCapacity, long srcBuffer, long srcSize, long cOptPtr) Unsafe version of:uncompressedUpdate -
LZ4F_uncompressedUpdate
public static long LZ4F_uncompressedUpdate(long cctx, ByteBuffer dstBuffer, ByteBuffer srcBuffer, @Nullable LZ4FCompressOptions cOptPtr) Can be called repetitively to add data stored as uncompressed blocks.Important rule:
dstCapacityMUST be large enough to store the entire source buffer as no compression is done for this operation. If this condition is not respected,LZ4F_uncompressedUpdate()will fail (result is anerrorCode). After an error, the state is left in a UB state, and must be re-initialized or freed. If previously a compressed block was written, buffered data is flushed first before appending uncompressed data is continued. This operation is only supported whenblockIndependentis used.- Parameters:
cOptPtr- optional :NULLcan be provided, in which case all options are set to default- Returns:
- number of bytes written into
dstBuffer(it can be zero, meaning input data was just buffered), or an error code if it fails (which can be tested usingisError)"
-
nLZ4F_createCompressionContext_advanced
public static long nLZ4F_createCompressionContext_advanced(long customMem, int version) Unsafe version of:createCompressionContext_advanced -
LZ4F_createCompressionContext_advanced
createCompressionContextwith custom allocation/free functions. -
nLZ4F_createDecompressionContext_advanced
public static long nLZ4F_createDecompressionContext_advanced(long customMem, int version) Unsafe version of:createDecompressionContext_advanced -
LZ4F_createDecompressionContext_advanced
createDecompressionContextwith custom allocation/free functions. -
nLZ4F_createCDict_advanced
public static long nLZ4F_createCDict_advanced(long customMem, long dictBuffer, long dictSize) Unsafe version of:createCDict_advanced -
LZ4F_createCDict_advanced
createCDictwith custom allocation/free functions.
-