[要約] RFC 8478は、Zstandard圧縮アルゴリズムとapplication/zstdメディアタイプの仕様を定義しています。目的は、高速で効率的なデータ圧縮と、Zstandardを使用するアプリケーション間の互換性を確保することです。

Internet Engineering Task Force (IETF)                         Y. Collet
Request for Comments: 8478                             M. Kucherawy, Ed.
Category: Informational                                         Facebook
ISSN: 2070-1721                                             October 2018
        

Zstandard Compression and the application/zstd Media Type

Zstandard圧縮とapplication / zstdメディアタイプ

Abstract

概要

Zstandard, or "zstd" (pronounced "zee standard"), is a data compression mechanism. This document describes the mechanism and registers a media type and content encoding to be used when transporting zstd-compressed content via Multipurpose Internet Mail Extensions (MIME).

Zstandard、または「zstd」(「zee standard」と発音)は、データ圧縮メカニズムです。このドキュメントでは、メカニズムについて説明し、多目的インターネットメール拡張機能(MIME)を介してzstd圧縮されたコンテンツを転送するときに使用されるメディアタイプとコンテンツエンコーディングを登録します。

Despite use of the word "standard" as part of its name, readers are advised that this document is not an Internet Standards Track specification; it is being published for informational purposes only.

名前の一部として「標準」という言葉を使用していますが、このドキュメントはInternet Standards Trackの仕様ではないことに注意してください。情報提供のみを目的として公開されています。

Status of This Memo

本文書の状態

This document is not an Internet Standards Track specification; it is published for informational purposes.

このドキュメントはInternet Standards Trackの仕様ではありません。情報提供を目的として公開されています。

This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Not all documents approved by the IESG are candidates for any level of Internet Standard; see Section 2 of RFC 7841.

このドキュメントは、IETF(Internet Engineering Task Force)の製品です。これは、IETFコミュニティのコンセンサスを表しています。公開レビューを受け、インターネットエンジニアリングステアリンググループ(IESG)による公開が承認されました。 IESGによって承認されたすべてのドキュメントが、あらゆるレベルのインターネット標準の候補であるとは限りません。 RFC 7841のセクション2をご覧ください。

Information about the current status of this document, any errata, and how to provide feedback on it may be obtained at https://www.rfc-editor.org/info/rfc8478.

このドキュメントの現在のステータス、正誤表、およびフィードバックの提供方法に関する情報は、https://www.rfc-editor.org/info/rfc8478で入手できます。

Copyright Notice

著作権表示

Copyright (c) 2018 IETF Trust and the persons identified as the document authors. All rights reserved.

Copyright(c)2018 IETF Trustおよびドキュメントの作成者として識別された人物。全著作権所有。

This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.

この文書は、BCP 78およびIETF文書に関するIETFトラストの法的規定(https://trustee.ietf.org/license-info)の対象であり、この文書の発行日に有効です。これらのドキュメントは、このドキュメントに関するあなたの権利と制限を説明しているため、注意深く確認してください。このドキュメントから抽出されたコードコンポーネントには、Trust Legal Provisionsのセクション4.eに記載されているSimplified BSD Licenseのテキストが含まれている必要があり、Simplified BSD Licenseに記載されているように保証なしで提供されます。

Table of Contents

目次

   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   4
   2.  Definitions . . . . . . . . . . . . . . . . . . . . . . . . .   4
   3.  Compression Algorithm . . . . . . . . . . . . . . . . . . . .   5
     3.1.  Frames  . . . . . . . . . . . . . . . . . . . . . . . . .   6
       3.1.1.  Zstandard Frames  . . . . . . . . . . . . . . . . . .   6
         3.1.1.1.  Frame Header  . . . . . . . . . . . . . . . . . .   7
         3.1.1.2.  Blocks  . . . . . . . . . . . . . . . . . . . . .  12
         3.1.1.3.  Compressed Blocks . . . . . . . . . . . . . . . .  14
         3.1.1.4.  Sequence Execution  . . . . . . . . . . . . . . .  28
         3.1.1.5.  Repeat Offsets  . . . . . . . . . . . . . . . . .  29
       3.1.2.  Skippable Frames  . . . . . . . . . . . . . . . . . .  30
   4.  Entropy Encoding  . . . . . . . . . . . . . . . . . . . . . .  30
     4.1.  FSE . . . . . . . . . . . . . . . . . . . . . . . . . . .  31
       4.1.1.  FSE Table Description . . . . . . . . . . . . . . . .  31
     4.2.  Huffman Coding  . . . . . . . . . . . . . . . . . . . . .  34
       4.2.1.  Huffman Tree Description  . . . . . . . . . . . . . .  35
         4.2.1.1.  Huffman Tree Header . . . . . . . . . . . . . . .  36
         4.2.1.2.  FSE Compression of Huffman Weights  . . . . . . .  37
         4.2.1.3.  Conversion from Weights to Huffman Prefix Codes .  38
       4.2.2.  Huffman-Coded Streams . . . . . . . . . . . . . . . .  39
   5.  Dictionary Format . . . . . . . . . . . . . . . . . . . . . .  40
   6.  IANA Considerations . . . . . . . . . . . . . . . . . . . . .  42
     6.1.  The 'application/zstd' Media Type . . . . . . . . . . . .  42
     6.2.  Content Encoding  . . . . . . . . . . . . . . . . . . . .  43
     6.3.  Dictionaries  . . . . . . . . . . . . . . . . . . . . . .  43
   7.  Security Considerations . . . . . . . . . . . . . . . . . . .  43
   8.  Implementation Status . . . . . . . . . . . . . . . . . . . .  44
   9.  References  . . . . . . . . . . . . . . . . . . . . . . . . .  45
     9.1.  Normative References  . . . . . . . . . . . . . . . . . .  45
     9.2.  Informative References  . . . . . . . . . . . . . . . . .  45
   Appendix A.  Decoding Tables for Predefined Codes . . . . . . . .  46
     A.1.  Literal Length Code Table . . . . . . . . . . . . . . . .  46
     A.2.  Match Length Code Table . . . . . . . . . . . . . . . . .  49
     A.3.  Offset Code Table . . . . . . . . . . . . . . . . . . . .  52
   Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . .  53
   Authors' Addresses  . . . . . . . . . . . . . . . . . . . . . . .  54
        
1. Introduction
1. はじめに

Zstandard, or "zstd" (pronounced "zee standard"), is a data compression mechanism, akin to gzip [RFC1952].

Zstandard、または「zstd」(「zee standard」と発音)は、gzip [RFC1952]に似たデータ圧縮メカニズムです。

Despite use of the word "standard" as part of its name, readers are advised that this document is not an Internet Standards Track specification; it is being published for informational purposes only.

名前の一部として「標準」という言葉を使用していますが、このドキュメントはInternet Standards Trackの仕様ではないことに注意してください。情報提供のみを目的として公開されています。

This document describes the Zstandard format. Also, to enable the transport of a data object compressed with Zstandard, this document registers a media type that can be used to identify such content when it is used in a payload encoded using Multipurpose Internet Mail Extensions (MIME).

このドキュメントでは、Zstandardフォーマットについて説明します。また、Zstandardで圧縮されたデータオブジェクトの転送を可能にするために、このドキュメントは、Multipurpose Internet Mail Extensions(MIME)を使用してエンコードされたペイロードで使用されるときに、そのようなコンテンツを識別するために使用できるメディアタイプを登録します。

2. Definitions
2. 定義

Some terms used elsewhere in this document are defined here for clarity.

このドキュメントの他の場所で使用されているいくつかの用語は、明確にするためにここで定義されています。

uncompressed: Describes an arbitrary set of bytes in their original form, prior to being subjected to compression.

uncompressed:圧縮前の任意のバイトセットを元の形式で記述します。

compress, compression: The act of processing a set of bytes via the compression mechanism described here.

圧縮、圧縮:ここで説明する圧縮メカニズムを介してバイトのセットを処理する行為。

compressed: Describes the result of passing a set of bytes through this mechanism. The original input has thus been compressed.

圧縮:このメカニズムを通じてバイトのセットを渡した結果を示します。したがって、元の入力は圧縮されています。

decompress, decompression: The act of processing a set of bytes through the inverse of the compression mechanism described here, in an attempt to recover the original set of bytes prior to compression.

decompress、decompression:圧縮前に元のバイトのセットを回復するために、ここで説明した圧縮メカニズムの逆を介してバイトのセットを処理する行為。

decompressed: Describes the result of passing a set of bytes through the reverse of this mechanism. When this is successful, the decompressed payload and the uncompressed payload are indistinguishable.

解凍:このメカニズムの逆を介してバイトのセットを渡した結果を示します。これが成功した場合、圧縮解除されたペイロードと圧縮解除されたペイロードは区別できません。

encode: The process of translating data from one form to another; this may include compression or it may refer to other translations done as part of this specification.

エンコード:データをある形式から別の形式に変換するプロセス。これには圧縮が含まれる場合や、この仕様の一部として行われる他の変換を参照する場合があります。

decode: The reverse of "encode"; describes a process of reversing a prior encoding to recover the original content.

デコード:「エンコード」の逆。は、元のコンテンツを復元するために以前のエンコーディングを逆にするプロセスを説明しています。

frame: Content compressed by Zstandard is transformed into a Zstandard frame. Multiple frames can be appended into a single file or stream. A frame is completely independent, has a defined beginning and end, and has a set of parameters that tells the decoder how to decompress it.

フレーム:Zstandardによって圧縮されたコンテンツは、Zstandardフレームに変換されます。複数のフレームを単一のファイルまたはストリームに追加できます。フレームは完全に独立しており、開始と終了が定義されており、デコーダーに解凍方法を指示する一連のパラメーターがあります。

block: A frame encapsulates one or multiple blocks. Each block contains arbitrary content, which is described by its header, and has a guaranteed maximum content size that depends upon frame parameters. Unlike frames, each block depends on previous blocks for proper decoding. However, each block can be decompressed without waiting for its successor, allowing streaming operations.

ブロック:フレームは、1つまたは複数のブロックをカプセル化します。各ブロックには、ヘッダーで記述された任意のコンテンツが含まれており、フレームパラメーターに依存する最大コンテンツサイズが保証されています。フレームとは異なり、各ブロックは適切なデコードのために前のブロックに依存しています。ただし、各ブロックは、後続操作を待たずに解凍でき、ストリーミング操作を許可します。

natural order: A sequence or ordering of objects or values that is typical of that type of object or value. A set of unique integers, for example, is in "natural order" if when progressing from one element in the set or sequence to the next, there is never a decrease in value.

自然順序:そのタイプのオブジェクトまたは値に典型的な、オブジェクトまたは値のシーケンスまたは順序。たとえば、一意の整数のセットは、セットまたはシーケンス内のある要素から次の要素に進むときに値が減少しない場合、「自然な順序」にあります。

The naming convention for identifiers within the specification is Mixed_Case_With_Underscores. Identifiers inside square brackets indicate that the identifier is optional in the presented context.

仕様内の識別子の命名規則は、Mixed_Case_With_Underscoresです。角括弧内の識別子は、提示されたコンテキストでは識別子がオプションであることを示します。

3. Compression Algorithm
3. 圧縮アルゴリズム

This section describes the Zstandard algorithm.

このセクションでは、Zstandardアルゴリズムについて説明します。

The purpose of this document is to define a lossless compressed data format that is a) independent of the CPU type, operating system, file system, and character set and b) is suitable for file compression and pipe and streaming compression, using the Zstandard algorithm. The text of the specification assumes a basic background in programming at the level of bits and other primitive data representations.

このドキュメントの目的は、a)CPUタイプ、オペレーティングシステム、ファイルシステム、および文字セットに依存せず、b)Zstandardアルゴリズムを使用して、ファイル圧縮とパイプおよびストリーミング圧縮に適した可逆圧縮データ形式を定義することです。 。仕様のテキストは、ビットレベルおよびその他のプリミティブデータ表現でのプログラミングにおける基本的な背景を前提としています。

The data can be produced or consumed, even for an arbitrarily long sequentially presented input data stream, using only an a priori bounded amount of intermediate storage, and hence can be used in data communications. The format uses the Zstandard compression method, and an optional xxHash-64 checksum method [XXHASH], for detection of data corruption.

データは、事前に制限された量の中間ストレージのみを使用して、任意に長く連続して提示される入力データストリームでも生成または消費できるため、データ通信で使用できます。この形式では、データの破損を検出するために、Zstandard圧縮方式と、オプションのxxHash-64チェックサム方式[XXHASH]を使用します。

The data format defined by this specification does not attempt to allow random access to compressed data.

この仕様で定義されているデータ形式は、圧縮データへのランダムアクセスを許可しようとするものではありません。

Unless otherwise indicated below, a compliant compressor must produce data sets that conform to the specifications presented here. However, it does not need to support all options.

以下で特に示されていない限り、準拠するコンプレッサーは、ここで提示される仕様に準拠するデータセットを生成する必要があります。ただし、すべてのオプションをサポートする必要はありません。

A compliant decompressor must be able to decompress at least one working set of parameters that conforms to the specifications presented here. It may also ignore informative fields, such as the checksum. Whenever it does not support a parameter defined in the compressed stream, it must produce a non-ambiguous error code and associated error message explaining which parameter is unsupported.

準拠する圧縮解除プログラムは、ここに示す仕様に準拠する少なくとも1つの作業パラメーターセットを圧縮解除できる必要があります。また、チェックサムなどの情報フィールドを無視する場合もあります。圧縮ストリームで定義されたパラメーターをサポートしていない場合は、あいまいでないエラーコードと、サポートされていないパラメーターを説明する関連エラーメッセージを生成する必要があります。

This specification is intended for use by implementers of software to compress data into Zstandard format and/or decompress data from Zstandard format. The Zstandard format is supported by an open source reference implementation, written in portable C, and available at [ZSTD].

この仕様は、ソフトウェアの実装者がデータをZstandardフォーマットに圧縮したり、Zstandardフォーマットからデータを解凍したりするために使用することを目的としています。 Zstandardフォーマットは、ポータブルCで記述されたオープンソースのリファレンス実装でサポートされており、[ZSTD]から入手できます。

3.1. Frames
3.1. フレーム

Zstandard compressed data is made up of one or more frames. Each frame is independent and can be decompressed independently of other frames. The decompressed content of multiple concatenated frames is the concatenation of each frame's decompressed content.

Zstandard圧縮データは、1つ以上のフレームで構成されています。各フレームは独立しており、他のフレームとは独立して解凍できます。複数の連結されたフレームの解凍されたコンテンツは、各フレームの解凍されたコンテンツの連結です。

There are two frame formats defined for Zstandard: Zstandard frames and skippable frames. Zstandard frames contain compressed data, while skippable frames contain custom user metadata.

Zstandardには、Zstandardフレームとスキップ可能なフレームの2つのフレーム形式が定義されています。 Zstandardフレームには圧縮データが含まれ、スキップ可能なフレームにはカスタムユーザーメタデータが含まれます。

3.1.1. Zstandard Frames
3.1.1. Z標準フレーム

The structure of a single Zstandard frame is as follows:

単一のZstandardフレームの構造は次のとおりです。

     +--------------------+------------+
     |    Magic_Number    | 4 bytes    |
     +--------------------+------------+
     |    Frame_Header    | 2-14 bytes |
     +--------------------+------------+
     |     Data_Block     | n bytes    |
     +--------------------+------------+
     | [More Data_Blocks] |            |
     +--------------------+------------+
     | [Content_Checksum] | 0-4 bytes  |
     +--------------------+------------+
        

Magic_Number: 4 bytes, little-endian format. Value: 0xFD2FB528.

Magic_Number:4バイト、リトルエンディアン形式。値:0xFD2FB528。

Frame_Header: 2 to 14 bytes, detailed in Section 3.1.1.1.

Frame_Header:2〜14バイト。詳細はセクション3.1.1.1を参照してください。

Data_Block: Detailed in Section 3.1.1.2. This is where data appears.

Data_Block:セクション3.1.1.2で詳細。ここにデータが表示されます。

Content_Checksum: An optional 32-bit checksum, only present if Content_Checksum_Flag is set. The content checksum is the result of the XXH64() hash function [XXHASH] digesting the original (decoded) data as input, and a seed of zero. The low 4 bytes of the checksum are stored in little-endian format.

Content_Checksum:オプションの32ビットチェックサム。Content_Checksum_Flagが設定されている場合にのみ存在します。コンテンツチェックサムは、元の(デコードされた)データを入力としてダイジェストしたXXH64()ハッシュ関数[XXHASH]の結果と、ゼロのシードです。チェックサムの下位4バイトはリトルエンディアン形式で保存されます。

The magic number was selected to be less probable to find at the beginning of an arbitrary file. It avoids trivial patterns (0x00, 0xFF, repeated bytes, increasing bytes, etc.), contains byte values outside of ASCII range, and doesn't map into UTF-8 space, all of which reduce the likelihood of its appearance at the top of a text file.

マジックナンバーは、任意のファイルの先頭で見つける可能性が低くなるように選択されました。単純なパターン(0x00、0xFF、繰り返されるバイト、増加するバイトなど)を回避し、ASCII範囲外のバイト値を含み、UTF-8スペースにマップしません。これらはすべて、上部に表示される可能性を減らします。テキストファイルの。

3.1.1.1. Frame Header
3.1.1.1. フレームヘッダー

The frame header has a variable size, with a minimum of 2 bytes and up to 14 bytes depending on optional parameters. The structure of Frame_Header is as follows:

フレームヘッダーのサイズは可変であり、オプションのパラメーターに応じて、最小2バイトから最大14バイトです。 Frame_Headerの構造は次のとおりです。

     +-------------------------+-----------+
     | Frame_Header_Descriptor | 1 byte    |
     +-------------------------+-----------+
     |   [Window_Descriptor]   | 0-1 byte  |
     +-------------------------+-----------+
     |     [Dictionary_ID]     | 0-4 bytes |
     +-------------------------+-----------+
     |  [Frame_Content_Size]   | 0-8 bytes |
     +-------------------------+-----------+
        
