Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/image: Add jpeg support #4695

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

IllusionMan1212
Copy link
Contributor

@IllusionMan1212 IllusionMan1212 commented Jan 15, 2025

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
  • 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.

core/image/jpeg/jpeg.odin Show resolved Hide resolved
core/image/jpeg/jpeg.odin Show resolved Hide resolved
core/image/jpeg/jpeg.odin Outdated Show resolved Hide resolved
core/image/jpeg/jpeg.odin Outdated Show resolved Hide resolved
core/image/jpeg/jpeg.odin Outdated Show resolved Hide resolved
core/image/jpeg/jpeg.odin Outdated Show resolved Hide resolved
core/image/jpeg/jpeg.odin Outdated Show resolved Hide resolved
core/image/jpeg/jpeg.odin Outdated Show resolved Hide resolved
core/image/jpeg/jpeg.odin Show resolved Hide resolved
core/image/jpeg/jpeg.odin Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants