Modify ZSTD_copyBlockSequences to agree with new API
This commit is contained in:
parent
761f40d1c6
commit
3a11c7eb03
@ -2442,17 +2442,19 @@ static size_t ZSTD_buildSeqStore(ZSTD_CCtx* zc, const void* src, size_t srcSize)
|
||||
static void ZSTD_copyBlockSequences(ZSTD_CCtx* zc)
|
||||
{
|
||||
const seqStore_t* seqStore = ZSTD_getSeqStore(zc);
|
||||
const seqDef* seqs = seqStore->sequencesStart;
|
||||
size_t seqsSize = seqStore->sequences - seqs;
|
||||
const seqDef* seqStoreSeqs = seqStore->sequencesStart;
|
||||
size_t seqStoreSeqSize = seqStore->sequences - seqStoreSeqs;
|
||||
|
||||
ZSTD_Sequence* outSeqs = &zc->seqCollector.seqStart[zc->seqCollector.seqIndex];
|
||||
size_t i; size_t position; int repIdx;
|
||||
size_t i;
|
||||
size_t position;
|
||||
int repIdx;
|
||||
|
||||
assert(zc->seqCollector.seqIndex + 1 < zc->seqCollector.maxSequences);
|
||||
for (i = 0, position = 0; i < seqsSize; ++i) {
|
||||
outSeqs[i].offset = seqs[i].offset;
|
||||
outSeqs[i].litLength = seqs[i].litLength;
|
||||
outSeqs[i].matchLength = seqs[i].matchLength + MINMATCH;
|
||||
for (i = 0, position = 0; i < seqStoreSeqSize; ++i) {
|
||||
outSeqs[i].offset = seqStoreSeqs[i].offset - ZSTD_REP_NUM;
|
||||
outSeqs[i].litLength = seqStoreSeqs[i].litLength;
|
||||
outSeqs[i].matchLength = seqStoreSeqs[i].matchLength + MINMATCH;
|
||||
|
||||
if (i == seqStore->longLengthPos) {
|
||||
if (seqStore->longLengthID == 1) {
|
||||
@ -2462,32 +2464,36 @@ static void ZSTD_copyBlockSequences(ZSTD_CCtx* zc)
|
||||
}
|
||||
}
|
||||
|
||||
if (outSeqs[i].offset <= ZSTD_REP_NUM) {
|
||||
outSeqs[i].rep = outSeqs[i].offset;
|
||||
repIdx = (unsigned int)i - outSeqs[i].offset;
|
||||
/* Repcode handling:
|
||||
* If litLength != 0:
|
||||
* rep == 1 --> offset == repeat offset 1
|
||||
* rep == 2 --> offset == repeat offset 2
|
||||
* rep == 3 --> offset == repeat offset 3
|
||||
* If litLength == 0:
|
||||
* rep == 1 --> offset == repeat offset 2
|
||||
* rep == 2 --> offset == repeat offset 3
|
||||
* rep == 3 --> offset == repeat offset 1 - 1
|
||||
*/
|
||||
if (seqStoreSeqs[i].offset <= ZSTD_REP_NUM) {
|
||||
outSeqs[i].rep = seqStoreSeqs[i].offset;
|
||||
repIdx = (unsigned int)i - seqStoreSeqs[i].offset;
|
||||
|
||||
if (outSeqs[i].litLength == 0) {
|
||||
if (outSeqs[i].offset < 3) {
|
||||
if (seqStoreSeqs[i].litLength == 0) {
|
||||
if (seqStoreSeqs[i].offset < 3) {
|
||||
--repIdx;
|
||||
} else {
|
||||
repIdx = (unsigned int)i - 1;
|
||||
}
|
||||
++outSeqs[i].rep;
|
||||
}
|
||||
assert(repIdx >= -3);
|
||||
outSeqs[i].offset = repIdx >= 0 ? outSeqs[repIdx].offset : repStartValue[-repIdx - 1];
|
||||
if (outSeqs[i].rep == 4) {
|
||||
if (outSeqs[i].rep == 3 && outSeqs[i].litLength == 0) {
|
||||
--outSeqs[i].offset;
|
||||
}
|
||||
} else {
|
||||
outSeqs[i].offset -= ZSTD_REP_NUM;
|
||||
}
|
||||
|
||||
position += outSeqs[i].litLength;
|
||||
outSeqs[i].matchPos = (unsigned int)position;
|
||||
position += outSeqs[i].matchLength;
|
||||
position += outSeqs[i].litLength + outSeqs[i].matchLength;
|
||||
}
|
||||
zc->seqCollector.seqIndex += seqsSize;
|
||||
zc->seqCollector.seqIndex += seqStoreSeqSize;
|
||||
}
|
||||
|
||||
size_t ZSTD_getSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
|
||||
|
31
lib/zstd.h
31
lib/zstd.h
@ -1114,24 +1114,25 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
|
||||
typedef struct ZSTD_CCtx_params_s ZSTD_CCtx_params;
|
||||
|
||||
typedef struct {
|
||||
unsigned int offset; /* The offset of the match.
|
||||
* If == 0, then represents a block of literals, determined by litLength
|
||||
*/
|
||||
unsigned int offset; /* The offset of the match.
|
||||
* If == 0, then represents a block of literals, determined by litLength
|
||||
*/
|
||||
|
||||
unsigned int litLength; /* Literal length */
|
||||
unsigned int matchLength; /* Match length. */
|
||||
unsigned int rep; /* Represents which repeat offset is used. Ranges from [0, 3].
|
||||
* If rep == 0, then this sequence does not contain a repeat offset.
|
||||
* Otherwise:
|
||||
* If litLength != 0:
|
||||
* rep == 1 --> offset == repeat offset 1
|
||||
* rep == 2 --> offset == repeat offset 2
|
||||
* rep == 3 --> offset == repeat offset 3
|
||||
* If litLength == 0:
|
||||
* rep == 1 --> offset == repeat offset 2
|
||||
* rep == 2 --> offset == repeat offset 3
|
||||
* rep == 3 --> offset == repeat offset 1 - 1
|
||||
*/
|
||||
|
||||
unsigned int rep; /* Represents which repeat offset is used. Ranges from [0, 3].
|
||||
* If rep == 0, then this sequence does not contain a repeat offset.
|
||||
* Otherwise:
|
||||
* If litLength != 0:
|
||||
* rep == 1 --> offset == repeat offset 1
|
||||
* rep == 2 --> offset == repeat offset 2
|
||||
* rep == 3 --> offset == repeat offset 3
|
||||
* If litLength == 0:
|
||||
* rep == 1 --> offset == repeat offset 2
|
||||
* rep == 2 --> offset == repeat offset 3
|
||||
* rep == 3 --> offset == repeat offset 1 - 1
|
||||
*/
|
||||
} ZSTD_Sequence;
|
||||
|
||||
typedef struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user