From c7942caff083f8c76085208c8a34812c337ad820 Mon Sep 17 00:00:00 2001 From: Ulrich Kunitz Date: Mon, 22 Oct 2018 23:46:43 +0200 Subject: [PATCH 1/3] Clarify special case of offset history update If the current sequence has literal length of zero then an offset value of three is handled in a special manner. While I implemented a golang decoder I had to consult the educational decoder for clarification on the update of the offset history in that case. This commit provides the clarification that the offset value Repeated_Offset1-1 is handled as a new offset is added to the offset history accordingly. --- doc/zstd_compression_format.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/zstd_compression_format.md b/doc/zstd_compression_format.md index e562e628b..eacf76252 100644 --- a/doc/zstd_compression_format.md +++ b/doc/zstd_compression_format.md @@ -919,6 +919,10 @@ This means that when `Repeated_Offset1` (most recent) is used, history is unmodi When `Repeated_Offset2` is used, it's swapped with `Repeated_Offset1`. If any other offset is used, it becomes `Repeated_Offset1` and the rest are shift back by one. +In the case of an `offset_value` of 3 and the literal length of the current +sequence is zero the value `Repeasted_Offset1 - 1_byte` is a new offset, +becoming the lead of the offset history and the first two repeated offsets will +be shifted back. Skippable Frames ---------------- From 4f702e44457508122e249109170452d89decb971 Mon Sep 17 00:00:00 2001 From: Ulrich Kunitz Date: Tue, 23 Oct 2018 08:36:50 +0200 Subject: [PATCH 2/3] Fixed a typo I fixed a typo in the last commit. Many thanks to @terrelin for pointing that out. --- doc/zstd_compression_format.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/zstd_compression_format.md b/doc/zstd_compression_format.md index eacf76252..0cf8ab178 100644 --- a/doc/zstd_compression_format.md +++ b/doc/zstd_compression_format.md @@ -920,7 +920,7 @@ When `Repeated_Offset2` is used, it's swapped with `Repeated_Offset1`. If any other offset is used, it becomes `Repeated_Offset1` and the rest are shift back by one. In the case of an `offset_value` of 3 and the literal length of the current -sequence is zero the value `Repeasted_Offset1 - 1_byte` is a new offset, +sequence is zero the value `Repeated_Offset1 - 1_byte` is a new offset, becoming the lead of the offset history and the first two repeated offsets will be shifted back. @@ -1415,7 +1415,7 @@ __`Content`__ : The rest of the dictionary is its content. 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`. + 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. From f0fe9b0f0298ed8e5c2eebf36e024803f176f6dd Mon Sep 17 00:00:00 2001 From: Ulrich Kunitz Date: Tue, 23 Oct 2018 08:43:19 +0200 Subject: [PATCH 3/3] Reverted removal of a trailing space. My editor removes trailing spaces while saving. Not confusing things I reverted that change. --- doc/zstd_compression_format.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/zstd_compression_format.md b/doc/zstd_compression_format.md index 0cf8ab178..a57470651 100644 --- a/doc/zstd_compression_format.md +++ b/doc/zstd_compression_format.md @@ -1415,7 +1415,7 @@ __`Content`__ : The rest of the dictionary is its content. 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`. + 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.