internal SRes Lzma2Enc_EncodeMt1(CLzma2Enc mainEncoder, ISeqOutStream outStream, ISeqInStream inStream, ICompressProgress progress) { ulong packTotal = 0; SRes res = SZ_OK; if (mainEncoder.mOutBuf == null) { mainEncoder.mOutBuf = IAlloc_AllocBytes(mainEncoder.mAlloc, LZMA2_CHUNK_SIZE_COMPRESSED_MAX); if (mainEncoder.mOutBuf == null) { return(SZ_ERROR_MEM); } } if ((res = Lzma2EncInt_Init(mainEncoder.mProps)) != SZ_OK) { return(res); } if ((res = mEnc.LzmaEnc_PrepareForLzma2(inStream, LZMA2_KEEP_WINDOW_SIZE, mainEncoder.mAlloc, mainEncoder.mAllocBig)) != SZ_OK) { return(res); } for (;;) { long packSize = LZMA2_CHUNK_SIZE_COMPRESSED_MAX; res = Lzma2EncInt_EncodeSubblock(mainEncoder.mOutBuf, ref packSize, outStream); if (res != SZ_OK) { break; } packTotal += (ulong)packSize; res = Progress(progress, mSrcPos, packTotal); if (res != SZ_OK) { break; } if (packSize == 0) { break; } } mEnc.LzmaEnc_Finish(); if (res == SZ_OK) { if (outStream.Write(new byte[] { 0 }, 1) != 1) { return(SZ_ERROR_WRITE); } } return(res); }
internal CMtCallbackImp(CLzma2Enc enc) { mLzma2Enc = enc; }
internal SRes Lzma2Enc_EncodeMt1(CLzma2Enc mainEncoder, ISeqOutStream outStream, ISeqInStream inStream, ICompressProgress progress) { ulong packTotal = 0; SRes res = SZ_OK; if (mainEncoder.mOutBuf == null) { mainEncoder.mOutBuf = IAlloc_AllocBytes(mainEncoder.mAlloc, LZMA2_CHUNK_SIZE_COMPRESSED_MAX); if (mainEncoder.mOutBuf == null) return SZ_ERROR_MEM; } if ((res = Lzma2EncInt_Init(mainEncoder.mProps)) != SZ_OK) return res; if ((res = mEnc.LzmaEnc_PrepareForLzma2(inStream, LZMA2_KEEP_WINDOW_SIZE, mainEncoder.mAlloc, mainEncoder.mAllocBig)) != SZ_OK) return res; for (;;) { long packSize = LZMA2_CHUNK_SIZE_COMPRESSED_MAX; res = Lzma2EncInt_EncodeSubblock(mainEncoder.mOutBuf, ref packSize, outStream); if (res != SZ_OK) break; packTotal += (ulong)packSize; res = Progress(progress, mSrcPos, packTotal); if (res != SZ_OK) break; if (packSize == 0) break; } mEnc.LzmaEnc_Finish(); if (res == SZ_OK) { if (outStream.Write(new byte[] { 0 }, 1) != 1) return SZ_ERROR_WRITE; } return res; }