3.1.1.1.1. Frame_Header_Descriptor
3.1.1.1.1. Frame_Header_Descriptor

The first header's byte is called the Frame_Header_Descriptor. It describes which other fields are present. Decoding this byte is enough to tell the size of Frame_Header.

最初のヘッダーのバイトは、Frame_Header_Descriptorと呼ばれます。他にどのフィールドが存在するかを説明します。このバイトをデコードするだけで、Frame_Headerのサイズがわかります。

     +------------+-------------------------+
     | Bit Number | Field Name              |
     +------------+-------------------------+
     |    7-6     | Frame_Content_Size_Flag |
     +------------+-------------------------+
     |     5      | Single_Segment_Flag     |
     +------------+-------------------------+
     |     4      | (unused)                |
     +------------+-------------------------+
     |     3      | (reserved)              |
     +------------+-------------------------+
     |     2      | Content_Checksum_Flag   |
     +------------+-------------------------+
     |    1-0     | Dictionary_ID_Flag      |
     +------------+-------------------------+
        

In this table, bit 7 is the highest bit, while bit 0 is the lowest one.

この表では、ビット7が最上位ビット、ビット0が最下位ビットです。

3.1.1.1.1.1. Frame_Content_Size_Flag
3.1.1.1.1.1. Frame_Content_Size_Flag

This is a 2-bit flag (equivalent to Frame_Header_Descriptor right-shifted 6 bits) specifying whether Frame_Content_Size (the decompressed data size) is provided within the header. Flag_Value provides FCS_Field_Size, which is the number of bytes used by Frame_Content_Size according to the following table:

これは、Frame_Content_Size(圧縮解除されたデータサイズ)がヘッダー内で提供されるかどうかを指定する2ビットフラグ(Frame_Header_Descriptorを右シフトした6ビットに相当)です。 Flag_ValueはFCS_Field_Sizeを提供します。これは、次の表に従ってFrame_Content_Sizeによって使用されるバイト数です。

     +----------------+--------+---+---+---+
     | Flag_Value     |   0    | 1 | 2 | 3 |
     +----------------+--------+---+---+---+
     | FCS_Field_Size | 0 or 1 | 2 | 4 | 8 |
     +----------------+--------+---+---+---+
        

When Flag_Value is 0, FCS_Field_Size depends on Single_Segment_Flag: If Single_Segment_Flag is set, FCS_Field_Size is 1. Otherwise, FCS_Field_Size is 0; Frame_Content_Size is not provided.

Flag_Valueが0の場合、FCS_Field_SizeはSingle_Segment_Flagに依存します。Single_Segment_Flagが設定されている場合、FCS_Field_Sizeは1です。それ以外の場合、FCS_Field_Sizeは0です。 Frame_Content_Sizeは提供されません。

3.1.1.1.1.2. Single_Segment_Flag
3.1.1.1.1.2. 単一セグメントフラグ

If this flag is set, data must be regenerated within a single continuous memory segment.

このフラグが設定されている場合、データは単一の連続メモリセグメント内で再生成する必要があります。

In this case, Window_Descriptor byte is skipped, but Frame_Content_Size is necessarily present. As a consequence, the decoder must allocate a memory segment of size equal or larger than Frame_Content_Size.

この場合、Window_Descriptorバイトはスキップされますが、Frame_Content_Sizeは必ず存在します。その結果、デコーダーは、Frame_Content_Size以上のサイズのメモリセグメントを割り当てる必要があります。

In order to protect the decoder from unreasonable memory requirements, a decoder is allowed to reject a compressed frame that requests a memory size beyond the decoder's authorized range.

デコーダを不当なメモリ要件から保護するために、デコーダは、デコーダの許可された範囲を超えるメモリサイズを要求する圧縮フレームを拒否できます。

For broader compatibility, decoders are recommended to support memory sizes of at least 8 MB. This is only a recommendation; each decoder is free to support higher or lower limits, depending on local limitations.

互換性を高めるために、デコーダーは少なくとも8 MBのメモリサイズをサポートすることをお勧めします。これは単なる推奨事項です。各デコーダは、ローカルの制限に応じて、上限または下限を自由にサポートできます。

3.1.1.1.1.3. Unused Bit
3.1.1.1.1.3. 未使用ビット

A decoder compliant with this specification version shall not interpret this bit. It might be used in a future version, to signal a property that is not mandatory to properly decode the frame. An encoder compliant with this specification must set this bit to zero.

この仕様バージョンに準拠したデコーダは、このビットを解釈しません。フレームを正しくデコードするために必須ではないプロパティを通知するために、将来のバージョンで使用される可能性があります。この仕様に準拠するエンコーダは、このビットをゼロに設定する必要があります。

3.1.1.1.1.4. Reserved Bit
3.1.1.1.1.4. 予約ビット

This bit is reserved for some future feature. Its value must be zero. A decoder compliant with this specification version must ensure it is not set. This bit may be used in a future revision, to signal a feature that must be interpreted to decode the frame correctly.

このビットは、将来の機能のために予約されています。その値はゼロでなければなりません。この仕様バージョンに準拠するデコーダは、設定されていないことを確認する必要があります。このビットは、フレームを正しくデコードするために解釈する必要がある機能を通知するために、将来のリビジョンで使用される可能性があります。

3.1.1.1.1.5. Content_Checksum_Flag
3.1.1.1.1.5. Content_Checksum_Flag

If this flag is set, a 32-bit Content_Checksum will be present at the frame's end. See the description of Content_Checksum above.

このフラグが設定されている場合、32ビットのContent_Checksumがフレームの最後に表示されます。上記のContent_Checksumの説明を参照してください。

3.1.1.1.1.6. Dictionary_ID_Flag
3.1.1.1.1.6. Dictionary_ID_Flag

This is a 2-bit flag (= Frame_Header_Descriptor & 0x3) indicating whether a dictionary ID is provided within the header. It also specifies the size of this field as DID_Field_Size:

これは、ヘッダー内に辞書IDが提供されているかどうかを示す2ビットのフラグ(= Frame_Header_Descriptor&0x3)です。また、このフィールドのサイズをDID_Field_Sizeとして指定します。

     +----------------+---+---+---+---+
     | Flag_Value     | 0 | 1 | 2 | 3 |
     +----------------+---+---+---+---+
     | DID_Field_Size | 0 | 1 | 2 | 4 |
     +----------------+---+---+---+---+
        
3.1.1.1.2. Window Descriptor
3.1.1.1.2. ウィンドウ記述子

This provides guarantees about the minimum memory buffer required to decompress a frame. This information is important for decoders to allocate enough memory.

これにより、フレームの圧縮解除に必要な最小メモリバッファーが保証されます。この情報は、デコーダが十分なメモリを割り当てるために重要です。

The Window_Descriptor byte is optional. When Single_Segment_Flag is set, Window_Descriptor is not present. In this case, Window_Size is Frame_Content_Size, which can be any value from 0 to 2^64-1 bytes (16 ExaBytes).

Window_Descriptorバイトはオプションです。 Single_Segment_Flagが設定されている場合、Window_Descriptorは存在しません。この場合、Window_SizeはFrame_Content_Sizeであり、0から2 ^ 64-1バイト(16エクサバイト)までの任意の値にすることができます。

     +------------+----------+----------+
     | Bit Number |   7-3    |   2-0    |
     +------------+----------+----------+
     | Field Name | Exponent | Mantissa |
     +------------+----------+----------+
        

The minimum memory buffer size is called Window_Size. It is described by the following formulae:

最小メモリバッファサイズはWindow_Sizeと呼ばれます。次の式で表されます。

     windowLog = 10 + Exponent;
     windowBase = 1 << windowLog;
     windowAdd = (windowBase / 8) * Mantissa;
     Window_Size = windowBase + windowAdd;
        

The minimum Window_Size is 1 KB. The maximum Window_Size is (1<<41) + 7*(1<<38) bytes, which is 3.75 TB.

最小のWindow_Sizeは1 KBです。最大Window_Sizeは(1 << 41)+ 7 *(1 << 38)バイトで、3.75 TBです。

In general, larger Window_Size values tend to improve the compression ratio, but at the cost of increased memory usage.

一般に、Window_Sizeの値を大きくすると、圧縮率が向上する傾向がありますが、メモリ使用量が増加します。

To properly decode compressed data, a decoder will need to allocate a buffer of at least Window_Size bytes.

圧縮データを正しくデコードするには、デコーダーは少なくともWindow_Sizeバイトのバッファーを割り当てる必要があります。

In order to protect decoders from unreasonable memory requirements, a decoder is allowed to reject a compressed frame that requests a memory size beyond decoder's authorized range.

デコーダーを不当なメモリ要件から保護するために、デコーダーは、デコーダーの許可範囲を超えるメモリサイズを要求する圧縮フレームを拒否できます。

For improved interoperability, it's recommended for decoders to support values of Window_Size up to 8 MB and for encoders not to generate frames requiring a Window_Size larger than 8 MB. It's merely a recommendation though, and decoders are free to support larger or lower limits, depending on local limitations.

相互運用性を向上させるには、デコーダーで最大8 MBのWindow_Sizeの値をサポートし、エンコーダーで8 MBより大きいWindow_Sizeを必要とするフレームを生成しないことをお勧めします。ただし、これは単なる推奨事項であり、デコーダーはローカルの制限に応じて、上限または下限を自由にサポートできます。

3.1.1.1.3. Dictionary_ID
3.1.1.1.3. 辞書ID

This is a variable size field, which contains the ID of the dictionary required to properly decode the frame. This field is optional. When it's not present, it's up to the decoder to know which dictionary to use.

これは可変サイズのフィールドで、フレームを正しくデコードするために必要なディクショナリのIDが含まれています。このフィールドはオプションです。存在しない場合、どの辞書を使用するかを知るのはデコーダー次第です。

Dictionary_ID field size is provided by DID_Field_Size. DID_Field_Size is directly derived from the value of Dictionary_ID_Flag. One byte can represent an ID 0-255; 2 bytes can represent an ID 0-65535; 4 bytes can represent an ID 0-4294967295. Format is little-endian.

Dictionary_IDフィールドのサイズは、DID_Field_Sizeによって提供されます。 DID_Field_Sizeは、Dictionary_ID_Flagの値から直接導出されます。 1バイトはID 0〜255を表すことができます。 2バイトはID 0〜65535を表すことができます。 4バイトはID 0-4294967295を表すことができます。形式はリトルエンディアンです。

It is permitted to represent a small ID (for example, 13) with a large 4-byte dictionary ID, even if it is less efficient.

効率が低くても、小さなID(たとえば、13)を大きな4バイトの辞書IDで表すことができます。

Within private environments, any dictionary ID can be used. However, for frames and dictionaries distributed in public space, Dictionary_ID must be attributed carefully. The following ranges are reserved for use only with dictionaries that have been registered with IANA (see Section 6.3):

プライベート環境では、任意の辞書IDを使用できます。ただし、パブリックスペースで配布されるフレームとディクショナリの場合、Dictionary_IDは慎重に属性化する必要があります。次の範囲は、IANAに登録されている辞書(セクション6.3を参照)でのみ使用するために予約されています。

   low range:  <= 32767
   high range:  >= (1 << 31)
        

Any other value for Dictionary_ID can be used by private arrangement between participants.

Dictionary_IDの他の値は、参加者間のプライベートアレンジメントで使用できます。

Any payload presented for decompression that references an unregistered reserved dictionary ID results in an error.

未登録の予約済み辞書IDを参照する解凍用に提示されたペイロードは、エラーになります。

3.1.1.1.4. Frame Content Size
3.1.1.1.4. フレームコンテンツサイズ

This is the original (uncompressed) size. This information is optional. Frame_Content_Size uses a variable number of bytes, provided by FCS_Field_Size. FCS_Field_Size is provided by the value of Frame_Content_Size_Flag. FCS_Field_Size can be equal to 0 (not present), 1, 2, 4, or 8 bytes.

これは元の(非圧縮)サイズです。この情報はオプションです。 Frame_Content_Sizeは、FCS_Field_Sizeによって提供される可変バイト数を使用します。 FCS_Field_Sizeは、Frame_Content_Size_Flagの値によって提供されます。 FCS_Field_Sizeは、0(存在しない)、1、2、4、または8バイトに等しくなります。

     +----------------+--------------+
     | FCS Field Size | Range        |
     +----------------+--------------+
     |        0       | unknown      |
     +----------------+--------------+
     |        1       | 0 - 255      |
     +----------------+--------------+
     |        2       | 256 - 65791  |
     +----------------+--------------+
     |        4       | 0 - 2^32 - 1 |
     +----------------+--------------+
     |        8       | 0 - 2^64 - 1 |
     +----------------+--------------+
        

Frame_Content_Size format is little-endian. When FCS_Field_Size is 1, 4, or 8 bytes, the value is read directly. When FCS_Field_Size is 2, the offset of 256 is added. It's allowed to represent a small size (for example 18) using any compatible variant.

Frame_Content_Size形式はリトルエンディアンです。 FCS_Field_Sizeが1、4、または8バイトの場合、値は直接読み取られます。 FCS_Field_Sizeが2の場合、256のオフセットが追加されます。互換性のあるバリアントを使用して、小さいサイズ(たとえば18)を表すことができます。

3.1.1.2. Blocks
3.1.1.2. ブロック

After Magic_Number and Frame_Header, there are some number of blocks. Each frame must have at least 1 block, but there is no upper limit on the number of blocks per frame.

Magic_NumberとFrame_Headerの後には、いくつかのブロックがあります。各フレームには少なくとも1つのブロックが必要ですが、フレームあたりのブロック数に上限はありません。

The structure of a block is as follows:

ブロックの構造は次のとおりです。

     +--------------+---------------+
     | Block_Header | Block_Content |
     +--------------+---------------+
     |    3 bytes   |    n bytes    |
     +--------------+---------------+
        

Block_Header uses 3 bytes, written using little-endian convention. It contains three fields:

Block_Headerは3バイトを使用し、リトルエンディアン規則を使用して記述されています。 3つのフィールドがあります。

     +------------+------------+------------+
     | Last_Block | Block_Type | Block_Size |
     +------------+------------+------------+
     |    bit 0   |   bits 1-2 |  bits 3-23 |
     +------------+------------+------------+
        
3.1.1.2.1. Last_Block
3.1.1.2.1. Last_Block

The lowest bit (Last_Block) signals whether this block is the last one. The frame will end after this last block. It may be followed by an optional Content_Checksum (see Section 3.1.1).

最下位ビット(Last_Block)は、このブロックが最後のブロックかどうかを示します。フレームはこの最後のブロックの後で終了します。その後に、オプションのContent_Checksumが続く場合があります(セクション3.1.1を参照)。

3.1.1.2.2. Block_Type
3.1.1.2.2. Block_Type

The next 2 bits represent the Block_Type. There are four block types:

次の2ビットはBlock_Typeを表します。 4つのブロックタイプがあります。

     +-----------+------------------+
     |   Value   |    Block_Type    |
     +-----------+------------------+
     |     0     |     Raw_Block    |
     +-----------+------------------+
     |     1     |     RLE_Block    |
     +-----------+------------------+
     |     2     | Compressed_Block |
     +-----------+------------------+
     |     3     |     Reserved     |
     +-----------+------------------+
        

Raw_Block: This is an uncompressed block. Block_Content contains Block_Size bytes.

Raw_Block:これは非圧縮ブロックです。 Block_ContentにはBlock_Sizeバイトが含まれます。

RLE_Block: This is a single byte, repeated Block_Size times. Block_Content consists of a single byte. On the decompression side, this byte must be repeated Block_Size times.

RLE_Block:これは単一バイトで、Block_Size回繰り返されます。 Block_Contentは1バイトで構成されます。解凍側では、このバイトをBlock_Size回繰り返す必要があります。

Compressed_Block: This is a compressed block as described in Section 3.1.1.3. Block_Size is the length of Block_Content, namely the compressed data. The decompressed size is not known, but its maximum possible value is guaranteed (see below).

Compressed_Block:これは、セクション3.1.1.3で説明されている圧縮ブロックです。 Block_Sizeは、Block_Contentの長さ、つまり圧縮データです。解凍されたサイズは不明ですが、可能な最大値が保証されています(以下を参照)。

Reserved: This is not a block. This value cannot be used with the current specification. If such a value is present, it is considered to be corrupt data.

予約済み:これはブロックではありません。この値は現在の仕様では使用できません。そのような値が存在する場合、それは破損したデータと見なされます。

3.1.1.2.3. Block_Size
3.1.1.2.3. Block_Size

The upper 21 bits of Block_Header represent the Block_Size. Block_Size is the size of the block excluding the header. A block can contain any number of bytes (even zero), up to Block_Maximum_Decompressed_Size, which is the smallest of:

Block_Headerの上位21ビットは、Block_Sizeを表します。 Block_Sizeは、ヘッダーを除くブロックのサイズです。ブロックには、最大でBlock_Maximum_Decompressed_Sizeまでの任意のバイト数(ゼロも含む)を含めることができます。

o Window_Size

o Window_Size

o 128 KB

o 128 KB

A Compressed_Block has the extra restriction that Block_Size is always strictly less than the decompressed size. If this condition cannot be respected, the block must be sent uncompressed instead (i.e., treated as a Raw_Block).

Compressed_Blockには、Block_Sizeが常に厳密に解凍されたサイズよりも小さいという追加の制限があります。この条件が守られない場合は、代わりにブロックを圧縮せずに送信する必要があります(Raw_Blockとして扱われます)。

3.1.1.3. Compressed Blocks
3.1.1.3. 圧縮ブロック

To decompress a compressed block, the compressed size must be provided from the Block_Size field within Block_Header.

