From eef270de2697e98cc6d7a26cbdadfc89ddbea82e Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 15 Oct 2023 15:30:41 -0500 Subject: [PATCH] Fix HDR with external displays on macOS Sonoma Fixes #1079 --- app/streaming/video/ffmpeg-renderers/vt.mm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/streaming/video/ffmpeg-renderers/vt.mm b/app/streaming/video/ffmpeg-renderers/vt.mm index d8d9ffc2..0db46df7 100644 --- a/app/streaming/video/ffmpeg-renderers/vt.mm +++ b/app/streaming/video/ffmpeg-renderers/vt.mm @@ -301,7 +301,18 @@ public: m_ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_709); break; case COLORSPACE_REC_2020: - m_ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_2020); + // This is necessary to ensure HDR works properly with external displays on macOS Sonoma. + if (frame->color_trc == AVCOL_TRC_SMPTE2084) { + if (@available(macOS 11.0, *)) { + m_ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_2100_PQ); + } + else { + m_ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_2020); + } + } + else { + m_ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_2020); + } break; case COLORSPACE_REC_601: m_ColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);