Dictionary for lzma86dechead

Doubts, help and support about QuickBMS and other game research tools
StreamThread
Posts: 54
Joined: Fri May 27, 2016 2:28 pm

Dictionary for lzma86dechead

Post by StreamThread »

Hello

DDS image compressed with lzma86dechead and can be successfully decompressed by suitable comtype.

Header when its compressed is:

Code: Select all

00 5D 00 00   80 00 80 00   04 00 00 00 ...


OK. Now it should be compressed back. But with comptype lzma_86dechead_compress, output file have header:

Code: Select all

2C 00 00 00   08 00 80 00   04 00 00 00 ...


Obviously, that is not the result what needed.

Maybe should be some right dictionary for this?

Thanks in advance.
Samples of compressed and source image in attach.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Dictionary for lzma86dechead

Post by aluigi »

Why not? The first byte is a set of flags and both 0x5d and 0x2c are perfectly valid.
StreamThread
Posts: 54
Joined: Fri May 27, 2016 2:28 pm

Re: Dictionary for lzma86dechead

Post by StreamThread »

IDK, that's just doesn't work. I tryed change flag from 0x2c to 0x5d, but game engine is crash anyway.
That's game is Far Cry Instincts Predator, if important. I writing a packing script for it.

Script is working, packing correct without compression. So, all problem in that compression method. CryEngine is so capricious )

Well, maybe it's still possible packing with "old' lzma_86dechead_compress method, with 0x5d and so on?
Last edited by StreamThread on Thu Oct 04, 2018 5:03 pm, edited 1 time in total.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Dictionary for lzma86dechead

Post by aluigi »

I doubt the crash is caused by the properties used by quickbms for better compressing the data (necessary for the original reimport mode), because the compression is just that one and the only difference is a setting supported by the algorithm itself.

This is what quickbms uses for the settings, in lzma_set_properties() in unz.c:

Code: Select all

        props->level = 9;            /*  0 <= level <= 9 */
        props->dictSize = 1<<dictsz; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
                                       (1 << 12) <= dictSize <= (1 << 30) for 64-bit version
                                       default = (1 << 24) */
        // xz wants lc+lp <= 4
        //props->lc = 1;               /* 0 <= lc <= 8, default = 3 */
        //props->lp = 3;               /* 0 <= lp <= 4, default = 0 */
        props->lc = 8;               /* 0 <= lc <= 8, default = 3 */
        props->lp = 4;               /* 0 <= lp <= 4, default = 0 */

        props->pb = 0; /* yeah 0!*/  /* 0 <= pb <= 4, default = 2 */
        //props->algo = 1;             /* 0 - fast, 1 - normal, default = 1 */
        props->fb = 273;             /* 5 <= fb <= 273, default = 32 */
        //props->btMode = 1;           /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
        props->numHashBytes = 4;     /* 2, 3 or 4, default = 4 */
        //props->mc = (1 << 30);       /* 1 <= mc <= (1 << 30), default = 32 */
If I remember correctly the "pb" field set to zero provided better results during my tests and it's the one that probably resulting in 0x5d->0x2c (which is NOT a constant magic, it's a set of flags).

Some info about these fields:
https://stackoverflow.com/questions/305 ... gs-details