diff --git a/app/streaming/video/ffmpeg-renderers/plvk.cpp b/app/streaming/video/ffmpeg-renderers/plvk.cpp index 5ff03121..d03698b7 100644 --- a/app/streaming/video/ffmpeg-renderers/plvk.cpp +++ b/app/streaming/video/ffmpeg-renderers/plvk.cpp @@ -427,6 +427,13 @@ void PlVkRenderer::renderFrame(AVFrame *frame) return; } + // Adjust the swapchain if the colorspace of incoming frames has changed + if (!pl_color_space_equal(&mappedFrame.color, &m_LastColorspace)) { + m_LastColorspace = mappedFrame.color; + SDL_assert(pl_color_space_equal(&mappedFrame.color, &m_LastColorspace)); + pl_swapchain_colorspace_hint(m_Swapchain, &mappedFrame.color); + } + // Reserve enough space to avoid allocating under the overlay lock pl_overlay_part overlayParts[Overlay::OverlayMax] = {}; std::vector texturesToDestroy; @@ -649,43 +656,6 @@ void PlVkRenderer::notifyOverlayUpdated(Overlay::OverlayType type) SDL_AtomicUnlock(&m_OverlayLock); } -void PlVkRenderer::setHdrMode(bool enabled) -{ - pl_color_space csp = {}; - - if (enabled) { - csp.primaries = PL_COLOR_PRIM_BT_2020; - csp.transfer = PL_COLOR_TRC_PQ; - - // Use the host's provided HDR metadata if present - SS_HDR_METADATA hdrMetadata; - if (LiGetHdrMetadata(&hdrMetadata)) { - csp.hdr.prim.red.x = hdrMetadata.displayPrimaries[0].x / 50000.f; - csp.hdr.prim.red.y = hdrMetadata.displayPrimaries[0].y / 50000.f; - csp.hdr.prim.green.x = hdrMetadata.displayPrimaries[1].x / 50000.f; - csp.hdr.prim.green.y = hdrMetadata.displayPrimaries[1].y / 50000.f; - csp.hdr.prim.blue.x = hdrMetadata.displayPrimaries[2].x / 50000.f; - csp.hdr.prim.blue.y = hdrMetadata.displayPrimaries[2].y / 50000.f; - csp.hdr.prim.white.x = hdrMetadata.whitePoint.x / 50000.f; - csp.hdr.prim.white.y = hdrMetadata.whitePoint.y / 50000.f; - csp.hdr.min_luma = hdrMetadata.minDisplayLuminance / 10000.f; - csp.hdr.max_luma = hdrMetadata.maxDisplayLuminance; - csp.hdr.max_cll = hdrMetadata.maxContentLightLevel; - csp.hdr.max_fall = hdrMetadata.maxFrameAverageLightLevel; - } - else { - // Use the generic HDR10 metadata if the host doesn't provide HDR metadata - csp.hdr = pl_hdr_metadata_hdr10; - } - } - else { - csp.primaries = PL_COLOR_PRIM_UNKNOWN; - csp.transfer = PL_COLOR_TRC_UNKNOWN; - } - - pl_swapchain_colorspace_hint(m_Swapchain, &csp); -} - int PlVkRenderer::getRendererAttributes() { int attributes = 0; diff --git a/app/streaming/video/ffmpeg-renderers/plvk.h b/app/streaming/video/ffmpeg-renderers/plvk.h index b21e5dcf..e5bfb693 100644 --- a/app/streaming/video/ffmpeg-renderers/plvk.h +++ b/app/streaming/video/ffmpeg-renderers/plvk.h @@ -15,7 +15,6 @@ public: virtual void renderFrame(AVFrame* frame) override; virtual bool testRenderFrame(AVFrame* frame) override; virtual void notifyOverlayUpdated(Overlay::OverlayType) override; - virtual void setHdrMode(bool enabled) override; virtual int getRendererAttributes() override; virtual int getDecoderCapabilities() override; virtual bool needsTestFrame() override; @@ -44,6 +43,7 @@ private: pl_swapchain m_Swapchain = nullptr; pl_renderer m_Renderer = nullptr; pl_tex m_Textures[PL_MAX_PLANES] = {}; + pl_color_space m_LastColorspace = {}; // Overlay state SDL_SpinLock m_OverlayLock = 0;