diff options
author | Alexander Mohr <alexander.m.mohr@mercedes-benz.com> | 2022-06-03 13:38:54 (GMT) |
---|---|---|
committer | Alexander Mohr <alexander.m.mohr@mercedes-benz.com> | 2022-06-09 15:08:01 (GMT) |
commit | 4aeb5020c35e2464c25eb69d8bf6c7645b8faf20 (patch) | |
tree | d23ce84bf30f996bf6c7842445078986be63c628 /lib/lz4.c | |
parent | 14d3b6342f1dca15fe36f952434ecf3c9b8329a0 (diff) | |
download | lz4-4aeb5020c35e2464c25eb69d8bf6c7645b8faf20.zip lz4-4aeb5020c35e2464c25eb69d8bf6c7645b8faf20.tar.gz lz4-4aeb5020c35e2464c25eb69d8bf6c7645b8faf20.tar.bz2 |
frame-api: add method to insert uncomressed data
new method `uncompressed_update` allows to insert blocks without
compression into the lz4 stream.
The usage is documented in the frameCompress example
Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
Diffstat (limited to 'lib/lz4.c')
-rw-r--r-- | lib/lz4.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1679,6 +1679,15 @@ int LZ4_compress_forceExtDict (LZ4_stream_t* LZ4_dict, const char* source, char* return result; } +int LZ4_DictSize (LZ4_stream_t* LZ4_dict, int dictSize) +{ + LZ4_stream_t_internal* const dict = &LZ4_dict->internal_donotuse; + + if ((U32)dictSize > 64 KB) { dictSize = 64 KB; } /* useless to define a dictionary > 64 KB */ + if ((U32)dictSize > dict->dictSize) { dictSize = (int)dict->dictSize; } + + return dictSize; +} /*! LZ4_saveDict() : * If previously compressed data block is not guaranteed to remain available at its memory location, @@ -1690,12 +1699,9 @@ int LZ4_compress_forceExtDict (LZ4_stream_t* LZ4_dict, const char* source, char* int LZ4_saveDict (LZ4_stream_t* LZ4_dict, char* safeBuffer, int dictSize) { LZ4_stream_t_internal* const dict = &LZ4_dict->internal_donotuse; - + dictSize = LZ4_DictSize(LZ4_dict, dictSize); DEBUGLOG(5, "LZ4_saveDict : dictSize=%i, safeBuffer=%p", dictSize, safeBuffer); - if ((U32)dictSize > 64 KB) { dictSize = 64 KB; } /* useless to define a dictionary > 64 KB */ - if ((U32)dictSize > dict->dictSize) { dictSize = (int)dict->dictSize; } - if (safeBuffer == NULL) assert(dictSize == 0); if (dictSize > 0) { const BYTE* const previousDictEnd = dict->dictionary + dict->dictSize; |