[WIP] Support zlib streams over 2 GB

Some of the method parameters
This commit is contained in:
Christian Schneider 2018-02-23 13:39:48 +01:00
parent 24d437878c
commit 17b146edfe
2 changed files with 10 additions and 10 deletions

View file

@ -2491,7 +2491,7 @@ void copy_penalty_bytes(long long& rek_penalty_bytes_len, bool& use_penalty_byte
}
#define DEF_COMPARE_CHUNK 512
int def_compare(FILE *compfile, int level, int windowbits, int memlevel, int& decompressed_bytes_used, int decompressed_bytes_total, bool in_memory) {
int def_compare(FILE *compfile, int level, int windowbits, int memlevel, int& decompressed_bytes_used, long long decompressed_bytes_total, bool in_memory) {
int ret, flush;
unsigned have;
z_stream strm;
@ -2517,13 +2517,13 @@ int def_compare(FILE *compfile, int level, int windowbits, int memlevel, int& de
bool use_penalty_bytes = false;
unsigned char* buf_ptr = decomp_io_buf;
int buf_pos = 0;
long long buf_pos = 0;
/* compress until end of file */
do {
print_work_sign(true);
if (in_memory) {
strm.avail_in = min(decompressed_bytes_total - buf_pos, DEF_COMPARE_CHUNK);
strm.avail_in = min((int)(decompressed_bytes_total - buf_pos), DEF_COMPARE_CHUNK);
strm.next_in = buf_ptr + buf_pos;
buf_pos += strm.avail_in;
flush = (buf_pos >= decompressed_bytes_total) ? Z_FINISH : Z_NO_FLUSH;
@ -3160,7 +3160,7 @@ int def_bzip2(FILE *source, FILE *dest, int level) {
return BZ_OK;
}
long long file_recompress(FILE* origfile, int compression_level, int windowbits, int memlevel, int& decompressed_bytes_used, int decompressed_bytes_total, bool in_memory) {
long long file_recompress(FILE* origfile, int compression_level, int windowbits, int memlevel, int& decompressed_bytes_used, long long decompressed_bytes_total, bool in_memory) {
long long retval;
if (!in_memory) {
@ -6201,7 +6201,7 @@ int try_to_decompress_bzip2(FILE* file, int compression_level, int& compressed_s
return r;
}
void try_recompress(FILE* origfile, int comp_level, int mem_level, int windowbits, int& compressed_stream_size, int decomp_bytes_total, bool in_memory) {
void try_recompress(FILE* origfile, int comp_level, int mem_level, int windowbits, int& compressed_stream_size, long long decomp_bytes_total, bool in_memory) {
print_work_sign(true);
identical_bytes = file_recompress(origfile, comp_level, windowbits, mem_level, identical_bytes_decomp, decomp_bytes_total, in_memory);
@ -6209,8 +6209,8 @@ void try_recompress(FILE* origfile, int comp_level, int mem_level, int windowbit
if ((identical_bytes > best_identical_bytes) || ((identical_bytes == best_identical_bytes) && (penalty_bytes_len < best_penalty_bytes_len))) {
if (identical_bytes > min_ident_size) {
if (DEBUG_MODE) {
printf("Identical recompressed bytes: %i of %i\n", identical_bytes, compressed_stream_size);
printf ("Identical decompressed bytes: %i of %i\n", identical_bytes_decomp, decomp_bytes_total);
cout << "Identical recompressed bytes: " << identical_bytes << " of " << compressed_stream_size << endl;
cout << "Identical decompressed bytes: " << identical_bytes_decomp << " of " << decomp_bytes_total << endl;
}
bool enough_identical_compressed_bytes = (identical_bytes == compressed_stream_size);

View file

@ -19,8 +19,8 @@ bool intense_mode_is_active();
bool brute_mode_is_active();
int inf_bzip2(FILE *source, FILE *dest);
int def_bzip2(FILE *source, FILE *dest, int level);
int file_recompress(FILE* origfile, int compression_level, int windowbits, int memlevel, int& decompressed_bytes_used, int decomp_bytes_total, bool in_memory);
int file_recompress_bzip2(FILE* origfile, int level, int& decompressed_bytes_used, int& decompressed_bytes_total);
long long file_recompress(FILE* origfile, int compression_level, int windowbits, int memlevel, int& decompressed_bytes_used, long long decomp_bytes_total, bool in_memory);
long long file_recompress_bzip2(FILE* origfile, int level, int& decompressed_bytes_used, int& decompressed_bytes_total);
void write_decompressed_data(long long byte_count, char* decompressed_file_name = tempfile1);
void write_decompressed_data_io_buf(long long byte_count, bool in_memory, char* decompressed_file_name = tempfile1);
unsigned int compare_files(FILE* file1, FILE* file2, unsigned int pos1, unsigned int pos2);
@ -60,7 +60,7 @@ void decompress_file();
void convert_file();
int try_to_decompress(FILE* file, int windowbits, int& compressed_stream_size, bool& in_memory);
int try_to_decompress_bzip2(FILE* file, int compression_level, int& compressed_stream_size);
void try_recompress(FILE* origfile, int comp_level, int mem_level, int windowbits, int& compressed_stream_size, int decomp_bytes_total, bool in_memory);
void try_recompress(FILE* origfile, int comp_level, int mem_level, int windowbits, int& compressed_stream_size, long long decomp_bytes_total, bool in_memory);
void try_recompress_bzip2(FILE* origfile, int level, int& compressed_stream_size);
void write_header();
void read_header();