"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "stream.c" between
lrzip-0.640.tar.xz and lrzip-0.641.tar.xz

About: lrzip (Long Range ZIP or Lzma RZIP) is a compression program optimised for large files. It combines the best parts of various algorithms for large files and scales with increasing RAM size.

stream.c  (lrzip-0.640.tar.xz):stream.c  (lrzip-0.641.tar.xz)
skipping to change at line 1884 skipping to change at line 1884
return 0; return 0;
} }
/* As others are slow and lz4 very fast, it is worth doing a quick lz4 pass /* As others are slow and lz4 very fast, it is worth doing a quick lz4 pass
to see if there is any compression at all with lz4 first. It is unlikely to see if there is any compression at all with lz4 first. It is unlikely
that others will be able to compress if lz4 is unable to drop a single byte that others will be able to compress if lz4 is unable to drop a single byte
so do not compress any block that is incompressible by lz4. */ so do not compress any block that is incompressible by lz4. */
static int lz4_compresses(rzip_control *control, uchar *s_buf, i64 s_len) static int lz4_compresses(rzip_control *control, uchar *s_buf, i64 s_len)
{ {
int in_len, test_len = s_len, save_len = s_len; int dlen, test_len;
int dlen;
char *c_buf = NULL, *test_buf = (char *)s_buf; char *c_buf = NULL, *test_buf = (char *)s_buf;
/* set minimum buffer test size based on the length of the test stream */
int buftest_size = (test_len > 5 * STREAM_BUFSIZE ? STREAM_BUFSIZE : STRE
AM_BUFSIZE / 4096);
int ret = 0; int ret = 0;
int workcounter = 0; /* count # of passes */ int workcounter = 0; /* count # of passes */
int best_dlen = INT_MAX; /* save best compression estimate */ int best_dlen = INT_MAX; /* save best compression estimate */
if (!LZ4_TEST) if (!LZ4_TEST)
return 1; return 1;
in_len = MIN(test_len, buftest_size); dlen = MIN(s_len, STREAM_BUFSIZE);
dlen = STREAM_BUFSIZE + STREAM_BUFSIZE / 16 + 64 + 3; test_len = MIN(dlen, STREAM_BUFSIZE >> 8);
c_buf = malloc(dlen); c_buf = malloc(dlen);
if (unlikely(!c_buf)) if (unlikely(!c_buf))
fatal_return(("Unable to allocate c_buf in lz4_compresses\n"), 0) ; fatal_return(("Unable to allocate c_buf in lz4_compresses\n"), 0) ;
/* Test progressively larger blocks at a time and as soon as anything /* Test progressively larger blocks at a time and as soon as anything
compressible is found, jump out as a success */ compressible is found, jump out as a success */
while (test_len > 0) { do {
int lz4_ret; int lz4_ret;
workcounter++; workcounter++;
lz4_ret = LZ4_compress_default((const char *)test_buf, c_buf, tes t_len, dlen); lz4_ret = LZ4_compress_default((const char *)test_buf, c_buf, tes t_len, dlen);
if (!lz4_ret) // Bigger than dlen, no point going further if (!lz4_ret) // Bigger than dlen
break; lz4_ret = test_len;
if (lz4_ret < best_dlen) if (lz4_ret < best_dlen)
best_dlen = lz4_ret; best_dlen = lz4_ret;
if (lz4_ret < test_len) { if (lz4_ret < test_len) {
ret = 1; ret = 1;
break; break;
} }
/* expand and move buffer */ /* expand test length */
test_len -= in_len; test_len <<= 1;
if (test_len) { } while (test_len <= dlen);
test_buf += (ptrdiff_t)in_len;
if (buftest_size < STREAM_BUFSIZE) if (!ret)
buftest_size <<= 1; print_maxverbose("lz4 testing FAILED for chunk %ld. %d Passes\n",
in_len = MIN(test_len, buftest_size); workcounter);
} else {
print_maxverbose("lz4 testing OK for chunk %ld. Compressed size =
%5.2F%% of chunk, %d Passes\n",
s_len, 100 * ((double) best_dlen / (double) test_
len), workcounter);
} }
print_maxverbose("lz4 testing %s for chunk %ld. Compressed size = %5.2F%%
of chunk, %d Passes\n",
(ret == 0? "FAILED" : "OK"), save_len,
100 * ((double) best_dlen / (double) in_len), workcounter
);
dealloc(c_buf); dealloc(c_buf);
return ret; return ret;
} }
 End of changes. 7 change blocks. 
24 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)