public SRes Lzma2Enc_Encode(ISeqOutStream outStream, ISeqInStream inStream, ICompressProgress progress) { for (int i = 0; i < mProps.mNumBlockThreads; i++) { CLzma2EncInternal t = mCoders[i]; if (t.mEnc == null) { t.mEnc = LzmaEnc_Create(mAlloc); if (t.mEnc == null) { return(SZ_ERROR_MEM); } } } #if !_7ZIP_ST if (mProps.mNumBlockThreads <= 1) #endif return(mCoders[0].Lzma2Enc_EncodeMt1(this, outStream, inStream, progress)); #if !_7ZIP_ST mMtCoder.mProgress = progress; mMtCoder.mInStream = inStream; mMtCoder.mOutStream = outStream; mMtCoder.mAlloc = mAlloc; mMtCoder.mMtCallback = new CMtCallbackImp(this); mMtCoder.mBlockSize = mProps.mBlockSize; mMtCoder.mDestBlockSize = mProps.mBlockSize + (mProps.mBlockSize >> 10) + 16; mMtCoder.mNumThreads = mProps.mNumBlockThreads; return(mMtCoder.MtCoder_Code()); #endif }
public void Lzma2Enc_Destroy() { for (uint i = 0; i < mCoders.Length; i++) { CLzma2EncInternal t = mCoders[i]; if (t.mEnc != null) { t.mEnc.LzmaEnc_Destroy(mAlloc, mAllocBig); t.mEnc = null; } } #if !_7ZIP_ST mMtCoder.MtCoder_Destruct(); #endif IAlloc_FreeBytes(mAlloc, mOutBuf); IAlloc_FreeObject(mAlloc, this); }
public CLzma2Enc(ISzAlloc alloc, ISzAlloc allocBig) // Lzma2Enc_Create { Trace.AllocSmallObject("CLzma2Enc", alloc); mProps.Lzma2EncProps_Init(); mProps.Lzma2EncProps_Normalize(); mOutBuf = null; mAlloc = alloc; mAllocBig = allocBig; mCoders = new CLzma2EncInternal[NUM_MT_CODER_THREADS_MAX]; for (int i = 0; i < mCoders.Length; i++) { mCoders[i] = new CLzma2EncInternal(); mCoders[i].mEnc = null; } #if !_7ZIP_ST mMtCoder = new CMtCoder(); #endif }
// Lzma2Enc_Create public CLzma2Enc(ISzAlloc alloc, ISzAlloc allocBig) { Trace.AllocSmallObject("CLzma2Enc", alloc); mProps.Lzma2EncProps_Init(); mProps.Lzma2EncProps_Normalize(); mOutBuf = null; mAlloc = alloc; mAllocBig = allocBig; mCoders = new CLzma2EncInternal[NUM_MT_CODER_THREADS_MAX]; for (int i = 0; i < mCoders.Length; i++) { mCoders[i] = new CLzma2EncInternal(); mCoders[i].mEnc = null; } #if !_7ZIP_ST mMtCoder = new CMtCoder(); #endif }
internal SRes Code(int index, P <byte> dest, ref long destSize, P <byte> src, long srcSize, bool finished) { CLzma2EncInternal p = mLzma2Enc.mCoders[index]; SRes res = SZ_OK; long destLim = destSize; destSize = 0; if (srcSize != 0) { if ((res = p.Lzma2EncInt_Init(mLzma2Enc.mProps)) != SZ_OK) { return(res); } if ((res = p.mEnc.LzmaEnc_MemPrepare(src, srcSize, CLzma2EncInternal.LZMA2_KEEP_WINDOW_SIZE, mLzma2Enc.mAlloc, mLzma2Enc.mAllocBig)) != SZ_OK) { return(res); } while (p.mSrcPos < (ulong)srcSize) { long packSize = destLim - destSize; res = p.Lzma2EncInt_EncodeSubblock(dest + destSize, ref packSize, null); if (res != SZ_OK) { break; } destSize += packSize; if (packSize == 0) { res = SZ_ERROR_FAIL; break; } if (mLzma2Enc.mMtCoder.mMtProgress.MtProgress_Set(index, p.mSrcPos, (ulong)destSize) != SZ_OK) { res = SZ_ERROR_PROGRESS; break; } } p.mEnc.LzmaEnc_Finish(); if (res != SZ_OK) { return(res); } } if (finished) { if (destSize == destLim) { return(SZ_ERROR_OUTPUT_EOF); } dest[destSize++] = 0; } return(res); }