diff options
Diffstat (limited to 'encoder.c')
-rw-r--r-- | encoder.c | 29 |
1 files changed, 14 insertions, 15 deletions
@@ -1,5 +1,5 @@ /* Clzip - LZMA lossless data compressor - Copyright (C) 2010-2024 Antonio Diaz Diaz. + Copyright (C) 2010-2025 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 @@ -31,7 +31,7 @@ CRC32 crc32; -int LZe_get_match_pairs( struct LZ_encoder * const e, struct Pair * pairs ) +int LZe_get_match_pairs( LZ_encoder * const e, Pair * pairs ) { int len_limit = e->match_len_limit; if( len_limit > Mb_available_bytes( &e->eb.mb ) ) @@ -133,7 +133,7 @@ int LZe_get_match_pairs( struct LZ_encoder * const e, struct Pair * pairs ) } -static void LZe_update_distance_prices( struct LZ_encoder * const e ) +static void LZe_update_distance_prices( LZ_encoder * const e ) { int dis, len_state; for( dis = start_dis_model; dis < modeled_distances; ++dis ) @@ -172,7 +172,7 @@ static void LZe_update_distance_prices( struct LZ_encoder * const e ) ( trials[0].dis4 == -1 ) means literal. A match/rep longer or equal than match_len_limit finishes the sequence. */ -static int LZe_sequence_optimizer( struct LZ_encoder * const e, +static int LZe_sequence_optimizer( LZ_encoder * const e, const int reps[num_rep_distances], const State state ) { @@ -291,7 +291,7 @@ static int LZe_sequence_optimizer( struct LZ_encoder * const e, } /* give final values to current trial */ - struct Trial * cur_trial = &e->trials[cur]; + Trial * cur_trial = &e->trials[cur]; State cur_state; { const int dis4 = cur_trial->dis4; @@ -303,7 +303,7 @@ static int LZe_sequence_optimizer( struct LZ_encoder * const e, cur_state = e->trials[prev_index].state; if( prev_index + 1 == cur ) /* len == 1 */ { - if( dis4 == 0 ) cur_state = St_set_short_rep( cur_state ); + if( dis4 == 0 ) cur_state = St_set_shortrep( cur_state ); else cur_state = St_set_char( cur_state ); /* literal */ } else if( dis4 < num_rep_distances ) cur_state = St_set_rep( cur_state ); @@ -336,7 +336,7 @@ static int LZe_sequence_optimizer( struct LZ_encoder * const e, next_price += LZeb_price_matched( &e->eb, prev_byte, cur_byte, match_byte ); /* try last updates to next trial */ - struct Trial * next_trial = &e->trials[cur+1]; + Trial * next_trial = &e->trials[cur+1]; Tr_update( next_trial, next_price, -1, cur ); /* literal */ @@ -346,8 +346,7 @@ static int LZe_sequence_optimizer( struct LZ_encoder * const e, if( match_byte == cur_byte && next_trial->dis4 != 0 && next_trial->prev_index2 == single_step_trial ) { - const int price = rep_match_price + - LZeb_price_shortrep( &e->eb, cur_state, pos_state ); + const int price = rep_match_price + LZeb_price_shortrep( &e->eb, cur_state, pos_state ); if( price <= next_trial->price ) { next_trial->price = price; @@ -478,12 +477,12 @@ static int LZe_sequence_optimizer( struct LZ_encoder * const e, } -bool LZe_encode_member( struct LZ_encoder * const e, +bool LZe_encode_member( LZ_encoder * const e, const unsigned long long member_size ) { const unsigned long long member_size_limit = member_size - Lt_size - max_marker_size; - const bool best = ( e->match_len_limit > 12 ); + const bool best = e->match_len_limit > 12; const int dis_price_count = best ? 1 : 512; const int align_price_count = best ? 1 : dis_align_size; const int price_count = ( e->match_len_limit > 36 ) ? 1013 : 4093; @@ -537,7 +536,7 @@ bool LZe_encode_member( struct LZ_encoder * const e, const int len = e->trials[i].price; int dis = e->trials[i].dis4; - bool bit = ( dis < 0 ); + bool bit = dis < 0; Re_encode_bit( &e->eb.renc, &e->eb.bm_match[state][pos_state], !bit ); if( bit ) /* literal byte */ { @@ -556,11 +555,11 @@ bool LZe_encode_member( struct LZ_encoder * const e, { CRC32_update_buf( &e->eb.crc, Mb_ptr_to_current_pos( &e->eb.mb ) - ahead, len ); mtf_reps( dis, reps ); - bit = ( dis < num_rep_distances ); + bit = dis < num_rep_distances; Re_encode_bit( &e->eb.renc, &e->eb.bm_rep[state], bit ); if( bit ) /* repeated match */ { - bit = ( dis == 0 ); + bit = dis == 0; Re_encode_bit( &e->eb.renc, &e->eb.bm_rep0[state], !bit ); if( bit ) Re_encode_bit( &e->eb.renc, &e->eb.bm_len[state][pos_state], len > 1 ); @@ -570,7 +569,7 @@ bool LZe_encode_member( struct LZ_encoder * const e, if( dis > 1 ) Re_encode_bit( &e->eb.renc, &e->eb.bm_rep2[state], dis > 2 ); } - if( len == 1 ) state = St_set_short_rep( state ); + if( len == 1 ) state = St_set_shortrep( state ); else { Re_encode_len( &e->eb.renc, &e->eb.rep_len_model, len, pos_state ); |