-
Notifications
You must be signed in to change notification settings - Fork 28
fix: use extra channel's own bit_depth for modular-to-f32 conversion #604
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
base: main
Are you sure you want to change the base?
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
104e206 to
8bf5953
Compare
|
jxl/src/frame/render.rs
Outdated
| for i in 3..num_channels { | ||
| pipeline = | ||
| pipeline.add_inout_stage(ConvertModularToF32Stage::new(i, metadata.bit_depth))?; | ||
| // Use each extra channel's own bit depth, not the image's metadata bit depth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this comment.
Extra channels (alpha, depth, etc.) can have different bit depths than the main color channels. For example, an image might be 8-bit RGB with a 16-bit alpha channel. Previously, the render pipeline used the image's global `metadata.bit_depth` for converting all extra channels from modular to f32. This caused incorrect conversion for extra channels with different bit depths - values would be ~257x wrong when an 8-bit channel was decoded with 16-bit scale. This PR: - Adds a `bit_depth()` getter to `ExtraChannelInfo` - Uses each extra channel's own bit depth in `ConvertModularToF32Stage` - Adds tests demonstrating the impact of using wrong bit depth
8bf5953 to
d354042
Compare
| } | ||
|
|
||
| /// Test ConvertModularToF32Stage consistency with different bit depths. | ||
| #[test] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I see the point of all the other tests, except these last two.
Do you mind removing them?
Summary
Extra channels (alpha, depth, etc.) can have different bit depths than the main color channels. For example, an image might be 8-bit RGB with a 16-bit alpha channel.
Previously, the render pipeline used the image's global
metadata.bit_depthfor converting all extra channels from modular to f32. This caused incorrect conversion for extra channels with different bit depths.This PR:
bit_depth()getter toExtraChannelInfoConvertModularToF32StageTest plan
🤖 Generated with Claude Code