Archive: LZMA - BCJ Filter Patch


LZMA - BCJ Filter Patch
http://www.7-zip.org/alpha/nsis216bcj-2.zip

Patch features:

1) Updating for LZMA SDK 4.37.
2) BCJ filter before LZMA compressing.

BCJ filter allows to increase compression ratio for x86 executables on 6-8%.
BCJ filter converts CALL and JUMP instructions from relative offsets to
absolute addresses, so such data become more compressible.

How to use
----------

You can specify
SetCompressorFilter 1
or
SetCompressorFilter 0

If you specify "SetCompressorFilter 1", LZMA encoder uses BCJ filter.

Example:

SetCompressor /solid lzma
SetCompressorDictSize 8
SetCompressorFilter 1

---
Igor Pavlov
http://www.7-zip.org


Wow nice work!
I'll do some benchmarks later :] I'll also try and get hold of kichik and let him know.

-Stu


Do you have to use the /solid flag to use the BCJ filter? In other words, will this work?


SetCompressor lzma
SetCompressorFilter 1

When will 7zip be able to open nsis-lzma files?
Total Commander can do the most with plugin (search forum),
but not all of them and then it extract damaged files.


This basic installer crashes when ran:


Name "Testing"
OutFile "testing.exe"

!include MUI.nsh

!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_LANGUAGE English

Section
SectionEnd


Windows XP.
Put old makensis and stubs back and it doesn't crash anymore.

-Stu

Originally posted by Afrow UK
This basic installer crashes when ran [...] Put old makensis and stubs back and it doesn't crash anymore.
LZMA and Bzip2 work fine but the installer crashes if SetCompressor is Zlib.
The patch is already used in 7-zip saving 40KB.

Igor, thank you for your patch.

The zlib crash probably happens because of the second parameter passed to inflate. Try using #ifdef NSIS_COMPRESS_USE_LZMA around that change to make it take affect only for lzma. You could also simply use the old zlib stub.

As far as I can tell, it'll work better without solid compression. It seems to use the filter on the entire compressed block and not on a file by file base. This happens because the filter is set in the compressor itself and not when the file is added outside of the compressor.

The filter's location also makes it work only for lzma and not other compressions. This is why I'd rather keep this as a patch for now. Igor said he won't update it for newer versions, but the changes are simple enough to work for future versions. I don't think there'll be any large scale change that'll render this patch invalid in the near future.