From 55ef990fee6c1588b63614255cc08705b118e7ed Mon Sep 17 00:00:00 2001 From: Michael Oliver Date: Sat, 24 Oct 2026 21:31:13 -0700 Subject: [PATCH] feat(ocio): warn when the OCIO display doesn't match the macOS presentation (#162) Choosing a display that the presentation mode's surface can't show right gave no sign that anything was wrong: ST2084-P3-D65 in HDR PQ presentation is read as Rec.2020 and oversaturated, Display P3 in SDR is read as sRGB and desaturated, and an HDR display in SDR or EDR gets the wrong levels. Warn in the log and on the view when the display is chosen or turned on and it's an ACES config display that doesn't fit the presentation, naming the one to use. Displays from other configs are never warned about. A source the OCIO display can't find an input color space for now also shows its warning on the view, by file name. Part of #154. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Michael Oliver --- .../ocio_source_setup/ocio_source_setup.py | 60 ++++++++++++++++++- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/src/plugins/rv-packages/ocio_source_setup/ocio_source_setup.py b/src/plugins/rv-packages/ocio_source_setup/ocio_source_setup.py index 16835f1b..dadac134 100644 --- a/src/plugins/rv-packages/ocio_source_setup/ocio_source_setup.py +++ b/src/plugins/rv-packages/ocio_source_setup/ocio_source_setup.py @@ -3,7 +3,7 @@ # # SPDX-License-Identifier: Apache-2.0 # -from rv import rvtypes, commands +from rv import rvtypes, commands, extra_commands import os import sys import urllib.request @@ -172,6 +172,55 @@ def read_presentation_mode(): return mode if mode in PRESENTATION_DISPLAYS else "sdr" +# +# The ACES config displays that show right in each presentation mode. +# The SDR and EDR surfaces have sRGB primaries, so P3 displays come out +# desaturated there, and the PQ and HLG surfaces are Rec.2100, so only +# the matching Rec.2100 display fits. Displays not named here (studio +# configs) are never warned about. +# + +SDR_DISPLAYS = ["sRGB - Display", "Gamma 2.2 Rec.709 - Display", "Rec.1886 Rec.709 - Display"] +PRESENTATION_COMPATIBLE_DISPLAYS = { + "sdr": SDR_DISPLAYS, + "edr": SDR_DISPLAYS, + "pq": ["Rec.2100-PQ - Display"], + "hlg": ["Rec.2100-HLG - Display"], +} +KNOWN_DISPLAYS = SDR_DISPLAYS + [ + "Display P3 - Display", + "Display P3 HDR - Display", + "P3-D65 - Display", + "Rec.2100-PQ - Display", + "Rec.2100-HLG - Display", + "ST2084-P3-D65 - Display", +] +PRESENTATION_NAMES = {"sdr": "SDR", "edr": "EDR", "pq": "HDR PQ (Rec.2100)", "hlg": "HDR HLG (Rec.2100)"} + + +def display_warning(config, mode, display): + 'Why the display won\'t show right in the macOS presentation mode, or "".' + if not mode or config is None or display not in KNOWN_DISPLAYS: + return "" + if display in PRESENTATION_COMPATIBLE_DISPLAYS[mode]: + return "" + expected = PRESENTATION_DISPLAYS[mode] + if expected not in config.getDisplays(): + return "" + return "%s doesn't match the %s presentation: colors or levels will be wrong. Use %s." % ( + display, + PRESENTATION_NAMES[mode], + expected, + ) + + +def warnAboutDisplay(config, display): + warning = display_warning(config, PRESENTATION_MODE, display) + if warning: + print("WARNING: OCIO: " + warning) + extra_commands.displayFeedback("OCIO: " + warning, 6.0) + + # The view reads the mode once at startup, so a changed preference only # applies after a restart. Read it here at the same time. PRESENTATION_MODE = read_presentation_mode() @@ -415,6 +464,7 @@ def F(event): commands.setStringProperty(dOCIO + ".ocio_display.display", [display], True) commands.setStringProperty(dOCIO + ".ocio_display.view", [view], True) commands.setIntProperty(dOCIO + ".ocio.active", [1], True) + warnAboutDisplay(theMode().config, display) commands.redraw() return F @@ -714,6 +764,9 @@ def useDisplayOCIO(self, group, source=None): commands.setIntProperty(activeProp, [1], True) self.usingOCIOForDisplay[group] = True + dOCIO = groupMemberOfType(dpipeline, "OCIODisplay") + if dOCIO is not None: + warnAboutDisplay(self.config, commands.getStringProperty(dOCIO + ".ocio_display.display")[0]) self.useSourceOCIOInputs() commands.redraw() @@ -797,7 +850,10 @@ def useSourceOCIOInputs(self, sources=None): continue colorspace = self.sourceInputColorSpace(source) if not colorspace: - print("WARNING: no OCIO input color space for %s; the OCIO display may show it wrongly" % source) + media = os.path.basename(commands.getStringProperty(source + ".media.movie")[0]) + warning = "no input color space for %s, so the OCIO display may show it wrongly." % media + print("WARNING: OCIO: " + warning) + extra_commands.displayFeedback("OCIO: " + warning, 6.0) continue self.useSourceOCIO(source, "OCIOFile", colorspace) if self.sourceUsesOCIOInput(source):