Merging upstream version 1.5~rc1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
0384b57edf
commit
81ec456584
21 changed files with 318 additions and 279 deletions
2
AUTHORS
2
AUTHORS
|
@ -4,4 +4,4 @@ The ideas embodied in lzlib are due to (at least) the following people:
|
||||||
Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrey Markov (for
|
Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrey Markov (for
|
||||||
the definition of Markov chains), G.N.N. Martin (for the definition of
|
the definition of Markov chains), G.N.N. Martin (for the definition of
|
||||||
range encoding), Igor Pavlov (for putting all the above together in
|
range encoding), Igor Pavlov (for putting all the above together in
|
||||||
LZMA), and Julian Seward (for bzip2's CLI and the idea of unzcrash).
|
LZMA), and Julian Seward (for bzip2's CLI).
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
2013-07-28 Antonio Diaz Diaz <antonio@gnu.org>
|
||||||
|
|
||||||
|
* Version 1.5-rc1 released.
|
||||||
|
* Removed decompression support for version 0 files.
|
||||||
|
* The LZ_compress_sync_flush mechanism has been fixed (again).
|
||||||
|
* Minor fixes.
|
||||||
|
|
||||||
2013-05-28 Antonio Diaz Diaz <antonio@gnu.org>
|
2013-05-28 Antonio Diaz Diaz <antonio@gnu.org>
|
||||||
|
|
||||||
* Version 1.4 released.
|
* Version 1.4 released.
|
||||||
|
|
6
INSTALL
6
INSTALL
|
@ -1,7 +1,7 @@
|
||||||
Requirements
|
Requirements
|
||||||
------------
|
------------
|
||||||
You will need a C compiler.
|
You will need a C compiler.
|
||||||
I use gcc 4.8.0 and 3.3.6, but the code should compile with any
|
I use gcc 4.8.1 and 3.3.6, but the code should compile with any
|
||||||
standards compliant compiler.
|
standards compliant compiler.
|
||||||
Gcc is available at http://gcc.gnu.org.
|
Gcc is available at http://gcc.gnu.org.
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ Procedure
|
||||||
---------
|
---------
|
||||||
1. Unpack the archive if you have not done so already:
|
1. Unpack the archive if you have not done so already:
|
||||||
|
|
||||||
lzip -cd lzlib[version].tar.lz | tar -xf -
|
tar -xf lzlib[version].tar.lz
|
||||||
or
|
or
|
||||||
gzip -cd lzlib[version].tar.gz | tar -xf -
|
lzip -cd lzlib[version].tar.lz | tar -xf -
|
||||||
|
|
||||||
This creates the directory ./lzlib[version] containing the source from
|
This creates the directory ./lzlib[version] containing the source from
|
||||||
the main archive.
|
the main archive.
|
||||||
|
|
23
NEWS
23
NEWS
|
@ -1,21 +1,8 @@
|
||||||
Changes in version 1.4:
|
Changes in version 1.5:
|
||||||
|
|
||||||
Multi-step trials have been implemented.
|
Decompression support for deprecated version 0 files has been removed.
|
||||||
|
|
||||||
Compression ratio has been slightly increased.
|
A bug has been fixed that would make an instance of "struct LZ_Encoder"
|
||||||
|
unresponsive if "LZ_compress_sync_flush" is called at the wrong moment.
|
||||||
|
|
||||||
Compression time has been reduced by 8%.
|
Minor fixes.
|
||||||
|
|
||||||
Decompression time has been reduced by 7%.
|
|
||||||
|
|
||||||
Arguments and return values of functions in lzlib.h have been changed
|
|
||||||
from 'long long' to 'unsigned long long'.
|
|
||||||
|
|
||||||
The minimum size of the input compression buffer has been reduced to 64KiB.
|
|
||||||
|
|
||||||
"LZ_decompress_read" now tells "LZ_header_error" from "LZ_unexpected_eof"
|
|
||||||
the same way as lzip does when the EOF happens at the header.
|
|
||||||
|
|
||||||
The target "install-as-lzip" has been added to the Makefile.
|
|
||||||
|
|
||||||
The target "install-bin" has been added to the Makefile.
|
|
||||||
|
|
19
README
19
README
|
@ -5,6 +5,10 @@ and decompression functions, including integrity checking of the
|
||||||
decompressed data. The compressed data format used by the library is the
|
decompressed data. The compressed data format used by the library is the
|
||||||
lzip format. Lzlib is written in C.
|
lzip format. Lzlib is written in C.
|
||||||
|
|
||||||
|
The lzip file format is designed for long-term data archiving. It is
|
||||||
|
clean, provides very safe 4 factor integrity checking, and is backed by
|
||||||
|
the recovery capabilities of lziprecover.
|
||||||
|
|
||||||
The functions and variables forming the interface of the compression
|
The functions and variables forming the interface of the compression
|
||||||
library are declared in the file lzlib.h. Usage examples of the library
|
library are declared in the file lzlib.h. Usage examples of the library
|
||||||
are given in the files main.c and bbexample.c from the source
|
are given in the files main.c and bbexample.c from the source
|
||||||
|
@ -31,9 +35,18 @@ any signal handler. The decoder checks the consistency of the compressed
|
||||||
data, so the library should never crash even in case of corrupted input.
|
data, so the library should never crash even in case of corrupted input.
|
||||||
|
|
||||||
Lzlib implements a simplified version of the LZMA (Lempel-Ziv-Markov
|
Lzlib implements a simplified version of the LZMA (Lempel-Ziv-Markov
|
||||||
chain-Algorithm) algorithm. The original LZMA algorithm was designed by
|
chain-Algorithm) algorithm. The high compression of LZMA comes from
|
||||||
Igor Pavlov. For a description of the LZMA algorithm, see the Lzip
|
combining two basic, well-proven compression ideas: sliding dictionaries
|
||||||
manual.
|
(LZ77/78) and markov models (the thing used by every compression
|
||||||
|
algorithm that uses a range encoder or similar order-0 entropy coder as
|
||||||
|
its last stage) with segregation of contexts according to what the bits
|
||||||
|
are used for.
|
||||||
|
|
||||||
|
The ideas embodied in lzlib are due to (at least) the following people:
|
||||||
|
Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrey Markov (for
|
||||||
|
the definition of Markov chains), G.N.N. Martin (for the definition of
|
||||||
|
range encoding), Igor Pavlov (for putting all the above together in
|
||||||
|
LZMA), and Julian Seward (for bzip2's CLI).
|
||||||
|
|
||||||
|
|
||||||
Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Buff to buff example - A test program for the lzlib library
|
/* Buff to buff example - Test program for the lzlib library
|
||||||
Copyright (C) 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
Copyright (C) 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This program is free software: you have unlimited permission
|
This program is free software: you have unlimited permission
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Lzlib - A compression library for lzip files
|
/* Lzlib - Compression library for lzip files
|
||||||
Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This library is free software: you can redistribute it and/or modify
|
This library is free software: you can redistribute it and/or modify
|
||||||
|
|
18
configure
vendored
18
configure
vendored
|
@ -1,17 +1,17 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# configure script for Lzlib - A compression library for lzip files
|
# configure script for Lzlib - Compression library for lzip files
|
||||||
# Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
# Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
||||||
#
|
#
|
||||||
# This configure script is free software: you have unlimited permission
|
# This configure script is free software: you have unlimited permission
|
||||||
# to copy, distribute and modify it.
|
# to copy, distribute and modify it.
|
||||||
|
|
||||||
pkgname=lzlib
|
pkgname=lzlib
|
||||||
pkgversion=1.4
|
pkgversion=1.5-rc1
|
||||||
soversion=1
|
soversion=1
|
||||||
progname=minilzip
|
progname=minilzip
|
||||||
progname_shared=
|
progname_shared=
|
||||||
libname=lz
|
libname=lz
|
||||||
srctrigger=${libname}lib.h
|
srctrigger=doc/${pkgname}.texinfo
|
||||||
|
|
||||||
# clear some things potentially inherited from environment.
|
# clear some things potentially inherited from environment.
|
||||||
LC_ALL=C
|
LC_ALL=C
|
||||||
|
@ -113,14 +113,14 @@ while [ $# != 0 ] ; do
|
||||||
*=* | *-*-*) ;;
|
*=* | *-*-*) ;;
|
||||||
*)
|
*)
|
||||||
echo "configure: unrecognized option: '${option}'" 1>&2
|
echo "configure: unrecognized option: '${option}'" 1>&2
|
||||||
echo "Try 'configure --help' for more information."
|
echo "Try 'configure --help' for more information." 1>&2
|
||||||
exit 1 ;;
|
exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Check if the option took a separate argument
|
# Check if the option took a separate argument
|
||||||
if [ "${arg2}" = yes ] ; then
|
if [ "${arg2}" = yes ] ; then
|
||||||
if [ $# != 0 ] ; then args="${args} \"$1\"" ; shift
|
if [ $# != 0 ] ; then args="${args} \"$1\"" ; shift
|
||||||
else echo "configure: Missing argument to \"${option}\"" 1>&2
|
else echo "configure: Missing argument to '${option}'" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -138,10 +138,8 @@ if [ -z "${srcdir}" ] ; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -r "${srcdir}/${srctrigger}" ] ; then
|
if [ ! -r "${srcdir}/${srctrigger}" ] ; then
|
||||||
exec 1>&2
|
echo "configure: Can't find sources in ${srcdir} ${srcdirtext}" 1>&2
|
||||||
echo
|
echo "configure: (At least ${srctrigger} is missing)." 1>&2
|
||||||
echo "configure: Can't find sources in ${srcdir} ${srcdirtext}"
|
|
||||||
echo "configure: (At least ${srctrigger} is missing)."
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -181,7 +179,7 @@ echo "CFLAGS = ${CFLAGS}"
|
||||||
echo "LDFLAGS = ${LDFLAGS}"
|
echo "LDFLAGS = ${LDFLAGS}"
|
||||||
rm -f Makefile
|
rm -f Makefile
|
||||||
cat > Makefile << EOF
|
cat > Makefile << EOF
|
||||||
# Makefile for Lzlib - A compression library for lzip files
|
# Makefile for Lzlib - Compression library for lzip files
|
||||||
# Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
# Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
||||||
# This file was generated automatically by configure. Do not edit.
|
# This file was generated automatically by configure. Do not edit.
|
||||||
#
|
#
|
||||||
|
|
57
decoder.c
57
decoder.c
|
@ -1,4 +1,4 @@
|
||||||
/* Lzlib - A compression library for lzip files
|
/* Lzlib - Compression library for lzip files
|
||||||
Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This library is free software: you can redistribute it and/or modify
|
This library is free software: you can redistribute it and/or modify
|
||||||
|
@ -28,16 +28,13 @@
|
||||||
static bool LZd_verify_trailer( struct LZ_decoder * const decoder )
|
static bool LZd_verify_trailer( struct LZ_decoder * const decoder )
|
||||||
{
|
{
|
||||||
File_trailer trailer;
|
File_trailer trailer;
|
||||||
const int trailer_size = Ft_versioned_size( decoder->member_version );
|
|
||||||
const unsigned long long member_size =
|
const unsigned long long member_size =
|
||||||
decoder->rdec->member_position + trailer_size;
|
decoder->rdec->member_position + Ft_size;
|
||||||
|
|
||||||
int size = Rd_read_data( decoder->rdec, trailer, trailer_size );
|
int size = Rd_read_data( decoder->rdec, trailer, Ft_size );
|
||||||
if( size < trailer_size )
|
if( size < Ft_size )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( decoder->member_version == 0 ) Ft_set_member_size( trailer, member_size );
|
|
||||||
|
|
||||||
return ( decoder->rdec->code == 0 &&
|
return ( decoder->rdec->code == 0 &&
|
||||||
Ft_get_data_crc( trailer ) == LZd_crc( decoder ) &&
|
Ft_get_data_crc( trailer ) == LZd_crc( decoder ) &&
|
||||||
Ft_get_data_size( trailer ) == LZd_data_position( decoder ) &&
|
Ft_get_data_size( trailer ) == LZd_data_position( decoder ) &&
|
||||||
|
@ -49,38 +46,39 @@ static bool LZd_verify_trailer( struct LZ_decoder * const decoder )
|
||||||
3 = trailer error, 4 = unknown marker found. */
|
3 = trailer error, 4 = unknown marker found. */
|
||||||
static int LZd_decode_member( struct LZ_decoder * const decoder )
|
static int LZd_decode_member( struct LZ_decoder * const decoder )
|
||||||
{
|
{
|
||||||
|
struct Range_decoder * const rdec = decoder->rdec;
|
||||||
State * const state = &decoder->state;
|
State * const state = &decoder->state;
|
||||||
|
|
||||||
if( decoder->member_finished ) return 0;
|
if( decoder->member_finished ) return 0;
|
||||||
if( !Rd_try_reload( decoder->rdec, false ) ) return 0;
|
if( !Rd_try_reload( rdec, false ) ) return 0;
|
||||||
if( decoder->verify_trailer_pending )
|
if( decoder->verify_trailer_pending )
|
||||||
{
|
{
|
||||||
if( Rd_available_bytes( decoder->rdec ) < Ft_versioned_size( decoder->member_version ) &&
|
if( Rd_available_bytes( rdec ) < Ft_size && !rdec->at_stream_end )
|
||||||
!decoder->rdec->at_stream_end )
|
|
||||||
return 0;
|
return 0;
|
||||||
decoder->verify_trailer_pending = false;
|
decoder->verify_trailer_pending = false;
|
||||||
decoder->member_finished = true;
|
decoder->member_finished = true;
|
||||||
if( LZd_verify_trailer( decoder ) ) return 0; else return 3;
|
if( LZd_verify_trailer( decoder ) ) return 0; else return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
while( !Rd_finished( decoder->rdec ) )
|
while( !Rd_finished( rdec ) )
|
||||||
{
|
{
|
||||||
const int pos_state = LZd_data_position( decoder ) & pos_state_mask;
|
const int pos_state = LZd_data_position( decoder ) & pos_state_mask;
|
||||||
if( !Rd_enough_available_bytes( decoder->rdec ) ||
|
if( !Rd_enough_available_bytes( rdec ) ||
|
||||||
!LZd_enough_free_bytes( decoder ) )
|
!LZd_enough_free_bytes( decoder ) )
|
||||||
return 0;
|
return 0;
|
||||||
if( Rd_decode_bit( decoder->rdec, &decoder->bm_match[*state][pos_state] ) == 0 ) /* 1st bit */
|
if( Rd_decode_bit( rdec, &decoder->bm_match[*state][pos_state] ) == 0 ) /* 1st bit */
|
||||||
{
|
{
|
||||||
const uint8_t prev_byte = LZd_get_prev_byte( decoder );
|
const uint8_t prev_byte = LZd_get_prev_byte( decoder );
|
||||||
if( St_is_char( *state ) )
|
if( St_is_char( *state ) )
|
||||||
{
|
{
|
||||||
*state -= ( *state < 4 ) ? *state : 3;
|
*state -= ( *state < 4 ) ? *state : 3;
|
||||||
LZd_put_byte( decoder, Rd_decode_tree( decoder->rdec,
|
LZd_put_byte( decoder, Rd_decode_tree( rdec,
|
||||||
decoder->bm_literal[get_lit_state(prev_byte)], 8 ) );
|
decoder->bm_literal[get_lit_state(prev_byte)], 8 ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*state -= ( *state < 10 ) ? 3 : 6;
|
*state -= ( *state < 10 ) ? 3 : 6;
|
||||||
LZd_put_byte( decoder, Rd_decode_matched( decoder->rdec,
|
LZd_put_byte( decoder, Rd_decode_matched( rdec,
|
||||||
decoder->bm_literal[get_lit_state(prev_byte)],
|
decoder->bm_literal[get_lit_state(prev_byte)],
|
||||||
LZd_get_byte( decoder, decoder->rep0 ) ) );
|
LZd_get_byte( decoder, decoder->rep0 ) ) );
|
||||||
}
|
}
|
||||||
|
@ -88,22 +86,22 @@ static int LZd_decode_member( struct LZ_decoder * const decoder )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
if( Rd_decode_bit( decoder->rdec, &decoder->bm_rep[*state] ) == 1 ) /* 2nd bit */
|
if( Rd_decode_bit( rdec, &decoder->bm_rep[*state] ) == 1 ) /* 2nd bit */
|
||||||
{
|
{
|
||||||
if( Rd_decode_bit( decoder->rdec, &decoder->bm_rep0[*state] ) == 0 ) /* 3rd bit */
|
if( Rd_decode_bit( rdec, &decoder->bm_rep0[*state] ) == 0 ) /* 3rd bit */
|
||||||
{
|
{
|
||||||
if( Rd_decode_bit( decoder->rdec, &decoder->bm_len[*state][pos_state] ) == 0 ) /* 4th bit */
|
if( Rd_decode_bit( rdec, &decoder->bm_len[*state][pos_state] ) == 0 ) /* 4th bit */
|
||||||
{ *state = St_set_short_rep( *state );
|
{ *state = St_set_short_rep( *state );
|
||||||
LZd_put_byte( decoder, LZd_get_byte( decoder, decoder->rep0 ) ); continue; }
|
LZd_put_byte( decoder, LZd_get_byte( decoder, decoder->rep0 ) ); continue; }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned distance;
|
unsigned distance;
|
||||||
if( Rd_decode_bit( decoder->rdec, &decoder->bm_rep1[*state] ) == 0 ) /* 4th bit */
|
if( Rd_decode_bit( rdec, &decoder->bm_rep1[*state] ) == 0 ) /* 4th bit */
|
||||||
distance = decoder->rep1;
|
distance = decoder->rep1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( Rd_decode_bit( decoder->rdec, &decoder->bm_rep2[*state] ) == 0 ) /* 5th bit */
|
if( Rd_decode_bit( rdec, &decoder->bm_rep2[*state] ) == 0 ) /* 5th bit */
|
||||||
distance = decoder->rep2;
|
distance = decoder->rep2;
|
||||||
else
|
else
|
||||||
{ distance = decoder->rep3; decoder->rep3 = decoder->rep2; }
|
{ distance = decoder->rep3; decoder->rep3 = decoder->rep2; }
|
||||||
|
@ -113,42 +111,41 @@ static int LZd_decode_member( struct LZ_decoder * const decoder )
|
||||||
decoder->rep0 = distance;
|
decoder->rep0 = distance;
|
||||||
}
|
}
|
||||||
*state = St_set_rep( *state );
|
*state = St_set_rep( *state );
|
||||||
len = min_match_len + Rd_decode_len( decoder->rdec, &decoder->rep_len_model, pos_state );
|
len = min_match_len + Rd_decode_len( rdec, &decoder->rep_len_model, pos_state );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int dis_slot;
|
int dis_slot;
|
||||||
const unsigned rep0_saved = decoder->rep0;
|
const unsigned rep0_saved = decoder->rep0;
|
||||||
len = min_match_len + Rd_decode_len( decoder->rdec, &decoder->match_len_model, pos_state );
|
len = min_match_len + Rd_decode_len( rdec, &decoder->match_len_model, pos_state );
|
||||||
dis_slot = Rd_decode_tree6( decoder->rdec, decoder->bm_dis_slot[get_dis_state(len)] );
|
dis_slot = Rd_decode_tree6( rdec, decoder->bm_dis_slot[get_dis_state(len)] );
|
||||||
if( dis_slot < start_dis_model ) decoder->rep0 = dis_slot;
|
if( dis_slot < start_dis_model ) decoder->rep0 = dis_slot;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const int direct_bits = ( dis_slot >> 1 ) - 1;
|
const int direct_bits = ( dis_slot >> 1 ) - 1;
|
||||||
decoder->rep0 = ( 2 | ( dis_slot & 1 ) ) << direct_bits;
|
decoder->rep0 = ( 2 | ( dis_slot & 1 ) ) << direct_bits;
|
||||||
if( dis_slot < end_dis_model )
|
if( dis_slot < end_dis_model )
|
||||||
decoder->rep0 += Rd_decode_tree_reversed( decoder->rdec,
|
decoder->rep0 += Rd_decode_tree_reversed( rdec,
|
||||||
decoder->bm_dis + decoder->rep0 - dis_slot - 1,
|
decoder->bm_dis + decoder->rep0 - dis_slot - 1,
|
||||||
direct_bits );
|
direct_bits );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
decoder->rep0 += Rd_decode( decoder->rdec, direct_bits - dis_align_bits ) << dis_align_bits;
|
decoder->rep0 += Rd_decode( rdec, direct_bits - dis_align_bits ) << dis_align_bits;
|
||||||
decoder->rep0 += Rd_decode_tree_reversed4( decoder->rdec, decoder->bm_align );
|
decoder->rep0 += Rd_decode_tree_reversed4( rdec, decoder->bm_align );
|
||||||
if( decoder->rep0 == 0xFFFFFFFFU ) /* Marker found */
|
if( decoder->rep0 == 0xFFFFFFFFU ) /* Marker found */
|
||||||
{
|
{
|
||||||
decoder->rep0 = rep0_saved;
|
decoder->rep0 = rep0_saved;
|
||||||
Rd_normalize( decoder->rdec );
|
Rd_normalize( rdec );
|
||||||
if( len == min_match_len ) /* End Of Stream marker */
|
if( len == min_match_len ) /* End Of Stream marker */
|
||||||
{
|
{
|
||||||
if( Rd_available_bytes( decoder->rdec ) < Ft_versioned_size( decoder->member_version ) &&
|
if( Rd_available_bytes( rdec ) < Ft_size && !rdec->at_stream_end )
|
||||||
!decoder->rdec->at_stream_end )
|
|
||||||
{ decoder->verify_trailer_pending = true; return 0; }
|
{ decoder->verify_trailer_pending = true; return 0; }
|
||||||
decoder->member_finished = true;
|
decoder->member_finished = true;
|
||||||
if( LZd_verify_trailer( decoder ) ) return 0; else return 3;
|
if( LZd_verify_trailer( decoder ) ) return 0; else return 3;
|
||||||
}
|
}
|
||||||
if( len == min_match_len + 1 ) /* Sync Flush marker */
|
if( len == min_match_len + 1 ) /* Sync Flush marker */
|
||||||
{
|
{
|
||||||
if( Rd_try_reload( decoder->rdec, true ) ) continue;
|
if( Rd_try_reload( rdec, true ) ) continue;
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
return 4;
|
return 4;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Lzlib - A compression library for lzip files
|
/* Lzlib - Compression library for lzip files
|
||||||
Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This library is free software: you can redistribute it and/or modify
|
This library is free software: you can redistribute it and/or modify
|
||||||
|
@ -33,8 +33,8 @@ struct Range_decoder
|
||||||
unsigned long long member_position;
|
unsigned long long member_position;
|
||||||
uint32_t code;
|
uint32_t code;
|
||||||
uint32_t range;
|
uint32_t range;
|
||||||
bool reload_pending;
|
|
||||||
bool at_stream_end;
|
bool at_stream_end;
|
||||||
|
bool reload_pending;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline bool Rd_init( struct Range_decoder * const rdec )
|
static inline bool Rd_init( struct Range_decoder * const rdec )
|
||||||
|
@ -43,8 +43,8 @@ static inline bool Rd_init( struct Range_decoder * const rdec )
|
||||||
rdec->member_position = 0;
|
rdec->member_position = 0;
|
||||||
rdec->code = 0;
|
rdec->code = 0;
|
||||||
rdec->range = 0xFFFFFFFFU;
|
rdec->range = 0xFFFFFFFFU;
|
||||||
rdec->reload_pending = false;
|
|
||||||
rdec->at_stream_end = false;
|
rdec->at_stream_end = false;
|
||||||
|
rdec->reload_pending = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +311,6 @@ struct LZ_decoder
|
||||||
unsigned long long partial_data_pos;
|
unsigned long long partial_data_pos;
|
||||||
int dictionary_size;
|
int dictionary_size;
|
||||||
uint32_t crc;
|
uint32_t crc;
|
||||||
int member_version;
|
|
||||||
bool member_finished;
|
bool member_finished;
|
||||||
bool verify_trailer_pending;
|
bool verify_trailer_pending;
|
||||||
unsigned rep0; /* rep[0-3] latest four distances */
|
unsigned rep0; /* rep[0-3] latest four distances */
|
||||||
|
@ -391,7 +390,6 @@ static inline bool LZd_init( struct LZ_decoder * const decoder,
|
||||||
return false;
|
return false;
|
||||||
decoder->partial_data_pos = 0;
|
decoder->partial_data_pos = 0;
|
||||||
decoder->crc = 0xFFFFFFFFU;
|
decoder->crc = 0xFFFFFFFFU;
|
||||||
decoder->member_version = Fh_version( header );
|
|
||||||
decoder->member_finished = false;
|
decoder->member_finished = false;
|
||||||
decoder->verify_trailer_pending = false;
|
decoder->verify_trailer_pending = false;
|
||||||
decoder->rep0 = 0;
|
decoder->rep0 = 0;
|
||||||
|
|
125
doc/lzlib.info
125
doc/lzlib.info
|
@ -3,7 +3,7 @@ lzlib.texinfo.
|
||||||
|
|
||||||
INFO-DIR-SECTION Data Compression
|
INFO-DIR-SECTION Data Compression
|
||||||
START-INFO-DIR-ENTRY
|
START-INFO-DIR-ENTRY
|
||||||
* Lzlib: (lzlib). A compression library for lzip files
|
* Lzlib: (lzlib). Compression library for lzip files
|
||||||
END-INFO-DIR-ENTRY
|
END-INFO-DIR-ENTRY
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,22 +12,22 @@ File: lzlib.info, Node: Top, Next: Introduction, Up: (dir)
|
||||||
Lzlib Manual
|
Lzlib Manual
|
||||||
************
|
************
|
||||||
|
|
||||||
This manual is for Lzlib (version 1.4, 28 May 2013).
|
This manual is for Lzlib (version 1.5-rc1, 28 July 2013).
|
||||||
|
|
||||||
* Menu:
|
* Menu:
|
||||||
|
|
||||||
* Introduction:: Purpose and features of Lzlib
|
* Introduction:: Purpose and features of Lzlib
|
||||||
* Library Version:: Checking library version
|
* Library version:: Checking library version
|
||||||
* Buffering:: Sizes of Lzlib's buffers
|
* Buffering:: Sizes of Lzlib's buffers
|
||||||
* Parameter Limits:: Min / max values for some parameters
|
* Parameter limits:: Min / max values for some parameters
|
||||||
* Compression Functions:: Descriptions of the compression functions
|
* Compression functions:: Descriptions of the compression functions
|
||||||
* Decompression Functions:: Descriptions of the decompression functions
|
* Decompression functions:: Descriptions of the decompression functions
|
||||||
* Error Codes:: Meaning of codes returned by functions
|
* Error codes:: Meaning of codes returned by functions
|
||||||
* Error Messages:: Error messages corresponding to error codes
|
* Error messages:: Error messages corresponding to error codes
|
||||||
* Data Format:: Detailed format of the compressed data
|
* Data format:: Detailed format of the compressed data
|
||||||
* Examples:: A small tutorial with examples
|
* Examples:: A small tutorial with examples
|
||||||
* Problems:: Reporting bugs
|
* Problems:: Reporting bugs
|
||||||
* Concept Index:: Index of concepts
|
* Concept index:: Index of concepts
|
||||||
|
|
||||||
|
|
||||||
Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
||||||
|
@ -36,7 +36,7 @@ This manual is for Lzlib (version 1.4, 28 May 2013).
|
||||||
copy, distribute and modify it.
|
copy, distribute and modify it.
|
||||||
|
|
||||||
|
|
||||||
File: lzlib.info, Node: Introduction, Next: Library Version, Prev: Top, Up: Top
|
File: lzlib.info, Node: Introduction, Next: Library version, Prev: Top, Up: Top
|
||||||
|
|
||||||
1 Introduction
|
1 Introduction
|
||||||
**************
|
**************
|
||||||
|
@ -46,6 +46,10 @@ and decompression functions, including integrity checking of the
|
||||||
decompressed data. The compressed data format used by the library is the
|
decompressed data. The compressed data format used by the library is the
|
||||||
lzip format. Lzlib is written in C.
|
lzip format. Lzlib is written in C.
|
||||||
|
|
||||||
|
The lzip file format is designed for long-term data archiving. It is
|
||||||
|
clean, provides very safe 4 factor integrity checking, and is backed by
|
||||||
|
the recovery capabilities of lziprecover.
|
||||||
|
|
||||||
The functions and variables forming the interface of the compression
|
The functions and variables forming the interface of the compression
|
||||||
library are declared in the file `lzlib.h'. Usage examples of the
|
library are declared in the file `lzlib.h'. Usage examples of the
|
||||||
library are given in the files `main.c' and `bbexample.c' from the
|
library are given in the files `main.c' and `bbexample.c' from the
|
||||||
|
@ -73,14 +77,23 @@ compressed data, so the library should never crash even in case of
|
||||||
corrupted input.
|
corrupted input.
|
||||||
|
|
||||||
Lzlib implements a simplified version of the LZMA (Lempel-Ziv-Markov
|
Lzlib implements a simplified version of the LZMA (Lempel-Ziv-Markov
|
||||||
chain-Algorithm) algorithm. The original LZMA algorithm was designed by
|
chain-Algorithm) algorithm. The high compression of LZMA comes from
|
||||||
Igor Pavlov. For a description of the LZMA algorithm, see the Lzip
|
combining two basic, well-proven compression ideas: sliding dictionaries
|
||||||
manual.
|
(LZ77/78) and markov models (the thing used by every compression
|
||||||
|
algorithm that uses a range encoder or similar order-0 entropy coder as
|
||||||
|
its last stage) with segregation of contexts according to what the bits
|
||||||
|
are used for.
|
||||||
|
|
||||||
|
The ideas embodied in lzlib are due to (at least) the following
|
||||||
|
people: Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrey
|
||||||
|
Markov (for the definition of Markov chains), G.N.N. Martin (for the
|
||||||
|
definition of range encoding), Igor Pavlov (for putting all the above
|
||||||
|
together in LZMA), and Julian Seward (for bzip2's CLI).
|
||||||
|
|
||||||
|
|
||||||
File: lzlib.info, Node: Library Version, Next: Buffering, Prev: Introduction, Up: Top
|
File: lzlib.info, Node: Library version, Next: Buffering, Prev: Introduction, Up: Top
|
||||||
|
|
||||||
2 Library Version
|
2 Library version
|
||||||
*****************
|
*****************
|
||||||
|
|
||||||
-- Function: const char * LZ_version ( void )
|
-- Function: const char * LZ_version ( void )
|
||||||
|
@ -98,7 +111,7 @@ application.
|
||||||
error( "bad library version" );
|
error( "bad library version" );
|
||||||
|
|
||||||
|
|
||||||
File: lzlib.info, Node: Buffering, Next: Parameter Limits, Prev: Library Version, Up: Top
|
File: lzlib.info, Node: Buffering, Next: Parameter limits, Prev: Library version, Up: Top
|
||||||
|
|
||||||
3 Buffering
|
3 Buffering
|
||||||
***********
|
***********
|
||||||
|
@ -126,9 +139,9 @@ minimum sizes:
|
||||||
member currently being decompressed or 64KiB, whichever is larger.
|
member currently being decompressed or 64KiB, whichever is larger.
|
||||||
|
|
||||||
|
|
||||||
File: lzlib.info, Node: Parameter Limits, Next: Compression Functions, Prev: Buffering, Up: Top
|
File: lzlib.info, Node: Parameter limits, Next: Compression functions, Prev: Buffering, Up: Top
|
||||||
|
|
||||||
4 Parameter Limits
|
4 Parameter limits
|
||||||
******************
|
******************
|
||||||
|
|
||||||
These functions provide minimum and maximum values for some parameters.
|
These functions provide minimum and maximum values for some parameters.
|
||||||
|
@ -155,9 +168,9 @@ Current values are shown in square brackets.
|
||||||
Returns the largest valid match length limit [273].
|
Returns the largest valid match length limit [273].
|
||||||
|
|
||||||
|
|
||||||
File: lzlib.info, Node: Compression Functions, Next: Decompression Functions, Prev: Parameter Limits, Up: Top
|
File: lzlib.info, Node: Compression functions, Next: Decompression functions, Prev: Parameter limits, Up: Top
|
||||||
|
|
||||||
5 Compression Functions
|
5 Compression functions
|
||||||
***********************
|
***********************
|
||||||
|
|
||||||
These are the functions used to compress data. In case of error, all of
|
These are the functions used to compress data. In case of error, all of
|
||||||
|
@ -254,7 +267,7 @@ calling `LZ_compress_errno' before using it.
|
||||||
|
|
||||||
-- Function: enum LZ_Errno LZ_compress_errno ( struct LZ_Encoder *
|
-- Function: enum LZ_Errno LZ_compress_errno ( struct LZ_Encoder *
|
||||||
const ENCODER )
|
const ENCODER )
|
||||||
Returns the current error code for ENCODER (*note Error Codes::).
|
Returns the current error code for ENCODER (*note Error codes::).
|
||||||
|
|
||||||
-- Function: int LZ_compress_finished ( struct LZ_Encoder * const
|
-- Function: int LZ_compress_finished ( struct LZ_Encoder * const
|
||||||
ENCODER )
|
ENCODER )
|
||||||
|
@ -287,9 +300,9 @@ calling `LZ_compress_errno' before using it.
|
||||||
perhaps not yet read.
|
perhaps not yet read.
|
||||||
|
|
||||||
|
|
||||||
File: lzlib.info, Node: Decompression Functions, Next: Error Codes, Prev: Compression Functions, Up: Top
|
File: lzlib.info, Node: Decompression functions, Next: Error codes, Prev: Compression functions, Up: Top
|
||||||
|
|
||||||
6 Decompression Functions
|
6 Decompression functions
|
||||||
*************************
|
*************************
|
||||||
|
|
||||||
These are the functions used to decompress data. In case of error, all
|
These are the functions used to decompress data. In case of error, all
|
||||||
|
@ -370,7 +383,7 @@ verified by calling `LZ_decompress_errno' before using it.
|
||||||
|
|
||||||
-- Function: enum LZ_Errno LZ_decompress_errno ( struct LZ_Decoder *
|
-- Function: enum LZ_Errno LZ_decompress_errno ( struct LZ_Decoder *
|
||||||
const DECODER )
|
const DECODER )
|
||||||
Returns the current error code for DECODER (*note Error Codes::).
|
Returns the current error code for DECODER (*note Error codes::).
|
||||||
|
|
||||||
-- Function: int LZ_decompress_finished ( struct LZ_Decoder * const
|
-- Function: int LZ_decompress_finished ( struct LZ_Decoder * const
|
||||||
DECODER )
|
DECODER )
|
||||||
|
@ -419,9 +432,9 @@ verified by calling `LZ_decompress_errno' before using it.
|
||||||
but perhaps not yet read.
|
but perhaps not yet read.
|
||||||
|
|
||||||
|
|
||||||
File: lzlib.info, Node: Error Codes, Next: Error Messages, Prev: Decompression Functions, Up: Top
|
File: lzlib.info, Node: Error codes, Next: Error messages, Prev: Decompression functions, Up: Top
|
||||||
|
|
||||||
7 Error Codes
|
7 Error codes
|
||||||
*************
|
*************
|
||||||
|
|
||||||
Most library functions return -1 to indicate that they have failed. But
|
Most library functions return -1 to indicate that they have failed. But
|
||||||
|
@ -471,9 +484,9 @@ whether a call failed. If the call failed, then you can examine
|
||||||
Problems::).
|
Problems::).
|
||||||
|
|
||||||
|
|
||||||
File: lzlib.info, Node: Error Messages, Next: Data Format, Prev: Error Codes, Up: Top
|
File: lzlib.info, Node: Error messages, Next: Data format, Prev: Error codes, Up: Top
|
||||||
|
|
||||||
8 Error Messages
|
8 Error messages
|
||||||
****************
|
****************
|
||||||
|
|
||||||
-- Function: const char * LZ_strerror ( const enum LZ_Errno LZ_ERRNO )
|
-- Function: const char * LZ_strerror ( const enum LZ_Errno LZ_ERRNO )
|
||||||
|
@ -487,9 +500,9 @@ File: lzlib.info, Node: Error Messages, Next: Data Format, Prev: Error Codes,
|
||||||
`LZ_(de)compress_errno'.
|
`LZ_(de)compress_errno'.
|
||||||
|
|
||||||
|
|
||||||
File: lzlib.info, Node: Data Format, Next: Examples, Prev: Error Messages, Up: Top
|
File: lzlib.info, Node: Data format, Next: Examples, Prev: Error messages, Up: Top
|
||||||
|
|
||||||
9 Data Format
|
9 Data format
|
||||||
*************
|
*************
|
||||||
|
|
||||||
Perfection is reached, not when there is no longer anything to add, but
|
Perfection is reached, not when there is no longer anything to add, but
|
||||||
|
@ -545,6 +558,8 @@ with no additional information before, between, or after them.
|
||||||
The lzma stream, finished by an end of stream marker. Uses default
|
The lzma stream, finished by an end of stream marker. Uses default
|
||||||
values for encoder properties. See the lzip manual for a full
|
values for encoder properties. See the lzip manual for a full
|
||||||
description.
|
description.
|
||||||
|
Lzip only uses the LZMA marker `2' ("End Of Stream" marker). Lzlib
|
||||||
|
also uses the LZMA marker `3' ("Sync Flush" marker).
|
||||||
|
|
||||||
`CRC32 (4 bytes)'
|
`CRC32 (4 bytes)'
|
||||||
CRC of the uncompressed original data.
|
CRC of the uncompressed original data.
|
||||||
|
@ -560,7 +575,7 @@ with no additional information before, between, or after them.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File: lzlib.info, Node: Examples, Next: Problems, Prev: Data Format, Up: Top
|
File: lzlib.info, Node: Examples, Next: Problems, Prev: Data format, Up: Top
|
||||||
|
|
||||||
10 A small tutorial with examples
|
10 A small tutorial with examples
|
||||||
*********************************
|
*********************************
|
||||||
|
@ -680,7 +695,7 @@ next member in case of data error.
|
||||||
7) LZ_decompress_close
|
7) LZ_decompress_close
|
||||||
|
|
||||||
|
|
||||||
File: lzlib.info, Node: Problems, Next: Concept Index, Prev: Examples, Up: Top
|
File: lzlib.info, Node: Problems, Next: Concept index, Prev: Examples, Up: Top
|
||||||
|
|
||||||
11 Reporting Bugs
|
11 Reporting Bugs
|
||||||
*****************
|
*****************
|
||||||
|
@ -696,9 +711,9 @@ by running `minilzip --version' or in `LZ_version_string' from
|
||||||
`lzlib.h'.
|
`lzlib.h'.
|
||||||
|
|
||||||
|
|
||||||
File: lzlib.info, Node: Concept Index, Prev: Problems, Up: Top
|
File: lzlib.info, Node: Concept index, Prev: Problems, Up: Top
|
||||||
|
|
||||||
Concept Index
|
Concept index
|
||||||
*************
|
*************
|
||||||
|
|
||||||
|