mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-06-23 14:56:41 +00:00
Add out variable to LZMA2 decoder and change dictionarySize setup
This commit is contained in:
@@ -10,13 +10,16 @@ class LZMA2Decoder {
|
||||
private let pointerData: DataWithPointer
|
||||
private let decoder: LZMATempDecoder
|
||||
|
||||
var out: [UInt8] {
|
||||
return self.decoder.out
|
||||
}
|
||||
|
||||
init(_ pointerData: DataWithPointer) throws {
|
||||
self.pointerData = pointerData
|
||||
self.decoder = try LZMATempDecoder(pointerData)
|
||||
self.decoder.dictionarySize = try LZMA2Decoder.calculateDictionarySize(self.pointerData.byte())
|
||||
}
|
||||
|
||||
private static func calculateDictionarySize(_ byte: UInt8) throws -> Int {
|
||||
func setDictionarySize(_ byte: UInt8) throws {
|
||||
let bits = byte & 0x3F
|
||||
guard byte & 0xC0 == 0
|
||||
else { throw LZMA2Error.wrongProperties }
|
||||
@@ -30,7 +33,8 @@ class LZMA2Decoder {
|
||||
dictSize = UInt32(2 | (bits.toInt() & 1))
|
||||
dictSize <<= UInt32(bits.toInt() / 2 + 11)
|
||||
}
|
||||
return Int(dictSize)
|
||||
|
||||
self.decoder.dictionarySize = Int(dictSize)
|
||||
}
|
||||
|
||||
/// Main LZMA2 decoder function.
|
||||
|
||||
Reference in New Issue
Block a user