mirror of
https://github.com/google/brotli.git
synced 2026-09-22 14:45:51 +00:00
Custom dictionary causes failed round trip on some input #99
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @phlknght on GitHub (Mar 15, 2016).
Using BrotliCompressWithCustomDictionary to compress certain files then decompressing after using BrotliSetCustomDictionary followed by BrotliDecompressStream results in output that doesn't match the original file. However, most files survive the round trip intact.
Here is my compress code which is lightly modified from bro.cc, since it is possible that I am doing something wrong:
And here is my decompress function:
I created a repo with my custom dictionary, dictator.out, which I generated with Cloudflare's dictator.go script and then appended 7 bytes to the end because of the LOAD64 padding, along with broken.bin and works.bin. Broken.bin doesn't survive the round trip intact, and works.bin does.
On the positive side, I am getting a nice boost in compression ratio using the custom dictionary. It went from .336 to .285, though I can't completely trust that figure until the round trip test works for all files.
@phlknght commented on GitHub (Mar 15, 2016):
This commit has the same changes built directly into bro.cc. Probably easier to pull this locally to try it out. It also shows the same behavior.
@eustas commented on GitHub (Mar 15, 2016):
Hello.
Thank you for your report. Going to investigate this tomorrow.
@phlknght commented on GitHub (Mar 15, 2016):
Thanks! I went ahead and created the actual test case using your same framework in this commit.
@eustas commented on GitHub (Mar 16, 2016):
Hello. We have a fix for this. The problem is in decoder. Will publish fix soon.
@phlknght commented on GitHub (Mar 16, 2016):
Thanks for the quick response.
@phlknght commented on GitHub (Apr 21, 2016):
I pulled
510131d1db, and the custom dictionary round trip seems to be working properly now. Thanks!