diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 09:32:10 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 09:32:10 +0000 |
commit | 48f82c742fbb20fd624a466f0f3dcbc9a9679768 (patch) | |
tree | 694e61fe55b10051d97cd89a73cd70de544d85c5 /decoder.h | |
parent | Adding debian version 1.13~rc2-1. (diff) | |
download | lzip-48f82c742fbb20fd624a466f0f3dcbc9a9679768.tar.xz lzip-48f82c742fbb20fd624a466f0f3dcbc9a9679768.zip |
Merging upstream version 1.13.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'decoder.h')
-rw-r--r-- | decoder.h | 38 |
1 files changed, 18 insertions, 20 deletions
@@ -29,8 +29,8 @@ class Range_decoder bool read_block(); - Range_decoder( const Range_decoder & ); - void operator=( const Range_decoder & ); + Range_decoder( const Range_decoder & ); // declared as private + void operator=( const Range_decoder & ); // declared as private public: explicit Range_decoder( const int ifd ) @@ -42,16 +42,15 @@ public: code( 0 ), range( 0xFFFFFFFFU ), infd( ifd ), - at_stream_end( false ) {} + at_stream_end( false ) + {} ~Range_decoder() { delete[] buffer; } - bool code_is_zero() const throw() { return ( code == 0 ); } + bool code_is_zero() const { return ( code == 0 ); } bool finished() { return pos >= stream_pos && !read_block(); } - long long member_position() const throw() - { return partial_member_pos + pos; } - void reset_member_position() throw() - { partial_member_pos = -pos; } + long long member_position() const { return partial_member_pos + pos; } + void reset_member_position() { partial_member_pos = -pos; } uint8_t get_byte() { @@ -59,7 +58,7 @@ public: return buffer[pos++]; } - int read( uint8_t * const outbuf, const int size ) + int read_data( uint8_t * const outbuf, const int size ) { int rest = size; while( rest > 0 && !finished() ) @@ -192,7 +191,7 @@ class Literal_decoder { Bit_model bm_literal[1<<literal_context_bits][0x300]; - int lstate( const int prev_byte ) const throw() + int lstate( const uint8_t prev_byte ) const { return ( prev_byte >> ( 8 - literal_context_bits ) ); } public: @@ -209,6 +208,7 @@ public: class LZ_decoder { long long partial_data_pos; + Range_decoder & range_decoder; const int dictionary_size; const int buffer_size; uint8_t * const buffer; // output buffer @@ -217,18 +217,17 @@ class LZ_decoder uint32_t crc_; const int outfd; // output file descriptor const int member_version; - Range_decoder & range_decoder; void flush_data(); bool verify_trailer( const Pretty_print & pp ) const; - uint8_t get_prev_byte() const throw() + uint8_t get_prev_byte() const { const int i = ( ( pos > 0 ) ? pos : buffer_size ) - 1; return buffer[i]; } - uint8_t get_byte( const int distance ) const throw() + uint8_t get_byte( const int distance ) const { int i = pos - distance - 1; if( i < 0 ) i += buffer_size; @@ -258,13 +257,14 @@ class LZ_decoder } } - LZ_decoder( const LZ_decoder & ); - void operator=( const LZ_decoder & ); + LZ_decoder( const LZ_decoder & ); // declared as private + void operator=( const LZ_decoder & ); // declared as private public: LZ_decoder( const File_header & header, Range_decoder & rdec, const int ofd ) : partial_data_pos( 0 ), + range_decoder( rdec ), dictionary_size( header.dictionary_size() ), buffer_size( std::max( 65536, dictionary_size ) ), buffer( new uint8_t[buffer_size] ), @@ -272,16 +272,14 @@ public: stream_pos( 0 ), crc_( 0xFFFFFFFFU ), outfd( ofd ), - member_version( header.version() ), - range_decoder( rdec ) + member_version( header.version() ) { buffer[buffer_size-1] = 0; } // prev_byte of first_byte ~LZ_decoder() { delete[] buffer; } - uint32_t crc() const throw() { return crc_ ^ 0xFFFFFFFFU; } + uint32_t crc() const { return crc_ ^ 0xFFFFFFFFU; } - long long data_position() const throw() - { return partial_data_pos + pos; } + long long data_position() const { return partial_data_pos + pos; } int decode_member( const Pretty_print & pp ); }; |