LZOTools

Documentation for LZOTools.

LZOTools.LZO1Type
LZO1

The LZO1 algorithm.

Keyword arguments

  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1AType
LZO1A

The LZO1A algorithm.

Keyword arguments

  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1A_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1A_99Type
LZO1A_99

The LZO1A_99 algorithm.

Keyword arguments

  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1A_99_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1BType
LZO1B

The LZO1B algorithm.

Keyword arguments

  • compression_level::Int = -1: compression level 1-9, with 9 producing the maximum compression ratio and 1 running the fastest, and where -1 chooses the default (1).
  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1B_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1B_99Type
LZO1B_99

The LZO1B_99 algorithm.

Keyword arguments

  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1B_99_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1CType
LZO1C

The LZO1C algorithm.

Keyword arguments

  • compression_level::Int = -1: compression level 1-9, with 9 producing the maximum compression ratio and 1 running the fastest, and where -1 chooses the default (1).
  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1C_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1C_99Type
LZO1C_99

The LZO1C_99 algorithm.

Keyword arguments

  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1C_99_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1C_999Type
LZO1C_999

The LZO1C_999 algorithm.

Keyword arguments

  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1C_999_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1F_1Type
LZO1F_1

The LZO1F_1 algorithm.

Keyword arguments

  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1F_1_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1F_999Type
LZO1F_999

The LZO1F_999 algorithm.

Keyword arguments

  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1F_999_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1X_1Type
LZO1X_1

The LZO1X_1 algorithm.

Keyword arguments

  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1X_1_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1X_1_11Type
LZO1X_1_11

The LZO1X111 algorithm.

Keyword arguments

  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1X_1_11_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1X_1_12Type
LZO1X_1_12

The LZO1X112 algorithm.

Keyword arguments

  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1X_1_12_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1X_1_15Type
LZO1X_1_15

The LZO1X115 algorithm.

Keyword arguments

  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1X_1_15_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1X_999Type
LZO1X_999

The LZO1X_999 algorithm.

Keyword arguments

  • compression_level::Int = 8: compression level 1-8, with 8 producing the maximum compression ratio and 1 running the fastest.
  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1X_999_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1Y_1Type
LZO1Y_1

The LZO1Y_1 algorithm.

Keyword arguments

  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1Y_1_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1Y_999Type
LZO1Y_999

The LZO1Y_999 algorithm.

Keyword arguments

  • compression_level::Int = 8: compression level 1-8, with 8 producing the maximum compression ratio and 1 running the fastest.
  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1Y_999_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1Z_999Type
LZO1Z_999

The LZO1Z_999 algorithm.

Keyword arguments

  • compression_level::Int = 8: compression level 1-8, with 8 producing the maximum compression ratio and 1 running the fastest.
  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1Z_999_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO1_99Type
LZO1_99

The LZO1_99 algorithm.

