Lines Matching +full:sub +full:- +full:block
5 * This source code is licensed under both the BSD-style license (found in the
8 * You may select, at your option, one of the above-listed licenses.
11 /*-*************************************
23 * Compresses literals section for a sub-block.
32 * hufMetadata->hType has literals block type info.
33 * If it is set_basic, all sub-blocks literals section will be Raw_Literals_Block.
34 * If it is set_rle, all sub-blocks literals section will be RLE_Literals_Block.
35 …* If it is set_compressed, first sub-block's literals section will be Compressed_Literals_Blo…
36 * If it is set_compressed, first sub-block's literals section will be Treeless_Literals_Block
37 * and the following sub-blocks' literals sections will be Treeless_Literals_Block.
38 * @return : compressed size of literals section of a sub-block
48 size_t const lhSize = 3 + (litSize >= (1 KB - header)) + (litSize >= (16 KB - header)); in ZSTD_compressSubBlock_literal()
53 symbolEncodingType_e hType = writeEntropy ? hufMetadata->hType : set_repeat; in ZSTD_compressSubBlock_literal()
61 if (litSize == 0 || hufMetadata->hType == set_basic) { in ZSTD_compressSubBlock_literal()
64 } else if (hufMetadata->hType == set_rle) { in ZSTD_compressSubBlock_literal()
70 assert(hufMetadata->hType == set_compressed || hufMetadata->hType == set_repeat); in ZSTD_compressSubBlock_literal()
72 if (writeEntropy && hufMetadata->hType == set_compressed) { in ZSTD_compressSubBlock_literal()
73 ZSTD_memcpy(op, hufMetadata->hufDesBuffer, hufMetadata->hufDesSize); in ZSTD_compressSubBlock_literal()
74 op += hufMetadata->hufDesSize; in ZSTD_compressSubBlock_literal()
75 cLitSize += hufMetadata->hufDesSize; in ZSTD_compressSubBlock_literal()
76 DEBUGLOG(5, "ZSTD_compressSubBlock_literal (hSize=%zu)", hufMetadata->hufDesSize); in ZSTD_compressSubBlock_literal()
80 …{ const size_t cSize = singleStream ? HUF_compress1X_usingCTable(op, oend-op, literals, litSize,… in ZSTD_compressSubBlock_literal()
81 … : HUF_compress4X_usingCTable(op, oend-op, literals, litSize, hufTable); in ZSTD_compressSubBlock_literal()
105 case 3: /* 2 - 2 - 10 - 10 */ in ZSTD_compressSubBlock_literal()
110 case 4: /* 2 - 2 - 14 - 14 */ in ZSTD_compressSubBlock_literal()
115 case 5: /* 2 - 2 - 18 - 18 */ in ZSTD_compressSubBlock_literal()
125 DEBUGLOG(5, "Compressed literals: %u -> %u", (U32)litSize, (U32)(op-ostart)); in ZSTD_compressSubBlock_literal()
126 return op-ostart; in ZSTD_compressSubBlock_literal()
136 while (send-sp > 0) { in ZSTD_seqDecompressedSize()
150 * Compresses sequences section for a sub-block.
151 * fseMetadata->llType, fseMetadata->ofType, and fseMetadata->mlType have
152 * symbol compression modes for the super-block.
153 * The first successfully compressed block will have these in its header.
155 * The following sub-blocks will always have repeat mode.
156 * @return : compressed size of sequences section of a sub-block
167 const int longOffsets = cctxParams->cParams.windowLog > STREAM_ACCUMULATOR_MIN; in ZSTD_compressSubBlock_sequences()
177 RETURN_ERROR_IF((oend-op) < 3 /*max nbSeq Size*/ + 1 /*seqHead*/, in ZSTD_compressSubBlock_sequences()
184 op[0]=0xFF, MEM_writeLE16(op+1, (U16)(nbSeq - LONGNBSEQ)), op+=3; in ZSTD_compressSubBlock_sequences()
186 return op - ostart; in ZSTD_compressSubBlock_sequences()
192 DEBUGLOG(5, "ZSTD_compressSubBlock_sequences (seqHeadSize=%u)", (unsigned)(op-ostart)); in ZSTD_compressSubBlock_sequences()
195 const U32 LLtype = fseMetadata->llType; in ZSTD_compressSubBlock_sequences()
196 const U32 Offtype = fseMetadata->ofType; in ZSTD_compressSubBlock_sequences()
197 const U32 MLtype = fseMetadata->mlType; in ZSTD_compressSubBlock_sequences()
198 … DEBUGLOG(5, "ZSTD_compressSubBlock_sequences (fseTablesSize=%zu)", fseMetadata->fseTablesSize); in ZSTD_compressSubBlock_sequences()
200 ZSTD_memcpy(op, fseMetadata->fseTablesBuffer, fseMetadata->fseTablesSize); in ZSTD_compressSubBlock_sequences()
201 op += fseMetadata->fseTablesSize; in ZSTD_compressSubBlock_sequences()
208 op, oend - op, in ZSTD_compressSubBlock_sequences()
209 fseTables->matchlengthCTable, mlCode, in ZSTD_compressSubBlock_sequences()
210 fseTables->offcodeCTable, ofCode, in ZSTD_compressSubBlock_sequences()
211 fseTables->litlengthCTable, llCode, in ZSTD_compressSubBlock_sequences()
222 * block, since it isn't worth optimizing. in ZSTD_compressSubBlock_sequences()
225 …if (writeEntropy && fseMetadata->lastCountSize && fseMetadata->lastCountSize + bitstreamSize < 4) { in ZSTD_compressSubBlock_sequences()
227 assert(fseMetadata->lastCountSize + bitstreamSize == 3); in ZSTD_compressSubBlock_sequences()
229 "emitting an uncompressed block."); in ZSTD_compressSubBlock_sequences()
239 * This can happen when the previous sequences section block is compressed in ZSTD_compressSubBlock_sequences()
240 * with rle mode and the current block's sequences section is compressed in ZSTD_compressSubBlock_sequences()
244 if (op-seqHead < 4) { in ZSTD_compressSubBlock_sequences()
246 "an uncompressed block when sequences are < 4 bytes"); in ZSTD_compressSubBlock_sequences()
252 return op - ostart; in ZSTD_compressSubBlock_sequences()
256 * Compresses a single sub-block.
257 * @return : compressed size of the sub-block
276 { size_t cLitSize = ZSTD_compressSubBlock_literal((const HUF_CElt*)entropy->huf.CTable, in ZSTD_compressSubBlock()
277 … &entropyMetadata->hufMetadata, literals, litSize, in ZSTD_compressSubBlock()
278 … op, oend-op, bmi2, writeLitEntropy, litEntropyWritten); in ZSTD_compressSubBlock()
283 { size_t cSeqSize = ZSTD_compressSubBlock_sequences(&entropy->fse, in ZSTD_compressSubBlock()
284 &entropyMetadata->fseMetadata, in ZSTD_compressSubBlock()
288 op, oend-op, in ZSTD_compressSubBlock()
294 /* Write block header */ in ZSTD_compressSubBlock()
295 { size_t cSize = (op-ostart)-ZSTD_blockHeaderSize; in ZSTD_compressSubBlock()
299 return op-ostart; in ZSTD_compressSubBlock()
312 if (hufMetadata->hType == set_basic) return litSize; in ZSTD_estimateSubBlockSize_literal()
313 else if (hufMetadata->hType == set_rle) return 1; in ZSTD_estimateSubBlockSize_literal()
314 else if (hufMetadata->hType == set_compressed || hufMetadata->hType == set_repeat) { in ZSTD_estimateSubBlockSize_literal()
317 …{ size_t cLitSizeEstimate = HUF_estimateCompressedSize((const HUF_CElt*)huf->CTable, countWksp, … in ZSTD_estimateSubBlockSize_literal()
318 if (writeEntropy) cLitSizeEstimate += hufMetadata->hufDesSize; in ZSTD_estimateSubBlockSize_literal()
372 … cSeqSizeEstimate += ZSTD_estimateSubBlockSize_symbolType(fseMetadata->ofType, ofCodeTable, MaxOff, in ZSTD_estimateSubBlockSize_sequences()
373 nbSeq, fseTables->offcodeCTable, NULL, in ZSTD_estimateSubBlockSize_sequences()
376 … cSeqSizeEstimate += ZSTD_estimateSubBlockSize_symbolType(fseMetadata->llType, llCodeTable, MaxLL, in ZSTD_estimateSubBlockSize_sequences()
377 nbSeq, fseTables->litlengthCTable, LL_bits, in ZSTD_estimateSubBlockSize_sequences()
380 … cSeqSizeEstimate += ZSTD_estimateSubBlockSize_symbolType(fseMetadata->mlType, mlCodeTable, MaxML, in ZSTD_estimateSubBlockSize_sequences()
381 nbSeq, fseTables->matchlengthCTable, ML_bits, in ZSTD_estimateSubBlockSize_sequences()
384 if (writeEntropy) cSeqSizeEstimate += fseMetadata->fseTablesSize; in ZSTD_estimateSubBlockSize_sequences()
399 … &entropy->huf, &entropyMetadata->hufMetadata, in ZSTD_estimateSubBlockSize()
402 … nbSeq, &entropy->fse, &entropyMetadata->fseMetadata, in ZSTD_estimateSubBlockSize()
409 if (fseMetadata->llType == set_compressed || fseMetadata->llType == set_rle) in ZSTD_needSequenceEntropyTables()
411 if (fseMetadata->mlType == set_compressed || fseMetadata->mlType == set_rle) in ZSTD_needSequenceEntropyTables()
413 if (fseMetadata->ofType == set_compressed || fseMetadata->ofType == set_rle) in ZSTD_needSequenceEntropyTables()
419 * Breaks super-block into multiple sub-blocks and compresses them.
420 * Entropy will be written to the first block.
422 * All sub-blocks are compressed blocks (no raw or rle blocks).
423 * @return : compressed size of the super block (which is multiple ZSTD blocks)
435 const seqDef* const sstart = seqStorePtr->sequencesStart; in ZSTD_compressSubBlock_multi()
436 const seqDef* const send = seqStorePtr->sequences; in ZSTD_compressSubBlock_multi()
438 const BYTE* const lstart = seqStorePtr->litStart; in ZSTD_compressSubBlock_multi()
439 const BYTE* const lend = seqStorePtr->lit; in ZSTD_compressSubBlock_multi()
446 const BYTE* llCodePtr = seqStorePtr->llCode; in ZSTD_compressSubBlock_multi()
447 const BYTE* mlCodePtr = seqStorePtr->mlCode; in ZSTD_compressSubBlock_multi()
448 const BYTE* ofCodePtr = seqStorePtr->ofCode; in ZSTD_compressSubBlock_multi()
449 size_t targetCBlockSize = cctxParams->targetCBlockSize; in ZSTD_compressSubBlock_multi()
451 int writeLitEntropy = entropyMetadata->hufMetadata.hType == set_compressed; in ZSTD_compressSubBlock_multi()
456 (unsigned)(lend-lp), (unsigned)(send-sstart)); in ZSTD_compressSubBlock_multi()
466 lastSequence = sequence == send - 1; in ZSTD_compressSubBlock_multi()
472 assert(litSize <= (size_t)(lend - lp)); in ZSTD_compressSubBlock_multi()
473 litSize = (size_t)(lend - lp); in ZSTD_compressSubBlock_multi()
481 &nextCBlock->entropy, entropyMetadata, in ZSTD_compressSubBlock_multi()
487 const size_t cSize = ZSTD_compressSubBlock(&nextCBlock->entropy, entropyMetadata, in ZSTD_compressSubBlock_multi()
492 op, oend-op, in ZSTD_compressSubBlock_multi()
498 DEBUGLOG(5, "Committed the sub-block"); in ZSTD_compressSubBlock_multi()
521 … ZSTD_memcpy(&nextCBlock->entropy.huf, &prevCBlock->entropy.huf, sizeof(prevCBlock->entropy.huf)); in ZSTD_compressSubBlock_multi()
523 if (writeSeqEntropy && ZSTD_needSequenceEntropyTables(&entropyMetadata->fseMetadata)) { in ZSTD_compressSubBlock_multi()
525 * must emit an uncompressed block. in ZSTD_compressSubBlock_multi()
531 size_t const cSize = ZSTD_noCompressBlock(op, oend - op, ip, iend - ip, lastBlock); in ZSTD_compressSubBlock_multi()
532 …DEBUGLOG(5, "ZSTD_compressSubBlock_multi last sub-block uncompressed, %zu bytes", (size_t)(iend - … in ZSTD_compressSubBlock_multi()
540 ZSTD_memcpy(&rep, prevCBlock->rep, sizeof(rep)); in ZSTD_compressSubBlock_multi()
542 …ZSTD_updateRep(rep.rep, seq->offBase - 1, ZSTD_getSequenceLength(seqStorePtr, seq).litLength == 0); in ZSTD_compressSubBlock_multi()
544 ZSTD_memcpy(nextCBlock->rep, &rep, sizeof(rep)); in ZSTD_compressSubBlock_multi()
548 return op-ostart; in ZSTD_compressSubBlock_multi()
557 FORWARD_IF_ERROR(ZSTD_buildBlockEntropyStats(&zc->seqStore, in ZSTD_compressSuperBlock()
558 &zc->blockState.prevCBlock->entropy, in ZSTD_compressSuperBlock()
559 &zc->blockState.nextCBlock->entropy, in ZSTD_compressSuperBlock()
560 &zc->appliedParams, in ZSTD_compressSuperBlock()
562 … zc->entropyWorkspace, ENTROPY_WORKSPACE_SIZE /* statically allocated in resetCCtx */), ""); in ZSTD_compressSuperBlock()
564 return ZSTD_compressSubBlock_multi(&zc->seqStore, in ZSTD_compressSuperBlock()
565 zc->blockState.prevCBlock, in ZSTD_compressSuperBlock()
566 zc->blockState.nextCBlock, in ZSTD_compressSuperBlock()
568 &zc->appliedParams, in ZSTD_compressSuperBlock()
571 zc->bmi2, lastBlock, in ZSTD_compressSuperBlock()
572 zc->entropyWorkspace, ENTROPY_WORKSPACE_SIZE /* statically allocated in resetCCtx */); in ZSTD_compressSuperBlock()