Back to... Zip-Ada

Source file : lzma-encoding.ads



   1  --  LZMA.Encoding - a standalone, generic LZMA encoder.
   2  -----------------
   3  --  See body for credits and other informations.
   4  --
   5  --  Examples of use:
   6  --    LZMA_Enc, a standalone encoder to .lzma files
   7  --    Zip.Compress.LZMA_E, creates Zip files entries with LZMA encoding
   8  
   9  --  Legal licensing note:
  10  
  11  --  Copyright (c) 2016 .. 2019 Gautier de Montmollin
  12  --  SWITZERLAND
  13  
  14  --  Permission is hereby granted, free of charge, to any person obtaining a copy
  15  --  of this software and associated documentation files (the "Software"), to deal
  16  --  in the Software without restriction, including without limitation the rights
  17  --  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  18  --  copies of the Software, and to permit persons to whom the Software is
  19  --  furnished to do so, subject to the following conditions:
  20  
  21  --  The above copyright notice and this permission notice shall be included in
  22  --  all copies or substantial portions of the Software.
  23  
  24  --  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  25  --  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26  --  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  27  --  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  28  --  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  29  --  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  30  --  THE SOFTWARE.
  31  
  32  --  NB: this is the MIT License, as found on the site
  33  --  http://www.opensource.org/licenses/mit-license.php
  34  
  35  package LZMA.Encoding is
  36  
  37    --  Low level: faster but weaker compression
  38    --  High level: slower but stronger compression
  39    --
  40    type Compression_Level is (
  41      Level_0,  --  no LZ compression
  42      Level_1,  --  uses Info-Zip's match finder for Deflate (32KB  sliding window), level 6
  43      Level_2,  --  uses Info-Zip's match finder for Deflate (32KB  sliding window), level 10
  44      Level_3   --  uses LZMA SDK's BT4 match finder, dictionary's size specified in dictionary_size
  45    );
  46  
  47    generic
  48      --  Input of data:
  49      with function  Read_Byte return Byte;
  50      with function  More_Bytes return Boolean;
  51      --  Output of LZMA-compressed data:
  52      with procedure Write_Byte (b : Byte);
  53      --
  54    procedure Encode
  55      (level                  : Compression_Level           := Level_1;
  56       literal_context_bits   : Literal_Context_Bits_Range  := 3;   --  Bits of last byte are used.
  57       literal_position_bits  : Literal_Position_Bits_Range := 0;   --  Position mod 2**bits is used.
  58       position_bits          : Position_Bits_Range         := 2;   --  Position mod 2**bits is used.
  59       end_marker             : Boolean := True;   --  Produce an End-Of-Stream marker (*) ?
  60       uncompressed_size_info : Boolean := False;  --  Optional extra header needed for .lzma files.
  61                                                   --  In LZMA.Decoding, type LZMA_Hints: has_size.
  62       dictionary_size        : Natural := Default_dictionary_size);  --  Not used by Level_1, Level_2.
  63  
  64    --  (*) In PKWARE's Appnote (5.8.9), the use of an EOS marker is "highly recommended" for LZMA.
  65    --
  66    --  NB: the value of uncompressed_size_info actually determines two variants
  67    --      of the LZMA header, which are *not* compatible with each other!
  68    --
  69    --      In .zip files, uncompressed_size_info = False.
  70    --      This information is already available in Zip entry headers.
  71    --      In .lzma files, uncompressed_size_info = True.
  72    --
  73    --      When uncompressed_size_info = True, this implementation sets
  74    --      a special size value indicating that the size is unknown.
  75    --      Reason: size is not known in advance and the header cannot be
  76    --      rewritten when processing is done.
  77    --
  78    --      See also the has_size field of the LZMA_Hints record in LZMA.Decoding.
  79  
  80  end LZMA.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.