-
JPEG optimisation
08/06/2026 at 11:31 • 0 commentsStandards usually impracticable things, although JPEG standard gives transparent enough diagrams and block schemes about JPEG file structure and it's decoding. That is why just viewing of the image is typical task. However optimised algorithm for switching images unnoticeable takes 3x bigger time then the first point.
- Arai Agui Nakajima fast IDCT algorithm, takes 48 pages of matrices and complex arithmetic in my copybook, gave first picture less then 1s.
- Assembly optimisation. ARM M3 assembly with help of Josep's Yiu manual is quite easy task. Instruction-by instruction control helped to reduce time of huffman decoding almost at 1/3. Repacking an array from zig-zag to 8x8 with directly coded addresses, gives yet another little boost (the function run time decreases from 25us to 7us, but due to overall time of decoding it is mperceptibly little). While rewriting the last two steps of decoding (IDCT and YUV to RGB transform) leads to fail. Sorry, but I have to admit defeat to the gcc optimiser. My IDCT assembly variant works at ~10% slower then my compiled C variant, while in RGB I won the same 10% of runtime.
- Table huffman. To put variable-length codes into the array, do we have the idea dumber than it? I wrote this in C variant, and it runs as fast as my optimized bit-by-bit decoding. So this idea is failed too. But maybe I will decide to re write this table algorithm to assembly.
So, without hardware decoder we can't obtain 15FPS, but there is a lifehachk, when we turn image into the mash of random colour pixels and artifacts (at 10% of quality), we got a low size file, which is decoded for 0.07s. And in case of MJPEG file with it's joint tables gives desired 15FPS. But beter way is reducing resolution.
Mikhail Belkin