From 9dc12b63c70a9bcf46bbe0a639b725c6724e5008 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Fri, 30 Dec 2016 17:55:09 +0300 Subject: [PATCH 01/12] =?UTF-8?q?All=20is=E2=80=A6=20arrays=20in=20LZMADec?= =?UTF-8?q?oder=20replaced=20with=20single=20probabilities=20array.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/LZMADecoder.swift | 65 +++++++++++++-------------------------- 1 file changed, 21 insertions(+), 44 deletions(-) diff --git a/Sources/LZMADecoder.swift b/Sources/LZMADecoder.swift index bbd9d927..cbeb4335 100644 --- a/Sources/LZMADecoder.swift +++ b/Sources/LZMADecoder.swift @@ -21,6 +21,7 @@ struct LZMAConstants { static let endPosModelIndex: Int = 14 static let numFullDistances: Int = (1 << (endPosModelIndex >> 1)) static let matchMinLen: Int = 2 + // LZMAConstants.numStates << LZMAConstants.numPosBitsMax = 192 } final class LZMADecoder { @@ -45,19 +46,18 @@ final class LZMADecoder { Each table contains 0x300 probabilities. */ private var literalProbs: [[Int]] - // These arrays are used to select type of match or literal. - private var isMatch: [Int] = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates << LZMAConstants.numPosBitsMax) - private var isRep: [Int] = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates) - private var isRepG0: [Int] = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates) - private var isRepG1: [Int] = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates) - private var isRepG2: [Int] = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates) - private var isRep0Long: [Int] = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates << LZMAConstants.numPosBitsMax) + + /** + Array with all probabilities: + + - 0..<192: isMatch + - 193..<205: isRep + - 205..<217: isRepG0 + - 217..<229: isRepG1 + - 229..<241: isRepG2 + - 241..<433: isRep0Long + */ + private var probabilities: [Int] = Array(repeating: LZMAConstants.probInitValue, count: 2 * 192 + 4 * 12) private var posDecoders: [Int] @@ -117,19 +117,8 @@ final class LZMADecoder { self.rangeDecoder = LZMARangeDecoder() } - self.isMatch = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates << LZMAConstants.numPosBitsMax) - self.isRep = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates) - self.isRepG0 = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates) - self.isRepG1 = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates) - self.isRepG2 = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates) - self.isRep0Long = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates << LZMAConstants.numPosBitsMax) + self.probabilities = Array(repeating: LZMAConstants.probInitValue, count: 2 * 192 + 4 * 12) self.literalProbs = Array(repeating: Array(repeating: LZMAConstants.probInitValue, count: 0x300), count: 1 << (lc + lp).toInt()) @@ -174,19 +163,7 @@ final class LZMADecoder { self.rep2 = 0 self.rep3 = 0 - self.isMatch = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates << LZMAConstants.numPosBitsMax) - self.isRep = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates) - self.isRepG0 = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates) - self.isRepG1 = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates) - self.isRepG2 = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates) - self.isRep0Long = Array(repeating: LZMAConstants.probInitValue, - count: LZMAConstants.numStates << LZMAConstants.numPosBitsMax) - + self.probabilities = Array(repeating: LZMAConstants.probInitValue, count: 2 * 192 + 4 * 12) self.literalProbs = Array(repeating: Array(repeating: LZMAConstants.probInitValue, count: 0x300), count: 1 << (lc + lp).toInt()) @@ -273,7 +250,7 @@ final class LZMADecoder { let posState = outWindow.totalPosition & ((1 << pb.toInt()) - 1) lzmaDiagPrint("posState: \(posState)") - if rangeDecoder.decode(bitWithProb: &isMatch[(state << LZMAConstants.numPosBitsMax) + posState]) == 0 { + if rangeDecoder.decode(bitWithProb: &probabilities[(state << LZMAConstants.numPosBitsMax) + posState]) == 0 { if uncompressedSize == 0 { throw LZMAError.ExceededUncompressedSize } // DECODE LITERAL: @@ -328,13 +305,13 @@ final class LZMADecoder { } var len: Int - if rangeDecoder.decode(bitWithProb: &isRep[state]) != 0 { + if rangeDecoder.decode(bitWithProb: &probabilities[193 + state]) != 0 { // REP MATCH CASE if uncompressedSize == 0 { throw LZMAError.ExceededUncompressedSize } if outWindow.isEmpty { throw LZMAError.WindowIsEmpty } - if rangeDecoder.decode(bitWithProb: &isRepG0[state]) == 0 { + if rangeDecoder.decode(bitWithProb: &probabilities[205 + state]) == 0 { // (We use last distance from 'distance history table'). - if rangeDecoder.decode(bitWithProb: &isRep0Long[(state << LZMAConstants.numPosBitsMax) + posState]) == 0 { + if rangeDecoder.decode(bitWithProb: &probabilities[241 + (state << LZMAConstants.numPosBitsMax) + posState]) == 0 { // SHORT REP MATCH CASE state = state < 7 ? 9 : 11 lzmaDiagPrint("updatedState: \(state)") @@ -348,10 +325,10 @@ final class LZMADecoder { // So the following code selectes one distance from history... // based on the binary data. let dist: Int - if rangeDecoder.decode(bitWithProb: &isRepG1[state]) == 0 { + if rangeDecoder.decode(bitWithProb: &probabilities[217 + state]) == 0 { dist = rep1 } else { - if rangeDecoder.decode(bitWithProb: &isRepG2[state]) == 0 { + if rangeDecoder.decode(bitWithProb: &probabilities[229 + state]) == 0 { dist = rep2 } else { dist = rep3 From 2774fcbb57d5633d42791054445d2a122604686c Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Fri, 30 Dec 2016 18:11:05 +0300 Subject: [PATCH 02/12] Added prevByte computed property to DWP so it is possible to make bitArray private again. --- Sources/DataWithPointer.swift | 6 +++++- Sources/LZMADecoder.swift | 15 ++++++--------- Sources/XZArchive.swift | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Sources/DataWithPointer.swift b/Sources/DataWithPointer.swift index bbd6e9eb..da4de96d 100644 --- a/Sources/DataWithPointer.swift +++ b/Sources/DataWithPointer.swift @@ -17,7 +17,7 @@ final class DataWithPointer { let bitOrder: BitOrder let size: Int - private(set) var bitArray: [UInt8] + private var bitArray: [UInt8] var index: Int = 0 private(set) var bitMask: UInt8 @@ -25,6 +25,10 @@ final class DataWithPointer { return self.size == self.index } + var prevAlignedByte: UInt8 { + return self.bitArray[self.index - 1] + } + init(array: inout [UInt8], bitOrder: BitOrder) { self.bitOrder = bitOrder self.bitArray = array diff --git a/Sources/LZMADecoder.swift b/Sources/LZMADecoder.swift index cbeb4335..cb67d778 100644 --- a/Sources/LZMADecoder.swift +++ b/Sources/LZMADecoder.swift @@ -98,25 +98,22 @@ final class LZMADecoder { self.pb = pb self.dictionarySize = dictionarySize self.uncompressedSize = uncompressedSize + + guard let rD = LZMARangeDecoder(&self.pointerData) else { + throw LZMAError.RangeDecoderInitError + } + self.rangeDecoder = rD } else { self.lc = 0 self.lp = 0 self.pb = 0 self.dictionarySize = 0 self.uncompressedSize = -1 - } - self.outWindow = LZMAOutWindow(dictSize: self.dictionarySize) - - if initProperties { - guard let rD = LZMARangeDecoder(&self.pointerData) else { - throw LZMAError.RangeDecoderInitError - } - self.rangeDecoder = rD - } else { self.rangeDecoder = LZMARangeDecoder() } + self.outWindow = LZMAOutWindow(dictSize: self.dictionarySize) self.probabilities = Array(repeating: LZMAConstants.probInitValue, count: 2 * 192 + 4 * 12) self.literalProbs = Array(repeating: Array(repeating: LZMAConstants.probInitValue, diff --git a/Sources/XZArchive.swift b/Sources/XZArchive.swift index 5233285d..0cacc4ae 100644 --- a/Sources/XZArchive.swift +++ b/Sources/XZArchive.swift @@ -354,7 +354,7 @@ extension DataWithPointer { return (result, bytes) } result &= 0x7F - while self.bitArray[self.index - 1] & 0x80 != 0 { + while self.prevAlignedByte & 0x80 != 0 { let byte = self.alignedByte() if i >= 9 || byte == 0x00 { throw XZError.MultiByteIntegerError From 41936b573e23cb1eab88b993dfba15ef2bc0cfc9 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Fri, 30 Dec 2016 21:51:26 +0300 Subject: [PATCH 03/12] Removed lzma print functions. --- Sources/LZMABitTreeDecoder.swift | 5 +--- Sources/LZMADecoder.swift | 48 -------------------------------- Sources/LZMALenDecoder.swift | 3 -- Sources/LZMARangeDecoder.swift | 15 ---------- 4 files changed, 1 insertion(+), 70 deletions(-) diff --git a/Sources/LZMABitTreeDecoder.swift b/Sources/LZMABitTreeDecoder.swift index 0a17e8dd..fdf8f2ec 100644 --- a/Sources/LZMABitTreeDecoder.swift +++ b/Sources/LZMABitTreeDecoder.swift @@ -25,16 +25,13 @@ final class LZMABitTreeDecoder { func decode(with rangeDecoder: inout LZMARangeDecoder) -> Int { var m = 1 - for i in 0.. Int { - lzmaDiagPrint("!!!BitTreeReverseDecode") return LZMABitTreeDecoder.bitTreeReverseDecode(probs: &self.probs, startIndex: 0, bits: self.numBits, diff --git a/Sources/LZMADecoder.swift b/Sources/LZMADecoder.swift index cb67d778..3ffef17c 100644 --- a/Sources/LZMADecoder.swift +++ b/Sources/LZMADecoder.swift @@ -227,17 +227,12 @@ final class LZMADecoder { } func decodeLZMA() throws -> [UInt8] { - lzmaInfoPrint("lc: \(lc), lp: \(lp), pb: \(pb), dictionarySize: \(dictionarySize)") - lzmaInfoPrint("uncompressedSize: \(uncompressedSize)") - /// An array for storing output data var out: [UInt8] = uncompressedSize == -1 ? [] : Array(repeating: 0, count: uncompressedSize) var outIndex = uncompressedSize == -1 ? -1 : 0 // Main decoding cycle. while true { - lzmaDiagPrint("=========================") - lzmaDiagPrint("start_unpackSize: \(uncompressedSize)") // If uncompressed size was defined and everything is unpacked then stop. if uncompressedSize == 0 { if rangeDecoder.isFinishedOK { @@ -246,14 +241,12 @@ final class LZMADecoder { } let posState = outWindow.totalPosition & ((1 << pb.toInt()) - 1) - lzmaDiagPrint("posState: \(posState)") if rangeDecoder.decode(bitWithProb: &probabilities[(state << LZMAConstants.numPosBitsMax) + posState]) == 0 { if uncompressedSize == 0 { throw LZMAError.ExceededUncompressedSize } // DECODE LITERAL: /// Previous literal (zero, if there was none). let prevByte = outWindow.isEmpty ? 0 : outWindow.byte(at: 1) - lzmaDiagPrint("decodeLiteral_prevByte: \(prevByte)") /// Decoded symbol. Initial value is 1. var symbol = 1 /** @@ -283,7 +276,6 @@ final class LZMADecoder { while symbol < 0x100 { symbol = (symbol << 1) | rangeDecoder.decode(bitWithProb: &literalProbs[litState][symbol]) } - lzmaDiagPrint("decodeLiteral_symbol: \(symbol)") let byte = (symbol - 0x100).toUInt8() outWindow.put(byte, &out, &outIndex, &uncompressedSize) // END. @@ -296,7 +288,6 @@ final class LZMADecoder { } else { state -= 6 } - lzmaDiagPrint("decodeLiteral_updatedState: \(state)") continue } @@ -311,9 +302,7 @@ final class LZMADecoder { if rangeDecoder.decode(bitWithProb: &probabilities[241 + (state << LZMAConstants.numPosBitsMax) + posState]) == 0 { // SHORT REP MATCH CASE state = state < 7 ? 9 : 11 - lzmaDiagPrint("updatedState: \(state)") let byte = outWindow.byte(at: rep0 + 1) - lzmaDiagPrint("byte_to_put: \(byte)") outWindow.put(byte, &out, &outIndex, &uncompressedSize) continue } @@ -335,16 +324,9 @@ final class LZMADecoder { } rep1 = rep0 rep0 = dist - lzmaDiagPrint("rep_match_rep0: \(rep0)") - lzmaDiagPrint("rep_match_rep1: \(rep1)") - lzmaDiagPrint("rep_match_rep2: \(rep2)") - lzmaDiagPrint("rep_match_rep3: \(rep3)") - lzmaDiagPrint("rep_match_dist: \(dist)") } len = repLenDecoder.decode(with: &rangeDecoder, posState: posState) - lzmaDiagPrint("read_len: \(len)") state = state < 7 ? 8 : 11 - lzmaDiagPrint("updatedState: \(state)") } else { // SIMPLE MATCH CASE // First, we need to move history of distance values. rep3 = rep2 @@ -353,12 +335,6 @@ final class LZMADecoder { len = lenDecoder.decode(with: &rangeDecoder, posState: posState) state = state < 7 ? 7 : 10 - lzmaDiagPrint("beforeDecodeDistance_updatedRep3: \(rep3)") - lzmaDiagPrint("beforeDecodeDistance_updatedRep2: \(rep2)") - lzmaDiagPrint("beforeDecodeDistance_updatedRep1: \(rep1)") - lzmaDiagPrint("beforeDecodeDistance_updatedLen: \(len)") - lzmaDiagPrint("beforeDecodeDistance_updatedState: \(state)") - // DECODE DISTANCE: /// Is used to define context for distance decoding. var lenState = len @@ -366,22 +342,16 @@ final class LZMADecoder { lenState = LZMAConstants.numLenToPosStates - 1 } - lzmaDiagPrint("decodeDistance_lenState: \(lenState)") /// Defines decoding scheme for distance value. let posSlot = posSlotDecoder[lenState].decode(with: &rangeDecoder) - lzmaDiagPrint("decodeDistance_posSlot: \(posSlot)") if posSlot < 4 { // If `posSlot` is less than 4 then distance has defined value (no need to decode). // And distance is actually equal to `posSlot`. rep0 = posSlot - lzmaDiagPrint("decodeDistance: posSlot => rep0") } else { - lzmaDiagPrint("decodeDistance: dist => rep0") let numDirectBits = (posSlot >> 1) - 1 - lzmaDiagPrint("decodeDistance_numDirectBits: \(numDirectBits)") var dist = ((2 | (posSlot & 1)) << numDirectBits) - lzmaDiagPrint("decodeDistance_startDist: \(dist)") if posSlot < LZMAConstants.endPosModelIndex { // In this case we need a sequence of bits decoded with bit tree... // ...(separate trees for different `posSlot` values)... @@ -390,16 +360,13 @@ final class LZMADecoder { startIndex: dist - posSlot, bits: numDirectBits, rangeDecoder: &rangeDecoder) - lzmaDiagPrint("decodeDistance_updatedDist_0: \(dist)") } else { // Middle bits of distance are decoded as direct bits from RangeDecoder. dist += rangeDecoder.decode(directBits: (numDirectBits - LZMAConstants.numAlignBits)) << LZMAConstants.numAlignBits - lzmaDiagPrint("decodeDistance_updatedDist_1_1: \(dist)") // Low 4 bits are decoded with a bit tree decoder (called 'AlignDecoder')... // ...with "Reverse" scheme. dist += alignDecoder.reverseDecode(with: &rangeDecoder) - lzmaDiagPrint("decodeDistance_updatedDist_1_2: \(dist)") } rep0 = dist } @@ -408,7 +375,6 @@ final class LZMADecoder { // Check if finish marker is encountered. // Distance value of 2^32 is used to indicate 'End of Stream' marker. if UInt32(rep0) == 0xFFFFFFFF { - lzmaDiagPrint("finish_marker") guard rangeDecoder.isFinishedOK else { throw LZMAError.RangeDecoderFinishError } break } @@ -418,9 +384,7 @@ final class LZMADecoder { } // Converting from zero-based length of the match to the real one. len += LZMAConstants.matchMinLen - lzmaDiagPrint("finalLen: \(len)") if uncompressedSize > -1 && uncompressedSize < len { throw LZMAError.RepeatWillExceed } - lzmaDiagPrint("copyMatch_at: \(rep0 + 1)") outWindow.copyMatch(at: rep0 + 1, length: len, &out, &outIndex, &uncompressedSize) } @@ -428,15 +392,3 @@ final class LZMADecoder { } } - -func lzmaDiagPrint(_ s: String) { - #if LZMA_DIAG - print(s) - #endif -} - -func lzmaInfoPrint(_ s: String) { - #if LZMA_INFO - print(s) - #endif -} diff --git a/Sources/LZMALenDecoder.swift b/Sources/LZMALenDecoder.swift index f99cb550..67c880ef 100644 --- a/Sources/LZMALenDecoder.swift +++ b/Sources/LZMALenDecoder.swift @@ -31,18 +31,15 @@ final class LZMALenDecoder { /// Decodes zero-based match length. func decode(with rangeDecoder: inout LZMARangeDecoder, posState: Int) -> Int { // There can be one of three options. - lzmaDiagPrint("!!!LenDecoder_DECODE") // We need one or two bits to find out which decoding scheme to use. // `choice` is used to decode first bit. // `choice2` is used to decode second bit. // If binary sequence starts with 0 then: if rangeDecoder.decode(bitWithProb: &self.choice) == 0 { - lzmaDiagPrint("lenDecoder_lowCoder_posState: \(posState)") return self.lowCoder[posState].decode(with: &rangeDecoder) } // If binary sequence starts with 1 0 then: if rangeDecoder.decode(bitWithProb: &self.choice2) == 0 { - lzmaDiagPrint("lenDecoder_midCoder_posState: \(posState)") return 8 + self.midCoder[posState].decode(with: &rangeDecoder) } // If binary sequence starts with 1 1 then: diff --git a/Sources/LZMARangeDecoder.swift b/Sources/LZMARangeDecoder.swift index c074a03d..5d7aae76 100644 --- a/Sources/LZMARangeDecoder.swift +++ b/Sources/LZMARangeDecoder.swift @@ -50,23 +50,15 @@ final class LZMARangeDecoder { /// Decodes sequence of direct bits (binary symbols with fixed and equal probabilities). func decode(directBits: Int) -> Int { - lzmaDiagPrint("!!!decodeDirectBits") - lzmaDiagPrint("decodeDirectBits_code_start: \(self.code)") - lzmaDiagPrint("decodeDirectBits_range_start: \(self.range)") var res: UInt32 = 0 var count = directBits - lzmaDiagPrint("decodeDirectBits_count: \(count)") repeat { self.range >>= 1 - lzmaDiagPrint("decodeDirectBits_range_1: \(self.range)") self.code = UInt32.subtractWithOverflow(self.code, self.range).0 - lzmaDiagPrint("decodeDirectBits_code_1: \(self.code)") let t = UInt32.subtractWithOverflow(0, self.code >> 31).0 - lzmaDiagPrint("decodeDirectBits_t: \(t)") self.code = UInt32.addWithOverflow(self.code, self.range & t).0 if self.code == self.range { - lzmaDiagPrint("???Corrupted") self.isCorrupted = true } @@ -82,9 +74,6 @@ final class LZMARangeDecoder { /// Decodes binary symbol (bit) with predicted (estimated) probability. func decode(bitWithProb prob: inout Int) -> Int { let bound = (self.range >> UInt32(LZMAConstants.numBitModelTotalBits)) * UInt32(prob) - lzmaDiagPrint("decodebit") - lzmaDiagPrint("bound: \(bound)") - lzmaDiagPrint("probBefore: \(prob)") let symbol: Int if self.code < bound { prob += ((1 << LZMAConstants.numBitModelTotalBits) - prob) >> LZMAConstants.numMoveBits @@ -96,10 +85,6 @@ final class LZMARangeDecoder { self.range -= bound symbol = 1 } - lzmaDiagPrint("probAfter: \(prob)") - lzmaDiagPrint("codeAfter: \(self.code)") - lzmaDiagPrint("rangeAfter: \(self.range)") - lzmaDiagPrint("-------------------") self.normalize() return symbol } From 29b46e75827bf7c4a017ccc6a8bae8a57db3e552 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Fri, 30 Dec 2016 23:02:58 +0300 Subject: [PATCH 04/12] Added various unsinged integer operators overloads. --- Sources/Extensions.swift | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/Sources/Extensions.swift b/Sources/Extensions.swift index fed2aea1..e8649740 100644 --- a/Sources/Extensions.swift +++ b/Sources/Extensions.swift @@ -46,3 +46,52 @@ extension Int { } } + +func +(lhs: UInt8, rhs: UInt16) -> UInt16 { + return UInt16(lhs) + rhs +} + +func +(lhs: UInt16, rhs: UInt8) -> UInt16 { + return lhs + UInt16(rhs) +} + +func +(lhs: UInt8, rhs: UInt32) -> UInt32 { + return UInt32(lhs) + rhs +} + +func +(lhs: UInt32, rhs: UInt8) -> UInt32 { + return lhs + UInt32(rhs) +} + +func +(lhs: UInt8, rhs: UInt64) -> UInt64 { + return UInt64(lhs) + rhs +} + +func +(lhs: UInt64, rhs: UInt8) -> UInt64 { + return lhs + UInt64(rhs) +} + +func +(lhs: UInt16, rhs: UInt32) -> UInt32 { + return UInt32(lhs) + rhs +} + +func +(lhs: UInt32, rhs: UInt16) -> UInt32 { + return lhs + UInt32(rhs) +} + +func +(lhs: UInt16, rhs: UInt64) -> UInt64 { + return UInt64(lhs) + rhs +} + +func +(lhs: UInt64, rhs: UInt16) -> UInt64 { + return lhs + UInt64(rhs) +} + +func +(lhs: UInt32, rhs: UInt64) -> UInt64 { + return UInt64(lhs) + rhs +} + +func +(lhs: UInt64, rhs: UInt32) -> UInt64 { + return lhs + UInt64(rhs) +} + From 1d8d0142503bb97858691631b7af4323b39394ab Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Fri, 30 Dec 2016 23:03:27 +0300 Subject: [PATCH 05/12] =?UTF-8?q?Added=20a=20couple=20of=20=E2=80=98good?= =?UTF-8?q?=20functions=E2=80=99=20to=20DWP.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/DataWithPointer.swift | 214 ++++++++++++++++++++++++++++------ 1 file changed, 179 insertions(+), 35 deletions(-) diff --git a/Sources/DataWithPointer.swift b/Sources/DataWithPointer.swift index da4de96d..a44c0c0f 100644 --- a/Sources/DataWithPointer.swift +++ b/Sources/DataWithPointer.swift @@ -13,6 +13,8 @@ enum BitOrder { case reversed } +// TODO: Replace all preconditions with guard statements. + final class DataWithPointer { let bitOrder: BitOrder @@ -47,34 +49,6 @@ final class DataWithPointer { self.init(array: &array, bitOrder: bitOrder) } - func bits(count: Int) -> [UInt8] { - guard count > 0 else { return [] } - - var array: [UInt8] = Array(repeating: 0, count: count) - for i in 0.. 0 ? 1 : 0 - - switch self.bitOrder { - case .reversed: - if self.bitMask == 128 { - self.index += 1 - self.bitMask = 1 - } else { - self.bitMask <<= 1 - } - case .straight: - if self.bitMask == 1 { - self.index += 1 - self.bitMask = 128 - } else { - self.bitMask >>= 1 - } - } - } - - return array - } - func intFromBits(count: Int) -> Int { guard count > 0 else { return 0 } @@ -135,6 +109,46 @@ final class DataWithPointer { return bit } + func intFromAlignedBytes(count: Int) -> Int { + self.skipUntilNextByte() + var result = 0 + for i in 0.. [UInt8] { + guard count > 0 else { return [] } + + var array: [UInt8] = Array(repeating: 0, count: count) + for i in 0.. 0 ? 1 : 0 + + switch self.bitOrder { + case .reversed: + if self.bitMask == 128 { + self.index += 1 + self.bitMask = 1 + } else { + self.bitMask <<= 1 + } + case .straight: + if self.bitMask == 1 { + self.index += 1 + self.bitMask = 128 + } else { + self.bitMask >>= 1 + } + } + } + + return array + } + func alignedByte() -> UInt8 { self.skipUntilNextByte() self.index += 1 @@ -151,26 +165,156 @@ final class DataWithPointer { return result } - func intFromAlignedBytes(count: Int) -> Int { + func uint64FromAlignedBytes(count: Int) -> UInt64 { + guard count > 0 else { return 0 } + precondition(count <= 8, "DWP.u64.Bytes: UInt64 cannot store more than 8 bytes.") self.skipUntilNextByte() - var result = 0 + var result: UInt64 = 0 for i in 0.. UInt64 { + func uint32FromAlignedBytes(count: Int) -> UInt32 { + guard count > 0 else { return 0 } + precondition(count <= 4, "DWP.u32.Bytes: UInt32 cannot store more than 4 bytes.") self.skipUntilNextByte() - var result: UInt64 = 0 - for i: UInt64 in 0.. UInt16 { + guard count > 0 else { return 0 } + precondition(count <= 2, "DWP.u16.Bytes: UInt64 cannot store more than 2 bytes.") + self.skipUntilNextByte() + var result: UInt16 = 0 + for i in 0.. UInt64 { + guard count > 0 else { return 0 } + precondition(count <= 64, "DWP.u64.bits: UInt64 cannot store more than 64 bits.") + + var result: UInt64 = 0 + for i in 0.. 0 ? 1 : 0 + result += (1 << power) * UInt64(bit) + + switch self.bitOrder { + case .reversed: + if self.bitMask == 128 { + self.index += 1 + self.bitMask = 1 + } else { + self.bitMask <<= 1 + } + case .straight: + if self.bitMask == 1 { + self.index += 1 + self.bitMask = 128 + } else { + self.bitMask >>= 1 + } + } + } + + return result + } + + func uint32FromBits(count: Int) -> UInt32 { + guard count > 0 else { return 0 } + precondition(count <= 32, "DWP.u32.bits: UInt32 cannot store more than 32 bits.") + + var result: UInt32 = 0 + for i in 0.. 0 ? 1 : 0 + result += (1 << power) * UInt32(bit) + + switch self.bitOrder { + case .reversed: + if self.bitMask == 128 { + self.index += 1 + self.bitMask = 1 + } else { + self.bitMask <<= 1 + } + case .straight: + if self.bitMask == 1 { + self.index += 1 + self.bitMask = 128 + } else { + self.bitMask >>= 1 + } + } + } + + return result + } + + func uint16FromBits(count: Int) -> UInt16 { + guard count > 0 else { return 0 } + precondition(count <= 64, "DWP.u16.bits: UInt16 cannot store more than 16 bits.") + + var result: UInt16 = 0 + for i in 0.. 0 ? 1 : 0 + result += (1 << power) * UInt16(bit) + + switch self.bitOrder { + case .reversed: + if self.bitMask == 128 { + self.index += 1 + self.bitMask = 1 + } else { + self.bitMask <<= 1 + } + case .straight: + if self.bitMask == 1 { + self.index += 1 + self.bitMask = 128 + } else { + self.bitMask >>= 1 + } + } + } + + return result + } + // MARK: Manipulations with index and bitShift func skipUntilNextByte() { From 21f61f19cf1212f682264eb8e600491a41d7f4c0 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Sun, 1 Jan 2017 14:39:55 +0300 Subject: [PATCH 06/12] Removed 'good functions' recently added to DWP. --- Sources/DataWithPointer.swift | 226 ++++++---------------------------- 1 file changed, 41 insertions(+), 185 deletions(-) diff --git a/Sources/DataWithPointer.swift b/Sources/DataWithPointer.swift index a44c0c0f..da4de96d 100644 --- a/Sources/DataWithPointer.swift +++ b/Sources/DataWithPointer.swift @@ -13,8 +13,6 @@ enum BitOrder { case reversed } -// TODO: Replace all preconditions with guard statements. - final class DataWithPointer { let bitOrder: BitOrder @@ -49,6 +47,34 @@ final class DataWithPointer { self.init(array: &array, bitOrder: bitOrder) } + func bits(count: Int) -> [UInt8] { + guard count > 0 else { return [] } + + var array: [UInt8] = Array(repeating: 0, count: count) + for i in 0.. 0 ? 1 : 0 + + switch self.bitOrder { + case .reversed: + if self.bitMask == 128 { + self.index += 1 + self.bitMask = 1 + } else { + self.bitMask <<= 1 + } + case .straight: + if self.bitMask == 1 { + self.index += 1 + self.bitMask = 128 + } else { + self.bitMask >>= 1 + } + } + } + + return array + } + func intFromBits(count: Int) -> Int { guard count > 0 else { return 0 } @@ -109,46 +135,6 @@ final class DataWithPointer { return bit } - func intFromAlignedBytes(count: Int) -> Int { - self.skipUntilNextByte() - var result = 0 - for i in 0.. [UInt8] { - guard count > 0 else { return [] } - - var array: [UInt8] = Array(repeating: 0, count: count) - for i in 0.. 0 ? 1 : 0 - - switch self.bitOrder { - case .reversed: - if self.bitMask == 128 { - self.index += 1 - self.bitMask = 1 - } else { - self.bitMask <<= 1 - } - case .straight: - if self.bitMask == 1 { - self.index += 1 - self.bitMask = 128 - } else { - self.bitMask >>= 1 - } - } - } - - return array - } - func alignedByte() -> UInt8 { self.skipUntilNextByte() self.index += 1 @@ -165,156 +151,26 @@ final class DataWithPointer { return result } - func uint64FromAlignedBytes(count: Int) -> UInt64 { - guard count > 0 else { return 0 } - precondition(count <= 8, "DWP.u64.Bytes: UInt64 cannot store more than 8 bytes.") + func intFromAlignedBytes(count: Int) -> Int { + self.skipUntilNextByte() + var result = 0 + for i in 0.. UInt64 { self.skipUntilNextByte() var result: UInt64 = 0 - for i in 0.. UInt32 { - guard count > 0 else { return 0 } - precondition(count <= 4, "DWP.u32.Bytes: UInt32 cannot store more than 4 bytes.") - self.skipUntilNextByte() - var result: UInt32 = 0 - for i in 0.. UInt16 { - guard count > 0 else { return 0 } - precondition(count <= 2, "DWP.u16.Bytes: UInt64 cannot store more than 2 bytes.") - self.skipUntilNextByte() - var result: UInt16 = 0 - for i in 0.. UInt64 { - guard count > 0 else { return 0 } - precondition(count <= 64, "DWP.u64.bits: UInt64 cannot store more than 64 bits.") - - var result: UInt64 = 0 - for i in 0.. 0 ? 1 : 0 - result += (1 << power) * UInt64(bit) - - switch self.bitOrder { - case .reversed: - if self.bitMask == 128 { - self.index += 1 - self.bitMask = 1 - } else { - self.bitMask <<= 1 - } - case .straight: - if self.bitMask == 1 { - self.index += 1 - self.bitMask = 128 - } else { - self.bitMask >>= 1 - } - } - } - - return result - } - - func uint32FromBits(count: Int) -> UInt32 { - guard count > 0 else { return 0 } - precondition(count <= 32, "DWP.u32.bits: UInt32 cannot store more than 32 bits.") - - var result: UInt32 = 0 - for i in 0.. 0 ? 1 : 0 - result += (1 << power) * UInt32(bit) - - switch self.bitOrder { - case .reversed: - if self.bitMask == 128 { - self.index += 1 - self.bitMask = 1 - } else { - self.bitMask <<= 1 - } - case .straight: - if self.bitMask == 1 { - self.index += 1 - self.bitMask = 128 - } else { - self.bitMask >>= 1 - } - } - } - - return result - } - - func uint16FromBits(count: Int) -> UInt16 { - guard count > 0 else { return 0 } - precondition(count <= 64, "DWP.u16.bits: UInt16 cannot store more than 16 bits.") - - var result: UInt16 = 0 - for i in 0.. 0 ? 1 : 0 - result += (1 << power) * UInt16(bit) - - switch self.bitOrder { - case .reversed: - if self.bitMask == 128 { - self.index += 1 - self.bitMask = 1 - } else { - self.bitMask <<= 1 - } - case .straight: - if self.bitMask == 1 { - self.index += 1 - self.bitMask = 128 - } else { - self.bitMask >>= 1 - } - } - } - - return result - } - // MARK: Manipulations with index and bitShift func skipUntilNextByte() { From 4183db2eef7a46b41a27b1cb6bc3d57b65ecdb96 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Sun, 1 Jan 2017 14:40:24 +0300 Subject: [PATCH 07/12] Removed recently added integer operators overloads. --- Sources/Extensions.swift | 49 ---------------------------------------- 1 file changed, 49 deletions(-) diff --git a/Sources/Extensions.swift b/Sources/Extensions.swift index e8649740..fed2aea1 100644 --- a/Sources/Extensions.swift +++ b/Sources/Extensions.swift @@ -46,52 +46,3 @@ extension Int { } } - -func +(lhs: UInt8, rhs: UInt16) -> UInt16 { - return UInt16(lhs) + rhs -} - -func +(lhs: UInt16, rhs: UInt8) -> UInt16 { - return lhs + UInt16(rhs) -} - -func +(lhs: UInt8, rhs: UInt32) -> UInt32 { - return UInt32(lhs) + rhs -} - -func +(lhs: UInt32, rhs: UInt8) -> UInt32 { - return lhs + UInt32(rhs) -} - -func +(lhs: UInt8, rhs: UInt64) -> UInt64 { - return UInt64(lhs) + rhs -} - -func +(lhs: UInt64, rhs: UInt8) -> UInt64 { - return lhs + UInt64(rhs) -} - -func +(lhs: UInt16, rhs: UInt32) -> UInt32 { - return UInt32(lhs) + rhs -} - -func +(lhs: UInt32, rhs: UInt16) -> UInt32 { - return lhs + UInt32(rhs) -} - -func +(lhs: UInt16, rhs: UInt64) -> UInt64 { - return UInt64(lhs) + rhs -} - -func +(lhs: UInt64, rhs: UInt16) -> UInt64 { - return lhs + UInt64(rhs) -} - -func +(lhs: UInt32, rhs: UInt64) -> UInt64 { - return UInt64(lhs) + rhs -} - -func +(lhs: UInt64, rhs: UInt32) -> UInt64 { - return lhs + UInt64(rhs) -} - From 33dd12aea6c5c76dc2592af2acdc5868b9f51958 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Sun, 1 Jan 2017 20:30:56 +0300 Subject: [PATCH 08/12] Simplified code for range decoder initialization. --- Sources/LZMADecoder.swift | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/Sources/LZMADecoder.swift b/Sources/LZMADecoder.swift index 3ffef17c..acc0ffae 100644 --- a/Sources/LZMADecoder.swift +++ b/Sources/LZMADecoder.swift @@ -98,24 +98,18 @@ final class LZMADecoder { self.pb = pb self.dictionarySize = dictionarySize self.uncompressedSize = uncompressedSize - - guard let rD = LZMARangeDecoder(&self.pointerData) else { - throw LZMAError.RangeDecoderInitError - } - self.rangeDecoder = rD } else { self.lc = 0 self.lp = 0 self.pb = 0 self.dictionarySize = 0 self.uncompressedSize = -1 - - self.rangeDecoder = LZMARangeDecoder() } + self.rangeDecoder = LZMARangeDecoder() + self.outWindow = LZMAOutWindow(dictSize: self.dictionarySize) - self.probabilities = Array(repeating: LZMAConstants.probInitValue, count: 2 * 192 + 4 * 12) self.literalProbs = Array(repeating: Array(repeating: LZMAConstants.probInitValue, count: 0x300), count: 1 << (lc + lp).toInt()) @@ -213,12 +207,6 @@ final class LZMADecoder { throw LZMA2Error.WrongReset } - // Apparently, we need to reinitialize RangeDecoder each time. - guard let rD = LZMARangeDecoder(&self.pointerData) else { - throw LZMAError.RangeDecoderInitError - } - self.rangeDecoder = rD - self.uncompressedSize = unpackSize out = try decodeLZMA() guard unpackSize == out.count && pointerData.index - dataStartIndex == compressedSize @@ -227,6 +215,12 @@ final class LZMADecoder { } func decodeLZMA() throws -> [UInt8] { + // First, we need to initialize Rande Decoder. + guard let rD = LZMARangeDecoder(&self.pointerData) else { + throw LZMAError.RangeDecoderInitError + } + self.rangeDecoder = rD + /// An array for storing output data var out: [UInt8] = uncompressedSize == -1 ? [] : Array(repeating: 0, count: uncompressedSize) var outIndex = uncompressedSize == -1 ? -1 : 0 From 64a1b37f1afc5988677e7e8c47c117336aeb35a8 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Sun, 1 Jan 2017 20:37:43 +0300 Subject: [PATCH 09/12] Simplified lzmaDecoder initializer. --- Sources/LZMA.swift | 23 +++++++++++++++++-- Sources/LZMA2.swift | 36 ++++++++++++++--------------- Sources/LZMADecoder.swift | 48 ++++++++------------------------------- 3 files changed, 49 insertions(+), 58 deletions(-) diff --git a/Sources/LZMA.swift b/Sources/LZMA.swift index 98e7632b..498d64b7 100644 --- a/Sources/LZMA.swift +++ b/Sources/LZMA.swift @@ -59,9 +59,28 @@ public final class LZMA: DecompressionAlgorithm { /// Object with input data which supports convenient work with bit shifts. var pointerData = DataWithPointer(data: data, bitOrder: .reversed) - let lzmaDecoder = try LZMADecoder(&pointerData) + // Firstly, we need to parse LZMA properties. + var properties = pointerData.alignedByte() + if properties >= (9 * 5 * 5) { + throw LZMAError.WrongProperties + } + /// The number of literal context bits + let lc = properties % 9 + properties /= 9 + /// The number of pos bits + let pb = properties / 5 + /// The number of literal pos bits + let lp = properties % 5 + var dictionarySize = pointerData.intFromAlignedBytes(count: 4) + dictionarySize = dictionarySize < (1 << 12) ? 1 << 12 : dictionarySize - return Data(bytes: try lzmaDecoder.decodeLZMA()) + /// Size of uncompressed data. -1 means it is unknown. + var uncompressedSize = pointerData.intFromAlignedBytes(count: 8) + uncompressedSize = Double(uncompressedSize) == pow(Double(2), Double(64)) - 1 ? -1 : uncompressedSize + + let lzmaDecoder = try LZMADecoder(&pointerData, lc, pb, lp, dictionarySize) + + return Data(bytes: try lzmaDecoder.decodeLZMA(&uncompressedSize)) } } diff --git a/Sources/LZMA2.swift b/Sources/LZMA2.swift index c7a8d2a2..27a49c30 100644 --- a/Sources/LZMA2.swift +++ b/Sources/LZMA2.swift @@ -37,23 +37,6 @@ public enum LZMA2Error: Error { /// Provides function to decompress data, which were compressed with LZMA2 public final class LZMA2: DecompressionAlgorithm { - static func dictionarySize(_ byte: UInt8) throws -> Int { - let bits = byte & 0x3F - guard byte & 0xC0 == 0 - else { throw LZMA2Error.WrongProperties } - guard bits < 40 - else { throw LZMA2Error.WrongDictionarySize } - - var dictSize: UInt32 = 0 - if bits == 40 { - dictSize = UInt32.max - } else { - dictSize = UInt32(2 | (bits.toInt() & 1)) - dictSize <<= UInt32(bits.toInt() / 2 + 11) - } - return Int(dictSize) - } - /** Decompresses `compressedData` with LZMA2 algortihm. LZMA2 is a modification of LZMA. @@ -77,7 +60,7 @@ public final class LZMA2: DecompressionAlgorithm { static func decompress(_ dictionarySize: Int, _ pointerData: inout DataWithPointer) throws -> [UInt8] { // At this point lzmaDecoder will be in a VERY bad state. - let lzmaDecoder = try LZMADecoder(&pointerData, false) + let lzmaDecoder = try LZMADecoder(&pointerData, 0, 0, 0, 0) var out: [UInt8] = [] @@ -103,4 +86,21 @@ public final class LZMA2: DecompressionAlgorithm { return out } + static func dictionarySize(_ byte: UInt8) throws -> Int { + let bits = byte & 0x3F + guard byte & 0xC0 == 0 + else { throw LZMA2Error.WrongProperties } + guard bits < 40 + else { throw LZMA2Error.WrongDictionarySize } + + var dictSize: UInt32 = 0 + if bits == 40 { + dictSize = UInt32.max + } else { + dictSize = UInt32(2 | (bits.toInt() & 1)) + dictSize <<= UInt32(bits.toInt() / 2 + 11) + } + return Int(dictSize) + } + } diff --git a/Sources/LZMADecoder.swift b/Sources/LZMADecoder.swift index acc0ffae..ee79cb79 100644 --- a/Sources/LZMADecoder.swift +++ b/Sources/LZMADecoder.swift @@ -32,7 +32,7 @@ final class LZMADecoder { private var lp: UInt8 private var pb: UInt8 private var dictionarySize: Int - private var uncompressedSize: Int +// private var uncompressedSize: Int private var outWindow: LZMAOutWindow private var rangeDecoder: LZMARangeDecoder @@ -70,41 +70,14 @@ final class LZMADecoder { /// Is used to select exact variable from 'IsRep', 'IsRepG0', 'IsRepG1æ and 'IsRepG2' arrays. private var state: Int = 0 - init(_ pointerData: inout DataWithPointer, _ initProperties: Bool = true) throws { + init(_ pointerData: inout DataWithPointer, _ lc: UInt8, _ pb: UInt8, _ lp: UInt8, + _ dictionarySize: Int) throws { self.pointerData = pointerData - // First byte contains lzma properties. - if initProperties { - var properties = pointerData.alignedByte() - if properties >= (9 * 5 * 5) { - throw LZMAError.WrongProperties - } - /// The number of literal context bits - let lc = properties % 9 - properties /= 9 - /// The number of pos bits - let pb = properties / 5 - /// The number of literal pos bits - let lp = properties % 5 - var dictionarySize = pointerData.intFromAlignedBytes(count: 4) - dictionarySize = dictionarySize < (1 << 12) ? 1 << 12 : dictionarySize - - /// Size of uncompressed data. -1 means it is unknown. - var uncompressedSize = pointerData.intFromAlignedBytes(count: 8) - uncompressedSize = Double(uncompressedSize) == pow(Double(2), Double(64)) - 1 ? -1 : uncompressedSize - - self.lc = lc - self.lp = lp - self.pb = pb - self.dictionarySize = dictionarySize - self.uncompressedSize = uncompressedSize - } else { - self.lc = 0 - self.lp = 0 - self.pb = 0 - self.dictionarySize = 0 - self.uncompressedSize = -1 - } + self.lc = lc + self.lp = lp + self.pb = pb + self.dictionarySize = dictionarySize self.rangeDecoder = LZMARangeDecoder() @@ -206,15 +179,14 @@ final class LZMADecoder { default: throw LZMA2Error.WrongReset } - - self.uncompressedSize = unpackSize - out = try decodeLZMA() + var uncompressedSize = unpackSize + out = try decodeLZMA(&uncompressedSize) guard unpackSize == out.count && pointerData.index - dataStartIndex == compressedSize else { throw LZMA2Error.WrongSizes } return out } - func decodeLZMA() throws -> [UInt8] { + func decodeLZMA(_ uncompressedSize: inout Int) throws -> [UInt8] { // First, we need to initialize Rande Decoder. guard let rD = LZMARangeDecoder(&self.pointerData) else { throw LZMAError.RangeDecoderInitError From 1a02a737b1f74b7b20abcde0900df5075bd1e95a Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Sun, 1 Jan 2017 20:45:57 +0300 Subject: [PATCH 10/12] A small restructuring. --- Sources/LZMA.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sources/LZMA.swift b/Sources/LZMA.swift index 498d64b7..d15f3354 100644 --- a/Sources/LZMA.swift +++ b/Sources/LZMA.swift @@ -59,6 +59,10 @@ public final class LZMA: DecompressionAlgorithm { /// Object with input data which supports convenient work with bit shifts. var pointerData = DataWithPointer(data: data, bitOrder: .reversed) + return Data(bytes: try decompress(&pointerData)) + } + + static func decompress(_ pointerData: inout DataWithPointer) throws -> [UInt8] { // Firstly, we need to parse LZMA properties. var properties = pointerData.alignedByte() if properties >= (9 * 5 * 5) { @@ -74,13 +78,13 @@ public final class LZMA: DecompressionAlgorithm { var dictionarySize = pointerData.intFromAlignedBytes(count: 4) dictionarySize = dictionarySize < (1 << 12) ? 1 << 12 : dictionarySize - /// Size of uncompressed data. -1 means it is unknown. + /// Size of uncompressed data. -1 means it is unknown/undefined. var uncompressedSize = pointerData.intFromAlignedBytes(count: 8) uncompressedSize = Double(uncompressedSize) == pow(Double(2), Double(64)) - 1 ? -1 : uncompressedSize let lzmaDecoder = try LZMADecoder(&pointerData, lc, pb, lp, dictionarySize) - return Data(bytes: try lzmaDecoder.decodeLZMA(&uncompressedSize)) + return try lzmaDecoder.decodeLZMA(&uncompressedSize) } } From 02e76226bf64737c4f7539c7f97bbdc982599b08 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Mon, 2 Jan 2017 15:25:13 +0300 Subject: [PATCH 11/12] Fixed incorrect reading of adler32 due to misaligned byte. --- Sources/ZlibArchive.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ZlibArchive.swift b/Sources/ZlibArchive.swift index 4fa92b03..c2b4995e 100644 --- a/Sources/ZlibArchive.swift +++ b/Sources/ZlibArchive.swift @@ -148,7 +148,7 @@ public final class ZlibArchive: Archive { let out = try Deflate.decompress(&pointerData) - let adler32 = pointerData.intFromBits(count: 32).reverseBytes() + let adler32 = pointerData.intFromAlignedBytes(count: 4).reverseBytes() guard CheckSums.adler32(out) == adler32 else { throw ZlibError.WrongAdler32(Data(bytes: out)) } return Data(bytes: out) From e91ea337ece00d045f8db191faa83ca8059eac58 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Mon, 2 Jan 2017 15:30:06 +0300 Subject: [PATCH 12/12] Preparations for 2.0.1. --- CHANGELOG.md | 6 ++++++ SWCompression.podspec | 2 +- Sources/Service/Info-iOS.plist | 2 +- Sources/Service/Info-tvOS.plist | 2 +- Sources/Service/Info-watchOS.plist | 2 +- Sources/Service/Info.plist | 2 +- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f29338e..fa04b739 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,10 @@ # Changelog +v2.0.1 +---------------- +- Fixed incorrect reading adler32 checksum from zlib archives. +- Removed LZMA_INFO and LZMA_DIAG build options. +- (2.0.0) GZip archives with multiple 'members' are now parsed correctly. + v2.0.0 ---------------- - LZMA decompression. diff --git a/SWCompression.podspec b/SWCompression.podspec index 6a00f3ac..e9139913 100644 --- a/SWCompression.podspec +++ b/SWCompression.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "SWCompression" - s.version = "2.0.0" + s.version = "2.0.1" s.summary = "Framework with implementations in Swift of different (de)compression algorithms" s.description = <<-DESC diff --git a/Sources/Service/Info-iOS.plist b/Sources/Service/Info-iOS.plist index d87c8b3c..0e27f5f6 100644 --- a/Sources/Service/Info-iOS.plist +++ b/Sources/Service/Info-iOS.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.0.0 + 2.0.1 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/Sources/Service/Info-tvOS.plist b/Sources/Service/Info-tvOS.plist index d87c8b3c..0e27f5f6 100644 --- a/Sources/Service/Info-tvOS.plist +++ b/Sources/Service/Info-tvOS.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.0.0 + 2.0.1 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/Sources/Service/Info-watchOS.plist b/Sources/Service/Info-watchOS.plist index d87c8b3c..0e27f5f6 100644 --- a/Sources/Service/Info-watchOS.plist +++ b/Sources/Service/Info-watchOS.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.0.0 + 2.0.1 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/Sources/Service/Info.plist b/Sources/Service/Info.plist index 0f0801ad..2fc261af 100644 --- a/Sources/Service/Info.plist +++ b/Sources/Service/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.0.0 + 2.0.1 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSHumanReadableCopyright