ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Sat Dec 16, 2017 5:18 am

All times are UTC




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Oct 12, 2017 6:54 pm 

Joined: Thu Oct 12, 2017 5:59 pm
Posts: 2
So, decompressing and compressing result back with Deflate gives different result. Which makes me think i'm missing something.
Code:
comtype deflate

math SIZE = 32
math ZSIZE = 26

clog MEMORY_FILE 0 ZSIZE SIZE
log Decompressed.pak 0 SIZE MEMORY_FILE

comtype deflate_compress
clog MEMORY_FILE2 0 ZSIZE SIZE MEMORY_FILE
log Recompressed.pak 0 ZSIZE MEMORY_FILE2

comtype deflate
clog DecompressedX2.pak 0 ZSIZE SIZE MEMORY_FILE2

example's just a 26 bytes, decompresses to 32 fine.
However, recompressing it back gives result different from original one and decompressing it once more loses 6 bytes.

Am I just monumentally retarded and missed something obvious or is it just the intended behavior by design?
Thanks in advance for explanation.


Attachments:
Example.pak [26 Bytes]
Downloaded 10 times
Top
   
PostPosted: Thu Oct 12, 2017 7:15 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 7250
You made a mistake, check the lines with the "here" comment:
Code:
comtype deflate

math SIZE = 32
math ZSIZE = 26

clog MEMORY_FILE 0 ZSIZE SIZE
log Decompressed.pak 0 SIZE MEMORY_FILE

comtype deflate_compress
clog MEMORY_FILE2 0 SIZE SIZE MEMORY_FILE   # here
get ZSIZE asize MEMORY_FILE2                # here
log Recompressed.pak 0 ZSIZE MEMORY_FILE2

comtype deflate
clog DecompressedX2.pak 0 ZSIZE SIZE MEMORY_FILE2

And yes it's perfectly normal that different implementations of a compression algorithm or different settings produce different compressed results, it's a boring problem which is well known by the users who use the reimporting method with an untouched file to reimport occupies more bytes than the original one even if it's the same.


Top
   
PostPosted: Thu Oct 12, 2017 7:45 pm 

Joined: Thu Oct 12, 2017 5:59 pm
Posts: 2
Thank you a lot!
I bet in documentation there's a a good chunky reminder about how to avoid this kind of amateur mistakes, heh. Should've read it more thoroughly before asking...


Top
   
PostPosted: Thu Oct 12, 2017 10:45 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 7250
Don't worry that's ok, feel free to ask everytime you need.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited