Rizin
unix-like reverse engineering framework and cli tools
|
by Takayuki Matsuoka
blockStreaming_doubleBuffer.c
is LZ4 Streaming API example which implements double buffer (de)compression.
Please note :
First of all, allocate "Double Buffer" for input and LZ4 compressed data buffer for output. Double buffer has two pages, "first" page (Page#1) and "second" page (Page#2).
Next, read first block to double buffer's first page. And compress it by LZ4_compress_continue()
. For the first time, LZ4 doesn't know any previous dependencies, so it just compress the line without dependencies and generates compressed block {Out#1} to LZ4 compressed data buffer. After that, write {Out#1} to the file.
Next, read second block to double buffer's second page. And compress it. This time, LZ4 can use dependency to Block#1 to improve compression ratio. This dependency is called "Prefix mode".
Next, read third block to double buffer's first page, and compress it. Also this time, LZ4 can use dependency to Block#2. This dependency is called "External Dictonaly mode".
Continue these procedure to the end of the file.
Decompression will do reverse order.
Continue these procedure to the end of the compressed file.