4 ms·
Fabrice Bellard (the wizard behind FFmpeg, QEMU, etc.) has his own entry, which I find amazing: a ~4 kB program that outputs a ~50 kB image (of Lena), in additi
by cornstalks 8y ago
Fabrice Bellard (the wizard behind FFmpeg, QEMU, etc.) has his own entry, which I find amazing: a ~4 kB program that outputs a ~50 kB image (of Lena), in addition to being able to decompress other images. His entry's hint page: http://www.ioccc.org/2018/bellard/hint.html http://www.ioccc.org/2018/bellard/hint.html
- FartyMcFarter 8y ago> No specific obfuscation was needed as the algorithms already have a significant complexity. Hehe...
- saagarjha 8y agoHe wasn't joking: http://www.ioccc.org/2018/bellard/prog.c http://www.ioccc.org/2018/bellard/prog.c
- raverbashing 8y agoFunny, the compiler seems to have a hard time with it. Running it OTOH is instant.
- cdancette 8y agoCan you explain a bit more how this works? I am not familiar at all with these challenges 50kB to 4kB is a 10x compression, it doesn't seem that huge, what's the achievement here?
- saagarjha 8y agoAchieving 10x compression in a 4kB program+data file hybrid is pretty hard to do.
- w23j 8y agoFrom the author's comments: "The uncompressed image is 12 times larger than the source code of the program which includes the image data and the complete decoder. The actual image data is 1220 byte long, which gives a compression ratio of 40. Using a JPEG-like algorithm would not be enough to reach this level of compression (the Lena image would be barely recognizable). So the algorithm is based on the latest advances in image compression." http://www.ioccc.org/2018/bellard/hint.html http://www.ioccc.org/2018/bellard/hint.html
- rntrg 8y agoFrom the author’s notes: > The actual image data is 1220 byte long, which gives a compression ratio of 40.
- boomlinde 8y agoThose 4k include the decoder source code and the C string representation of the image data
- Asooka 8y agoIt's a 3KB decoder and 1KB of image data, from the hint: "The actual image data is 1220 byte long, which gives a compression ratio of 40"
- saagarjha 8y agoFor those using iTerm, a nice way to try this out is running it through imgcat: make && ./prog < lena512.bin | imgcat
- ufo 8y agoIf you have ImageMagick installed the `display` utility can also show PPM images from stdin: ./prog < lena512.bin | display --- btw, the `animate` program can also be used to display the animated GIFs from endoh1.
- ufo 8y agoIs there a program available somewhere to generate our own compressed image (.bin) files?
- wonthegame 8y agoGIMP?
- ufo 8y agoDidn't he come up with a custom image compression scheme? Or am I understanding this wrong?
- wonthegame 8y agoIt might be custom. I haven't checked or compared. There are options to save images in other formats with GIMP.
- vardump 8y agoYou understood correctly. This is a custom format that has some ideas from h.264 and who knows what else.
- vardump 8y agoAlmost certainly not yet. The compression method seems to be pretty advanced, borrowing ideas from h.264 etc. and is almost certainly incompatible with any currently existing format. If we're lucky, Bellard might eventually post an image compressor program on his website at https://bellard.org/ https://bellard.org/.
- vardump 8y agoHere's the default output (embedded 1220 byte 128x128 Lena picture) of Fabrice's IOCCC entry converted into PNG: https://pasteboard.co/Hk60KEv.png https://pasteboard.co/Hk60KEv.png Of course there are plenty of compression artifacts, but very impressive for just 1220 bytes of image data embedded in decompressor written in C totaling only 3984 bytes of source code! No idea about what kind of service pasteboard.co is, hopefully the image will stay up for a while... Edit: For comparison, here's a roughly corresponding original Lena image converted into 1269 byte 128x128 JPEG. convert -resize 128x128 -strip -quality 12% lena.png lena.jpg https://pasteboard.co/Hk67yXC.png https://pasteboard.co/Hk67yXC.png