圧縮ブロックを解凍するには、Block_Header内のBlock_Sizeフィールドから圧縮サイズを提供する必要があります。

A compressed block consists of two sections: a Literals Section (Section 3.1.1.3.1) and a Sequences_Section (Section 3.1.1.3.2). The results of the two sections are then combined to produce the decompressed data in Sequence Execution (Section 3.1.1.4).

圧縮ブロックは、リテラルセクション(セクション3.1.1.3.1)とシーケンス_セクション(セクション3.1.1.3.2)の2つのセクションで構成されます。次に、2つのセクションの結果を組み合わせて、シーケンス実行(セクション3.1.1.4)で解凍されたデータを生成します。

To decode a compressed block, the following elements are necessary:

圧縮ブロックをデコードするには、次の要素が必要です。

o Previous decoded data, up to a distance of Window_Size, or the beginning of the Frame, whichever is smaller. Single_Segment_Flag will be set in the latter case.

o 以前にデコードされたデータ、最大Window_Sizeの距離、またはフレームの先頭のいずれか小さい方。後者の場合、Single_Segment_Flagが設定されます。

o List of "recent offsets" from the previous Compressed_Block.

o 以前のCompressed_Blockからの「最近のオフセット」のリスト。

o The previous Huffman tree, required by Treeless_Literals_Block type.

o Treeless_Literals_Blockタイプに必要な以前のハフマンツリー。

o Previous Finite State Entropy (FSE) decoding tables, required by Repeat_Mode, for each symbol type (literals lengths, match lengths, offsets).

o 以前の有限状態エントロピー(FSE)デコードテーブル(Repeat_Modeで必要)、各シンボルタイプ(リテラル長、一致長、オフセット)

Note that decoding tables are not always from the previous Compressed_Block:

デコードテーブルは常に前のCompressed_Blockからのものではないことに注意してください。

o Every decoding table can come from a dictionary.

o すべてのデコードテーブルは、辞書から取得できます。

o The Huffman tree comes from the previous Compressed_Literals_Block.

o ハフマンツリーは、以前のCompressed_Literals_Blockに由来します。

3.1.1.3.1. Literals_Section_Header
3.1.1.3.1. Literals_Section_Header

All literals are regrouped in the first part of the block. They can be decoded first and then copied during Sequence Execution (see Section 3.1.1.4), or they can be decoded on the flow during Sequence Execution.

すべてのリテラルは、ブロックの最初の部分で再グループ化されます。最初にデコードしてから、シーケンス実行中にコピーするか(セクション3.1.1.4を参照)、またはシーケンス実行中にフローでデコードできます。

Literals can be stored uncompressed or compressed using Huffman prefix codes. When compressed, an optional tree description can be present, followed by 1 or 4 streams.

リテラルは、非圧縮で格納することも、Huffmanプレフィックスコードを使用して圧縮することもできます。圧縮されると、オプションのツリー記述が存在し、その後に1つまたは4つのストリームが続きます。

     +----------------------------+
     |   Literals_Section_Header  |
     +----------------------------+
     | [Huffman_Tree_Description] |
     +----------------------------+
     |        [Jump_Table]        |
     +----------------------------+
     |          Stream_1          |
     +----------------------------+
     |         [Stream_2]         |
     +----------------------------+
     |         [Stream_3]         |
     +----------------------------+
     |         [Stream_4]         |
     +----------------------------+
        
3.1.1.3.1.1. Literals_Section_Header
3.1.1.3.1.1. Literals_Section_Header

This field describes how literals are packed. It's a byte-aligned variable-size bit field, ranging from 1 to 5 bytes, using little-endian convention.

このフィールドは、リテラルがどのようにパックされるかを説明します。これは、バイト単位の可変サイズのビットフィールドで、リトルエンディアン規則を使用して、1〜5バイトの範囲です。

     +---------------------+-----------+
     | Literals_Block_Type |  2 bits   |
     +---------------------+-----------+
     |     Size_Format     | 1-2 bits  |
     +---------------------+-----------+
     |   Regenerated_Size  | 5-20 bits |
     +---------------------+-----------+
     |  [Compressed_Size]  | 0-18 bits |
     +---------------------+-----------+
        

In this representation, bits at the top are the lowest bits.

この表現では、一番上のビットが最下位ビットです。

The Literals_Block_Type field uses the two lowest bits of the first byte, describing four different block types:

Literals_Block_Typeフィールドは、最初のバイトの下位2ビットを使用して、4つの異なるブロックタイプを記述します。

     +---------------------------+-------+
     |    Literals_Block_Type    | Value |
     +---------------------------+-------+
     |     Raw_Literals_Block    |   0   |
     +---------------------------+-------+
     |     RLE_Literals_Block    |   1   |
     +---------------------------+-------+
     | Compressed_Literals_Block |   2   |
     +---------------------------+-------+
     |  Treeless_Literals_Block  |   3   |
     +---------------------------+-------+
        

Raw_Literals_Block: Literals are stored uncompressed. Literals_Section_Content is Regenerated_Size.

Raw_Literals_Block:リテラルは非圧縮で保存されます。 Literals_Section_ContentはRegenerated_Sizeです。

RLE_Literals_Block: Literals consist of a single-byte value repeated Regenerated_Size times. Literals_Section_Content is 1.

RLE_Literals_Block:リテラルは、Regenerated_Size回繰り返される1バイトの値で構成されます。 Literals_Section_Contentは1です。

Compressed_Literals_Block: This is a standard Huffman-compressed block, starting with a Huffman tree description. See details below. Literals_Section_Content is Compressed_Size.

Compressed_Literals_Block:これは、ハフマンツリーの説明から始まる、標準のハフマン圧縮ブロックです。詳細は以下をご覧ください。 Literals_Section_ContentはCompressed_Sizeです。

Treeless_Literals_Block: This is a Huffman-compressed block, using the Huffman tree from the previous Compressed_Literals_Block, or a dictionary if there is no previous Huffman-compressed literals block. Huffman_Tree_Description will be skipped. Note that if this mode is triggered without any previous Huffman-table in the frame (or dictionary, per Section 5), it should be treated as data corruption. Literals_Section_Content is Compressed_Size.

Treeless_Literals_Block:これは、以前のCompressed_Literals_Blockのハフマンツリーを使用したハフマン圧縮ブロック、または以前のハフマン圧縮リテラルブロックがない場合は辞書です。 Huffman_Tree_Descriptionはスキップされます。フレーム内に以前のハフマンテーブル(またはセクション5のディクショナリ)なしでこのモードがトリガーされた場合は、データの破損として扱う必要があります。 Literals_Section_ContentはCompressed_Sizeです。

The Size_Format is divided into two families:

Size_Formatは2つのファミリーに分けられます。

o For Raw_Literals_Block and RLE_Literals_Block, it's only necessary to decode Regenerated_Size. There is no Compressed_Size field.

o Raw_Literals_BlockおよびRLE_Literals_Blockの場合、Regenerated_Sizeをデコードするだけで十分です。 Compressed_Sizeフィールドはありません。

o For Compressed_Block and Treeless_Literals_Block, it's required to decode both Compressed_Size and Regenerated_Size (the decompressed size). It's also necessary to decode the number of streams (1 or 4).

o Compressed_BlockおよびTreeless_Literals_Blockの場合、Compressed_SizeとRegenerated_Size(解凍されたサイズ)の両方をデコードする必要があります。ストリームの数(1または4)をデコードすることも必要です。

For values spanning several bytes, the convention is little endian.

数バイトにわたる値の場合、規則はリトルエンディアンです。

Size_Format for Raw_Literals_Block and RLE_Literals_Block uses 1 or 2 bits. Its value is (Literals_Section_Header[0]>>2) & 0x3.

Raw_Literals_BlockおよびRLE_Literals_BlockのSize_Formatは、1ビットまたは2ビットを使用します。その値は(Literals_Section_Header [0] >> 2)&0x3です。

Size_Format == 00 or 10: Size_Format uses 1 bit. Regenerated_Size uses 5 bits (value 0-31). Literals_Section_Header uses 1 byte. Regenerated_Size = Literal_Section_Header[0]>>3.

Size_Format == 00または10:Size_Formatは1ビットを使用します。 Regenerated_Sizeは5ビットを使用します(値0〜31)。 Literals_Section_Headerは1バイトを使用します。 Regenerated_Size = Literal_Section_Header [0] >> 3。

   Size_Format == 01:  Size_Format uses 2 bits.  Regenerated_Size uses
      12 bits (values 0-4095).  Literals_Section_Header uses 2 bytes.
      Regenerated_Size = (Literals_Section_Header[0]>>4) +
      (Literals_Section_Header[1]<<4).
        
   Size_Format == 11:  Size_Format uses 2 bits.  Regenerated_Size uses
      20 bits (values 0-1048575).  Literals_Section_Header uses 3 bytes.
      Regenerated_Size = (Literals_Section_Header[0]>>4) +
      (Literals_Section_Header[1]<<4) + (Literals_Section_Header[2]<<12)
        

Only Stream_1 is present for these cases. Note that it is permitted to represent a short value (for example, 13) using a long format, even if it's less efficient.

これらの場合、Stream_1のみが存在します。効率が低くても、長い形式を使用して短い値(13など)を表すことが許可されていることに注意してください。

Size_Format for Compressed_Literals_Block and Treeless_Literals_Block always uses 2 bits.

Compressed_Literals_BlockおよびTreeless_Literals_BlockのSize_Formatは常に2ビットを使用します。

Size_Format == 00: A single stream. Both Regenerated_Size and Compressed_Size use 10 bits (values 0-1023). Literals_Section_Header uses 3 bytes.

Size_Format == 00:単一のストリーム。 Regenerated_SizeとCompressed_Sizeはどちらも10ビットを使用します(値0〜1023)。 Literals_Section_Headerは3バイトを使用します。

Size_Format == 01: 4 streams. Both Regenerated_Size and Compressed_Size use 10 bits (values 0-1023). Literals_Section_Header uses 3 bytes.

Size_Format == 01:4ストリーム。 Regenerated_SizeとCompressed_Sizeはどちらも10ビットを使用します(値0〜1023)。 Literals_Section_Headerは3バイトを使用します。

Size_Format == 10: 4 streams. Both Regenerated_Size and Compressed_Size use 14 bits (values 0-16383). Literals_Section_Header uses 4 bytes.

Size_Format == 10:4ストリーム。 Regenerated_SizeとCompressed_Sizeはどちらも14ビット(値0〜16383)を使用します。 Literals_Section_Headerは4バイトを使用します。

Size_Format == 11: 4 streams. Both Regenerated_Size and Compressed_Size use 18 bits (values 0-262143). Literals_Section_Header uses 5 bytes.

Size_Format == 11:4ストリーム。 Regenerated_SizeとCompressed_Sizeはどちらも18ビット(値0〜262143)を使用します。 Literals_Section_Headerは5バイトを使用します。

Both the Compressed_Size and Regenerated_Size fields follow little-endian convention. Note that Compressed_Size includes the size of the Huffman_Tree_Description when it is present.

Compressed_SizeフィールドとRegenerated_Sizeフィールドはどちらもリトルエンディアンの規則に従います。 Compressed_Sizeには、Huffman_Tree_Descriptionが存在する場合、そのサイズが含まれることに注意してください。

3.1.1.3.1.2. Raw_Literals_Block
3.1.1.3.1.2. Raw_Literals_Block

The data in Stream_1 is Regenerated_Size bytes long. It contains the raw literals data to be used during Sequence Execution (Section 3.1.1.3.2).

Stream_1のデータの長さはRegenerated_Sizeバイトです。これには、シーケンス実行中に使用される生のリテラルデータが含まれます(セクション3.1.1.3.2)。

3.1.1.3.1.3. RLE_Literals_Block
3.1.1.3.1.3. RLE_Literals_Block

Stream_1 consists of a single byte that should be repeated Regenerated_Size times to generate the decoded literals.

Stream_1は、デコードされたリテラルを生成するためにRegenerated_Size回繰り返される単一バイトで構成されています。

3.1.1.3.1.4. Compressed_Literals_Block and Treeless_Literals_Block
3.1.1.3.1.4. Compressed_Literals_BlockおよびTreeless_Literals_Block

Both of these modes contain Huffman-encoded data. For Treeless_Literals_Block, the Huffman table comes from the previously compressed literals block, or from a dictionary; see Section 5.

これらのモードの両方にハフマンエンコードされたデータが含まれています。 Treeless_Literals_Blockの場合、ハフマンテーブルは、以前に圧縮されたリテラルブロックまたは辞書から取得されます。セクション5を参照してください。

3.1.1.3.1.5. Huffman_Tree_Description
3.1.1.3.1.5. Huffman_Tree_Description

This section is only present when the Literals_Block_Type type is Compressed_Literals_Block (2). The format of Huffman_Tree_Description can be found in Section 4.2.1. The size of Huffman_Tree_Description is determined during the decoding process. It must be used to determine where streams begin.

このセクションは、Literals_Block_TypeタイプがCompressed_Literals_Block(2)の場合にのみ表示されます。 Huffman_Tree_Descriptionのフォーマットはセクション4.2.1にあります。 Huffman_Tree_Descriptionのサイズは、デコードプロセス中に決定されます。ストリームの開始位置を決定するために使用する必要があります。

Total_Streams_Size = Compressed_Size - Huffman_Tree_Description_Size

Total_Streams_Size = Compressed_Size-Huffman_Tree_Description_Size

3.1.1.3.1.6. Jump_Table
3.1.1.3.1.6. Jump_Table

The Jump_Table is only present when there are 4 Huffman-coded streams.

Jump_Tableは、4つのハフマンコーディングされたストリームがある場合にのみ存在します。

(Reminder: Huffman-compressed data consists of either 1 or 4 Huffman-coded streams.)

(注意:ハフマン圧縮データは、1つまたは4つのハフマン符号化ストリームで構成されます。)

If only 1 stream is present, it is a single bitstream occupying the entire remaining portion of the literals block, encoded as described within Section 4.2.2.

ストリームが1つしかない場合、それは、4.2.2項で説明されているようにエンコードされた、リテラルブロックの残りの部分全体を占める単一のビットストリームです。

If there are 4 streams, Literals_Section_Header only provides enough information to know the decompressed and compressed sizes of all 4 streams combined. The decompressed size of each stream is equal to (Regenerated_Size+3)/4, except for the last stream, which may be up to 3 bytes smaller, to reach a total decompressed size as specified in Regenerated_Size.

4つのストリームがある場合、Literals_Section_Headerは、4つすべてのストリームの組み合わせの解凍および圧縮サイズを知るのに十分な情報のみを提供します。各ストリームの圧縮解除されたサイズは、(Regenerated_Size + 3)/ 4に等しくなりますが、Regenerated_Sizeで指定された合計圧縮解除サイズに到達するために、最大3バイト小さい場合があります。

The compressed size of each stream is provided explicitly in the Jump_Table. The Jump_Table is 6 bytes long and consists of three 2-byte little-endian fields, describing the compressed sizes of the first 3 streams. Stream4_Size is computed from Total_Streams_Size minus sizes of other streams.

各ストリームの圧縮サイズは、Jump_Tableで明示的に提供されます。 Jump_Tableは6バイト長で、3つの2バイトリトルエンディアンフィールドで構成され、最初の3つのストリームの圧縮サイズを記述します。 Stream4_Sizeは、Total_Streams_Sizeから他のストリームのサイズを差し引いて計算されます。

     Stream4_Size = Total_Streams_Size - 6
                    - Stream1_Size - Stream2_Size
                    - Stream3_Size
        

Note that if Stream1_Size + Stream2_Size + Stream3_Size exceeds Total_Streams_Size, the data are considered corrupted.

Stream1_Size + Stream2_Size + Stream3_SizeがTotal_Streams_Sizeを超える場合、データは破損していると見なされます。

Each of these 4 bitstreams is then decoded independently as a Huffman-Coded stream, as described in Section 4.2.2.

セクション4.2.2で説明するように、これらの4つのビットストリームのそれぞれは、ハフマン符号化ストリームとして個別にデコードされます。

3.1.1.3.2. Sequences_Section
3.1.1.3.2. シーケンス_セクション

A compressed block is a succession of sequences. A sequence is a literal copy command, followed by a match copy command. A literal copy command specifies a length. It is the number of bytes to be copied (or extracted) from the Literals Section. A match copy command specifies an offset and a length.

圧縮ブロックは一連のシーケンスです。シーケンスはリテラルコピーコマンドで、その後に一致コピーコマンドが続きます。リテラルコピーコマンドは長さを指定します。これは、リテラルセクションからコピー(または抽出)されるバイト数です。 match copyコマンドは、オフセットと長さを指定します。

When all sequences are decoded, if there are literals left in the literals section, these bytes are added at the end of the block.

すべてのシーケンスがデコードされると、リテラルセクションにリテラルが残っている場合、これらのバイトはブロックの最後に追加されます。

This is described in more detail in Section 3.1.1.4.

これについては、セクション3.1.1.4で詳しく説明します。

The Sequences_Section regroups all symbols required to decode commands. There are three symbol types: literals lengths, offsets, and match lengths. They are encoded together, interleaved, in a single "bitstream".

Sequences_Sectionは、コマンドのデコードに必要なすべてのシンボルを再グループ化します。シンボルには、リテラルの長さ、オフセット、および一致の長さの3つのタイプがあります。それらは、単一の「ビットストリーム」で一緒にエンコードされ、インターリーブされます。

The Sequences_Section starts by a header, followed by optional probability tables for each symbol type, followed by the bitstream.

Sequences_Sectionはヘッダーで始まり、その後に各シンボルタイプのオプションの確率テーブルが続き、その後にビットストリームが続きます。

     Sequences_Section_Header
       [Literals_Length_Table]
       [Offset_Table]
       [Match_Length_Table]
       bitStream
        

