예제 #1
0
        internal int DecodeBlock(Stream source, byte[] buffer, int offset, int count)
        {
            if (_minimumContext == PpmContext.ZERO)
            {
                return(0);
            }

            int total = 0;

            while (total < count)
            {
                if (_numberStatistics != 0)
                {
                    DecodeSymbol1(_minimumContext);
                }
                else
                {
                    DecodeBinarySymbol(_minimumContext);
                }

                _coder.RangeRemoveSubrange();

                while (_foundState == PpmState.ZERO)
                {
                    _coder.RangeDecoderNormalize(source);
                    do
                    {
                        _orderFall++;
                        _minimumContext = _minimumContext.Suffix;
                        if (_minimumContext == PpmContext.ZERO)
                        {
                            goto StopDecoding;
                        }
                    }while (_minimumContext.NumberStatistics == _numberMasked);
                    DecodeSymbol2(_minimumContext);
                    _coder.RangeRemoveSubrange();
                }

                buffer[offset] = _foundState.Symbol;
                offset++;
                total++;

                if (_orderFall == 0 && (Pointer)_foundState.Successor >= _allocator._baseUnit)
                {
                    _maximumContext = _foundState.Successor;
                }
                else
                {
                    UpdateModel(_minimumContext);
                    if (_escapeCount == 0)
                    {
                        ClearMask();
                    }
                }

                _minimumContext   = _maximumContext;
                _numberStatistics = _minimumContext.NumberStatistics;
                _coder.RangeDecoderNormalize(source);
            }

StopDecoding:
            return(total);
        }
        internal int DecodeBlock(Stream source, byte[] buffer, int offset, int count)
        {
            if (minimumContext == PpmContext.Zero)
            {
                return(0);
            }

            int total = 0;

            while (total < count)
            {
                if (numberStatistics != 0)
                {
                    DecodeSymbol1(minimumContext);
                }
                else
                {
                    DecodeBinarySymbol(minimumContext);
                }

                Coder.RangeRemoveSubrange();

                while (foundState == PpmState.Zero)
                {
                    Coder.RangeDecoderNormalize(source);
                    do
                    {
                        orderFall++;
                        minimumContext = minimumContext.Suffix;
                        if (minimumContext == PpmContext.Zero)
                        {
                            goto StopDecoding;
                        }
                    }while (minimumContext.NumberStatistics == numberMasked);
                    DecodeSymbol2(minimumContext);
                    Coder.RangeRemoveSubrange();
                }

                buffer[offset] = foundState.Symbol;
                offset++;
                total++;

                if (orderFall == 0 && (Pointer)foundState.Successor >= Allocator.BaseUnit)
                {
                    maximumContext = foundState.Successor;
                }
                else
                {
                    UpdateModel(minimumContext);
                    if (escapeCount == 0)
                    {
                        ClearMask();
                    }
                }

                minimumContext   = maximumContext;
                numberStatistics = minimumContext.NumberStatistics;
                Coder.RangeDecoderNormalize(source);
            }

StopDecoding:
            return(total);
        }