Esempio n. 1
0
 public CLzmaProps(CLzmaProps other)
 {
     this.mLC = other.mLC;
     this.mLP = other.mLP;
     this.mPB = other.mPB;
     this.mDicSize = other.mDicSize;
 }
Esempio n. 2
0
            public SRes LzmaDec_Allocate(P<byte> props, uint propsSize, ISzAlloc alloc)
            {
                CLzmaProps propNew = new CLzmaProps();

                SRes res;
                if ((res = propNew.LzmaProps_Decode(props, propsSize)) != SZ_OK)
                    return res;

                if ((res = LzmaDec_AllocateProbs2(propNew, alloc)) != SZ_OK)
                    return res;

                long dicBufSize = propNew.mDicSize;
                if (mDic == null || dicBufSize != mDicBufSize)
                {
                    LzmaDec_FreeDict(alloc);
                    mDic = alloc.AllocBytes(alloc, dicBufSize);
                    if (mDic == null)
                    {
                        LzmaDec_FreeProbs(alloc);
                        return SZ_ERROR_MEM;
                    }
                }

                mDicBufSize = dicBufSize;
                mProp = new CLzmaProps(propNew);
                return SZ_OK;
            }
Esempio n. 3
0
 private static uint LzmaProps_GetNumProbs(CLzmaProps p)
 {
     return LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (p.mLC + p.mLP));
 }
Esempio n. 4
0
            /* ---------- Interfaces ---------- */

            /* There are 3 levels of interfaces:
                 1) Dictionary Interface
                 2) Buffer Interface
                 3) One Call Interface
               You can select any of these interfaces, but don't mix functions from different
               groups for same object. */


            /* There are two variants to allocate state for Dictionary Interface:
                 1) LzmaDec_Allocate / LzmaDec_Free
                 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs
               You can use variant 2, if you set dictionary buffer manually.
               For Buffer Interface you must always use variant 1.

            LzmaDec_Allocate* can return:
              SZ_OK
              SZ_ERROR_MEM         - Memory allocation error
              SZ_ERROR_UNSUPPORTED - Unsupported properties
            */

            public SRes LzmaDec_AllocateProbs(P<byte> props, uint propsSize, ISzAlloc alloc)
            {
                SRes res;
                CLzmaProps propNew = new CLzmaProps();
                if ((res = propNew.LzmaProps_Decode(props, propsSize)) != SZ_OK) return res;
                if ((res = LzmaDec_AllocateProbs2(propNew, alloc)) != SZ_OK) return res;
                mProp = new CLzmaProps(propNew);
                return SZ_OK;
            }
Esempio n. 5
0
 private SRes LzmaDec_AllocateProbs2(CLzmaProps propNew, ISzAlloc alloc)
 {
     uint numProbs = LzmaProps_GetNumProbs(propNew);
     if (mProbs == null || numProbs != mNumProbs)
     {
         LzmaDec_FreeProbs(alloc);
         mProbs = alloc.AllocUInt16(alloc, numProbs);
         mNumProbs = numProbs;
         if (mProbs == null)
             return SZ_ERROR_MEM;
     }
     return SZ_OK;
 }