To decode the Sequences_Section, it's necessary to know its size. This size is deduced from the size of the Literals_Section: Sequences_Section_Size = Block_Size - Literals_Section_Header - Literals_Section_Content

Sequences_Sectionをデコードするには、そのサイズを知る必要があります。このサイズは、Literals_Sectionのサイズから推定されます。Sequences_Section_Size= Block_Size-Literals_Section_Header-Literals_Section_Content

3.1.1.3.2.1. Sequences_Section_Header
3.1.1.3.2.1. Sequences_Section_Header

This header consists of two items:

このヘッダーは2つの項目で構成されています。

o Number_of_Sequences

o シーケンス数

o Symbol_Compression_Modes

o Symbol_Compression_Modes

Number_of_Sequences is a variable size field using between 1 and 3 bytes. If the first byte is "byte0":

Number_of_Sequencesは、1〜3バイトを使用する可変サイズのフィールドです。最初のバイトが「byte0」の場合:

o if (byte0 == 0): there are no sequences. The sequence section stops here. Decompressed content is defined entirely as Literals Section content. The FSE tables used in Repeat_Mode are not updated.

o if(byte0 == 0):シーケンスはありません。シーケンスセクションはここで終了します。解凍されたコンテンツは、完全にリテラルセクションのコンテンツとして定義されます。 Repeat_Modeで使用されるFSEテーブルは更新されません。

o if (byte0 < 128): Number_of_Sequences = byte0. Uses 1 byte.

o if(byte0 <128):Number_of_Sequences = byte0。 1バイトを使用します。

o if (byte0 < 255): Number_of_Sequences = ((byte0 - 128) << 8) + byte1. Uses 2 bytes.

o if(byte0 <255):Number_of_Sequences =((byte0-128)<< 8)+ byte1。 2バイトを使用します。

o if (byte0 == 255): Number_of_Sequences = byte1 + (byte2 << 8) + 0x7F00. Uses 3 bytes.

o if(byte0 == 255):Number_of_Sequences = byte1 +(byte2 << 8)+ 0x7F00。 3バイトを使用します。

Symbol_Compression_Modes is a single byte, defining the compression mode of each symbol type.

Symbol_Compression_Modesは1バイトで、各シンボルタイプの圧縮モードを定義します。

     +-------------+----------------------+
     | Bit Number  |      Field Name      |
     +-------------+----------------------+
     |     7-6     | Literal_Lengths_Mode |
     +-------------+----------------------+
     |     5-4     |     Offsets_Mode     |
     +-------------+----------------------+
     |     3-2     |  Match_Lengths_Mode  |
     +-------------+----------------------+
     |     1-0     |       Reserved       |
     +-------------+----------------------+
        

The last field, Reserved, must be all zeroes.

最後のフィールドReservedはすべてゼロでなければなりません。

Literals_Lengths_Mode, Offsets_Mode, and Match_Lengths_Mode define the Compression_Mode of literals lengths, offsets, and match lengths symbols, respectively. They follow the same enumeration:

Literals_Lengths_Mode、Offsets_Mode、Match_Lengths_Modeは、それぞれ、リテラルの長さ、オフセット、および長さの一致シンボルのCompression_Modeを定義します。彼らは同じ列挙に従います:

     +-------+---------------------+
     | Value |  Compression_Mode   |
     +-------+---------------------+
     |   0   |   Predefined_Mode   |
     +-------+---------------------+
     |   1   |      RLE_Mode       |
     +-------+---------------------+
     |   2   | FSE_Compressed_Mode |
     +-------+---------------------+
     |   3   |     Repeat_Mode     |
     +-------+---------------------+
        

Predefined_Mode: A predefined FSE (see Section 4.1) distribution table is used, as defined in Section 3.1.1.3.2.2. No distribution table will be present.

Predefined_Mode:セクション3.1.1.3.2.2で定義されているように、事前定義されたFSE(セクション4.1を参照)分散テーブルが使用されます。配布テーブルはありません。

RLE_Mode: The table description consists of a single byte, which contains the symbol's value. This symbol will be used for all sequences.

RLE_Mode:テーブルの説明は、シンボルの値を含む1バイトで構成されます。この記号は、すべてのシーケンスで使用されます。

FSE_Compressed_Mode: Standard FSE compression. A distribution table will be present. The format of this distribution table is described in Section 4.1.1. Note that the maximum allowed accuracy log for literals length and match length tables is 9, and the maximum accuracy log for the offsets table is 8. This mode must not be used when only one symbol is present; RLE_Mode should be used instead (although any other mode will work).

FSE_Compressed_Mode:標準のFSE圧縮。配布テーブルが表示されます。この分布表の形式については、セクション4.1.1で説明します。リテラル長と一致長テーブルの最大許容精度ログは9、オフセットテーブルの最大精度ログは8であることに注意してください。このモードは、シンボルが1つしかない場合は使用しないでください。代わりにRLE_Modeを使用する必要があります(他のモードでも機能します)。

Repeat_Mode: The table used in the previous Compressed_Block with Number_Of_Sequences > 0 will be used again, or if this is the first block, the table in the dictionary will be used. Note that this includes RLE_Mode, so if Repeat_Mode follows RLE_Mode, the same symbol will be repeated. It also includes Predefined_Mode, in which case Repeat_Mode will have the same outcome as Predefined_Mode. No distribution table will be present. If this mode is used without any previous sequence table in the frame (or dictionary; see Section 5) to repeat, this should be treated as corruption.

Repeat_Mode:Number_Of_Sequences> 0の以前のCompressed_Blockで使用されたテーブルが再度使用されます。または、これが最初のブロックの場合は、ディクショナリ内のテーブルが使用されます。これにはRLE_Modeが含まれるため、Repeat_ModeがRLE_Modeの後に続く場合、同じシンボルが繰り返されます。また、Predefined_Modeも含まれています。この場合、Repeat_ModeはPredefined_Modeと同じ結果になります。配布テーブルはありません。フレーム内の以前のシーケンステーブル(またはディクショナリ。セクション5を参照)なしでこのモードを使用して繰り返す場合、これは破損として扱われる必要があります。

3.1.1.3.2.1.1. Sequence Codes for Lengths and Offsets
3.1.1.3.2.1.1. 長さとオフセットのシーケンスコード

Each symbol is a code in its own context, which specifies Baseline and Number_of_Bits to add. Codes are FSE compressed and interleaved with raw additional bits in the same bitstream.

各シンボルは独自のコンテキストのコードであり、追加するBaselineおよびNumber_of_Bitsを指定します。コードはFSE圧縮され、同じビットストリーム内の未加工の追加ビットでインターリーブされます。

Literals length codes are values ranging from 0 to 35 inclusive. They define lengths from 0 to 131071 bytes. The literals length is equal to the decoded Baseline plus the result of reading Number_of_Bits bits from the bitstream, as a little-endian value.

リテラルの長さコードは、0から35までの範囲の値です。それらは0から131071バイトまでの長さを定義します。リテラルの長さは、デコードされたベースラインとリトルエンディアン値としてビットストリームからNumber_of_Bitsビットを読み取った結果を足したものに等しくなります。

     +----------------------+----------+----------------+
     | Literals_Length_Code | Baseline | Number_of_Bits |
     +----------------------+----------+----------------+
     |         0-15         |  length  |       0        |
     +----------------------+----------+----------------+
     |          16          |    16    |       1        |
     +----------------------+----------+----------------+
     |          17          |    18    |       1        |
     +----------------------+----------+----------------+
     |          18          |    20    |       1        |
     +----------------------+----------+----------------+
     |          19          |    22    |       1        |
     +----------------------+----------+----------------+
     |          20          |    24    |       2        |
     +----------------------+----------+----------------+
     |          21          |    28    |       2        |
     +----------------------+----------+----------------+
     |          22          |    32    |       3        |
     +----------------------+----------+----------------+
     |          23          |    40    |       3        |
     +----------------------+----------+----------------+
     |          24          |    48    |       4        |
     +----------------------+----------+----------------+
     |          25          |    64    |       6        |
     +----------------------+----------+----------------+
     |          26          |    128   |       7        |
     +----------------------+----------+----------------+
     |          27          |    256   |       8        |
     +----------------------+----------+----------------+
     |          28          |    512   |       9        |
     +----------------------+----------+----------------+
     |          29          |   1024   |       10       |
     +----------------------+----------+----------------+
     |          30          |   2048   |       11       |
     +----------------------+----------+----------------+
     |          31          |   4096   |       12       |
     +----------------------+----------+----------------+
     |          32          |   8192   |       13       |
     +----------------------+----------+----------------+
     |          33          |  16384   |       14       |
     +----------------------+----------+----------------+
     |          34          |  32768   |       15       |
     +----------------------+----------+----------------+
     |          35          |  65536   |       16       |
     +----------------------+----------+----------------+
        

Match length codes are values ranging from 0 to 52 inclusive. They define lengths from 3 to 131074 bytes. The match length is equal to the decoded Baseline plus the result of reading Number_of_Bits bits from the bitstream, as a little-endian value.

一致長コードは、0から52までの範囲の値です。それらは3から131074バイトの長さを定義します。一致の長さは、デコードされたベースラインとリトルエンディアン値としてビットストリームからNumber_of_Bitsビットを読み取った結果を足したものに等しくなります。

     +-------------------+-----------------------+----------------+
     | Match_Length_Code |       Baseline        | Number_of_Bits |
     +-------------------+-----------------------+----------------+
     |        0-31       | Match_Length_Code + 3 |       0        |
     +-------------------+-----------------------+----------------+
     |         32        |          35           |       1        |
     +-------------------+-----------------------+----------------+
     |         33        |          37           |       1        |
     +-------------------+-----------------------+----------------+
     |         34        |          39           |       1        |
     +-------------------+-----------------------+----------------+
     |         35        |          41           |       1        |
     +-------------------+-----------------------+----------------+
     |         36        |          43           |       2        |
     +-------------------+-----------------------+----------------+
     |         37        |          47           |       2        |
     +-------------------+-----------------------+----------------+
     |         38        |          51           |       3        |
     +-------------------+-----------------------+----------------+
     |         39        |          59           |       3        |
     +-------------------+-----------------------+----------------+
     |         40        |          67           |       4        |
     +-------------------+-----------------------+----------------+
     |         41        |          83           |       4        |
     +-------------------+-----------------------+----------------+
     |         42        |          99           |       5        |
     +-------------------+-----------------------+----------------+
     |         43        |         131           |       7        |
     +-------------------+-----------------------+----------------+
     |         44        |         259           |       8        |
     +-------------------+-----------------------+----------------+
     |         45        |         515           |       9        |
     +-------------------+-----------------------+----------------+
     |         46        |         1027          |       10       |
     +-------------------+-----------------------+----------------+
     |         47        |         2051          |       11       |
     +-------------------+-----------------------+----------------+
     |         48        |         4099          |       12       |
     +-------------------+-----------------------+----------------+
     |         49        |         8195          |       13       |
     +-------------------+-----------------------+----------------+
     |         50        |         16387         |       14       |
     +-------------------+-----------------------+----------------+
     |         51        |         32771         |       15       |
     +-------------------+-----------------------+----------------+
     |         52        |         65539         |       16       |
     +-------------------+-----------------------+----------------+
        

Offset codes are values ranging from 0 to N.

オフセットコードは、0〜Nの範囲の値です。

A decoder is free to limit its maximum supported value for N. Support for values of at least 22 is recommended. At the time of this writing, the reference decoder supports a maximum N value of 31.

デコーダーは、Nのサポートされる最大値を自由に制限できます。少なくとも22の値のサポートをお勧めします。この記事の執筆時点では、リファレンスデコーダーは最大N値31をサポートしています。

An offset code is also the number of additional bits to read in little-endian fashion and can be translated into an Offset_Value using the following formulas:

オフセットコードは、リトルエンディアン方式で読み取る追加のビット数でもあり、次の式を使用してOffset_Valueに変換できます。

     Offset_Value = (1 << offsetCode) + readNBits(offsetCode);
     if (Offset_Value > 3) Offset = Offset_Value - 3;
        

This means that maximum Offset_Value is (2^(N+1))-1, supporting back-reference distance up to (2^(N+1))-4, but it is limited by the maximum back-reference distance (see Section 3.1.1.1.2).

つまり、最大Offset_Valueは(2 ^(N + 1))-1であり、最大(2 ^(N + 1))-4までの後方参照距離をサポートしますが、最大後方参照距離によって制限されます(セクション3.1.1.1.2)。

Offset_Value from 1 to 3 are special: they define "repeat codes". This is described in more detail in Section 3.1.1.5.

1から3までのOffset_Valueは特別です。「オフセットコード」を定義します。これについては、3.1.1.5で詳しく説明します。

3.1.1.3.2.1.2. Decoding Sequences
3.1.1.3.2.1.2. シーケンスのデコード

FSE bitstreams are read in reverse of the direction they are written. In zstd, the compressor writes bits forward into a block, and the decompressor must read the bitstream backwards.

FSEビットストリームは、書き込まれた方向とは逆に読み取られます。 zstdでは、圧縮プログラムはビットを前方にブロックに書き込み、圧縮解除プログラムはビットストリームを逆方向に読み取る必要があります。

To find the start of the bitstream, it is therefore necessary to know the offset of the last byte of the block, which can be found by counting Block_Size bytes after the block header.

したがって、ビットストリームの開始を見つけるには、ブロックの最後のバイトのオフセットを知る必要があります。これは、ブロックヘッダーの後のBlock_Sizeバイトを数えることで見つけることができます。

After writing the last bit containing information, the compressor writes a single 1 bit and then fills the byte with 0-7 zero bits of padding. The last byte of the compressed bitstream cannot be zero for that reason.

情報を含む最後のビットを書き込んだ後、コンプレッサーは1つの1ビットを書き込み、次に0〜7のゼロビットのパディングでバイトを埋めます。そのため、圧縮ビットストリームの最後のバイトをゼロにすることはできません。

When decompressing, the last byte containing the padding is the first byte to read. The decompressor needs to skip 0-7 initial zero bits until the first 1 bit occurs. Afterwards, the useful part of the bitstream begins.

解凍するとき、パディングを含む最後のバイトは、読み取る最初のバイトです。デコンプレッサは、最初の1ビットが発生するまで0〜7の初期ゼロビットをスキップする必要があります。その後、ビットストリームの有用な部分が始まります。

FSE decoding requires a 'state' to be carried from symbol to symbol. For more explanation on FSE decoding, see Section 4.1.

FSEデコードでは、シンボル間で「状態」を伝達する必要があります。 FSEデコードの詳細については、セクション4.1を参照してください。

For sequence decoding, a separate state keeps track of each literal lengths, offsets, and match lengths symbols. Some FSE primitives are also used. For more details on the operation of these primitives, see Section 4.1.

シーケンスのデコードでは、個別の状態が各リテラルの長さ、オフセット、および一致の長さのシンボルを追跡します。一部のFSEプリミティブも使用されます。これらのプリミティブの操作の詳細については、セクション4.1を参照してください。

The bitstream starts with initial FSE state values, each using the required number of bits in their respective accuracy, decoded previously from their normalized distribution. It starts with Literals_Length_State, followed by Offset_State, and finally Match_Length_State.

ビットストリームは、初期のFSE状態値から始まります。各FSE状態値は、それぞれの精度で必要なビット数を使用し、以前に正規化された分布からデコードされます。 Literals_Length_Stateで始まり、次にOffset_Stateが続き、最後にMatch_Length_Stateが続きます。

Note that all values are read backward, so the 'start' of the bitstream is at the highest position in memory, immediately before the last 1 bit for padding.

すべての値が逆方向に読み取られるため、ビットストリームの「開始」は、パディング用の最後の1ビットの直前の、メモリ内の最も高い位置にあることに注意してください。

After decoding the starting states, a single sequence is decoded Number_Of_Sequences times. These sequences are decoded in order from first to last. Since the compressor writes the bitstream in the forward direction, this means the compressor must encode the sequences starting with the last one and ending with the first.

開始状態をデコードした後、単一のシーケンスがNumber_Of_Sequences回デコードされます。これらのシーケンスは、最初から最後の順にデコードされます。コンプレッサーはビットストリームを順方向に書き込むので、これは、コンプレッサーが最後のシーケンスから始まり最初のシーケンスで終わるシーケンスをエンコードする必要があることを意味します。

For each of the symbol types, the FSE state can be used to determine the appropriate code. The code then defines the Baseline and Number_of_Bits to read for each type. The description of the codes for how to determine these values can be found in Section 3.1.1.3.2.1.

シンボルタイプごとに、FSE状態を使用して適切なコードを決定できます。次に、コードはBaselineとNumber_of_Bitsを定義して、各タイプを読み取ります。これらの値を決定する方法のコードの説明は、セクション3.1.1.3.2.1にあります。

Decoding starts by reading the Number_of_Bits required to decode offset. It does the same for Match_Length and then for Literals_Length. This sequence is then used for Sequence Execution (see Section 3.1.1.4).

デコードは、オフセットのデコードに必要なNumber_of_Bitsを読み取ることから始まります。 Match_LengthとLiterals_Lengthの場合も同じです。このシーケンスは、シーケンスの実行に使用されます(セクション3.1.1.4を参照)。

If it is not the last sequence in the block, the next operation is to update states. Using the rules pre-calculated in the decoding tables, Literals_Length_State is updated, followed by Match_Length_State, and then Offset_State. See Section 4.1 for details on how to update states from the bitstream.

ブロックの最後のシーケンスでない場合、次の操作は状態の更新です。デコードテーブルで事前に計算されたルールを使用して、Literals_Length_Stateが更新され、次にMatch_Length_State、次にOffset_Stateが続きます。ビットストリームから状態を更新する方法の詳細については、セクション4.1を参照してください。

This operation will be repeated Number_of_Sequences times. At the end, the bitstream shall be entirely consumed; otherwise, the bitstream is considered corrupted.

