-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detecting truncated streams #1109
Comments
|
@terrelln Right. But a stream may have multiple frames, right? It returns 0 every time a frame is completely decoded — not just for the final frame. Maybe I misunderstand? |
The zlib stream is a zstd frame. Generally a stream contains a single frame. A zstd frame ends when Just like zlib can have multiple streams back to back, zstd can have multiple frames back to back, but in each case the streams/frames are independent. In the case of multiple zlib streams concatenated together, zlib will return |
Ah, perfect! I was confused by the terminology gap. 😅 With the key "zlib stream = zstd frame; zlib frame = zstd block," your initial response makes sense. Sorry about the noise! 🤭 It looks like Thank you. |
Hi,
zlib has a nice feature where the decompressor (
inflate
) returnsZ_STREAM_END
at the end of the stream. This works when zlib is used with or without the gzip framing (an "undocumented" feature accessed by passing a negative window size). The method is not zlib-specific and is a part of the DEFLATE standard: a special bitBFINAL
is set on the final frame. (In zlib it is referred to asinflate_state::last
.)This is useful for determining if a DEFLATE stream has been truncated. Without the bit, it is impossible to determine whether a stream ending at a frame boundary is truncated or not. It would be nice if Zstd provided similar functionality. I may be mistaken, but as far as I can tell Zstd does not expose truncated vs not to the user via
ZSTD_decompressStream()
(and may lack the metadata, although I have not investigated).The text was updated successfully, but these errors were encountered: