• Skip to sidebar navigation
  • Skip to content

Bitbucket

  • More
    ProjectsRepositories
    • Help
      • Online help
      • Learn Git
      • Welcome to Bitbucket
      • Keyboard shortcuts
    • Log In
    Android SDK
    1. Android SDK

    linux-imx

    Public
    Actions
    • Clone

    Learn more about cloning repositories

    You have read-only access

    Navigation
    • Source
    • Commits
    • Branches
    • Forks
    1. Android SDK
    2. linux-imx

    Source

    linux-imx/Documentation/lzo.txt
    Dave RodgmanDave Rodgman committed b11ed18efa805 Apr 2019
    Raw file
    Source viewDiff to previous
            Always followed by exactly one LE16 :  D D D D D D D D : D D D D D D S S
     
    1
    ===========================================================
    2
    LZO stream format as understood by Linux's LZO decompressor
    3
    ===========================================================
    4
    ​
    5
    Introduction
    6
    ============
    7
    ​
    8
      This is not a specification. No specification seems to be publicly available
    9
      for the LZO stream format. This document describes what input format the LZO
    10
      decompressor as implemented in the Linux kernel understands. The file subject
    11
      of this analysis is lib/lzo/lzo1x_decompress_safe.c. No analysis was made on
    12
      the compressor nor on any other implementations though it seems likely that
    13
      the format matches the standard one. The purpose of this document is to
    14
      better understand what the code does in order to propose more efficient fixes
    15
      for future bug reports.
    16
    ​
    17
    Description
    18
    ===========
    19
    ​
    20
      The stream is composed of a series of instructions, operands, and data. The
    21
      instructions consist in a few bits representing an opcode, and bits forming
    22
      the operands for the instruction, whose size and position depend on the
    23
      opcode and on the number of literals copied by previous instruction. The
    24
      operands are used to indicate:
    25
    ​
    26
        - a distance when copying data from the dictionary (past output buffer)
    27
        - a length (number of bytes to copy from dictionary)
    28
        - the number of literals to copy, which is retained in variable "state"
    29
          as a piece of information for next instructions.
    30
    ​
    31
      Optionally depending on the opcode and operands, extra data may follow. These
    32
      extra data can be a complement for the operand (eg: a length or a distance
    33
      encoded on larger values), or a literal to be copied to the output buffer.
    34
    ​
    35
      The first byte of the block follows a different encoding from other bytes, it
    36
      seems to be optimized for literal use only, since there is no dictionary yet
    37
      prior to that byte.
    38
    ​
    39
      Lengths are always encoded on a variable size starting with a small number
    40
      of bits in the operand. If the number of bits isn't enough to represent the
    41
      length, up to 255 may be added in increments by consuming more bytes with a
    42
      rate of at most 255 per extra byte (thus the compression ratio cannot exceed
    43
      around 255:1). The variable length encoding using #bits is always the same::
    44
    ​
    45
           length = byte & ((1 << #bits) - 1)
    46
           if (!length) {
    47
                   length = ((1 << #bits) - 1)
    48
                   length += 255*(number of zero bytes)
    49
                   length += first-non-zero-byte
    50
           }
    51
           length += constant (generally 2 or 3)
    52
    ​
    53
      For references to the dictionary, distances are relative to the output
    54
      pointer. Distances are encoded using very few bits belonging to certain
    55
      ranges, resulting in multiple copy instructions using different encodings.
    56
      Certain encodings involve one extra byte, others involve two extra bytes
    57
      forming a little-endian 16-bit quantity (marked LE16 below).
    58
    ​
    59
      After any instruction except the large literal copy, 0, 1, 2 or 3 literals
    60
      are copied before starting the next instruction. The number of literals that
    61
      were copied may change the meaning and behaviour of the next instruction. In
    62
      practice, only one instruction needs to know whether 0, less than 4, or more
    63
      literals were copied. This is the information stored in the <state> variable
    • Git repository management for enterprise teams powered by Atlassian Bitbucket
    • Atlassian Bitbucket v5.10.0
    • Documentation
    • Contact Support
    • Request a feature
    • About
    • Contact Atlassian
    Atlassian

    Everything looks good. Well let you know here if theres anything you should know about.