-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Close add HDR tone mapping settings, #4358 #4360
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
Conversation
Notes for ReviewersA few things of note…
Changes Made During MergeI made some changes during the merge. Hopefully they seem reasonable, if not object! Audio/Video Settings PanelI indented the controls for I greatly simplified the descriptions of the new settings to match the existing "minimal" style. Of note the original descriptions contain URLs pointing to the relevant section of the mpv manual:
That is an interesting idea. Of course these should be clickable links and we'd have to discuss whether they should point to a version specific manual rather than master. Since this is not done for other settings I thought it best to consider such a change for the feature release and update the descriptions of many settings. I this particular case referencing the mpv manual might make you think you could use the value I also tried to correct constraint warnings reported by Xcode. @svobs, If you have time please take a look and see if I'm adding regressions with respects to layout constraints. LoggingTo avoid the large log message that results from logging the full display info dictionary I changed the logging in Preference HandlingI changed the code in defaults write com.colliderli.iina.plist toneMappingAlgorithm 99 In other words even though users should not be messing with the preference file behind IINA's back we treat it as external input and provide some protection against invalid values. Screen ShotsThe original code with detailed descriptions of the settings: |
mpv.setString(MPVOption.GPURendererOptions.targetPrim, primaries) | ||
// PQ videos will be display as it was, HLG videos will be converted to PQ | ||
mpv.setString(MPVOption.GPURendererOptions.targetTrc, "pq") | ||
mpv.setFlag(MPVOption.Screenshot.screenshotTagColorspace, true) |
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.
This was used for screenshot in jxl format.
Since (newer) mpv actually doesn't support ppm / pgm ..., I suggest merging my screenshot code too.
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 had not noticed the old screenshot formats. They were removed from the UI in commit 994d622 back in 2017. I guess they did not remove the values from the enum to preserve compatibility with old plists. Probably safe to remove them now. I found the IINA+ commit that adds the new formats. I will prepare a separate PR for that change. Thanks for pointing this out.
I like the style change in preferences window. Good work! However, as tone-mapping algorithm is hard to understand for most people, I still prefer keeping the link to MPV document. |
I do like the idea of linking to the mpv manual. If the other reviewers approve I can make that change. I think they need to be clickable links. I'm thinking they should link to the stable manual and not master. Thoughts reviewers? |
@low-batt Can you rebase this PR? I'm having a hard time building this PR since we've already updated our deps. We should align the new options with previous options. I understand you are trying to align the texts, but this seems off to me. The original design looks better to me in this sense. As for link to the mpv manual, we can definitely do that, but adding a clickable button to the link of mpv manual is better, just like we previously did: |
I will rebase and fix the merge conflicts. I will add Late here. I will get this done tomorrow. |
This commit will: - Add the new settings enableToneMapping, toneMappingTargetPeak and toneMappingAlgorithm - Update the Audio/Video settings panel to allow the user to control these settings - Update VideoView.refreshEdrMode to support these new settings - Add the CoreDisplay framework to the Xcode project - Add support to VideoView.refreshEdrMode to automatically determine the target peak setting based on the peak brightness of the display using the CoreDisplay framework - Add reporting of the pixel format to the Inspector window - Enhance HDR detection in InspectorWindowController.updateInfo - Correct the path to the PiP framework in the Xcode project These change provide the ability to mpv's tone mapping when playing HDR videos. The main author of these changes is Carter Li. This is a merge of changes that have been tested in his IINA fork. A few minor changes were made during the merge. Co-authored-by: CarterLi <carter.li@eoitek.com>
This commit will: - Add the new settings enableToneMapping, toneMappingTargetPeak and toneMappingAlgorithm - Update the Audio/Video settings panel to allow the user to control these settings - Add help buttons that link to Wikipedia and the appropriate sections of the mpv manual - Update VideoView.refreshEdrMode to support these new settings - Add the CoreDisplay framework to the Xcode project - Add support to VideoView.refreshEdrMode to automatically determine the target peak setting based on the peak brightness of the display using the CoreDisplay framework - Add reporting of the pixel format to the Inspector window - Enhance HDR detection in InspectorWindowController.updateInfo - Correct the path to the PiP framework in the Xcode project These change provide the ability to mpv's tone mapping when playing HDR videos. The main author of these changes is Carter Li. This is a merge of changes that have been tested in his IINA fork. A few minor changes were made during the merge. Co-authored-by: CarterLi <carter.li@eoitek.com>
I rebased with I added help buttons that link to:
The panel now looks like: |
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.
Should we call refreshEdrMode
when the display is changed? A quick search shows that we are not doing that currently, but I might have missed that.
From a UI point of view, I think the text field under "Enable tone mapping" and the text field under the algorithm drop down do not provide useful information, given that we already provide the help link to the users. If they are confused by the settings, these text fields would not help.
For the text field under "Target peak", should we also inform the users that if we cannot detect automatically, the nits value will fallback to 400 nits?
iina/PrefCodecViewController.swift
Outdated
@@ -99,4 +103,21 @@ class PrefCodecViewController: PreferenceViewController, PreferenceWindowEmbedda | |||
let hwdec: Preference.HardwareDecoderOption = Preference.enum(for: .hardwareDecoder) | |||
hwdecDescriptionTextField.stringValue = hwdec.localizedDescription | |||
} | |||
|
|||
@IBAction func updateEnableToneMapping(_ sender: NSButton) { |
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.
Can you do this in xib by bindings?
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.
Yes, I'm changing this to binding enabling of the two controls to the checkbox in the XIB.
iina/VideoView.swift
Outdated
player.mpv.setString(MPVOption.GPURendererOptions.targetPeak, "auto") | ||
player.mpv.setString(MPVOption.GPURendererOptions.toneMapping, "auto") | ||
player.mpv.setString(MPVOption.GPURendererOptions.toneMappingParam, "default") | ||
player.mpv.setString(MPVOption.GPURendererOptions.toneMapping, "") |
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.
Why did you set this option twice? On line 319
player.mpv.setString(MPVOption.GPURendererOptions.toneMapping, "auto")
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.
Because it is that way in the code in the other repository and I failed to notice that when preparing the merge. GOOD CATCH!
The "auto" for toneMapping was a recent add by mpv, so maybe the empty string setting was supposed to be removed after upgrading to 035.1?
@CarterLi Which is the correct value to use?
I'm going to guess "auto" and remove the setting to the empty string.
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.
Just use the default value of MPV
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 default is "auto", so I removed this line that is in IINA+
iina/VideoView.swift
Outdated
targetPeak = hdrLuminance | ||
} else if let hdrLuminance = displayInfo["DisplayBacklight"] as? Int { | ||
// We know macOS Catalina uses this key. | ||
Logger.log("Found DisplayBacklight: \(hdrLuminance)", subsystem: hdrSubsystem); |
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.
Remove ;
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 did a search in this source and removed a number of semicolons.
iina/VideoView.swift
Outdated
Logger.log("Successfully obtained information about the display", subsystem: hdrSubsystem) | ||
// Prefer ReferencePeakHDRLuminance, which is reported by newer macOS versions. | ||
if let hdrLuminance = displayInfo["ReferencePeakHDRLuminance"] as? Int { | ||
Logger.log("Found ReferencePeakHDRLuminance: \(hdrLuminance)", subsystem: hdrSubsystem); |
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.
Remove ;
iina/VideoView.swift
Outdated
Logger.log("Found DisplayBacklight: \(hdrLuminance)", subsystem: hdrSubsystem); | ||
targetPeak = hdrLuminance | ||
} else { | ||
Logger.log("Didn't find ReferencePeakHDRLuminance or DisplayBacklight, assuming HDR400", subsystem: hdrSubsystem); |
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.
Remove ;
iina/VideoView.swift
Outdated
targetPeak = 400 | ||
} | ||
} else { | ||
Logger.log("Unable to obtain display information", level: .warning, subsystem: hdrSubsystem); |
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.
Remove ;
iina/VideoView.swift
Outdated
let algorithm = Preference.ToneMappingAlgorithmOption(rawValue: Preference.integer(for: .toneMappingAlgorithm))?.mpvString | ||
?? Preference.ToneMappingAlgorithmOption.defaultValue.mpvString | ||
|
||
Logger.log("Will enable tone mapping target-peak=\(targetPeak) algorithm=\(algorithm)", subsystem: hdrSubsystem); |
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.
Remove ;
iina/VideoView.swift
Outdated
targetPeak = 400 | ||
} | ||
} else { | ||
Logger.log("Unable to obtain display information", level: .warning, subsystem: hdrSubsystem); |
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.
We should also fallback the target peak to 400 if the display info cannot be obtained. Otherwise if we cannot obtain the display info, MPVOption.GPURendererOptions.targetPeak
will be set to 0 later.
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've updated this to also default to 400.
This commit will: - Add the new settings enableToneMapping, toneMappingTargetPeak and toneMappingAlgorithm - Update the Audio/Video settings panel to allow the user to control these settings - Update VideoView.refreshEdrMode to support these new settings - Add the CoreDisplay framework to the Xcode project - Add support to VideoView.refreshEdrMode to automatically determine the target peak setting based on the peak brightness of the display using the CoreDisplay framework - Add reporting of the pixel format to the Inspector window - Enhance HDR detection in InspectorWindowController.updateInfo - Correct the path to the PiP framework in the Xcode project These change provide the ability to mpv's tone mapping when playing HDR videos. The main author of these changes is Carter Li. This is a merge of changes that have been tested in his IINA fork. A few minor changes were made during the merge. Co-authored-by: CarterLi <carter.li@eoitek.com>
This commit will:
enableToneMapping
,toneMappingTargetPeak
andtoneMappingAlgorithm
Audio/Video
settings panel to allow the user to control these settingsVideoView.refreshEdrMode
to support these new settingsCoreDisplay
framework to the Xcode projectVideoView.refreshEdrMode
to automatically determine the target peak setting based on the peak brightness of the display using theCoreDisplay
frameworkInspectorWindowController.updateInfo
These change provide the ability to mpv's tone mapping when playing HDR videos.
The main author of these changes is Carter Li. This is a merge of changes that have been tested in his IINA fork. A few minor changes were made during the merge.
Description: