Skip to content

Commit

Permalink
minor code doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyan4973 committed Jan 8, 2025
1 parent daf8e8f commit 60ae6de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions lib/compress/zstd_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -7196,8 +7196,8 @@ size_t convertSequences_noRepcodes(
__m256i vadd = _mm256_add_epi32(vin, addition);

/* Check for long length */
__m256i cmp = _mm256_cmpgt_epi32(vadd, limit); // 0xFFFFFFFF for element > 65535
int cmp_res = _mm256_movemask_epi8(cmp);
__m256i ll_cmp = _mm256_cmpgt_epi32(vadd, limit); /* 0xFFFFFFFF for element > 65535 */
int ll_res = _mm256_movemask_epi8(ll_cmp);

/* Shuffle bytes so each half gives us the 8 bytes we need */
__m256i vshf = _mm256_shuffle_epi8(vadd, mask);
Expand Down Expand Up @@ -7228,7 +7228,7 @@ size_t convertSequences_noRepcodes(
* indices for lengths correspond to bits [4..7], [8..11], [20..23], [24..27]
* => combined mask = 0x0FF00FF0
*/
if (UNLIKELY((cmp_res & 0x0FF00FF0) != 0)) {
if (UNLIKELY((ll_res & 0x0FF00FF0) != 0)) {
/* long length detected: let's figure out which one*/
if (inSeqs[i].matchLength > 65535+MINMATCH) {
assert(longLen == 0);
Expand All @@ -7251,12 +7251,12 @@ size_t convertSequences_noRepcodes(

/* Handle leftover if @nbSequences is odd */
if (i < nbSequences) {
/* Fallback: process last sequence */
/* process last sequence */
assert(i == nbSequences - 1);
dstSeqs[i].offBase = OFFSET_TO_OFFBASE(inSeqs[i].offset);
/* note: doesn't work if one length is > 65535 */
dstSeqs[i].litLength = (U16)inSeqs[i].litLength;
dstSeqs[i].mlBase = (U16)(inSeqs[i].matchLength - MINMATCH);
/* check (unlikely) long lengths > 65535 */
if (UNLIKELY(inSeqs[i].matchLength > 65535+MINMATCH)) {
assert(longLen == 0);
longLen = i + 1;
Expand Down
5 changes: 3 additions & 2 deletions lib/zstd.h
Original file line number Diff line number Diff line change
Expand Up @@ -1696,15 +1696,16 @@ ZSTD_compressSequences(ZSTD_CCtx* cctx,
* - Not compatible with frame checksum, which must be disabled
* - If any block is incompressible, will fail and return an error
* - @litSize must be == sum of all @.litLength fields in @inSeqs. Any discrepancy will generate an error.
* - the buffer @literals must have a size @litCapacity which is larger than @litSize by at least 8 bytes.
* - @litBufCapacity is the size of the underlying buffer into which literals are written, starting at address @literals.
* @litBufCapacity must be at least 8 bytes larger than @litSize.
* - @decompressedSize must be correct, and correspond to the sum of all Sequences. Any discrepancy will generate an error.
* @return : final compressed size, or a ZSTD error code.
*/
ZSTDLIB_STATIC_API size_t
ZSTD_compressSequencesAndLiterals(ZSTD_CCtx* cctx,
void* dst, size_t dstCapacity,
const ZSTD_Sequence* inSeqs, size_t nbSequences,
const void* literals, size_t litSize, size_t litCapacity,
const void* literals, size_t litSize, size_t litBufCapacity,
size_t decompressedSize);


Expand Down

0 comments on commit 60ae6de

Please sign in to comment.