commit | 26bcfdd46ee56055b61b6e8f23f0ff57626a95a7 | [log] [tgz] |
---|---|---|
author | Amin Hassani <ahassani@google.com> | Sat Sep 30 00:54:15 2017 |
committer | chrome-bot <chrome-bot@chromium.org> | Tue Oct 17 20:02:53 2017 |
tree | 71a0bb21196d7d08f240d6b3a2599f5145a5e3cf | |
parent | 92f667a14a8183e0efcc98a2ed347830dce71710 [diff] |
puffin: Use empty puff writer There was a piece of code (Puffer.Puff) that was only being used in puffdiff but it was also being shipped with puffpatch too. That code figures out the size of the puff by puffing into a buffer, There was two problem with that. First, the code shouldn't have been mixed with the client code, and second, it needs retry of the Puffer.PuffDeflate to do the puffing again if the buffer size was small. This patch fixes that problem by removing that function and adding checks in the Puffer.PuffDeflate to not check for boundary or write into the buffer if the given buffer size was nullptr. This way we can create a PuffWriter with null buffer that can count the number of bytes needed for a puff buffer. Along with, all PuffDeflate and HuffDeflate functions based on the byte array buffer where removed and equivalent functions based on BitReader/BitWriter/PuffReader/PuffWriter were made public. Additionally this CL, adds a new function for finding the location of Puffs using the aforementioned functionality in the utils.cc (which will only be in used in puffdiff). Furthermore, this CL fixes a long undiscovered bug, for when the length of the literals was exactly 127. The PuffWriter would write a wrong value to the output and this would cause problem. The unittests for this bug was also added. Since this bug was in PuffWriter.cc and most of the changes are in PuffWriter.cc this was a good candidate for fixing this bug. BUG=chromium:768505 TEST=unittests pass; brillo_update_payload {generate|verify} pass; Change-Id: Ie5eb12dc637623b8f3ed08709590a323d9f830f8 Reviewed-on: https://chromium-review.googlesource.com/703680 Commit-Ready: Amin Hassani <ahassani@chromium.org> Tested-by: Amin Hassani <ahassani@chromium.org> Reviewed-by: Ben Chan <benchan@chromium.org> Reviewed-by: Sen Jiang <senj@chromium.org>
Source code for Puffin: A utility for deterministic DEFLATE recompression.
TODO(ahassani): Describe the directory structure and how-tos.
Alphabet A value that occurs in the input stream. It can be either a literal:[0..255], and end of block sign [256], a length[257..285], or a distance [0..29].
Huffman code A variable length code representing the Huffman encoded of an alphabet. Huffman codes can be created uniquely using Huffman code length array.
Huffman code array An array which an array index identifies a Huffman code and the array element in that index represents the corresponding alphabet. Throughout the code, Huffman code arrays are identified by vectors with postfix hcodes_
.
Huffman reverse code array An array which an array index identifies an alphabet and the array element in that index contains the Huffman code of the alphabet. Throughout the code, The Huffman reverse code arrays are identified by vectors with postfix rcodes_
.
Huffman code length The number of bits in a Huffman code.
Huffman code length array An array of Huffman code lengths with the array index as the alphabet. Throughout the code, Huffman code length arrays are identified by vectors with postfix lens_
.