Add new sequence format as an experimental CCtx param
diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c
index 521752d..434ad6e 100644
--- a/lib/compress/zstd_compress.c
+++ b/lib/compress/zstd_compress.c
@@ -457,6 +457,11 @@
bounds.lowerBound = (int)ZSTD_bm_buffered;
bounds.upperBound = (int)ZSTD_bm_stable;
return bounds;
+
+ case ZSTD_c_blockDelimiters:
+ bounds.lowerBound = (int)ZSTD_sf_noBlockDelimiters;
+ bounds.upperBound = (int)ZSTD_sf_explicitBlockDelimiters;
+ return bounds;
default:
bounds.error = ERROR(parameter_unsupported);
@@ -517,6 +522,7 @@
case ZSTD_c_srcSizeHint:
case ZSTD_c_stableInBuffer:
case ZSTD_c_stableOutBuffer:
+ case ZSTD_c_blockDelimiters:
default:
return 0;
}
@@ -567,6 +573,7 @@
case ZSTD_c_srcSizeHint:
case ZSTD_c_stableInBuffer:
case ZSTD_c_stableOutBuffer:
+ case ZSTD_c_blockDelimiters:
break;
default: RETURN_ERROR(parameter_unsupported, "unknown parameter");
@@ -767,6 +774,11 @@
BOUNDCHECK(ZSTD_c_stableOutBuffer, value);
CCtxParams->outBufferMode = (ZSTD_bufferMode_e)value;
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");
}
@@ -885,6 +897,9 @@
case ZSTD_c_stableOutBuffer :
*value = (int)CCtxParams->outBufferMode;
break;
+ case ZSTD_c_blockDelimiters :
+ *value = (int)CCtxParams->blockDelimiters;
+ break;
default: RETURN_ERROR(parameter_unsupported, "unknown parameter");
}
return 0;
@@ -1718,9 +1733,6 @@
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
* up to 3 extra bytes for alignment. See the comments in zstd_cwksp.h
*/
diff --git a/lib/compress/zstd_compress_internal.h b/lib/compress/zstd_compress_internal.h
index 41cce60..51cb66d 100644
--- a/lib/compress/zstd_compress_internal.h
+++ b/lib/compress/zstd_compress_internal.h
@@ -242,6 +242,9 @@
ZSTD_bufferMode_e inBufferMode;
ZSTD_bufferMode_e outBufferMode;
+ /* Sequence compression API */
+ ZSTD_sequenceFormat_e blockDelimiters;
+
/* Internal use, for createCCtxParams() and freeCCtxParams() only */
ZSTD_customMem customMem;
}; /* typedef'd to ZSTD_CCtx_params within "zstd.h" */
@@ -313,10 +316,6 @@
const ZSTD_CDict* cdict;
ZSTD_prefixDict prefixDict; /* single-usage dictionary */
- /* Sequence compression API */
- ZSTD_sequenceFormat_blockBoundaries_e blockDelimiters;
- ZSTD_sequenceFormat_repcodes_e calculateRepcodes;
-
/* Multi-threading */
#ifdef ZSTD_MULTITHREAD
ZSTDMT_CCtx* mtctx;
diff --git a/lib/zstd.h b/lib/zstd.h
index aea0e3c..a0aa6d3 100644
--- a/lib/zstd.h
+++ b/lib/zstd.h
@@ -417,6 +417,7 @@
* ZSTD_c_enableDedicatedDictSearch
* ZSTD_c_stableInBuffer
* ZSTD_c_stableOutBuffer
+ * ZSTD_c_blockDelimiters
* Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
* note : never ever use experimentalParam? names directly;
* also, the enums values themselves are unstable and can still change.
@@ -430,7 +431,8 @@
ZSTD_c_experimentalParam7=1004,
ZSTD_c_experimentalParam8=1005,
ZSTD_c_experimentalParam9=1006,
- ZSTD_c_experimentalParam10=1007
+ ZSTD_c_experimentalParam10=1007,
+ ZSTD_c_experimentalParam11=1008
} ZSTD_cParameter;
typedef struct {
@@ -1298,14 +1300,9 @@
ZSTDLIB_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
typedef enum {
- ZSTD_sf_noBlockDelimiters, /* Representation of ZSTD_Sequence has no block delimiters, sequences only */
- ZSTD_sf_explicitBlockDelimiters /* Representation of ZSTD_Sequence contains explicit block delimiters */
-} ZSTD_sequenceFormat_blockBoundaries_e;
-
-typedef enum {
- ZSTD_sf_calculateRepcodes,
- ZSTD_sf_noCalculateRepcodes
-} ZSTD_sequenceFormat_repcodes_e;
+ ZSTD_sf_noBlockDelimiters = 0, /* Representation of ZSTD_Sequence has no block delimiters, sequences only */
+ ZSTD_sf_explicitBlockDelimiters = 1 /* Representation of ZSTD_Sequence contains explicit block delimiters */
+} ZSTD_sequenceFormat_e;
/*! ZSTD_generateSequences() :
* Generate sequences using ZSTD_compress2, given a source buffer.
@@ -1317,6 +1314,9 @@
*
* zc can be used to insert custom compression params.
* 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
*/
@@ -1329,6 +1329,9 @@
*
* As such, the final generated result has no explicit representation of block boundaries,
* and the final last literals segment is not represented in the sequences.
+ *
+ * The output of this function can be fed into ZSTD_compressSequences() with ZSTD_c_blockDelimiters
+ * set to ZSTD_sf_noBlockDelimiters
* @return : number of sequences left after merging
*/
ZSTDLIB_API size_t ZSTD_mergeBlockDelimiters(ZSTD_Sequence* sequences, size_t seqsSize);
@@ -1748,6 +1751,15 @@
*/
#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() :
* Get the requested compression parameter value, selected by enum ZSTD_cParameter,
* and store it into int* value.