Esempio n. 1
0
            public SRes Lzma2Enc_SetProps(CLzma2EncProps props)
            {
                TR("Lzma2Enc_SetProps:level", props.mLzmaProps.mLevel);
                TR("Lzma2Enc_SetProps:dictSize", props.mLzmaProps.mDictSize);
                TR("Lzma2Enc_SetProps:lc", props.mLzmaProps.mLC);
                TR("Lzma2Enc_SetProps:lp", props.mLzmaProps.mLP);
                TR("Lzma2Enc_SetProps:pb", props.mLzmaProps.mPB);
                TR("Lzma2Enc_SetProps:algo", props.mLzmaProps.mAlgo);
                TR("Lzma2Enc_SetProps:fb", props.mLzmaProps.mFB);
                TR("Lzma2Enc_SetProps:btMode", props.mLzmaProps.mBtMode);
                TR("Lzma2Enc_SetProps:numHashBytes", props.mLzmaProps.mNumHashBytes);
                TR("Lzma2Enc_SetProps:mc", props.mLzmaProps.mMC);
                TR("Lzma2Enc_SetProps:writeEndMark", props.mLzmaProps.mWriteEndMark);
                TR("Lzma2Enc_SetProps:numThreads", props.mLzmaProps.mNumThreads);
                TR("Lzma2Enc_SetProps:blockSize", checked ((int)props.mBlockSize));
                TR("Lzma2Enc_SetProps:numBlockThreads", props.mNumBlockThreads);
                TR("Lzma2Enc_SetProps:numTotalThreads", props.mNumTotalThreads);

                CLzmaEncProps lzmaProps = new CLzmaEncProps(props.mLzmaProps);

                lzmaProps.LzmaEncProps_Normalize();
                if (lzmaProps.mLC + lzmaProps.mLP > LZMA2_LCLP_MAX)
                {
                    return(SZ_ERROR_PARAM);
                }

                mProps = new CLzma2EncProps(props);
                mProps.Lzma2EncProps_Normalize();
                return(SZ_OK);
            }
Esempio n. 2
0
 internal uint LzmaEncProps_GetDictSize()
 {
     CLzmaEncProps props = new CLzmaEncProps(this);
     props.LzmaEncProps_Normalize();
     return props.mDictSize;
 }
Esempio n. 3
0
            public SRes LzmaEnc_SetProps(CLzmaEncProps props2)
            {
                TR("LzmaEnc_SetProps:level", props2.mLevel);
                TR("LzmaEnc_SetProps:dictSize", props2.mDictSize);
                TR("LzmaEnc_SetProps:lc", props2.mLC);
                TR("LzmaEnc_SetProps:lp", props2.mLP);
                TR("LzmaEnc_SetProps:pb", props2.mPB);
                TR("LzmaEnc_SetProps:algo", props2.mAlgo);
                TR("LzmaEnc_SetProps:fb", props2.mFB);
                TR("LzmaEnc_SetProps:btMode", props2.mBtMode);
                TR("LzmaEnc_SetProps:numHashBytes", props2.mNumHashBytes);
                TR("LzmaEnc_SetProps:mc", props2.mMC);
                TR("LzmaEnc_SetProps:writeEndMark", props2.mWriteEndMark);
                TR("LzmaEnc_SetProps:numThreads", props2.mNumThreads);

                CLzmaEncProps props = new CLzmaEncProps(props2);
                props.LzmaEncProps_Normalize();

                if (props.mLC > LZMA_LC_MAX
                    || props.mLP > LZMA_LP_MAX
                    || props.mPB > LZMA_PB_MAX
                    || props.mDictSize > (1u << kDicLogSizeMaxCompress)
                    || props.mDictSize > (1u << 30))
                    return SZ_ERROR_PARAM;

                mDictSize = props.mDictSize;

                uint fb = (uint)props.mFB;
                if (fb < 5)
                    fb = 5;
                if (fb > LZMA_MATCH_LEN_MAX)
                    fb = LZMA_MATCH_LEN_MAX;
                mNumFastBytes = fb;

                mLC = props.mLC;
                mLP = props.mLP;
                mPB = props.mPB;
                mFastMode = (props.mAlgo == 0);
                mMatchFinderBase.mBtMode = (props.mBtMode != 0);

                uint numHashBytes = 4;
                if (props.mBtMode != 0)
                {
                    if (props.mNumHashBytes < 2)
                        numHashBytes = 2;
                    else if (props.mNumHashBytes < 4)
                        numHashBytes = (uint)props.mNumHashBytes;
                }
                mMatchFinderBase.mNumHashBytes = numHashBytes;

                mMatchFinderBase.mCutValue = props.mMC;

                mWriteEndMark = (props.mWriteEndMark != 0);

#if !_7ZIP_ST
                mMultiThread = (props.mNumThreads > 1);
#endif

                return SZ_OK;
            }
