summaryrefslogtreecommitdiffstats
path: root/encoder.cc
diff options
context:
space:
mode:
Diffstat (limited to 'encoder.cc')
-rw-r--r--encoder.cc42
1 files changed, 21 insertions, 21 deletions
diff --git a/encoder.cc b/encoder.cc
index 3e707f3..51c0069 100644
--- a/encoder.cc
+++ b/encoder.cc
@@ -75,7 +75,7 @@ int LZ_encoder::get_match_pairs( Pair * pairs )
while( maxlen < len_limit && data[maxlen-delta] == data[maxlen] )
++maxlen;
pairs[num_pairs-1].len = maxlen;
- if( maxlen >= len_limit ) pairs = 0; /* done. now just skip */
+ if( maxlen >= len_limit ) pairs = 0; // done. now just skip
}
if( maxlen < 3 ) maxlen = 3;
}
@@ -269,10 +269,10 @@ int LZ_encoder::sequence_optimizer( const int reps[num_rep_distances],
}
int cur = 0;
- while( true ) /* price optimization loop */
+ while( true ) // price optimization loop
{
move_pos();
- if( ++cur >= num_trials ) /* no more initialized trials */
+ if( ++cur >= num_trials ) // no more initialized trials
{
backward( cur );
return cur;
@@ -287,7 +287,7 @@ int LZ_encoder::sequence_optimizer( const int reps[num_rep_distances],
return cur;
}
- /* give final values to current trial */
+ // give final values to current trial
Trial & cur_trial = trials[cur];
State cur_state;
{
@@ -298,7 +298,7 @@ int LZ_encoder::sequence_optimizer( const int reps[num_rep_distances],
if( prev_index2 == single_step_trial )
{
cur_state = trials[prev_index].state;
- if( prev_index + 1 == cur ) /* len == 1 */
+ if( prev_index + 1 == cur ) // len == 1
{
if( dis == 0 ) cur_state.set_short_rep();
else cur_state.set_char(); // literal
@@ -306,14 +306,14 @@ int LZ_encoder::sequence_optimizer( const int reps[num_rep_distances],
else if( dis < num_rep_distances ) cur_state.set_rep();
else cur_state.set_match();
}
- else if( prev_index2 == dual_step_trial ) /* dis == 0 */
+ else if( prev_index2 == dual_step_trial ) // dis == 0
{
--prev_index;
cur_state = trials[prev_index].state;
cur_state.set_char();
cur_state.set_rep();
}
- else /* if( prev_index2 >= 0 ) */
+ else // if( prev_index2 >= 0 )
{
prev_index = prev_index2;
cur_state = trials[prev_index].state;
@@ -340,7 +340,7 @@ int LZ_encoder::sequence_optimizer( const int reps[num_rep_distances],
else
next_price += price_matched( prev_byte, cur_byte, match_byte );
- /* try last updates to next trial */
+ // try last updates to next trial
Trial & next_trial = trials[cur+1];
next_trial.update( next_price, -1, cur ); // literal
@@ -366,7 +366,7 @@ int LZ_encoder::sequence_optimizer( const int reps[num_rep_distances],
const int len_limit = std::min( match_len_limit, triable_bytes );
- /* try literal + rep0 */
+ // try literal + rep0
if( match_byte != cur_byte && next_trial.prev_index != cur )
{
const uint8_t * const data = ptr_to_current_pos();
@@ -390,7 +390,7 @@ int LZ_encoder::sequence_optimizer( const int reps[num_rep_distances],
int start_len = min_match_len;
- /* try rep distances */
+ // try rep distances
for( int rep = 0; rep < num_rep_distances; ++rep )
{
const uint8_t * const data = ptr_to_current_pos();
@@ -407,9 +407,9 @@ int LZ_encoder::sequence_optimizer( const int reps[num_rep_distances],
trials[cur+i].update( price + rep_len_prices.price( i, pos_state ),
rep, cur );
- if( rep == 0 ) start_len = len + 1; /* discard shorter matches */
+ if( rep == 0 ) start_len = len + 1; // discard shorter matches
- /* try rep + literal + rep0 */
+ // try rep + literal + rep0
int len2 = len + 1;
const int limit = std::min( match_len_limit + len2, triable_bytes );
while( len2 < limit && data[len2-dis] == data[len2] ) ++len2;
@@ -431,7 +431,7 @@ int LZ_encoder::sequence_optimizer( const int reps[num_rep_distances],
trials[cur+len+1+len2].update3( price, rep, cur + len + 1, cur );
}
- /* try matches */
+ // try matches
if( newlen >= start_len && newlen <= len_limit )
{
const int normal_match_price = match_price +
@@ -449,7 +449,7 @@ int LZ_encoder::sequence_optimizer( const int reps[num_rep_distances],
trials[cur+len].update( price, dis + num_rep_distances, cur );
- /* try match + literal + rep0 */
+ // try match + literal + rep0
if( len == pairs[i].len )
{
const uint8_t * const data = ptr_to_current_pos();
@@ -500,7 +500,7 @@ bool LZ_encoder::encode_member( const unsigned long long member_size )
for( int i = 0; i < num_rep_distances; ++i ) reps[i] = 0;
if( data_position() != 0 || renc.member_position() != File_header::size )
- return false; /* can be called only once */
+ return false; // can be called only once
if( !data_finished() ) // encode first byte
{
@@ -517,7 +517,7 @@ bool LZ_encoder::encode_member( const unsigned long long member_size )
{
if( price_counter <= 0 && pending_num_pairs == 0 )
{
- price_counter = price_count; /* recalculate prices every these bytes */
+ price_counter = price_count; // recalculate prices every these bytes
if( dis_price_counter <= 0 )
{ dis_price_counter = dis_price_count; update_distance_prices(); }
if( align_price_counter <= 0 )
@@ -531,7 +531,7 @@ bool LZ_encoder::encode_member( const unsigned long long member_size )
}
int ahead = sequence_optimizer( reps, state );
- if( ahead <= 0 ) return false; /* can't happen */
+ if( ahead <= 0 ) return false; // can't happen
price_counter -= ahead;
for( int i = 0; ahead > 0; )
@@ -542,7 +542,7 @@ bool LZ_encoder::encode_member( const unsigned long long member_size )
bool bit = ( dis < 0 );
renc.encode_bit( bm_match[state()][pos_state], !bit );
- if( bit ) /* literal byte */
+ if( bit ) // literal byte
{
const uint8_t prev_byte = peek( ahead + 1 );
const uint8_t cur_byte = peek( ahead );
@@ -556,13 +556,13 @@ bool LZ_encoder::encode_member( const unsigned long long member_size )
}
state.set_char();
}
- else /* match or repeated match */
+ else // match or repeated match
{
crc32.update_buf( crc_, ptr_to_current_pos() - ahead, len );
mtf_reps( dis, reps );
bit = ( dis < num_rep_distances );
renc.encode_bit( bm_rep[state()], bit );
- if( bit ) /* repeated match */
+ if( bit ) // repeated match
{
bit = ( dis == 0 );
renc.encode_bit( bm_rep0[state()], !bit );
@@ -582,7 +582,7 @@ bool LZ_encoder::encode_member( const unsigned long long member_size )
state.set_rep();
}
}
- else /* match */
+ else // match
{
encode_pair( dis - num_rep_distances, len, pos_state );
if( get_slot( dis - num_rep_distances ) >= end_dis_model )