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

Support displaying high dynamic range images, #26 #27

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

low-batt
Copy link

This commit will:

  • Change JXL.parse to use JxlDecoderGetColorAsEncodedProfile
  • Add support for itur_2100_PQ and displayP3_PQ color spaces
  • Add a MTKView view to the storyboard
  • Add a MetalImageView class to display HDR images with EDR enabled
  • Update build_libjxl.sh to work with latest libjxl version
  • Change build_libjxl.sh to use a tagged released version of libjxl instead of the latest changes in the main branch
  • Switch JXLook to libjxl v0.8.2, the latest released version
  • Remove use of libbrotlienc
  • Add application settings to allow some control over rendering of HDR images
  • Lower macOS deployment target to 10.15 from 11.0
  • Add support for unified logging using OSLog
  • Add logging of JXLook version and libjxl version at startup
  • Apply Xcode 14.3 recommended settings
  • Correct CFBundleVersion warning
  • Add .DS_Store to .gitignore

The NSImageView is now a subview of the MTKView. The NSImageView subview is preferred and will be used whenever it is able to properly render the image. The MTKView is used to display HDR images encoded with the PQ transfer function when the screen supports EDR, tone mapping the image to stay within the display headroom.

This commit will:
- Change JXL.parse to use JxlDecoderGetColorAsEncodedProfile
- Add support for itur_2100_PQ and displayP3_PQ color spaces
- Add a MTKView view to the storyboard
- Add a MetalImageView class to display HDR images with EDR enabled
- Update build_libjxl.sh to work with latest libjxl version
- Change build_libjxl.sh to use a tagged released version of libjxl
  instead of the latest changes in the main branch
- Switch JXLook to libjxl v0.8.2, the latest released version
- Remove use of libbrotlienc
- Add application settings to allow some control over rendering of HDR
  images
- Lower macOS deployment target to 10.15 from 11.0
- Add support for unified logging using OSLog
- Add logging of JXLook version and libjxl version at startup
- Apply Xcode 14.3 recommended settings
- Correct CFBundleVersion warning
- Add .DS_Store to .gitignore

The NSImageView is now a subview of the MTKView. The NSImageView subview
is preferred and will be used whenever it is able to properly render the
image. The MTKView is used to display HDR images encoded with the PQ
transfer function when the screen supports EDR, tone mapping the image
to stay within the display headroom.
@low-batt
Copy link
Author

@yllan @JLHwung Thank you for creating JXLook!

Internet posts indicate macOS Sonoma will contain support for JPEG XL. Great news. However as customary, Sonoma adds to the list of Macs that are no longer supported by the latest macOS version. Users running older versions of macOS will still need a JPEG XL viewer.

With the changes in this PR JXLook is able to display HDR images with EDR enabled. I have tested this on a MacBookPro18,2 with the M1 chip and XDR display running macOS Ventura as well as a MacBookAir8,2 running macOS Catalina.

I am operating way outside of my area of expertise, so I'm sure an expert will be able to point out lots of errors. However these changes certainly improve the display of HDR images.

This is what the new settings window looks like:

jxlook-settings

The following shows the logs messages emitted in a test where the JXLook window was initially on an external display that does not support EDR and then moved to the built in display that does:

