linked newAPI to ZSTDMT
diff --git a/doc/zstd_manual.html b/doc/zstd_manual.html
index 9e56513..523c49b 100644
--- a/doc/zstd_manual.html
+++ b/doc/zstd_manual.html
@@ -707,7 +707,7 @@
</b><p> Same as ZSTD_compress_generic(),
but using only simple integral types as arguments.
Argument list is less expressive than ZSTD_{in,out}Buffer,
- but can be helpful for binders towards dynamic languages
+ but can be helpful for binders to dynamic languages
which have troubles handling structures containing memory pointers.
</p></pre><BR>
diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c
index 083f891..48eb24d 100644
--- a/lib/compress/zstd_compress.c
+++ b/lib/compress/zstd_compress.c
@@ -3734,6 +3734,16 @@
return ZSTD_compressStream_generic(zcs, output, input, ZSTD_e_continue);
}
+/*! ZSTDMT_initCStream_internal() :
+ * Private use only. Init streaming operation.
+ * expects params to be valid.
+ * must receive dict, or cdict, or none, but not both.
+ * @return : 0, or an error code */
+size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs,
+ const void* dict, size_t dictSize, const ZSTD_CDict* cdict,
+ ZSTD_parameters params, unsigned long long pledgedSrcSize);
+
+
size_t ZSTD_compress_generic (ZSTD_CCtx* cctx,
ZSTD_outBuffer* output,
ZSTD_inBuffer* input,
@@ -3750,12 +3760,19 @@
if (cctx->compressionLevel != ZSTD_CLEVEL_CUSTOM)
params.cParams = ZSTD_getCParams(cctx->compressionLevel,
cctx->frameContentSize, 0 /* dictSize */);
- CHECK_F( ZSTD_resetCStream_internal(cctx, params, cctx->frameContentSize) );
+ if (cctx->nbThreads > 1) {
+ CHECK_F( ZSTDMT_initCStream_internal(cctx->mtctx, NULL, 0, cctx->cdict, params, cctx->frameContentSize) );
+ } else {
+ CHECK_F( ZSTD_resetCStream_internal(cctx, params, cctx->frameContentSize) );
+ } }
+
+ if (cctx->nbThreads > 1) {
+ DEBUGLOG(5, "starting ZSTDMT_compressStream_generic");
+ return ZSTDMT_compressStream_generic(cctx->mtctx, output, input, endOp) ;
}
DEBUGLOG(5, "starting ZSTD_compressStream_generic");
CHECK_F( ZSTD_compressStream_generic(cctx, output, input, endOp) );
-
DEBUGLOG(5, "completing ZSTD_compress_generic");
return cctx->outBuffContentSize - cctx->outBuffFlushedSize; /* remaining to flush */
}
@@ -3773,7 +3790,6 @@
*dstPos = output.pos;
*srcPos = input.pos;
return cErr;
-
}
diff --git a/lib/compress/zstdmt_compress.c b/lib/compress/zstdmt_compress.c
index c71dcd6..09ac512 100644
--- a/lib/compress/zstdmt_compress.c
+++ b/lib/compress/zstdmt_compress.c
@@ -559,9 +559,9 @@
}
-static size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs,
- const void* dict, size_t dictSize, const ZSTD_CDict* cdict,
- ZSTD_parameters params, unsigned long long pledgedSrcSize)
+size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs,
+ const void* dict, size_t dictSize, const ZSTD_CDict* cdict,
+ ZSTD_parameters params, unsigned long long pledgedSrcSize)
{
/* params are supposed to be fully validated at this point */
assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
@@ -849,3 +849,22 @@
return ZSTD_endStream(zcs->cctxPool->cctx[0], output);
return ZSTDMT_flushStream_internal(zcs, output, 1);
}
+
+size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
+ ZSTD_outBuffer* output,
+ ZSTD_inBuffer* input,
+ ZSTD_EndDirective endOp)
+{
+ CHECK_F (ZSTDMT_compressStream(mtctx, output, input));
+ switch(endOp)
+ {
+ case ZSTD_e_flush:
+ return ZSTDMT_flushStream(mtctx, output);
+ case ZSTD_e_end:
+ return ZSTDMT_endStream(mtctx, output);
+ case ZSTD_e_continue:
+ return 1;
+ default:
+ return ERROR(GENERIC);
+ }
+}
diff --git a/lib/compress/zstdmt_compress.h b/lib/compress/zstdmt_compress.h
index 267ed3e..8b0ca82 100644
--- a/lib/compress/zstdmt_compress.h
+++ b/lib/compress/zstdmt_compress.h
@@ -85,6 +85,19 @@
ZSTDLIB_API size_t ZSTDMT_setMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSDTMT_parameter parameter, unsigned value);
+/*! ZSTDMT_compressStream_generic() :
+ * Combines ZSTDMT_compressStream() with ZSTDMT_flushStream() or ZSTDMT_endStream()
+ * depending on flush directive
+ * @return : minimum amount of data still to be flushed
+ * 0 if fully flushed
+ * or an error code */
+ZSTDLIB_API size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
+ ZSTD_outBuffer* output,
+ ZSTD_inBuffer* input,
+ ZSTD_EndDirective endOp);
+
+
+
#if defined (__cplusplus)
}
#endif
diff --git a/lib/zstd.h b/lib/zstd.h
index b7fbbea..357af91 100644
--- a/lib/zstd.h
+++ b/lib/zstd.h
@@ -828,7 +828,7 @@
* Same as ZSTD_compress_generic(),
* but using only simple integral types as arguments.
* Argument list is less expressive than ZSTD_{in,out}Buffer,
- * but can be helpful for binders towards dynamic languages
+ * but can be helpful for binders to dynamic languages
* which have troubles handling structures containing memory pointers.
*/
size_t ZSTD_compress_generic_simpleArgs (