public void Code(System.IO.Stream inStream, System.IO.Stream outStream,
            Int64 inSize, Int64 outSize, ICodeProgress progress)
        {
            if (m_OutWindow == null)
                CreateDictionary();
            m_OutWindow.Init(outStream);
            if (outSize > 0)
                m_OutWindow.SetLimit(outSize);
            else
                m_OutWindow.SetLimit(Int64.MaxValue - m_OutWindow.Total);

            RangeCoder.Decoder rangeDecoder = new RangeCoder.Decoder();
            rangeDecoder.Init(inStream);

            Code(m_DictionarySize, m_OutWindow, rangeDecoder);

            m_OutWindow.ReleaseStream();
            rangeDecoder.ReleaseStream();

            if (!rangeDecoder.IsFinished || (inSize > 0 && rangeDecoder.Total != inSize))
                throw new DataErrorException();
            if (m_OutWindow.HasPending)
                throw new DataErrorException();
            m_OutWindow = null;
        }
Example #2
0
 public void Code(Stream inStream, Stream outStream, long inSize, long outSize, ICodeProgress progress)
 {
     if (this.m_OutWindow == null)
     {
         this.CreateDictionary();
     }
     this.m_OutWindow.Init(outStream);
     if (outSize > 0L)
     {
         this.m_OutWindow.SetLimit(outSize);
     }
     else
     {
         this.m_OutWindow.SetLimit(0x7fffffffffffffffL - this.m_OutWindow.Total);
     }
     SharpCompress.Compressor.LZMA.RangeCoder.Decoder rangeDecoder = new SharpCompress.Compressor.LZMA.RangeCoder.Decoder();
     rangeDecoder.Init(inStream);
     this.Code(this.m_DictionarySize, this.m_OutWindow, rangeDecoder);
     this.m_OutWindow.ReleaseStream();
     rangeDecoder.ReleaseStream();
     if (!(rangeDecoder.IsFinished && ((inSize <= 0L) || (rangeDecoder.Total == inSize))))
     {
         throw new DataErrorException();
     }
     if (this.m_OutWindow.HasPending)
     {
         throw new DataErrorException();
     }
     this.m_OutWindow = null;
 }
Example #3
0
 public void Code(Stream inStream, Stream outStream, long inSize, long outSize, ICodeProgress progress)
 {
     if (this.m_OutWindow == null)
     {
         this.CreateDictionary();
     }
     this.m_OutWindow.Init(outStream);
     if (outSize > 0L)
     {
         this.m_OutWindow.SetLimit(outSize);
     }
     else
     {
         this.m_OutWindow.SetLimit(0x7fffffffffffffffL - this.m_OutWindow.Total);
     }
     SharpCompress.Compressor.LZMA.RangeCoder.Decoder rangeDecoder = new SharpCompress.Compressor.LZMA.RangeCoder.Decoder();
     rangeDecoder.Init(inStream);
     this.Code(this.m_DictionarySize, this.m_OutWindow, rangeDecoder);
     this.m_OutWindow.ReleaseStream();
     rangeDecoder.ReleaseStream();
     if (!(rangeDecoder.IsFinished && ((inSize <= 0L) || (rangeDecoder.Total == inSize))))
     {
         throw new DataErrorException();
     }
     if (this.m_OutWindow.HasPending)
     {
         throw new DataErrorException();
     }
     this.m_OutWindow = null;
 }
Example #4
0
        public void Code(System.IO.Stream inStream, System.IO.Stream outStream,
                         Int64 inSize, Int64 outSize, ICodeProgress progress)
        {
            if (m_OutWindow == null)
            {
                CreateDictionary();
            }
            m_OutWindow.Init(outStream);
            if (outSize > 0)
            {
                m_OutWindow.SetLimit(outSize);
            }
            else
            {
                m_OutWindow.SetLimit(Int64.MaxValue - m_OutWindow.Total);
            }

            RangeCoder.Decoder rangeDecoder = new RangeCoder.Decoder();
            rangeDecoder.Init(inStream);

            Code(m_DictionarySize, m_OutWindow, rangeDecoder);

            m_OutWindow.ReleaseStream();
            rangeDecoder.ReleaseStream();

            if (!rangeDecoder.IsFinished || (inSize > 0 && rangeDecoder.Total != inSize))
            {
                throw new DataErrorException();
            }
            if (m_OutWindow.HasPending)
            {
                throw new DataErrorException();
            }
            m_OutWindow = null;
        }
Example #5
0
        public LzmaStream(byte[] properties, Stream inputStream, long inputSize, long outputSize,
                          Stream presetDictionary, bool isLZMA2)
        {
            this.inputStream = inputStream;
            this.inputSize   = inputSize;
            this.outputSize  = outputSize;
            this.isLZMA2     = isLZMA2;

            if (!isLZMA2)
            {
                dictionarySize = DataConverter.LittleEndian.GetInt32(properties, 1);
                outWindow.Create(dictionarySize);
                if (presetDictionary != null)
                {
                    outWindow.Train(presetDictionary);
                }

                rangeDecoder.Init(inputStream);

                decoder = new Decoder();
                decoder.SetDecoderProperties(properties);
                props = properties;

                availableBytes    = outputSize < 0 ? long.MaxValue : outputSize;
                rangeDecoderLimit = inputSize;
            }
            else
            {
                dictionarySize   = 2 | (properties[0] & 1);
                dictionarySize <<= (properties[0] >> 1) + 11;

                outWindow.Create(dictionarySize);
                if (presetDictionary != null)
                {
                    outWindow.Train(presetDictionary);
                    needDictReset = false;
                }

                props          = new byte[1];
                availableBytes = 0;
            }
        }