From the README, I gather:
Handling of output (decompressed) stream:
- In-memory decompression, where output stream fully resides in memory.
- Streaming decompression, which allows to process arbitrary-sized streams (longer than available memory), but requires in-memory buffer for Deflate dictionary window.
- Application specifies number of output bytes it wants to decompress, which can be as high as UINT_MAX to decompress everything into memory at once, or as low as 1 to decompress byte by byte, or any other value to decompress a chunk of that size.
- Option 1 is not feasible on the target MCU (not enough RAM)
- Option 2 works on a test application, but is not feasible on the target MCU, if the dictionary must be 32kB (not enough RAM)
That leaves me with:
Option 3: What I am trying to do is to decompress 128 bytes (or any other value) of bytes at a time (the 'chunk' size) from a stream. (Streaming the input in 128b chunks works fine!)
This 128 byte output works, once.
After that, if I re-init d.dest_start = d.dest = uz_data_dest;,
this will cause an error -3 when decompressing the next series of bytes.
I found out that this is because of the LZSS offset (lzOff) looking for previous occurrences of the same data, relative to the current position of the output buffer (hence d->dest[0] = d->dest[d->lzOff]). But since the output buffer has been re-initialized, these relative offsets are not valid anymore. So that sounds logical.
I gather that's why in this case, a dict is needed. Sure enough, I added a 32kB rambuffer to be used as dict, and it worked.
However, on the target embedded system, I don't have 32kB of RAM...
So the question is:
- Can decompressing in chunks (writing to the same RAM location for every chunk) be done without dictionary?
- If not, how big must the dictionary really be? Can a size smaller than 32kB be used and what are the conditions?
With some explanation about the exact usage of these case, I would be glad to provide some example code to be included in the repo, if that would help as documentation for the project!
Thanks for the project! 👍
From the README, I gather:
That leaves me with:
Option 3: What I am trying to do is to decompress 128 bytes (or any other value) of bytes at a time (the 'chunk' size) from a stream. (Streaming the input in 128b chunks works fine!)
This 128 byte output works, once.
After that, if I re-init
d.dest_start = d.dest = uz_data_dest;,this will cause an error -3 when decompressing the next series of bytes.
I found out that this is because of the LZSS offset (
lzOff) looking for previous occurrences of the same data, relative to the current position of the output buffer (henced->dest[0] = d->dest[d->lzOff]). But since the output buffer has been re-initialized, these relative offsets are not valid anymore. So that sounds logical.I gather that's why in this case, a
dictis needed. Sure enough, I added a 32kB rambuffer to be used as dict, and it worked.However, on the target embedded system, I don't have 32kB of RAM...
So the question is:
With some explanation about the exact usage of these case, I would be glad to provide some example code to be included in the repo, if that would help as documentation for the project!
Thanks for the project! 👍