]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
zstdmt : correctly set end of frame
authorYann Collet <cyan@fb.com>
Tue, 23 Jan 2018 23:52:40 +0000 (15:52 -0800)
committerYann Collet <cyan@fb.com>
Tue, 23 Jan 2018 23:52:40 +0000 (15:52 -0800)
lib/compress/zstdmt_compress.c
lib/zstd.h

index 448a3e73f7e5ca7f3d2c5176a317273f26fec8dc..0207920dceb8c99d31939844a8595f8e8fe1ccd3 100644 (file)
@@ -1001,9 +1001,10 @@ size_t ZSTDMT_initCStream(ZSTDMT_CCtx* zcs, int compressionLevel) {
 }
 
 
-static size_t ZSTDMT_createCompressionJob(ZSTDMT_CCtx* zcs, size_t srcSize, unsigned endFrame)
+static size_t ZSTDMT_createCompressionJob(ZSTDMT_CCtx* zcs, size_t srcSize, ZSTD_EndDirective endOp)
 {
     unsigned const jobID = zcs->nextJobID & zcs->jobIDMask;
+    int const endFrame = (endOp == ZSTD_e_end);
 
     if (zcs->nextJobID > zcs->doneJobID + zcs->jobIDMask) {
         DEBUGLOG(5, "ZSTDMT_createCompressionJob: will not create new job : table is full");
@@ -1060,7 +1061,7 @@ static size_t ZSTDMT_createCompressionJob(ZSTDMT_CCtx* zcs, size_t srcSize, unsi
             zcs->inBuff.buffer = g_nullBuffer;
             zcs->inBuff.filled = 0;
             zcs->prefixSize = 0;
-            zcs->frameEnded = 1;
+            zcs->frameEnded = endFrame;
             if (zcs->nextJobID == 0) {
                 /* single chunk exception : checksum is calculated directly within worker thread */
                 zcs->params.fParams.checksumFlag = 0;
@@ -1228,7 +1229,7 @@ size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
       || ((endOp != ZSTD_e_continue) && (mtctx->inBuff.filled > 0))  /* something to flush : let's go */
       || ((endOp == ZSTD_e_end) && (!mtctx->frameEnded)) ) {   /* must finish the frame with a zero-size block */
         size_t const jobSize = MIN(mtctx->inBuff.filled - mtctx->prefixSize, mtctx->targetSectionSize);
-        CHECK_F( ZSTDMT_createCompressionJob(mtctx, jobSize, endOp==ZSTD_e_end) );
+        CHECK_F( ZSTDMT_createCompressionJob(mtctx, jobSize, endOp) );
     }
 
     /* check for potential compressed data ready to be flushed */
index da9d295cd5343b6f213cb125b9874b144f247fff..e573daf5b3183aece6177007aee5d3693fd3e437 100644 (file)
@@ -1120,7 +1120,7 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* pre
 
 
 typedef enum {
-    ZSTD_e_continue=0, /* collect more data, encoder transparently decides when to output result, for optimal conditions */
+    ZSTD_e_continue=0, /* collect more data, encoder decides when to output compressed result, for optimal conditions */
     ZSTD_e_flush,      /* flush any data provided so far - frame will continue, future data can still reference previous data for better compression */
     ZSTD_e_end         /* flush any remaining data and close current frame. Any additional data starts a new frame. */
 } ZSTD_EndDirective;