Skip to content

jpeg: decoder parity stack (post-#590)#599

Closed
hjanuschka wants to merge 18 commits into
libjxl:mainfrom
hjanuschka:jpeg-decoder-after-590-stack
Closed

jpeg: decoder parity stack (post-#590)#599
hjanuschka wants to merge 18 commits into
libjxl:mainfrom
hjanuschka:jpeg-decoder-after-590-stack

Conversation

@hjanuschka

@hjanuschka hjanuschka commented Dec 27, 2025

Copy link
Copy Markdown
Collaborator

Depends on #590.

  • Adds standalone JPEG decoder + regression fixtures
  • Progressive scan handling
  • SIMD YCbCr/BGRA and IDCT parity
  • Libjpeg-turbo parity references (scaled + 12-bit)
  • Chromium integration sample under samples/chromium_integration

Tests:

  • cargo test -p jxl --features jpeg-reconstruction test_libjpeg_turbo_ -- --nocapture

Notes:

  • Idea related to Feature request: JPEG decoding #513
  • This PR is exploratory; not yet sure whether it should be kept or killed, might be a libjpeg-turbo replacement in chromium some day, or just a closed pr in the endless space!

- Add JpegReconstructionData struct with all JPEG metadata needed for
  bit-exact reconstruction (quant tables, Huffman codes, scans, markers)
- Implement jbrd box detection and parsing in BoxParser
- Add jpeg module with parsing logic for jbrd box binary format
- Expose has_jpeg_reconstruction() and jpeg_reconstruction_data() via API

Note: Full JPEG reconstruction requires Brotli decompression of marker
data which is not yet implemented. This adds the data structures and
box detection infrastructure.
- Implement JpegDecoder for baseline and progressive JPEG decoding
- Add accessor methods: width(), height(), num_components(), is_progressive(), metadata()
- Add extract_metadata() for CXX bridge compatibility
- Add 12 JPEG test files for various formats (grayscale, RGB, progressive, subsampling)
- Add 11 integration tests for JPEG file parsing
- Add extended types for libjpeg-turbo parity (JpegBitDepth, JpegColorSpace, IdctScale)
- Fix shift overflow in JpegBitDepth::max_value()
@goodusername123

goodusername123 commented Dec 28, 2025

Copy link
Copy Markdown

while interesting I do feel like this is a bit out of scope for jxl-rs for a few reasons:

  1. JXL only supports a subset of the de-facto JPEG spec/standard (some examples being no chroma sub-sampling modes besides 4:4:4 4:2:0 4:2:2 and no support for RGB outside of 4:4:4) so having a JPEG decoder that supports more of JPEG then JXL does feels a bit weird.
  2. Matching the decoded output of libjpeg-turbo (or any other JPEG decoder for that matter) is a non-goal. For example libjxl decodes in a way that is compliant with how the JPEG spec defines images get decoded but different from what libjpeg-turbo outputs since the JPEG spec has/gives a bit of leeway as to how a decoder should produce pixels.

@jonnyawsom3

Copy link
Copy Markdown
Contributor

See libjxl/libjxl#455 and libjxl/libjxl#1470 (comment)

As Username said, while theoretically possible, I'd say it's out of scope for now. There's been many discussions about it in the past, but other things take priority. jpegli already exists as a replacement JPEG library based on libjxl

@hjanuschka

Copy link
Copy Markdown
Collaborator Author

ok thank you folks! lets close it!

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.

3 participants