Odin icon indicating copy to clipboard operation
Odin copied to clipboard

core/image: Add jpeg support

Open IllusionMan1212 opened this issue 9 months ago • 1 comments

This adds support for decoding jpeg images to the core library. So far this only supports Baseline Sequential and Extended Sequential Huffman-coded jpegs, which are the most common types of jpeg files (along with progressive - SOF2) found online.

Planned Features

  • [ ] Progressive (SOF2) jpeg support
  • [x] Exif (APP1) metadata extraction
  • [ ] Decoding of CMYK/RGB jpegs (Possibly, still not sure)

Performance

This implementation is a mostly straightforward naive implementation of the decompression and decoding algorithms used in JPEG, and is therefore slower than most known decoders. Although this does employ an optimization for the IDCT formula by precalculating some data.

The slowest part of the decompression is the huffman decoding which is done by reading one bit from the bitstream and trying to match it with the huffman codes we have. I've yet to take a look at optimizations for this.

Note: -o:speed is recommended when testing performance, as regular builds can get really slow for large images.

Opened as a draft PR to get some early opinions about the code structure and performance.

IllusionMan1212 avatar Jan 15 '25 17:01 IllusionMan1212