unknownbrackets / maxcso

Fast cso compressor
ISC License
390 stars 23 forks source link

Some help regarding block size argument #42

Closed randombyt closed 3 years ago

randombyt commented 3 years ago

Hi, Thanks a lot for this handy tool. Most of my PS2 collection has been compressed using block size of 16384. The batch file being:

@ECHO OFF  
FOR %%I IN (*.iso) DO (  
  maxcso --fast --block=16384 "%%I"  
)

This block size was suggested to me by someone but I could not find any recommended block size for ps2 in maxcso docs or help. I have decompressed to check if the compression is lossless and it seems to be as decompressed files crc match with their original redump values.

I just wanted to ask if this value, block size = 16384, is ok or if I should go with the default i.e. maxcso --fast without any block size. Thanks.

unknownbrackets commented 3 years ago

The default block size is autodetected based on the ISO size. Any ISO larger than 2GB will use 16384 anyway, and it is a good value for any PS2 game. I suggest sticking with that value.

Yes, maxcso is lossless in all its compression. There are CSO compression tools that allow you to delete/replace files from the ISO during compression, but maxcso intentionally doesn't do any of that.

Just to explain what the block size value is:

CSO breaks the ISO up into chunks, each the specified block size. The larger the block size, the smaller the compressed CSO. The downside is that larger block sizes slow down "random access" - that's when a game reads little bits from different parts of the ISO, instead of reading continuously in a straight line. Larger block sizes also increase memory usage when reading from the CSO.

The gains in compression ratio drop after 16384 and especially after 32768. Many older tools can only handle ISOs smaller than 2 GB and with block sizes of 2048. That's why maxcso uses 2048 as the default for smaller ISOs - for compatibility. 16384 is the recommended value if compatibility isn't a concern.

In my testing of PCSX2 on a desktop, CSOs perform better than .gz files for decompression across the board - for any block size below 32768 (I didn't test larger than that.) Similarly, CSOs use less memory as well. However, both differences are a very small percentage of PCSX2's overall performance, so it will likely make no practical difference.


Also, --fast prevents maxcso from working hard to make the ISO as small as possible. This won't improve reading performance, and only improves compression time. The file will be larger because maxcso won't work as hard to make it smaller.

--fast is equivalent to -9 (maximum compression) in other CSO tools. Lower compression is not supported at all. Omitting --fast achieves better compression than any other CSO compressor.

On the other extreme, you can use --use-zopfli as in maxcso --use-zopfli --block=32768 "%%I". This will make compression very slow. Decompression speed and memory usage won't really be impacted (i.e. in PCSX2 / Play! / PPSSPP), but the file will be smaller. Even though it'll take forever, this will only give you another 1% at best.

-[Unknown]

randombyt commented 3 years ago

Thank you very much for the detailed answer, this cleared my confusion.