I have this embedded system with a flash memory placed on the board to store a huge number of data. The main controller is an ARM Cortex-M3 processor and I'm supposed to compress the data placed on a part of flash and put the compressed data on another part of the flash.
Now since the amount of SRAM is limited in these kind of systems how exactly can I use the LZ4HC algorithm?
Obviously I can't compress the whole data at once like we do in a PC and I guess I have to do this on a little chunk of data or "block by block" (for example every 512 or 4096 bytes of data). I'm just not sure how. I couldn't totally understand the functions.
Is that even possible to do this block by block?
I couldn't find any example. And the open source code does not come with a good documentation. Actually I think there is no documentation.
lz4hc.c and lz4hc.h. The variant still depends on regular lz4 source files. In particular, the decompression is still provided by lz4.c. )That's many questions
That's really very small.The capabilities of the algorithm will be impactedThat being said, you can make the "fast" version work in this budget.You'll need at a minimum :- a memory segment for compression table (LZ4_MEMORY_USAGE)- an input buffer- an output buffer
Try different mixes, keep the better one for your usages.
Not sure better in what way.
The LZ4_HC algorithm requires a lot more memory.Though, it's kinda possible to create a "lower memory" version, this is a fairly advanced stuff,so I wouldn't advise such direction.One need to properly master basics before attempting more advanced topics.
Ok. Great. So HC is off the table. Since they wouldn't know about it I think it's better this way.
LZ4_compress_fast() deals with each block independently.LZ4_compress_fast_continue() makes each block dependent on previous one.This is pretty advanced topic.If you are unfamiliar with LZ4 API, I suggest you keep it simple, and only use the first variant (LZ4_compress_default()).
Yeah of course I'm not familiar with the API.
> if I use LZ4_compress_default() repetitively and save the output on the flash (append it to the previous generated outputs) is the decompressor still able to decompress them correctly?You will also need to save relevant metadata somewhere.Typically, the compressed size, and potentially the original size (or at least a guaranteed upper bound of original size).