seven-zip 1.4.2 → 1.7.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +49 -0
- data/.github/workflows/release.yml +21 -0
- data/README.md +13 -2
- data/Rakefile +2 -0
- data/ext/p7zip/C/7zBuf.h +4 -8
- data/ext/p7zip/C/7zBuf2.c +9 -3
- data/ext/p7zip/C/7zCrc.c +84 -32
- data/ext/p7zip/C/7zCrc.h +2 -2
- data/ext/p7zip/C/7zCrcOpt.c +89 -8
- data/ext/p7zip/C/7zStream.c +4 -2
- data/ext/p7zip/C/{Types.h → 7zTypes.h} +8 -6
- data/ext/p7zip/C/7zVersion.h +21 -6
- data/ext/p7zip/C/Aes.c +28 -15
- data/ext/p7zip/C/Aes.h +2 -2
- data/ext/p7zip/C/Alloc.c +60 -12
- data/ext/p7zip/C/Alloc.h +6 -7
- data/ext/p7zip/C/Bcj2.c +256 -0
- data/ext/p7zip/C/Bcj2.h +146 -0
- data/ext/p7zip/C/Bcj2Enc.c +312 -0
- data/ext/p7zip/C/Blake2.h +48 -0
- data/ext/p7zip/C/Blake2s.c +244 -0
- data/ext/p7zip/C/Bra.c +2 -0
- data/ext/p7zip/C/Bra.h +4 -8
- data/ext/p7zip/C/Bra86.c +48 -51
- data/ext/p7zip/C/BraIA64.c +3 -1
- data/ext/p7zip/C/BwtSort.c +3 -4
- data/ext/p7zip/C/BwtSort.h +4 -8
- data/ext/p7zip/C/Compiler.h +32 -0
- data/ext/p7zip/C/CpuArch.c +50 -7
- data/ext/p7zip/C/CpuArch.h +112 -41
- data/ext/p7zip/C/Delta.c +2 -0
- data/ext/p7zip/C/Delta.h +4 -8
- data/ext/p7zip/C/HuffEnc.c +8 -6
- data/ext/p7zip/C/HuffEnc.h +4 -8
- data/ext/p7zip/C/LzFind.c +391 -108
- data/ext/p7zip/C/LzFind.h +20 -18
- data/ext/p7zip/C/LzFindMt.c +100 -90
- data/ext/p7zip/C/LzFindMt.h +4 -8
- data/ext/p7zip/C/LzHash.h +23 -20
- data/ext/p7zip/C/Lzma2Dec.c +48 -26
- data/ext/p7zip/C/Lzma2Dec.h +4 -8
- data/ext/p7zip/C/Lzma2Enc.c +58 -15
- data/ext/p7zip/C/Lzma2Enc.h +3 -7
- data/ext/p7zip/C/{LzmaUtil/Lzma86Enc.h → Lzma86.h} +47 -14
- data/ext/p7zip/C/{LzmaUtil/Lzma86Dec.c → Lzma86Dec.c} +6 -13
- data/ext/p7zip/C/{LzmaUtil/Lzma86Enc.c → Lzma86Enc.c} +8 -15
- data/ext/p7zip/C/LzmaDec.c +180 -79
- data/ext/p7zip/C/LzmaDec.h +4 -8
- data/ext/p7zip/C/LzmaEnc.c +230 -147
- data/ext/p7zip/C/LzmaEnc.h +6 -8
- data/ext/p7zip/C/MtCoder.c +3 -3
- data/ext/p7zip/C/Ppmd.h +5 -5
- data/ext/p7zip/C/Ppmd7.c +9 -7
- data/ext/p7zip/C/Ppmd7.h +3 -3
- data/ext/p7zip/C/Ppmd7Dec.c +2 -0
- data/ext/p7zip/C/Ppmd7Enc.c +4 -2
- data/ext/p7zip/C/Ppmd8.c +34 -31
- data/ext/p7zip/C/Ppmd8.h +5 -1
- data/ext/p7zip/C/Ppmd8Dec.c +2 -0
- data/ext/p7zip/C/Ppmd8Enc.c +2 -0
- data/ext/p7zip/C/Precomp.h +10 -0
- data/ext/p7zip/C/RotateDefs.h +11 -1
- data/ext/p7zip/C/Sha1.c +340 -0
- data/ext/p7zip/C/Sha1.h +38 -0
- data/ext/p7zip/C/Sha256.c +107 -63
- data/ext/p7zip/C/Sha256.h +2 -2
- data/ext/p7zip/C/Sort.c +59 -11
- data/ext/p7zip/C/Sort.h +8 -10
- data/ext/p7zip/C/Threads.h +1 -1
- data/ext/p7zip/C/Xz.c +7 -5
- data/ext/p7zip/C/Xz.h +40 -17
- data/ext/p7zip/C/XzCrc64.c +69 -16
- data/ext/p7zip/C/XzCrc64.h +2 -2
- data/ext/p7zip/C/XzCrc64Opt.c +69 -0
- data/ext/p7zip/C/XzDec.c +93 -55
- data/ext/p7zip/C/XzEnc.c +206 -165
- data/ext/p7zip/C/XzEnc.h +23 -9
- data/ext/p7zip/C/XzIn.c +50 -43
- data/ext/p7zip/CPP/7zip/Archive/7z/7zCompressionMode.h +37 -13
- data/ext/p7zip/CPP/7zip/Archive/7z/7zDecode.cpp +392 -181
- data/ext/p7zip/CPP/7zip/Archive/7z/7zDecode.h +29 -29
- data/ext/p7zip/CPP/7zip/Archive/7z/7zEncode.cpp +424 -212
- data/ext/p7zip/CPP/7zip/Archive/7z/7zEncode.h +53 -16
- data/ext/p7zip/CPP/7zip/Archive/7z/7zExtract.cpp +312 -174
- data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderInStream.cpp +74 -61
- data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderInStream.h +22 -19
- data/ext/p7zip/CPP/7zip/Archive/7z/7zHandler.cpp +505 -232
- data/ext/p7zip/CPP/7zip/Archive/7z/7zHandler.h +70 -16
- data/ext/p7zip/CPP/7zip/Archive/7z/7zHandlerOut.cpp +602 -172
- data/ext/p7zip/CPP/7zip/Archive/7z/7zHeader.cpp +5 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zHeader.h +54 -3
- data/ext/p7zip/CPP/7zip/Archive/7z/7zIn.cpp +981 -616
- data/ext/p7zip/CPP/7zip/Archive/7z/7zIn.h +275 -89
- data/ext/p7zip/CPP/7zip/Archive/7z/7zItem.h +77 -162
- data/ext/p7zip/CPP/7zip/Archive/7z/7zOut.cpp +288 -238
- data/ext/p7zip/CPP/7zip/Archive/7z/7zOut.h +189 -20
- data/ext/p7zip/CPP/7zip/Archive/7z/7zProperties.cpp +59 -49
- data/ext/p7zip/CPP/7zip/Archive/7z/7zRegister.cpp +12 -9
- data/ext/p7zip/CPP/7zip/Archive/7z/7zSpecStream.cpp +4 -6
- data/ext/p7zip/CPP/7zip/Archive/7z/7zSpecStream.h +5 -5
- data/ext/p7zip/CPP/7zip/Archive/7z/7zUpdate.cpp +1743 -447
- data/ext/p7zip/CPP/7zip/Archive/7z/7zUpdate.h +61 -10
- data/ext/p7zip/CPP/7zip/Archive/ApmHandler.cpp +84 -120
- data/ext/p7zip/CPP/7zip/Archive/ArHandler.cpp +854 -0
- data/ext/p7zip/CPP/7zip/Archive/ArchiveExports.cpp +48 -32
- data/ext/p7zip/CPP/7zip/Archive/ArjHandler.cpp +519 -340
- data/ext/p7zip/CPP/7zip/Archive/Bz2Handler.cpp +223 -203
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabBlockInStream.cpp +50 -139
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabBlockInStream.h +17 -18
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabHandler.cpp +566 -234
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabHandler.h +10 -1
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabHeader.cpp +2 -2
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabHeader.h +12 -15
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabIn.cpp +341 -122
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabIn.h +81 -66
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabItem.h +17 -14
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabRegister.cpp +10 -4
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHandler.cpp +190 -83
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHandler.h +7 -1
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmIn.cpp +292 -174
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmIn.h +73 -47
- data/ext/p7zip/CPP/7zip/Archive/ComHandler.cpp +886 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2.cpp +994 -71
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2.h +364 -101
- data/ext/p7zip/CPP/7zip/Archive/Common/DummyOutStream.cpp +7 -12
- data/ext/p7zip/CPP/7zip/Archive/Common/DummyOutStream.h +4 -3
- data/ext/p7zip/CPP/7zip/Archive/Common/FindSignature.cpp +6 -6
- data/ext/p7zip/CPP/7zip/Archive/Common/FindSignature.h +2 -2
- data/ext/p7zip/CPP/7zip/Archive/Common/HandlerOut.cpp +77 -543
- data/ext/p7zip/CPP/7zip/Archive/Common/HandlerOut.h +31 -51
- data/ext/p7zip/CPP/7zip/Archive/Common/InStreamWithCRC.cpp +18 -14
- data/ext/p7zip/CPP/7zip/Archive/Common/ItemNameUtils.cpp +34 -7
- data/ext/p7zip/CPP/7zip/Archive/Common/ItemNameUtils.h +5 -2
- data/ext/p7zip/CPP/7zip/Archive/Common/MultiStream.cpp +25 -24
- data/ext/p7zip/CPP/7zip/Archive/Common/MultiStream.h +8 -3
- data/ext/p7zip/CPP/7zip/Archive/Common/OutStreamWithCRC.h +1 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/OutStreamWithSha1.cpp +2 -2
- data/ext/p7zip/CPP/7zip/Archive/Common/OutStreamWithSha1.h +5 -5
- data/ext/p7zip/CPP/7zip/Archive/Common/ParseProperties.cpp +0 -174
- data/ext/p7zip/CPP/7zip/Archive/Common/ParseProperties.h +2 -14
- data/ext/p7zip/CPP/7zip/Archive/CpioHandler.cpp +506 -335
- data/ext/p7zip/CPP/7zip/Archive/CramfsHandler.cpp +227 -84
- data/ext/p7zip/CPP/7zip/Archive/DeflateProps.cpp +0 -115
- data/ext/p7zip/CPP/7zip/Archive/DeflateProps.h +0 -29
- data/ext/p7zip/CPP/7zip/Archive/DllExports2.cpp +63 -17
- data/ext/p7zip/CPP/7zip/Archive/DmgHandler.cpp +1007 -339
- data/ext/p7zip/CPP/7zip/Archive/ElfHandler.cpp +618 -177
- data/ext/p7zip/CPP/7zip/Archive/ExtHandler.cpp +2867 -0
- data/ext/p7zip/CPP/7zip/Archive/FatHandler.cpp +136 -76
- data/ext/p7zip/CPP/7zip/Archive/FlvHandler.cpp +132 -150
- data/ext/p7zip/CPP/7zip/Archive/GptHandler.cpp +405 -0
- data/ext/p7zip/CPP/7zip/Archive/GzHandler.cpp +560 -214
- data/ext/p7zip/CPP/7zip/Archive/HandlerCont.cpp +288 -0
- data/ext/p7zip/CPP/7zip/Archive/HandlerCont.h +116 -0
- data/ext/p7zip/CPP/7zip/Archive/HfsHandler.cpp +1880 -0
- data/ext/p7zip/CPP/7zip/Archive/IArchive.h +415 -51
- data/ext/p7zip/CPP/7zip/Archive/IhexHandler.cpp +497 -0
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHandler.cpp +158 -71
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHandler.h +2 -1
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHeader.cpp +0 -9
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHeader.h +8 -5
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoIn.cpp +311 -91
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoIn.h +101 -83
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoItem.h +48 -39
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoRegister.cpp +12 -4
- data/ext/p7zip/CPP/7zip/Archive/LzhHandler.cpp +127 -114
- data/ext/p7zip/CPP/7zip/Archive/LzmaHandler.cpp +264 -121
- data/ext/p7zip/CPP/7zip/Archive/MachoHandler.cpp +402 -242
- data/ext/p7zip/CPP/7zip/Archive/MbrHandler.cpp +56 -114
- data/ext/p7zip/CPP/7zip/Archive/MslzHandler.cpp +230 -90
- data/ext/p7zip/CPP/7zip/Archive/MubHandler.cpp +129 -153
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisDecode.cpp +179 -58
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisDecode.h +36 -7
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisHandler.cpp +407 -237
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisHandler.h +9 -16
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisIn.cpp +5535 -1098
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisIn.h +345 -81
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisRegister.cpp +11 -4
- data/ext/p7zip/CPP/7zip/Archive/NtfsHandler.cpp +1424 -434
- data/ext/p7zip/CPP/7zip/Archive/PeHandler.cpp +1831 -521
- data/ext/p7zip/CPP/7zip/Archive/PpmdHandler.cpp +50 -35
- data/ext/p7zip/CPP/7zip/Archive/QcowHandler.cpp +615 -0
- data/ext/p7zip/CPP/7zip/Archive/Rar/Rar5Handler.cpp +2746 -0
- data/ext/p7zip/CPP/7zip/Archive/Rar/Rar5Handler.h +411 -0
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarHandler.cpp +1241 -355
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarHandler.h +70 -20
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarHeader.h +38 -34
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarItem.h +34 -16
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarVol.h +129 -0
- data/ext/p7zip/CPP/7zip/Archive/RpmHandler.cpp +641 -194
- data/ext/p7zip/CPP/7zip/Archive/SplitHandler.cpp +174 -181
- data/ext/p7zip/CPP/7zip/Archive/SquashfsHandler.cpp +237 -174
- data/ext/p7zip/CPP/7zip/Archive/SwfHandler.cpp +471 -192
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarHandler.cpp +350 -59
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarHandler.h +24 -7
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarHandlerOut.cpp +79 -27
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarHeader.cpp +5 -7
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarHeader.h +20 -44
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarIn.cpp +279 -64
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarIn.h +10 -1
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarItem.h +34 -8
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarOut.cpp +145 -87
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarOut.h +13 -5
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarRegister.cpp +14 -9
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarUpdate.cpp +154 -27
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarUpdate.h +10 -6
- data/ext/p7zip/CPP/7zip/Archive/Udf/UdfHandler.cpp +53 -128
- data/ext/p7zip/CPP/7zip/Archive/Udf/UdfHandler.h +6 -5
- data/ext/p7zip/CPP/7zip/Archive/Udf/UdfIn.cpp +384 -119
- data/ext/p7zip/CPP/7zip/Archive/Udf/UdfIn.h +40 -21
- data/ext/p7zip/CPP/7zip/Archive/UefiHandler.cpp +1618 -0
- data/ext/p7zip/CPP/7zip/Archive/VdiHandler.cpp +362 -0
- data/ext/p7zip/CPP/7zip/Archive/VhdHandler.cpp +438 -247
- data/ext/p7zip/CPP/7zip/Archive/VmdkHandler.cpp +1518 -0
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimHandler.cpp +837 -249
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimHandler.h +73 -47
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimHandlerOut.cpp +1614 -351
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimIn.cpp +1519 -513
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimIn.h +498 -139
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimRegister.cpp +13 -9
- data/ext/p7zip/CPP/7zip/Archive/XarHandler.cpp +272 -128
- data/ext/p7zip/CPP/7zip/Archive/XzHandler.cpp +502 -253
- data/ext/p7zip/CPP/7zip/Archive/XzHandler.h +65 -0
- data/ext/p7zip/CPP/7zip/Archive/ZHandler.cpp +114 -39
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipAddCommon.cpp +118 -134
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipAddCommon.h +6 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipCompressionMode.h +40 -20
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHandler.cpp +541 -274
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHandler.h +13 -40
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp +165 -254
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHeader.h +70 -178
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipIn.cpp +1934 -550
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipIn.h +294 -63
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipItem.cpp +160 -86
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipItem.h +139 -110
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipOut.cpp +177 -154
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipOut.h +50 -18
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipRegister.cpp +18 -9
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipUpdate.cpp +367 -201
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipUpdate.h +11 -10
- data/ext/p7zip/CPP/7zip/Bundles/Format7zFree/makefile +2 -319
- data/ext/p7zip/CPP/7zip/Bundles/Format7zFree/makefile.depend +0 -4962
- data/ext/p7zip/CPP/7zip/Bundles/Format7zFree/makefile.list +1004 -259
- data/ext/p7zip/CPP/7zip/Common/CWrappers.cpp +26 -22
- data/ext/p7zip/CPP/7zip/Common/CWrappers.h +19 -14
- data/ext/p7zip/CPP/7zip/Common/CreateCoder.cpp +298 -130
- data/ext/p7zip/CPP/7zip/Common/CreateCoder.h +118 -34
- data/ext/p7zip/CPP/7zip/Common/FilePathAutoRename.cpp +24 -28
- data/ext/p7zip/CPP/7zip/Common/FilePathAutoRename.h +5 -5
- data/ext/p7zip/CPP/7zip/Common/FileStreams.cpp +268 -65
- data/ext/p7zip/CPP/7zip/Common/FileStreams.h +70 -33
- data/ext/p7zip/CPP/7zip/Common/FilterCoder.cpp +302 -131
- data/ext/p7zip/CPP/7zip/Common/FilterCoder.h +141 -43
- data/ext/p7zip/CPP/7zip/Common/InBuffer.cpp +87 -35
- data/ext/p7zip/CPP/7zip/Common/InBuffer.h +54 -45
- data/ext/p7zip/CPP/7zip/Common/InOutTempBuffer.cpp +22 -17
- data/ext/p7zip/CPP/7zip/Common/InOutTempBuffer.h +5 -5
- data/ext/p7zip/CPP/7zip/Common/LimitedStreams.cpp +256 -43
- data/ext/p7zip/CPP/7zip/Common/LimitedStreams.h +135 -8
- data/ext/p7zip/CPP/7zip/Common/MemBlocks.cpp +5 -5
- data/ext/p7zip/CPP/7zip/Common/MemBlocks.h +3 -3
- data/ext/p7zip/CPP/7zip/Common/MethodId.cpp +0 -24
- data/ext/p7zip/CPP/7zip/Common/MethodId.h +1 -1
- data/ext/p7zip/CPP/7zip/Common/MethodProps.cpp +430 -71
- data/ext/p7zip/CPP/7zip/Common/MethodProps.h +170 -17
- data/ext/p7zip/CPP/7zip/Common/OffsetStream.cpp +8 -4
- data/ext/p7zip/CPP/7zip/Common/OffsetStream.h +4 -3
- data/ext/p7zip/CPP/7zip/Common/OutBuffer.cpp +26 -31
- data/ext/p7zip/CPP/7zip/Common/OutBuffer.h +17 -18
- data/ext/p7zip/CPP/7zip/Common/OutMemStream.cpp +5 -5
- data/ext/p7zip/CPP/7zip/Common/OutMemStream.h +5 -4
- data/ext/p7zip/CPP/7zip/Common/ProgressUtils.cpp +22 -13
- data/ext/p7zip/CPP/7zip/Common/ProgressUtils.h +4 -3
- data/ext/p7zip/CPP/7zip/Common/PropId.cpp +108 -0
- data/ext/p7zip/CPP/7zip/Common/RegisterArc.h +63 -17
- data/ext/p7zip/CPP/7zip/Common/RegisterCodec.h +79 -6
- data/ext/p7zip/CPP/7zip/Common/StreamBinder.cpp +95 -90
- data/ext/p7zip/CPP/7zip/Common/StreamBinder.h +46 -23
- data/ext/p7zip/CPP/7zip/Common/StreamObjects.cpp +88 -24
- data/ext/p7zip/CPP/7zip/Common/StreamObjects.h +36 -14
- data/ext/p7zip/CPP/7zip/Common/StreamUtils.cpp +4 -4
- data/ext/p7zip/CPP/7zip/Common/StreamUtils.h +6 -6
- data/ext/p7zip/CPP/7zip/Common/UniqBlocks.cpp +57 -0
- data/ext/p7zip/CPP/7zip/Common/UniqBlocks.h +26 -0
- data/ext/p7zip/CPP/7zip/Common/VirtThread.cpp +8 -6
- data/ext/p7zip/CPP/7zip/Common/VirtThread.h +6 -5
- data/ext/p7zip/CPP/7zip/Compress/BZip2Const.h +13 -12
- data/ext/p7zip/CPP/7zip/Compress/BZip2Crc.h +1 -1
- data/ext/p7zip/CPP/7zip/Compress/BZip2Decoder.cpp +198 -147
- data/ext/p7zip/CPP/7zip/Compress/BZip2Decoder.h +60 -27
- data/ext/p7zip/CPP/7zip/Compress/BZip2Encoder.cpp +111 -116
- data/ext/p7zip/CPP/7zip/Compress/BZip2Encoder.h +53 -59
- data/ext/p7zip/CPP/7zip/Compress/BZip2Register.cpp +12 -7
- data/ext/p7zip/CPP/7zip/Compress/Bcj2Coder.cpp +554 -282
- data/ext/p7zip/CPP/7zip/Compress/Bcj2Coder.h +73 -71
- data/ext/p7zip/CPP/7zip/Compress/Bcj2Register.cpp +10 -5
- data/ext/p7zip/CPP/7zip/Compress/BcjCoder.cpp +13 -4
- data/ext/p7zip/CPP/7zip/Compress/BcjCoder.h +17 -5
- data/ext/p7zip/CPP/7zip/Compress/BcjRegister.cpp +7 -9
- data/ext/p7zip/CPP/7zip/Compress/BitlDecoder.cpp +2 -2
- data/ext/p7zip/CPP/7zip/Compress/BitlDecoder.h +58 -61
- data/ext/p7zip/CPP/7zip/Compress/BitlEncoder.h +24 -25
- data/ext/p7zip/CPP/7zip/Compress/BitmDecoder.h +46 -17
- data/ext/p7zip/CPP/7zip/Compress/BitmEncoder.h +18 -19
- data/ext/p7zip/CPP/7zip/Compress/BranchMisc.cpp +14 -28
- data/ext/p7zip/CPP/7zip/Compress/BranchMisc.h +27 -6
- data/ext/p7zip/CPP/7zip/Compress/BranchRegister.cpp +26 -15
- data/ext/p7zip/CPP/7zip/Compress/ByteSwap.cpp +45 -26
- data/ext/p7zip/CPP/7zip/Compress/CodecExports.cpp +254 -70
- data/ext/p7zip/CPP/7zip/Compress/CopyCoder.cpp +65 -17
- data/ext/p7zip/CPP/7zip/Compress/CopyCoder.h +15 -3
- data/ext/p7zip/CPP/7zip/Compress/CopyRegister.cpp +5 -4
- data/ext/p7zip/CPP/7zip/Compress/Deflate64Register.cpp +12 -6
- data/ext/p7zip/CPP/7zip/Compress/DeflateConst.h +43 -46
- data/ext/p7zip/CPP/7zip/Compress/DeflateDecoder.cpp +145 -81
- data/ext/p7zip/CPP/7zip/Compress/DeflateDecoder.h +31 -33
- data/ext/p7zip/CPP/7zip/Compress/DeflateEncoder.cpp +179 -162
- data/ext/p7zip/CPP/7zip/Compress/DeflateEncoder.h +35 -30
- data/ext/p7zip/CPP/7zip/Compress/DeflateRegister.cpp +11 -7
- data/ext/p7zip/CPP/7zip/Compress/DeltaFilter.cpp +55 -39
- data/ext/p7zip/CPP/7zip/Compress/{DllExports2.cpp → DllExports2Compress.cpp} +8 -8
- data/ext/p7zip/CPP/7zip/Compress/DllExportsCompress.cpp +48 -0
- data/ext/p7zip/CPP/7zip/Compress/HuffmanDecoder.h +220 -49
- data/ext/p7zip/CPP/7zip/Compress/ImplodeDecoder.cpp +14 -9
- data/ext/p7zip/CPP/7zip/Compress/ImplodeDecoder.h +2 -3
- data/ext/p7zip/CPP/7zip/Compress/ImplodeHuffmanDecoder.cpp +7 -7
- data/ext/p7zip/CPP/7zip/Compress/ImplodeHuffmanDecoder.h +1 -1
- data/ext/p7zip/CPP/7zip/Compress/LzOutWindow.cpp +1 -1
- data/ext/p7zip/CPP/7zip/Compress/LzOutWindow.h +21 -18
- data/ext/p7zip/CPP/7zip/Compress/LzhDecoder.cpp +171 -141
- data/ext/p7zip/CPP/7zip/Compress/LzhDecoder.h +32 -64
- data/ext/p7zip/CPP/7zip/Compress/Lzham/LICENSE +22 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/LzhamRegister.cpp +783 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/README.md +211 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/include/lzham.h +803 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/include/lzham_dynamic_lib.h +156 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/include/lzham_exports.inc +31 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/include/lzham_static_lib.h +59 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/include/zlib.h +2 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/CMakeLists.txt +69 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_comp.h +38 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzbase.cpp +244 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzbase.h +46 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzcomp.cpp +750 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzcomp_internal.cpp +2240 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzcomp_internal.h +503 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzcomp_state.cpp +1684 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_match_accel.cpp +947 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_match_accel.h +164 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_null_threading.h +98 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_pthreads_threading.cpp +214 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_pthreads_threading.h +535 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_threading.h +12 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_win32_threading.cpp +232 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_win32_threading.h +387 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzhamcomp.vcxproj +208 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/CMakeLists.txt +86 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_assert.cpp +80 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_assert.h +58 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_checksum.cpp +73 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_checksum.h +13 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_config.h +25 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_core.h +303 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_decomp.h +37 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_helpers.h +54 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_huffman_codes.cpp +286 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_huffman_codes.h +32 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_lzdecomp.cpp +1586 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_lzdecompbase.cpp +131 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_lzdecompbase.h +89 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_math.h +142 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_mem.cpp +463 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_mem.h +115 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_platform.cpp +159 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_platform.h +284 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_prefix_coding.cpp +431 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_prefix_coding.h +157 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_symbol_codec.cpp +1527 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_symbol_codec.h +494 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_timer.cpp +147 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_timer.h +99 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_traits.h +141 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_types.h +72 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_utils.h +58 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_vector.cpp +83 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_vector.h +628 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzhamdecomp.vcxproj +224 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamlib/lzham_lib.cpp +179 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamlib/lzhamlib.vcxproj +187 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/makefile +10 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/makefile.depend +0 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/makefile.list +129 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzma2Decoder.cpp +123 -46
- data/ext/p7zip/CPP/7zip/Compress/Lzma2Decoder.h +29 -14
- data/ext/p7zip/CPP/7zip/Compress/Lzma2Encoder.cpp +14 -9
- data/ext/p7zip/CPP/7zip/Compress/Lzma2Encoder.h +1 -1
- data/ext/p7zip/CPP/7zip/Compress/Lzma2Register.cpp +9 -7
- data/ext/p7zip/CPP/7zip/Compress/LzmaDecoder.cpp +24 -8
- data/ext/p7zip/CPP/7zip/Compress/LzmaDecoder.h +8 -1
- data/ext/p7zip/CPP/7zip/Compress/LzmaEncoder.cpp +30 -27
- data/ext/p7zip/CPP/7zip/Compress/LzmaEncoder.h +3 -1
- data/ext/p7zip/CPP/7zip/Compress/LzmaRegister.cpp +9 -7
- data/ext/p7zip/CPP/7zip/Compress/LzmsDecoder.cpp +576 -0
- data/ext/p7zip/CPP/7zip/Compress/LzmsDecoder.h +271 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzx.h +32 -36
- data/ext/p7zip/CPP/7zip/Compress/LzxDecoder.cpp +380 -238
- data/ext/p7zip/CPP/7zip/Compress/LzxDecoder.h +170 -83
- data/ext/p7zip/CPP/7zip/Compress/Mtf8.h +7 -9
- data/ext/p7zip/CPP/7zip/Compress/PpmdDecoder.cpp +1 -5
- data/ext/p7zip/CPP/7zip/Compress/PpmdEncoder.cpp +51 -18
- data/ext/p7zip/CPP/7zip/Compress/PpmdEncoder.h +18 -8
- data/ext/p7zip/CPP/7zip/Compress/PpmdRegister.cpp +9 -8
- data/ext/p7zip/CPP/7zip/Compress/PpmdZip.cpp +61 -25
- data/ext/p7zip/CPP/7zip/Compress/PpmdZip.h +21 -6
- data/ext/p7zip/CPP/7zip/Compress/QuantumDecoder.cpp +122 -102
- data/ext/p7zip/CPP/7zip/Compress/QuantumDecoder.h +68 -157
- data/ext/p7zip/CPP/7zip/Compress/Rar/makefile +33 -18
- data/ext/p7zip/CPP/7zip/Compress/Rar/makefile.depend +0 -158
- data/ext/p7zip/CPP/7zip/Compress/Rar/makefile.list +105 -56
- data/ext/p7zip/CPP/7zip/Compress/Rar1Decoder.cpp +34 -21
- data/ext/p7zip/CPP/7zip/Compress/Rar1Decoder.h +2 -0
- data/ext/p7zip/CPP/7zip/Compress/Rar2Decoder.cpp +77 -67
- data/ext/p7zip/CPP/7zip/Compress/Rar2Decoder.h +12 -10
- data/ext/p7zip/CPP/7zip/Compress/Rar3Decoder.cpp +139 -118
- data/ext/p7zip/CPP/7zip/Compress/Rar3Decoder.h +48 -33
- data/ext/p7zip/CPP/7zip/Compress/Rar3Vm.cpp +148 -113
- data/ext/p7zip/CPP/7zip/Compress/Rar3Vm.h +35 -19
- data/ext/p7zip/CPP/7zip/Compress/Rar5Decoder.cpp +961 -0
- data/ext/p7zip/CPP/7zip/Compress/Rar5Decoder.h +335 -0
- data/ext/p7zip/CPP/7zip/Compress/RarCodecsRegister.cpp +13 -6
- data/ext/p7zip/CPP/7zip/Compress/ShrinkDecoder.cpp +91 -71
- data/ext/p7zip/CPP/7zip/Compress/ShrinkDecoder.h +2 -4
- data/ext/p7zip/CPP/7zip/Compress/XpressDecoder.cpp +129 -0
- data/ext/p7zip/CPP/7zip/Compress/XpressDecoder.h +13 -0
- data/ext/p7zip/CPP/7zip/Compress/ZDecoder.cpp +98 -20
- data/ext/p7zip/CPP/7zip/Compress/ZDecoder.h +19 -7
- data/ext/p7zip/CPP/7zip/Compress/ZlibDecoder.cpp +14 -11
- data/ext/p7zip/CPP/7zip/Compress/ZlibDecoder.h +32 -1
- data/ext/p7zip/CPP/7zip/Crypto/7zAes.cpp +137 -101
- data/ext/p7zip/CPP/7zip/Crypto/7zAes.h +31 -30
- data/ext/p7zip/CPP/7zip/Crypto/7zAesRegister.cpp +8 -9
- data/ext/p7zip/CPP/7zip/Crypto/HmacSha1.cpp +39 -28
- data/ext/p7zip/CPP/7zip/Crypto/HmacSha1.h +3 -3
- data/ext/p7zip/CPP/7zip/Crypto/HmacSha256.cpp +62 -0
- data/ext/p7zip/CPP/7zip/Crypto/HmacSha256.h +27 -0
- data/ext/p7zip/CPP/7zip/Crypto/MyAes.cpp +73 -7
- data/ext/p7zip/CPP/7zip/Crypto/MyAes.h +25 -8
- data/ext/p7zip/CPP/7zip/Crypto/MyAesReg.cpp +16 -0
- data/ext/p7zip/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp +29 -15
- data/ext/p7zip/CPP/7zip/Crypto/Pbkdf2HmacSha1.h +2 -1
- data/ext/p7zip/CPP/7zip/Crypto/RandGen.cpp +49 -34
- data/ext/p7zip/CPP/7zip/Crypto/RandGen.h +2 -2
- data/ext/p7zip/CPP/7zip/Crypto/Rar20Crypto.cpp +36 -39
- data/ext/p7zip/CPP/7zip/Crypto/Rar20Crypto.h +15 -17
- data/ext/p7zip/CPP/7zip/Crypto/Rar5Aes.cpp +257 -0
- data/ext/p7zip/CPP/7zip/Crypto/Rar5Aes.h +84 -0
- data/ext/p7zip/CPP/7zip/Crypto/RarAes.cpp +70 -71
- data/ext/p7zip/CPP/7zip/Crypto/RarAes.h +24 -19
- data/ext/p7zip/CPP/7zip/Crypto/Sha1Cls.h +51 -0
- data/ext/p7zip/CPP/7zip/Crypto/WzAes.cpp +68 -54
- data/ext/p7zip/CPP/7zip/Crypto/WzAes.h +37 -27
- data/ext/p7zip/CPP/7zip/Crypto/ZipCrypto.cpp +60 -34
- data/ext/p7zip/CPP/7zip/Crypto/ZipCrypto.h +28 -11
- data/ext/p7zip/CPP/7zip/Crypto/ZipStrong.cpp +90 -28
- data/ext/p7zip/CPP/7zip/Crypto/ZipStrong.h +13 -2
- data/ext/p7zip/CPP/7zip/Guid.txt +57 -11
- data/ext/p7zip/CPP/7zip/ICoder.h +202 -17
- data/ext/p7zip/CPP/7zip/IDecl.h +16 -3
- data/ext/p7zip/CPP/7zip/IPassword.h +1 -2
- data/ext/p7zip/CPP/7zip/IProgress.h +2 -16
- data/ext/p7zip/CPP/7zip/IStream.h +82 -13
- data/ext/p7zip/CPP/7zip/MyVersion.h +2 -11
- data/ext/p7zip/CPP/7zip/PropID.h +60 -9
- data/ext/p7zip/CPP/Common/C_FileIO.cpp +5 -1
- data/ext/p7zip/CPP/Common/C_FileIO.h +7 -1
- data/ext/p7zip/CPP/Common/CommandLineParser.cpp +122 -148
- data/ext/p7zip/CPP/Common/CommandLineParser.h +20 -29
- data/ext/p7zip/CPP/Common/Common.h +13 -0
- data/ext/p7zip/CPP/Common/CrcReg.cpp +98 -0
- data/ext/p7zip/CPP/Common/Defs.h +5 -10
- data/ext/p7zip/CPP/Common/DynLimBuf.cpp +93 -0
- data/ext/p7zip/CPP/Common/DynLimBuf.h +40 -0
- data/ext/p7zip/CPP/Common/DynamicBuffer.h +45 -31
- data/ext/p7zip/CPP/Common/IntToString.cpp +109 -40
- data/ext/p7zip/CPP/Common/IntToString.h +14 -9
- data/ext/p7zip/CPP/Common/Lang.cpp +120 -87
- data/ext/p7zip/CPP/Common/Lang.h +10 -15
- data/ext/p7zip/CPP/Common/ListFileUtils.cpp +82 -40
- data/ext/p7zip/CPP/Common/ListFileUtils.h +7 -4
- data/ext/p7zip/CPP/Common/MyBuffer.h +244 -0
- data/ext/p7zip/CPP/Common/MyCom.h +65 -28
- data/ext/p7zip/CPP/Common/MyGuidDef.h +1 -1
- data/ext/p7zip/CPP/Common/MyInitGuid.h +23 -0
- data/ext/p7zip/CPP/Common/MyLinux.h +42 -0
- data/ext/p7zip/CPP/Common/MyMap.cpp +8 -8
- data/ext/p7zip/CPP/Common/MyMap.h +2 -2
- data/ext/p7zip/CPP/Common/MyString.cpp +1643 -117
- data/ext/p7zip/CPP/Common/MyString.h +677 -486
- data/ext/p7zip/CPP/Common/MyTypes.h +38 -0
- data/ext/p7zip/CPP/Common/MyUnknown.h +4 -0
- data/ext/p7zip/CPP/Common/MyVector.cpp +0 -84
- data/ext/p7zip/CPP/Common/MyVector.h +472 -112
- data/ext/p7zip/CPP/Common/MyWindows.cpp +18 -1
- data/ext/p7zip/CPP/Common/MyWindows.h +8 -0
- data/ext/p7zip/CPP/Common/MyXml.cpp +169 -118
- data/ext/p7zip/CPP/Common/MyXml.h +14 -11
- data/ext/p7zip/CPP/Common/NewHandler.cpp +39 -0
- data/ext/p7zip/CPP/Common/NewHandler.h +55 -2
- data/ext/p7zip/CPP/Common/Random.h +14 -0
- data/ext/p7zip/CPP/Common/Sha1Reg.cpp +40 -0
- data/ext/p7zip/CPP/Common/Sha256Reg.cpp +40 -0
- data/ext/p7zip/CPP/Common/StdInStream.cpp +46 -27
- data/ext/p7zip/CPP/Common/StdInStream.h +11 -10
- data/ext/p7zip/CPP/Common/StdOutStream.cpp +48 -35
- data/ext/p7zip/CPP/Common/StdOutStream.h +44 -17
- data/ext/p7zip/CPP/Common/StringConvert.cpp +56 -17
- data/ext/p7zip/CPP/Common/StringConvert.h +7 -3
- data/ext/p7zip/CPP/Common/StringToInt.cpp +102 -48
- data/ext/p7zip/CPP/Common/StringToInt.h +13 -10
- data/ext/p7zip/CPP/Common/TextConfig.cpp +33 -47
- data/ext/p7zip/CPP/Common/TextConfig.h +3 -6
- data/ext/p7zip/CPP/Common/UTFConvert.cpp +218 -75
- data/ext/p7zip/CPP/Common/UTFConvert.h +4 -3
- data/ext/p7zip/CPP/Common/Wildcard.cpp +345 -125
- data/ext/p7zip/CPP/Common/Wildcard.h +82 -13
- data/ext/p7zip/CPP/Common/XzCrc64Reg.cpp +42 -0
- data/ext/p7zip/CPP/Windows/FileDir.cpp +427 -475
- data/ext/p7zip/CPP/Windows/FileDir.h +94 -72
- data/ext/p7zip/CPP/Windows/FileFind.cpp +235 -244
- data/ext/p7zip/CPP/Windows/FileFind.h +63 -59
- data/ext/p7zip/CPP/Windows/FileIO.cpp +29 -46
- data/ext/p7zip/CPP/Windows/FileIO.h +40 -42
- data/ext/p7zip/CPP/Windows/FileName.cpp +696 -17
- data/ext/p7zip/CPP/Windows/FileName.h +11 -3
- data/ext/p7zip/CPP/Windows/NtCheck.h +2 -0
- data/ext/p7zip/CPP/Windows/PropVariant.cpp +134 -30
- data/ext/p7zip/CPP/Windows/PropVariant.h +80 -24
- data/ext/p7zip/CPP/Windows/PropVariantUtils.cpp +89 -18
- data/ext/p7zip/CPP/Windows/PropVariantUtils.h +12 -7
- data/ext/p7zip/CPP/Windows/System.cpp +20 -15
- data/ext/p7zip/CPP/Windows/System.h +3 -2
- data/ext/p7zip/CPP/Windows/TimeUtils.cpp +203 -0
- data/ext/p7zip/CPP/Windows/TimeUtils.h +24 -0
- data/ext/p7zip/CPP/include_windows/basetyps.h +4 -4
- data/ext/p7zip/CPP/include_windows/windows.h +17 -11
- data/ext/p7zip/CPP/myWindows/StdAfx.h +97 -5
- data/ext/p7zip/CPP/myWindows/config.h +20 -5
- data/ext/p7zip/CPP/myWindows/myPrivate.h +8 -0
- data/ext/p7zip/CPP/myWindows/wine_date_and_time.cpp +34 -0
- data/ext/p7zip/ChangeLog +283 -35
- data/ext/p7zip/{DOCS → DOC}/7zC.txt +6 -13
- data/ext/p7zip/{DOCS → DOC}/License.txt +3 -2
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/add.htm +93 -87
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/bench.htm +88 -79
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/delete.htm +62 -59
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/extract.htm +96 -91
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/extract_full.htm +73 -68
- data/ext/p7zip/DOC/MANUAL/cmdline/commands/hash.htm +65 -0
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/index.htm +36 -33
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/list.htm +78 -77
- data/ext/p7zip/DOC/MANUAL/cmdline/commands/rename.htm +51 -0
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/style.css +232 -232
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/test.htm +47 -46
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/update.htm +71 -66
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/exit_codes.htm +27 -27
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/index.htm +29 -29
- data/ext/p7zip/{DOCS/MANUAL/switches → DOC/MANUAL/cmdline}/style.css +232 -232
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/ar_exclude.htm +56 -56
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/ar_include.htm +80 -83
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/ar_no.htm +52 -52
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/bb.htm +61 -0
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/bs.htm +67 -0
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/charset.htm +61 -0
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/exclude.htm +71 -60
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/include.htm +89 -87
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/index.htm +95 -64
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/large_pages.htm +59 -50
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/list_tech.htm +36 -36
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/method.htm +738 -625
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/output_dir.htm +53 -53
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/overwrite.htm +56 -56
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/password.htm +55 -54
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/recurse.htm +85 -83
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/sa.htm +58 -0
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/scc.htm +42 -0
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/scrc.htm +53 -0
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/sdel.htm +39 -0
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/sfx.htm +153 -156
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/shared.htm +40 -0
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/sni.htm +56 -0
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/sns.htm +77 -0
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/spf.htm +80 -0
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/ssc.htm +50 -50
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/stdin.htm +56 -55
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/stdout.htm +54 -50
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/stl.htm +39 -0
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/stop_switch.htm +31 -31
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/stx.htm +50 -0
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline/switches}/style.css +232 -232
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/type.htm +121 -83
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/update.htm +177 -176
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/volume.htm +49 -49
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/working_dir.htm +56 -55
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/yes.htm +48 -48
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/syntax.htm +120 -120
- data/ext/p7zip/DOC/MANUAL/fm/about.htm +21 -0
- data/ext/p7zip/DOC/MANUAL/fm/benchmark.htm +56 -0
- data/ext/p7zip/DOC/MANUAL/fm/index.htm +54 -0
- data/ext/p7zip/DOC/MANUAL/fm/menu.htm +154 -0
- data/ext/p7zip/DOC/MANUAL/fm/options.htm +152 -0
- data/ext/p7zip/DOC/MANUAL/fm/plugins/7-zip/add.htm +311 -0
- data/ext/p7zip/DOC/MANUAL/fm/plugins/7-zip/extract.htm +78 -0
- data/ext/p7zip/DOC/MANUAL/fm/plugins/7-zip/index.htm +63 -0
- data/ext/p7zip/DOC/MANUAL/fm/plugins/7-zip/style.css +232 -0
- data/ext/p7zip/DOC/MANUAL/fm/plugins/index.htm +22 -0
- data/ext/p7zip/DOC/MANUAL/fm/plugins/style.css +232 -0
- data/ext/p7zip/DOC/MANUAL/fm/style.css +232 -0
- data/ext/p7zip/DOC/MANUAL/general/7z.htm +117 -0
- data/ext/p7zip/DOC/MANUAL/general/faq.htm +125 -0
- data/ext/p7zip/DOC/MANUAL/general/formats.htm +100 -0
- data/ext/p7zip/DOC/MANUAL/general/index.htm +27 -0
- data/ext/p7zip/DOC/MANUAL/general/license.htm +30 -0
- data/ext/p7zip/DOC/MANUAL/general/performance.htm +98 -0
- data/ext/p7zip/DOC/MANUAL/general/style.css +232 -0
- data/ext/p7zip/DOC/MANUAL/general/thanks.htm +43 -0
- data/ext/p7zip/DOC/MANUAL/start.htm +37 -0
- data/ext/p7zip/DOC/MANUAL/style.css +232 -0
- data/ext/p7zip/DOC/Methods.txt +158 -0
- data/ext/p7zip/{DOCS → DOC}/copying.txt +9 -11
- data/ext/p7zip/DOC/lzma.txt +328 -0
- data/ext/p7zip/{DOCS → DOC}/readme.txt +42 -65
- data/ext/p7zip/{DOCS/history.txt → DOC/src-history.txt} +88 -2
- data/ext/p7zip/README +117 -91
- data/ext/p7zip/TODO +0 -2
- data/ext/p7zip/install.sh +31 -29
- data/ext/p7zip/last_error +1 -0
- data/ext/p7zip/makefile +29 -125
- data/ext/p7zip/makefile.afl +23 -0
- data/ext/p7zip/makefile.aix_gcc +5 -4
- data/ext/p7zip/makefile.android_arm +49 -0
- data/ext/p7zip/makefile.beos +5 -4
- data/ext/p7zip/makefile.common +150 -0
- data/ext/p7zip/makefile.crc32 +3 -3
- data/ext/p7zip/makefile.cygwin +5 -4
- data/ext/p7zip/makefile.cygwin64 +21 -0
- data/ext/p7zip/makefile.cygwin64_asm +22 -0
- data/ext/p7zip/makefile.cygwin_asm +6 -4
- data/ext/p7zip/makefile.cygwin_clang +21 -0
- data/ext/p7zip/makefile.cygwin_clang_asm +23 -0
- data/ext/p7zip/{makefile.djgpp_old → makefile.djgpp} +5 -4
- data/ext/p7zip/makefile.djgpp_watt +7 -5
- data/ext/p7zip/makefile.freebsd5 +5 -4
- data/ext/p7zip/{makefile.freebsd6 → makefile.freebsd6+} +6 -5
- data/ext/p7zip/makefile.glb +27 -18
- data/ext/p7zip/makefile.gprof +3 -2
- data/ext/p7zip/makefile.haiku +19 -0
- data/ext/p7zip/makefile.hpux-acc +3 -2
- data/ext/p7zip/makefile.hpux-acc_64 +3 -2
- data/ext/p7zip/makefile.hpux-gcc +5 -4
- data/ext/p7zip/makefile.linux_amd64 +5 -4
- data/ext/p7zip/makefile.linux_amd64_asm +12 -5
- data/ext/p7zip/makefile.linux_amd64_asm_icc +5 -3
- data/ext/p7zip/makefile.linux_amd64_sanitizer +26 -0
- data/ext/p7zip/makefile.linux_any_cpu +5 -4
- data/ext/p7zip/makefile.linux_any_cpu_gcc_4.X +7 -4
- data/ext/p7zip/makefile.linux_clang_amd64_asm +25 -0
- data/ext/p7zip/makefile.linux_clang_amd64_asm_sanitize +27 -0
- data/ext/p7zip/makefile.linux_cross_aarch64 +25 -0
- data/ext/p7zip/makefile.linux_cross_arm +7 -4
- data/ext/p7zip/makefile.linux_cross_djgpp +27 -0
- data/ext/p7zip/makefile.linux_cross_m68k +26 -0
- data/ext/p7zip/makefile.linux_cross_mipsel +27 -0
- data/ext/p7zip/makefile.linux_cross_ppc +25 -0
- data/ext/p7zip/makefile.linux_cross_ppc64 +25 -0
- data/ext/p7zip/makefile.linux_cross_ppc64le +25 -0
- data/ext/p7zip/makefile.linux_cross_s390x +25 -0
- data/ext/p7zip/makefile.linux_cross_sparc64 +25 -0
- data/ext/p7zip/makefile.linux_gcc6_sanitize +23 -0
- data/ext/p7zip/makefile.linux_gcc_2.95_no_need_for_libstdc +6 -4
- data/ext/p7zip/makefile.linux_other +6 -5
- data/ext/p7zip/makefile.linux_s390x +5 -4
- data/ext/p7zip/{makefile.machine_base → makefile.linux_scan-build} +5 -4
- data/ext/p7zip/makefile.linux_valgrind +25 -0
- data/ext/p7zip/{makefile.linux_clang_amd64 → makefile.linux_x32} +6 -5
- data/ext/p7zip/makefile.linux_x86_asm_gcc_4.X +10 -5
- data/ext/p7zip/makefile.linux_x86_asm_gcc_4.X_fltk +8 -4
- data/ext/p7zip/makefile.linux_x86_asm_gcc_mudflap_4.X +4 -2
- data/ext/p7zip/makefile.linux_x86_asm_icc +4 -2
- data/ext/p7zip/makefile.linux_x86_icc +3 -2
- data/ext/p7zip/makefile.macosx_arm64 +17 -0
- data/ext/p7zip/{makefile.macosx_32bits → makefile.macosx_gcc_32bits} +3 -2
- data/ext/p7zip/{makefile.macosx_32bits_asm → makefile.macosx_gcc_32bits_asm} +5 -3
- data/ext/p7zip/{makefile.macosx_32bits_ppc → makefile.macosx_gcc_32bits_ppc} +3 -2
- data/ext/p7zip/{makefile.macosx_64bits → makefile.macosx_gcc_64bits} +3 -2
- data/ext/p7zip/makefile.macosx_llvm_64bits +9 -3
- data/ext/p7zip/makefile.netbsd +5 -4
- data/ext/p7zip/makefile.netware_asm_gcc_3.X +6 -4
- data/ext/p7zip/makefile.oldmake +41 -130
- data/ext/p7zip/makefile.openbsd +7 -3
- data/ext/p7zip/makefile.openbsd_no_port +9 -5
- data/ext/p7zip/makefile.qnx_shared.bin +5 -4
- data/ext/p7zip/makefile.qnx_static +5 -4
- data/ext/p7zip/makefile.solaris_sparc_CC_32 +5 -4
- data/ext/p7zip/makefile.solaris_sparc_CC_64 +6 -4
- data/ext/p7zip/makefile.solaris_sparc_gcc +7 -6
- data/ext/p7zip/makefile.solaris_x86 +5 -4
- data/ext/p7zip/makefile.tru64 +5 -4
- data/ext/seven_zip_ruby/extconf.rb +92 -6
- data/ext/seven_zip_ruby/seven_zip_archive.cpp +40 -17
- data/ext/seven_zip_ruby/seven_zip_archive.h +1 -1
- data/ext/seven_zip_ruby/utils.cpp +267 -124
- data/ext/seven_zip_ruby/utils.h +2 -0
- data/lib/seven_zip_ruby/7z.dll +0 -0
- data/lib/seven_zip_ruby/7z.sfx +0 -0
- data/lib/seven_zip_ruby/7z64.dll +0 -0
- data/lib/seven_zip_ruby/7zCon.sfx +0 -0
- data/lib/seven_zip_ruby/seven_zip_reader.rb +16 -1
- data/lib/seven_zip_ruby/version.rb +1 -1
- data/p7zip/.gitignore +7 -0
- data/p7zip/README.txt +29 -0
- data/p7zip/extract.sh +134 -0
- data/spec/seven_zip_ruby_spec.rb +22 -13
- data/test/res/The Flying Spaghetti Monster.txt +3 -0
- data/test/res/The Three Little Pigs.txt +5 -0
- data/test/res/UTF_content.txt +3 -0
- data/test/res/test_reader_data.7z +0 -0
- data/test/res/test_reader_filename_cp932.7z +0 -0
- data/test/res/test_reader_files.7z +0 -0
- data/test/test_seven_zip_reader.rb +187 -0
- data/test/test_seven_zip_writer.rb +184 -0
- metadata +267 -219
- data/.github/workflows/test-and-release.yml +0 -43
- data/ext/C/Types.h +0 -254
- data/ext/CPP/7zip/Archive/IArchive.h +0 -234
- data/ext/CPP/7zip/IDecl.h +0 -15
- data/ext/CPP/7zip/IPassword.h +0 -24
- data/ext/CPP/7zip/IProgress.h +0 -33
- data/ext/CPP/7zip/IStream.h +0 -58
- data/ext/CPP/7zip/PropID.h +0 -76
- data/ext/CPP/Common/MyCom.h +0 -225
- data/ext/CPP/Common/MyGuidDef.h +0 -54
- data/ext/CPP/Common/MyInitGuid.h +0 -22
- data/ext/CPP/Common/MyUnknown.h +0 -13
- data/ext/CPP/Common/MyWindows.h +0 -204
- data/ext/CPP/Common/Types.h +0 -11
- data/ext/CPP/Windows/PropVariant.h +0 -56
- data/ext/CPP/include_windows/basetyps.h +0 -19
- data/ext/CPP/include_windows/tchar.h +0 -89
- data/ext/CPP/include_windows/windows.h +0 -194
- data/ext/p7zip/Asm/x64/7zCrcT8U.asm +0 -103
- data/ext/p7zip/Asm/x86/7zCrcT8U.asm +0 -101
- data/ext/p7zip/C/7zCrcT8.c +0 -43
- data/ext/p7zip/C/Alloc.back3 +0 -238
- data/ext/p7zip/C/Alloc.c.back +0 -243
- data/ext/p7zip/C/Alloc.c.back2 +0 -222
- data/ext/p7zip/C/LzmaUtil/Lzma86Dec.h +0 -51
- data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderOutStream.cpp +0 -149
- data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderOutStream.h +0 -58
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHeader.cpp +0 -24
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHeader.h +0 -28
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmRegister.cpp +0 -13
- data/ext/p7zip/CPP/7zip/Archive/Com/ComHandler.cpp +0 -239
- data/ext/p7zip/CPP/7zip/Archive/Com/ComHandler.h +0 -28
- data/ext/p7zip/CPP/7zip/Archive/Com/ComIn.cpp +0 -389
- data/ext/p7zip/CPP/7zip/Archive/Com/ComIn.h +0 -119
- data/ext/p7zip/CPP/7zip/Archive/Com/ComRegister.cpp +0 -13
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2MT.cpp +0 -240
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2MT.h +0 -80
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2ST.cpp +0 -239
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2ST.h +0 -88
- data/ext/p7zip/CPP/7zip/Archive/Common/CrossThreadProgress.cpp +0 -15
- data/ext/p7zip/CPP/7zip/Archive/Common/CrossThreadProgress.h +0 -37
- data/ext/p7zip/CPP/7zip/Archive/DebHandler.cpp +0 -413
- data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsHandler.cpp +0 -243
- data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsHandler.h +0 -26
- data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsIn.cpp +0 -480
- data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsIn.h +0 -154
- data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsRegister.cpp +0 -13
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarHeader.cpp +0 -21
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarIn.cpp +0 -478
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarIn.h +0 -123
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarItem.cpp +0 -55
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarRegister.cpp +0 -13
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp +0 -78
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarVolumeInStream.h +0 -49
- data/ext/p7zip/CPP/7zip/Archive/Udf/UdfRegister.cpp +0 -13
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHeader.cpp +0 -36
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipItemEx.h +0 -34
- data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_7zFM.txt +0 -163
- data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_7zG.txt +0 -131
- data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_7za.txt +0 -253
- data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_ALL.txt +0 -32
- data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_Format7zFree.txt +0 -290
- data/ext/p7zip/CPP/7zip/CMAKE/generate.sh +0 -37
- data/ext/p7zip/CPP/7zip/CMAKE/generate_xcode.sh +0 -32
- data/ext/p7zip/CPP/7zip/Common/LockedStream.cpp +0 -23
- data/ext/p7zip/CPP/7zip/Common/LockedStream.h +0 -38
- data/ext/p7zip/CPP/7zip/Compress/ArjDecoder1.cpp +0 -309
- data/ext/p7zip/CPP/7zip/Compress/ArjDecoder1.h +0 -98
- data/ext/p7zip/CPP/7zip/Compress/ArjDecoder2.cpp +0 -90
- data/ext/p7zip/CPP/7zip/Compress/ArjDecoder2.h +0 -59
- data/ext/p7zip/CPP/7zip/Compress/BranchCoder.cpp +0 -19
- data/ext/p7zip/CPP/7zip/Compress/BranchCoder.h +0 -44
- data/ext/p7zip/CPP/7zip/Compress/DllExports.cpp +0 -39
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp +0 -531
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp +0 -1018
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBench.h +0 -48
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp +0 -311
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.h +0 -20
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/makefile +0 -173
- data/ext/p7zip/CPP/7zip/Compress/Lzx86Converter.cpp +0 -90
- data/ext/p7zip/CPP/7zip/Compress/Lzx86Converter.h +0 -46
- data/ext/p7zip/CPP/7zip/Compress/RangeCoder.h +0 -205
- data/ext/p7zip/CPP/7zip/Compress/RangeCoderBit.h +0 -114
- data/ext/p7zip/CPP/7zip/Crypto/Sha1.cpp +0 -229
- data/ext/p7zip/CPP/7zip/Crypto/Sha1.h +0 -68
- data/ext/p7zip/CPP/7zip/PREMAKE/generate.sh +0 -18
- data/ext/p7zip/CPP/7zip/PREMAKE/premake4.lua +0 -263
- data/ext/p7zip/CPP/7zip/QMAKE/7ZA/7ZA.pro +0 -228
- data/ext/p7zip/CPP/7zip/QMAKE/7ZA/7ZA_osx.pro +0 -228
- data/ext/p7zip/CPP/7zip/QMAKE/test_emul/test_emul.pro +0 -26
- data/ext/p7zip/CPP/7zip/TEST/TestUI/TestUI.cpp +0 -560
- data/ext/p7zip/CPP/7zip/TEST/TestUI/makefile +0 -33
- data/ext/p7zip/CPP/7zip/TEST/TestUI/makefile.depend +0 -577
- data/ext/p7zip/CPP/7zip/TEST/TestUI/makefile.list +0 -16
- data/ext/p7zip/CPP/Common/Buffer.h +0 -77
- data/ext/p7zip/CPP/Common/Types.h +0 -11
- data/ext/p7zip/CPP/Windows/COM.cpp +0 -37
- data/ext/p7zip/CPP/Windows/COM.h +0 -69
- data/ext/p7zip/CPP/Windows/Clipboard.cpp +0 -160
- data/ext/p7zip/CPP/Windows/Clipboard.h +0 -28
- data/ext/p7zip/CPP/Windows/CommonDialog.h +0 -19
- data/ext/p7zip/CPP/Windows/Control/ComboBox.h +0 -82
- data/ext/p7zip/CPP/Windows/Control/Controls.cpp +0 -515
- data/ext/p7zip/CPP/Windows/Control/Dialog.cpp +0 -560
- data/ext/p7zip/CPP/Windows/Control/Dialog.h +0 -179
- data/ext/p7zip/CPP/Windows/Control/DialogImpl.h +0 -73
- data/ext/p7zip/CPP/Windows/Control/Edit.h +0 -24
- data/ext/p7zip/CPP/Windows/Control/ListView.h +0 -164
- data/ext/p7zip/CPP/Windows/Control/ProgressBar.h +0 -34
- data/ext/p7zip/CPP/Windows/Control/Static.h +0 -23
- data/ext/p7zip/CPP/Windows/Control/StatusBar.h +0 -56
- data/ext/p7zip/CPP/Windows/Control/Window2.cpp +0 -211
- data/ext/p7zip/CPP/Windows/Control/Window2.h +0 -111
- data/ext/p7zip/CPP/Windows/DLL.cpp +0 -193
- data/ext/p7zip/CPP/Windows/DLL.h +0 -48
- data/ext/p7zip/CPP/Windows/Error.cpp +0 -58
- data/ext/p7zip/CPP/Windows/Error.h +0 -33
- data/ext/p7zip/CPP/Windows/Menu.h +0 -4
- data/ext/p7zip/CPP/Windows/PropVariantConversions.cpp +0 -142
- data/ext/p7zip/CPP/Windows/PropVariantConversions.h +0 -14
- data/ext/p7zip/CPP/Windows/Registry.cpp +0 -313
- data/ext/p7zip/CPP/Windows/Registry.h +0 -113
- data/ext/p7zip/CPP/Windows/ResourceString.h +0 -22
- data/ext/p7zip/CPP/Windows/Shell.h +0 -21
- data/ext/p7zip/CPP/Windows/Time.cpp +0 -88
- data/ext/p7zip/CPP/Windows/Time.h +0 -21
- data/ext/p7zip/CPP/Windows/Window.cpp +0 -101
- data/ext/p7zip/CPP/Windows/Window.h +0 -43
- data/ext/p7zip/CPP/myWindows/initguid.h +0 -4
- data/ext/p7zip/CPP/myWindows/makefile +0 -21
- data/ext/p7zip/CPP/myWindows/makefile.depend +0 -32
- data/ext/p7zip/CPP/myWindows/makefile.list +0 -28
- data/ext/p7zip/CPP/myWindows/myAddExeFlag.cpp +0 -20
- data/ext/p7zip/CPP/myWindows/myGetTickCount.cpp +0 -8
- data/ext/p7zip/CPP/myWindows/mySplitCommandLine.cpp +0 -82
- data/ext/p7zip/CPP/myWindows/test_emul.cpp +0 -745
- data/ext/p7zip/CPP/myWindows/wine_GetXXXDefaultLangID.cpp +0 -741
- data/ext/p7zip/DOCS/MANUAL/switches/charset.htm +0 -49
- data/ext/p7zip/DOCS/Methods.txt +0 -152
- data/ext/p7zip/DOCS/lzma.txt +0 -598
- data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/ChangeLog +0 -41
- data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/readme +0 -21
- data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/readme.u7z +0 -30
- data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/u7z +0 -133
- data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/README +0 -21
- data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/check/check.sh +0 -117
- data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/check/files.tar +0 -0
- data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/man1/p7zip.1 +0 -33
- data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/p7zip +0 -144
- data/ext/p7zip/contrib/qnx630sp3/qnx630sp3-shared +0 -14
- data/ext/p7zip/contrib/qnx630sp3/qnx630sp3-static +0 -10
- data/ext/p7zip/integration_context_menu.txt +0 -51
- data/ext/p7zip/makefile.rules +0 -661
- /data/ext/p7zip/{DOCS → DOC}/7zFormat.txt +0 -0
- /data/ext/p7zip/{DOCS → DOC}/unRarLicense.txt +0 -0
@@ -0,0 +1,2240 @@
|
|
1
|
+
// File: lzham_lzcomp_internal.cpp
|
2
|
+
// See Copyright Notice and license at the end of include/lzham.h
|
3
|
+
#include "lzham_core.h"
|
4
|
+
#include "lzham_lzcomp_internal.h"
|
5
|
+
#include "lzham_checksum.h"
|
6
|
+
#include "lzham_timer.h"
|
7
|
+
#include "lzham_lzbase.h"
|
8
|
+
#include <string.h>
|
9
|
+
|
10
|
+
// Update and print high-level coding statistics if set to 1.
|
11
|
+
// TODO: Add match distance coding statistics.
|
12
|
+
#define LZHAM_UPDATE_STATS 0
|
13
|
+
|
14
|
+
// Only parse on the main thread, for easier debugging.
|
15
|
+
#define LZHAM_FORCE_SINGLE_THREADED_PARSING 0
|
16
|
+
|
17
|
+
// Verify all computed match costs against the generic/slow state::get_cost() method.
|
18
|
+
#define LZHAM_VERIFY_MATCH_COSTS 0
|
19
|
+
|
20
|
+
// Set to 1 to force all blocks to be uncompressed (raw).
|
21
|
+
#define LZHAM_FORCE_ALL_RAW_BLOCKS 0
|
22
|
+
|
23
|
+
#define LZHAM_EXTREME_PARSING_FAST_BYTES 96
|
24
|
+
|
25
|
+
namespace lzham
|
26
|
+
{
|
27
|
+
static comp_settings s_level_settings[cCompressionLevelCount] =
|
28
|
+
{
|
29
|
+
// cCompressionLevelFastest
|
30
|
+
{
|
31
|
+
8, // m_fast_bytes
|
32
|
+
1, // m_match_accel_max_matches_per_probe
|
33
|
+
2, // m_match_accel_max_probes
|
34
|
+
},
|
35
|
+
// cCompressionLevelFaster
|
36
|
+
{
|
37
|
+
24, // m_fast_bytes
|
38
|
+
6, // m_match_accel_max_matches_per_probe
|
39
|
+
12, // m_match_accel_max_probes
|
40
|
+
},
|
41
|
+
// cCompressionLevelDefault
|
42
|
+
{
|
43
|
+
32, // m_fast_bytes
|
44
|
+
UINT_MAX, // m_match_accel_max_matches_per_probe
|
45
|
+
16, // m_match_accel_max_probes
|
46
|
+
},
|
47
|
+
// cCompressionLevelBetter
|
48
|
+
{
|
49
|
+
48, // m_fast_bytes
|
50
|
+
UINT_MAX, // m_match_accel_max_matches_per_probe
|
51
|
+
32, // m_match_accel_max_probes
|
52
|
+
},
|
53
|
+
// cCompressionLevelUber
|
54
|
+
{
|
55
|
+
64, // m_fast_bytes
|
56
|
+
UINT_MAX, // m_match_accel_max_matches_per_probe
|
57
|
+
cMatchAccelMaxSupportedProbes, // m_match_accel_max_probes
|
58
|
+
}
|
59
|
+
};
|
60
|
+
|
61
|
+
lzcompressor::lzcompressor(lzham_malloc_context malloc_context) :
|
62
|
+
m_malloc_context(malloc_context),
|
63
|
+
m_src_size(-1),
|
64
|
+
m_src_adler32(0),
|
65
|
+
m_accel(malloc_context),
|
66
|
+
m_codec(malloc_context),
|
67
|
+
m_block_buf(malloc_context),
|
68
|
+
m_comp_buf(malloc_context),
|
69
|
+
m_step(0),
|
70
|
+
m_block_start_dict_ofs(0),
|
71
|
+
m_block_index(0),
|
72
|
+
m_finished(false),
|
73
|
+
m_use_task_pool(false),
|
74
|
+
m_use_extreme_parsing(false),
|
75
|
+
m_start_of_block_state(malloc_context),
|
76
|
+
m_state(malloc_context),
|
77
|
+
m_fast_bytes(128),
|
78
|
+
m_num_parse_threads(0)
|
79
|
+
{
|
80
|
+
LZHAM_VERIFY( ((uint32_ptr)this & (LZHAM_GET_ALIGNMENT(lzcompressor) - 1)) == 0);
|
81
|
+
|
82
|
+
for (uint i = 0; i < LZHAM_ARRAY_SIZE(m_parse_thread_state); i++)
|
83
|
+
m_parse_thread_state[i].set_malloc_context(malloc_context);
|
84
|
+
}
|
85
|
+
|
86
|
+
bool lzcompressor::init_seed_bytes()
|
87
|
+
{
|
88
|
+
uint cur_seed_ofs = 0;
|
89
|
+
|
90
|
+
while (cur_seed_ofs < m_params.m_num_seed_bytes)
|
91
|
+
{
|
92
|
+
uint total_bytes_remaining = m_params.m_num_seed_bytes - cur_seed_ofs;
|
93
|
+
uint num_bytes_to_add = math::minimum(total_bytes_remaining, m_params.m_block_size);
|
94
|
+
|
95
|
+
if (!m_accel.add_bytes_begin(num_bytes_to_add, static_cast<const uint8*>(m_params.m_pSeed_bytes) + cur_seed_ofs))
|
96
|
+
{
|
97
|
+
LZHAM_LOG_ERROR(7000);
|
98
|
+
return false;
|
99
|
+
}
|
100
|
+
m_accel.add_bytes_end();
|
101
|
+
|
102
|
+
m_accel.advance_bytes(num_bytes_to_add);
|
103
|
+
|
104
|
+
cur_seed_ofs += num_bytes_to_add;
|
105
|
+
}
|
106
|
+
|
107
|
+
return true;
|
108
|
+
}
|
109
|
+
|
110
|
+
bool lzcompressor::raw_parse_thread_state::init(lzcompressor& lzcomp, const lzcompressor::init_params ¶ms)
|
111
|
+
{
|
112
|
+
if (!m_state.init(lzcomp, params.m_table_max_update_interval, params.m_table_update_interval_slow_rate))
|
113
|
+
return false;
|
114
|
+
|
115
|
+
if (lzcomp.m_use_extreme_parsing)
|
116
|
+
{
|
117
|
+
for (uint j = 0; j < LZHAM_ARRAY_SIZE(m_nodes); j++)
|
118
|
+
m_nodes[j].clear();
|
119
|
+
}
|
120
|
+
else
|
121
|
+
{
|
122
|
+
node_state *pNodes = reinterpret_cast<node_state*>(m_nodes);
|
123
|
+
|
124
|
+
memset(pNodes, 0xFF, (1 + cMaxParseGraphNodes) * sizeof(node_state));
|
125
|
+
}
|
126
|
+
|
127
|
+
return true;
|
128
|
+
}
|
129
|
+
|
130
|
+
bool lzcompressor::init(const init_params& params)
|
131
|
+
{
|
132
|
+
clear();
|
133
|
+
|
134
|
+
if ((params.m_dict_size_log2 < CLZBase::cMinDictSizeLog2) || (params.m_dict_size_log2 > CLZBase::cMaxDictSizeLog2))
|
135
|
+
{
|
136
|
+
LZHAM_LOG_ERROR(7001);
|
137
|
+
return false;
|
138
|
+
}
|
139
|
+
|
140
|
+
if ((params.m_compression_level < 0) || (params.m_compression_level > cCompressionLevelCount))
|
141
|
+
{
|
142
|
+
LZHAM_LOG_ERROR(7002);
|
143
|
+
return false;
|
144
|
+
}
|
145
|
+
|
146
|
+
m_params = params;
|
147
|
+
m_use_task_pool = (m_params.m_pTask_pool) && (m_params.m_pTask_pool->get_num_threads() != 0) && (m_params.m_max_helper_threads > 0);
|
148
|
+
|
149
|
+
m_use_extreme_parsing = ((m_params.m_lzham_compress_flags & LZHAM_COMP_FLAG_EXTREME_PARSING) && (m_params.m_compression_level == cCompressionLevelUber));
|
150
|
+
|
151
|
+
if (!m_use_task_pool)
|
152
|
+
m_params.m_max_helper_threads = 0;
|
153
|
+
|
154
|
+
m_settings = s_level_settings[params.m_compression_level];
|
155
|
+
|
156
|
+
m_fast_bytes = m_use_extreme_parsing ? LZHAM_EXTREME_PARSING_FAST_BYTES : m_settings.m_fast_bytes;
|
157
|
+
if (m_params.m_fast_bytes_override)
|
158
|
+
{
|
159
|
+
m_fast_bytes = math::clamp<uint>(m_params.m_fast_bytes_override, 8, CLZBase::cMaxMatchLen + 1);
|
160
|
+
}
|
161
|
+
|
162
|
+
const uint dict_size = 1U << m_params.m_dict_size_log2;
|
163
|
+
|
164
|
+
if (params.m_num_seed_bytes)
|
165
|
+
{
|
166
|
+
if (!params.m_pSeed_bytes)
|
167
|
+
{
|
168
|
+
LZHAM_LOG_ERROR(7003);
|
169
|
+
return false;
|
170
|
+
}
|
171
|
+
if (params.m_num_seed_bytes > dict_size)
|
172
|
+
{
|
173
|
+
LZHAM_LOG_ERROR(7004);
|
174
|
+
return false;
|
175
|
+
}
|
176
|
+
}
|
177
|
+
|
178
|
+
uint max_block_size = dict_size / 8;
|
179
|
+
if (m_params.m_block_size > max_block_size)
|
180
|
+
{
|
181
|
+
m_params.m_block_size = max_block_size;
|
182
|
+
}
|
183
|
+
|
184
|
+
m_num_parse_threads = 1;
|
185
|
+
|
186
|
+
#if !LZHAM_FORCE_SINGLE_THREADED_PARSING
|
187
|
+
if ((m_params.m_max_helper_threads > 0) && ((m_params.m_lzham_compress_flags & LZHAM_COMP_FLAG_FORCE_SINGLE_THREADED_PARSING) == 0))
|
188
|
+
{
|
189
|
+
LZHAM_ASSUME(cMaxParseThreads >= 4);
|
190
|
+
|
191
|
+
if (m_params.m_block_size < 16384)
|
192
|
+
m_num_parse_threads = LZHAM_MIN(cMaxParseThreads, m_params.m_max_helper_threads + 1);
|
193
|
+
else if ((m_params.m_max_helper_threads <= 5) || (m_params.m_compression_level == cCompressionLevelFastest))
|
194
|
+
m_num_parse_threads = 1;
|
195
|
+
else
|
196
|
+
m_num_parse_threads = m_use_extreme_parsing ? 4 : 2;
|
197
|
+
}
|
198
|
+
#endif
|
199
|
+
|
200
|
+
int num_parse_jobs = m_num_parse_threads - 1;
|
201
|
+
uint match_accel_helper_threads = LZHAM_MAX(0, (int)m_params.m_max_helper_threads - num_parse_jobs);
|
202
|
+
match_accel_helper_threads = LZHAM_MIN(match_accel_helper_threads, cMatchAccelMaxSupportedThreads);
|
203
|
+
|
204
|
+
LZHAM_ASSERT(m_num_parse_threads >= 1);
|
205
|
+
LZHAM_ASSERT(m_num_parse_threads <= cMaxParseThreads);
|
206
|
+
|
207
|
+
if (!m_use_task_pool)
|
208
|
+
{
|
209
|
+
LZHAM_ASSERT(!match_accel_helper_threads && (m_num_parse_threads == 1));
|
210
|
+
}
|
211
|
+
else
|
212
|
+
{
|
213
|
+
LZHAM_ASSERT((match_accel_helper_threads + (m_num_parse_threads - 1)) <= m_params.m_max_helper_threads);
|
214
|
+
}
|
215
|
+
|
216
|
+
uint accel_flags = 0;
|
217
|
+
if (m_params.m_lzham_compress_flags & LZHAM_COMP_FLAG_DETERMINISTIC_PARSING)
|
218
|
+
accel_flags |= search_accelerator::cFlagDeterministic;
|
219
|
+
|
220
|
+
if (m_params.m_compression_level > cCompressionLevelFastest)
|
221
|
+
{
|
222
|
+
if ((m_params.m_lzham_compress_flags & LZHAM_COMP_FLAG_USE_LOW_MEMORY_MATCH_FINDER) == 0)
|
223
|
+
accel_flags |= search_accelerator::cFlagHash24;
|
224
|
+
|
225
|
+
accel_flags |= search_accelerator::cFlagLen2Matches;
|
226
|
+
}
|
227
|
+
|
228
|
+
if (!m_accel.init(this, params.m_pTask_pool, match_accel_helper_threads, dict_size, m_settings.m_match_accel_max_matches_per_probe, false, m_settings.m_match_accel_max_probes, accel_flags))
|
229
|
+
{
|
230
|
+
LZHAM_LOG_ERROR(7005);
|
231
|
+
return false;
|
232
|
+
}
|
233
|
+
|
234
|
+
init_position_slots(params.m_dict_size_log2);
|
235
|
+
init_slot_tabs();
|
236
|
+
|
237
|
+
if (!m_state.init(*this, m_params.m_table_max_update_interval, m_params.m_table_update_interval_slow_rate))
|
238
|
+
{
|
239
|
+
LZHAM_LOG_ERROR(7006);
|
240
|
+
return false;
|
241
|
+
}
|
242
|
+
|
243
|
+
if (!m_block_buf.try_reserve(m_params.m_block_size))
|
244
|
+
{
|
245
|
+
LZHAM_LOG_ERROR(7007);
|
246
|
+
return false;
|
247
|
+
}
|
248
|
+
|
249
|
+
if (!m_comp_buf.try_reserve(m_params.m_block_size*2))
|
250
|
+
{
|
251
|
+
LZHAM_LOG_ERROR(7008);
|
252
|
+
return false;
|
253
|
+
}
|
254
|
+
|
255
|
+
for (uint i = 0; i < LZHAM_ARRAY_SIZE(m_parse_thread_state); i++)
|
256
|
+
{
|
257
|
+
if (!m_parse_thread_state[i].init(*this, m_params))
|
258
|
+
{
|
259
|
+
LZHAM_LOG_ERROR(7009);
|
260
|
+
return false;
|
261
|
+
}
|
262
|
+
}
|
263
|
+
|
264
|
+
if (params.m_num_seed_bytes)
|
265
|
+
{
|
266
|
+
if (!init_seed_bytes())
|
267
|
+
{
|
268
|
+
LZHAM_LOG_ERROR(7010);
|
269
|
+
return false;
|
270
|
+
}
|
271
|
+
}
|
272
|
+
|
273
|
+
if (!send_zlib_header())
|
274
|
+
{
|
275
|
+
LZHAM_LOG_ERROR(7011);
|
276
|
+
return false;
|
277
|
+
}
|
278
|
+
|
279
|
+
m_src_size = 0;
|
280
|
+
|
281
|
+
return true;
|
282
|
+
}
|
283
|
+
|
284
|
+
// See http://www.gzip.org/zlib/rfc-zlib.html
|
285
|
+
// Method is set to 14 (LZHAM) and CINFO is (window_size - 15).
|
286
|
+
bool lzcompressor::send_zlib_header()
|
287
|
+
{
|
288
|
+
if ((m_params.m_lzham_compress_flags & LZHAM_COMP_FLAG_WRITE_ZLIB_STREAM) == 0)
|
289
|
+
return true;
|
290
|
+
|
291
|
+
// set CM (method) and CINFO (dictionary size) fields
|
292
|
+
int cmf = LZHAM_Z_LZHAM | ((m_params.m_dict_size_log2 - 15) << 4);
|
293
|
+
|
294
|
+
// set FLEVEL by mapping LZHAM's compression level to zlib's
|
295
|
+
int flg = 0;
|
296
|
+
switch (m_params.m_compression_level)
|
297
|
+
{
|
298
|
+
case LZHAM_COMP_LEVEL_FASTEST:
|
299
|
+
{
|
300
|
+
flg = 0 << 6;
|
301
|
+
break;
|
302
|
+
}
|
303
|
+
case LZHAM_COMP_LEVEL_FASTER:
|
304
|
+
{
|
305
|
+
flg = 1 << 6;
|
306
|
+
break;
|
307
|
+
}
|
308
|
+
case LZHAM_COMP_LEVEL_DEFAULT:
|
309
|
+
case LZHAM_COMP_LEVEL_BETTER:
|
310
|
+
{
|
311
|
+
flg = 2 << 6;
|
312
|
+
break;
|
313
|
+
}
|
314
|
+
default:
|
315
|
+
{
|
316
|
+
flg = 3 << 6;
|
317
|
+
break;
|
318
|
+
}
|
319
|
+
}
|
320
|
+
|
321
|
+
// set FDICT flag
|
322
|
+
if (m_params.m_pSeed_bytes)
|
323
|
+
flg |= 32;
|
324
|
+
|
325
|
+
int check = ((cmf << 8) + flg) % 31;
|
326
|
+
if (check)
|
327
|
+
flg += (31 - check);
|
328
|
+
|
329
|
+
LZHAM_ASSERT(0 == (((cmf << 8) + flg) % 31));
|
330
|
+
if (!m_comp_buf.try_push_back(static_cast<uint8>(cmf)))
|
331
|
+
return false;
|
332
|
+
if (!m_comp_buf.try_push_back(static_cast<uint8>(flg)))
|
333
|
+
return false;
|
334
|
+
|
335
|
+
if (m_params.m_pSeed_bytes)
|
336
|
+
{
|
337
|
+
// send adler32 of DICT
|
338
|
+
uint dict_adler32 = adler32(m_params.m_pSeed_bytes, m_params.m_num_seed_bytes);
|
339
|
+
for (uint i = 0; i < 4; i++)
|
340
|
+
{
|
341
|
+
if (!m_comp_buf.try_push_back(static_cast<uint8>(dict_adler32 >> 24)))
|
342
|
+
return false;
|
343
|
+
dict_adler32 <<= 8;
|
344
|
+
}
|
345
|
+
}
|
346
|
+
|
347
|
+
return true;
|
348
|
+
}
|
349
|
+
|
350
|
+
void lzcompressor::clear()
|
351
|
+
{
|
352
|
+
m_codec.clear();
|
353
|
+
m_src_size = -1;
|
354
|
+
m_src_adler32 = cInitAdler32;
|
355
|
+
m_block_buf.clear();
|
356
|
+
m_comp_buf.clear();
|
357
|
+
|
358
|
+
m_step = 0;
|
359
|
+
m_finished = false;
|
360
|
+
m_use_task_pool = false;
|
361
|
+
m_use_extreme_parsing = false;
|
362
|
+
m_block_start_dict_ofs = 0;
|
363
|
+
m_block_index = 0;
|
364
|
+
m_state.clear();
|
365
|
+
m_num_parse_threads = 0;
|
366
|
+
m_fast_bytes = 128;
|
367
|
+
|
368
|
+
for (uint i = 0; i < cMaxParseThreads; i++)
|
369
|
+
{
|
370
|
+
parse_thread_state &parse_state = m_parse_thread_state[i];
|
371
|
+
parse_state.m_state.clear();
|
372
|
+
|
373
|
+
for (uint j = 0; j <= cMaxParseGraphNodes; j++)
|
374
|
+
parse_state.m_nodes[j].clear();
|
375
|
+
|
376
|
+
parse_state.m_start_ofs = 0;
|
377
|
+
parse_state.m_bytes_to_match = 0;
|
378
|
+
parse_state.m_best_decisions.clear();
|
379
|
+
parse_state.m_issue_reset_state_partial = false;
|
380
|
+
parse_state.m_emit_decisions_backwards = false;
|
381
|
+
parse_state.m_failed = false;
|
382
|
+
parse_state.m_parse_early_out_thresh = UINT_MAX;
|
383
|
+
parse_state.m_bytes_actually_parsed = 0;
|
384
|
+
}
|
385
|
+
}
|
386
|
+
|
387
|
+
bool lzcompressor::reset()
|
388
|
+
{
|
389
|
+
if (m_src_size < 0)
|
390
|
+
return false;
|
391
|
+
|
392
|
+
m_accel.reset();
|
393
|
+
m_codec.reset();
|
394
|
+
m_stats.clear();
|
395
|
+
m_src_size = 0;
|
396
|
+
m_src_adler32 = cInitAdler32;
|
397
|
+
m_block_buf.try_resize(0);
|
398
|
+
m_comp_buf.try_resize(0);
|
399
|
+
|
400
|
+
m_step = 0;
|
401
|
+
m_finished = false;
|
402
|
+
m_block_start_dict_ofs = 0;
|
403
|
+
m_block_index = 0;
|
404
|
+
m_state.reset();
|
405
|
+
|
406
|
+
if (m_params.m_num_seed_bytes)
|
407
|
+
{
|
408
|
+
if (!init_seed_bytes())
|
409
|
+
{
|
410
|
+
LZHAM_LOG_ERROR(7012);
|
411
|
+
return false;
|
412
|
+
}
|
413
|
+
}
|
414
|
+
|
415
|
+
return send_zlib_header();
|
416
|
+
}
|
417
|
+
|
418
|
+
bool lzcompressor::code_decision(lzdecision lzdec, uint& cur_ofs, uint& bytes_to_match)
|
419
|
+
{
|
420
|
+
#ifdef LZHAM_LZDEBUG
|
421
|
+
if (!m_codec.encode_bits(CLZBase::cLZHAMDebugSyncMarkerValue, CLZBase::cLZHAMDebugSyncMarkerBits)) return false;
|
422
|
+
if (!m_codec.encode_bits(lzdec.is_match(), 1)) return false;
|
423
|
+
if (!m_codec.encode_bits(lzdec.get_len(), 17)) return false;
|
424
|
+
if (!m_codec.encode_bits(m_state.m_cur_state, 4)) return false;
|
425
|
+
#endif
|
426
|
+
|
427
|
+
#ifdef LZHAM_LZVERIFY
|
428
|
+
if (lzdec.is_match())
|
429
|
+
{
|
430
|
+
uint match_dist = lzdec.get_match_dist(m_state);
|
431
|
+
|
432
|
+
LZHAM_VERIFY(m_accel[cur_ofs] == m_accel[(cur_ofs - match_dist) & (m_accel.get_max_dict_size() - 1)]);
|
433
|
+
}
|
434
|
+
#endif
|
435
|
+
|
436
|
+
const uint len = lzdec.get_len();
|
437
|
+
|
438
|
+
if (!m_state.encode(m_codec, *this, m_accel, lzdec))
|
439
|
+
{
|
440
|
+
LZHAM_LOG_ERROR(7013);
|
441
|
+
return false;
|
442
|
+
}
|
443
|
+
|
444
|
+
cur_ofs += len;
|
445
|
+
LZHAM_ASSERT(bytes_to_match >= len);
|
446
|
+
bytes_to_match -= len;
|
447
|
+
|
448
|
+
//m_accel.advance_bytes(len);
|
449
|
+
|
450
|
+
m_step++;
|
451
|
+
|
452
|
+
return true;
|
453
|
+
}
|
454
|
+
|
455
|
+
bool lzcompressor::send_sync_block(lzham_flush_t flush_type)
|
456
|
+
{
|
457
|
+
m_codec.reset();
|
458
|
+
|
459
|
+
if (!m_codec.start_encoding(128))
|
460
|
+
{
|
461
|
+
LZHAM_LOG_ERROR(7014);
|
462
|
+
return false;
|
463
|
+
}
|
464
|
+
|
465
|
+
#ifdef LZHAM_LZDEBUG
|
466
|
+
if (!m_codec.encode_bits(166, 12))
|
467
|
+
{
|
468
|
+
LZHAM_LOG_ERROR(7015);
|
469
|
+
return false;
|
470
|
+
}
|
471
|
+
#endif
|
472
|
+
|
473
|
+
if (!m_codec.encode_bits(cSyncBlock, cBlockHeaderBits))
|
474
|
+
{
|
475
|
+
LZHAM_LOG_ERROR(7016);
|
476
|
+
return false;
|
477
|
+
}
|
478
|
+
|
479
|
+
int flush_code = 0;
|
480
|
+
switch (flush_type)
|
481
|
+
{
|
482
|
+
case LZHAM_FULL_FLUSH:
|
483
|
+
flush_code = 2;
|
484
|
+
break;
|
485
|
+
case LZHAM_TABLE_FLUSH:
|
486
|
+
flush_code = 1;
|
487
|
+
break;
|
488
|
+
case LZHAM_SYNC_FLUSH:
|
489
|
+
flush_code = 3;
|
490
|
+
break;
|
491
|
+
case LZHAM_NO_FLUSH:
|
492
|
+
case LZHAM_FINISH:
|
493
|
+
flush_code = 0;
|
494
|
+
break;
|
495
|
+
}
|
496
|
+
if (!m_codec.encode_bits(flush_code, cBlockFlushTypeBits))
|
497
|
+
{
|
498
|
+
LZHAM_LOG_ERROR(7017);
|
499
|
+
return false;
|
500
|
+
}
|
501
|
+
|
502
|
+
if (!m_codec.encode_align_to_byte())
|
503
|
+
{
|
504
|
+
LZHAM_LOG_ERROR(7018);
|
505
|
+
return false;
|
506
|
+
}
|
507
|
+
if (!m_codec.encode_bits(0x0000, 16))
|
508
|
+
{
|
509
|
+
LZHAM_LOG_ERROR(7019);
|
510
|
+
return false;
|
511
|
+
}
|
512
|
+
if (!m_codec.encode_bits(0xFFFF, 16))
|
513
|
+
{
|
514
|
+
LZHAM_LOG_ERROR(7020);
|
515
|
+
return false;
|
516
|
+
}
|
517
|
+
if (!m_codec.stop_encoding(true))
|
518
|
+
{
|
519
|
+
LZHAM_LOG_ERROR(7021);
|
520
|
+
return false;
|
521
|
+
}
|
522
|
+
if (!m_comp_buf.append(m_codec.get_encoding_buf()))
|
523
|
+
{
|
524
|
+
LZHAM_LOG_ERROR(7022);
|
525
|
+
return false;
|
526
|
+
}
|
527
|
+
|
528
|
+
m_block_index++;
|
529
|
+
return true;
|
530
|
+
}
|
531
|
+
|
532
|
+
bool lzcompressor::flush(lzham_flush_t flush_type)
|
533
|
+
{
|
534
|
+
LZHAM_ASSERT(!m_finished);
|
535
|
+
if (m_finished)
|
536
|
+
{
|
537
|
+
LZHAM_LOG_ERROR(7023);
|
538
|
+
return false;
|
539
|
+
}
|
540
|
+
|
541
|
+
bool status = true;
|
542
|
+
if (m_block_buf.size())
|
543
|
+
{
|
544
|
+
status = compress_block(m_block_buf.get_ptr(), m_block_buf.size());
|
545
|
+
|
546
|
+
m_block_buf.try_resize(0);
|
547
|
+
}
|
548
|
+
|
549
|
+
if (status)
|
550
|
+
{
|
551
|
+
status = send_sync_block(flush_type);
|
552
|
+
|
553
|
+
if (LZHAM_FULL_FLUSH == flush_type)
|
554
|
+
{
|
555
|
+
m_accel.flush();
|
556
|
+
m_state.reset();
|
557
|
+
}
|
558
|
+
}
|
559
|
+
|
560
|
+
lzham_flush_buffered_printf();
|
561
|
+
|
562
|
+
return status;
|
563
|
+
}
|
564
|
+
|
565
|
+
bool lzcompressor::put_bytes(const void* pBuf, uint buf_len)
|
566
|
+
{
|
567
|
+
LZHAM_ASSERT(!m_finished);
|
568
|
+
if (m_finished)
|
569
|
+
{
|
570
|
+
LZHAM_LOG_ERROR(7024);
|
571
|
+
return false;
|
572
|
+
}
|
573
|
+
|
574
|
+
bool status = true;
|
575
|
+
|
576
|
+
if (!pBuf)
|
577
|
+
{
|
578
|
+
// Last block - flush whatever's left and send the final block.
|
579
|
+
if (m_block_buf.size())
|
580
|
+
{
|
581
|
+
status = compress_block(m_block_buf.get_ptr(), m_block_buf.size());
|
582
|
+
|
583
|
+
m_block_buf.try_resize(0);
|
584
|
+
}
|
585
|
+
|
586
|
+
if (status)
|
587
|
+
{
|
588
|
+
if (!send_final_block())
|
589
|
+
{
|
590
|
+
status = false;
|
591
|
+
LZHAM_LOG_ERROR(7025);
|
592
|
+
}
|
593
|
+
}
|
594
|
+
|
595
|
+
m_finished = true;
|
596
|
+
}
|
597
|
+
else
|
598
|
+
{
|
599
|
+
// Compress blocks.
|
600
|
+
const uint8 *pSrcBuf = static_cast<const uint8*>(pBuf);
|
601
|
+
uint num_src_bytes_remaining = buf_len;
|
602
|
+
|
603
|
+
while (num_src_bytes_remaining)
|
604
|
+
{
|
605
|
+
const uint num_bytes_to_copy = LZHAM_MIN(num_src_bytes_remaining, m_params.m_block_size - m_block_buf.size());
|
606
|
+
|
607
|
+
if (num_bytes_to_copy == m_params.m_block_size)
|
608
|
+
{
|
609
|
+
LZHAM_ASSERT(!m_block_buf.size());
|
610
|
+
|
611
|
+
// Full-block available - compress in-place.
|
612
|
+
status = compress_block(pSrcBuf, num_bytes_to_copy);
|
613
|
+
}
|
614
|
+
else
|
615
|
+
{
|
616
|
+
// Less than a full block available - append to already accumulated bytes.
|
617
|
+
if (!m_block_buf.append(static_cast<const uint8 *>(pSrcBuf), num_bytes_to_copy))
|
618
|
+
{
|
619
|
+
LZHAM_LOG_ERROR(7026);
|
620
|
+
return false;
|
621
|
+
}
|
622
|
+
|
623
|
+
LZHAM_ASSERT(m_block_buf.size() <= m_params.m_block_size);
|
624
|
+
|
625
|
+
if (m_block_buf.size() == m_params.m_block_size)
|
626
|
+
{
|
627
|
+
status = compress_block(m_block_buf.get_ptr(), m_block_buf.size());
|
628
|
+
|
629
|
+
m_block_buf.try_resize(0);
|
630
|
+
}
|
631
|
+
}
|
632
|
+
|
633
|
+
if (!status)
|
634
|
+
{
|
635
|
+
LZHAM_LOG_ERROR(7027);
|
636
|
+
return false;
|
637
|
+
}
|
638
|
+
|
639
|
+
pSrcBuf += num_bytes_to_copy;
|
640
|
+
num_src_bytes_remaining -= num_bytes_to_copy;
|
641
|
+
}
|
642
|
+
}
|
643
|
+
|
644
|
+
lzham_flush_buffered_printf();
|
645
|
+
|
646
|
+
return status;
|
647
|
+
}
|
648
|
+
|
649
|
+
bool lzcompressor::send_final_block()
|
650
|
+
{
|
651
|
+
if (!m_codec.start_encoding(16))
|
652
|
+
{
|
653
|
+
LZHAM_LOG_ERROR(7028);
|
654
|
+
return false;
|
655
|
+
}
|
656
|
+
|
657
|
+
#ifdef LZHAM_LZDEBUG
|
658
|
+
if (!m_codec.encode_bits(166, 12))
|
659
|
+
{
|
660
|
+
LZHAM_LOG_ERROR(7029);
|
661
|
+
return false;
|
662
|
+
}
|
663
|
+
#endif
|
664
|
+
|
665
|
+
if (!m_block_index)
|
666
|
+
{
|
667
|
+
if (!send_configuration())
|
668
|
+
{
|
669
|
+
LZHAM_LOG_ERROR(7030);
|
670
|
+
return false;
|
671
|
+
}
|
672
|
+
}
|
673
|
+
|
674
|
+
if (!m_codec.encode_bits(cEOFBlock, cBlockHeaderBits))
|
675
|
+
{
|
676
|
+
LZHAM_LOG_ERROR(7031);
|
677
|
+
return false;
|
678
|
+
}
|
679
|
+
|
680
|
+
if (!m_codec.encode_align_to_byte())
|
681
|
+
{
|
682
|
+
LZHAM_LOG_ERROR(7032);
|
683
|
+
return false;
|
684
|
+
}
|
685
|
+
|
686
|
+
if (!m_codec.encode_bits(m_src_adler32, 32))
|
687
|
+
{
|
688
|
+
LZHAM_LOG_ERROR(7033);
|
689
|
+
return false;
|
690
|
+
}
|
691
|
+
|
692
|
+
if (!m_codec.stop_encoding(true))
|
693
|
+
{
|
694
|
+
LZHAM_LOG_ERROR(7034);
|
695
|
+
return false;
|
696
|
+
}
|
697
|
+
|
698
|
+
if (m_comp_buf.empty())
|
699
|
+
{
|
700
|
+
m_comp_buf.swap(m_codec.get_encoding_buf());
|
701
|
+
}
|
702
|
+
else
|
703
|
+
{
|
704
|
+
if (!m_comp_buf.append(m_codec.get_encoding_buf()))
|
705
|
+
{
|
706
|
+
LZHAM_LOG_ERROR(7035);
|
707
|
+
return false;
|
708
|
+
}
|
709
|
+
}
|
710
|
+
|
711
|
+
m_block_index++;
|
712
|
+
|
713
|
+
#if LZHAM_UPDATE_STATS
|
714
|
+
m_stats.print();
|
715
|
+
#endif
|
716
|
+
|
717
|
+
return true;
|
718
|
+
}
|
719
|
+
|
720
|
+
bool lzcompressor::send_configuration()
|
721
|
+
{
|
722
|
+
// TODO: Currently unused.
|
723
|
+
//if (!m_codec.encode_bits(m_settings.m_fast_adaptive_huffman_updating, 1))
|
724
|
+
// return false;
|
725
|
+
//if (!m_codec.encode_bits(0, 1))
|
726
|
+
// return false;
|
727
|
+
|
728
|
+
return true;
|
729
|
+
}
|
730
|
+
|
731
|
+
void lzcompressor::node::add_state(
|
732
|
+
int parent_index, int parent_state_index,
|
733
|
+
const lzdecision &lzdec, const state &parent_state,
|
734
|
+
bit_cost_t total_cost,
|
735
|
+
uint total_complexity, uint max_parse_node_states)
|
736
|
+
{
|
737
|
+
state_base trial_state;
|
738
|
+
parent_state.save_partial_state(trial_state);
|
739
|
+
trial_state.partial_advance(lzdec);
|
740
|
+
|
741
|
+
for (int i = m_num_node_states - 1; i >= 0; i--)
|
742
|
+
{
|
743
|
+
node_state &cur_node_state = m_node_states[i];
|
744
|
+
if (cur_node_state.m_saved_state == trial_state)
|
745
|
+
{
|
746
|
+
if ( (total_cost < cur_node_state.m_total_cost) ||
|
747
|
+
((total_cost == cur_node_state.m_total_cost) && (total_complexity < cur_node_state.m_total_complexity)) )
|
748
|
+
{
|
749
|
+
cur_node_state.m_parent_index = static_cast<int16>(parent_index);
|
750
|
+
cur_node_state.m_parent_state_index = static_cast<int8>(parent_state_index);
|
751
|
+
cur_node_state.m_lzdec = lzdec;
|
752
|
+
cur_node_state.m_total_cost = total_cost;
|
753
|
+
cur_node_state.m_total_complexity = total_complexity;
|
754
|
+
|
755
|
+
while (i > 0)
|
756
|
+
{
|
757
|
+
if ((m_node_states[i].m_total_cost < m_node_states[i - 1].m_total_cost) ||
|
758
|
+
((m_node_states[i].m_total_cost == m_node_states[i - 1].m_total_cost) && (m_node_states[i].m_total_complexity < m_node_states[i - 1].m_total_complexity)))
|
759
|
+
{
|
760
|
+
std::swap(m_node_states[i], m_node_states[i - 1]);
|
761
|
+
i--;
|
762
|
+
}
|
763
|
+
else
|
764
|
+
break;
|
765
|
+
}
|
766
|
+
}
|
767
|
+
|
768
|
+
return;
|
769
|
+
}
|
770
|
+
}
|
771
|
+
|
772
|
+
int insert_index;
|
773
|
+
for (insert_index = m_num_node_states; insert_index > 0; insert_index--)
|
774
|
+
{
|
775
|
+
node_state &cur_node_state = m_node_states[insert_index - 1];
|
776
|
+
|
777
|
+
if ( (total_cost > cur_node_state.m_total_cost) ||
|
778
|
+
((total_cost == cur_node_state.m_total_cost) && (total_complexity >= cur_node_state.m_total_complexity)) )
|
779
|
+
{
|
780
|
+
break;
|
781
|
+
}
|
782
|
+
}
|
783
|
+
|
784
|
+
if (insert_index == static_cast<int>(max_parse_node_states))
|
785
|
+
return;
|
786
|
+
|
787
|
+
uint num_behind = m_num_node_states - insert_index;
|
788
|
+
uint num_to_move = (m_num_node_states < max_parse_node_states) ? num_behind : (num_behind - 1);
|
789
|
+
if (num_to_move)
|
790
|
+
{
|
791
|
+
LZHAM_ASSERT((insert_index + 1 + num_to_move) <= max_parse_node_states);
|
792
|
+
memmove(&m_node_states[insert_index + 1], &m_node_states[insert_index], sizeof(node_state) * num_to_move);
|
793
|
+
}
|
794
|
+
|
795
|
+
node_state *pNew_node_state = &m_node_states[insert_index];
|
796
|
+
pNew_node_state->m_parent_index = static_cast<int16>(parent_index);
|
797
|
+
pNew_node_state->m_parent_state_index = static_cast<uint8>(parent_state_index);
|
798
|
+
pNew_node_state->m_lzdec = lzdec;
|
799
|
+
pNew_node_state->m_total_cost = total_cost;
|
800
|
+
pNew_node_state->m_total_complexity = total_complexity;
|
801
|
+
pNew_node_state->m_saved_state = trial_state;
|
802
|
+
|
803
|
+
m_num_node_states = LZHAM_MIN(m_num_node_states + 1, static_cast<uint>(max_parse_node_states));
|
804
|
+
|
805
|
+
#ifdef LZHAM_LZVERIFY
|
806
|
+
for (uint i = 0; i < (m_num_node_states - 1); ++i)
|
807
|
+
{
|
808
|
+
node_state &a = m_node_states[i];
|
809
|
+
node_state &b = m_node_states[i + 1];
|
810
|
+
LZHAM_VERIFY(
|
811
|
+
(a.m_total_cost < b.m_total_cost) ||
|
812
|
+
((a.m_total_cost == b.m_total_cost) && (a.m_total_complexity <= b.m_total_complexity)) );
|
813
|
+
}
|
814
|
+
#endif
|
815
|
+
}
|
816
|
+
|
817
|
+
// The "extreme" parser tracks the best cMaxParseNodeStates (default 4) candidate LZ decisions per lookahead character.
|
818
|
+
// This allows the compressor to make locally suboptimal decisions that ultimately result in a better parse.
|
819
|
+
// It assumes the input statistics are locally stationary over the input block to parse.
|
820
|
+
bool lzcompressor::extreme_parse(parse_thread_state &parse_state)
|
821
|
+
{
|
822
|
+
LZHAM_ASSERT(parse_state.m_bytes_to_match <= cMaxParseGraphNodes);
|
823
|
+
|
824
|
+
parse_state.m_failed = false;
|
825
|
+
parse_state.m_emit_decisions_backwards = true;
|
826
|
+
|
827
|
+
node *pNodes = parse_state.m_nodes;
|
828
|
+
|
829
|
+
#ifdef LZHAM_BUILD_DEBUG
|
830
|
+
for (uint i = 0; i < (cMaxParseGraphNodes + 1); i++)
|
831
|
+
{
|
832
|
+
LZHAM_ASSERT(pNodes[i].m_num_node_states == 0);
|
833
|
+
}
|
834
|
+
#endif
|
835
|
+
|
836
|
+
state &approx_state = *parse_state.m_pState;
|
837
|
+
|
838
|
+
pNodes[0].m_num_node_states = 1;
|
839
|
+
node_state &first_node_state = pNodes[0].m_node_states[0];
|
840
|
+
approx_state.save_partial_state(first_node_state.m_saved_state);
|
841
|
+
first_node_state.m_parent_index = -1;
|
842
|
+
first_node_state.m_parent_state_index = -1;
|
843
|
+
first_node_state.m_total_cost = 0;
|
844
|
+
first_node_state.m_total_complexity = 0;
|
845
|
+
|
846
|
+
const uint bytes_to_parse = parse_state.m_bytes_to_match;
|
847
|
+
|
848
|
+
const uint lookahead_start_ofs = m_accel.get_lookahead_pos() & m_accel.get_max_dict_size_mask();
|
849
|
+
|
850
|
+
uint cur_dict_ofs = parse_state.m_start_ofs;
|
851
|
+
uint cur_lookahead_ofs = cur_dict_ofs - lookahead_start_ofs;
|
852
|
+
uint cur_node_index = 0;
|
853
|
+
|
854
|
+
enum { cMaxFullMatches = cMatchAccelMaxSupportedProbes };
|
855
|
+
uint match_lens[cMaxFullMatches];
|
856
|
+
uint match_distances[cMaxFullMatches];
|
857
|
+
|
858
|
+
bit_cost_t lzdec_bitcosts[cMaxMatchLen + 1];
|
859
|
+
|
860
|
+
node prev_lit_node;
|
861
|
+
prev_lit_node.clear();
|
862
|
+
|
863
|
+
node *pMax_node_in_graph = &pNodes[0];
|
864
|
+
|
865
|
+
while (cur_node_index < bytes_to_parse)
|
866
|
+
{
|
867
|
+
node* pCur_node = &pNodes[cur_node_index];
|
868
|
+
|
869
|
+
if ((cur_node_index >= parse_state.m_parse_early_out_thresh) && (pCur_node == pMax_node_in_graph))
|
870
|
+
{
|
871
|
+
// If the best path *must* pass through this node, and we're far enough along, and we're parsing using a single thread, then exit so we can move all our state forward.
|
872
|
+
if (pCur_node->m_num_node_states == 1)
|
873
|
+
break;
|
874
|
+
}
|
875
|
+
|
876
|
+
const uint max_admissable_match_len = LZHAM_MIN(static_cast<uint>(CLZBase::cMaxMatchLen), bytes_to_parse - cur_node_index);
|
877
|
+
const uint find_dict_size = m_accel.get_cur_dict_size() + cur_lookahead_ofs;
|
878
|
+
|
879
|
+
const uint lit_pred0 = approx_state.get_pred_char(m_accel, cur_dict_ofs, 1);
|
880
|
+
|
881
|
+
const uint8* pLookahead = &m_accel.m_dict[cur_dict_ofs];
|
882
|
+
|
883
|
+
// full matches
|
884
|
+
uint max_full_match_len = 0;
|
885
|
+
uint num_full_matches = 0;
|
886
|
+
uint len2_match_dist = 0;
|
887
|
+
|
888
|
+
if (max_admissable_match_len >= CLZBase::cMinMatchLen)
|
889
|
+
{
|
890
|
+
const dict_match* pMatches = m_accel.find_matches(cur_lookahead_ofs);
|
891
|
+
if (pMatches)
|
892
|
+
{
|
893
|
+
for ( ; ; )
|
894
|
+
{
|
895
|
+
uint match_len = pMatches->get_len();
|
896
|
+
LZHAM_ASSERT((pMatches->get_dist() > 0) && (pMatches->get_dist() <= m_dict_size));
|
897
|
+
match_len = LZHAM_MIN(match_len, max_admissable_match_len);
|
898
|
+
|
899
|
+
if (match_len > max_full_match_len)
|
900
|
+
{
|
901
|
+
max_full_match_len = match_len;
|
902
|
+
|
903
|
+
match_lens[num_full_matches] = match_len;
|
904
|
+
match_distances[num_full_matches] = pMatches->get_dist();
|
905
|
+
num_full_matches++;
|
906
|
+
}
|
907
|
+
|
908
|
+
if (pMatches->is_last())
|
909
|
+
break;
|
910
|
+
pMatches++;
|
911
|
+
}
|
912
|
+
}
|
913
|
+
|
914
|
+
len2_match_dist = m_accel.get_len2_match(cur_lookahead_ofs);
|
915
|
+
}
|
916
|
+
|
917
|
+
uint ahead_bytes = 1;
|
918
|
+
for (uint cur_node_state_index = 0; cur_node_state_index < pCur_node->m_num_node_states; cur_node_state_index++)
|
919
|
+
{
|
920
|
+
node_state &cur_node_state = pCur_node->m_node_states[cur_node_state_index];
|
921
|
+
|
922
|
+
if (cur_node_index)
|
923
|
+
{
|
924
|
+
LZHAM_ASSERT(cur_node_state.m_parent_index >= 0);
|
925
|
+
|
926
|
+
approx_state.restore_partial_state(cur_node_state.m_saved_state);
|
927
|
+
}
|
928
|
+
|
929
|
+
uint is_match_model_index = LZHAM_IS_MATCH_MODEL_INDEX(approx_state.m_cur_state);
|
930
|
+
|
931
|
+
const bit_cost_t cur_node_total_cost = cur_node_state.m_total_cost;
|
932
|
+
const uint cur_node_total_complexity = cur_node_state.m_total_complexity;
|
933
|
+
|
934
|
+
// rep matches
|
935
|
+
uint match_hist_max_len = 0;
|
936
|
+
uint match_hist_min_match_len = 1;
|
937
|
+
for (uint rep_match_index = 0; rep_match_index < cMatchHistSize; rep_match_index++)
|
938
|
+
{
|
939
|
+
uint hist_match_len = 0;
|
940
|
+
|
941
|
+
uint dist = approx_state.m_match_hist[rep_match_index];
|
942
|
+
if (dist <= find_dict_size)
|
943
|
+
{
|
944
|
+
const uint comp_pos = static_cast<uint>((m_accel.m_lookahead_pos + cur_lookahead_ofs - dist) & m_accel.m_max_dict_size_mask);
|
945
|
+
const uint8* pComp = &m_accel.m_dict[comp_pos];
|
946
|
+
|
947
|
+
for (hist_match_len = 0; hist_match_len < max_admissable_match_len; hist_match_len++)
|
948
|
+
if (pComp[hist_match_len] != pLookahead[hist_match_len])
|
949
|
+
break;
|
950
|
+
}
|
951
|
+
|
952
|
+
if (hist_match_len >= match_hist_min_match_len)
|
953
|
+
{
|
954
|
+
match_hist_max_len = math::maximum(match_hist_max_len, hist_match_len);
|
955
|
+
|
956
|
+
approx_state.get_rep_match_costs(cur_dict_ofs, lzdec_bitcosts, rep_match_index, match_hist_min_match_len, hist_match_len, is_match_model_index);
|
957
|
+
|
958
|
+
uint rep_match_total_complexity = cur_node_total_complexity + (cRep0Complexity + rep_match_index);
|
959
|
+
for (uint l = match_hist_min_match_len; l <= hist_match_len; l++)
|
960
|
+
{
|
961
|
+
#if LZHAM_VERIFY_MATCH_COSTS
|
962
|
+
{
|
963
|
+
lzdecision actual_dec(cur_dict_ofs, l, -((int)rep_match_index + 1));
|
964
|
+
bit_cost_t actual_cost = approx_state.get_cost(*this, m_accel, actual_dec);
|
965
|
+
LZHAM_ASSERT(actual_cost == lzdec_bitcosts[l]);
|
966
|
+
}
|
967
|
+
#endif
|
968
|
+
node& dst_node = pCur_node[l];
|
969
|
+
|
970
|
+
bit_cost_t rep_match_total_cost = cur_node_total_cost + lzdec_bitcosts[l];
|
971
|
+
|
972
|
+
dst_node.add_state(cur_node_index, cur_node_state_index, lzdecision(cur_dict_ofs, l, -((int)rep_match_index + 1)), approx_state, rep_match_total_cost, rep_match_total_complexity, parse_state.m_max_parse_node_states);
|
973
|
+
pMax_node_in_graph = LZHAM_MAX(pMax_node_in_graph, &dst_node);
|
974
|
+
}
|
975
|
+
}
|
976
|
+
|
977
|
+
match_hist_min_match_len = CLZBase::cMinMatchLen;
|
978
|
+
}
|
979
|
+
|
980
|
+
if (match_hist_max_len >= m_fast_bytes)
|
981
|
+
{
|
982
|
+
ahead_bytes = match_hist_max_len;
|
983
|
+
break;
|
984
|
+
}
|
985
|
+
|
986
|
+
uint min_truncate_match_len = match_hist_max_len;
|
987
|
+
|
988
|
+
// nearest len2 match
|
989
|
+
if (len2_match_dist)
|
990
|
+
{
|
991
|
+
lzdecision lzdec(cur_dict_ofs, 2, len2_match_dist);
|
992
|
+
bit_cost_t actual_cost = approx_state.get_cost(*this, m_accel, lzdec);
|
993
|
+
pCur_node[2].add_state(cur_node_index, cur_node_state_index, lzdec, approx_state, cur_node_total_cost + actual_cost, cur_node_total_complexity + cShortMatchComplexity, parse_state.m_max_parse_node_states);
|
994
|
+
pMax_node_in_graph = LZHAM_MAX(pMax_node_in_graph, &pCur_node[2]);
|
995
|
+
|
996
|
+
min_truncate_match_len = LZHAM_MAX(min_truncate_match_len, 2);
|
997
|
+
}
|
998
|
+
|
999
|
+
// full matches
|
1000
|
+
if (max_full_match_len > min_truncate_match_len)
|
1001
|
+
{
|
1002
|
+
uint prev_max_match_len = LZHAM_MAX(1, min_truncate_match_len);
|
1003
|
+
for (uint full_match_index = 0; full_match_index < num_full_matches; full_match_index++)
|
1004
|
+
{
|
1005
|
+
uint end_len = match_lens[full_match_index];
|
1006
|
+
if (end_len <= min_truncate_match_len)
|
1007
|
+
continue;
|
1008
|
+
|
1009
|
+
uint start_len = prev_max_match_len + 1;
|
1010
|
+
uint match_dist = match_distances[full_match_index];
|
1011
|
+
|
1012
|
+
LZHAM_ASSERT(start_len <= end_len);
|
1013
|
+
|
1014
|
+
approx_state.get_full_match_costs(*this, cur_dict_ofs, lzdec_bitcosts, match_dist, start_len, end_len, is_match_model_index);
|
1015
|
+
|
1016
|
+
for (uint l = start_len; l <= end_len; l++)
|
1017
|
+
{
|
1018
|
+
uint match_complexity = (l >= cLongMatchComplexityLenThresh) ? cLongMatchComplexity : cShortMatchComplexity;
|
1019
|
+
|
1020
|
+
#if LZHAM_VERIFY_MATCH_COSTS
|
1021
|
+
{
|
1022
|
+
lzdecision actual_dec(cur_dict_ofs, l, match_dist);
|
1023
|
+
bit_cost_t actual_cost = approx_state.get_cost(*this, m_accel, actual_dec);
|
1024
|
+
LZHAM_ASSERT(actual_cost == lzdec_bitcosts[l]);
|
1025
|
+
}
|
1026
|
+
#endif
|
1027
|
+
node& dst_node = pCur_node[l];
|
1028
|
+
|
1029
|
+
bit_cost_t match_total_cost = cur_node_total_cost + lzdec_bitcosts[l];
|
1030
|
+
uint match_total_complexity = cur_node_total_complexity + match_complexity;
|
1031
|
+
|
1032
|
+
dst_node.add_state( cur_node_index, cur_node_state_index, lzdecision(cur_dict_ofs, l, match_dist), approx_state, match_total_cost, match_total_complexity, parse_state.m_max_parse_node_states);
|
1033
|
+
pMax_node_in_graph = LZHAM_MAX(pMax_node_in_graph, &dst_node);
|
1034
|
+
}
|
1035
|
+
|
1036
|
+
prev_max_match_len = end_len;
|
1037
|
+
}
|
1038
|
+
|
1039
|
+
if (max_full_match_len >= m_fast_bytes)
|
1040
|
+
{
|
1041
|
+
ahead_bytes = max_full_match_len;
|
1042
|
+
break;
|
1043
|
+
}
|
1044
|
+
}
|
1045
|
+
|
1046
|
+
// literal
|
1047
|
+
bit_cost_t lit_cost = approx_state.get_lit_cost(*this, m_accel, cur_dict_ofs, lit_pred0, is_match_model_index);
|
1048
|
+
bit_cost_t lit_total_cost = cur_node_total_cost + lit_cost;
|
1049
|
+
uint lit_total_complexity = cur_node_total_complexity + cLitComplexity;
|
1050
|
+
#if LZHAM_VERIFY_MATCH_COSTS
|
1051
|
+
{
|
1052
|
+
lzdecision actual_dec(cur_dict_ofs, 0, 0);
|
1053
|
+
bit_cost_t actual_cost = approx_state.get_cost(*this, m_accel, actual_dec);
|
1054
|
+
LZHAM_ASSERT(actual_cost == lit_cost);
|
1055
|
+
}
|
1056
|
+
#endif
|
1057
|
+
|
1058
|
+
pCur_node[1].add_state(cur_node_index, cur_node_state_index, lzdecision(cur_dict_ofs, 0, 0), approx_state, lit_total_cost, lit_total_complexity, parse_state.m_max_parse_node_states);
|
1059
|
+
pMax_node_in_graph = LZHAM_MAX(pMax_node_in_graph, &pCur_node[1]);
|
1060
|
+
|
1061
|
+
} // cur_node_state_index
|
1062
|
+
|
1063
|
+
cur_dict_ofs += ahead_bytes;
|
1064
|
+
cur_lookahead_ofs += ahead_bytes;
|
1065
|
+
cur_node_index += ahead_bytes;
|
1066
|
+
}
|
1067
|
+
|
1068
|
+
LZHAM_ASSERT(static_cast<int>(cur_node_index) == (pMax_node_in_graph - pNodes));
|
1069
|
+
uint bytes_actually_parsed = cur_node_index;
|
1070
|
+
|
1071
|
+
// Now get the optimal decisions by starting from the goal node.
|
1072
|
+
// m_best_decisions is filled backwards.
|
1073
|
+
if (!parse_state.m_best_decisions.try_reserve(bytes_actually_parsed))
|
1074
|
+
{
|
1075
|
+
parse_state.m_failed = true;
|
1076
|
+
|
1077
|
+
for (uint i = 0; i <= bytes_actually_parsed; i++)
|
1078
|
+
pNodes[i].clear();
|
1079
|
+
|
1080
|
+
LZHAM_LOG_ERROR(7036);
|
1081
|
+
|
1082
|
+
return false;
|
1083
|
+
}
|
1084
|
+
|
1085
|
+
bit_cost_t lowest_final_cost = cBitCostMax; //math::cNearlyInfinite;
|
1086
|
+
int node_state_index = 0;
|
1087
|
+
node_state *pLast_node_states = pNodes[bytes_actually_parsed].m_node_states;
|
1088
|
+
for (uint i = 0; i < pNodes[bytes_actually_parsed].m_num_node_states; i++)
|
1089
|
+
{
|
1090
|
+
if (pLast_node_states[i].m_total_cost < lowest_final_cost)
|
1091
|
+
{
|
1092
|
+
lowest_final_cost = pLast_node_states[i].m_total_cost;
|
1093
|
+
node_state_index = i;
|
1094
|
+
}
|
1095
|
+
}
|
1096
|
+
|
1097
|
+
int node_index = bytes_actually_parsed;
|
1098
|
+
lzdecision *pDst_dec = parse_state.m_best_decisions.get_ptr();
|
1099
|
+
do
|
1100
|
+
{
|
1101
|
+
LZHAM_ASSERT((node_index >= 0) && (node_index <= (int)cMaxParseGraphNodes));
|
1102
|
+
|
1103
|
+
node& cur_node = pNodes[node_index];
|
1104
|
+
const node_state &cur_node_state = cur_node.m_node_states[node_state_index];
|
1105
|
+
|
1106
|
+
*pDst_dec++ = cur_node_state.m_lzdec;
|
1107
|
+
|
1108
|
+
node_index = cur_node_state.m_parent_index;
|
1109
|
+
node_state_index = cur_node_state.m_parent_state_index;
|
1110
|
+
|
1111
|
+
} while (node_index > 0);
|
1112
|
+
|
1113
|
+
parse_state.m_best_decisions.try_resize_no_construct(static_cast<uint>(pDst_dec - parse_state.m_best_decisions.get_ptr()));
|
1114
|
+
parse_state.m_bytes_actually_parsed = bytes_actually_parsed;
|
1115
|
+
|
1116
|
+
for (uint i = 0; i <= bytes_actually_parsed; i++)
|
1117
|
+
pNodes[i].clear();
|
1118
|
+
|
1119
|
+
return true;
|
1120
|
+
}
|
1121
|
+
|
1122
|
+
// Parsing notes:
|
1123
|
+
// The regular "optimal" parser only tracks the single cheapest candidate LZ decision per lookahead character.
|
1124
|
+
// This function finds the shortest path through an extremely dense node graph using a streamlined/simplified Dijkstra's algorithm with some coding heuristics.
|
1125
|
+
// Graph edges are LZ "decisions", cost is measured in fractional bits needed to code each graph edge, and graph nodes are lookahead characters.
|
1126
|
+
// There is no need to track visited/unvisted nodes, or find the next cheapest unvisted node in each iteration. The search always proceeds sequentially, visiting each lookahead character in turn from left/right.
|
1127
|
+
// The major CPU expense of this function is the complexity of LZ decision cost evaluation, so a lot of implementation effort is spent here reducing this overhead.
|
1128
|
+
// To simplify the problem, it assumes the input statistics are locally stationary over the input block to parse. (Otherwise, it would need to store, track, and update
|
1129
|
+
// unique symbol statistics for each lookahead character, which would be very costly.)
|
1130
|
+
// This function always sequentially pushes "forward" the unvisited node horizon. This horizon frequently collapses to a single node, which guarantees that the shortest path through the
|
1131
|
+
// graph must pass through this node. LZMA tracks cumulative bitprices relative to this node, while LZHAM currently always tracks cumulative bitprices relative to the first node in the lookahead buffer.
|
1132
|
+
// In very early versions of LZHAM the parse was much more understandable (straight Dijkstra with almost no bit price optimizations or coding heuristics).
|
1133
|
+
bool lzcompressor::optimal_parse(parse_thread_state &parse_state)
|
1134
|
+
{
|
1135
|
+
LZHAM_ASSERT(parse_state.m_bytes_to_match <= cMaxParseGraphNodes);
|
1136
|
+
|
1137
|
+
parse_state.m_failed = false;
|
1138
|
+
parse_state.m_emit_decisions_backwards = true;
|
1139
|
+
|
1140
|
+
node_state *pNodes = reinterpret_cast<node_state*>(parse_state.m_nodes);
|
1141
|
+
pNodes[0].m_parent_index = -1;
|
1142
|
+
pNodes[0].m_total_cost = 0;
|
1143
|
+
pNodes[0].m_total_complexity = 0;
|
1144
|
+
|
1145
|
+
#ifdef LZHAM_BUILD_DEBUG
|
1146
|
+
for (uint i = 1; i < (cMaxParseGraphNodes + 1); i++)
|
1147
|
+
{
|
1148
|
+
LZHAM_ASSERT(pNodes[i].m_total_cost == cUINT64_MAX);
|
1149
|
+
LZHAM_ASSERT(pNodes[i].m_total_complexity == UINT_MAX);
|
1150
|
+
LZHAM_ASSERT(pNodes[i].m_parent_index == -1);
|
1151
|
+
}
|
1152
|
+
#endif
|
1153
|
+
|
1154
|
+
state &approx_state = *parse_state.m_pState;
|
1155
|
+
|
1156
|
+
const uint bytes_to_parse = parse_state.m_bytes_to_match;
|
1157
|
+
|
1158
|
+
const uint lookahead_start_ofs = m_accel.get_lookahead_pos() & m_accel.get_max_dict_size_mask();
|
1159
|
+
|
1160
|
+
uint cur_dict_ofs = parse_state.m_start_ofs;
|
1161
|
+
uint cur_lookahead_ofs = cur_dict_ofs - lookahead_start_ofs;
|
1162
|
+
uint cur_node_index = 0;
|
1163
|
+
|
1164
|
+
enum { cMaxFullMatches = cMatchAccelMaxSupportedProbes };
|
1165
|
+
uint match_lens[cMaxFullMatches];
|
1166
|
+
uint match_distances[cMaxFullMatches];
|
1167
|
+
|
1168
|
+
bit_cost_t lzdec_bitcosts[cMaxMatchLen + 1];
|
1169
|
+
|
1170
|
+
node_state *pMax_node_in_graph = &pNodes[0];
|
1171
|
+
|
1172
|
+
while (cur_node_index < bytes_to_parse)
|
1173
|
+
{
|
1174
|
+
node_state* pCur_node = &pNodes[cur_node_index];
|
1175
|
+
|
1176
|
+
if ((cur_node_index >= parse_state.m_parse_early_out_thresh) && (pCur_node == pMax_node_in_graph))
|
1177
|
+
{
|
1178
|
+
// If the best path *must* pass through this node, and we're far enough along, and we're parsing using a single thread, then exit so we can move all our state forward.
|
1179
|
+
break;
|
1180
|
+
}
|
1181
|
+
|
1182
|
+
const uint max_admissable_match_len = LZHAM_MIN(static_cast<uint>(CLZBase::cMaxMatchLen), bytes_to_parse - cur_node_index);
|
1183
|
+
const uint find_dict_size = m_accel.m_cur_dict_size + cur_lookahead_ofs;
|
1184
|
+
|
1185
|
+
if (cur_node_index)
|
1186
|
+
{
|
1187
|
+
LZHAM_ASSERT(pCur_node->m_parent_index >= 0);
|
1188
|
+
|
1189
|
+
// Move to this node's state using the lowest cost LZ decision found.
|
1190
|
+
approx_state.restore_partial_state(pCur_node->m_saved_state);
|
1191
|
+
approx_state.partial_advance(pCur_node->m_lzdec);
|
1192
|
+
}
|
1193
|
+
|
1194
|
+
const bit_cost_t cur_node_total_cost = pCur_node->m_total_cost;
|
1195
|
+
// This assert includes a fudge factor - make sure we don't overflow our scaled costs.
|
1196
|
+
LZHAM_ASSERT((cBitCostMax - cur_node_total_cost) > (cBitCostScale * 64));
|
1197
|
+
const uint cur_node_total_complexity = pCur_node->m_total_complexity;
|
1198
|
+
|
1199
|
+
const uint lit_pred0 = approx_state.get_pred_char(m_accel, cur_dict_ofs, 1);
|
1200
|
+
uint is_match_model_index = LZHAM_IS_MATCH_MODEL_INDEX(approx_state.m_cur_state);
|
1201
|
+
|
1202
|
+
const uint8* pLookahead = &m_accel.m_dict[cur_dict_ofs];
|
1203
|
+
|
1204
|
+
// rep matches
|
1205
|
+
uint match_hist_max_len = 0;
|
1206
|
+
uint match_hist_min_match_len = 1;
|
1207
|
+
for (uint rep_match_index = 0; rep_match_index < cMatchHistSize; rep_match_index++)
|
1208
|
+
{
|
1209
|
+
uint hist_match_len = 0;
|
1210
|
+
|
1211
|
+
uint dist = approx_state.m_match_hist[rep_match_index];
|
1212
|
+
if (dist <= find_dict_size)
|
1213
|
+
{
|
1214
|
+
const uint comp_pos = static_cast<uint>((m_accel.m_lookahead_pos + cur_lookahead_ofs - dist) & m_accel.m_max_dict_size_mask);
|
1215
|
+
const uint8* pComp = &m_accel.m_dict[comp_pos];
|
1216
|
+
|
1217
|
+
for (hist_match_len = 0; hist_match_len < max_admissable_match_len; hist_match_len++)
|
1218
|
+
if (pComp[hist_match_len] != pLookahead[hist_match_len])
|
1219
|
+
break;
|
1220
|
+
}
|
1221
|
+
|
1222
|
+
if (hist_match_len >= match_hist_min_match_len)
|
1223
|
+
{
|
1224
|
+
match_hist_max_len = math::maximum(match_hist_max_len, hist_match_len);
|
1225
|
+
|
1226
|
+
approx_state.get_rep_match_costs(cur_dict_ofs, lzdec_bitcosts, rep_match_index, match_hist_min_match_len, hist_match_len, is_match_model_index);
|
1227
|
+
|
1228
|
+
uint rep_match_total_complexity = cur_node_total_complexity + (cRep0Complexity + rep_match_index);
|
1229
|
+
for (uint l = match_hist_min_match_len; l <= hist_match_len; l++)
|
1230
|
+
{
|
1231
|
+
#if LZHAM_VERIFY_MATCH_COSTS
|
1232
|
+
{
|
1233
|
+
lzdecision actual_dec(cur_dict_ofs, l, -((int)rep_match_index + 1));
|
1234
|
+
bit_cost_t actual_cost = approx_state.get_cost(*this, m_accel, actual_dec);
|
1235
|
+
LZHAM_ASSERT(actual_cost == lzdec_bitcosts[l]);
|
1236
|
+
}
|
1237
|
+
#endif
|
1238
|
+
node_state& dst_node = pCur_node[l];
|
1239
|
+
|
1240
|
+
bit_cost_t rep_match_total_cost = cur_node_total_cost + lzdec_bitcosts[l];
|
1241
|
+
|
1242
|
+
if ((rep_match_total_cost > dst_node.m_total_cost) || ((rep_match_total_cost == dst_node.m_total_cost) && (rep_match_total_complexity >= dst_node.m_total_complexity)))
|
1243
|
+
continue;
|
1244
|
+
|
1245
|
+
dst_node.m_total_cost = rep_match_total_cost;
|
1246
|
+
dst_node.m_total_complexity = rep_match_total_complexity;
|
1247
|
+
dst_node.m_parent_index = (uint16)cur_node_index;
|
1248
|
+
approx_state.save_partial_state(dst_node.m_saved_state);
|
1249
|
+
dst_node.m_lzdec.init(cur_dict_ofs, l, -((int)rep_match_index + 1));
|
1250
|
+
dst_node.m_lzdec.m_len = l;
|
1251
|
+
|
1252
|
+
pMax_node_in_graph = LZHAM_MAX(pMax_node_in_graph, &dst_node);
|
1253
|
+
}
|
1254
|
+
}
|
1255
|
+
|
1256
|
+
match_hist_min_match_len = CLZBase::cMinMatchLen;
|
1257
|
+
}
|
1258
|
+
|
1259
|
+
uint max_match_len = match_hist_max_len;
|
1260
|
+
|
1261
|
+
if (max_match_len >= m_fast_bytes)
|
1262
|
+
{
|
1263
|
+
cur_dict_ofs += max_match_len;
|
1264
|
+
cur_lookahead_ofs += max_match_len;
|
1265
|
+
cur_node_index += max_match_len;
|
1266
|
+
continue;
|
1267
|
+
}
|
1268
|
+
|
1269
|
+
// full matches
|
1270
|
+
if (max_admissable_match_len >= CLZBase::cMinMatchLen)
|
1271
|
+
{
|
1272
|
+
uint num_full_matches = 0;
|
1273
|
+
|
1274
|
+
if (match_hist_max_len < 2)
|
1275
|
+
{
|
1276
|
+
// Get the nearest len2 match if we didn't find a rep len2.
|
1277
|
+
uint len2_match_dist = m_accel.get_len2_match(cur_lookahead_ofs);
|
1278
|
+
if (len2_match_dist)
|
1279
|
+
{
|
1280
|
+
bit_cost_t cost = approx_state.get_len2_match_cost(*this, cur_dict_ofs, len2_match_dist, is_match_model_index);
|
1281
|
+
|
1282
|
+
#if LZHAM_VERIFY_MATCH_COSTS
|
1283
|
+
{
|
1284
|
+
lzdecision actual_dec(cur_dict_ofs, 2, len2_match_dist);
|
1285
|
+
bit_cost_t actual_cost = approx_state.get_cost(*this, m_accel, actual_dec);
|
1286
|
+
LZHAM_ASSERT(actual_cost == cost);
|
1287
|
+
}
|
1288
|
+
#endif
|
1289
|
+
|
1290
|
+
node_state& dst_node = pCur_node[2];
|
1291
|
+
|
1292
|
+
bit_cost_t match_total_cost = cur_node_total_cost + cost;
|
1293
|
+
uint match_total_complexity = cur_node_total_complexity + cShortMatchComplexity;
|
1294
|
+
|
1295
|
+
if ((match_total_cost < dst_node.m_total_cost) || ((match_total_cost == dst_node.m_total_cost) && (match_total_complexity < dst_node.m_total_complexity)))
|
1296
|
+
{
|
1297
|
+
dst_node.m_total_cost = match_total_cost;
|
1298
|
+
dst_node.m_total_complexity = match_total_complexity;
|
1299
|
+
dst_node.m_parent_index = (uint16)cur_node_index;
|
1300
|
+
approx_state.save_partial_state(dst_node.m_saved_state);
|
1301
|
+
dst_node.m_lzdec.init(cur_dict_ofs, 2, len2_match_dist);
|
1302
|
+
|
1303
|
+
pMax_node_in_graph = LZHAM_MAX(pMax_node_in_graph, &dst_node);
|
1304
|
+
}
|
1305
|
+
|
1306
|
+
max_match_len = 2;
|
1307
|
+
}
|
1308
|
+
}
|
1309
|
+
|
1310
|
+
const uint min_truncate_match_len = max_match_len;
|
1311
|
+
|
1312
|
+
// Now get all full matches: the nearest matches at each match length. (Actually, we don't
|
1313
|
+
// always get the nearest match. The match finder favors those matches which have the lowest value
|
1314
|
+
// in the nibble of each match distance, all other things being equal, to help exploit how the lowest
|
1315
|
+
// nibble of match distances is separately coded.)
|
1316
|
+
const dict_match* pMatches = m_accel.find_matches(cur_lookahead_ofs);
|
1317
|
+
if (pMatches)
|
1318
|
+
{
|
1319
|
+
for ( ; ; )
|
1320
|
+
{
|
1321
|
+
uint match_len = pMatches->get_len();
|
1322
|
+
LZHAM_ASSERT((pMatches->get_dist() > 0) && (pMatches->get_dist() <= m_dict_size));
|
1323
|
+
match_len = LZHAM_MIN(match_len, max_admissable_match_len);
|
1324
|
+
|
1325
|
+
if (match_len > max_match_len)
|
1326
|
+
{
|
1327
|
+
max_match_len = match_len;
|
1328
|
+
|
1329
|
+
match_lens[num_full_matches] = match_len;
|
1330
|
+
match_distances[num_full_matches] = pMatches->get_dist();
|
1331
|
+
num_full_matches++;
|
1332
|
+
}
|
1333
|
+
|
1334
|
+
if (pMatches->is_last())
|
1335
|
+
break;
|
1336
|
+
pMatches++;
|
1337
|
+
}
|
1338
|
+
}
|
1339
|
+
|
1340
|
+
if (num_full_matches)
|
1341
|
+
{
|
1342
|
+
uint prev_max_match_len = LZHAM_MAX(1, min_truncate_match_len);
|
1343
|
+
for (uint full_match_index = 0; full_match_index < num_full_matches; full_match_index++)
|
1344
|
+
{
|
1345
|
+
uint start_len = prev_max_match_len + 1;
|
1346
|
+
uint end_len = match_lens[full_match_index];
|
1347
|
+
uint match_dist = match_distances[full_match_index];
|
1348
|
+
|
1349
|
+
LZHAM_ASSERT(start_len <= end_len);
|
1350
|
+
|
1351
|
+
approx_state.get_full_match_costs(*this, cur_dict_ofs, lzdec_bitcosts, match_dist, start_len, end_len, is_match_model_index);
|
1352
|
+
|
1353
|
+
for (uint l = start_len; l <= end_len; l++)
|
1354
|
+
{
|
1355
|
+
uint match_complexity = (l >= cLongMatchComplexityLenThresh) ? cLongMatchComplexity : cShortMatchComplexity;
|
1356
|
+
|
1357
|
+
#if LZHAM_VERIFY_MATCH_COSTS
|
1358
|
+
{
|
1359
|
+
lzdecision actual_dec(cur_dict_ofs, l, match_dist);
|
1360
|
+
bit_cost_t actual_cost = approx_state.get_cost(*this, m_accel, actual_dec);
|
1361
|
+
LZHAM_ASSERT(actual_cost == lzdec_bitcosts[l]);
|
1362
|
+
}
|
1363
|
+
#endif
|
1364
|
+
node_state& dst_node = pCur_node[l];
|
1365
|
+
|
1366
|
+
bit_cost_t match_total_cost = cur_node_total_cost + lzdec_bitcosts[l];
|
1367
|
+
uint match_total_complexity = cur_node_total_complexity + match_complexity;
|
1368
|
+
|
1369
|
+
if ((match_total_cost > dst_node.m_total_cost) || ((match_total_cost == dst_node.m_total_cost) && (match_total_complexity >= dst_node.m_total_complexity)))
|
1370
|
+
continue;
|
1371
|
+
|
1372
|
+
dst_node.m_total_cost = match_total_cost;
|
1373
|
+
dst_node.m_total_complexity = match_total_complexity;
|
1374
|
+
dst_node.m_parent_index = (uint16)cur_node_index;
|
1375
|
+
approx_state.save_partial_state(dst_node.m_saved_state);
|
1376
|
+
dst_node.m_lzdec.init(cur_dict_ofs, l, match_dist);
|
1377
|
+
|
1378
|
+
pMax_node_in_graph = LZHAM_MAX(pMax_node_in_graph, &dst_node);
|
1379
|
+
}
|
1380
|
+
|
1381
|
+
prev_max_match_len = end_len;
|
1382
|
+
}
|
1383
|
+
}
|
1384
|
+
}
|
1385
|
+
|
1386
|
+
if (max_match_len >= m_fast_bytes)
|
1387
|
+
{
|
1388
|
+
cur_dict_ofs += max_match_len;
|
1389
|
+
cur_lookahead_ofs += max_match_len;
|
1390
|
+
cur_node_index += max_match_len;
|
1391
|
+
continue;
|
1392
|
+
}
|
1393
|
+
|
1394
|
+
// literal
|
1395
|
+
bit_cost_t lit_cost = approx_state.get_lit_cost(*this, m_accel, cur_dict_ofs, lit_pred0, is_match_model_index);
|
1396
|
+
bit_cost_t lit_total_cost = cur_node_total_cost + lit_cost;
|
1397
|
+
uint lit_total_complexity = cur_node_total_complexity + cLitComplexity;
|
1398
|
+
#if LZHAM_VERIFY_MATCH_COSTS
|
1399
|
+
{
|
1400
|
+
lzdecision actual_dec(cur_dict_ofs, 0, 0);
|
1401
|
+
bit_cost_t actual_cost = approx_state.get_cost(*this, m_accel, actual_dec);
|
1402
|
+
LZHAM_ASSERT(actual_cost == lit_cost);
|
1403
|
+
}
|
1404
|
+
#endif
|
1405
|
+
if ((lit_total_cost < pCur_node[1].m_total_cost) || ((lit_total_cost == pCur_node[1].m_total_cost) && (lit_total_complexity < pCur_node[1].m_total_complexity)))
|
1406
|
+
{
|
1407
|
+
pCur_node[1].m_total_cost = lit_total_cost;
|
1408
|
+
pCur_node[1].m_total_complexity = lit_total_complexity;
|
1409
|
+
pCur_node[1].m_parent_index = (int16)cur_node_index;
|
1410
|
+
approx_state.save_partial_state(pCur_node[1].m_saved_state);
|
1411
|
+
pCur_node[1].m_lzdec.init(cur_dict_ofs, 0, 0);
|
1412
|
+
|
1413
|
+
pMax_node_in_graph = LZHAM_MAX(pMax_node_in_graph, &pCur_node[1]);
|
1414
|
+
}
|
1415
|
+
|
1416
|
+
cur_dict_ofs++;
|
1417
|
+
cur_lookahead_ofs++;
|
1418
|
+
cur_node_index++;
|
1419
|
+
|
1420
|
+
} // graph search
|
1421
|
+
|
1422
|
+
LZHAM_ASSERT(static_cast<int>(cur_node_index) == (pMax_node_in_graph - pNodes));
|
1423
|
+
uint bytes_actually_parsed = cur_node_index;
|
1424
|
+
|
1425
|
+
// Now get the optimal decisions by starting from the goal node.
|
1426
|
+
// m_best_decisions is filled backwards.
|
1427
|
+
if (!parse_state.m_best_decisions.try_reserve(bytes_actually_parsed))
|
1428
|
+
{
|
1429
|
+
parse_state.m_failed = true;
|
1430
|
+
|
1431
|
+
memset(pNodes, 0xFF, (pMax_node_in_graph - pNodes + 1) * sizeof(node_state));
|
1432
|
+
|
1433
|
+
LZHAM_LOG_ERROR(7037);
|
1434
|
+
|
1435
|
+
return false;
|
1436
|
+
}
|
1437
|
+
|
1438
|
+
int node_index = bytes_actually_parsed;
|
1439
|
+
lzdecision *pDst_dec = parse_state.m_best_decisions.get_ptr();
|
1440
|
+
do
|
1441
|
+
{
|
1442
|
+
LZHAM_ASSERT((node_index >= 0) && (node_index <= (int)cMaxParseGraphNodes));
|
1443
|
+
node_state& cur_node = pNodes[node_index];
|
1444
|
+
|
1445
|
+
*pDst_dec++ = cur_node.m_lzdec;
|
1446
|
+
|
1447
|
+
node_index = cur_node.m_parent_index;
|
1448
|
+
|
1449
|
+
} while (node_index > 0);
|
1450
|
+
|
1451
|
+
parse_state.m_best_decisions.try_resize_no_construct(static_cast<uint>(pDst_dec - parse_state.m_best_decisions.get_ptr()));
|
1452
|
+
|
1453
|
+
parse_state.m_bytes_actually_parsed = bytes_actually_parsed;
|
1454
|
+
|
1455
|
+
memset(pNodes, 0xFF, (pMax_node_in_graph - pNodes + 1) * sizeof(node_state));
|
1456
|
+
|
1457
|
+
return true;
|
1458
|
+
}
|
1459
|
+
|
1460
|
+
void lzcompressor::parse_job_callback(uint64 data, void* pData_ptr)
|
1461
|
+
{
|
1462
|
+
const uint parse_job_index = (uint)data;
|
1463
|
+
parse_thread_state &parse_state = m_parse_thread_state[parse_job_index];
|
1464
|
+
|
1465
|
+
scoped_perf_section parse_job_timer(cVarArgs, "parse_job_callback %u", parse_job_index);
|
1466
|
+
|
1467
|
+
LZHAM_NOTE_UNUSED(pData_ptr);
|
1468
|
+
|
1469
|
+
if (m_use_extreme_parsing)
|
1470
|
+
extreme_parse(parse_state);
|
1471
|
+
else
|
1472
|
+
optimal_parse(parse_state);
|
1473
|
+
|
1474
|
+
if (parse_state.m_use_semaphore)
|
1475
|
+
{
|
1476
|
+
parse_state.m_finished.release();
|
1477
|
+
}
|
1478
|
+
}
|
1479
|
+
|
1480
|
+
// ofs is the absolute dictionary offset, must be >= the lookahead offset.
|
1481
|
+
// TODO: Doesn't find len2 matches
|
1482
|
+
int lzcompressor::enumerate_lz_decisions(uint ofs, const state& cur_state, lzham::vector<lzpriced_decision>& decisions, uint min_match_len, uint max_match_len)
|
1483
|
+
{
|
1484
|
+
LZHAM_ASSERT(min_match_len >= 1);
|
1485
|
+
|
1486
|
+
uint start_ofs = m_accel.get_lookahead_pos() & m_accel.get_max_dict_size_mask();
|
1487
|
+
LZHAM_ASSERT(ofs >= start_ofs);
|
1488
|
+
const uint lookahead_ofs = ofs - start_ofs;
|
1489
|
+
|
1490
|
+
uint largest_index = 0;
|
1491
|
+
uint largest_len;
|
1492
|
+
bit_cost_t largest_cost;
|
1493
|
+
|
1494
|
+
if (min_match_len <= 1)
|
1495
|
+
{
|
1496
|
+
if (!decisions.try_resize(1))
|
1497
|
+
{
|
1498
|
+
LZHAM_LOG_ERROR(7038);
|
1499
|
+
return -1;
|
1500
|
+
}
|
1501
|
+
|
1502
|
+
lzpriced_decision& lit_dec = decisions[0];
|
1503
|
+
lit_dec.init(ofs, 0, 0, 0);
|
1504
|
+
lit_dec.m_cost = cur_state.get_cost(*this, m_accel, lit_dec);
|
1505
|
+
largest_cost = lit_dec.m_cost;
|
1506
|
+
|
1507
|
+
largest_len = 1;
|
1508
|
+
}
|
1509
|
+
else
|
1510
|
+
{
|
1511
|
+
if (!decisions.try_resize(0))
|
1512
|
+
{
|
1513
|
+
LZHAM_LOG_ERROR(7039);
|
1514
|
+
return -1;
|
1515
|
+
}
|
1516
|
+
|
1517
|
+
largest_len = 0;
|
1518
|
+
largest_cost = cBitCostMax;
|
1519
|
+
}
|
1520
|
+
|
1521
|
+
uint match_hist_max_len = 0;
|
1522
|
+
|
1523
|
+
// Add rep matches.
|
1524
|
+
for (uint i = 0; i < cMatchHistSize; i++)
|
1525
|
+
{
|
1526
|
+
uint hist_match_len = m_accel.get_match_len(lookahead_ofs, cur_state.m_match_hist[i], max_match_len);
|
1527
|
+
if (hist_match_len < min_match_len)
|
1528
|
+
continue;
|
1529
|
+
|
1530
|
+
if ( ((hist_match_len == 1) && (i == 0)) || (hist_match_len >= CLZBase::cMinMatchLen) )
|
1531
|
+
{
|
1532
|
+
match_hist_max_len = math::maximum(match_hist_max_len, hist_match_len);
|
1533
|
+
|
1534
|
+
lzpriced_decision dec(ofs, hist_match_len, -((int)i + 1));
|
1535
|
+
dec.m_cost = cur_state.get_cost(*this, m_accel, dec);
|
1536
|
+
|
1537
|
+
if (!decisions.try_push_back(dec))
|
1538
|
+
{
|
1539
|
+
LZHAM_LOG_ERROR(7040);
|
1540
|
+
return -1;
|
1541
|
+
}
|
1542
|
+
|
1543
|
+
if ( (hist_match_len > largest_len) || ((hist_match_len == largest_len) && (dec.m_cost < largest_cost)) )
|
1544
|
+
{
|
1545
|
+
largest_index = decisions.size() - 1;
|
1546
|
+
largest_len = hist_match_len;
|
1547
|
+
largest_cost = dec.m_cost;
|
1548
|
+
}
|
1549
|
+
}
|
1550
|
+
}
|
1551
|
+
|
1552
|
+
// Now add full matches.
|
1553
|
+
if ((max_match_len >= CLZBase::cMinMatchLen) && (match_hist_max_len < m_fast_bytes))
|
1554
|
+
{
|
1555
|
+
const dict_match* pMatches = m_accel.find_matches(lookahead_ofs);
|
1556
|
+
|
1557
|
+
if (pMatches)
|
1558
|
+
{
|
1559
|
+
for ( ; ; )
|
1560
|
+
{
|
1561
|
+
uint match_len = math::minimum(pMatches->get_len(), max_match_len);
|
1562
|
+
LZHAM_ASSERT((pMatches->get_dist() > 0) && (pMatches->get_dist() <= m_dict_size));
|
1563
|
+
|
1564
|
+
// Full matches are very likely to be more expensive than rep matches of the same length, so don't bother evaluating them.
|
1565
|
+
if ((match_len >= min_match_len) && (match_len > match_hist_max_len))
|
1566
|
+
{
|
1567
|
+
if ((max_match_len > CLZBase::cMaxMatchLen) && (match_len == CLZBase::cMaxMatchLen))
|
1568
|
+
{
|
1569
|
+
match_len = m_accel.get_match_len(lookahead_ofs, pMatches->get_dist(), max_match_len, CLZBase::cMaxMatchLen);
|
1570
|
+
}
|
1571
|
+
|
1572
|
+
lzpriced_decision dec(ofs, match_len, pMatches->get_dist());
|
1573
|
+
dec.m_cost = cur_state.get_cost(*this, m_accel, dec);
|
1574
|
+
|
1575
|
+
if (!decisions.try_push_back(dec))
|
1576
|
+
{
|
1577
|
+
LZHAM_LOG_ERROR(7041);
|
1578
|
+
return -1;
|
1579
|
+
}
|
1580
|
+
|
1581
|
+
if ( (match_len > largest_len) || ((match_len == largest_len) && (dec.get_cost() < largest_cost)) )
|
1582
|
+
{
|
1583
|
+
largest_index = decisions.size() - 1;
|
1584
|
+
largest_len = match_len;
|
1585
|
+
largest_cost = dec.get_cost();
|
1586
|
+
}
|
1587
|
+
}
|
1588
|
+
if (pMatches->is_last())
|
1589
|
+
break;
|
1590
|
+
pMatches++;
|
1591
|
+
}
|
1592
|
+
}
|
1593
|
+
}
|
1594
|
+
|
1595
|
+
return largest_index;
|
1596
|
+
}
|
1597
|
+
|
1598
|
+
bool lzcompressor::greedy_parse(parse_thread_state &parse_state)
|
1599
|
+
{
|
1600
|
+
parse_state.m_failed = true;
|
1601
|
+
parse_state.m_emit_decisions_backwards = false;
|
1602
|
+
|
1603
|
+
const uint bytes_to_parse = parse_state.m_bytes_to_match;
|
1604
|
+
|
1605
|
+
const uint lookahead_start_ofs = m_accel.get_lookahead_pos() & m_accel.get_max_dict_size_mask();
|
1606
|
+
|
1607
|
+
uint cur_dict_ofs = parse_state.m_start_ofs;
|
1608
|
+
uint cur_lookahead_ofs = cur_dict_ofs - lookahead_start_ofs;
|
1609
|
+
uint cur_ofs = 0;
|
1610
|
+
|
1611
|
+
state &approx_state = *parse_state.m_pState;
|
1612
|
+
|
1613
|
+
lzham::vector<lzpriced_decision> &decisions = parse_state.m_temp_decisions;
|
1614
|
+
|
1615
|
+
if (!decisions.try_reserve(384))
|
1616
|
+
{
|
1617
|
+
LZHAM_LOG_ERROR(7042);
|
1618
|
+
return false;
|
1619
|
+
}
|
1620
|
+
|
1621
|
+
if (!parse_state.m_best_decisions.try_resize(0))
|
1622
|
+
{
|
1623
|
+
LZHAM_LOG_ERROR(7043);
|
1624
|
+
return false;
|
1625
|
+
}
|
1626
|
+
|
1627
|
+
while (cur_ofs < bytes_to_parse)
|
1628
|
+
{
|
1629
|
+
const uint max_admissable_match_len = LZHAM_MIN(static_cast<uint>(CLZBase::cMaxHugeMatchLen), bytes_to_parse - cur_ofs);
|
1630
|
+
|
1631
|
+
int largest_dec_index = enumerate_lz_decisions(cur_dict_ofs, approx_state, decisions, 1, max_admissable_match_len);
|
1632
|
+
if (largest_dec_index < 0)
|
1633
|
+
{
|
1634
|
+
LZHAM_LOG_ERROR(7044);
|
1635
|
+
return false;
|
1636
|
+
}
|
1637
|
+
|
1638
|
+
const lzpriced_decision &dec = decisions[largest_dec_index];
|
1639
|
+
|
1640
|
+
if (!parse_state.m_best_decisions.try_push_back(dec))
|
1641
|
+
{
|
1642
|
+
LZHAM_LOG_ERROR(7045);
|
1643
|
+
return false;
|
1644
|
+
}
|
1645
|
+
|
1646
|
+
approx_state.partial_advance(dec);
|
1647
|
+
|
1648
|
+
uint match_len = dec.get_len();
|
1649
|
+
LZHAM_ASSERT(match_len <= max_admissable_match_len);
|
1650
|
+
cur_dict_ofs += match_len;
|
1651
|
+
cur_lookahead_ofs += match_len;
|
1652
|
+
cur_ofs += match_len;
|
1653
|
+
|
1654
|
+
if (parse_state.m_best_decisions.size() >= parse_state.m_max_greedy_decisions)
|
1655
|
+
{
|
1656
|
+
parse_state.m_greedy_parse_total_bytes_coded = cur_ofs;
|
1657
|
+
parse_state.m_bytes_actually_parsed = cur_ofs;
|
1658
|
+
parse_state.m_greedy_parse_gave_up = true;
|
1659
|
+
return false;
|
1660
|
+
}
|
1661
|
+
}
|
1662
|
+
|
1663
|
+
parse_state.m_greedy_parse_total_bytes_coded = cur_ofs;
|
1664
|
+
|
1665
|
+
LZHAM_ASSERT(cur_ofs == bytes_to_parse);
|
1666
|
+
|
1667
|
+
parse_state.m_failed = false;
|
1668
|
+
parse_state.m_bytes_actually_parsed = parse_state.m_bytes_to_match;
|
1669
|
+
|
1670
|
+
return true;
|
1671
|
+
}
|
1672
|
+
|
1673
|
+
bool lzcompressor::compress_block(const void* pBuf, uint buf_len)
|
1674
|
+
{
|
1675
|
+
uint cur_ofs = 0;
|
1676
|
+
uint bytes_remaining = buf_len;
|
1677
|
+
while (bytes_remaining)
|
1678
|
+
{
|
1679
|
+
uint bytes_to_compress = math::minimum(m_accel.get_max_add_bytes(), bytes_remaining);
|
1680
|
+
if (!compress_block_internal(static_cast<const uint8*>(pBuf) + cur_ofs, bytes_to_compress))
|
1681
|
+
{
|
1682
|
+
LZHAM_LOG_ERROR(7046);
|
1683
|
+
return false;
|
1684
|
+
}
|
1685
|
+
|
1686
|
+
cur_ofs += bytes_to_compress;
|
1687
|
+
bytes_remaining -= bytes_to_compress;
|
1688
|
+
}
|
1689
|
+
return true;
|
1690
|
+
}
|
1691
|
+
|
1692
|
+
bool lzcompressor::compress_block_internal(const void* pBuf, uint buf_len)
|
1693
|
+
{
|
1694
|
+
scoped_perf_section compress_block_timer(cVarArgs, "****** compress_block %u", m_block_index);
|
1695
|
+
|
1696
|
+
LZHAM_ASSERT(pBuf);
|
1697
|
+
LZHAM_ASSERT(buf_len <= m_params.m_block_size);
|
1698
|
+
|
1699
|
+
LZHAM_ASSERT(m_src_size >= 0);
|
1700
|
+
if (m_src_size < 0)
|
1701
|
+
return false;
|
1702
|
+
|
1703
|
+
m_src_size += buf_len;
|
1704
|
+
|
1705
|
+
// Important: Don't do any expensive work until after add_bytes_begin() is called, to increase parallelism.
|
1706
|
+
if (!m_accel.add_bytes_begin(buf_len, static_cast<const uint8*>(pBuf)))
|
1707
|
+
{
|
1708
|
+
LZHAM_LOG_ERROR(7047);
|
1709
|
+
return false;
|
1710
|
+
}
|
1711
|
+
|
1712
|
+
bool computed_adler32 = false;
|
1713
|
+
|
1714
|
+
m_start_of_block_state = m_state;
|
1715
|
+
|
1716
|
+
m_block_start_dict_ofs = m_accel.get_lookahead_pos() & (m_accel.get_max_dict_size() - 1);
|
1717
|
+
|
1718
|
+
uint cur_dict_ofs = m_block_start_dict_ofs;
|
1719
|
+
|
1720
|
+
uint bytes_to_match = buf_len;
|
1721
|
+
|
1722
|
+
if (!m_codec.start_encoding((buf_len * 9) / 8))
|
1723
|
+
{
|
1724
|
+
LZHAM_LOG_ERROR(7048);
|
1725
|
+
return false;
|
1726
|
+
}
|
1727
|
+
|
1728
|
+
if (!m_block_index)
|
1729
|
+
{
|
1730
|
+
if (!send_configuration())
|
1731
|
+
{
|
1732
|
+
LZHAM_LOG_ERROR(7049);
|
1733
|
+
return false;
|
1734
|
+
}
|
1735
|
+
}
|
1736
|
+
|
1737
|
+
#ifdef LZHAM_LZDEBUG
|
1738
|
+
m_codec.encode_bits(166, 12);
|
1739
|
+
#endif
|
1740
|
+
|
1741
|
+
if (!m_codec.encode_bits(cCompBlock, cBlockHeaderBits))
|
1742
|
+
{
|
1743
|
+
LZHAM_LOG_ERROR(7050);
|
1744
|
+
return false;
|
1745
|
+
}
|
1746
|
+
|
1747
|
+
if (!m_codec.encode_arith_init())
|
1748
|
+
{
|
1749
|
+
LZHAM_LOG_ERROR(7051);
|
1750
|
+
return false;
|
1751
|
+
}
|
1752
|
+
|
1753
|
+
m_state.start_of_block(m_accel, cur_dict_ofs, m_block_index);
|
1754
|
+
|
1755
|
+
bool emit_reset_update_rate_command = false;
|
1756
|
+
|
1757
|
+
if (m_params.m_lzham_compress_flags & LZHAM_COMP_FLAG_TRADEOFF_DECOMPRESSION_RATE_FOR_COMP_RATIO)
|
1758
|
+
{
|
1759
|
+
emit_reset_update_rate_command = true;
|
1760
|
+
|
1761
|
+
m_state.reset_update_rate();
|
1762
|
+
}
|
1763
|
+
|
1764
|
+
// TODO: We could also issue a full huff/arith table reset (code 2), and see if that actually improves the block's compression.
|
1765
|
+
m_codec.encode_bits(emit_reset_update_rate_command ? 1 : 0, cBlockFlushTypeBits);
|
1766
|
+
|
1767
|
+
//coding_stats initial_stats(m_stats);
|
1768
|
+
|
1769
|
+
uint initial_step = m_step;
|
1770
|
+
|
1771
|
+
while (bytes_to_match)
|
1772
|
+
{
|
1773
|
+
const uint cAvgAcceptableGreedyMatchLen = 384;
|
1774
|
+
if ((m_params.m_pSeed_bytes) && (bytes_to_match >= cAvgAcceptableGreedyMatchLen))
|
1775
|
+
{
|
1776
|
+
parse_thread_state &greedy_parse_state = m_parse_thread_state[cMaxParseThreads];
|
1777
|
+
|
1778
|
+
greedy_parse_state.m_pState = &greedy_parse_state.m_state;
|
1779
|
+
greedy_parse_state.m_state = m_state;
|
1780
|
+
greedy_parse_state.m_state.m_cur_ofs = cur_dict_ofs;
|
1781
|
+
|
1782
|
+
greedy_parse_state.m_issue_reset_state_partial = false;
|
1783
|
+
greedy_parse_state.m_start_ofs = cur_dict_ofs;
|
1784
|
+
greedy_parse_state.m_bytes_to_match = LZHAM_MIN(bytes_to_match, static_cast<uint>(CLZBase::cMaxHugeMatchLen));
|
1785
|
+
|
1786
|
+
greedy_parse_state.m_max_greedy_decisions = LZHAM_MAX((bytes_to_match / cAvgAcceptableGreedyMatchLen), 2);
|
1787
|
+
greedy_parse_state.m_greedy_parse_gave_up = false;
|
1788
|
+
greedy_parse_state.m_greedy_parse_total_bytes_coded = 0;
|
1789
|
+
|
1790
|
+
greedy_parse_state.m_parse_early_out_thresh = UINT_MAX;
|
1791
|
+
greedy_parse_state.m_bytes_actually_parsed = 0;
|
1792
|
+
|
1793
|
+
greedy_parse_state.m_use_semaphore = false;
|
1794
|
+
|
1795
|
+
if (!greedy_parse(greedy_parse_state))
|
1796
|
+
{
|
1797
|
+
if (!greedy_parse_state.m_greedy_parse_gave_up)
|
1798
|
+
{
|
1799
|
+
LZHAM_LOG_ERROR(7052);
|
1800
|
+
return false;
|
1801
|
+
}
|
1802
|
+
}
|
1803
|
+
|
1804
|
+
uint num_greedy_decisions_to_code = 0;
|
1805
|
+
|
1806
|
+
const lzham::vector<lzdecision> &best_decisions = greedy_parse_state.m_best_decisions;
|
1807
|
+
|
1808
|
+
if (!greedy_parse_state.m_greedy_parse_gave_up)
|
1809
|
+
num_greedy_decisions_to_code = best_decisions.size();
|
1810
|
+
else
|
1811
|
+
{
|
1812
|
+
uint num_small_decisions = 0;
|
1813
|
+
uint total_match_len = 0;
|
1814
|
+
uint max_match_len = 0;
|
1815
|
+
|
1816
|
+
uint i;
|
1817
|
+
for (i = 0; i < best_decisions.size(); i++)
|
1818
|
+
{
|
1819
|
+
const lzdecision &dec = best_decisions[i];
|
1820
|
+
if (dec.get_len() <= CLZBase::cMaxMatchLen)
|
1821
|
+
{
|
1822
|
+
num_small_decisions++;
|
1823
|
+
if (num_small_decisions > 16)
|
1824
|
+
break;
|
1825
|
+
}
|
1826
|
+
|
1827
|
+
total_match_len += dec.get_len();
|
1828
|
+
max_match_len = LZHAM_MAX(max_match_len, dec.get_len());
|
1829
|
+
}
|
1830
|
+
|
1831
|
+
if (max_match_len > CLZBase::cMaxMatchLen)
|
1832
|
+
{
|
1833
|
+
if ((total_match_len / i) >= cAvgAcceptableGreedyMatchLen)
|
1834
|
+
{
|
1835
|
+
num_greedy_decisions_to_code = i;
|
1836
|
+
}
|
1837
|
+
}
|
1838
|
+
}
|
1839
|
+
|
1840
|
+
if (num_greedy_decisions_to_code)
|
1841
|
+
{
|
1842
|
+
for (uint i = 0; i < num_greedy_decisions_to_code; i++)
|
1843
|
+
{
|
1844
|
+
LZHAM_ASSERT(best_decisions[i].m_pos == (int)cur_dict_ofs);
|
1845
|
+
//LZHAM_ASSERT(i >= 0);
|
1846
|
+
LZHAM_ASSERT(i < best_decisions.size());
|
1847
|
+
|
1848
|
+
#if LZHAM_UPDATE_STATS
|
1849
|
+
bit_cost_t cost = m_state.get_cost(*this, m_accel, best_decisions[i]);
|
1850
|
+
m_stats.update(best_decisions[i], m_state, m_accel, cost);
|
1851
|
+
#endif
|
1852
|
+
|
1853
|
+
if (!code_decision(best_decisions[i], cur_dict_ofs, bytes_to_match))
|
1854
|
+
{
|
1855
|
+
LZHAM_LOG_ERROR(7053);
|
1856
|
+
return false;
|
1857
|
+
}
|
1858
|
+
|
1859
|
+
m_accel.advance_bytes(best_decisions[i].get_len());
|
1860
|
+
}
|
1861
|
+
|
1862
|
+
if ((!greedy_parse_state.m_greedy_parse_gave_up) || (!bytes_to_match))
|
1863
|
+
{
|
1864
|
+
if (!computed_adler32)
|
1865
|
+
{
|
1866
|
+
computed_adler32 = true;
|
1867
|
+
|
1868
|
+
scoped_perf_section add_bytes_timer("adler32");
|
1869
|
+
m_src_adler32 = adler32(pBuf, buf_len, m_src_adler32);
|
1870
|
+
}
|
1871
|
+
|
1872
|
+
continue;
|
1873
|
+
}
|
1874
|
+
}
|
1875
|
+
}
|
1876
|
+
|
1877
|
+
uint num_parse_jobs = LZHAM_MIN(m_num_parse_threads, (bytes_to_match + cMaxParseGraphNodes - 1) / cMaxParseGraphNodes);
|
1878
|
+
if ((m_params.m_lzham_compress_flags & LZHAM_COMP_FLAG_DETERMINISTIC_PARSING) == 0)
|
1879
|
+
{
|
1880
|
+
if (m_use_task_pool && m_accel.get_max_helper_threads())
|
1881
|
+
{
|
1882
|
+
// Increase the number of active parse jobs as the match finder finishes up to keep CPU utilization up.
|
1883
|
+
num_parse_jobs += m_accel.get_num_completed_helper_threads();
|
1884
|
+
num_parse_jobs = LZHAM_MIN(num_parse_jobs, cMaxParseThreads);
|
1885
|
+
}
|
1886
|
+
}
|
1887
|
+
|
1888
|
+
// Don't bother threading if the remaining bytes to parse is too small.
|
1889
|
+
if ((bytes_to_match < 1536) || (m_params.m_lzham_compress_flags & LZHAM_COMP_FLAG_FORCE_SINGLE_THREADED_PARSING))
|
1890
|
+
num_parse_jobs = 1;
|
1891
|
+
|
1892
|
+
// Update the coding statistics more frequently near the beginning of streams.
|
1893
|
+
if ((!m_block_index) && ((cur_dict_ofs - m_block_start_dict_ofs) < cMaxParseGraphNodes * 4))
|
1894
|
+
num_parse_jobs = 1;
|
1895
|
+
|
1896
|
+
uint parse_thread_start_ofs = cur_dict_ofs;
|
1897
|
+
uint parse_thread_total_size = LZHAM_MIN(bytes_to_match, cMaxParseGraphNodes * num_parse_jobs);
|
1898
|
+
|
1899
|
+
uint parse_thread_remaining = parse_thread_total_size;
|
1900
|
+
|
1901
|
+
state_base saved_state;
|
1902
|
+
if (num_parse_jobs == 1)
|
1903
|
+
m_state.save_partial_state(saved_state);
|
1904
|
+
|
1905
|
+
for (uint parse_thread_index = 0; parse_thread_index < num_parse_jobs; parse_thread_index++)
|
1906
|
+
{
|
1907
|
+
parse_thread_state &parse_thread = m_parse_thread_state[parse_thread_index];
|
1908
|
+
|
1909
|
+
if (num_parse_jobs == 1)
|
1910
|
+
{
|
1911
|
+
parse_thread.m_pState = &m_state;
|
1912
|
+
}
|
1913
|
+
else
|
1914
|
+
{
|
1915
|
+
parse_thread.m_pState = &parse_thread.m_state;
|
1916
|
+
parse_thread.m_state = m_state;
|
1917
|
+
}
|
1918
|
+
|
1919
|
+
parse_thread.m_pState->m_cur_ofs = parse_thread_start_ofs;
|
1920
|
+
|
1921
|
+
if (parse_thread_index > 0)
|
1922
|
+
{
|
1923
|
+
parse_thread.m_pState->reset_state_partial();
|
1924
|
+
parse_thread.m_issue_reset_state_partial = true;
|
1925
|
+
}
|
1926
|
+
else
|
1927
|
+
{
|
1928
|
+
parse_thread.m_issue_reset_state_partial = false;
|
1929
|
+
}
|
1930
|
+
|
1931
|
+
parse_thread.m_start_ofs = parse_thread_start_ofs;
|
1932
|
+
if (parse_thread_index == (num_parse_jobs - 1))
|
1933
|
+
parse_thread.m_bytes_to_match = parse_thread_remaining;
|
1934
|
+
else
|
1935
|
+
parse_thread.m_bytes_to_match = parse_thread_total_size / num_parse_jobs;
|
1936
|
+
|
1937
|
+
parse_thread.m_bytes_to_match = LZHAM_MIN(parse_thread.m_bytes_to_match, cMaxParseGraphNodes);
|
1938
|
+
LZHAM_ASSERT(parse_thread.m_bytes_to_match > 0);
|
1939
|
+
|
1940
|
+
parse_thread.m_max_parse_node_states = m_params.m_extreme_parsing_max_best_arrivals;
|
1941
|
+
parse_thread.m_max_greedy_decisions = UINT_MAX;
|
1942
|
+
parse_thread.m_greedy_parse_gave_up = false;
|
1943
|
+
|
1944
|
+
parse_thread.m_parse_early_out_thresh = UINT_MAX;
|
1945
|
+
parse_thread.m_bytes_actually_parsed = 0;
|
1946
|
+
|
1947
|
+
parse_thread.m_use_semaphore = ((m_use_task_pool) && (num_parse_jobs > 1)) && (parse_thread_index > 0);
|
1948
|
+
|
1949
|
+
if ((m_params.m_compression_level == cCompressionLevelUber) && (num_parse_jobs == 1))
|
1950
|
+
{
|
1951
|
+
// Allow the parsers to exit early if they encounter a graph bottleneck, so we can move the coding statistics forward before parsing again.
|
1952
|
+
parse_thread.m_parse_early_out_thresh = (m_params.m_lzham_compress_flags & LZHAM_COMP_FLAG_EXTREME_PARSING) ? 16 : 64;
|
1953
|
+
}
|
1954
|
+
|
1955
|
+
parse_thread_start_ofs += parse_thread.m_bytes_to_match;
|
1956
|
+
parse_thread_remaining -= parse_thread.m_bytes_to_match;
|
1957
|
+
}
|
1958
|
+
|
1959
|
+
{
|
1960
|
+
scoped_perf_section parse_timer("parsing");
|
1961
|
+
|
1962
|
+
if ((m_use_task_pool) && (num_parse_jobs > 1))
|
1963
|
+
{
|
1964
|
+
{
|
1965
|
+
scoped_perf_section queue_task_timer("queuing parse tasks");
|
1966
|
+
|
1967
|
+
if (!m_params.m_pTask_pool->queue_multiple_object_tasks(this, &lzcompressor::parse_job_callback, 1, num_parse_jobs - 1))
|
1968
|
+
return false;
|
1969
|
+
}
|
1970
|
+
|
1971
|
+
parse_job_callback(0, NULL);
|
1972
|
+
}
|
1973
|
+
else
|
1974
|
+
{
|
1975
|
+
for (uint parse_thread_index = 0; parse_thread_index < num_parse_jobs; parse_thread_index++)
|
1976
|
+
{
|
1977
|
+
parse_job_callback(parse_thread_index, NULL);
|
1978
|
+
}
|
1979
|
+
}
|
1980
|
+
}
|
1981
|
+
|
1982
|
+
if (num_parse_jobs == 1)
|
1983
|
+
m_state.restore_partial_state(saved_state);
|
1984
|
+
|
1985
|
+
if (!computed_adler32)
|
1986
|
+
{
|
1987
|
+
computed_adler32 = true;
|
1988
|
+
|
1989
|
+
scoped_perf_section add_bytes_timer("adler32");
|
1990
|
+
m_src_adler32 = adler32(pBuf, buf_len, m_src_adler32);
|
1991
|
+
}
|
1992
|
+
|
1993
|
+
#define LZHAM_RELEASE_SEMAPHORES for (uint pti = 1; pti < num_parse_jobs; pti++) if (m_parse_thread_state[pti].m_use_semaphore) { m_parse_thread_state[pti].m_finished.wait(); m_parse_thread_state[pti].m_use_semaphore = false; }
|
1994
|
+
|
1995
|
+
{
|
1996
|
+
scoped_perf_section coding_timer("coding");
|
1997
|
+
|
1998
|
+
uint total_bytes_parsed = 0;
|
1999
|
+
|
2000
|
+
for (uint parse_thread_index = 0; parse_thread_index < num_parse_jobs; parse_thread_index++)
|
2001
|
+
{
|
2002
|
+
parse_thread_state &parse_thread = m_parse_thread_state[parse_thread_index];
|
2003
|
+
|
2004
|
+
if (parse_thread.m_use_semaphore)
|
2005
|
+
{
|
2006
|
+
scoped_perf_section sect(cVarArgs, "Waiting for parser %u", parse_thread_index);
|
2007
|
+
m_parse_thread_state[parse_thread_index].m_finished.wait();
|
2008
|
+
m_parse_thread_state[parse_thread_index].m_use_semaphore = false;
|
2009
|
+
}
|
2010
|
+
|
2011
|
+
if (parse_thread.m_failed)
|
2012
|
+
{
|
2013
|
+
LZHAM_RELEASE_SEMAPHORES
|
2014
|
+
LZHAM_LOG_ERROR(7054);
|
2015
|
+
return false;
|
2016
|
+
}
|
2017
|
+
|
2018
|
+
const lzham::vector<lzdecision> &best_decisions = parse_thread.m_best_decisions;
|
2019
|
+
|
2020
|
+
if (parse_thread.m_issue_reset_state_partial)
|
2021
|
+
{
|
2022
|
+
if (!m_state.encode_reset_state_partial(m_codec, m_accel, cur_dict_ofs))
|
2023
|
+
{
|
2024
|
+
LZHAM_RELEASE_SEMAPHORES
|
2025
|
+
LZHAM_LOG_ERROR(7055);
|
2026
|
+
return false;
|
2027
|
+
}
|
2028
|
+
m_step++;
|
2029
|
+
}
|
2030
|
+
|
2031
|
+
if (best_decisions.size())
|
2032
|
+
{
|
2033
|
+
int i = 0;
|
2034
|
+
int end_dec_index = static_cast<int>(best_decisions.size()) - 1;
|
2035
|
+
int dec_step = 1;
|
2036
|
+
if (parse_thread.m_emit_decisions_backwards)
|
2037
|
+
{
|
2038
|
+
i = static_cast<int>(best_decisions.size()) - 1;
|
2039
|
+
end_dec_index = 0;
|
2040
|
+
dec_step = -1;
|
2041
|
+
LZHAM_ASSERT(best_decisions.back().m_pos == (int)parse_thread.m_start_ofs);
|
2042
|
+
}
|
2043
|
+
else
|
2044
|
+
{
|
2045
|
+
LZHAM_ASSERT(best_decisions.front().m_pos == (int)parse_thread.m_start_ofs);
|
2046
|
+
}
|
2047
|
+
|
2048
|
+
// Loop rearranged to avoid bad x64 codegen problem with MSVC2008.
|
2049
|
+
for ( ; ; )
|
2050
|
+
{
|
2051
|
+
LZHAM_ASSERT(best_decisions[i].m_pos == (int)cur_dict_ofs);
|
2052
|
+
LZHAM_ASSERT(i >= 0);
|
2053
|
+
LZHAM_ASSERT(i < (int)best_decisions.size());
|
2054
|
+
|
2055
|
+
#if LZHAM_UPDATE_STATS
|
2056
|
+
bit_cost_t cost = m_state.get_cost(*this, m_accel, best_decisions[i]);
|
2057
|
+
m_stats.update(best_decisions[i], m_state, m_accel, cost);
|
2058
|
+
//m_state.print(m_codec, *this, m_accel, best_decisions[i]);
|
2059
|
+
#endif
|
2060
|
+
|
2061
|
+
if (!code_decision(best_decisions[i], cur_dict_ofs, bytes_to_match))
|
2062
|
+
{
|
2063
|
+
LZHAM_RELEASE_SEMAPHORES
|
2064
|
+
LZHAM_LOG_ERROR(7056);
|
2065
|
+
return false;
|
2066
|
+
}
|
2067
|
+
|
2068
|
+
total_bytes_parsed += best_decisions[i].get_len();
|
2069
|
+
|
2070
|
+
if (i == end_dec_index)
|
2071
|
+
break;
|
2072
|
+
i += dec_step;
|
2073
|
+
}
|
2074
|
+
|
2075
|
+
LZHAM_NOTE_UNUSED(i);
|
2076
|
+
}
|
2077
|
+
|
2078
|
+
LZHAM_ASSERT(cur_dict_ofs == parse_thread.m_start_ofs + parse_thread.m_bytes_actually_parsed);
|
2079
|
+
|
2080
|
+
} // parse_thread_index
|
2081
|
+
|
2082
|
+
m_accel.advance_bytes(total_bytes_parsed);
|
2083
|
+
|
2084
|
+
} // coding
|
2085
|
+
|
2086
|
+
} // while (bytes_to_match)
|
2087
|
+
|
2088
|
+
{
|
2089
|
+
scoped_perf_section add_bytes_timer("add_bytes_end");
|
2090
|
+
m_accel.add_bytes_end();
|
2091
|
+
}
|
2092
|
+
|
2093
|
+
if (!m_state.encode_eob(m_codec, m_accel, cur_dict_ofs))
|
2094
|
+
{
|
2095
|
+
LZHAM_LOG_ERROR(7057);
|
2096
|
+
return false;
|
2097
|
+
}
|
2098
|
+
|
2099
|
+
#ifdef LZHAM_LZDEBUG
|
2100
|
+
if (!m_codec.encode_bits(366, 12))
|
2101
|
+
{
|
2102
|
+
LZHAM_LOG_ERROR(7058);
|
2103
|
+
return false;
|
2104
|
+
}
|
2105
|
+
#endif
|
2106
|
+
|
2107
|
+
{
|
2108
|
+
scoped_perf_section stop_encoding_timer("stop_encoding");
|
2109
|
+
if (!m_codec.stop_encoding(true))
|
2110
|
+
{
|
2111
|
+
LZHAM_LOG_ERROR(7059);
|
2112
|
+
return false;
|
2113
|
+
}
|
2114
|
+
}
|
2115
|
+
|
2116
|
+
// Coded the entire block - now see if it makes more sense to just send a raw/uncompressed block.
|
2117
|
+
|
2118
|
+
uint compressed_size = m_codec.get_encoding_buf().size();
|
2119
|
+
LZHAM_NOTE_UNUSED(compressed_size);
|
2120
|
+
|
2121
|
+
//bool used_raw_block = false;
|
2122
|
+
|
2123
|
+
#if !LZHAM_FORCE_ALL_RAW_BLOCKS
|
2124
|
+
#if (defined(LZHAM_DISABLE_RAW_BLOCKS) || defined(LZHAM_LZDEBUG))
|
2125
|
+
if (0)
|
2126
|
+
#else
|
2127
|
+
// TODO: Allow the user to control this threshold, i.e. if less than 1% then just store uncompressed.
|
2128
|
+
if (compressed_size >= buf_len)
|
2129
|
+
#endif
|
2130
|
+
#endif
|
2131
|
+
{
|
2132
|
+
// Failed to compress the block, so go back to our original state and just code a raw block.
|
2133
|
+
m_state = m_start_of_block_state;
|
2134
|
+
m_step = initial_step;
|
2135
|
+
//m_stats = initial_stats;
|
2136
|
+
|
2137
|
+
m_codec.reset();
|
2138
|
+
|
2139
|
+
if (!m_codec.start_encoding(buf_len + 16))
|
2140
|
+
{
|
2141
|
+
LZHAM_LOG_ERROR(7060);
|
2142
|
+
return false;
|
2143
|
+
}
|
2144
|
+
|
2145
|
+
if (!m_block_index)
|
2146
|
+
{
|
2147
|
+
if (!send_configuration())
|
2148
|
+
{
|
2149
|
+
LZHAM_LOG_ERROR(7061);
|
2150
|
+
return false;
|
2151
|
+
}
|
2152
|
+
}
|
2153
|
+
|
2154
|
+
#ifdef LZHAM_LZDEBUG
|
2155
|
+
if (!m_codec.encode_bits(166, 12))
|
2156
|
+
{
|
2157
|
+
LZHAM_LOG_ERROR(7062);
|
2158
|
+
return false;
|
2159
|
+
}
|
2160
|
+
#endif
|
2161
|
+
|
2162
|
+
if (!m_codec.encode_bits(cRawBlock, cBlockHeaderBits))
|
2163
|
+
{
|
2164
|
+
LZHAM_LOG_ERROR(7063);
|
2165
|
+
return false;
|
2166
|
+
}
|
2167
|
+
|
2168
|
+
LZHAM_ASSERT(buf_len <= 0x1000000);
|
2169
|
+
if (!m_codec.encode_bits(buf_len - 1, 24))
|
2170
|
+
{
|
2171
|
+
LZHAM_LOG_ERROR(7064);
|
2172
|
+
return false;
|
2173
|
+
}
|
2174
|
+
|
2175
|
+
// Write buf len check bits, to help increase the probability of detecting corrupted data more early.
|
2176
|
+
uint buf_len0 = (buf_len - 1) & 0xFF;
|
2177
|
+
uint buf_len1 = ((buf_len - 1) >> 8) & 0xFF;
|
2178
|
+
uint buf_len2 = ((buf_len - 1) >> 16) & 0xFF;
|
2179
|
+
if (!m_codec.encode_bits((buf_len0 ^ buf_len1) ^ buf_len2, 8))
|
2180
|
+
{
|
2181
|
+
LZHAM_LOG_ERROR(7065);
|
2182
|
+
return false;
|
2183
|
+
}
|
2184
|
+
|
2185
|
+
if (!m_codec.encode_align_to_byte())
|
2186
|
+
{
|
2187
|
+
LZHAM_LOG_ERROR(7066);
|
2188
|
+
return false;
|
2189
|
+
}
|
2190
|
+
|
2191
|
+
const uint8* pSrc = m_accel.get_ptr(m_block_start_dict_ofs);
|
2192
|
+
|
2193
|
+
for (uint i = 0; i < buf_len; i++)
|
2194
|
+
{
|
2195
|
+
if (!m_codec.encode_bits(*pSrc++, 8))
|
2196
|
+
{
|
2197
|
+
LZHAM_LOG_ERROR(7067);
|
2198
|
+
return false;
|
2199
|
+
}
|
2200
|
+
}
|
2201
|
+
|
2202
|
+
if (!m_codec.stop_encoding(true))
|
2203
|
+
{
|
2204
|
+
LZHAM_LOG_ERROR(7068);
|
2205
|
+
return false;
|
2206
|
+
}
|
2207
|
+
|
2208
|
+
//used_raw_block = true;
|
2209
|
+
emit_reset_update_rate_command = false;
|
2210
|
+
}
|
2211
|
+
|
2212
|
+
{
|
2213
|
+
scoped_perf_section append_timer("append");
|
2214
|
+
|
2215
|
+
if (m_comp_buf.empty())
|
2216
|
+
{
|
2217
|
+
m_comp_buf.swap(m_codec.get_encoding_buf());
|
2218
|
+
}
|
2219
|
+
else
|
2220
|
+
{
|
2221
|
+
if (!m_comp_buf.append(m_codec.get_encoding_buf()))
|
2222
|
+
{
|
2223
|
+
LZHAM_LOG_ERROR(7069);
|
2224
|
+
return false;
|
2225
|
+
}
|
2226
|
+
}
|
2227
|
+
}
|
2228
|
+
|
2229
|
+
#if LZHAM_UPDATE_STATS
|
2230
|
+
LZHAM_VERIFY(m_stats.m_total_bytes == m_src_size);
|
2231
|
+
if (emit_reset_update_rate_command)
|
2232
|
+
m_stats.m_total_update_rate_resets++;
|
2233
|
+
#endif
|
2234
|
+
|
2235
|
+
m_block_index++;
|
2236
|
+
|
2237
|
+
return true;
|
2238
|
+
}
|
2239
|
+
|
2240
|
+
} // namespace lzham
|