Adding upstream version 1.18.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
ed1b0d872f
commit
f46d8ce0c8
45 changed files with 1576 additions and 774 deletions
32
mtester.h
32
mtester.h
|
@ -1,5 +1,5 @@
|
|||
/* Lziprecover - Data recovery tool for the lzip format
|
||||
Copyright (C) 2009-2015 Antonio Diaz Diaz.
|
||||
Copyright (C) 2009-2016 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
|
||||
|
@ -37,27 +37,29 @@ public:
|
|||
at_stream_end( false )
|
||||
{}
|
||||
|
||||
bool code_is_zero() const { return ( code == 0 ); }
|
||||
bool finished() { return pos >= buffer_size; }
|
||||
long member_position() const { return pos; }
|
||||
unsigned long member_position() const { return pos; }
|
||||
|
||||
uint8_t get_byte()
|
||||
{
|
||||
if( finished() ) return 0xAA; // make code != 0
|
||||
// 0xFF avoids decoder error if member is truncated at EOS marker
|
||||
if( finished() ) return 0xFF;
|
||||
return buffer[pos++];
|
||||
}
|
||||
|
||||
const File_trailer * get_trailer()
|
||||
{
|
||||
if( buffer_size - pos < File_trailer::size ) return 0;
|
||||
const File_trailer * const p = (File_trailer *)(buffer + pos);
|
||||
const File_trailer * const p = (File_trailer *)( buffer + pos );
|
||||
pos += File_trailer::size;
|
||||
return p;
|
||||
}
|
||||
|
||||
void load()
|
||||
{
|
||||
code = 0;
|
||||
for( int i = 0; i < 5; ++i ) code = (code << 8) | get_byte();
|
||||
range = 0xFFFFFFFFU;
|
||||
code &= range; // make sure that first byte is discarded
|
||||
}
|
||||
|
||||
|
@ -198,11 +200,14 @@ class LZ_mtester
|
|||
unsigned pos; // current pos in buffer
|
||||
unsigned stream_pos; // first byte not yet written to file
|
||||
uint32_t crc_;
|
||||
const int outfd; // output file descriptor
|
||||
unsigned rep0; // rep[0-3] latest four distances
|
||||
unsigned rep1; // used for efficient coding of
|
||||
unsigned rep2; // repeated distances
|
||||
unsigned rep3;
|
||||
State state;
|
||||
unsigned max_rep0; // maximum distance found
|
||||
bool pos_wrapped;
|
||||
|
||||
Bit_model bm_literal[1<<literal_context_bits][0x300];
|
||||
Bit_model bm_match[State::states][pos_states];
|
||||
|
@ -267,7 +272,7 @@ class LZ_mtester
|
|||
|
||||
public:
|
||||
LZ_mtester( const uint8_t * const ibuf, const long ibuf_size,
|
||||
const int dict_size )
|
||||
const unsigned dict_size, const int ofd = -1 )
|
||||
:
|
||||
partial_data_pos( 0 ),
|
||||
rdec( ibuf, ibuf_size ),
|
||||
|
@ -276,10 +281,13 @@ public:
|
|||
pos( 0 ),
|
||||
stream_pos( 0 ),
|
||||
crc_( 0xFFFFFFFFU ),
|
||||
outfd( ofd ),
|
||||
rep0( 0 ),
|
||||
rep1( 0 ),
|
||||
rep2( 0 ),
|
||||
rep3( 0 )
|
||||
rep3( 0 ),
|
||||
max_rep0( 0 ),
|
||||
pos_wrapped( false )
|
||||
{ buffer[dictionary_size-1] = 0; } // prev_byte of first byte
|
||||
|
||||
~LZ_mtester() { delete[] buffer; }
|
||||
|
@ -287,12 +295,13 @@ public:
|
|||
unsigned crc() const { return crc_ ^ 0xFFFFFFFFU; }
|
||||
unsigned long long data_position() const { return partial_data_pos + pos; }
|
||||
bool finished() { return rdec.finished(); }
|
||||
long member_position() const { return rdec.member_position(); }
|
||||
unsigned long member_position() const { return rdec.member_position(); }
|
||||
unsigned max_distance() const { return max_rep0 + 1; }
|
||||
|
||||
void duplicate_buffer();
|
||||
int test_member( const long pos_limit = LONG_MAX );
|
||||
int test_member( const unsigned long pos_limit = LONG_MAX ); // sets max_rep0
|
||||
int debug_decode_member( const long long dpos, const long long mpos,
|
||||
const bool show_packets );
|
||||
const bool show_packets ); // sets max_rep0
|
||||
};
|
||||
|
||||
|
||||
|
@ -300,5 +309,6 @@ uint8_t * read_member( const int infd, const long long mpos,
|
|||
const long long msize );
|
||||
const LZ_mtester * prepare_master( const uint8_t * const buffer,
|
||||
const long buffer_size,
|
||||
const long pos_limit );
|
||||
const unsigned long pos_limit,
|
||||
const unsigned dictionary_size );
|
||||
bool test_member_rest( const LZ_mtester & master, long * const failure_posp = 0 );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue