Lines Matching defs:cctxPtr
357 LZ4F_cctx_t* cctxPtr;
359 cctxPtr = (LZ4F_cctx_t*)ALLOCATOR(sizeof(LZ4F_cctx_t));
360 if (cctxPtr==NULL) return (LZ4F_errorCode_t)(-LZ4F_ERROR_allocation_failed);
362 cctxPtr->version = version;
363 cctxPtr->cStage = 0; /* Next stage : write header */
365 *LZ4F_compressionContextPtr = (LZ4F_compressionContext_t)cctxPtr;
373 LZ4F_cctx_t* cctxPtr = (LZ4F_cctx_t*)LZ4F_compressionContext;
375 if (cctxPtr != NULL) /* null pointers can be safely provided to this function, like free() */
377 FREEMEM(cctxPtr->lz4CtxPtr);
378 FREEMEM(cctxPtr->tmpBuff);
395 LZ4F_cctx_t* cctxPtr = (LZ4F_cctx_t*)compressionContext;
402 if (cctxPtr->cStage != 0) return (size_t)-LZ4F_ERROR_GENERIC;
405 cctxPtr->prefs = *preferencesPtr;
409 U32 tableID = (cctxPtr->prefs.compressionLevel < minHClevel) ? 1 : 2; /* 0:nothing ; 1:LZ4 table ; 2:HC tables */
410 if (cctxPtr->lz4CtxLevel < tableID)
412 FREEMEM(cctxPtr->lz4CtxPtr);
413 if (cctxPtr->prefs.compressionLevel < minHClevel)
414 cctxPtr->lz4CtxPtr = (void*)LZ4_createStream();
416 cctxPtr->lz4CtxPtr = (void*)LZ4_createStreamHC();
417 cctxPtr->lz4CtxLevel = tableID;
422 if (cctxPtr->prefs.frameInfo.blockSizeID == 0) cctxPtr->prefs.frameInfo.blockSizeID = LZ4F_BLOCKSIZEID_DEFAULT;
423 cctxPtr->maxBlockSize = LZ4F_getBlockSize(cctxPtr->prefs.frameInfo.blockSizeID);
425 requiredBuffSize = cctxPtr->maxBlockSize + ((cctxPtr->prefs.frameInfo.blockMode == LZ4F_blockLinked) * 128 KB);
427 requiredBuffSize = (cctxPtr->prefs.frameInfo.blockMode == LZ4F_blockLinked) * 64 KB; /* just needs dict */
429 if (cctxPtr->maxBufferSize < requiredBuffSize)
431 cctxPtr->maxBufferSize = requiredBuffSize;
432 FREEMEM(cctxPtr->tmpBuff);
433 cctxPtr->tmpBuff = (BYTE*)ALLOCATOR(requiredBuffSize);
434 if (cctxPtr->tmpBuff == NULL) return (size_t)-LZ4F_ERROR_allocation_failed;
436 cctxPtr->tmpIn = cctxPtr->tmpBuff;
437 cctxPtr->tmpInSize = 0;
438 XXH32_reset(&(cctxPtr->xxh), 0);
439 if (cctxPtr->prefs.compressionLevel < minHClevel)
440 LZ4_resetStream((LZ4_stream_t*)(cctxPtr->lz4CtxPtr));
442 LZ4_resetStreamHC((LZ4_streamHC_t*)(cctxPtr->lz4CtxPtr), cctxPtr->prefs.compressionLevel);
451 + ((cctxPtr->prefs.frameInfo.blockMode & _1BIT ) << 5) /* Block mode */
452 + ((cctxPtr->prefs.frameInfo.contentChecksumFlag & _1BIT ) << 2) /* Frame checksum */
453 + ((cctxPtr->prefs.frameInfo.contentSize > 0) << 3)); /* Frame content size */
455 *dstPtr++ = (BYTE)((cctxPtr->prefs.frameInfo.blockSizeID & _3BITS) << 4);
457 if (cctxPtr->prefs.frameInfo.contentSize)
459 LZ4F_writeLE64(dstPtr, cctxPtr->prefs.frameInfo.contentSize);
461 cctxPtr->totalInSize = 0;
467 cctxPtr->cStage = 1; /* header written, now request input data block */
544 static int LZ4F_localSaveDict(LZ4F_cctx_t* cctxPtr)
546 if (cctxPtr->prefs.compressionLevel < minHClevel)
547 return LZ4_saveDict ((LZ4_stream_t*)(cctxPtr->lz4CtxPtr), (char*)(cctxPtr->tmpBuff), 64 KB);
548 return LZ4_saveDictHC ((LZ4_streamHC_t*)(cctxPtr->lz4CtxPtr), (char*)(cctxPtr->tmpBuff), 64 KB);
565 LZ4F_cctx_t* cctxPtr = (LZ4F_cctx_t*)compressionContext;
566 size_t blockSize = cctxPtr->maxBlockSize;
575 if (cctxPtr->cStage != 1) return (size_t)-LZ4F_ERROR_GENERIC;
576 if (dstMaxSize < LZ4F_compressBound(srcSize, &(cctxPtr->prefs))) return (size_t)-LZ4F_ERROR_dstMaxSize_tooSmall;
581 compress = LZ4F_selectCompression(cctxPtr->prefs.frameInfo.blockMode, cctxPtr->prefs.compressionLevel);
584 if (cctxPtr->tmpInSize > 0) /* some data already within tmp buffer */
586 size_t sizeToCopy = blockSize - cctxPtr->tmpInSize;
590 memcpy(cctxPtr->tmpIn + cctxPtr->tmpInSize, srcBuffer, srcSize);
592 cctxPtr->tmpInSize += srcSize;
599 memcpy(cctxPtr->tmpIn + cctxPtr->tmpInSize, srcBuffer, sizeToCopy);
602 dstPtr += LZ4F_compressBlock(dstPtr, cctxPtr->tmpIn, blockSize, compress, cctxPtr->lz4CtxPtr, cctxPtr->prefs.compressionLevel);
604 if (cctxPtr->prefs.frameInfo.blockMode==LZ4F_blockLinked) cctxPtr->tmpIn += blockSize;
605 cctxPtr->tmpInSize = 0;
613 dstPtr += LZ4F_compressBlock(dstPtr, srcPtr, blockSize, compress, cctxPtr->lz4CtxPtr, cctxPtr->prefs.compressionLevel);
617 if ((cctxPtr->prefs.autoFlush) && (srcPtr < srcEnd))
621 dstPtr += LZ4F_compressBlock(dstPtr, srcPtr, srcEnd - srcPtr, compress, cctxPtr->lz4CtxPtr, cctxPtr->prefs.compressionLevel);
626 if ((cctxPtr->prefs.frameInfo.blockMode==LZ4F_blockLinked) && (lastBlockCompressed==fromSrcBuffer))
630 cctxPtr->tmpIn = cctxPtr->tmpBuff;
634 int realDictSize = LZ4F_localSaveDict(cctxPtr);
636 cctxPtr->tmpIn = cctxPtr->tmpBuff + realDictSize;
641 if ((cctxPtr->tmpIn + blockSize) > (cctxPtr->tmpBuff + cctxPtr->maxBufferSize) /* necessarily LZ4F_blockLinked && lastBlockCompressed==fromTmpBuffer */
642 && !(cctxPtr->prefs.autoFlush))
644 int realDictSize = LZ4F_localSaveDict(cctxPtr);
645 cctxPtr->tmpIn = cctxPtr->tmpBuff + realDictSize;
653 memcpy(cctxPtr->tmpIn, srcPtr, sizeToCopy);
654 cctxPtr->tmpInSize = sizeToCopy;
657 if (cctxPtr->prefs.frameInfo.contentChecksumFlag == LZ4F_contentChecksumEnabled)
658 XXH32_update(&(cctxPtr->xxh), srcBuffer, srcSize);
660 cctxPtr->totalInSize += srcSize;
675 LZ4F_cctx_t* cctxPtr = (LZ4F_cctx_t*)compressionContext;
681 if (cctxPtr->tmpInSize == 0) return 0; /* nothing to flush */
682 if (cctxPtr->cStage != 1) return (size_t)-LZ4F_ERROR_GENERIC;
683 if (dstMaxSize < (cctxPtr->tmpInSize + 8)) return (size_t)-LZ4F_ERROR_dstMaxSize_tooSmall; /* +8 : block header(4) + block checksum(4) */
687 compress = LZ4F_selectCompression(cctxPtr->prefs.frameInfo.blockMode, cctxPtr->prefs.compressionLevel);
690 dstPtr += LZ4F_compressBlock(dstPtr, cctxPtr->tmpIn, cctxPtr->tmpInSize, compress, cctxPtr->lz4CtxPtr, cctxPtr->prefs.compressionLevel);
691 if (cctxPtr->prefs.frameInfo.blockMode==LZ4F_blockLinked) cctxPtr->tmpIn += cctxPtr->tmpInSize;
692 cctxPtr->tmpInSize = 0;
695 if ((cctxPtr->tmpIn + cctxPtr->maxBlockSize) > (cctxPtr->tmpBuff + cctxPtr->maxBufferSize)) /* necessarily LZ4F_blockLinked */
697 int realDictSize = LZ4F_localSaveDict(cctxPtr);
698 cctxPtr->tmpIn = cctxPtr->tmpBuff + realDictSize;
716 LZ4F_cctx_t* cctxPtr = (LZ4F_cctx_t*)compressionContext;
728 if (cctxPtr->prefs.frameInfo.contentChecksumFlag == LZ4F_contentChecksumEnabled)
730 U32 xxh = XXH32_digest(&(cctxPtr->xxh));
735 cctxPtr->cStage = 0; /* state is now re-usable (with identical preferences) */
737 if (cctxPtr->prefs.frameInfo.contentSize)
739 if (cctxPtr->prefs.frameInfo.contentSize != cctxPtr->totalInSize)