"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "encoder_base.cc" between
lzip-1.21.tar.lz and lzip-1.22-rc1.tar.lz

About: Lzip is a lossless file compressor based on the LZMA algorithm. It decompresses almost as fast as gzip and compresses better than bzip2, but requires more memory and time during compression. Release candidate.

encoder_base.cc  (lzip-1.21.tar.lz):encoder_base.cc  (lzip-1.22-rc1.tar.lz)
/* Lzip - LZMA lossless data compressor /* Lzip - LZMA lossless data compressor
Copyright (C) 2008-2019 Antonio Diaz Diaz. Copyright (C) 2008-2020 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#define _FILE_OFFSET_BITS 64 #define _FILE_OFFSET_BITS 64
#include <algorithm> #include <algorithm>
#include <cerrno> #include <cerrno>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <new>
#include <string> #include <string>
#include <vector> #include <vector>
#include <stdint.h> #include <stdint.h>
#include "lzip.h" #include "lzip.h"
#include "encoder_base.h" #include "encoder_base.h"
Dis_slots dis_slots; Dis_slots dis_slots;
Prob_prices prob_prices; Prob_prices prob_prices;
skipping to change at line 89 skipping to change at line 90
infd( ifd ), infd( ifd ),
at_stream_end( false ) at_stream_end( false )
{ {
const int buffer_size_limit = const int buffer_size_limit =
( dict_factor * dict_size ) + before_size + after_size; ( dict_factor * dict_size ) + before_size + after_size;
buffer_size = std::max( 65536, dict_size ); buffer_size = std::max( 65536, dict_size );
buffer = (uint8_t *)std::malloc( buffer_size ); buffer = (uint8_t *)std::malloc( buffer_size );
if( !buffer ) throw std::bad_alloc(); if( !buffer ) throw std::bad_alloc();
if( read_block() && !at_stream_end && buffer_size < buffer_size_limit ) if( read_block() && !at_stream_end && buffer_size < buffer_size_limit )
{ {
buffer_size = buffer_size_limit; uint8_t * const tmp = (uint8_t *)std::realloc( buffer, buffer_size_limit );
uint8_t * const tmp = (uint8_t *)std::realloc( buffer, buffer_size );
if( !tmp ) { std::free( buffer ); throw std::bad_alloc(); } if( !tmp ) { std::free( buffer ); throw std::bad_alloc(); }
buffer = tmp; buffer = tmp;
buffer_size = buffer_size_limit;
read_block(); read_block();
} }
if( at_stream_end && stream_pos < dict_size ) if( at_stream_end && stream_pos < dict_size )
dictionary_size = std::max( (int)min_dictionary_size, stream_pos ); dictionary_size = std::max( (int)min_dictionary_size, stream_pos );
else else
dictionary_size = dict_size; dictionary_size = dict_size;
pos_limit = buffer_size; pos_limit = buffer_size;
if( !at_stream_end ) pos_limit -= after_size; if( !at_stream_end ) pos_limit -= after_size;
unsigned size = 1 << std::max( 16, real_bits( dictionary_size - 1 ) - 2 ); unsigned size = 1 << std::max( 16, real_bits( dictionary_size - 1 ) - 2 );
if( dictionary_size > 1 << 26 ) // 64 MiB if( dictionary_size > 1 << 26 ) // 64 MiB
skipping to change at line 152 skipping to change at line 153
if( pos > 0 ) if( pos > 0 )
{ {
if( outfd >= 0 && writeblock( outfd, buffer, pos ) != pos ) if( outfd >= 0 && writeblock( outfd, buffer, pos ) != pos )
throw Error( "Write error" ); throw Error( "Write error" );
partial_member_pos += pos; partial_member_pos += pos;
pos = 0; pos = 0;
show_cprogress(); show_cprogress();
} }
} }
// End Of Stream mark => (dis == 0xFFFFFFFFU, len == min_match_len) // End Of Stream marker => (dis == 0xFFFFFFFFU, len == min_match_len)
void LZ_encoder_base::full_flush( const State state ) void LZ_encoder_base::full_flush( const State state )
{ {
const int pos_state = data_position() & pos_state_mask; const int pos_state = data_position() & pos_state_mask;
renc.encode_bit( bm_match[state()][pos_state], 1 ); renc.encode_bit( bm_match[state()][pos_state], 1 );
renc.encode_bit( bm_rep[state()], 0 ); renc.encode_bit( bm_rep[state()], 0 );
encode_pair( 0xFFFFFFFFU, min_match_len, pos_state ); encode_pair( 0xFFFFFFFFU, min_match_len, pos_state );
renc.flush(); renc.flush();
Lzip_trailer trailer; Lzip_trailer trailer;
trailer.data_crc( crc() ); trailer.data_crc( crc() );
trailer.data_size( data_position() ); trailer.data_size( data_position() );
 End of changes. 7 change blocks. 
16 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)