この操作はNumber_of_Sequences回繰り返されます。最後に、ビットストリームは完全に消費されます。それ以外の場合、ビットストリームは破損していると見なされます。

3.1.1.3.2.2. Default Distributions
3.1.1.3.2.2. デフォルトの分布

If Predefined_Mode is selected for a symbol type, its FSE decoding table is generated from a predefined distribution table defined here. For details on how to convert this distribution into a decoding table, see Section 4.1.

シンボルタイプにPredefined_Modeが選択されている場合、そのFSEデコードテーブルは、ここで定義されている事前定義された分布テーブルから生成されます。この分布をデコードテーブルに変換する方法の詳細については、セクション4.1を参照してください。

3.1.1.3.2.2.1. Literals Length
3.1.1.3.2.2.1. リテラルの長さ

The decoding table uses an accuracy log of 6 bits (64 states).

デコードテーブルは、6ビット(64ステート)の精度ログを使用します。

short literalsLength_defaultDistribution[36] = { 4, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 1, 1, 1, 1, 1, -1,-1,-1,-1 };

短いリテラルLength_defaultDistribution [36] = {4、3、2、2、2、2、2、2、2、2、2、2、1、1、1、2、2、2、2、2、2 、2、2、2、3、2、1、1、1、1、1、-1、-1、-1、-1};

3.1.1.3.2.2.2. Match Length
3.1.1.3.2.2.2. 長さに合わせる

The decoding table uses an accuracy log of 6 bits (64 states).

デコードテーブルは、6ビット(64ステート)の精度ログを使用します。

short matchLengths_defaultDistribution[53] = { 1, 4, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,-1,-1, -1,-1,-1,-1,-1 };

short matchLengths_defaultDistribution [53] = {1、4、3、2、2、2、2、2、2、1、1、1、1、1、1、1、1、1、1、1、1、1 、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、- 1、-1、-1、-1、-1、-1、-1};

3.1.1.3.2.2.3. Offset Codes
3.1.1.3.2.2.3. オフセットコード

The decoding table uses an accuracy log of 5 bits (32 states), and supports a maximum N value of 28, allowing offset values up to 536,870,908.

デコードテーブルは5ビット(32ステート)の精度ログを使用し、最大N値28をサポートし、最大536,870,908のオフセット値を許可します。

If any sequence in the compressed block requires a larger offset than this, it's not possible to use the default distribution to represent it.

圧縮ブロックのシーケンスでこれよりも大きなオフセットが必要な場合、デフォルトの分布を使用してそれを表すことはできません。

short offsetCodes_defaultDistribution[29] = { 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,-1,-1,-1,-1,-1 };

short offsetCodes_defaultDistribution [29] = {1、1、1、1、1、1、2、2、2、1、1、1、1、1、1、1、1、1、1、1、1、1 、1、1、-1、-1、-1、-1、-1};

3.1.1.4. Sequence Execution
3.1.1.4. シーケンス実行

Once literals and sequences have been decoded, they are combined to produce the decoded content of a block.

リテラルとシーケンスがデコードされると、それらが組み合わされて、ブロックのデコードされたコンテンツが生成されます。

Each sequence consists of a tuple of (literals_length, offset_value, match_length), decoded as described in the Sequences_Section (Section 3.1.1.3.2). To execute a sequence, first copy literals_length bytes from the decoded literals to the output.

各シーケンスは、(literals_length、offset_value、match_length)のタプルで構成され、Sequences_Section(セクション3.1.1.3.2)の説明に従ってデコードされます。シーケンスを実行するには、最初に、literals_lengthバイトをデコードされたリテラルから出力にコピーします。

Then, match_length bytes are copied from previous decoded data. The offset to copy from is determined by offset_value:

次に、match_lengthバイトが以前にデコードされたデータからコピーされます。コピー元のオフセットは、offset_valueによって決定されます。

o if Offset_Value > 3, then the offset is Offset_Value - 3;

o Offset_Value> 3の場合、オフセットはOffset_Value-3です。

o if Offset_Value is from 1-3, the offset is a special repeat offset value. See Section 3.1.1.5 for how the offset is determined in this case.

o Offset_Valueが1〜3の場合、オフセットは特別な繰り返しオフセット値です。この場合のオフセットの決定方法については、セクション3.1.1.5を参照してください。

The offset is defined as from the current position (after copying the literals), so an offset of 6 and a match length of 3 means that 3 bytes should be copied from 6 bytes back. Note that all offsets leading to previously decoded data must be smaller than Window_Size defined in Frame_Header_Descriptor (Section 3.1.1.1.1).

オフセットは(リテラルをコピーした後の)現在の位置からのオフセットとして定義されるため、オフセット6と一致長3は、6バイトから3バイトをコピーする必要があることを意味します。以前にデコードされたデータにつながるすべてのオフセットは、Frame_Header_Descriptor(セクション3.1.1.1.1)で定義されたWindow_Sizeよりも小さくなければならないことに注意してください。

3.1.1.5. Repeat Offsets
3.1.1.5. オフセットを繰り返す

As seen above, the first three values define a repeated offset; we will call them Repeated_Offset1, Repeated_Offset2, and Repeated_Offset3. They are sorted in recency order, with Repeated_Offset1 meaning "most recent one".

上記のように、最初の3つの値は繰り返しオフセットを定義します。それらをRepeated_Offset1、Repeated_Offset2、およびRepeated_Offset3と呼びます。それらは、Recented_Offset1が「最新のもの」を意味する最新の順序でソートされます。

If offset_value is 1, then the offset used is Repeated_Offset1, etc.

offset_valueが1の場合、使用されるオフセットはRepeated_Offset1などです。

There is one exception: When the current sequence's literals_length is 0, repeated offsets are shifted by 1, so an offset_value of 1 means Repeated_Offset2, an offset_value of 2 means Repeated_Offset3, and an offset_value of 3 means Repeated_Offset1 - 1_byte.

例外が1つあります。現在のシーケンスのliterals_lengthが0の場合、繰り返されるオフセットは1だけシフトされるため、offset_value 1はRepeated_Offset2を意味し、offset_value 2はRepeated_Offset3を意味し、offset_value 3はRepeated_Offset1-1_byteを意味します。

For the first block, the starting offset history is populated with the following values: Repeated_Offset1 (1), Repeated_Offset2 (4), and Repeated_Offset3 (8), unless a dictionary is used, in which case they come from the dictionary.

最初のブロックの場合、開始オフセット履歴には、Repeated_Offset1(1)、Repeated_Offset2(4)、およびRepeated_Offset3(8)の値が入力されます。ただし、辞書が使用されている場合は、辞書から取得されます。

Then each block gets its starting offset history from the ending values of the most recent Compressed_Block. Note that blocks that are not Compressed_Block are skipped; they do not contribute to offset history.

次に、各ブロックは最新のCompressed_Blockの終了値から開始オフセット履歴を取得します。 Compressed_Blockでないブロックはスキップされることに注意してください。それらはオフセット履歴に寄与しません。

The newest offset takes the lead in offset history, shifting others back (up to its previous place if it was already present). This means that when Repeated_Offset1 (most recent) is used, history is unmodified. When Repeated_Offset2 is used, it is swapped with Repeated_Offset1. If any other offset is used, it becomes Repeated_Offset1, and the rest are shifted back by 1.

最新のオフセットがオフセット履歴で先頭になり、他のオフセットを(既に存在していた場合は前の場所に)戻します。つまり、Repeated_Offset1(最新)を使用すると、履歴は変更されません。 Repeated_Offset2を使用すると、Repeated_Offset1と入れ替わります。他のオフセットが使用されている場合、それはRepeated_Offset1になり、残りは1だけ後ろにシフトされます。

3.1.2. Skippable Frames
3.1.2. スキップ可能なフレーム
     +--------------+------------+-----------+
     | Magic_Number | Frame_Size | User_Data |
     +--------------+------------+-----------+
     |    4 bytes   |   4 bytes  |  n bytes  |
     +--------------+------------+-----------+
        

Skippable frames allow the insertion of user-defined metadata into a flow of concatenated frames.

スキップ可能なフレームにより、ユーザー定義のメタデータを連結フレームのフローに挿入できます。

Skippable frames defined in this specification are compatible with skippable frames in [LZ4].

この仕様で定義されているスキップ可能なフレームは、[LZ4]のスキップ可能なフレームと互換性があります。

From a compliant decoder perspective, skippable frames simply need to be skipped, and their content ignored, resuming decoding after the skippable frame.

準拠するデコーダーの観点からは、スキップ可能なフレームは単にスキップする必要があり、そのコンテンツは無視され、スキップ可能なフレームの後にデコードが再開されます。

It should be noted that a skippable frame can be used to watermark a stream of concatenated frames embedding any kind of tracking information (even just a Universally Unique Identifier (UUID)). Users wary of such possibility should scan the stream of concatenated frames in an attempt to detect such frames for analysis or removal.

スキップ可能なフレームを使用して、任意の種類の追跡情報(Universally Unique Identifier(UUID)でも)を埋め込んだ連結フレームのストリームに透かしを入れることができることに注意してください。このような可能性に注意するユーザーは、分析または削除のためにそのようなフレームを検出する試みで、連結されたフレームのストリームをスキャンする必要があります。

The fields are:

フィールドは次のとおりです。

Magic_Number: 4 bytes, little-endian format. Value: 0x184D2A5?, which means any value from 0x184D2A50 to 0x184D2A5F. All 16 values are valid to identify a skippable frame. This specification does not detail any specific tagging methods for skippable frames.

Magic_Number:4バイト、リトルエンディアン形式。値:0x184D2A5 ?、つまり0x184D2A50から0x184D2A5Fまでの任意の値を意味します。 16個の値はすべて、スキップ可能なフレームを識別するために有効です。この仕様では、スキップ可能なフレームの特定のタグ付け方法については詳しく説明していません。

Frame_Size: This is the size, in bytes, of the following User_Data (without including the magic number nor the size field itself). This field is represented using 4 bytes, little-endian format, unsigned 32 bits. This means User_Data can't be bigger than (2^32-1) bytes.

Frame_Size:これは、次のUser_Dataのサイズ(バイト単位)です(マジックナンバーもサイズフィールド自体も含まれません)。このフィールドは、4バイト、リトルエンディアン形式、符号なし32ビットを使用して表されます。つまり、User_Dataは(2 ^ 32-1)バイトを超えることはできません。

User_Data: This field can be anything. Data will just be skipped by the decoder.

User_Data:このフィールドは何でもかまいません。データはデコーダーによってスキップされます。

4. Entropy Encoding
4. エントロピーエンコーディング

Two types of entropy encoding are used by the Zstandard format: FSE and Huffman coding. Huffman is used to compress literals, while FSE is used for all other symbols (Literals_Length_Code, Match_Length_Code, and offset codes) and to compress Huffman headers.

Zstandardフォーマットでは、FSEとハフマンコーディングの2種類のエントロピーエンコーディングが使用されます。 HSEはリテラルの圧縮に使用され、FSEは他のすべてのシンボル(Literals_Length_Code、Match_Length_Code、およびオフセットコード)に使用され、Huffmanヘッダーの圧縮に使用されます。

4.1. FSE
4.1. ESF

FSE, short for Finite State Entropy, is an entropy codec based on [ANS]. FSE encoding/decoding involves a state that is carried over between symbols, so decoding must be done in the opposite direction as encoding. Therefore, all FSE bitstreams are read from end to beginning. Note that the order of the bits in the stream is not reversed; they are simply read in the reverse order from which they were written.

FSEは、有限状態エントロピーの略で、[ANS]に基づくエントロピーコーデックです。 FSEエンコーディング/デコーディングには、シンボル間で引き継がれる状態が含まれるため、デコーディングはエンコーディングとは逆の方向で行う必要があります。したがって、すべてのFSEビットストリームは最初から最後まで読み込まれます。ストリーム内のビットの順序は逆にならないことに注意してください。それらは、書き込まれたときとは逆の順序で単に読み取られます。

For additional details on FSE, see Finite State Entropy [FSE].

FSEの詳細については、有限状態エントロピー[FSE]を参照してください。

FSE decoding involves a decoding table that has a power of 2 size and contains three elements: Symbol, Num_Bits, and Baseline. The base 2 logarithm of the table size is its Accuracy_Log. An FSE state value represents an index in this table.

FSEデコードには、2の累乗サイズを持ち、Symbol、Num_Bits、およびBaselineの3つの要素を含むデコードテーブルが含まれます。テーブルサイズの2を底とする対数は、そのAccuracy_Logです。 FSE状態値は、このテーブルのインデックスを表します。

To obtain the initial state value, consume Accuracy_Log bits from the stream as a little-endian value. The next symbol in the stream is the Symbol indicated in the table for that state. To obtain the next state value, the decoder should consume Num_Bits bits from the stream as a little-endian value and add it to Baseline.

初期状態値を取得するには、ストリームからAccuracy_Logビットをリトルエンディアン値として消費します。ストリームの次のシンボルは、その状態の表に示されているシンボルです。次の状態値を取得するには、デコーダーがストリームからNum_Bitsビットをリトルエンディアン値として消費し、それをベースラインに追加する必要があります。

4.1.1. FSE Table Description
4.1.1. FSEテーブルの説明

To decode FSE streams, it is necessary to construct the decoding table. The Zstandard format encodes FSE table descriptions as described here.

FSEストリームをデコードするには、デコードテーブルを作成する必要があります。ここで説明するように、ZstandardフォーマットはFSEテーブルの説明をエンコードします。

An FSE distribution table describes the probabilities of all symbols from 0 to the last present one (included) on a normalized scale of (1 << Accuracy_Log). Note that there must be two or more symbols with non-zero probability.

FSE分布表は、(1 << Accuracy_Log)の正規化されたスケールで、0から最後に存在するもの(含まれる)までのすべてのシンボルの確率を示します。確率がゼロでない2つ以上のシンボルが必要であることに注意してください。

A bitstream is read forward, in little-endian fashion. It is not necessary to know its exact size, since the size will be discovered and reported by the decoding process. The bitstream starts by reporting on which scale it operates. If low4bits designates the lowest 4 bits of the first byte, then Accuracy_Log = low4bits + 5.

ビットストリームは、リトルエンディアン方式で前方に読み込まれます。サイズはデコードプロセスによって検出および報告されるため、正確なサイズを知る必要はありません。ビットストリームは、どのスケールで動作するかをレポートすることから始まります。 low4bitsが最初のバイトの最下位4ビットを指定する場合、Accuracy_Log = low4bits + 5。

This is followed by each symbol value, from 0 to the last present one. The number of bits used by each field is variable and depends on:

この後には、0から最後の現在までの各シンボル値が続きます。各フィールドで使用されるビット数は可変であり、以下に依存します。

Remaining probabilities + 1: For example, presuming an Accuracy_Log of 8, and presuming 100 probabilities points have already been distributed, the decoder may read any value from 0 to (256 - 100 + 1) == 157, inclusive. Therefore, it must read log2sup(157) == 8 bits.

残りの確率+ 1:たとえば、8のAccuracy_Logを推定し、100の確率ポイントがすでに配布されていると推定すると、デコーダーは0から(256-100 + 1)== 157までの任意の値を読み取ることができます。したがって、log2sup(157)== 8ビットを読み取る必要があります。

Value decoded: Small values use 1 fewer bit. For example, presuming values from 0 to 157 (inclusive) are possible, 255 - 157 = 98 values are remaining in an 8-bit field. The first 98 values (hence from 0 to 97) use only 7 bits, and values from 98 to 157 use 8 bits. This is achieved through this scheme:

デコードされた値:小さい値は1ビット少ないビットを使用します。たとえば、0〜157(両端を含む)の推定値が可能であり、8ビットのフィールドには255〜157 = 98の値が残っています。最初の98個の値(したがって0〜97)は7ビットのみを使用し、98〜157個の値は8ビットを使用します。これは次のスキームによって実現されます。

     +------------+---------------+-----------+
     | Value Read | Value Decoded | Bits Used |
     +------------+---------------+-----------+
     |   0 - 97   |     0 - 97    |     7     |
     +------------+---------------+-----------+
     |  98 - 127  |    98 - 127   |     8     |
     +------------+---------------+-----------+
     | 128 - 225  |     0 - 97    |     7     |
     +------------+---------------+-----------+
     | 226 - 255  |   128 - 157   |     8     |
     +------------+---------------+-----------+
        

Symbol probabilities are read one by one, in order. The probability is obtained from Value decoded using the formula P = Value - 1. This means the value 0 becomes the negative probability -1. This is a special probability that means "less than 1". Its effect on the distribution table is described below. For the purpose of calculating total allocated probability points, it counts as 1.

シンボル確率は、順番に1つずつ読み取られます。確率は、式P =値-1を使用してデコードされた値から取得されます。これは、値0が負の確率-1になることを意味します。これは、「1未満」を意味する特別な確率です。分布表への影響は次のとおりです。割り当てられた確率ポイントの合計を計算するために、1としてカウントされます。

When a symbol has a probability of zero, it is followed by a 2-bit repeat flag. This repeat flag tells how many probabilities of zeroes follow the current one. It provides a number ranging from 0 to 3. If it is a 3, another 2-bit repeat flag follows, and so on.

シンボルの確率がゼロの場合、2ビットの繰り返しフラグが続きます。この繰り返しフラグは、現在の確率に続くゼロの確率の数を示します。 0〜3の範囲の数を提供します。3の場合は、さらに2ビットの繰り返しフラグが続きます。

When the last symbol reaches a cumulated total of (1 << Accuracy_Log), decoding is complete. If the last symbol makes the cumulated total go above (1 << Accuracy_Log), distribution is considered corrupted.

最後のシンボルが(1 << Accuracy_Log)の累計に達すると、デコードが完了します。最後のシンボルによって累積合計が(1 << Accuracy_Log)を超える場合、分布は破損していると見なされます。

