mirror of
https://github.com/google/brotli.git
synced 2026-07-09 02:08:06 +00:00
There is no way to get the size of decompressed file before decoding #321
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 @eyny on GitHub (May 19, 2020).
I am sorry if I am mistaken, but I could not find any method to find the size of decompressed file before executing decoding operation. We need to find the best size for destination buffer, the less the better. This would be a nice function to have just like "ZSTD_getFrameContentSize" of zstd library. There was a function called "BrotliDecompressedSize", however, I cannot find it anywhere in the source files. It seems that it is deprecated.
@eustas commented on GitHub (Jul 2, 2020):
It is true, there is no way to determine the size of content without decompressing. Brotli was designed for streaming use case. Strictly speaking it is not even file format...
We are working on framing format that will allow navigation among other useful features: https://datatracker.ietf.org/doc/draft-vandevenne-shared-brotli-format/
Sorry for it took too long to roll out.
As for your problem - it depends on what is the source of brotli files. If you control the generation (and reading) of those, then just append/prepend 4/6/8 bytes with content size and use it =)