blib/lib/Compress/LZV1.pm

filter: Statementstmt 100% 7 / 7 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 100% 7 / 7 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« lzv1/lzv1.c ↑ Summary
1 =head1 NAME
2  
3 Compress::LZV1 - extremely leight-weight Lev-Zimpel-Vogt compression
4  
5 =head1 SYNOPSIS
6  
7 use Compress::LZV1;
8  
9 $probably_compressed = compress $uncompressed_data;
10  
11 $original_data = uncompress $probably_compressed;
12  
13 =head1 DESCRIPTION
14  
15 LZV1 is an extremely fast (not that much slower than a pure memcpy)
16 compression algorithm. It is ideal for applications where you want to save
17 I<some> space but not at the cost of speed. It is ideal for repetitive
18 data as well. The module is self-contained and very small (no large
19 library to be pulled in).
20  
21 I have no idea wether any patents in any countries apply to this
22 algorithm, but at the moment it is believed that it is free from any
23 patents.
24  
25 =head1 FUNCTIONS
26  
27 =head2 $compressed = compress $uncompressed
28  
29 Try to compress the given string as quickly and as much as possible. In
30 the worst case, the string can enlarge by at most a single byte. Empty
31 strings yield empty strings. The uncompressed data string must be smaller
32 than 16MB (1<<24).
33  
34 The compressed is (currently) in one of two forms:
35  
36 * a literal 'U', followed by the original, uncompressed data
37  
38 * a literal 'L', followed by three bytes (big-endian) uncompressed length, followed by the actual LZV1 data
39  
40 =head2 $decompressed = decompress $compressed
41  
42 Uncompress the string (compressed by C<compress>) and return the original
43 data. Decompression errors can result in either broken data (there is no
44 checksum kept) or a runtime error.
45  
46 =head1 SEE ALSO
47  
48 Other Compress::* modules, especially Compress::LZO (for speed) and
49 Compress::Zlib.
50  
51 =head1 AUTHOR
52  
53 This perl extension was written by Marc Lehmann <pcg@goof.com> (See
54 also http://www.goof.com/pcg/marc/). The original lzv1 code was written
55 by Hermann Vogt and put under the GPL. (There is also a i386 assembler
56 version that is not used in this module).
57  
58 The lzv1 code was accompanied by the following comment:
59  
60 =over 4
61  
62 The method presented here is faster and compresses better than lzrw1 and
63 lzrw1-a. I named it lzv for "Lev-Zimpel-Vogt". It uses ideas introduced
64 by Ross Williams in his algorithm lzrw1 [R. N. Williams (1991): "An
65 Extremly Fast ZIV-Lempel Data Compression Algorithm", Proceedings IEEE
66 Data Compression Conference, Snowbird, Utah, 362-371] and by Fiala and
67 Green in their algorithm a1 [E. R. Fiala, D. H. Greene (1989): "Data
68 Compression with Finite Windows", Communications of the ACM, 4, 490-505].
69 Because lzv differs strongly from both, I hope there will be no patent
70 problems. The hashing-method has been stolen from Jean-loup Gailly's
71 (patent free) gzip.
72  
73 =back
74  
75 =head1 BUGS
76  
77 It seems that the c-code has _big_ alignment problems :(
78  
79 =cut
80  
81 package Compress::LZV1;
82  
83 2 require Exporter;
84 2 require DynaLoader;
85  
86 2 $VERSION = 0.04;
87 2 @ISA = qw/Exporter DynaLoader/;
88 2 @EXPORT = qw(compress decompress);
89 2 bootstrap Compress::LZV1 $VERSION;
90  
91 2 1;
92  
93  
94  
95  
96  
« lzv1/lzv1.c ↑ Summary