mirror of
https://github.com/facebook/zstd.git
synced 2025-10-09 00:05:28 -04:00
Add new sequence format as an experimental CCtx param
This commit is contained in:
parent
347824ad73
commit
7f563b0519
@ -457,6 +457,11 @@ ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter param)
|
|||||||
bounds.lowerBound = (int)ZSTD_bm_buffered;
|
bounds.lowerBound = (int)ZSTD_bm_buffered;
|
||||||
bounds.upperBound = (int)ZSTD_bm_stable;
|
bounds.upperBound = (int)ZSTD_bm_stable;
|
||||||
return bounds;
|
return bounds;
|
||||||
|
|
||||||
|
case ZSTD_c_blockDelimiters:
|
||||||
|
bounds.lowerBound = (int)ZSTD_sf_noBlockDelimiters;
|
||||||
|
bounds.upperBound = (int)ZSTD_sf_explicitBlockDelimiters;
|
||||||
|
return bounds;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
bounds.error = ERROR(parameter_unsupported);
|
bounds.error = ERROR(parameter_unsupported);
|
||||||
@ -517,6 +522,7 @@ static int ZSTD_isUpdateAuthorized(ZSTD_cParameter param)
|
|||||||
case ZSTD_c_srcSizeHint:
|
case ZSTD_c_srcSizeHint:
|
||||||
case ZSTD_c_stableInBuffer:
|
case ZSTD_c_stableInBuffer:
|
||||||
case ZSTD_c_stableOutBuffer:
|
case ZSTD_c_stableOutBuffer:
|
||||||
|
case ZSTD_c_blockDelimiters:
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -567,6 +573,7 @@ size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int value)
|
|||||||
case ZSTD_c_srcSizeHint:
|
case ZSTD_c_srcSizeHint:
|
||||||
case ZSTD_c_stableInBuffer:
|
case ZSTD_c_stableInBuffer:
|
||||||
case ZSTD_c_stableOutBuffer:
|
case ZSTD_c_stableOutBuffer:
|
||||||
|
case ZSTD_c_blockDelimiters:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: RETURN_ERROR(parameter_unsupported, "unknown parameter");
|
default: RETURN_ERROR(parameter_unsupported, "unknown parameter");
|
||||||
@ -767,6 +774,11 @@ size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* CCtxParams,
|
|||||||
BOUNDCHECK(ZSTD_c_stableOutBuffer, value);
|
BOUNDCHECK(ZSTD_c_stableOutBuffer, value);
|
||||||
CCtxParams->outBufferMode = (ZSTD_bufferMode_e)value;
|
CCtxParams->outBufferMode = (ZSTD_bufferMode_e)value;
|
||||||
return CCtxParams->outBufferMode;
|
return CCtxParams->outBufferMode;
|
||||||
|
|
||||||
|
case ZSTD_c_blockDelimiters:
|
||||||
|
BOUNDCHECK(ZSTD_c_blockDelimiters, value);
|
||||||
|
CCtxParams->blockDelimiters = (ZSTD_sequenceFormat_e)value;
|
||||||
|
return CCtxParams->blockDelimiters;
|
||||||
|
|
||||||
default: RETURN_ERROR(parameter_unsupported, "unknown parameter");
|
default: RETURN_ERROR(parameter_unsupported, "unknown parameter");
|
||||||
}
|
}
|
||||||
@ -885,6 +897,9 @@ size_t ZSTD_CCtxParams_getParameter(
|
|||||||
case ZSTD_c_stableOutBuffer :
|
case ZSTD_c_stableOutBuffer :
|
||||||
*value = (int)CCtxParams->outBufferMode;
|
*value = (int)CCtxParams->outBufferMode;
|
||||||
break;
|
break;
|
||||||
|
case ZSTD_c_blockDelimiters :
|
||||||
|
*value = (int)CCtxParams->blockDelimiters;
|
||||||
|
break;
|
||||||
default: RETURN_ERROR(parameter_unsupported, "unknown parameter");
|
default: RETURN_ERROR(parameter_unsupported, "unknown parameter");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -1718,9 +1733,6 @@ static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc,
|
|||||||
zc->ldmState.loadedDictEnd = 0;
|
zc->ldmState.loadedDictEnd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
zc->blockDelimiters = ZSTD_sf_noBlockDelimiters;
|
|
||||||
zc->calculateRepcodes = ZSTD_sf_calculateRepcodes;
|
|
||||||
|
|
||||||
/* Due to alignment, when reusing a workspace, we can actually consume
|
/* Due to alignment, when reusing a workspace, we can actually consume
|
||||||
* up to 3 extra bytes for alignment. See the comments in zstd_cwksp.h
|
* up to 3 extra bytes for alignment. See the comments in zstd_cwksp.h
|
||||||
*/
|
*/
|
||||||
|
@ -242,6 +242,9 @@ struct ZSTD_CCtx_params_s {
|
|||||||
ZSTD_bufferMode_e inBufferMode;
|
ZSTD_bufferMode_e inBufferMode;
|
||||||
ZSTD_bufferMode_e outBufferMode;
|
ZSTD_bufferMode_e outBufferMode;
|
||||||
|
|
||||||
|
/* Sequence compression API */
|
||||||
|
ZSTD_sequenceFormat_e blockDelimiters;
|
||||||
|
|
||||||
/* Internal use, for createCCtxParams() and freeCCtxParams() only */
|
/* Internal use, for createCCtxParams() and freeCCtxParams() only */
|
||||||
ZSTD_customMem customMem;
|
ZSTD_customMem customMem;
|
||||||
}; /* typedef'd to ZSTD_CCtx_params within "zstd.h" */
|
}; /* typedef'd to ZSTD_CCtx_params within "zstd.h" */
|
||||||
@ -313,10 +316,6 @@ struct ZSTD_CCtx_s {
|
|||||||
const ZSTD_CDict* cdict;
|
const ZSTD_CDict* cdict;
|
||||||
ZSTD_prefixDict prefixDict; /* single-usage dictionary */
|
ZSTD_prefixDict prefixDict; /* single-usage dictionary */
|
||||||
|
|
||||||
/* Sequence compression API */
|
|
||||||
ZSTD_sequenceFormat_blockBoundaries_e blockDelimiters;
|
|
||||||
ZSTD_sequenceFormat_repcodes_e calculateRepcodes;
|
|
||||||
|
|
||||||
/* Multi-threading */
|
/* Multi-threading */
|
||||||
#ifdef ZSTD_MULTITHREAD
|
#ifdef ZSTD_MULTITHREAD
|
||||||
ZSTDMT_CCtx* mtctx;
|
ZSTDMT_CCtx* mtctx;
|
||||||
|
30
lib/zstd.h
30
lib/zstd.h
@ -417,6 +417,7 @@ typedef enum {
|
|||||||
* ZSTD_c_enableDedicatedDictSearch
|
* ZSTD_c_enableDedicatedDictSearch
|
||||||
* ZSTD_c_stableInBuffer
|
* ZSTD_c_stableInBuffer
|
||||||
* ZSTD_c_stableOutBuffer
|
* ZSTD_c_stableOutBuffer
|
||||||
|
* ZSTD_c_blockDelimiters
|
||||||
* Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
|
* Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
|
||||||
* note : never ever use experimentalParam? names directly;
|
* note : never ever use experimentalParam? names directly;
|
||||||
* also, the enums values themselves are unstable and can still change.
|
* also, the enums values themselves are unstable and can still change.
|
||||||
@ -430,7 +431,8 @@ typedef enum {
|
|||||||
ZSTD_c_experimentalParam7=1004,
|
ZSTD_c_experimentalParam7=1004,
|
||||||
ZSTD_c_experimentalParam8=1005,
|
ZSTD_c_experimentalParam8=1005,
|
||||||
ZSTD_c_experimentalParam9=1006,
|
ZSTD_c_experimentalParam9=1006,
|
||||||
ZSTD_c_experimentalParam10=1007
|
ZSTD_c_experimentalParam10=1007,
|
||||||
|
ZSTD_c_experimentalParam11=1008
|
||||||
} ZSTD_cParameter;
|
} ZSTD_cParameter;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -1298,14 +1300,9 @@ ZSTDLIB_API unsigned long long ZSTD_decompressBound(const void* src, size_t srcS
|
|||||||
ZSTDLIB_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
|
ZSTDLIB_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ZSTD_sf_noBlockDelimiters, /* Representation of ZSTD_Sequence has no block delimiters, sequences only */
|
ZSTD_sf_noBlockDelimiters = 0, /* Representation of ZSTD_Sequence has no block delimiters, sequences only */
|
||||||
ZSTD_sf_explicitBlockDelimiters /* Representation of ZSTD_Sequence contains explicit block delimiters */
|
ZSTD_sf_explicitBlockDelimiters = 1 /* Representation of ZSTD_Sequence contains explicit block delimiters */
|
||||||
} ZSTD_sequenceFormat_blockBoundaries_e;
|
} ZSTD_sequenceFormat_e;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
ZSTD_sf_calculateRepcodes,
|
|
||||||
ZSTD_sf_noCalculateRepcodes
|
|
||||||
} ZSTD_sequenceFormat_repcodes_e;
|
|
||||||
|
|
||||||
/*! ZSTD_generateSequences() :
|
/*! ZSTD_generateSequences() :
|
||||||
* Generate sequences using ZSTD_compress2, given a source buffer.
|
* Generate sequences using ZSTD_compress2, given a source buffer.
|
||||||
@ -1317,6 +1314,9 @@ typedef enum {
|
|||||||
*
|
*
|
||||||
* zc can be used to insert custom compression params.
|
* zc can be used to insert custom compression params.
|
||||||
* This function invokes ZSTD_compress2
|
* This function invokes ZSTD_compress2
|
||||||
|
*
|
||||||
|
* The output of this function can be fed into ZSTD_compressSequences() with ZSTD_c_explicitBlockDelimiters
|
||||||
|
* set to ZSTD_sf_explicitBlockDelimiters
|
||||||
* @return : number of sequences generated
|
* @return : number of sequences generated
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -1329,6 +1329,9 @@ ZSTDLIB_API size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
|
|||||||
*
|
*
|
||||||
* As such, the final generated result has no explicit representation of block boundaries,
|
* 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.
|
* and the final last literals segment is not represented in the sequences.
|
||||||
|
*
|
||||||
|
* The output of this function can be fed into ZSTD_compressSequences() with ZSTD_c_blockDelimiters
|
||||||
|
* set to ZSTD_sf_noBlockDelimiters
|
||||||
* @return : number of sequences left after merging
|
* @return : number of sequences left after merging
|
||||||
*/
|
*/
|
||||||
ZSTDLIB_API size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence* sequences, size_t seqsSize);
|
ZSTDLIB_API size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence* sequences, size_t seqsSize);
|
||||||
@ -1748,6 +1751,15 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* pre
|
|||||||
*/
|
*/
|
||||||
#define ZSTD_c_stableOutBuffer ZSTD_c_experimentalParam10
|
#define ZSTD_c_stableOutBuffer ZSTD_c_experimentalParam10
|
||||||
|
|
||||||
|
/* ZSTD_c_blockDelimiters
|
||||||
|
* Default is 0 == ZSTD_sf_noBlockDelimiters.
|
||||||
|
*
|
||||||
|
* For use with sequence compression API: ZSTD_compressSequences().
|
||||||
|
* Designates whether or not the given array of ZSTD_Sequence contains block delimiters
|
||||||
|
* which are defined as sequences with offset == 0 and matchLength == 0.
|
||||||
|
*/
|
||||||
|
#define ZSTD_c_blockDelimiters ZSTD_c_experimentalParam11
|
||||||
|
|
||||||
/*! ZSTD_CCtx_getParameter() :
|
/*! ZSTD_CCtx_getParameter() :
|
||||||
* Get the requested compression parameter value, selected by enum ZSTD_cParameter,
|
* Get the requested compression parameter value, selected by enum ZSTD_cParameter,
|
||||||
* and store it into int* value.
|
* and store it into int* value.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user