bash-3.2$ ./streamLog 
Filtering the log data using "subsystem == "org.yllan.JXLook""
Timestamp               Ty Process[PID:TID]
2023-07-24 15:30:22.570 I  JXLook[63344:1ecb0a] [org.yllan.JXLook:view] JXLook 0.1.4 (2426)
2023-07-24 15:30:22.570 I  JXLook[63344:1ecb0a] [org.yllan.JXLook:view] Copyright (c) 2021-2023 Yung-Luen Lan
2023-07-24 15:30:22.570 I  JXLook[63344:1ecb0a] [org.yllan.JXLook:view] Using libjxl v0.8.2
2023-07-24 15:30:22.570 I  JXLook[63344:1ecb0a] [org.yllan.JXLook:view] Running under macOS Version 13.4 (Build 22F66)
2023-07-24 15:33:20.448 I  JXLook[63344:1ecb0a] [org.yllan.JXLook:decode] Decoding file: <private>
2023-07-24 15:33:20.449 Db JXLook[63344:1ecb0a] [org.yllan.JXLook:decode] Basic info: JxlBasicInfo(have_container: 1, xsize: 1419, ysize: 2048, bits_per_sample: 16, exponent_bits_per_sample: 0, intensity_target: 255.0, min_nits: 0.0, relative_to_max_display: 0, linear_below: 0.0, uses_original_profile: 0, have_preview: 0, have_animation: 0, orientation: JXL_ORIENT_IDENTITY, num_color_channels: 3, num_extra_channels: 0, alpha_bits: 0, alpha_exponent_bits: 0, alpha_premultiplied: 0, preview: __C.JxlPreviewHeader(xsize: 0, ysize: 0), animation: __C.JxlAnimationHeader(tps_numerator: 0, tps_denominator: 0, num_loops: 0, have_timecodes: 0), intrinsic_xsize: 1419, intrinsic_ysize: 2048, padding: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
2023-07-24 15:33:20.450 Db JXLook[63344:1ecb0a] [org.yllan.JXLook:decode] Color encoding: JxlColorEncoding(color_space: JXL_COLOR_SPACE_RGB, white_point: JXL_WHITE_POINT_D65, white_point_xy: (0.3127, 0.329), primaries: JXL_PRIMARIES_2100, primaries_red_xy: (0.708, 0.292), primaries_green_xy: (0.17, 0.797), primaries_blue_xy: (0.131, 0.046), transfer_function: JXL_TRANSFER_FUNCTION_PQ, gamma: 0.0, rendering_intent: JXL_RENDERING_INTENT_PERCEPTUAL)
2023-07-24 15:33:20.450 Db JXLook[63344:1ecb0a] [org.yllan.JXLook:decode] Buffer size: 34873344
2023-07-24 15:33:20.475 Db JXLook[63344:1ecb0a] [org.yllan.JXLook:decode] Color space: Rec. ITU-R BT.2100 PQ colorspace
2023-07-24 15:33:20.498 I  JXLook[63344:1ecb0a] [org.yllan.JXLook:render] Rendering high dynamic range image: <private>
2023-07-24 15:33:20.501 I  JXLook[63344:1ecb0a] [org.yllan.JXLook:render] Screen does not support extended dynamic range: LG UltraFine
2023-07-24 15:33:20.540 Db JXLook[63344:1ecb0a] [org.yllan.JXLook:render] Using NSImageView to draw image
2023-07-24 15:34:53.486 Db JXLook[63344:1ecb0a] [org.yllan.JXLook:render] Window moved to screen: Built-in Retina Display
2023-07-24 15:34:53.489 I  JXLook[63344:1ecb0a] [org.yllan.JXLook:render] Rendering high dynamic range image: <private>
2023-07-24 15:34:53.489 I  JXLook[63344:1ecb0a] [org.yllan.JXLook:render] Screen supports extended dynamic range: Built-in Retina Display (max 16.0x)
2023-07-24 15:34:53.492 I  JXLook[63344:1ecb0a] [org.yllan.JXLook:render] Tone mapping HDR image to display headroom
2023-07-24 15:34:53.505 Db JXLook[63344:1ecb0a] [org.yllan.JXLook:render] Using MTKView to draw image
2023-07-24 15:35:14.693 I  JXLook[63344:1ecb0a] [org.yllan.JXLook:view] Terminating

Initially the image was displayed using the NSImageView. Then to support EDR tone mapping JXLook switched to the MTKView.

@JLHwung
Copy link
Contributor

JLHwung commented Jul 24, 2023

@low-batt This PR looks awesome. Thank you.

@low-batt
Copy link
Author

low-batt commented Jul 24, 2023

The HDR JPEG XL images posted by Eric Chan on mit.edu look great on a Mac with an XDR display.

I tried to put a lot of comments in the code to make it clear what it is doing. Any questions or if you want me to make changes I'm around.

@low-batt low-batt mentioned this pull request Aug 20, 2023
@MaykThewessen
Copy link

great work man!

How to run this? or install it? is there an .app file available for download since i dont know how to compile an .app

@low-batt
Copy link
Author

low-batt commented Oct 8, 2023

Hi @MaykThewessen

I am currently patiently waiting for the creator of JXLook, @yllan to notice this pull request and comment. Typically software engineers are overloaded with school or work deadlines causing all volunteer open source projects to progress in spurts when developers have a moment to focus on the project. I am a little concerned that @yllan does not have any GitHub activity in 2023. There is a Twitter ID listed. You could try that and see what is up. I am currently super busy, but I'm ready to respond with changes to this PR if requested.

Since this was posted Apple has released macOS Sonoma. I have not upgraded yet over concerns about some of the problems people have reported. I am going to have to upgrade and see how much JPEG-XL support Apple added.

I'm not seeing any active forks, so I don't think anyone has pulled these changes and published an app. So as you suspected currently you must build JSLook with these changes using Xcode.

This project is not too hard to build. Xcode needs to be installed along with the command line tools. The repository needs to be cloned. Then you need to switch to this PR which can be easily done using the GitHub CLI. Then the build_libjxl.sh script needs to be run. Once all that is done then you can open the project in Xcode. At that point there is one last issue to overcome, which is the project is checked in expecting a developer account. So you must configure the project to build locally. I show how to do that in closed issue #21.

At least I think that is all that is needed. Been a while since I built JXLook and of course I don't know the situation with building under macOS Sonoma.

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.

None yet

3 participants