public class LZ4Frame
extends java.lang.Object
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.
| Modifier and Type | Field and Description |
|---|---|
static int |
LZ4F_BLOCK_CHECKSUM_SIZE
Size in bytes of a block checksum footer in little-endian format.
|
static int |
LZ4F_BLOCK_HEADER_SIZE
Size in bytes of a block header in little-endian format.
|
static int |
LZ4F_blockChecksumEnabled
LZ4F_blockChecksum_t |
static int |
LZ4F_blockIndependent
LZ4F_blockMode_t |
static int |
LZ4F_blockLinked
LZ4F_blockMode_t |
static int |
LZ4F_CONTENT_CHECKSUM_SIZE
Size in bytes of the content checksum.
|
static int |
LZ4F_contentChecksumEnabled
LZ4F_contentChecksum_t |
static int |
LZ4F_default
LZ4F_blockSizeID_t |
static int |
LZ4F_ERROR_allocation_failed
Error code.
|
static int |
LZ4F_ERROR_blockChecksum_invalid
Error code.
|
static int |
LZ4F_ERROR_blockMode_invalid
Error code.
|
static int |
LZ4F_ERROR_compressionLevel_invalid
Error code.
|
static int |
LZ4F_ERROR_contentChecksum_invalid
Error code.
|
static int |
LZ4F_ERROR_contentChecksumFlag_invalid
Error code.
|
static int |
LZ4F_ERROR_decompressionFailed
Error code.
|
static int |
LZ4F_ERROR_dstMaxSize_tooSmall
Error code.
|
static int |
LZ4F_ERROR_frameDecoding_alreadyStarted
Error code.
|
static int |
LZ4F_ERROR_frameHeader_incomplete
Error code.
|
static int |
LZ4F_ERROR_frameSize_wrong
Error code.
|
static int |
LZ4F_ERROR_frameType_unknown
Error code.
|
static int |
LZ4F_ERROR_GENERIC
Error code.
|
static int |
LZ4F_ERROR_headerChecksum_invalid
Error code.
|
static int |
LZ4F_ERROR_headerVersion_wrong
Error code.
|
static int |
LZ4F_ERROR_maxBlockSize_invalid
Error code.
|
static int |
LZ4F_ERROR_maxCode
Error code.
|
static int |
LZ4F_ERROR_reservedFlag_set
Error code.
|
static int |
LZ4F_ERROR_srcPtr_wrong
Error code.
|
static int |
LZ4F_ERROR_srcSize_tooLarge
Error code.
|
static int |
LZ4F_frame
LZ4F_frameType_t |
static int |
LZ4F_HEADER_SIZE_MAX
Maximum header size.
|
static int |
LZ4F_HEADER_SIZE_MIN
Minimum header size.
|
static int |
LZ4F_max1MB
LZ4F_blockSizeID_t |
static int |
LZ4F_max256KB
LZ4F_blockSizeID_t |
static int |
LZ4F_max4MB
LZ4F_blockSizeID_t |
static int |
LZ4F_max64KB
LZ4F_blockSizeID_t |
static int |
LZ4F_noBlockChecksum
LZ4F_blockChecksum_t |
static int |
LZ4F_noContentChecksum
LZ4F_contentChecksum_t |
static int |
LZ4F_OK_NoError
Error code.
|
static int |
LZ4F_skippableFrame
LZ4F_frameType_t |
static int |
LZ4F_VERSION
Version number.
|
| Modifier and Type | Method and Description |
|---|---|
static long |
LZ4F_compressBegin_usingCDict(long cctx,
java.nio.ByteBuffer dstBuffer,
long cdict,
LZ4FPreferences prefsPtr)
Inits streaming dictionary compression, and writes the frame header into
dstBuffer. |
static long |
LZ4F_compressBegin(long cctx,
java.nio.ByteBuffer dstBuffer,
LZ4FPreferences prefsPtr)
Will write the frame header into
dstBuffer. |
static long |
LZ4F_compressBound(long srcSize,
LZ4FPreferences prefsPtr)
Provides minimum
dstCapacity required to guarantee compression success given a srcSize and preferences, covering worst case scenario. |
static long |
LZ4F_compressEnd(long cctx,
java.nio.ByteBuffer dstBuffer,
LZ4FCompressOptions cOptPtr)
To properly finish an LZ4 frame, invoke
compressEnd. |
static long |
LZ4F_compressFrame_usingCDict(long cctx,
java.nio.ByteBuffer dst,
java.nio.ByteBuffer src,
long cdict,
LZ4FPreferences preferencesPtr)
Compress an entire
srcBuffer into a valid LZ4 frame using a digested Dictionary. |
static long |
LZ4F_compressFrame(java.nio.ByteBuffer dstBuffer,
java.nio.ByteBuffer srcBuffer,
LZ4FPreferences preferencesPtr)
Compress an entire
srcBuffer into a valid LZ4 frame. |
static long |
LZ4F_compressFrameBound(long srcSize,
LZ4FPreferences preferencesPtr)
Returns the maximum possible size of a frame compressed with
compressFrame given srcSize content and preferences. |
static int |
LZ4F_compressionLevel_max() |
static long |
LZ4F_compressUpdate(long cctx,
java.nio.ByteBuffer dstBuffer,
java.nio.ByteBuffer srcBuffer,
LZ4FCompressOptions cOptPtr)
LZ4F_compressUpdate() can be called repetitively to compress as much data as necessary. |
static long |
LZ4F_createCDict(java.nio.ByteBuffer dictBuffer)
When compressing multiple messages / blocks with the same dictionary, it's recommended to load it just once.
|
static long |
LZ4F_createCompressionContext(org.lwjgl.PointerBuffer cctxPtr,
int version)
The first thing to do is to create a
compressionContext object, which will be used in all compression operations. |
static long |
LZ4F_createDecompressionContext(org.lwjgl.PointerBuffer dctxPtr,
int version)
Create an
LZ4F_dctx object, to track all decompression operations. |
static long |
LZ4F_decompress_usingDict(long dctxPtr,
java.nio.ByteBuffer dstBuffer,
org.lwjgl.PointerBuffer dstSizePtr,
java.nio.ByteBuffer srcBuffer,
org.lwjgl.PointerBuffer srcSizePtr,
java.nio.ByteBuffer dict,
LZ4FDecompressOptions decompressOptionsPtr)
Same as
decompress, using a predefined dictionary. |
static long |
LZ4F_decompress(long dctx,
java.nio.ByteBuffer dstBuffer,
org.lwjgl.PointerBuffer dstSizePtr,
java.nio.ByteBuffer srcBuffer,
org.lwjgl.PointerBuffer srcSizePtr,
LZ4FDecompressOptions dOptPtr)
Call this function repetitively to regenerate compressed data from
srcBuffer. |
static long |
LZ4F_flush(long cctx,
java.nio.ByteBuffer dstBuffer,
LZ4FCompressOptions cOptPtr)
When data must be generated and sent immediately, without waiting for a block to be completely filled, it's possible to call
flush. |
static void |
LZ4F_freeCDict(long CDict) |
static long |
LZ4F_freeCompressionContext(long cctx) |
static long |
LZ4F_freeDecompressionContext(long dctx)
Frees an
LZ4F_dctx object. |
static int |
LZ4F_getErrorCode(long functionResult) |
static java.lang.String |
LZ4F_getErrorName(long code)
Return error code string; for debugging.
|
static long |
LZ4F_getFrameInfo(long dctx,
LZ4FFrameInfo frameInfoPtr,
java.nio.ByteBuffer srcBuffer,
org.lwjgl.PointerBuffer srcSizePtr)
This function extracts frame parameters (max
blockSize, dictID, etc.). |
static int |
LZ4F_getVersion() |
static boolean |
LZ4F_isError(long code)
Tells when a function result is an error code.
|
static void |
LZ4F_resetDecompressionContext(long dctx)
In case of an error, the context is left in "undefined" state.
|
static long |
nLZ4F_compressBegin_usingCDict(long cctx,
long dstBuffer,
long dstCapacity,
long cdict,
long prefsPtr)
Unsafe version of:
compressBegin_usingCDict |
static long |
nLZ4F_compressBegin(long cctx,
long dstBuffer,
long dstCapacity,
long prefsPtr)
Unsafe version of:
compressBegin |
static long |
nLZ4F_compressBound(long srcSize,
long prefsPtr)
Unsafe version of:
compressBound |
static long |
nLZ4F_compressEnd(long cctx,
long dstBuffer,
long dstCapacity,
long cOptPtr)
Unsafe version of:
compressEnd |
static long |
nLZ4F_compressFrame_usingCDict(long cctx,
long dst,
long dstCapacity,
long src,
long srcSize,
long cdict,
long preferencesPtr)
Unsafe version of:
compressFrame_usingCDict |
static long |
nLZ4F_compressFrame(long dstBuffer,
long dstCapacity,
long srcBuffer,
long srcSize,
long preferencesPtr)
Unsafe version of:
compressFrame |
static long |
nLZ4F_compressFrameBound(long srcSize,
long preferencesPtr)
Unsafe version of:
compressFrameBound |
static long |
nLZ4F_compressUpdate(long cctx,
long dstBuffer,
long dstCapacity,
long srcBuffer,
long srcSize,
long cOptPtr)
Unsafe version of:
compressUpdate |
static long |
nLZ4F_createCDict(long dictBuffer,
long dictSize)
Unsafe version of:
createCDict |
static long |
nLZ4F_createCompressionContext(long cctxPtr,
int version)
Unsafe version of:
createCompressionContext |
static long |
nLZ4F_createDecompressionContext(long dctxPtr,
int version)
Unsafe version of:
createDecompressionContext |
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 |
static long |
nLZ4F_decompress(long dctx,
long dstBuffer,
long dstSizePtr,
long srcBuffer,
long srcSizePtr,
long dOptPtr)
Unsafe version of:
decompress |
static long |
nLZ4F_flush(long cctx,
long dstBuffer,
long dstCapacity,
long cOptPtr)
Unsafe version of:
flush |
static void |
nLZ4F_freeCDict(long CDict) |
static long |
nLZ4F_freeCompressionContext(long cctx) |
static long |
nLZ4F_freeDecompressionContext(long dctx)
Unsafe version of:
freeDecompressionContext |
static long |
nLZ4F_getErrorName(long code)
Unsafe version of:
getErrorName |
static long |
nLZ4F_getFrameInfo(long dctx,
long frameInfoPtr,
long srcBuffer,
long srcSizePtr)
Unsafe version of:
getFrameInfo |
static int |
nLZ4F_isError(long code)
Unsafe version of:
isError |
static void |
nLZ4F_resetDecompressionContext(long dctx)
Unsafe version of:
resetDecompressionContext |
public static final int LZ4F_VERSION
This number can be used to check for an incompatible API breaking change.
public static final int LZ4F_HEADER_SIZE_MIN
public static final int LZ4F_HEADER_SIZE_MAX
public static final int LZ4F_BLOCK_HEADER_SIZE
public static final int LZ4F_BLOCK_CHECKSUM_SIZE
public static final int LZ4F_CONTENT_CHECKSUM_SIZE
public static final int LZ4F_default
LZ4F_blockSizeID_t
The 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.
public static final int LZ4F_max64KB
LZ4F_blockSizeID_t
The 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.
public static final int LZ4F_max256KB
LZ4F_blockSizeID_t
The 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.
public static final int LZ4F_max1MB
LZ4F_blockSizeID_t
The 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.
public static final int LZ4F_max4MB
LZ4F_blockSizeID_t
The 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.
public static final int LZ4F_blockLinked
LZ4F_blockMode_t
Linked blocks sharply reduce inefficiencies when using small blocks, they compress better. However, some LZ4 decoders are only compatible with independent blocks
public static final int LZ4F_blockIndependent
LZ4F_blockMode_t
Linked blocks sharply reduce inefficiencies when using small blocks, they compress better. However, some LZ4 decoders are only compatible with independent blocks
public static final int LZ4F_noContentChecksum
public static final int LZ4F_contentChecksumEnabled
public static final int LZ4F_noBlockChecksum
public static final int LZ4F_blockChecksumEnabled
public static final int LZ4F_frame
public static final int LZ4F_skippableFrame
public static final int LZ4F_OK_NoError
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_GENERIC
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_maxBlockSize_invalid
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_blockMode_invalid
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_contentChecksumFlag_invalid
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_compressionLevel_invalid
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_headerVersion_wrong
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_blockChecksum_invalid
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_reservedFlag_set
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_allocation_failed
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_srcSize_tooLarge
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_dstMaxSize_tooSmall
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_frameHeader_incomplete
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_frameType_unknown
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_frameSize_wrong
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_srcPtr_wrong
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_decompressionFailed
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_headerChecksum_invalid
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_contentChecksum_invalid
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_frameDecoding_alreadyStarted
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static final int LZ4F_ERROR_maxCode
OK_NoErrorERROR_GENERICERROR_maxBlockSize_invalidERROR_blockMode_invalidERROR_contentChecksumFlag_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_maxCodepublic static int nLZ4F_isError(long code)
isErrorpublic static boolean LZ4F_isError(long code)
public static long nLZ4F_getErrorName(long code)
getErrorName@Nullable public static java.lang.String LZ4F_getErrorName(long code)
public static int LZ4F_compressionLevel_max()
public static long nLZ4F_compressFrameBound(long srcSize,
long preferencesPtr)
compressFrameBoundpublic static long LZ4F_compressFrameBound(long srcSize,
@Nullable
LZ4FPreferences preferencesPtr)
compressFrame given srcSize content and preferences.
Returns the maximum possible compressed size with compressFrame given srcSize and preferences. preferencesPtr is optional. It can be
replaced by NULL, in which case, the function will assume default preferences.
this result is only usable with compressFrame. It may also be used with compressUpdate if no {@link #LZ4F_flush flush} operation is performed.
public static long nLZ4F_compressFrame(long dstBuffer,
long dstCapacity,
long srcBuffer,
long srcSize,
long preferencesPtr)
compressFramedstCapacity - MUST be ≥ compressFrameBound(srcSize, preferencesPtr)public static long LZ4F_compressFrame(java.nio.ByteBuffer dstBuffer,
java.nio.ByteBuffer srcBuffer,
@Nullable
LZ4FPreferences preferencesPtr)
srcBuffer into a valid LZ4 frame.
The LZ4F_preferences_t structure is optional: you can provide NULL as argument. All preferences will be set to default.
dstBuffer or an error code if it fails (can be tested using isError)public static int LZ4F_getVersion()
public static long nLZ4F_createCompressionContext(long cctxPtr,
int version)
createCompressionContextpublic static long LZ4F_createCompressionContext(org.lwjgl.PointerBuffer cctxPtr,
int version)
compressionContext object, which will be used in all compression operations. This is achieved using
LZ4F_createCompressionContext(), which takes as argument a version.
The function will provide a pointer to a fully allocated LZ4F_cctx object. Object can release its memory using freeCompressionContext;
public static long nLZ4F_freeCompressionContext(long cctx)
public static long LZ4F_freeCompressionContext(long cctx)
public static long nLZ4F_compressBegin(long cctx,
long dstBuffer,
long dstCapacity,
long prefsPtr)
compressBegindstCapacity - must be ≥ HEADER_SIZE_MAX bytespublic static long LZ4F_compressBegin(long cctx,
java.nio.ByteBuffer dstBuffer,
@Nullable
LZ4FPreferences prefsPtr)
dstBuffer.prefsPtr - optional: you can provide NULL as argument, all preferences will then be set to defaultdstBuffer for the header or an error code (which can be tested using isError)public static long nLZ4F_compressBound(long srcSize,
long prefsPtr)
compressBoundpublic static long LZ4F_compressBound(long srcSize,
@Nullable
LZ4FPreferences prefsPtr)
dstCapacity required to guarantee compression success given a srcSize and preferences, covering worst case scenario.
Estimation is valid for either compressUpdate, flush or compressEnd. Estimation includes the possibility that internal buffer might already
be filled by up to (blockSize-1) bytes. It also includes frame footer (ending + checksum), which would have to be generated by
compressEnd. Estimation doesn't include frame header, as it was already generated by compressBegin.
Result is always the same for a srcSize and prefsPtr, so it can be trusted to size reusable buffers.
When srcSize==0, LZ4F_compressBound() provides an upper bound for flush and compressEnd operations.
prefsPtr - optional: when NULL is provided, preferences will be set to cover worst case scenariopublic static long nLZ4F_compressUpdate(long cctx,
long dstBuffer,
long dstCapacity,
long srcBuffer,
long srcSize,
long cOptPtr)
compressUpdatepublic static long LZ4F_compressUpdate(long cctx,
java.nio.ByteBuffer dstBuffer,
java.nio.ByteBuffer srcBuffer,
@Nullable
LZ4FCompressOptions cOptPtr)
LZ4F_compressUpdate() can be called repetitively to compress as much data as necessary.
Important rule: dstCapacity MUST be large enough to ensure operation success even in worst case situations. This value is provided by
compressBound. If this condition is not respected, LZ4F_compress() will fail (result is an errorCode).
LZ4F_compressUpdate() doesn't guarantee error recovery. When an error occurs, compression context must be freed or resized.
cOptPtr - optional: NULL can be provided, in which case all options are set to defaultdstBuffer (it can be zero, meaning input data was just buffered) or an error code if it fails (which can be tested
using isError)public static long nLZ4F_flush(long cctx,
long dstBuffer,
long dstCapacity,
long cOptPtr)
flushdstCapacity - must be large enough to ensure the operation will be successfulpublic static long LZ4F_flush(long cctx,
java.nio.ByteBuffer dstBuffer,
@Nullable
LZ4FCompressOptions cOptPtr)
flush. It will
immediately compress any data buffered within cctx.cOptPtr - optional: it's possible to provide NULL, all options will be set to defaultdstBuffer (can be zero, when there is no data stored within cctx) or an error code if it fails (which can be
tested using isError)public static long nLZ4F_compressEnd(long cctx,
long dstBuffer,
long dstCapacity,
long cOptPtr)
compressEndpublic static long LZ4F_compressEnd(long cctx,
java.nio.ByteBuffer dstBuffer,
@Nullable
LZ4FCompressOptions cOptPtr)
compressEnd. It will flush whatever data remained within cctx (like flush) and properly finalize
the frame, with an endMark and a checksum.cOptPtr - optional: NULL can be provided, in which case all options will be set to defaultdstBuffer, necessarily ≥ 4 (endMark), or an error code if it fails (which can be tested using isError).
A successful call to compressEnd makes cctx available again for another compression task.
public static long nLZ4F_createDecompressionContext(long dctxPtr,
int version)
createDecompressionContextpublic static long LZ4F_createDecompressionContext(org.lwjgl.PointerBuffer dctxPtr,
int version)
LZ4F_dctx object, to track all decompression operations.
The function provides a pointer to an allocated and initialized LZ4F_dctx object. dctx memory can be released using
freeDecompressionContext.
public static long nLZ4F_freeDecompressionContext(long dctx)
freeDecompressionContextpublic static long LZ4F_freeDecompressionContext(long dctx)
LZ4F_dctx object.isError.
Result of LZ4F_freeDecompressionContext() indicates current state of decompressionContext when being released. That is, it should be
== 0 if decompression has been completed fully and correctly.
public static long nLZ4F_getFrameInfo(long dctx,
long frameInfoPtr,
long srcBuffer,
long srcSizePtr)
getFrameInfopublic static long LZ4F_getFrameInfo(long dctx,
LZ4FFrameInfo frameInfoPtr,
java.nio.ByteBuffer srcBuffer,
org.lwjgl.PointerBuffer srcSizePtr)
blockSize, dictID, etc.). Its usage is optional.
Extracted information is typically useful for allocation and dictionary. This function works in 2 situations:
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_MAX bytes. It's allowed to provide more input data than this minimum.
dctx.LZ4F_getFrameInfo() will fail.The number of bytes consumed from srcBuffer will be updated within *srcSizePtr (necessarily ≤ original value). Decompression must
resume from (srcBuffer + *srcSizePtr).
Notes:
dctx is not modified. Decoding operation can resume from beginning safelyLZ4F_frameInfo_t structurepublic static long nLZ4F_decompress(long dctx,
long dstBuffer,
long dstSizePtr,
long srcBuffer,
long srcSizePtr,
long dOptPtr)
decompresspublic static long LZ4F_decompress(long dctx,
java.nio.ByteBuffer dstBuffer,
org.lwjgl.PointerBuffer dstSizePtr,
java.nio.ByteBuffer srcBuffer,
org.lwjgl.PointerBuffer srcSizePtr,
LZ4FDecompressOptions dOptPtr)
srcBuffer. The function will read up to *srcSizePtr
bytes from srcBuffer, and decompress data into dstBuffer, of capacity *dstSizePtr.
The nb of bytes consumed from srcBuffer will be written into *srcSizePtr (necessarily ≤ original value). The number of bytes
decompressed into dstBuffer will be written into *dstSizePtr (necessarily ≤ original value).
The nb of bytes regenerated into dstBuffer is 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.
dstBuffer can freely change between each consecutive function invocation. dstBuffer content will be overwritten.
After a frame is fully decoded, dctx can be used again to decompress another frame.
After a decompression error, use resetDecompressionContext before re-using dctx, to return to clean state.
srcSize bytes LZ4F_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, the dctx context is not
resumable. Use resetDecompressionContext to return to clean state.
public static void nLZ4F_resetDecompressionContext(long dctx)
resetDecompressionContextpublic static void LZ4F_resetDecompressionContext(long dctx)
This method can also be used to abruptly stop an unfinished decompression, and start a new one using the same context resources.
public static int LZ4F_getErrorCode(long functionResult)
public static long nLZ4F_createCDict(long dictBuffer,
long dictSize)
createCDictpublic static long LZ4F_createCDict(java.nio.ByteBuffer dictBuffer)
LZ4_createCDict() will create a
digested dictionary, ready to start future compression operations without startup delay.
LZ4_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only.
dictBuffer can be released after LZ4_CDict creation, since its content is copied within CDict.
public static void nLZ4F_freeCDict(long CDict)
public static void LZ4F_freeCDict(long CDict)
public static long nLZ4F_compressFrame_usingCDict(long cctx,
long dst,
long dstCapacity,
long src,
long srcSize,
long cdict,
long preferencesPtr)
compressFrame_usingCDictpublic static long LZ4F_compressFrame_usingCDict(long cctx,
java.nio.ByteBuffer dst,
java.nio.ByteBuffer src,
long cdict,
LZ4FPreferences preferencesPtr)
srcBuffer into a valid LZ4 frame using a digested Dictionary.
dst MUST be ≥ compressFrameBound(srcSize, preferencesPtr). If this condition is not respected, function will fail (return an
errorCode).
cctx - must point to a context created by createCompressionContext.cdict - if NULL, compress without a dictionarypreferencesPtr - optional: you may provide NULL as argument, but it's not recommended, as it's the only way to provide dictID in the frame headerdstBuffer or an error code if it fails (can be tested using isError)public static long nLZ4F_compressBegin_usingCDict(long cctx,
long dstBuffer,
long dstCapacity,
long cdict,
long prefsPtr)
compressBegin_usingCDictpublic static long LZ4F_compressBegin_usingCDict(long cctx,
java.nio.ByteBuffer dstBuffer,
long cdict,
LZ4FPreferences prefsPtr)
dstBuffer.
dstCapacity must be ≥ HEADER_SIZE_MAX bytes.
prefsPtr - optional: you may provide NULL as argument, however, it's the only way to provide dictID in the frame headerdstBuffer for the header, or an error code (which can be tested using isError)public static long nLZ4F_decompress_usingDict(long dctxPtr,
long dstBuffer,
long dstSizePtr,
long srcBuffer,
long srcSizePtr,
long dict,
long dictSize,
long decompressOptionsPtr)
decompress_usingDictpublic static long LZ4F_decompress_usingDict(long dctxPtr,
java.nio.ByteBuffer dstBuffer,
org.lwjgl.PointerBuffer dstSizePtr,
java.nio.ByteBuffer srcBuffer,
org.lwjgl.PointerBuffer srcSizePtr,
java.nio.ByteBuffer dict,
LZ4FDecompressOptions decompressOptionsPtr)
decompress, using a predefined dictionary.
Dictionary is used "in place", without any preprocessing. It must remain accessible throughout the entire frame decoding.
Copyright LWJGL. All Rights Reserved. License terms.