summaryrefslogtreecommitdiffstats
path: root/encoder_base.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2018-02-13 06:55:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2018-02-13 06:56:31 +0000
commitc47aa7dfb21de77e630d5738d73a0f38204bfe0b (patch)
tree73bf32ded6d79f9d4876203cb922233e44f757c3 /encoder_base.c
parentReleasing debian version 1.9-4. (diff)
downloadclzip-c47aa7dfb21de77e630d5738d73a0f38204bfe0b.tar.xz
clzip-c47aa7dfb21de77e630d5738d73a0f38204bfe0b.zip
Merging upstream version 1.10.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'encoder_base.c')
-rw-r--r--encoder_base.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/encoder_base.c b/encoder_base.c
index e384d22..019a162 100644
--- a/encoder_base.c
+++ b/encoder_base.c
@@ -1,5 +1,5 @@
/* Clzip - LZMA lossless data compressor
- Copyright (C) 2010-2017 Antonio Diaz Diaz.
+ Copyright (C) 2010-2018 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -69,21 +69,22 @@ void Mb_normalize_pos( struct Matchfinder_base * const mb )
}
-bool Mb_init( struct Matchfinder_base * const mb, const int before,
+bool Mb_init( struct Matchfinder_base * const mb, const int before_size,
const int dict_size, const int after_size,
const int dict_factor, const int num_prev_positions23,
const int pos_array_factor, const int ifd )
{
const int buffer_size_limit =
- ( dict_factor * dict_size ) + before + after_size;
+ ( dict_factor * dict_size ) + before_size + after_size;
unsigned size;
int i;
mb->partial_data_pos = 0;
- mb->before_size = before;
+ mb->before_size = before_size;
mb->pos = 0;
mb->cyclic_pos = 0;
mb->stream_pos = 0;
+ mb->num_prev_positions23 = num_prev_positions23;
mb->infd = ifd;
mb->at_stream_end = false;
@@ -111,8 +112,8 @@ bool Mb_init( struct Matchfinder_base * const mb, const int before,
size >>= 1;
mb->key4_mask = size - 1;
size += num_prev_positions23;
-
mb->num_prev_positions = size;
+
mb->pos_array_size = pos_array_factor * ( mb->dictionary_size + 1 );
size += mb->pos_array_size;
if( size * sizeof mb->prev_positions[0] <= size ) mb->prev_positions = 0;
@@ -134,8 +135,20 @@ void Mb_reset( struct Matchfinder_base * const mb )
mb->stream_pos -= mb->pos;
mb->pos = 0;
mb->cyclic_pos = 0;
- for( i = 0; i < mb->num_prev_positions; ++i ) mb->prev_positions[i] = 0;
Mb_read_block( mb );
+ if( mb->at_stream_end && mb->stream_pos < mb->dictionary_size )
+ {
+ int size;
+ mb->dictionary_size = max( min_dictionary_size, mb->stream_pos );
+ size = 1 << max( 16, real_bits( mb->dictionary_size - 1 ) - 2 );
+ if( mb->dictionary_size > 1 << 26 ) /* 64 MiB */
+ size >>= 1;
+ mb->key4_mask = size - 1;
+ size += mb->num_prev_positions23;
+ mb->num_prev_positions = size;
+ mb->pos_array = mb->prev_positions + mb->num_prev_positions;
+ }
+ for( i = 0; i < mb->num_prev_positions; ++i ) mb->prev_positions[i] = 0;
}
@@ -148,7 +161,7 @@ void Re_flush_data( struct Range_encoder * const renc )
{ show_error( "Write error", errno, false ); cleanup_and_fail( 1 ); }
renc->partial_member_pos += renc->pos;
renc->pos = 0;
- show_progress( 0, 0, 0, 0 );
+ show_cprogress( 0, 0, 0, 0 );
}
}
@@ -188,5 +201,5 @@ void LZeb_reset( struct LZ_encoder_base * const eb )
Bm_array_init( eb->bm_align, dis_align_size );
Lm_init( &eb->match_len_model );
Lm_init( &eb->rep_len_model );
- Re_reset( &eb->renc );
+ Re_reset( &eb->renc, eb->mb.dictionary_size );
}