Keyword arguments

  • working_memory::Vector{UInt8} = zeros(UInt8, LZO1_99_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.LZO2A_999Type
LZO2A_999

The LZO2A_999 algorithm.

Keyword arguments

  • working_memory::Vector{UInt8} = zeros(UInt8, LZO2A_999_WORKING_MEMORY_SIZE): a block of memory used for historical lookups.
source
LZOTools.compressMethod
compress([algorithm], src::AbstractVector{UInt8}; [kwargs...])::Vector{UInt8}

Compress src using LZO algorithm algorithm.

Returns a Vector{UInt8} loaded with the compressed version of src.

The algorithm argument, if given, can be an instance of an AbstractLZOAlgorithm, a Type{<:AbstractLZOAlgorithm}, or a Symbol or String that names an LZO algorithm. The supported compression algorithm types are listed below–the symbol and string versions are the same, case-sensitive characters as the type name:

  • LZO1X_1, :LZO1X_1, or "LZO1X_1" (also LZO1X or LZO, and is the default if no algorithm is given)
  • LZO1, etc.
  • LZO1_99
  • LZO1A
  • LZO1A_99
  • LZO1B_1 (also LZO1B)
  • LZO1B_2
  • LZO1B_3
  • LZO1B_4
  • LZO1B_5
  • LZO1B_6
  • LZO1B_7
  • LZO1B_8
  • LZO1B_9
  • LZO1B_99
  • LZO1B_999
  • LZO1C_1 (also LZO1C)
  • LZO1C_2
  • LZO1C_3
  • LZO1C_4
  • LZO1C_5
  • LZO1C_6
  • LZO1C_7
  • LZO1C_8
  • LZO1C_9
  • LZO1C_99
  • LZO1C_999
  • LZO1F_1 (also LZO1F)
  • LZO1F_999
  • LZO1X_1_11
  • LZO1X_1_12
  • LZO1X_1_15
  • LZO1X_999
  • LZO1Y_1 (also LZO1Y)
  • LZO1Y_999
  • LZO1Z_999
  • LZO2A_999

Keyword arguments kwargs, if given, are passed to the algorithm struct constructors. See the documentation for the specific algorithm type for more information about valid keyword arguments and defaults.

source
LZOTools.decompressMethod
decompress([algorithm], src::AbstractVector{UInt8}; [kwargs...])::Vector{UInt8}

Decompress src using LZO algorithm algorithm. Only available for algorithms with safe decompression functions defined.

Returns a Vector{UInt8} loaded with the decompressed version of src.

The algorithm argument, if given, can be an instance of an AbstractLZOAlgorithm, a Type{<:AbstractLZOAlgorithm}, or a Symbol or String that names an LZO algorithm. The supported decompression algorithm types are listed below–the symbol and string versions are the same, case-sensitive characters as the type name:

  • LZO1X_1, :LZO1X_1, or "LZO1X_1" (also LZO1X, LZO, LZO1X_1_11, LZO1X_1_12, LZO1X_1_15, or LZO1X_999, and is the default if no algorithm is given)
  • LZO1B_1 (also LZO1B, LZO1B_2, LZO1B_3, LZO1B_4, LZO1B_5, LZO1B_6, LZO1B_7, LZO1B_8, LZO1B_9, LZO1B_99, or LZO1B_999)
  • LZO1C_1 (also LZO1C, LZO1C_2, LZO1C_3, LZO1C_4, LZO1C_5, LZO1C_6, LZO1C_7, LZO1C_8, LZO1C_9, LZO1C_99, or LZO1C_999)
  • LZO1F_1 (also LZO1F or LZO1F_999)
  • LZO1Y_1 (also LZO1Y or LZO1Y_999)
  • LZO1Z_999
  • LZO2A_999

Keyword arguments kwargs, if given, are passed to the algorithm struct constructors. See the documentation for the specific algorithm type for more information about valid keyword arguments and defaults.

source
LZOTools.max_compressed_lengthMethod
max_compressed_length(algo, n)::Int

Compute the maximum length that will result from compressing n bytes using LZO algorithm algo.

The worst-case scenario is a single super-long literal, in which case the input has to be emitted in its entirety (n bytes) plus the appropriate commands to start a long literal (n/255 bytes + a constant depending on n) plus the end of stream command (3 bytes). However, the liblzo2 authors suggest the following formula for most algorithms.

source
LZOTools.optimize!Method
optimize!([algorithm], src::AbstractVector{UInt8}; [kwargs...])::Vector{UInt8}

Optimize the already compressed src in-place using LZO algorithm algorithm, returning the resized and optimized src.

The algorithm argument, if given, can be an instance of an AbstractLZOAlgorithm, a Type{<:AbstractLZOAlgorithm}, or a Symbol or String that names an LZO algorithm. The supported compression algorithm types are listed below–the symbol and string versions are the same, case-sensitive characters as the type name:

  • LZO1X_1, :LZO1X_1, or "LZO1X_1" (also LZO1X or LZO, and is the default if no algorithm is given)
  • LZO1X_1_11
  • LZO1X_1_12
  • LZO1X_1_15
  • LZO1X_999
  • LZO1Y_1 (also LZO1Y)
  • LZO1Y_999

!!! warn Match the compression algorithm with the optimization algorithm Undefined behavior occurs if the algorithm passed to optimize does not match the algorithm passed to compress when src was generated.

Keyword arguments kwargs, if given, are passed to the algorithm struct constructors. See the documentation for the specific algorithm type for more information about valid keyword arguments and defaults.

Note

Optimizing compressed data involves splitting "long" literal copy commands into one "short" and one "long" run, then embedding the "short" literal copy into the the previous history copy command, thereby saving up to two bytes from each "long" literal copy command. The particular circumstances under which this optimization can occur happens in only about 1% of literal copy commands and can save at most about 1% of that command's total length, so optimization is only recommended when a 0.01% improvement in compression ratio is absolutely necessary. Also note that any increase in compression ratio achieved through optimization marginally increases the processing time required to decompress the data.

source
LZOTools.unsafe_compress!Method
unsafe_compress!([algorithm], dest, src; [kwargs...])::Int

Compress src to dest using LZO algorithm algorithm, returning the number of bytes loaded into dest.

The method is "unsafe" in that it does not check to see if the compressed output can fit into dest before proceeding, and may write out of bounds or crash your program if the number of bytes required to compress src is larger than the number of bytes available in dest. The method returns the number of bytes written to dest, which may be greater than length(dest).

Both dest and src must have pointer and length methods defined, and the memory of dest has to be writable or else undefined behavior will occur.

The algorithm argument, if given, can be an instance of an AbstractLZOAlgorithm, a Type{<:AbstractLZOAlgorithm}, or a Symbol or String that names an LZO algorithm. The supported compression algorithm types are listed below–the symbol and string versions are the same, case-sensitive characters as the type name:

  • LZO1X_1, :LZO1X_1, or "LZO1X_1" (also LZO1X or LZO, and is the default if no algorithm is given)
  • LZO1, etc.
  • LZO1_99
  • LZO1A
  • LZO1A_99
  • LZO1B_1 (also LZO1B)
  • LZO1B_2
  • LZO1B_3
  • LZO1B_4
  • LZO1B_5
  • LZO1B_6
  • LZO1B_7
  • LZO1B_8
  • LZO1B_9
  • LZO1B_99
  • LZO1B_999
  • LZO1C_1 (also LZO1C)
  • LZO1C_2
  • LZO1C_3
  • LZO1C_4
  • LZO1C_5
  • LZO1C_6
  • LZO1C_7
  • LZO1C_8
  • LZO1C_9
  • LZO1C_99
  • LZO1C_999
  • LZO1F_1 (also LZO1F)
  • LZO1F_999
  • LZO1X_1_11
  • LZO1X_1_12
  • LZO1X_1_15
  • LZO1X_999
  • LZO1Y_1 (also LZO1Y)
  • LZO1Y_999
  • LZO1Z_999
  • LZO2A_999

Keyword arguments kwargs, if given, are passed to the algorithm struct constructors. See the documentation for the specific algorithm type for more information about valid keyword arguments and defaults.

source
LZOTools.unsafe_decompress!Method
unsafe_decompress!([algorithm], dest, src; [kwargs...])::Int

Decompress src to dest using LZO algorithm algorithm, returning the number of bytes loaded into dest.

The method is "unsafe" in that it does not check to see if the decompressed output can fit into dest before proceeding, and may write out of bounds or crash your program if the number of bytes required to decompress src is larger than the number of bytes available in dest. The method returns the number of bytes written to dest, which may be greater than length(dest).

Both dest and src have to have pointer and length methods defined, and the memory of dest has to be writable or else undefined behavior will occur.

The algorithm argument, if given, can be an instance of an AbstractLZOAlgorithm, a Type{<:AbstractLZOAlgorithm}, or a Symbol or String that names an LZO algorithm. The supported decompression algorithm types are listed below–the symbol and string versions are the same, case-sensitive characters as the type name:

  • LZO1X_1, :LZO1X_1, or "LZO1X_1" (also LZO1X, LZO, LZO1X_1_11, LZO1X_1_12, LZO1X_1_15, or LZO1X_999, and is the default if no algorithm is given)
  • LZO1 (also LZO1_99)
  • LZO1A (also LZO1A_99)
  • LZO1B_1 (also LZO1B, LZO1B_2, LZO1B_3, LZO1B_4, LZO1B_5, LZO1B_6, LZO1B_7, LZO1B_8, LZO1B_9, LZO1B_99, or LZO1B_999)
  • LZO1C_1 (also LZO1C, LZO1C_2, LZO1C_3, LZO1C_4, LZO1C_5, LZO1C_6, LZO1C_7, LZO1C_8, LZO1C_9, LZO1C_99, or LZO1C_999)
  • LZO1F_1 (also LZO1F or LZO1F_999)
  • LZO1Y_1 (also LZO1Y or LZO1Y_999)
  • LZO1Z_999
  • LZO2A_999

Keyword arguments kwargs, if given, are passed to the algorithm struct constructors. See the documentation for the specific algorithm type for more information about valid keyword arguments and defaults.

source
LZOTools.unsafe_optimize!Method
unsafe_optimize!([algorithm], dest, src; [kwargs...])::Int

Optimize the already compressed src in-place by decompressing to dest using LZO algorithm algorithm.

The method is "unsafe" in that it does not check to see if the decompressed output can fit into dest before proceeding, and may write out of bounds or crash your program if the number of bytes required to decompress src is larger than the number of bytes available in dest. The method returns the number of bytes written to dest, which may be greater than length(dest).

Both dest and src have to have pointer and length methods defined, and the memory of both have to be writable or else undefined behavior will occur.

The algorithm argument, if given, can be an instance of an AbstractLZOAlgorithm, a Type{<:AbstractLZOAlgorithm}, or a Symbol or String that names an LZO algorithm. The supported compression algorithm types are listed below–the symbol and string versions are the same, case-sensitive characters as the type name:

  • LZO1X_1, :LZO1X_1, or "LZO1X_1" (also LZO1X or LZO, and is the default if no algorithm is given)
  • LZO1X_1_11
  • LZO1X_1_12
  • LZO1X_1_15
  • LZO1X_999
  • LZO1Y_1 (also LZO1Y)
  • LZO1Y_999

!!! warn Match the compression algorithm with the optimization algorithm Undefined behavior occurs if the algorithm passed to optimize does not match the algorithm passed to compress when src was generated.

Keyword arguments kwargs, if given, are passed to the algorithm struct constructors. See the documentation for the specific algorithm type for more information about valid keyword arguments and defaults.

source