public uint Decode(RangeDecoder decoder) { uint newBound = (decoder._range >> K_NUM_BIT_MODEL_TOTAL_BITS) * _prob; if (decoder._code < newBound) { decoder._range = newBound; _prob += (K_BIT_MODEL_TOTAL - _prob) >> NUM_MOVE_BITS; if (decoder._range < K_TOP_VALUE) { decoder._code = (decoder._code << 8) | decoder.ReadByte(); decoder._range <<= 8; } return(0); } decoder._range -= newBound; decoder._code -= newBound; _prob -= _prob >> NUM_MOVE_BITS; if (decoder._range < K_TOP_VALUE) { decoder._code = (decoder._code << 8) | decoder.ReadByte(); decoder._range <<= 8; } return(1); }
public uint Decode(RangeDecoder decoder) { uint newBound = (decoder.Range >> kNumBitModelTotalBits) * Prob; if (decoder.Code < newBound) { decoder.Range = newBound; Prob += (kBitModelTotal - Prob) >> numMoveBits; if (decoder.Range < kTopValue) { decoder.Code = (decoder.Code << 8) | decoder.ReadByte(); decoder.Range <<= 8; } return 0; } else { decoder.Range -= newBound; decoder.Code -= newBound; Prob -= Prob >> numMoveBits; if (decoder.Range < kTopValue) { decoder.Code = (decoder.Code << 8) | decoder.ReadByte(); decoder.Range <<= 8; } return 1; } }
public Bcj2DecoderStream(Stream[] streams, byte[] info, long limit) { if (info != null && info.Length > 0) { throw new NotSupportedException(); } if (streams.Length != 4) { throw new NotSupportedException(); } mLimit = limit; mMainStream = streams[0]; mCallStream = streams[1]; mJumpStream = streams[2]; mRangeDecoder = new RangeDecoder(streams[3]); mStatusDecoder = new StatusDecoder[256 + 2]; for (int i = 0; i < mStatusDecoder.Length; i++) { mStatusDecoder[i] = new StatusDecoder(); } mIter = Run().GetEnumerator(); }
public uint Decode(RangeDecoder decoder) { uint newBound = (decoder.Range >> kNumBitModelTotalBits) * Prob; if (decoder.Code < newBound) { decoder.Range = newBound; Prob += (kBitModelTotal - Prob) >> numMoveBits; if (decoder.Range < kTopValue) { decoder.Code = (decoder.Code << 8) | decoder.ReadByte(); decoder.Range <<= 8; } return(0); } else { decoder.Range -= newBound; decoder.Code -= newBound; Prob -= Prob >> numMoveBits; if (decoder.Range < kTopValue) { decoder.Code = (decoder.Code << 8) | decoder.ReadByte(); decoder.Range <<= 8; } return(1); } }
public uint Decode(RangeDecoder rangeRangeDecoder) { var newBound = (rangeRangeDecoder.Range >> kNumBitModelTotalBits) * Prob; if (rangeRangeDecoder.Code < newBound) { rangeRangeDecoder.Range = newBound; Prob += (kBitModelTotal - Prob) >> kNumMoveBits; if (rangeRangeDecoder.Range < RangeDecoder.kTopValue) { rangeRangeDecoder.Code = (rangeRangeDecoder.Code << 8) | (byte)rangeRangeDecoder.Stream.ReadByte(); rangeRangeDecoder.Range <<= 8; } return(0); } rangeRangeDecoder.Range -= newBound; rangeRangeDecoder.Code -= newBound; Prob -= Prob >> kNumMoveBits; if (rangeRangeDecoder.Range < RangeDecoder.kTopValue) { rangeRangeDecoder.Code = (rangeRangeDecoder.Code << 8) | (byte)rangeRangeDecoder.Stream.ReadByte(); rangeRangeDecoder.Range <<= 8; } return(1); }
internal uint Decode(RangeDecoder RangeDecoder) { uint NewBound = (RangeDecoder.Range >> 11) * Prob; if (RangeDecoder.Code < NewBound) { RangeDecoder.Range = NewBound; Prob += (2048U - Prob) >> 5; if (RangeDecoder.Range < 16777216U) { RangeDecoder.Code = (RangeDecoder.Code << 8) | (uint)RangeDecoder.Stream.ReadByte(); RangeDecoder.Range <<= 8; } return(0U); } else { RangeDecoder.Code -= NewBound; RangeDecoder.Range -= NewBound; Prob -= Prob >> 5; if (RangeDecoder.Range < 16777216U) { RangeDecoder.Code = (RangeDecoder.Code << 8) | (uint)RangeDecoder.Stream.ReadByte(); RangeDecoder.Range <<= 8; } return(1U); } }
public uint Decode(RangeDecoder rangeRangeDecoder) { uint m = 1; for (var bitIndex = NumBitLevels; bitIndex > 0; bitIndex--) { m = (m << 1) + Models[m].Decode(rangeRangeDecoder); } return(m - ((uint)1 << NumBitLevels)); }
internal byte Decode(RangeDecoder RangeDecoder) { uint Symbol = 1U; while (Symbol < 256U) { Symbol = (Symbol << 1) | Decoders[Symbol].Decode(RangeDecoder); } return((byte)Symbol); }
public uint ReverseDecode(RangeDecoder rangeRangeDecoder) { uint m = 1; uint symbol = 0; for (var bitIndex = 0; bitIndex < NumBitLevels; bitIndex++) { var bit = Models[m].Decode(rangeRangeDecoder); m <<= 1; m += bit; symbol |= bit << bitIndex; } return(symbol); }
public static uint ReverseDecode(BitDecoder[] Models, uint startIndex, RangeDecoder rangeRangeDecoder, int NumBitLevels) { uint m = 1; uint symbol = 0; for (var bitIndex = 0; bitIndex < NumBitLevels; bitIndex++) { var bit = Models[startIndex + m].Decode(rangeRangeDecoder); m <<= 1; m += bit; symbol |= bit << bitIndex; } return(symbol); }
public Bcj2DecoderStream(Stream[] streams, byte[] info, long limit) { if (info != null && info.Length > 0) throw new NotSupportedException(); if (streams.Length != 4) throw new NotSupportedException(); mMainStream = streams[0]; mCallStream = streams[1]; mJumpStream = streams[2]; mRangeDecoder = new RangeDecoder(streams[3]); mStatusDecoder = new StatusDecoder[256 + 2]; for (int i = 0; i < mStatusDecoder.Length; i++) mStatusDecoder[i] = new StatusDecoder(); mIter = Run().GetEnumerator(); }
internal byte Decode(RangeDecoder RangeDecoder, byte MatchByte) { uint Match = MatchByte, Symbol = 1U; while (Symbol < 256U) { uint MatchBit = (Match >> 7) & 1U, Bit = Decoders[((1U + MatchBit) << 8) + Symbol].Decode(RangeDecoder); Match <<= 1; Symbol = (Symbol << 1) | Bit; if (MatchBit != Bit) { while (Symbol < 256U) { Symbol = (Symbol << 1) | Decoders[Symbol].Decode(RangeDecoder); } break; } } return((byte)Symbol); }
public override void SetInputStream(int index, ReaderNode stream, long length) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } switch (index) { case 0: mMainStream = stream; break; case 1: mCallStream = stream; break; case 2: mJumpStream = stream; break; case 3: mRangeDecoder = new RangeDecoder(stream); break; default: throw new ArgumentOutOfRangeException(nameof(index)); } }
public uint Decode(RangeDecoder rangeDecoder, uint posState) { if (m_Choice.Decode(rangeDecoder) == 0) { return(m_LowCoder[posState].Decode(rangeDecoder)); } else { uint symbol = LzmaBase.kNumLowLenSymbols; if (m_Choice2.Decode(rangeDecoder) == 0) { symbol += m_MidCoder[posState].Decode(rangeDecoder); } else { symbol += LzmaBase.kNumMidLenSymbols; symbol += m_HighCoder.Decode(rangeDecoder); } return(symbol); } }
public Bcj2DecoderStream(Stream[] streams, byte[] info, long limit) { if ((info != null) && (info.Length > 0)) { throw new NotSupportedException(); } if (streams.Length != 4) { throw new NotSupportedException(); } this.mLimit = limit; this.mMainStream = streams[0]; this.mCallStream = streams[1]; this.mJumpStream = streams[2]; this.mRangeDecoder = new RangeDecoder(streams[3]); this.mStatusDecoder = new StatusDecoder[0x102]; for (int i = 0; i < this.mStatusDecoder.Length; i++) { this.mStatusDecoder[i] = new StatusDecoder(); } this.mIter = this.Run().GetEnumerator(); }
internal byte Decode(RangeDecoder RangeDecoder, uint Position, byte PreviousByte, byte MatchByte) => Decoders[GetState(Position, PreviousByte)].Decode(RangeDecoder, MatchByte);
public override void SetInputStream(int index, ReaderNode stream, long length) { if (stream == null) throw new ArgumentNullException(nameof(stream)); switch (index) { case 0: mMainStream = stream; break; case 1: mCallStream = stream; break; case 2: mJumpStream = stream; break; case 3: mRangeDecoder = new RangeDecoder(stream); break; default: throw new ArgumentOutOfRangeException(nameof(index)); } }
internal uint Decode(RangeDecoder RangeDecoder, uint PositionState) => ChoiceA.Decode(RangeDecoder) == 0U ? LowDecoder[PositionState].Decode(RangeDecoder) : 8U + (ChoiceB.Decode(RangeDecoder) == 0U ? MidDecoder[PositionState].Decode(RangeDecoder) : (8U + HighDecoder.Decode(RangeDecoder)));