Esempio n. 4
0
            public void Lzma2EncProps_Normalize()
            {
                CLzmaEncProps normalizedLzmaProps = new CLzmaEncProps(mLzmaProps);

                normalizedLzmaProps.LzmaEncProps_Normalize();
                int tempThreadsNormalized = normalizedLzmaProps.mNumThreads;
                int tempThreads           = mLzmaProps.mNumThreads;
                int tempBlockThreads      = mNumBlockThreads;
                int tempTotalThreads      = mNumTotalThreads;

                if (tempBlockThreads > NUM_MT_CODER_THREADS_MAX)
                {
                    tempBlockThreads = NUM_MT_CODER_THREADS_MAX;
                }

                if (tempTotalThreads <= 0)
                {
                    if (tempBlockThreads <= 0)
                    {
                        tempBlockThreads = 1;
                    }

                    tempTotalThreads = tempThreadsNormalized * tempBlockThreads;
                }
                else if (tempBlockThreads <= 0)
                {
                    tempBlockThreads = tempTotalThreads / tempThreadsNormalized;

                    if (tempBlockThreads == 0)
                    {
                        tempThreads      = 1;
                        tempBlockThreads = tempTotalThreads;
                    }

                    if (tempBlockThreads > NUM_MT_CODER_THREADS_MAX)
                    {
                        tempBlockThreads = NUM_MT_CODER_THREADS_MAX;
                    }
                }
                else if (tempThreads <= 0)
                {
                    tempThreads = tempTotalThreads / tempBlockThreads;
                    if (tempThreads == 0)
                    {
                        tempThreads = 1;
                    }
                }
                else
                {
                    tempTotalThreads = tempThreadsNormalized * tempBlockThreads;
                }

                mLzmaProps.mNumThreads = tempThreads;
                mNumBlockThreads       = tempBlockThreads;
                mNumTotalThreads       = tempTotalThreads;
                mLzmaProps.LzmaEncProps_Normalize();

                if (mBlockSize == 0)
                {
                    uint dictSize  = mLzmaProps.mDictSize;
                    long blockSize = (long)dictSize << 2;

                    const uint kMinSize = 1 << 20;
                    const uint kMaxSize = 1 << 28;

                    if (blockSize < kMinSize)
                    {
                        blockSize = kMinSize;
                    }

                    if (blockSize > kMaxSize)
                    {
                        blockSize = kMaxSize;
                    }

                    if (blockSize < dictSize)
                    {
                        blockSize = dictSize;
                    }

                    mBlockSize = blockSize;
                }
            }
