-
Notifications
You must be signed in to change notification settings - Fork 622
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
HDR Decoder: float by default #1599
HDR Decoder: float by default #1599
Conversation
…pport # Conflicts: # src/codecs/hdr/decoder.rs # src/codecs/hdr/encoder.rs # src/lib.rs
src/codecs/hdr/decoder.rs
Outdated
fn read_image_data(&mut self, buf: &mut [u8]) -> ImageResult<()> { | ||
assert_eq!(u64::try_from(buf.len()), Ok(self.total_bytes())); | ||
fn read_image_data_f32(&mut self, image_bytes: &mut [u8]) -> ImageResult<()> { | ||
panic!("dsfowsidjw"); |
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.
running the tests currently does not trigger this panic. some ideas why this is not triggered?
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.
the benchmarks trigger this panic
Anyone remember why this stalled? The changes look reasonable, modulo figuring out whether they include any API-breaking changes. |
I believe the following happened:
Maybe you can check it out and try to investigate @fintelia? Maybe it already works but only the tests need some tweaking |
Note: This PR only handles decoding, not encoding yet. The encoder itself is already full image/src/codecs/hdr/encoder.rs Lines 12 to 20 in 183e74e
It seems like it is never called at all yet? Probably because it does not implement the standard It was planned to be called here image/src/io/free_functions.rs Line 182 in 9ed41d7
But we should rather put it here I guess. image/src/io/free_functions.rs Lines 244 to 246 in 9ed41d7
|
Anyways, do we consider changing the returned Some users might expect the returned type to always be |
The short answer: not really, but we don't 100% know. Downstream could rely on matching Some changes to color types had been made previously but most from rgba to rgb and not to the sample type. Potentially, there could be some code that requires opt-in to th changes in I'd say it's okay, although we may seek to clarify this through the |
# Conflicts: # src/codecs/hdr/decoder.rs
revisiting this:
now, the reference tests fail. first, this was because the png format doesn't support float. added the workaround that all hdr images are converted from rgb32f to rgb8 before comparing with png. now, it fails because there is a bug in the pr somewhere, the tests do their job. current state: it seems to be on the right way, but some channels are apparently not handled correctly. you can see this when comparing the rendered png reference image with the hdr image, it doesn't match. |
left: the original hdr image, as displayed in affinity photo maybe the problem is that we must do gamma correction for the output to match? the old decoder did gamma correction (when reading the float values from the image and converting them to u8, because it calls edit: successall tests pass when the new decoder uses the gamma technique of the previous implementation opinions? how would i do that? |
added one commit that implements the gamma correction. but, as i said, i think there is a better way: output linear values and update the tested reference images. i'll revert that commit if you agree |
Could you take a look at #1937, I think it is doing something very similar? |
Yes indeed. That pr achieves the same with less code changes, but
oh, the debug statements should be removed from this pr |
the tests need to be adjusted either pr, because changing non-linear u8 to linear f32 should result in failing tests. which is another breaking change. we should probably provide functionality to obtain the old behavior without much of a hassle |
note: i checked out that PR and indeed the tests fail, as they should. |
Superseded by #2150 |
I suggest we replace the default color type of the hdr format. It was rgb8, but instead we should consider making it f32, to avoid loosing information.
I also thought about whether it was possible to implement
Pixel
forRgbe8
, which looks like the optimal solution, since it saves memory but retains the float precision and infinite range. However, there is no color type associated with that, and we cannot directly return a pixel buffer, so that seems impossible.Also adds some tests for round-trip checks and (soon) pixel checks ns across image formats.