From 84878498ef3f4f69cd068d3faf744c1743883ad6 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 7 Sep 2019 11:19:10 +1000 Subject: [PATCH] Replace RAC's Brotli Short Codec value by LZ4 RAC still supports Brotli (as a Long Codec, not a Short Codec). It's just no longer given a dedicated Short Codec value (and therefore less likely to be supported out-of-the-box by cmd/ractool). Brotli occupies a similar position to Zstandard on the speed versus size frontier. LZ4 occupies a noticably different position, faster but larger. --- cmd/ractool/data.go | 8 ++++---- cmd/ractool/main.go | 8 ++++---- doc/spec/rac-spec.md | 12 +++++++----- lib/rac/rac.go | 4 ++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/cmd/ractool/data.go b/cmd/ractool/data.go index 2b4fd4e2..543f0bac 100644 --- a/cmd/ractool/data.go +++ b/cmd/ractool/data.go @@ -22,10 +22,10 @@ Random access means that it is possible to reconstruct part of the decompressed file, starting at a given offset into the decompressed file, without always having to first decompress all of the preceding data. -In comparison to some other popular compression formats, all three of the Zlib, -Brotli and Zstandard specifications (RFCs 1950, 7932 and 8478) explicitly -contain the identical phrase: "the data format defined by this specification -does not attempt to allow random access to compressed data". +In comparison to some other popular compression formats, all four of the Zlib, +Brotli, LZ4 and Zstandard specifications explicitly contain the identical +phrase: "the data format defined by this specification does not attempt to +allow random access to compressed data". See the RAC specification for more details: https://github.com/google/wuffs/blob/master/doc/spec/rac-spec.md diff --git a/cmd/ractool/main.go b/cmd/ractool/main.go index 3ac3df2e..27c53bd5 100644 --- a/cmd/ractool/main.go +++ b/cmd/ractool/main.go @@ -23,10 +23,10 @@ Random access means that it is possible to reconstruct part of the decompressed file, starting at a given offset into the decompressed file, without always having to first decompress all of the preceding data. -In comparison to some other popular compression formats, all three of the Zlib, -Brotli and Zstandard specifications (RFCs 1950, 7932 and 8478) explicitly -contain the identical phrase: "the data format defined by this specification -does not attempt to allow random access to compressed data". +In comparison to some other popular compression formats, all four of the Zlib, +Brotli, LZ4 and Zstandard specifications explicitly contain the identical +phrase: "the data format defined by this specification does not attempt to +allow random access to compressed data". See the RAC specification for more details: https://github.com/google/wuffs/blob/master/doc/spec/rac-spec.md diff --git a/doc/spec/rac-spec.md b/doc/spec/rac-spec.md index a14fef27..de6e1e3e 100644 --- a/doc/spec/rac-spec.md +++ b/doc/spec/rac-spec.md @@ -7,9 +7,10 @@ Status: Draft (as of September 2019). There is no compatibility guarantee yet. RAC is a *compressed* file format that allows *random access* (not just sequential access) to the decompressed contents. In comparison to some other -popular compression formats, all three of the +popular compression formats, all four of the [Zlib](https://tools.ietf.org/html/rfc1950), -[Brotli](https://tools.ietf.org/html/rfc7932) and +[Brotli](https://tools.ietf.org/html/rfc7932), +[LZ4](https://github.com/lz4/lz4/blob/master/doc/lz4_Frame_format.md) and [Zstandard](https://tools.ietf.org/html/rfc8478) specifications explicitly contain the identical phrase: "the data format defined by this specification does not attempt to allow random access to compressed data". @@ -25,7 +26,8 @@ sharing additional context, such as a LZ77 prefix dictionary). A RAC file also contains a hierarchical index of those chunks. RAC is a container format, and while it supports common compression codecs like -Zlib, Brotli and Zstandard, it is not tied to any particular compression codec. +Zlib, Brotli, LZ4 and Zstandard, it is not tied to any particular compression +codec. Non-goals for version 1 include: @@ -300,7 +302,7 @@ compression algorithm: - `0x00` means "RAC + Zeroes". - `0x01` means "RAC + Zlib". - - `0x02` means "RAC + Brotli". + - `0x02` means "RAC + LZ4". - `0x04` means "RAC + ZStandard". - All other values are reserved. @@ -515,7 +517,7 @@ reserved. The empty `Tertiary CRange` is ignored. The `Leaf STag` value is also ignored, other than deriving the `Secondary CRange`. -## RAC + Brotli +## RAC + LZ4 TODO. diff --git a/lib/rac/rac.go b/lib/rac/rac.go index 093fa9ef..e5215868 100644 --- a/lib/rac/rac.go +++ b/lib/rac/rac.go @@ -83,7 +83,7 @@ func (c Codec) name() string { case 1: return "Zlib" case 2: - return "Brotli" + return "LZ4" case 4: return "Zstandard" } @@ -98,7 +98,7 @@ func parentChildCodecsValid(parent Codec, child Codec, parentHasMixBit bool) boo const ( CodecZeroes = Codec(0x00 << 56) CodecZlib = Codec(0x01 << 56) - CodecBrotli = Codec(0x02 << 56) + CodecLZ4 = Codec(0x02 << 56) CodecZstandard = Codec(0x04 << 56) codecMixBit = Codec(1 << 62)