Source file : zip-compress-reduce.ads
1 -- Just for fun, playing with the old Zip "Reduce" format...
2 --
3 -- "Reduce" combines the LZ77 method with a probabilistic
4 -- predictor using a Markov chain.
5 --
6 -- The format has a single block, then a single matrix,
7 -- for the whole data to be compressed :-(.
8 --
9 -- NB: this compressor works in two passes, the first pass
10 -- serving to compute the exact optimal Markov matrix for the whole
11 -- data to be compressed. Hence, it is slow. However,
12 -- we cache the last n=LZ_cache_size bytes compressed by LZ77.
13 -- The resulting compression is optimal within the constraints of the
14 -- "Reduce" format (one block, poor encoding of compressed data and of the
15 -- compression structure itself (the Markov matrix)).
16 --
17 -- Author: G. de Montmollin, January 2009
18 --
19 -- Legal licensing note:
20
21 -- Copyright (c) 2009 .. 2023 Gautier de Montmollin
22 -- SWITZERLAND
23
24 -- Permission is hereby granted, free of charge, to any person obtaining a copy
25 -- of this software and associated documentation files (the "Software"), to deal
26 -- in the Software without restriction, including without limitation the rights
27 -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28 -- copies of the Software, and to permit persons to whom the Software is
29 -- furnished to do so, subject to the following conditions:
30
31 -- The above copyright notice and this permission notice shall be included in
32 -- all copies or substantial portions of the Software.
33
34 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35 -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36 -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37 -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38 -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39 -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
40 -- THE SOFTWARE.
41
42 -- NB: this is the MIT License, as found on the site
43 -- http://www.opensource.org/licenses/mit-license.php
44
45 with Zip.CRC_Crypto;
46
47 private procedure Zip.Compress.Reduce
48 (input,
49 output : in out Zip_Streams.Root_Zipstream_Type'Class;
50 input_size_known : Boolean;
51 input_size : Zip_64_Data_Size_Type; -- ignored if unknown
52 feedback : Feedback_Proc;
53 method : Reduction_Method;
54 CRC : in out Interfaces.Unsigned_32; -- only updated here
55 crypto : in out CRC_Crypto.Crypto_pack;
56 output_size : out Zip_64_Data_Size_Type;
57 compression_ok : out Boolean); -- indicates when compressed <= uncompressed
Web view of Ada source code generated by GNATHTML, project: ALI_Parse version 1.0.
Zip-Ada: Ada library for zip archive files (.zip).
Ada programming.
Some news about Zip-Ada and other Ada projects
on Gautier's blog.