Fix issue #17.

Use LZ4 and Libbsc extra padding space for the compression buffer in adaptive modes.
This commit is contained in:
Moinak Ghosh 2014-01-29 00:12:04 +05:30
parent 518ecf23a7
commit 33281a2257
2 changed files with 9 additions and 5 deletions

View file

@ -86,6 +86,9 @@ extern int ppmd_alloc(void *data);
extern void ppmd_free(void *data); extern void ppmd_free(void *data);
extern int ppmd_state_init(void **data, int *level, int alloc); extern int ppmd_state_init(void **data, int *level, int alloc);
extern int lz4_buf_extra(uint64_t buflen);
extern int libbsc_buf_extra(uint64_t buflen);
struct adapt_data { struct adapt_data {
void *lzma_data; void *lzma_data;
void *ppmd_data; void *ppmd_data;
@ -119,8 +122,14 @@ adapt_stats(int show)
void void
adapt_props(algo_props_t *data, int level, uint64_t chunksize) adapt_props(algo_props_t *data, int level, uint64_t chunksize)
{ {
int ext1, ext2;
data->delta2_span = 200; data->delta2_span = 200;
data->deltac_min_distance = EIGHTM; data->deltac_min_distance = EIGHTM;
ext1 = lz4_buf_extra(chunksize);
ext2 = libbsc_buf_extra(chunksize);
if (ext2 > ext1) ext1 = ext2;
data->buf_extra = ext1;
} }
int int

View file

@ -2127,11 +2127,6 @@ start_compress(pc_ctx_t *pctx, const char *filename, uint64_t chunksize, int lev
* We also keep extra 8-byte space for the last chunk's size. * We also keep extra 8-byte space for the last chunk's size.
*/ */
compressed_chunksize = chunksize + CHUNK_HDR_SZ + zlib_buf_extra(chunksize); compressed_chunksize = chunksize + CHUNK_HDR_SZ + zlib_buf_extra(chunksize);
if (chunksize + props.buf_extra > compressed_chunksize) {
compressed_chunksize += (chunksize + props.buf_extra -
compressed_chunksize);
}
if (pctx->_props_func) { if (pctx->_props_func) {
pctx->_props_func(&props, level, chunksize); pctx->_props_func(&props, level, chunksize);
if (chunksize + props.buf_extra > compressed_chunksize) { if (chunksize + props.buf_extra > compressed_chunksize) {