Esempio n. 5
0
            public SRes Lzma2Enc_SetProps(CLzma2EncProps props)
            {
                TR("Lzma2Enc_SetProps:level", props.mLzmaProps.mLevel);
                TR("Lzma2Enc_SetProps:dictSize", props.mLzmaProps.mDictSize);
                TR("Lzma2Enc_SetProps:lc", props.mLzmaProps.mLC);
                TR("Lzma2Enc_SetProps:lp", props.mLzmaProps.mLP);
                TR("Lzma2Enc_SetProps:pb", props.mLzmaProps.mPB);
                TR("Lzma2Enc_SetProps:algo", props.mLzmaProps.mAlgo);
                TR("Lzma2Enc_SetProps:fb", props.mLzmaProps.mFB);
                TR("Lzma2Enc_SetProps:btMode", props.mLzmaProps.mBtMode);
                TR("Lzma2Enc_SetProps:numHashBytes", props.mLzmaProps.mNumHashBytes);
                TR("Lzma2Enc_SetProps:mc", props.mLzmaProps.mMC);
                TR("Lzma2Enc_SetProps:writeEndMark", props.mLzmaProps.mWriteEndMark);
                TR("Lzma2Enc_SetProps:numThreads", props.mLzmaProps.mNumThreads);
                TR("Lzma2Enc_SetProps:blockSize", checked((int)props.mBlockSize));
                TR("Lzma2Enc_SetProps:numBlockThreads", props.mNumBlockThreads);
                TR("Lzma2Enc_SetProps:numTotalThreads", props.mNumTotalThreads);

                CLzmaEncProps lzmaProps = new CLzmaEncProps(props.mLzmaProps);
                lzmaProps.LzmaEncProps_Normalize();
                if (lzmaProps.mLC + lzmaProps.mLP > LZMA2_LCLP_MAX)
                    return SZ_ERROR_PARAM;

                mProps = new CLzma2EncProps(props);
                mProps.Lzma2EncProps_Normalize();
                return SZ_OK;
            }
Esempio n. 6
0
            public void Lzma2EncProps_Normalize()
            {
                CLzmaEncProps normalizedLzmaProps = new CLzmaEncProps(mLzmaProps);
                normalizedLzmaProps.LzmaEncProps_Normalize();
                int tempThreadsNormalized = normalizedLzmaProps.mNumThreads;
                int tempThreads = mLzmaProps.mNumThreads;
                int tempBlockThreads = mNumBlockThreads;
                int tempTotalThreads = mNumTotalThreads;

                if (tempBlockThreads > NUM_MT_CODER_THREADS_MAX)
                    tempBlockThreads = NUM_MT_CODER_THREADS_MAX;

                if (tempTotalThreads <= 0)
                {
                    if (tempBlockThreads <= 0)
                        tempBlockThreads = 1;

                    tempTotalThreads = tempThreadsNormalized * tempBlockThreads;
                }
                else if (tempBlockThreads <= 0)
                {
                    tempBlockThreads = tempTotalThreads / tempThreadsNormalized;

                    if (tempBlockThreads == 0)
                    {
                        tempThreads = 1;
                        tempBlockThreads = tempTotalThreads;
                    }

                    if (tempBlockThreads > NUM_MT_CODER_THREADS_MAX)
                        tempBlockThreads = NUM_MT_CODER_THREADS_MAX;
                }
                else if (tempThreads <= 0)
                {
                    tempThreads = tempTotalThreads / tempBlockThreads;
                    if (tempThreads == 0)
                        tempThreads = 1;
                }
                else
                {
                    tempTotalThreads = tempThreadsNormalized * tempBlockThreads;
                }

                mLzmaProps.mNumThreads = tempThreads;
                mNumBlockThreads = tempBlockThreads;
                mNumTotalThreads = tempTotalThreads;
                mLzmaProps.LzmaEncProps_Normalize();

                if (mBlockSize == 0)
                {
                    uint dictSize = mLzmaProps.mDictSize;
                    long blockSize = (long)dictSize << 2;

                    const uint kMinSize = 1 << 20;
                    const uint kMaxSize = 1 << 28;

                    if (blockSize < kMinSize)
                        blockSize = kMinSize;

                    if (blockSize > kMaxSize)
                        blockSize = kMaxSize;

                    if (blockSize < dictSize)
                        blockSize = dictSize;

                    mBlockSize = blockSize;
                }
            }