diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-06 11:32:29 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-06 11:32:29 +0000 |
commit | 1ca0d3282eb7fd0872b93f18e4923b3f44f2f179 (patch) | |
tree | 3fe74ab2a59a6e2fc7ea35b993488cbc80d4135e /encoder.c | |
parent | Adding debian version 1.1-2. (diff) | |
download | clzip-1ca0d3282eb7fd0872b93f18e4923b3f44f2f179.tar.xz clzip-1ca0d3282eb7fd0872b93f18e4923b3f44f2f179.zip |
Merging upstream version 1.2.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r-- | encoder.c | 48 |
1 files changed, 34 insertions, 14 deletions
@@ -388,23 +388,25 @@ int LZe_sequence_optimizer( struct LZ_encoder * const encoder, return 1; } - { - const int normal_match_price = match_price + price0( encoder->bm_rep[state] ); - int len = min_match_len; if( main_len <= replens[rep_index] ) { + int len; main_len = replens[rep_index]; - for( ; len <= main_len; ++len ) + for( len = min_match_len; len <= main_len; ++len ) encoder->trials[len].price = infinite_price; } - else for( ; len <= main_len; ++len ) + else { - encoder->trials[len].dis = encoder->match_distances[len] + num_rep_distances; - encoder->trials[len].prev_index = 0; - encoder->trials[len].price = normal_match_price + - LZe_price_pair( encoder, encoder->match_distances[len], len, pos_state ); + int len; + const int normal_match_price = match_price + price0( encoder->bm_rep[state] ); + for( len = min_match_len; len <= main_len; ++len ) + { + encoder->trials[len].dis = encoder->match_distances[len] + num_rep_distances; + encoder->trials[len].prev_index = 0; + encoder->trials[len].price = normal_match_price + + LZe_price_pair( encoder, encoder->match_distances[len], len, pos_state ); + } } - } for( rep = 0; rep < num_rep_distances; ++rep ) { @@ -513,13 +515,31 @@ int LZe_sequence_optimizer( struct LZ_encoder * const encoder, const int normal_match_price = match_price + price0( encoder->bm_rep[cur_trial->state] ); int len; + int dis = encoder->match_distances[min_match_len]; + int dis_state = get_dis_state( min_match_len ); + int dis_price = infinite_price; + while( num_trials < cur + newlen ) encoder->trials[++num_trials].price = infinite_price; - for( len = min_match_len; len <= newlen; ++len ) - Tr_update( &encoder->trials[cur+len], encoder->match_distances[len] + num_rep_distances, - cur, normal_match_price + - LZe_price_pair( encoder, encoder->match_distances[len], len, pos_state ) ); + if( dis < modeled_distances ) + Tr_update( &encoder->trials[cur+min_match_len], dis + num_rep_distances, + cur, normal_match_price + encoder->dis_prices[dis_state][dis] + + Lee_price( &encoder->len_encoder, min_match_len, pos_state ) ); + + for( len = min_match_len + 1; len <= newlen; ++len ) + { + if( dis != encoder->match_distances[len] || + dis_state < max_dis_states - 1 ) + { + dis = encoder->match_distances[len]; + dis_state = get_dis_state( len ); + dis_price = LZe_price_dis( encoder, dis, dis_state ); + } + Tr_update( &encoder->trials[cur+len], dis + num_rep_distances, cur, + normal_match_price + dis_price + + Lee_price( &encoder->len_encoder, len, pos_state ) ); + } } } } |