conor42 / 7-Zip-FL2

7-Zip using the Fast LZMA2 library
27 stars 1 forks source link

How flzma2 decode ? #1

Open jinfeihan57 opened 4 years ago

jinfeihan57 commented 4 years ago

In file /CPP/7zip/Compress/Lzma2Encoder.cpp HRESULT CFastEncoder::FastLzma2::AddByteCount(size_t count, ISequentialOutStream outStream, ICompressProgressInfo progress) { dict_pos += count; if (dict_pos == dict.size) { size_t res = FL2_updateDictionary(fcs, dict_pos); CHECK_H(WaitAndReport(res, progress)); if (res != 0) CHECK_H(WriteBuffers(outStream)); res = FL2_getDictionaryBuffer(fcs, &dict); while (FL2_isTimedOut(res)) { if (!UpdateProgress(progress)) return S_FALSE; res = FL2_getDictionaryBuffer(fcs, &dict); } CHECK_S(res); dict_pos = 0; } if (!UpdateProgress(progress)) return S_FALSE; return S_OK; } You didn't call FL2_compressStream() to compress src data. Can FL2_getDictionaryBuffer also compress data? You use basic Flzma2 API to compress. Did you change the FL2_compressStream() format? Did you change the format to support the decompression of lzma2 OR Can FL2_compressStream() compressed data be decompressed by Lzma2Decode() .

conor42 commented 4 years ago

FL2_getDictionaryBuffer() is part of an alternate set of functions which skip a copy operation. The output stream is decoded by Lzma2Decode().

jinfeihan57 commented 4 years ago

Thanks for your answer. I think i found it. flzma2copy FL2_compressStream() need a memcopy. 7zipflzma2 In 7zip-FL,you skip it. 👍 )