-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix colormanagement broken in 1.3.0, #3929 #5213
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
This is a draft because we need to update the |
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.
Tested with libmpv
+latest patches, confirmed user can override ICC profile when "Load ICC Profile" checkbox is checked. (The recompiled libmpv
hasn't been uploaded yet)
A few questions here, not blocking this PR tho:
videoLayer
's colorspace is always set to window's colorspace, even though the user provide their own ICC profile. Is this desired?- The
vcolorspaceField
now will only show the color profile of the screen (system setting), even though the user provide their own ICC profile. Is this correct?
I don't know enough about color spaces to provide an authoritative answer. What I can say is that the mpv code does not take into account the icc-profile option when setting the color space of the layer. |
|
Too late here for me to be thinking, so just one comment. The |
Update: libmpv is uploaded. Convert this PR to ready for review. |
To be clear, I am not suggesting that |
@@ -347,6 +347,40 @@ class ViewLayer: CAOpenGLLayer { | |||
return ctx | |||
} | |||
|
|||
// MARK: - ICC Profile |
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 was this put in ViewLayer
? Looks like it would fit better in MPVController
(or even just VideoView
). You could pull out the videoView.$isUninited.withLock
into the calling method to keep it inside VideoView
and reduce level of nested code.
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.
Sorry I'm slow in responding. Been focused on the JPEG XL problems.
The plan is to put it in MPVRenderer
, along with all the render related code currently in MPVController
, similar to how mpv structures the code. But I got interrupted doing that refactoring. As we are now looking to freeze changes, test and release the first beta, this refactoring will have to wait for a future release. So this method is here temporarily.
iina/VideoView.swift
Outdated
logHDR("Not using ICC profile due to user preference") | ||
player.mpv.setFlag(MPVOption.GPURendererOptions.iccProfileAuto, false) | ||
} else if let screenColorSpace { | ||
logHDR("Using ICC profile") |
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.
Might be good to change this message to "Configuring auto ICC profile" or something with "auto" in it
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.
Will fix.
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 updated the log message to include the name of the color space:
19:10:15.183 [hdr0][d] Using the ICC profile of the color space LG UltraFine
I didn't mention any thing about automatically, because IINA doesn't take advantage of that aspect of the option. IINA is manually turning icc-profile-auto
on and off.
/// The IINA `Load ICC profile` setting is tied to the `--icc-profile-auto` option. This allows users to override IINA using | ||
/// the [--icc-profile](https://mpv.io/manual/stable/#options-icc-profile) option. | ||
func setRenderICCProfile(_ profile: NSColorSpace) { | ||
videoView.$isUninited.withLock() { isUninited in |
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 merged this PR into my own code yesterday and have since been getting frequent crashes at startup when using the Xcode debugger, coming from inside mpv_render_context_render
. The last 2 I saved:
Assertion failed: (tex->params.render_src), function update_uniform, file ra_gl.c, line 990.
Assertion failed: (h->canary == CANARY), function ta_dbg_check_header, file ta.c, line 291.
I did some experiments and it looks like I fixed it by locking the OpenGL context around the isUninited
lock here in setRenderICCProfile
. I realize my code is different than develop
but I do suspect the problem exists here but just may be more rare. I suspect mpv needs calls to mpv_render_context_set_parameter
to be isolated from all other rendering-related operations.
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 will make this a draft and look into this.
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, that was it. I added the code to lock the OpenGL context.
Changed to draft while I look into the crashes @svobs encountered. |
This commit will: - Add a new method setRenderICCProfile to VideoLayer that sets MPV_RENDER_PARAM_ICC_PROFILE - Remove setting of the mpv option icc-profile from the VideoView method setICCProfile - Change VideoView to use icc-profile-auto instead of icc-profile to control use of an ICC profile Using icc-profile-auto frees icc-profile for use by users as icc-profile overrides icc-profile-auto. IINA must set MPV_RENDER_PARAM_ICC_PROFILE in order for icc-profile-auto to work.
This commit will: - Add a new method setRenderICCProfile to VideoLayer that sets MPV_RENDER_PARAM_ICC_PROFILE - Remove setting of the mpv option icc-profile from the VideoView method setICCProfile - Change VideoView to use icc-profile-auto instead of icc-profile to control use of an ICC profile Using icc-profile-auto frees icc-profile for use by users as icc-profile overrides icc-profile-auto. IINA must set MPV_RENDER_PARAM_ICC_PROFILE in order for icc-profile-auto to work.
* Fix colormanagement broken in 1.3.0, iina#3929 This commit will: - Add a new method setRenderICCProfile to VideoLayer that sets MPV_RENDER_PARAM_ICC_PROFILE - Remove setting of the mpv option icc-profile from the VideoView method setICCProfile - Change VideoView to use icc-profile-auto instead of icc-profile to control use of an ICC profile Using icc-profile-auto frees icc-profile for use by users as icc-profile overrides icc-profile-auto. IINA must set MPV_RENDER_PARAM_ICC_PROFILE in order for icc-profile-auto to work. * Fix colormanagement broken in 1.3.0, iina#3929 This commit will: - Add a new method setRenderICCProfile to VideoLayer that sets MPV_RENDER_PARAM_ICC_PROFILE - Remove setting of the mpv option icc-profile from the VideoView method setICCProfile - Change VideoView to use icc-profile-auto instead of icc-profile to control use of an ICC profile Using icc-profile-auto frees icc-profile for use by users as icc-profile overrides icc-profile-auto. IINA must set MPV_RENDER_PARAM_ICC_PROFILE in order for icc-profile-auto to work.
This commit will:
setRenderICCProfile
toVideoLayer
that setsMPV_RENDER_PARAM_ICC_PROFILE
icc-profile
from theVideoView
methodsetICCProfile
VideoView
to useicc-profile-auto
instead oficc-profile
to control use of an ICC profileUsing
icc-profile-auto
freesicc-profile
for use by users asicc-profile
overridesicc-profile-auto
. IINA must setMPV_RENDER_PARAM_ICC_PROFILE
in order foricc-profile-auto
to work.Description: