]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
ZSTD_getPrice
authorinikep <inikep@gmail.com>
Wed, 3 Feb 2016 16:25:42 +0000 (17:25 +0100)
committerinikep <inikep@gmail.com>
Wed, 3 Feb 2016 16:25:42 +0000 (17:25 +0100)
lib/zstd_compress.c
lib/zstd_opt.c

index fe9bde30c0f19e2d1a31bf794268f938d40292da..71ff02e7b93db231ff2882be4ed6999d66187182 100644 (file)
@@ -2305,7 +2305,7 @@ static const ZSTD_parameters ZSTD_defaultParameters[4][ZSTD_MAX_CLEVEL+1] = {
     { 0, 22, 20, 22,  4,  4, ZSTD_lazy2   },  /* level 11 + L=4 */ // 41902762   lazy1=42087013     norep1=42911693
     { 0, 23, 21, 22,  5,  4, ZSTD_btlazy2 },  /* level 16 + L=4 */ // 41233150   btlazy1=41560211   norep1=42322286
     { 0, 23, 21, 22,  5,  4, ZSTD_opt     },  /* level 23 */
-    { 0, 23, 21, 22,  5,  4, ZSTD_opt_bt  },  /* level 23 */
+    { 0, 23, 21, 22,  5,  4, ZSTD_opt_bt  },  /* level 24 */
 },
 {   /* for srcSize <= 256 KB */
     /*     W,  C,  H,  S,  L, strat */
index e6f0f402f9580dd059f874d33b07b63cbc3babe2..ebd33835a998a759298bbec0b00fcf8ca8676257 100644 (file)
@@ -64,6 +64,41 @@ FORCE_INLINE U32 LZ5HC_get_price(U32 litlen, U32 offset, U32 mlen)
     return lit_cost + match_cost;
 }
 
+MEM_STATIC size_t ZSTD_getPrice(seqStore_t* seqStorePtr, size_t litLength, const BYTE* literals, size_t offsetCode, size_t matchCode)
+{
+#if 0
+    static const BYTE* g_start = NULL;
+    if (g_start==NULL) g_start = literals;
+    //if (literals - g_start == 8695)
+    printf("pos %6u : %3u literals & match %3u bytes at distance %6u \n",
+           (U32)(literals - g_start), (U32)litLength, (U32)matchCode+4, (U32)offsetCode);
+#endif
+    size_t price = 0;
+
+    /* literals */
+    seqStorePtr->lit += litLength;
+
+    /* literal Length */
+    if (litLength >= MaxLL) {
+        *(seqStorePtr->litLength++) = MaxLL;
+        if (litLength<255 + MaxLL) price += 8; else price += 32;
+    }   
+    else *(seqStorePtr->litLength++) = (BYTE)litLength;
+
+    /* match offset */
+    *(seqStorePtr->offset++) = (U32)offsetCode;
+
+    /* match Length */
+    if (matchCode >= MaxML) {
+        *(seqStorePtr->matchLength++) = MaxML;
+        if (matchCode < 255+MaxML) price += 8; else price += 32;
+    }
+    else *(seqStorePtr->matchLength++) = (BYTE)matchCode;
+    
+    return price;
+}
+
+
 
 #define SET_PRICE(pos, mlen, offset, litlen, price)   \
     {                                                 \