mcmilk / 7-Zip-zstd

7-Zip with support for Brotli, Fast-LZMA2, Lizard, LZ4, LZ5 and Zstandard
https://mcmilk.de/projects/7-Zip-zstd/
Other
5.07k stars 300 forks source link

How do I make a codec for 7zip? #112

Closed tansy closed 4 years ago

tansy commented 4 years ago

I tried to make a codec (let's call it plugin codec in opposition to archive codec) for lzip in that case, so I don't have to patch every new release as it's annoying like hell. I thought it would be trivial, as pretty much everything is codec/plugin in 7zip but it turned out to be much more complicated. I found that unlike main/official 7zip release you do have few codecs made as plugins which is really cool but still don't understand it. Codec.def provides symbols that are to be exported in .so/.dll but I checked all your released codecs sources and they are not defined anywhere which perplexes me. I have no Idea how to get to that and what to do even with clear examples of working plugins.

So first what is the meaning of these methods****, is that all symbols I provide for export to make it work and how do I change existing archive codec, for example $_7ZIP_SRC/CPP/7zip/Archive/LzHandler.cpp or .../Bzip2Handler.cpp, whatever, simpler the better.

I just noticed, that for lizard, for example, there is either plugin and archive codec definitions. Is that redundancy or is it really a dynamic plugin or it is embedded archive codec?


* plugin codecs are shared objects/dll that can be simply added dynamically to 7zip, with exports defined in $_7ZIP_SRC/CPP/7zip/Compress/Codec.def where archive codecs are wired/embedded into 7zip and cannot be dynamically added/removed, their exports are defined in $_7ZIP_SRC/CPP/7zip/Archive/Archive.def or .../Archive2.def.

** brotli, flzma, lizard, zstd

** `$ find $_7ZIP_SRC -iname lizard\ -exec grep CreateEncoder {} ";"` gives nothing

**** Codec.def: CreateDecoder, CreateEncoder, CreateObject, GetMethodProperty, GetNumberOfMethods

mcmilk commented 4 years ago

You can use LZ4 or LZ5 as an example ... just do an diff -urN with default 7-zip and mine 7-Zip ZS here ... you will find the differences ;)

tansy commented 4 years ago

That's what I did, thanks. Now I will study it in free time.