Hi... I'm making a compressor. It's for a game I made, where I have block data like minecraft.
My progress so far is good. I'm able to get about 10x compression on my save-files. This is good!
Everything in my game so far is implemented with a very small amount of code (relatively). Entire game is 300K... but feature all the subsystems needed for a modern game. (Hit-detection, level creation/management, graphics, sound-threading, 3D code, dynamic shader reloading (So I can live-edit my shaders and see results in-game), saving/loading, compression, string libraries, data file parsing/rendering, user-interface, etc etc)
So I don't want to use compression like gzip because actually just putting it in, will already double the size of my game Not fun.
My compress/decompress takes about 4K of code... It's nice.
BUT it compresses very slow. My "pattern detection" code, is using "dynamic programming". It will ALWAYS find the best match. But it's so slow.
I'm using something like this: https://algorithms.tutorialhorizon.c...mon-substring/ but adapted for compression of files.
Advantage: Small code, simple code, tight compression.
Can anyone advise me how to find/make some code that is small AND fast AND acheives good matching? I don't mind if its code that I need to adapt to make work. I don't need a "ready made solution"... just to see that someone else made something "small and fast" should be enough for me to learn it's technique...
it would really be helpful
I did look at some existing "Small compressors" such as http://create.stephan-brumme.com/smallz4/ but... his code had a bug in it, and actually ran VERY VERY VERY slowly... like 100x slower than mine, on a simple text file. And also didn't compress well. Bad compression, bugs on some files, and also 100x slower than mine. I tried a few other "small code size compressors", but similar problem. All very slow and buggy.
For info about my compressor. It's not special It's like LZ4 (offset match) except I'm using 2 byte codes instead of 3. Also it has more flexible encoding, so it can escape 16 bytes with 1 byte overhead. And optional "Extension" so I can use 3 byte codes for longer offset-matches... if needed. Not special but if anyone is super-interested I can give code...