even gained 2 bytes on calgary.tar...
added conditional traces `g_debuglog_enable`
#if defined(LZ4_DEBUG) && (LZ4_DEBUG>=2)
# include <stdio.h>
-# define DEBUGLOG(l, ...) { \
- if (l<=LZ4_DEBUG) { \
- fprintf(stderr, __FILE__ ": "); \
- fprintf(stderr, __VA_ARGS__); \
- fprintf(stderr, " \n"); \
+static int g_debuglog_enable = 1;
+# define DEBUGLOG(l, ...) { \
+ if ((g_debuglog_enable) && (l<=LZ4_DEBUG)) { \
+ fprintf(stderr, __FILE__ ": "); \
+ fprintf(stderr, __VA_ARGS__); \
+ fprintf(stderr, " \n"); \
} }
#else
# define DEBUGLOG(l, ...) {} /* disabled */
void LZ4_resetStream (LZ4_stream_t* LZ4_stream)
{
+ DEBUGLOG(4, "LZ4_resetStream");
MEM_INIT(LZ4_stream, 0, sizeof(LZ4_stream_t));
}
repeat_state_e repeat = rep_untested;
size_t srcPatternLength = 0;
-
+ DEBUGLOG(7, "LZ4HC_InsertAndGetWiderMatch");
/* First Match */
LZ4HC_Insert(hc4, ip);
matchIndex = HashTable[LZ4HC_hashPtr(ip)];
+ DEBUGLOG(7, "First match at index %u / %u (lowLimit)",
+ matchIndex, lowLimit);
while ((matchIndex>=lowLimit) && (nbAttempts)) {
+ DEBUGLOG(7, "remaining attempts : %i", nbAttempts);
nbAttempts--;
if (matchIndex >= dictLimit) {
const BYTE* const matchPtr = base + matchIndex;
#if defined(LZ4_DEBUG) && (LZ4_DEBUG >= 2)
static const BYTE* start = NULL;
static U32 totalCost = 0;
+ U32 const pos = (U32)(*anchor - start);
U32 const ll = (U32)(*ip - *anchor);
U32 const llAdd = (ll>=15) ? ((ll-15) / 255) + 1 : 0;
U32 const mlAdd = (matchLength>=19) ? ((matchLength-19) / 255) + 1 : 0;
U32 const cost = 1 + llAdd + ll + 2 + mlAdd;
if (start==NULL) start = *anchor; /* only works for single segment */
- totalCost += cost;
- DEBUGLOG(2, "pos:%7u -- literals:%3u, match:%4i, offset:%5u, cost:%3u/%7u",
- (U32)(*anchor - start),
+ //g_debuglog_enable = (pos >= 112705) & (pos <= 112760);
+ DEBUGLOG(2, "pos:%7u -- literals:%3u, match:%4i, offset:%5u, cost:%3u / %u",
+ pos,
(U32)(*ip - *anchor), matchLength, (U32)(*ip-match),
cost, totalCost);
+ totalCost += cost;
#endif
/* Encode Literal length */
} } }
last_match_pos = matches[nb_matches_initial-1].len;
{ int addLit;
- for (addLit = 1; addLit <= 2; addLit ++) {
+ for (addLit = 1; addLit <= 3; addLit ++) {
opt[last_match_pos+addLit].mlen = 1; /* literal */
opt[last_match_pos+addLit].off = 0;
opt[last_match_pos+addLit].litlen = addLit;
if (curPtr >= mflimit) break;
+ DEBUGLOG(7, "search at rPos:%u", cur);
//nb_matches = LZ4HC_BinTree_GetAllMatches(ctx, curPtr, matchlimit, MINMATCH-1, matches, fullUpdate);
nb_matches = LZ4HC_HashChain_GetAllMatches(ctx, curPtr, matchlimit, MINMATCH-1, matches, fullUpdate);
//nb_matches = LZ4HC_HashChain_GetAllMatches(ctx, curPtr, matchlimit, last_match_pos - cur + 1, matches, fullUpdate); /* only works if last_match_pos is really the last match pos */
price = opt[cur].price + LZ4HC_sequencePrice(0, ml);
}
- if (pos > last_match_pos+2 || price <= opt[pos].price) {
+ if (pos > last_match_pos+3 || price <= opt[pos].price) {
DEBUGLOG(7, "rPos:%3i => price:%3i (matchlen=%i)",
pos, price, ml);
assert(pos < LZ4_OPT_NUM);
} } } }
/* complete following positions with literals */
{ int addLit;
- for (addLit = 1; addLit <= 2; addLit ++) {
+ for (addLit = 1; addLit <= 3; addLit ++) {
opt[last_match_pos+addLit].mlen = 1; /* literal */
opt[last_match_pos+addLit].off = 0;
opt[last_match_pos+addLit].litlen = addLit;