Finally, the decoder can tell how many bytes were used in this process and how many symbols are present. The bitstream consumes a round number of bytes. Any remaining bit within the last byte is simply unused.

最後に、デコーダはこのプロセスで使用されたバイト数と存在するシンボルの数を知ることができます。ビットストリームは、丸いバイト数を消費します。最後のバイト内の残りのビットは単に使用されません。

The distribution of normalized probabilities is enough to create a unique decoding table. The table has a size of (1 << Accuracy_Log). Each cell describes the symbol decoded and instructions to get the next state.

正規化された確率の分布は、一意のデコードテーブルを作成するのに十分です。テーブルのサイズは(1 << Accuracy_Log)です。各セルは、デコードされたシンボルと次の状態を取得するための命令を記述しています。

Symbols are scanned in their natural order for "less than 1" probabilities as described above. Symbols with this probability are being attributed a single cell, starting from the end of the table and retreating. These symbols define a full state reset, reading Accuracy_Log bits.

シンボルは、上記の「1未満」の確率について自然な順序でスキャンされます。この確率のシンボルは、テーブルの最後から始まり、後退する単一のセルに割り当てられます。これらのシンボルは、完全な状態のリセットを定義し、Accuracy_Logビットを読み取ります。

All remaining symbols are allocated in their natural order. Starting from symbol 0 and table position 0, each symbol gets allocated as many cells as its probability. Cell allocation is spread, not linear; each successor position follows this rule:

残りのすべてのシンボルは自然な順序で割り当てられます。シンボル0とテーブル位置0から始まり、各シンボルにはその確率と同じ数のセルが割り当てられます。セルの割り当ては分散され、線形ではありません。各後続職位は次のルールに従います。

     position += (tableSize >> 1) + (tableSize >> 3) + 3;
     position &= tableSize - 1;
        

A position is skipped if it is already occupied by a "less than 1" probability symbol. Position does not reset between symbols; it simply iterates through each position in the table, switching to the next symbol when enough states have been allocated to the current one.

ポジションが「1未満」の確率シンボルによってすでに占有されている場合、そのポジションはスキップされます。シンボル間の位置はリセットされません。テーブルの各位置を繰り返し処理し、現在の状態に十分な状態が割り当てられると、次の記号に切り替えます。

The result is a list of state values. Each state will decode the current symbol.

結果は状態値のリストです。各状態は現在のシンボルをデコードします。

To get the Number_of_Bits and Baseline required for the next state, it is first necessary to sort all states in their natural order. The lower states will need 1 more bit than higher ones. The process is repeated for each symbol.

次の状態に必要なNumber_of_BitsとBaselineを取得するには、最初にすべての状態を自然な順序でソートする必要があります。低い状態には、高い状態よりも1ビット多く必要です。このプロセスは、シンボルごとに繰り返されます。

For example, presuming a symbol has a probability of 5, it receives five state values. States are sorted in natural order. The next power of 2 is 8. The space of probabilities is divided into 8 equal parts. Presuming the Accuracy_Log is 7, this defines 128 states, and each share (divided by 8) is 16 in size. In order to reach 8, 8 - 5 = 3 lowest states will count "double", doubling the number of shares (32 in width), requiring 1 more bit in the process.

たとえば、シンボルの確率が5であるとすると、5つの状態値を受け取ります。状態は自然な順序でソートされます。 2の次のべき乗は8です。確率の空間は8つの等しい部分に分割されます。 Accuracy_Logが7であると想定すると、128の状態が定義され、各共有(8で除算)のサイズは16になります。 8、8-5 = 3の最低状態に到達するためには、「ダブル」を数え、共有数(幅32)を2倍にし、プロセスでさらに1ビットを必要とします。

Baseline is assigned starting from the higher states using fewer bits, and proceeding naturally, then resuming at the first state, each taking its allocated width from Baseline.

ベースラインは、より少ないビットを使用してより高い状態から始まり、自然に進み、最初の状態から再開し、それぞれがベースラインから割り当てられた幅を使用して割り当てられます。

     +----------------+-------+-------+--------+------+-------+
     |   state order  |   0   |   1   |   2    |  3   |  4    |
     +----------------+-------+-------+--------+------+-------+
     |     width      |   32  |   32  |   32   |  16  |  16   |
     +----------------+-------+-------+--------+------+-------+
     | Number_of_Bits |   5   |   5   |   5    |  4   |  4    |
     +----------------+-------+-------+--------+------+-------+
     |  range number  |   2   |   4   |   6    |  0   |  1    |
     +----------------+-------+-------+--------+------+-------+
     |    Baseline    |   32  |   64  |   96   |  0   |  16   |
     +----------------+-------+-------+--------+------+-------+
     |     range      | 32-63 | 64-95 | 96-127 | 0-15 | 16-31 |
     +----------------+-------+-------+--------+------+-------+
        

The next state is determined from the current state by reading the required Number_of_Bits and adding the specified Baseline.

次の状態は、必要なNumber_of_Bitsを読み取り、指定されたベースラインを追加することにより、現在の状態から決定されます。

See Appendix A for the results of this process that are applied to the default distributions.

デフォルトの分布に適用されるこのプロセスの結果については、付録Aを参照してください。

4.2. Huffman Coding
4.2. ハフマンコーディング

Zstandard Huffman-coded streams are read backwards, similar to the FSE bitstreams. Therefore, to find the start of the bitstream, it is necessary to know the offset of the last byte of the Huffman-coded stream.

Zstandard Huffmanでコード化されたストリームは、FSEビットストリームと同様に、逆方向に読み取られます。したがって、ビットストリームの開始を見つけるには、ハフマン符号化ストリームの最後のバイトのオフセットを知る必要があります。

After writing the last bit containing information, the compressor writes a single 1 bit and then fills the byte with 0-7 0 bits of padding. The last byte of the compressed bitstream cannot be 0 for that reason.

情報を含む最後のビットを書き込んだ後、コンプレッサーは単一の1ビットを書き込んでから、そのバイトを0〜7 0ビットのパディングで埋めます。そのため、圧縮ビットストリームの最後のバイトを0にすることはできません。

When decompressing, the last byte containing the padding is the first byte to read. The decompressor needs to skip 0-7 initial 0 bits and the first 1 bit that occurs. Afterwards, the useful part of the bitstream begins.

解凍するとき、パディングを含む最後のバイトは、読み取る最初のバイトです。デコンプレッサは、0〜7の初期0ビットと最初に発生する1ビットをスキップする必要があります。その後、ビットストリームの有用な部分が始まります。

The bitstream contains Huffman-coded symbols in little-endian order, with the codes defined by the method below.

ビットストリームには、リトルエンディアン順でハフマン符号化されたシンボルが含まれ、コードは以下の方法で定義されます。

4.2.1. Huffman Tree Description
4.2.1. ハフマンツリーの説明

Prefix coding represents symbols from an a priori known alphabet by bit sequences (codewords), one codeword for each symbol, in a manner such that different symbols may be represented by bit sequences of different lengths, but a parser can always parse an encoded string unambiguously symbol by symbol.

プレフィックスコーディングは、アプリオリに既知のアルファベットからのシンボルをビットシーケンス(コードワード)でシンボルごとに1つのコードワードで表します。異なるシンボルは異なる長さのビットシーケンスで表すことができますが、パーサーは常にエンコードされた文字列を明確に解析できます。シンボルごとに。

Given an alphabet with known symbol frequencies, the Huffman algorithm allows the construction of an optimal prefix code using the fewest bits of any possible prefix codes for that alphabet.

既知のシンボル頻度を持つアルファベットが与えられた場合、ハフマンアルゴリズムにより、そのアルファベットの可能なプレフィックスコードの最小ビットを使用して最適なプレフィックスコードを構築できます。

The prefix code must not exceed a maximum code length. More bits improve accuracy but yield a larger header size and require more memory or more complex decoding operations. This specification limits the maximum code length to 11 bits.

プレフィックスコードは最大コード長を超えてはなりません。ビット数を増やすと精度が向上しますが、ヘッダーサイズが大きくなり、より多くのメモリまたはより複雑なデコード操作が必要になります。この仕様では、最大コード長が11ビットに制限されています。

All literal values from zero (included) to the last present one (excluded) are represented by Weight with values from 0 to Max_Number_of_Bits. Transformation from Weight to Number_of_Bits follows this pseudocode:

ゼロ(含まれている)から最後に存在する(除外された)までのすべてのリテラル値は、0からMax_Number_of_Bitsまでの値を持つ重みで表されます。 WeightからNumber_of_Bitsへの変換は、次の擬似コードに従います。

     if Weight == 0
       Number_of_Bits = 0
     else
       Number_of_Bits = Max_Number_of_Bits + 1 - Weight
        

The last symbol's Weight is deduced from previously decoded ones, by completing to the nearest power of 2. This power of 2 gives Max_Number_of_Bits the depth of the current tree.

最後のシンボルのウェイトは、最も近い2の累乗まで完了することにより、以前にデコードされたものから推定されます。この2の累乗は、Max_Number_of_Bitsに現在のツリーの深さを与えます。

For example, presume the following Huffman tree must be described:

たとえば、次のハフマンツリーについて説明する必要があるとします。

     +---------------+----------------+
     | Literal Value | Number_of_Bits |
     +---------------+----------------+
     |       0       |        1       |
     +---------------+----------------+
     |       1       |        2       |
     +---------------+----------------+
     |       2       |        3       |
     +---------------+----------------+
     |       3       |        0       |
     +---------------+----------------+
     |       4       |        4       |
     +---------------+----------------+
     |       5       |        4       |
     +---------------+----------------+
        

The tree depth is 4, since its longest element uses 4 bits. (The longest elements are those with the smallest frequencies.) Value 5 will not be listed as it can be determined from the values for 0-4, nor will values above 5 as they are all 0. Values from 0 to 4 will be listed using Weight instead of Number_of_Bits. The pseudocode to determine Weight is:

最長の要素は4ビットを使用するため、ツリーの深さは4です。 (最も長い要素は最小の頻度を持つものです。)値5は0〜4の値から決定できるため、リストされません。また、5を超える値はすべて0であるため、リストされません。0〜4の値がリストされます。 Number_of_Bitsの代わりにWeightを使用します。重みを決定するための疑似コードは次のとおりです。

     if Number_of_Bits == 0
       Weight = 0
     else
       Weight = Max_Number_of_Bits + 1 - Number_of_Bits
        

It gives the following series of weights:

次の一連の重みが与えられます。

     +---------------+--------+
     | Literal Value | Weight |
     +---------------+--------+
     |       0       |   4    |
     +---------------+--------+
     |       1       |   3    |
     +---------------+--------+
     |       2       |   2    |
     +---------------+--------+
     |       3       |   0    |
     +---------------+--------+
     |       4       |   1    |
     +---------------+--------+
        

