public Encoder() { int num; this._state = new Base.State(); this._repDistances = new uint[4]; this._optimum = new Optimal[0x1000]; this._matchFinder = null; this._rangeEncoder = new SharpCompress.Compressor.LZMA.RangeCoder.Encoder(); this._isMatch = new BitEncoder[0xc0]; this._isRep = new BitEncoder[12]; this._isRepG0 = new BitEncoder[12]; this._isRepG1 = new BitEncoder[12]; this._isRepG2 = new BitEncoder[12]; this._isRep0Long = new BitEncoder[0xc0]; this._posSlotEncoder = new BitTreeEncoder[4]; this._posEncoders = new BitEncoder[0x72]; this._posAlignEncoder = new BitTreeEncoder(4); this._lenEncoder = new LenPriceTableEncoder(); this._repMatchLenEncoder = new LenPriceTableEncoder(); this._literalEncoder = new LiteralEncoder(); this._matchDistances = new uint[0x224]; this._numFastBytes = 0x20; this._posSlotPrices = new uint[0x100]; this._distancesPrices = new uint[0x200]; this._alignPrices = new uint[0x10]; this._distTableSize = 0x2c; this._posStateBits = 2; this._posStateMask = 3; this._numLiteralPosStateBits = 0; this._numLiteralContextBits = 3; this._dictionarySize = 0x400000; this._dictionarySizePrev = uint.MaxValue; this._numFastBytesPrev = uint.MaxValue; this._matchFinderType = EMatchFinderType.BT4; this._writeEndMark = false; this.reps = new uint[4]; this.repLens = new uint[4]; this.properties = new byte[5]; this.tempPrices = new uint[0x80]; this._trainSize = 0; for (num = 0; num < 0x1000L; num++) { this._optimum[num] = new Optimal(); } for (num = 0; num < 4L; num++) { this._posSlotEncoder[num] = new BitTreeEncoder(6); } }
public void SetCoderProperties(CoderPropID[] propIDs, object[] properties) { for (UInt32 i = 0; i < properties.Length; i++) { object prop = properties[i]; switch (propIDs[i]) { case CoderPropID.NumFastBytes: { if (!(prop is Int32)) throw new InvalidParamException(); Int32 numFastBytes = (Int32)prop; if (numFastBytes < 5 || numFastBytes > Base.kMatchMaxLen) throw new InvalidParamException(); _numFastBytes = (UInt32)numFastBytes; break; } case CoderPropID.Algorithm: { /* if (!(prop is Int32)) throw new InvalidParamException(); Int32 maximize = (Int32)prop; _fastMode = (maximize == 0); _maxMode = (maximize >= 2); */ break; } case CoderPropID.MatchFinder: { if (!(prop is String)) throw new InvalidParamException(); EMatchFinderType matchFinderIndexPrev = _matchFinderType; int m = FindMatchFinder(((string)prop).ToUpper()); if (m < 0) throw new InvalidParamException(); _matchFinderType = (EMatchFinderType)m; if (_matchFinder != null && matchFinderIndexPrev != _matchFinderType) { _dictionarySizePrev = 0xFFFFFFFF; _matchFinder = null; } break; } case CoderPropID.DictionarySize: { const int kDicLogSizeMaxCompress = 30; if (!(prop is Int32)) throw new InvalidParamException(); ; Int32 dictionarySize = (Int32)prop; if (dictionarySize < (UInt32)(1 << Base.kDicLogSizeMin) || dictionarySize > (UInt32)(1 << kDicLogSizeMaxCompress)) throw new InvalidParamException(); _dictionarySize = (UInt32)dictionarySize; int dicLogSize; for (dicLogSize = 0; dicLogSize < (UInt32)kDicLogSizeMaxCompress; dicLogSize++) if (dictionarySize <= ((UInt32)(1) << dicLogSize)) break; _distTableSize = (UInt32)dicLogSize * 2; break; } case CoderPropID.PosStateBits: { if (!(prop is Int32)) throw new InvalidParamException(); Int32 v = (Int32)prop; if (v < 0 || v > (UInt32)Base.kNumPosStatesBitsEncodingMax) throw new InvalidParamException(); _posStateBits = (int)v; _posStateMask = (((UInt32)1) << (int)_posStateBits) - 1; break; } case CoderPropID.LitPosBits: { if (!(prop is Int32)) throw new InvalidParamException(); Int32 v = (Int32)prop; if (v < 0 || v > (UInt32)Base.kNumLitPosStatesBitsEncodingMax) throw new InvalidParamException(); _numLiteralPosStateBits = (int)v; break; } case CoderPropID.LitContextBits: { if (!(prop is Int32)) throw new InvalidParamException(); Int32 v = (Int32)prop; if (v < 0 || v > (UInt32)Base.kNumLitContextBitsMax) throw new InvalidParamException(); ; _numLiteralContextBits = (int)v; break; } case CoderPropID.EndMarker: { if (!(prop is Boolean)) throw new InvalidParamException(); SetWriteEndMarkerMode((Boolean)prop); break; } default: throw new InvalidParamException(); } } }
public void SetCoderProperties(CoderPropID[] propIDs, object[] properties) { for (uint i = 0; i < properties.Length; i++) { EMatchFinderType type; int num4; int num6; object obj2 = properties[i]; switch (propIDs[i]) { case CoderPropID.DictionarySize: if (!(obj2 is int)) { throw new InvalidParamException(); } goto Label_013B; case CoderPropID.PosStateBits: if (!(obj2 is int)) { throw new InvalidParamException(); } goto Label_01C3; case CoderPropID.LitContextBits: if (!(obj2 is int)) { throw new InvalidParamException(); } goto Label_0267; case CoderPropID.LitPosBits: if (!(obj2 is int)) { throw new InvalidParamException(); } goto Label_0220; case CoderPropID.NumFastBytes: if (!(obj2 is int)) { throw new InvalidParamException(); } break; case CoderPropID.MatchFinder: if (!(obj2 is string)) { throw new InvalidParamException(); } goto Label_00C0; case CoderPropID.Algorithm: { continue; } case CoderPropID.EndMarker: if (!(obj2 is bool)) { throw new InvalidParamException(); } goto Label_02AE; default: throw new InvalidParamException(); } int num2 = (int) obj2; if ((num2 < 5) || (num2 > 0x111L)) { throw new InvalidParamException(); } this._numFastBytes = (uint) num2; continue; Label_00C0: type = this._matchFinderType; int num3 = FindMatchFinder(((string) obj2).ToUpper()); if (num3 < 0) { throw new InvalidParamException(); } this._matchFinderType = (EMatchFinderType) num3; if ((this._matchFinder != null) && (type != this._matchFinderType)) { this._dictionarySizePrev = uint.MaxValue; this._matchFinder = null; } continue; Label_013B: num4 = (int) obj2; if ((num4 < 1L) || (num4 > 0x40000000L)) { throw new InvalidParamException(); } this._dictionarySize = (uint) num4; int num5 = 0; while (num5 < 30L) { if (num4 <= (((uint) 1) << num5)) { break; } num5++; } this._distTableSize = (uint) (num5 * 2); continue; Label_01C3: num6 = (int) obj2; if ((num6 < 0) || (num6 > 4L)) { throw new InvalidParamException(); } this._posStateBits = num6; this._posStateMask = (uint) ((((int) 1) << this._posStateBits) - 1); continue; Label_0220: num6 = (int) obj2; if ((num6 < 0) || (num6 > 4L)) { throw new InvalidParamException(); } this._numLiteralPosStateBits = num6; continue; Label_0267: num6 = (int) obj2; if ((num6 < 0) || (num6 > 8L)) { throw new InvalidParamException(); } this._numLiteralContextBits = num6; continue; Label_02AE: this.SetWriteEndMarkerMode((bool) obj2); } }