private static void RcTree_ReverseEncode(CRangeEnc rc, P<ushort> probs, int numBitLevels, uint symbol) { uint m = 1; for (int i = 0; i < numBitLevels; i++) { uint bit = symbol & 1; rc.RangeEnc_EncodeBit(probs + m, bit); m = (m << 1) | bit; symbol >>= 1; } }
internal static void RcTree_Encode(CRangeEnc rc, P<ushort> probs, int numBitLevels, uint symbol) { uint m = 1; for (int i = numBitLevels; i != 0;) { i--; uint bit = (symbol >> i) & 1; rc.RangeEnc_EncodeBit(probs + m, bit); m = (m << 1) | bit; } }
private static void LitEnc_EncodeMatched(CRangeEnc p, P<ushort> probs, uint symbol, uint matchByte) { uint offs = 0x100; symbol |= 0x100; do { matchByte <<= 1; p.RangeEnc_EncodeBit(probs + (offs + (matchByte & offs) + (symbol >> 8)), (symbol >> 7) & 1); symbol <<= 1; offs &= ~(matchByte ^ symbol); } while (symbol < 0x10000); }
private static void LitEnc_Encode(CRangeEnc p, P<ushort> probs, uint symbol) { symbol |= 0x100; do { p.RangeEnc_EncodeBit(probs + (symbol >> 8), (symbol >> 7) & 1); symbol <<= 1; } while (symbol < 0x10000); }
internal void LenEnc_Encode2(CRangeEnc rc, uint symbol, uint posState, bool updatePrice, P<uint> probPrices) { LenEnc_Encode(rc, symbol, posState); if (updatePrice) { if (--mCounters[posState] == 0) LenPriceEnc_UpdateTable(posState, probPrices); } }
internal void LenEnc_Encode(CRangeEnc rc, uint symbol, uint posState) { if (symbol < CLzmaEnc.kLenNumLowSymbols) { rc.RangeEnc_EncodeBit(ref mChoice, 0); CLzmaEnc.RcTree_Encode(rc, P.From(mLow, posState << CLzmaEnc.kLenNumLowBits), CLzmaEnc.kLenNumLowBits, symbol); } else { rc.RangeEnc_EncodeBit(ref mChoice, 1); if (symbol < CLzmaEnc.kLenNumLowSymbols + CLzmaEnc.kLenNumMidSymbols) { rc.RangeEnc_EncodeBit(ref mChoice2, 0); CLzmaEnc.RcTree_Encode(rc, P.From(mMid, posState << CLzmaEnc.kLenNumMidBits), CLzmaEnc.kLenNumMidBits, symbol - CLzmaEnc.kLenNumLowSymbols); } else { rc.RangeEnc_EncodeBit(ref mChoice2, 1); CLzmaEnc.RcTree_Encode(rc, mHigh, CLzmaEnc.kLenNumHighBits, symbol - CLzmaEnc.kLenNumLowSymbols - CLzmaEnc.kLenNumMidSymbols); } } }