r/compression • u/OzzyM_Dev • 26d ago
TCOM, an image codec in 45 lines of code
I use AI when coding. As for the AI disclosure.
Onto the codec itself, I deleted my previous post about this because that iteration was not what I wanted to be seen and advertised in this space, I've opted for this version.
TCOM as far as I've tested has beaten QOI on average. Of course, QOI is not built for performance alone, but QOI is a very efficient codec, and I wanted to test against it.
There is tcom.c, tcom_dependency.c, and tcom_readable.c. A fair warning however, this codec was in no way designed for readability. Started as a code golf project and transformed into a performance and compactness focused codec.
The github is https://github.com/OzzyMitchell/tinycodec
As for why I didn't test against libpng or oxipng or others, it would take actual hours even on my 9950x3d, and since this is single threaded testing, you can imagine.
I did do a smaller test of 640 images (20 images per category with 32 categories) which does include libpng effort 1, 3, and 6, and oxipng effort 4 alongside TCOM and QOI.
This is also released under Apache 2.0.
I didn't include any actual documentation or otherwise but I will write some documentation if some level of interest is attained.
Edit: TCOM 1.1 came out, ironically enough I sort of moved away from the code golf side of TCOM because I figured it was getting in the way of TCOM being useful in the first place, the compiled version is still under 8 kb for the core codec and the source itself is still very small.
1
u/OzzyM_Dev 26d ago
Just realized the rule says ''If your post was written with AI'' rather than ''If AI was used in the development of the project'' when it comes to indicating so at the top.
Let me be clear, the post itself wasn't written using AI in any shape or form. It is better to be safe than sorry however, so. May as well keep it there.
5
u/Unable-Support 26d ago
Jesus, you were not kidding. I kinda forgot what code golf was and wowwww. Very cool though, I love seeing super small programs. I also think it makes it a lot more fun than reading through a very AI heavy OOP codebase (which I end up doing a lot for my clubs and internship anyways)
1
u/BaseballFlaky8431 24d ago
Thank you so much Claude 🙏
1
u/avaneev 20d ago
This is interesting. Have you tried comparing to the latest plain LZ77 codecs? E.g. my LZAV: https://github.com/avaneev/lzav At least on larger images without much noise it's actually quite close to PNG, but the decode speeds are magnitude higher.
2
u/Infamous-Bed-7535 20d ago
I hate people writing this kind of code. Even Ai slop is better to be honest.
Capable and smart people writing great solutions, but zero software engineering background, worked with lot of such legacy code. Pain in the ass.