Source file : huffman-encoding.ads
1 -- Huffman.Encoding
2 --------------------
3 --
4 -- Legal licensing note:
5 --
6 -- Copyright (c) 2024 Gautier de Montmollin (maintainer of the Ada version)
7 -- SWITZERLAND
8 --
9 -- Permission is hereby granted, free of charge, to any person obtaining a copy
10 -- of this software and associated documentation files (the "Software"), to deal
11 -- in the Software without restriction, including without limitation the rights
12 -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 -- copies of the Software, and to permit persons to whom the Software is
14 -- furnished to do so, subject to the following conditions:
15 --
16 -- The above copyright notice and this permission notice shall be included in
17 -- all copies or substantial portions of the Software.
18 --
19 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 -- THE SOFTWARE.
26 --
27 -- NB: this is the MIT License, as found 03-Nov-2024 on the site
28 -- http://www.opensource.org/licenses/mit-license.php
29
30 with Interfaces;
31
32 package Huffman.Encoding is
33
34 invalid : constant := -1;
35
36 subtype Code_Range is Interfaces.Integer_32 range invalid .. Interfaces.Integer_32'Last;
37
38 type Length_Code_Pair is record
39 bit_length : Natural; -- Huffman code length, in bits
40 code : Code_Range := invalid; -- The code itself (the 0's and 1's)
41 end record;
42
43 type Descriptor is array (Natural range <>) of Length_Code_Pair;
44
45 -- The Prepare_Huffman_Codes procedure finds the Huffman
46 -- code for all values, given the bit_length imposed as input.
47 --
48 procedure Prepare_Codes
49 (hd : in out Descriptor;
50 max_huffman_bits : in Positive;
51 invert_bit_order : in Boolean);
52
53 end Huffman.Encoding;
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.