If a RKC becomes larger than 20480 bytes, it must be reduced. There are two ways to reduce the space of the YAZ0/U8 archive without removing objects:
The old compression levels 1 to 9 works all with the same method. For level 9 it is: From any point, compare the coming sequence of bytes with all 4096 possible places before. Use the longest sequence found. For sequences <3, make a byte copy. Then continue with the next position. The result is a good compression, but not so good as Nintendo did it.
Level 1 to 8 works with the same method, but reduce the number of compared sequences in steps to at least 256 bytes before the current position. So level 1 is about 16 times faster than level 9.
In 2011 I developed compression level 10, and now I have optimized it. If a back reference is found, try a single byte copy as alternative to the found back reference. Then compare both variants and use the better one. With this level 10, the SZS tools are able to compress tracks better than Nintendo did it.
Level 10 looks 1 step into the future. But what is, if an algorithm looks N steps into the future and decides then to use a single byte copy or the back reference? I realized this recursive algorithm with levels 100 to 150. For time optimization, I have implemented it as iterative variant with a stack. The least significant digits (00 to 50) defines the recursion depth. Levels 100 to 101 are insignificant and exist only to compare them with other levels. Level 120 is already time intensive and only manageable with small RKC files.
Theoretical, 1 level more means double time. But because of some optimizations 5 level more need usually 10 to 20 times as much time. So level 140 needs years for a standard (large) track.
And so the first step to minimize the compressed file is done!
There are 2 good candidates for reordering data without side effect. One is the order of KCL vertices and normals, and the other one the order of global objects. The SZS tools support both. The effect of reordering is to have more repeated sequences within the back reference window of 4096 bytes.
Also KCL vertices (positions) and normals can be rounded. And sometimes they must be rounded (and Nintendo did it too) because the number of different values is limited. If rounding in lager steps, the compressed data becomes smaller. Here we talk about rouding some digits behind the comma.
Tiny levels | |
---|---|
Keyword | Description |
OFF |
|
1 LOSSLESS |
|
2 RECREATE |
|
MINIMAL |
|
GOOD |
|
MEDIUM |
|
EXTREME |
|
7 DANGEROUS |