zstd_opt.h: small improvement in compression ratio
This commit is contained in:
parent
575ab00db7
commit
d365ae3497
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
* Copyright (c) 2016-present, Przemyslaw Skibinski, Yann Collet, Facebook, Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This source code is licensed under the BSD-style license found in the
|
* This source code is licensed under the BSD-style license found in the
|
||||||
@ -401,7 +401,6 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx,
|
|||||||
ZSTD_rescaleFreqs(seqStorePtr);
|
ZSTD_rescaleFreqs(seqStorePtr);
|
||||||
ip += (ip==prefixStart);
|
ip += (ip==prefixStart);
|
||||||
{ U32 i; for (i=0; i<ZSTD_REP_NUM; i++) rep[i]=ctx->rep[i]; }
|
{ U32 i; for (i=0; i<ZSTD_REP_NUM; i++) rep[i]=ctx->rep[i]; }
|
||||||
//inr = ip;
|
|
||||||
|
|
||||||
/* Match Loop */
|
/* Match Loop */
|
||||||
while (ip < ilimit) {
|
while (ip < ilimit) {
|
||||||
@ -511,6 +510,9 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx,
|
|||||||
|
|
||||||
best_off = i - (opt[cur].mlen != 1);
|
best_off = i - (opt[cur].mlen != 1);
|
||||||
|
|
||||||
|
if (mlen > best_mlen) best_mlen = mlen;
|
||||||
|
|
||||||
|
do {
|
||||||
if (opt[cur].mlen == 1) {
|
if (opt[cur].mlen == 1) {
|
||||||
litlen = opt[cur].litlen;
|
litlen = opt[cur].litlen;
|
||||||
if (cur > litlen) {
|
if (cur > litlen) {
|
||||||
@ -522,9 +524,6 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx,
|
|||||||
price = opt[cur].price + ZSTD_getPrice(seqStorePtr, 0, NULL, best_off, mlen - MINMATCH);
|
price = opt[cur].price + ZSTD_getPrice(seqStorePtr, 0, NULL, best_off, mlen - MINMATCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mlen > best_mlen) best_mlen = mlen;
|
|
||||||
|
|
||||||
do {
|
|
||||||
if (cur + mlen > last_pos || price <= opt[cur + mlen].price)
|
if (cur + mlen > last_pos || price <= opt[cur + mlen].price)
|
||||||
SET_PRICE(cur + mlen, mlen, i, litlen, price);
|
SET_PRICE(cur + mlen, mlen, i, litlen, price);
|
||||||
mlen--;
|
mlen--;
|
||||||
@ -657,7 +656,6 @@ void ZSTD_compressBlock_opt_extDict_generic(ZSTD_CCtx* ctx,
|
|||||||
ctx->nextToUpdate3 = ctx->nextToUpdate;
|
ctx->nextToUpdate3 = ctx->nextToUpdate;
|
||||||
ZSTD_rescaleFreqs(seqStorePtr);
|
ZSTD_rescaleFreqs(seqStorePtr);
|
||||||
ip += (ip==prefixStart);
|
ip += (ip==prefixStart);
|
||||||
//inr = ip;
|
|
||||||
|
|
||||||
/* Match Loop */
|
/* Match Loop */
|
||||||
while (ip < ilimit) {
|
while (ip < ilimit) {
|
||||||
@ -666,7 +664,6 @@ void ZSTD_compressBlock_opt_extDict_generic(ZSTD_CCtx* ctx,
|
|||||||
U32 current = (U32)(ip-base);
|
U32 current = (U32)(ip-base);
|
||||||
memset(opt, 0, sizeof(ZSTD_optimal_t));
|
memset(opt, 0, sizeof(ZSTD_optimal_t));
|
||||||
last_pos = 0;
|
last_pos = 0;
|
||||||
//inr = ip;
|
|
||||||
opt[0].litlen = (U32)(ip - anchor);
|
opt[0].litlen = (U32)(ip - anchor);
|
||||||
|
|
||||||
/* check repCode */
|
/* check repCode */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user