Skip to content

Conversation

@hjanuschka
Copy link
Collaborator

Summary

Takes over #604 from @lilith who is unable to continue.

  • Use each extra channel's own bit_depth instead of the image's global metadata.bit_depth for modular-to-f32 conversion
  • Add bit_depth() getter to ExtraChannelInfo
  • Add tests demonstrating the ~257x error when wrong bit depth is used

Previously, an 8-bit extra channel decoded with a 16-bit image would have its max value (255) incorrectly mapped to ~0.00389 instead of 1.0.

Closes #604

Co-authored-by: Lilith River [email protected]

@hjanuschka hjanuschka force-pushed the fix-extra-channel-bitdepth branch from 57a9a80 to 15e2dbb Compare January 20, 2026 13:14
@github-actions
Copy link

github-actions bot commented Jan 20, 2026

Benchmark @ 373ab08

MULTI-FILE BENCHMARK RESULTS (4 files)
  CPU architecture: x86_64
  WARNING: System appears noisy: high system load (2.62). Results may be unreliable.
Statistics:
  Confidence:               99.0%
  Max relative error:        3.0%

Comparing: 3badb391 (Base) vs fcd3d4cf (PR)

File Base (MP/s) PR (MP/s) Δ%
bike.jxl 23.551 23.402 -0.63% ±2.6%
green_queen_modular_e3.jxl 8.010 8.020 +0.12% ±1.0%
green_queen_vardct_e3.jxl 21.071 21.071 +0.00% ±1.7%
sunset_logo.jxl 2.033 2.248 +10.63% ±1.2%

@veluca93 veluca93 enabled auto-merge (squash) January 20, 2026 20:52
lilith and others added 2 commits January 20, 2026 21:53
Tests removed:
- test_extra_channel_bit_depth (just tests struct field storage)
- test_extra_channel_float_bit_depth (equivalent to testing BitDepth directly)
- test_wrong_bit_depth_produces_wrong_conversion (tests math in isolation)
- test_modular_to_f32_bit_depth_matters (same issue)

Kept the modular_to_f32 consistency tests as they actually exercise the stage.
@veluca93 veluca93 force-pushed the fix-extra-channel-bitdepth branch from 6751dda to 373ab08 Compare January 20, 2026 20:53
@veluca93 veluca93 merged commit 9a4fbb8 into libjxl:main Jan 20, 2026
18 checks passed
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