summaryrefslogtreecommitdiffstats
path: root/encoder.c
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-06 11:39:02 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-06 11:39:02 +0000
commit243f444e517f5319ff1fc0cd5c5145388a883940 (patch)
treeab207ec478cb32a6ba58a9538275ade26e750f3d /encoder.c
parentAdding debian version 1.5~pre1-3. (diff)
downloadclzip-243f444e517f5319ff1fc0cd5c5145388a883940.tar.xz
clzip-243f444e517f5319ff1fc0cd5c5145388a883940.zip
Merging upstream version 1.5~pre2.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r--encoder.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/encoder.c b/encoder.c
index 5b005b0..312c569 100644
--- a/encoder.c
+++ b/encoder.c
@@ -1,4 +1,4 @@
-/* Clzip - Data compressor based on the LZMA algorithm
+/* Clzip - LZMA lossless data compressor
Copyright (C) 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
@@ -248,6 +248,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;
+ if( verbosity >= 2 ) show_progress( 0, 0, 0, 0 );
}
}
@@ -289,17 +290,16 @@ static void LZe_full_flush( struct LZ_encoder * const encoder, const State state
int i;
const int pos_state = Mf_data_position( encoder->matchfinder ) & pos_state_mask;
File_trailer trailer;
- Re_encode_bit( &encoder->range_encoder, &encoder->bm_match[state][pos_state], 1 );
- Re_encode_bit( &encoder->range_encoder, &encoder->bm_rep[state], 0 );
+ Re_encode_bit( &encoder->renc, &encoder->bm_match[state][pos_state], 1 );
+ Re_encode_bit( &encoder->renc, &encoder->bm_rep[state], 0 );
LZe_encode_pair( encoder, 0xFFFFFFFFU, min_match_len, pos_state );
- Re_flush( &encoder->range_encoder );
+ Re_flush( &encoder->renc );
Ft_set_data_crc( trailer, LZe_crc( encoder ) );
Ft_set_data_size( trailer, Mf_data_position( encoder->matchfinder ) );
- Ft_set_member_size( trailer, Re_member_position( &encoder->range_encoder ) +
- Ft_size );
+ Ft_set_member_size( trailer, Re_member_position( &encoder->renc ) + Ft_size );
for( i = 0; i < Ft_size; ++i )
- Re_put_byte( &encoder->range_encoder, trailer[i] );
- Re_flush_data( &encoder->range_encoder );
+ Re_put_byte( &encoder->renc, trailer[i] );
+ Re_flush_data( &encoder->renc );
}
@@ -368,7 +368,7 @@ bool LZe_init( struct LZ_encoder * const encoder,
Bm_array_init( encoder->bm_align, dis_align_size );
encoder->matchfinder = mf;
- if( !Re_init( &encoder->range_encoder, outfd ) ) return false;
+ if( !Re_init( &encoder->renc, outfd ) ) return false;
Lee_init( &encoder->match_len_encoder, encoder->matchfinder->match_len_limit );
Lee_init( &encoder->rep_len_encoder, encoder->matchfinder->match_len_limit );
encoder->num_dis_slots =
@@ -377,13 +377,13 @@ bool LZe_init( struct LZ_encoder * const encoder,
encoder->align_price_count = 0;
for( i = 0; i < Fh_size; ++i )
- Re_put_byte( &encoder->range_encoder, header[i] );
+ Re_put_byte( &encoder->renc, header[i] );
return true;
}
/* Return value == number of bytes advanced (ahead).
- trials[0]..trials[retval-1] contain the steps to encode.
+ trials[0]..trials[ahead-1] contain the steps to encode.
( trials[0].dis == -1 && trials[0].price == 1 ) means literal.
*/
static int LZe_sequence_optimizer( struct LZ_encoder * const encoder,
@@ -584,8 +584,7 @@ static int LZe_sequence_optimizer( struct LZ_encoder * const encoder,
if( St_is_char( cur_state ) )
next_price += LZe_price_literal( encoder, prev_byte, cur_byte );
else
- next_price += LZe_price_matched( encoder,
- prev_byte, cur_byte, match_byte );
+ next_price += LZe_price_matched( encoder, prev_byte, cur_byte, match_byte );
Mf_move_pos( encoder->matchfinder );
/* try last updates to next trial */
@@ -756,14 +755,14 @@ bool LZe_encode_member( struct LZ_encoder * const encoder,
for( i = 0; i < num_rep_distances; ++i ) rep_distances[i] = 0;
if( Mf_data_position( encoder->matchfinder ) != 0 ||
- Re_member_position( &encoder->range_encoder ) != Fh_size )
+ Re_member_position( &encoder->renc ) != Fh_size )
return false; /* can be called only once */
if( !Mf_finished( encoder->matchfinder ) ) /* encode first byte */
{
const uint8_t prev_byte = 0;
const uint8_t cur_byte = Mf_peek( encoder->matchfinder, 0 );
- Re_encode_bit( &encoder->range_encoder, &encoder->bm_match[state][0], 0 );
+ Re_encode_bit( &encoder->renc, &encoder->bm_match[state][0], 0 );
LZe_encode_literal( encoder, prev_byte, cur_byte );
CRC32_update_byte( &encoder->crc, cur_byte );
Mf_get_match_pairs( encoder->matchfinder, 0 );
@@ -791,7 +790,7 @@ bool LZe_encode_member( struct LZ_encoder * const encoder,
const int len = encoder->trials[i].price;
bool bit = ( dis < 0 && len == 1 );
- Re_encode_bit( &encoder->range_encoder,
+ Re_encode_bit( &encoder->renc,
&encoder->bm_match[state][pos_state], !bit );
if( bit ) /* literal byte */
{
@@ -813,23 +812,23 @@ bool LZe_encode_member( struct LZ_encoder * const encoder,
CRC32_update_buf( &encoder->crc, Mf_ptr_to_current_pos( encoder->matchfinder ) - ahead, len );
LZe_mtf_reps( dis, rep_distances );
bit = ( dis < num_rep_distances );
- Re_encode_bit( &encoder->range_encoder, &encoder->bm_rep[state], bit );
+ Re_encode_bit( &encoder->renc, &encoder->bm_rep[state], bit );
if( bit )
{
bit = ( dis == 0 );
- Re_encode_bit( &encoder->range_encoder, &encoder->bm_rep0[state], !bit );
+ Re_encode_bit( &encoder->renc, &encoder->bm_rep0[state], !bit );
if( bit )
- Re_encode_bit( &encoder->range_encoder, &encoder->bm_len[state][pos_state], len > 1 );
+ Re_encode_bit( &encoder->renc, &encoder->bm_len[state][pos_state], len > 1 );
else
{
- Re_encode_bit( &encoder->range_encoder, &encoder->bm_rep1[state], dis > 1 );
+ Re_encode_bit( &encoder->renc, &encoder->bm_rep1[state], dis > 1 );
if( dis > 1 )
- Re_encode_bit( &encoder->range_encoder, &encoder->bm_rep2[state], dis > 2 );
+ Re_encode_bit( &encoder->renc, &encoder->bm_rep2[state], dis > 2 );
}
if( len == 1 ) state = St_set_short_rep( state );
else
{
- Lee_encode( &encoder->rep_len_encoder, &encoder->range_encoder, len, pos_state );
+ Lee_encode( &encoder->rep_len_encoder, &encoder->renc, len, pos_state );
state = St_set_rep( state );
}
}
@@ -841,7 +840,7 @@ bool LZe_encode_member( struct LZ_encoder * const encoder,
}
}
ahead -= len; i += len;
- if( Re_member_position( &encoder->range_encoder ) >= member_size_limit )
+ if( Re_member_position( &encoder->renc ) >= member_size_limit )
{
if( !Mf_dec_pos( encoder->matchfinder, ahead ) ) return false;
LZe_full_flush( encoder, state );