The decoder will do the inverse operation: having collected weights of literals from 0 to 4, it knows the last literal, 5, is present with a non-zero Weight. The Weight of 5 can be determined by advancing to the next power of 2. The sum of 2^(Weight-1) (excluding 0's) is 15. The nearest power of 2 is 16. Therefore, Max_Number_of_Bits = 4 and Weight[5] = 16 - 15 = 1.

デコーダーは逆の操作を行います。0から4までのリテラルの重みを収集すると、最後のリテラル5がゼロ以外の重みで存在することがわかります。 5の重みは、2の次の累乗に進むことによって決定できます。2^(Weight-1)(0を除く)の合計は15です。したがって、2の最も近い累乗は16です。したがって、Max_Number_of_Bits = 4およびWeight [5 ] = 16-15 = 1。

4.2.1.1. Huffman Tree Header
4.2.1.1. ハフマンツリーヘッダー

This is a single byte value (0-255), which describes how the series of weights is encoded.

これは、1バイトの値(0〜255)であり、一連の重みがどのようにエンコードされるかを示します。

headerByte < 128: The series of weights is compressed using FSE (see below). The length of the FSE-compressed series is equal to headerByte (0-127).

headerByte <128:FSEを使用して一連の重みが圧縮されます(以下を参照)。 FSEで圧縮されたシリーズの長さは、headerByte(0-127)と同じです。

headerByte >= 128: This is a direct representation, where each Weight is written directly as a 4-bit field (0-15). They are encoded forward, 2 weights to a byte with the first weight taking the top 4 bits and the second taking the bottom 4; for example, the following operations could be used to read the weights:

headerByte> = 128:これは直接表現であり、各ウェイトは4ビットフィールド(0〜15)として直接書き込まれます。それらは順方向にエンコードされ、2つの重みがバイトになり、最初の重みが上位4ビットを取り、2番目の重みが下位4ビットをとります。たとえば、次の操作を使用して重みを読み取ることができます。

     Weight[0] = (Byte[0] >> 4)
     Weight[1] = (Byte[0] & 0xf),
     etc.
        

The full representation occupies ceiling(Number_of_Symbols/2) bytes, meaning it uses only full bytes even if Number_of_Symbols is odd. Number_of_Symbols = headerByte - 127. Note that maximum Number_of_Symbols is 255 - 127 = 128. If any literal has a value over 128, raw header mode is not possible, and it is necessary to use FSE compression.

完全な表現は、ceiling(Number_of_Symbols / 2)バイトを占有します。つまり、Number_of_Symbolsが奇数であっても、完全なバイトのみを使用します。 Number_of_Symbols = headerByte-127。最大Number_of_Symbolsは255-127 = 128であることに注意してください。いずれかのリテラルの値が128を超える場合、生のヘッダーモードは不可能であり、FSE圧縮を使用する必要があります。

4.2.1.2. FSE Compression of Huffman Weights
4.2.1.2. ハフマン重みのFSE圧縮

In this case, the series of Huffman weights is compressed using FSE compression. It is a single bitstream with two interleaved states, sharing a single distribution table.

この場合、一連のハフマン重みはFSE圧縮を使用して圧縮されます。これは、2つのインターリーブされた状態を持つ単一のビットストリームであり、単一の分散テーブルを共有します。

To decode an FSE bitstream, it is necessary to know its compressed size. Compressed size is provided by headerByte. It's also necessary to know its maximum possible decompressed size, which is 255, since literal values span from 0 to 255, and the last symbol's Weight is not represented.

FSEビットストリームをデコードするには、その圧縮サイズを知る必要があります。圧縮サイズはheaderByteによって提供されます。リテラル値の範囲は0〜255であり、最後のシンボルの重みが表されないため、解凍可能な最大サイズ(255)を知ることも必要です。

An FSE bitstream starts by a header, describing probabilities distribution. It will create a decoding table. For a list of Huffman weights, the maximum accuracy log is 6 bits. For more details, see Section 4.1.1.

FSEビットストリームは、確率分布を記述するヘッダーで始まります。デコードテーブルを作成します。ハフマンの重みのリストの場合、最大精度ログは6ビットです。詳細については、セクション4.1.1を参照してください。

The Huffman header compression uses two states, which share the same FSE distribution table. The first state (State1) encodes the even-numbered index symbols, and the second (State2) encodes the odd-numbered index symbols. State1 is initialized first, and then State2, and they take turns decoding a single symbol and updating their state. For more details on these FSE operations, see Section 4.1.

ハフマンヘッダー圧縮は、同じFSE分布テーブルを共有する2つの状態を使用します。最初の状態(State1)は偶数番号のインデックスシンボルをエンコードし、2番目の状態(State2)は奇数番号のインデックスシンボルをエンコードします。 State1が最初に初期化され、次にState2が初期化され、順番に1つのシンボルをデコードして状態を更新します。これらのFSE操作の詳細については、セクション4.1を参照してください。

The number of symbols to be decoded is determined by tracking the bitStream overflow condition: If updating state after decoding a symbol would require more bits than remain in the stream, it is assumed that extra bits are zero. Then, symbols for each of the final states are decoded and the process is complete.

デコードされるシンボルの数は、bitStreamのオーバーフロー条件を追跡することで決定されます。次に、各最終状態のシンボルがデコードされ、プロセスが完了します。

4.2.1.3. Conversion from Weights to Huffman Prefix Codes
4.2.1.3. 重みからハフマン接頭辞コードへの変換

All present symbols will now have a Weight value. It is possible to transform weights into Number_of_Bits, using this formula:

現在のすべてのシンボルには、ウェイト値があります。次の式を使用して、重みをNumber_of_Bitsに変換することができます。

if Weight > 0 Number_of_Bits = Max_Number_of_Bits + 1 - Weight else Number_of_Bits = 0

ウェイト> 0の場合Number_of_Bits = Max_Number_of_Bits + 1-ウェイトそれ以外の場合Number_of_Bits = 0

Symbols are sorted by Weight. Within the same Weight, symbols keep natural sequential order. Symbols with a Weight of zero are removed. Then, starting from the lowest Weight, prefix codes are distributed in sequential order.

記号は重量で並べ替えられています。同じウェイト内では、シンボルは自然な順序で並べられます。ウェイトがゼロのシンボルは削除されます。次に、最も低いウェイトから始めて、プレフィックスコードが順番に配布されます。

For example, assume the following list of weights has been decoded:

たとえば、次の重みのリストがデコードされているとします。

     +---------+--------+
     | Literal | Weight |
     +---------+--------+
     |    0    |   4    |
     +---------+--------+
     |    1    |   3    |
     +---------+--------+
     |    2    |   2    |
     +---------+--------+
     |    3    |   0    |
     +---------+--------+
     |    4    |   1    |
     +---------+--------+
     |    5    |   1    |
     +---------+--------+
        

Sorting by weight and then the natural sequential order yields the following distribution:

重みでソートしてから自然な順序で並べると、次の分布になります。

     +---------+--------+----------------+--------------+
     | Literal | Weight | Number_Of_Bits | Prefix Codes |
     +---------+--------+----------------|--------------+
     |    3    |   0    |        0       |      N/A     |
     +---------+--------+----------------|--------------+
     |    4    |   1    |        4       |     0000     |
     +---------+--------+----------------|--------------+
     |    5    |   1    |        4       |     0001     |
     +---------+--------+----------------|--------------+
     |    2    |   2    |        3       |      001     |
     +---------+--------+----------------|--------------+
     |    1    |   3    |        2       |       01     |
     +---------+--------+----------------|--------------+
     |    0    |   4    |        1       |        1     |
     +---------+--------+----------------|--------------+
        
4.2.2. Huffman-Coded Streams
4.2.2. ハフマン符号化ストリーム

Given a Huffman decoding table, it is possible to decode a Huffman-coded stream.

ハフマン復号化テーブルが与えられると、ハフマン符号化ストリームを復号化することが可能です。

Each bitstream must be read backward, which starts from the end and goes up to the beginning. Therefore, it is necessary to know the size of each bitstream.

各ビットストリームは逆方向に読み取る必要があります。これは最後から始まり、最初まで続きます。したがって、各ビットストリームのサイズを知る必要があります。

It is also necessary to know exactly which bit is the last. This is detected by a final bit flag: the highest bit of the last byte is a final-bit-flag. Consequently, a last byte of 0 is not possible. And the final-bit-flag itself is not part of the useful bitstream. Hence, the last byte contains between 0 and 7 useful bits.

どのビットが最後かを正確に知ることも必要です。これは、最終ビットフラグによって検出されます。最後のバイトの最上位ビットは、最終ビットフラグです。したがって、最後のバイトの0は不可能です。そして、最終ビットフラグ自体は、有用なビットストリームの一部ではありません。したがって、最後のバイトには0〜7ビットの有効ビットが含まれています。

Starting from the end, it is possible to read the bitstream in a little-endian fashion, keeping track of already used bits. Since the bitstream is encoded in reverse order, starting from the end, read symbols in forward order.

最後から、リトルエンディアン方式でビットストリームを読み取り、すでに使用されているビットを追跡することができます。ビットストリームは最後から逆の順序でエンコードされるため、シンボルを順方向に読み取ります。

For example, if the literal sequence "0145" was encoded using the above prefix code, it would be encoded (in reverse order) as:

たとえば、リテラルシーケンス "0145"が上記のプレフィックスコードを使用してエンコードされた場合、次のようにエンコードされます(逆順)。

     +---------+----------+
     | Symbol  | Encoding |
     +---------+----------+
     |    5    |   0000   |
     +---------+----------+
     |    4    |   0001   |
     +---------+----------+
     |    1    |    01    |
     +---------+----------+
     |    0    |    1     |
     +---------+----------+
     | Padding |   00001  |
     +---------+----------+
        

This results in the following 2-byte bitstream:

これにより、次の2バイトのビットストリームが生成されます。

00010000 00001101

00010000 00001101

Here is an alternative representation with the symbol codes separated by underscores:

次に、アンダースコアで区切られたシンボルコードを使用した代替表現を示します。

0001_0000 00001_1_01

0001_0000 00001_1_01

Reading the highest Max_Number_of_Bits bits, it's possible to compare the extracted value to the decoding table, determining the symbol to decode and number of bits to discard.

最上位のMax_Number_of_Bitsビットを読み取ると、抽出した値をデコードテーブルと比較して、デコードするシンボルと破棄するビット数を決定できます。

The process continues reading up to the required number of symbols per stream. If a bitstream is not entirely and exactly consumed, hence reaching exactly its beginning position with all bits consumed, the decoding process is considered faulty.

プロセスは、ストリームごとに必要な数のシンボルまで読み取りを続行します。ビットストリームが完全かつ正確に消費されず、したがってすべてのビットが消費されて正確に開始位置に到達する場合、復号化プロセスは不良と見なされます。

5. Dictionary Format
5. 辞書フォーマット

Zstandard is compatible with "raw content" dictionaries, free of any format restriction, except that they must be at least 8 bytes. These dictionaries function as if they were just the content part of a formatted dictionary.

Zstandardは、8バイト以上でなければならないことを除いて、フォーマット制限のない「未加工コンテンツ」辞書と互換性があります。これらの辞書は、フォーマットされた辞書のコンテンツ部分であるかのように機能します。

However, dictionaries created by "zstd --train" in the reference implementation follow a specific format, described here.

ただし、リファレンス実装で「zstd --train」によって作成された辞書は、ここで説明する特定の形式に従います。

Dictionaries are not included in the compressed content but rather are provided out of band. That is, the Dictionary_ID identifies which should be used, but this specification does not describe the mechanism by which the dictionary is obtained prior to use during compression or decompression.

辞書は圧縮されたコンテンツに含まれていませんが、帯域外で提供されます。つまり、Dictionary_IDはどちらを使用するかを識別しますが、この仕様では、圧縮または解凍時に使用する前に辞書を取得するメカニズムについては説明していません。

A dictionary has a size, defined either by a buffer limit or a file size. The general format is:

辞書には、バッファ制限またはファイルサイズのいずれかによって定義されるサイズがあります。一般的な形式は次のとおりです。

     +--------------+---------------+----------------+---------+
     | Magic_Number | Dictionary_ID | Entropy_Tables | Content |
     +--------------+---------------+----------------+---------+
        

Magic_Number: 4 bytes ID, value 0xEC30A437, little-endian format.

Magic_Number:4バイトのID、値0xEC30A437、リトルエンディアン形式。

Dictionary_ID: 4 bytes, stored in little-endian format. Dictionary_ID can be any value, except 0 (which means no Dictionary_ID). It is used by decoders to check if they use the correct dictionary. If the frame is going to be distributed in a private environment, any Dictionary_ID can be used. However, for public distribution of compressed frames, the following ranges are reserved and shall not be used:

Dictionary_ID:4バイト、リトルエンディアン形式で保存されます。 Dictionary_IDには、0(Dictionary_IDがないことを意味する)以外の任意の値を指定できます。デコーダーが正しい辞書を使用しているかどうかを確認するために使用されます。フレームがプライベート環境で配布される場合は、任意のDictionary_IDを使用できます。ただし、圧縮フレームの公開配信では、次の範囲が予約されており、使用されません。

         low range: <= 32767
         high range: >= (2^31)
        

Entropy_Tables: Follow the same format as the tables in compressed blocks. See the relevant FSE and Huffman sections for how to decode these tables. They are stored in the following order: Huffman table for literals, FSE table for offsets, FSE table for match lengths, and FSE table for literals lengths. These tables populate the Repeat Stats literals mode and Repeat distribution mode for sequence decoding. It is finally followed by 3 offset values, populating repeat offsets (instead of using {1,4,8}), stored in order, 4-bytes little-endian each, for a total of 12 bytes. Each repeat offset must have a value less than the dictionary size.

Entropy_Tables:圧縮ブロックのテーブルと同じ形式に従います。これらのテーブルのデコード方法については、関連するFSEおよびハフマンのセクションを参照してください。それらは次の順序で保管されます。リテラルのハフマンテーブル、オフセットのFSEテーブル、一致長のFSEテーブル、リテラル長のFSEテーブル。これらのテーブルは、シーケンスのデコードのためにリピート統計リテラルモードとリピート配布モードを設定します。最後に3つのオフセット値が続き、リピートオフセット({1,4,8}を使用する代わりに)が入力され、それぞれ4バイトのリトルエンディアンで順番に格納され、合計12バイトになります。各繰り返しオフセットには、ディクショナリサイズよりも小さい値を指定する必要があります。

Content: The rest of the dictionary is its content. The content acts as a "past" in front of data to be compressed or decompressed, so it can be referenced in sequence commands. As long as the amount of data decoded from this frame is less than or equal to Window_Size, sequence commands may specify offsets longer than the total length of decoded output so far to reference back to the dictionary, even parts of the dictionary with offsets larger than Window_Size. After the total output has surpassed Window_Size, however, this is no longer allowed, and the dictionary is no longer accessible.

コンテンツ:辞書の残りの部分はそのコンテンツです。コンテンツは、圧縮または解凍されるデータの前の「過去」として機能するため、シーケンスコマンドで参照できます。このフレームからデコードされたデータの量がWin​​dow_Size以下である限り、シーケンスコマンドは、これまでにデコードされた出力の合計長よりも長いオフセットを指定して、ディクショナリに戻って参照することができます。 Window_Size。ただし、合計出力がWindow_Sizeを超えると、これは許可されなくなり、ディクショナリにアクセスできなくなります。

6. IANA Considerations
6. IANAに関する考慮事項

IANA has made two registrations, as described below.

IANAは、以下に説明するように2つの登録を行いました。

6.1. The 'application/zstd' Media Type
6.1. 「application / zstd」メディアタイプ

The 'application/zstd' media type identifies a block of data that is compressed using zstd compression. The data is a stream of bytes as described in this document. IANA has added the following to the "Media Types" registry:

「application / zstd」メディアタイプは、zstd圧縮を使用して圧縮されたデータのブロックを識別します。このドキュメントで説明されているように、データはバイトのストリームです。 IANAは、「メディアタイプ」レジストリに以下を追加しました。

Type name: application

タイプ名:アプリケーション

Subtype name: zstd

サブタイプ名:zstd

Required parameters: N/A

必須パラメーター:なし

Optional parameters: N/A

オプションのパラメーター:N / A

Encoding considerations: binary

エンコーディングに関する考慮事項:バイナリ

Security considerations: See Section 7 of RFC 8478

セキュリティに関する考慮事項:RFC 8478のセクション7をご覧ください

Interoperability considerations: N/A

相互運用性に関する考慮事項:N / A

Published specification: RFC 8478

公開された仕様:RFC 8478

Applications that use this media type: anywhere data size is an issue

このメディアタイプを使用するアプリケーション:データサイズが問題になる場所

Additional information:

追加情報:

Magic number(s): 4 bytes, little-endian format. Value: 0xFD2FB528

マジックナンバー:4バイト、リトルエンディアン形式。値:0xFD2FB528

File extension(s): zst

ファイル拡張子:zst

      Macintosh file type code(s):  N/A
        

For further information: See [ZSTD]

詳細については、[ZSTD]を参照してください。

Intended usage: common

使用目的:一般

Restrictions on usage: N/A

使用上の制限:N / A

Author: Murray S. Kucherawy

著者:マレー・S・クチェラウィ

Change Controller: IETF Provisional registration: no

変更管理者:IETF仮登録:いいえ

6.2. Content Encoding
6.2. コンテンツのエンコーディング

IANA has added the following entry to the "HTTP Content Coding Registry" within the "Hypertext Transfer Protocol (HTTP) Parameters" registry:

IANAは、「ハイパーテキスト転送プロトコル(HTTP)パラメータ」レジストリ内の「HTTPコンテンツコーディングレジストリ」に次のエントリを追加しました。

Name: zstd

名前:zstd

Description: A stream of bytes compressed using the Zstandard protocol

説明:Zstandardプロトコルを使用して圧縮されたバイトのストリーム

Pointer to specification text: RFC 8478

仕様テキストへのポインター:RFC 8478

6.3. Dictionaries
6.3. 辞書

Work in progress includes development of dictionaries that will optimize compression and decompression of particular types of data. Specification of such dictionaries for public use will necessitate registration of a code point from the reserved range described in Section 3.1.1.1.3 and its association with a specific dictionary.

進行中の作業には、特定のタイプのデータの圧縮と解凍を最適化する辞書の開発が含まれます。このような辞書を公的に使用するように指定するには、セクション3.1.1.1.3で説明されている予約範囲からのコードポイントの登録と、特定の辞書との関連付けが必要になります。

However, there are at present no such dictionaries published for public use, so this document makes no immediate request of IANA to create such a registry.

ただし、現時点ではそのような辞書は公開されていないため、このドキュメントでは、IANAにそのようなレジストリを作成するようにすぐに要求することはありません。

7. Security Considerations
7. セキュリティに関する考慮事項

Any data compression method involves the reduction of redundancy in the data. Zstandard is no exception, and the usual precautions apply.

どのデータ圧縮方法でも、データの冗長性が低下します。 Zstandardも例外ではなく、通常の予防措置が適用されます。

One should never compress a message whose content must remain secret with a message generated by a third party. Such a compression can be used to guess the content of the secret message through analysis of entropy reduction. This was demonstrated in the Compression Ratio Info-leak Made Easy (CRIME) attack [CRIME], for example.

第三者が生成したメッセージで内容を秘密にしておく必要があるメッセージを圧縮してはなりません。このような圧縮は、エントロピー削減の分析を通じて秘密のメッセージの内容を推測するために使用できます。これは、たとえば、圧縮率情報漏えい容易化(CRIME)攻撃[CRIME]で実証されました。

A decoder has to demonstrate capabilities to detect and prevent any kind of data tampering in the compressed frame from triggering system faults, such as reading or writing beyond allowed memory ranges. This can be guaranteed by either the implementation language or careful bound checkings. Of particular note is the encoding of Number_of_Sequences values that cause the decoder to read into the block header (and beyond), as well as the indication of a Frame_Content_Size that is smaller than the actual decompressed data, in an attempt to trigger a buffer overflow. It is highly recommended to fuzz-test (i.e., provide invalid, unexpected, or random input and verify safe operation of) decoder implementations to test and harden their capability to detect bad frames and deal with them without any adverse system side effect.

デコーダーは、圧縮されたフレーム内のあらゆる種類のデータ改ざんが、許可されたメモリ範囲を超えた読み取りや書き込みなどのシステム障害をトリガーすることを検出および防止する機能を実証する必要があります。これは、実装言語または慎重な境界チェックのいずれかによって保証できます。特に注目すべきは、バッファーオーバーフローをトリガーしようとして、デコーダーにブロックヘッダー(およびそれ以降)を読み込ませるNumber_of_Sequences値のエンコードと、実際の圧縮解除されたデータよりも小さいFrame_Content_Sizeの表示です。ファズテスト(つまり、無効な、予期しない、またはランダムな入力を提供し、安全な動作を確認する)デコーダー実装をテストして、不良フレームを検出する機能をテストおよび強化し、システムに悪影響を与えずに対処することを強くお勧めします。

An attacker may provide correctly formed compressed frames with unreasonable memory requirements. A decoder must always control memory requirements and enforce some (system-specific) limits in order to protect memory usage from such scenarios.

攻撃者は、適切に形成された圧縮フレームに不当なメモリ要件を提供する可能性があります。このようなシナリオからメモリ使用量を保護するために、デコーダは常にメモリ要件を制御し、いくつかの(システム固有の)制限を適用する必要があります。

Compression can be optimized by training a dictionary on a variety of related content payloads. This dictionary must then be available at the decoder for decompression of the payload to be possible. While this document does not specify how to acquire a dictionary for a given compressed payload, it is worth noting that third-party dictionaries may interact unexpectedly with a decoder, leading to possible memory or other resource exhaustion attacks. We expect such topics to be discussed in further detail in the Security Considerations section of a forthcoming RFC for dictionary acquisition and transmission, but highlight this issue now out of an abundance of caution.

圧縮は、関連するさまざまなコンテンツペイロードで辞書をトレーニングすることで最適化できます。ペイロードを解凍するには、このディクショナリをデコーダで使用できる必要があります。このドキュメントでは、特定の圧縮されたペイロードのディクショナリを取得する方法を指定していませんが、サードパーティのディクショナリがデコーダーと予期せず相互作用し、メモリやその他のリソース枯渇攻撃を引き起こす可能性があることに注意してください。このようなトピックについては、今後の辞書の取得と送信に関するRFCの「セキュリティに関する考慮事項」セクションでさらに詳しく説明することが期待されますが、この問題は十分な注意を払って強調しています。

As discussed in Section 3.1.2, it is possible to store arbitrary user metadata in skippable frames. While such frames are ignored during decompression of the data, they can be used as a watermark to track the path of the compressed payload.

セクション3.1.2で説明したように、スキップ可能なフレームに任意のユーザーメタデータを格納することが可能です。このようなフレームはデータの解凍中は無視されますが、圧縮ペイロードのパスを追跡するための透かしとして使用できます。

8. Implementation Status
8. 実施状況

Source code for a C language implementation of a Zstandard-compliant library is available at [ZSTD-GITHUB]. This implementation is considered to be the reference implementation and is production ready; it implements the full range of the specification. It is routinely tested against security hazards and widely deployed within Facebook infrastructure.

Zstandard準拠ライブラリのC言語実装のソースコードは、[ZSTD-GITHUB]で入手できます。この実装はリファレンス実装と見なされ、本番環境で使用できます。仕様の全範囲を実装しています。セキュリティの危険性に対して定期的にテストされ、Facebookインフラストラクチャ内で広く展開されています。

The reference version is optimized for speed and is highly portable. It has been proven to run safely on multiple architectures (e.g., x86, x64, ARM, MIPS, PowerPC, IA64) featuring 32- or 64-bit addressing schemes, a little- or big-endian storage scheme, a number of different operating systems (e.g., UNIX (including Linux, BSD, OS-X, and Solaris) and Windows), and a number of compilers (e.g., gcc, clang, visual, and icc).

参照バージョンは速度が最適化されており、移植性に優れています。 32ビットまたは64ビットのアドレッシングスキーム、リトルエンディアンまたはビッグエンディアンのストレージスキーム、多数の異なるオペレーティングシステムを備えた複数のアーキテクチャ(x86、x64、ARM、MIPS、PowerPC、IA64など)で安全に実行できることが実証されていますシステム(たとえば、UNIX(Linux、BSD、OS-X、およびSolarisを含む)およびWindows)、およびいくつかのコンパイラ(たとえば、gcc、clang、visual、icc)。

9. References
9. 参考文献
9.1. Normative References
9.1. 引用文献

[ZSTD] "Zstandard", <http://www.zstd.net>.

[ZSTD]「Zstandard」、<http://www.zstd.net>。

9.2. Informative References
9.2. 参考引用

[ANS] Duda, J., "Asymmetric numeral systems: entropy coding combining speed of Huffman coding with compression rate of arithmetic coding", January 2014, <https://arxiv.org/pdf/1311.2540>.

[ANS] Duda、J。、「非対称数値システム:ハフマンコーディングの速度と算術コーディングの圧縮率を組み合わせたエントロピーコーディング」、2014年1月、<https://arxiv.org/pdf/1311.2540>。

[CRIME] "CRIME", June 2018, <https://en.wikipedia.org/w/ index.php?title=CRIME&oldid=844538656>.

[CRIME]「CRIME」、2018年6月、<https://en.wikipedia.org/w/ index.php?title = CRIME&oldid = 844538656>。

[FSE] "FiniteStateEntropy", commit 6efa78a, June 2018, <https://github.com/Cyan4973/FiniteStateEntropy/>.

[FSE]「FiniteStateEntropy」、コミット6efa78a、2018年6月、<https://github.com/Cyan4973/FiniteStateEntropy/>。

[LZ4] "LZ4 Frame Format Description", commit d03224b, January 2018, <https://github.com/lz4/lz4/blob/master/doc/ lz4_Frame_format.md>.

[LZ4]「LZ4フレーム形式の説明」、コミットd03224b、2018年1月、<https://github.com/lz4/lz4/blob/master/doc/ lz4_Frame_format.md>。

[RFC1952] Deutsch, P., "GZIP file format specification version 4.3", RFC 1952, DOI 10.17487/RFC1952, May 1996, <https://www.rfc-editor.org/info/rfc1952>.

[RFC1952] Deutsch、P。、「GZIPファイル形式仕様バージョン4.3」、RFC 1952、DOI 10.17487 / RFC1952、1996年5月、<https://www.rfc-editor.org/info/rfc1952>。

[XXHASH] "XXHASH Algorithm", <http://www.xxhash.org>.

[XXHASH] "XXHASH Algorithm"、<http://www.xxhash.org>。

[ZSTD-GITHUB] "zstd", commit 8514bd8, August 2018, <https://github.com/facebook/zstd>.

[ZSTD-GITHUB]「zstd」、コミット8514bd8、2018年8月、<https://github.com/facebook/zstd>。

Appendix A. Decoding Tables for Predefined Codes
付録A.定義済みコードのデコードテーブル

This appendix contains FSE decoding tables for the predefined literal length, match length, and offset codes. The tables have been constructed using the algorithm as given above in Section 4.1.1. The tables here can be used as examples to crosscheck that an implementation has built its decoding tables correctly.

この付録には、事前定義されたリテラル長、一致長、およびオフセットコードのFSEデコードテーブルが含まれています。テーブルは、4.1.1節で前述したアルゴリズムを使用して作成されています。ここにある表は、実装がデコード表を正しく作成したことをクロスチェックするための例として使用できます。

A.1. Literal Length Code Table
A.1. リテラル長コード表
     +-------+--------+----------------+------+
     | State | Symbol | Number_Of_Bits | Base |
     +-------+--------+----------------+------+
     |    0  |    0   |        0       |   0  |
     +-------+--------+----------------+------+
     |    0  |    0   |        4       |   0  |
     +-------+--------+----------------+------+
     |    1  |    0   |        4       |  16  |
     +-------+--------+----------------+------+
     |    2  |    1   |        5       |  32  |
     +-------+--------+----------------+------+
     |    3  |    3   |        5       |   0  |
     +-------+--------+----------------+------+
     |    4  |    4   |        5       |   0  |
     +-------+--------+----------------+------+
     |    5  |    6   |        5       |   0  |
     +-------+--------+----------------+------+
     |    6  |    7   |        5       |   0  |
     +-------+--------+----------------+------+
     |    7  |    9   |        5       |   0  |
     +-------+--------+----------------+------+
     |    8  |   10   |        5       |   0  |
     +-------+--------+----------------+------+
     |    9  |   12   |        5       |   0  |
     +-------+--------+----------------+------+
     |   10  |   14   |        6       |   0  |
     +-------+--------+----------------+------+
     |   11  |   16   |        5       |   0  |
     +-------+--------+----------------+------+
     |   12  |   18   |        5       |   0  |
     +-------+--------+----------------+------+
     |   13  |   19   |        5       |   0  |
     +-------+--------+----------------+------+
     |   14  |   21   |        5       |   0  |
     +-------+--------+----------------+------+
     |   15  |   22   |        5       |   0  |
     +-------+--------+----------------+------+
     |   16  |   24   |        5       |   0  |
        
     +-------+--------+----------------+------+
     |   17  |   25   |        5       |  32  |
     +-------+--------+----------------+------+
     |   18  |   26   |        5       |   0  |
     +-------+--------+----------------+------+
     |   19  |   27   |        6       |   0  |
     +-------+--------+----------------+------+
     |   20  |   29   |        6       |   0  |
     +-------+--------+----------------+------+
     |   21  |   31   |        6       |   0  |
     +-------+--------+----------------+------+
     |   22  |    0   |        4       |  32  |
     +-------+--------+----------------+------+
     |   23  |    1   |        4       |   0  |
     +-------+--------+----------------+------+
     |   24  |    2   |        5       |   0  |
     +-------+--------+----------------+------+
     |   25  |    4   |        5       |  32  |
     +-------+--------+----------------+------+
     |   26  |    5   |        5       |   0  |
     +-------+--------+----------------+------+
     |   27  |    7   |        5       |  32  |
     +-------+--------+----------------+------+
     |   28  |    8   |        5       |   0  |
     +-------+--------+----------------+------+
     |   29  |   10   |        5       |  32  |
     +-------+--------+----------------+------+
     |   30  |   11   |        5       |   0  |
     +-------+--------+----------------+------+
     |   31  |   13   |        6       |   0  |
     +-------+--------+----------------+------+
     |   32  |   16   |        5       |  32  |
     +-------+--------+----------------+------+
     |   33  |   17   |        5       |   0  |
     +-------+--------+----------------+------+
     |   34  |   19   |        5       |  32  |
     +-------+--------+----------------+------+
     |   35  |   20   |        5       |   0  |
     +-------+--------+----------------+------+
     |   36  |   22   |        5       |  32  |
     +-------+--------+----------------+------+
     |   37  |   23   |        5       |   0  |
     +-------+--------+----------------+------+
     |   38  |   25   |        4       |   0  |
     +-------+--------+----------------+------+
     |   39  |   25   |        4       |  16  |
     +-------+--------+----------------+------+
     |   40  |   26   |        5       |  32  |
        
     +-------+--------+----------------+------+
     |   41  |   28   |        6       |   0  |
     +-------+--------+----------------+------+
     |   42  |   30   |        6       |   0  |
     +-------+--------+----------------+------+
     |   43  |    0   |        4       |  48  |
     +-------+--------+----------------+------+
     |   44  |    1   |        4       |  16  |
     +-------+--------+----------------+------+
     |   45  |    2   |        5       |  32  |
     +-------+--------+----------------+------+
     |   46  |    3   |        5       |  32  |
     +-------+--------+----------------+------+
     |   47  |    5   |        5       |  32  |
     +-------+--------+----------------+------+
     |   48  |    6   |        5       |  32  |
     +-------+--------+----------------+------+
     |   49  |    8   |        5       |  32  |
     +-------+--------+----------------+------+
     |   50  |    9   |        5       |  32  |
     +-------+--------+----------------+------+
     |   51  |   11   |        5       |  32  |
     +-------+--------+----------------+------+
     |   52  |   12   |        5       |  32  |
     +-------+--------+----------------+------+
     |   53  |   15   |        6       |   0  |
     +-------+--------+----------------+------+
     |   54  |   17   |        5       |  32  |
     +-------+--------+----------------+------+
     |   55  |   18   |        5       |  32  |
     +-------+--------+----------------+------+
     |   56  |   20   |        5       |  32  |
     +-------+--------+----------------+------+
     |   57  |   21   |        5       |  32  |
     +-------+--------+----------------+------+
     |   58  |   23   |        5       |  32  |
     +-------+--------+----------------+------+
     |   59  |   24   |        5       |  32  |
     +-------+--------+----------------+------+
     |   60  |   35   |        6       |   0  |
     +-------+--------+----------------+------+
     |   61  |   34   |        6       |   0  |
     +-------+--------+----------------+------+
     |   62  |   33   |        6       |   0  |
     +-------+--------+----------------+------+
     |   63  |   32   |        6       |   0  |
     +-------+--------+----------------+------+
        
A.2. Match Length Code Table
A.2. 一致長さコード表
     +-------+--------+----------------+------+
     | State | Symbol | Number_Of_Bits | Base |
     +-------+--------+----------------+------+
     |    0  |    0   |        0       |   0  |
     +-------+--------+----------------+------+
     |    0  |    0   |        6       |   0  |
     +-------+--------+----------------+------+
     |    1  |    1   |        4       |   0  |
     +-------+--------+----------------+------+
     |    2  |    2   |        5       |  32  |
     +-------+--------+----------------+------+
     |    3  |    3   |        5       |   0  |
     +-------+--------+----------------+------+
     |    4  |    5   |        5       |   0  |
     +-------+--------+----------------+------+
     |    5  |    6   |        5       |   0  |
     +-------+--------+----------------+------+
     |    6  |    8   |        5       |   0  |
     +-------+--------+----------------+------+
     |    7  |   10   |        6       |   0  |
     +-------+--------+----------------+------+
     |    8  |   13   |        6       |   0  |
     +-------+--------+----------------+------+
     |    9  |   16   |        6       |   0  |
     +-------+--------+----------------+------+
     |   10  |   19   |        6       |   0  |
     +-------+--------+----------------+------+
     |   11  |   22   |        6       |   0  |
     +-------+--------+----------------+------+
     |   12  |   25   |        6       |   0  |
     +-------+--------+----------------+------+
     |   13  |   28   |        6       |   0  |
     +-------+--------+----------------+------+
     |   14  |   31   |        6       |   0  |
     +-------+--------+----------------+------+
     |   15  |   33   |        6       |   0  |
     +-------+--------+----------------+------+
     |   16  |   35   |        6       |   0  |
     +-------+--------+----------------+------+
     |   17  |   37   |        6       |   0  |
     +-------+--------+----------------+------+
     |   18  |   39   |        6       |   0  |
     +-------+--------+----------------+------+
     |   19  |   41   |        6       |   0  |
     +-------+--------+----------------+------+
     |   20  |   43   |        6       |   0  |
        
     +-------+--------+----------------+------+
     |   21  |   45   |        6       |   0  |
     +-------+--------+----------------+------+
     |   22  |    1   |        4       |  16  |
     +-------+--------+----------------+------+
     |   23  |    2   |        4       |   0  |
     +-------+--------+----------------+------+
     |   24  |    3   |        5       |  32  |
     +-------+--------+----------------+------+
     |   25  |    4   |        5       |   0  |
     +-------+--------+----------------+------+
     |   26  |    6   |        5       |  32  |
     +-------+--------+----------------+------+
     |   27  |    7   |        5       |   0  |
     +-------+--------+----------------+------+
     |   28  |    9   |        6       |   0  |
     +-------+--------+----------------+------+
     |   29  |   12   |        6       |   0  |
     +-------+--------+----------------+------+
     |   30  |   15   |        6       |   0  |
     +-------+--------+----------------+------+
     |   31  |   18   |        6       |   0  |
     +-------+--------+----------------+------+
     |   32  |   21   |        6       |   0  |
     +-------+--------+----------------+------+
     |   33  |   24   |        6       |   0  |
     +-------+--------+----------------+------+
     |   34  |   27   |        6       |   0  |
     +-------+--------+----------------+------+
     |   35  |   30   |        6       |   0  |
     +-------+--------+----------------+------+
     |   36  |   32   |        6       |   0  |
     +-------+--------+----------------+------+
     |   37  |   34   |        6       |   0  |
     +-------+--------+----------------+------+
     |   38  |   36   |        6       |   0  |
     +-------+--------+----------------+------+
     |   39  |   38   |        6       |   0  |
     +-------+--------+----------------+------+
     |   40  |   40   |        6       |   0  |
     +-------+--------+----------------+------+
     |   41  |   42   |        6       |   0  |
     +-------+--------+----------------+------+
     |   42  |   44   |        6       |   0  |
     +-------+--------+----------------+------+
     |   43  |    1   |        4       |  32  |
     +-------+--------+----------------+------+
     |   44  |    1   |        4       |  48  |
        
     +-------+--------+----------------+------+
     |   45  |    2   |        4       |  16  |
     +-------+--------+----------------+------+
     |   46  |    4   |        5       |  32  |
     +-------+--------+----------------+------+
     |   47  |    5   |        5       |  32  |
     +-------+--------+----------------+------+
     |   48  |    7   |        5       |  32  |
     +-------+--------+----------------+------+
     |   49  |    8   |        5       |  32  |
     +-------+--------+----------------+------+
     |   50  |   11   |        6       |   0  |
     +-------+--------+----------------+------+
     |   51  |   14   |        6       |   0  |
     +-------+--------+----------------+------+
     |   52  |   17   |        6       |   0  |
     +-------+--------+----------------+------+
     |   53  |   20   |        6       |   0  |
     +-------+--------+----------------+------+
     |   54  |   23   |        6       |   0  |
     +-------+--------+----------------+------+
     |   55  |   26   |        6       |   0  |
     +-------+--------+----------------+------+
     |   56  |   29   |        6       |   0  |
     +-------+--------+----------------+------+
     |   57  |   52   |        6       |   0  |
     +-------+--------+----------------+------+
     |   58  |   51   |        6       |   0  |
     +-------+--------+----------------+------+
     |   59  |   50   |        6       |   0  |
     +-------+--------+----------------+------+
     |   60  |   49   |        6       |   0  |
     +-------+--------+----------------+------+
     |   61  |   48   |        6       |   0  |
     +-------+--------+----------------+------+
     |   62  |   47   |        6       |   0  |
     +-------+--------+----------------+------+
     |   63  |   46   |        6       |   0  |
     +-------+--------+----------------+------+
        
A.3. Offset Code Table
A.3. オフセットコードテーブル
     +-------+--------+----------------+------+
     | State | Symbol | Number_Of_Bits | Base |
     +-------+--------+----------------+------+
     |    0  |    0   |        0       |   0  |
     +-------+--------+----------------+------+
     |    0  |    0   |        5       |   0  |
     +-------+--------+----------------+------+
     |    1  |    6   |        4       |   0  |
     +-------+--------+----------------+------+
     |    2  |    9   |        5       |   0  |
     +-------+--------+----------------+------+
     |    3  |   15   |        5       |   0  |
     +-------+--------+----------------+------+
     |    4  |   21   |        5       |   0  |
     +-------+--------+----------------+------+
     |    5  |    3   |        5       |   0  |
     +-------+--------+----------------+------+
     |    6  |    7   |        4       |   0  |
     +-------+--------+----------------+------+
     |    7  |   12   |        5       |   0  |
     +-------+--------+----------------+------+
     |    8  |   18   |        5       |   0  |
     +-------+--------+----------------+------+
     |    9  |   23   |        5       |   0  |
     +-------+--------+----------------+------+
     |   10  |    5   |        5       |   0  |
     +-------+--------+----------------+------+
     |   11  |    8   |        4       |   0  |
     +-------+--------+----------------+------+
     |   12  |   14   |        5       |   0  |
     +-------+--------+----------------+------+
     |   13  |   20   |        5       |   0  |
     +-------+--------+----------------+------+
     |   14  |    2   |        5       |   0  |
     +-------+--------+----------------+------+
     |   15  |    7   |        4       |  16  |
     +-------+--------+----------------+------+
     |   16  |   11   |        5       |   0  |
     +-------+--------+----------------+------+
     |   17  |   17   |        5       |   0  |
     +-------+--------+----------------+------+
     |   18  |   22   |        5       |   0  |
     +-------+--------+----------------+------+
     |   19  |    4   |        5       |   0  |
     +-------+--------+----------------+------+
     |   20  |    8   |        4       |  16  |
        
     +-------+--------+----------------+------+
     |   21  |   13   |        5       |   0  |
     +-------+--------+----------------+------+
     |   22  |   19   |        5       |   0  |
     +-------+--------+----------------+------+
     |   23  |    1   |        5       |   0  |
     +-------+--------+----------------+------+
     |   24  |    6   |        4       |  16  |
     +-------+--------+----------------+------+
     |   25  |   10   |        5       |   0  |
     +-------+--------+----------------+------+
     |   26  |   16   |        5       |   0  |
     +-------+--------+----------------+------+
     |   27  |   28   |        5       |   0  |
     +-------+--------+----------------+------+
     |   28  |   27   |        5       |   0  |
     +-------+--------+----------------+------+
     |   29  |   26   |        5       |   0  |
     +-------+--------+----------------+------+
     |   30  |   25   |        5       |   0  |
     +-------+--------+----------------+------+
     |   31  |   24   |        5       |   0  |
     +-------+--------+----------------+------+
        

Acknowledgments

謝辞

zstd was developed by Yann Collet.

zstdはYann Colletによって開発されました。

Bobo Bose-Kolanu, Felix Handte, Kyle Nekritz, Nick Terrell, and David Schleimer provided helpful feedback during the development of this document.

Bobo Bose-Kolanu、Felix Handte、Kyle Nekritz、Nick Terrell、およびDavid Schleimerは、このドキュメントの作成中に役立つフィードバックを提供しました。

Authors' Addresses

著者のアドレス

Yann Collet Facebook 1 Hacker Way Menlo Park, CA 94025 United States of America

ヤンコレットFacebook 1 Hacker Way Menlo Park、CA 94025アメリカ合衆国

   Email: cyan@fb.com
        

Murray S. Kucherawy (editor) Facebook 1 Hacker Way Menlo Park, CA 94025 United States of America

Murray S. Kucherawy(編集者)Facebook 1 Hacker Way Menlo Park、CA 94025アメリカ合衆国

   Email: msk@fb.com