Repository: xbmc/xbmc
File: xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererBase.cpp (C++)

Code before:
      DXGI_HDR_METADATA_HDR10 hdr10 = {};
      hdr10.RedPrimary[0] = 34000; // Display P3 primaries
      hdr10.RedPrimary[1] = 16000;
      hdr10.GreenPrimary[0] = 13250;
      hdr10.GreenPrimary[1] = 34500;
      hdr10.BluePrimary[0] = 7500;
      hdr10.BluePrimary[1] = 3000;
      hdr10.WhitePoint[0] = 15635;
      hdr10.WhitePoint[1] = 16450;
      hdr10.MaxMasteringLuminance = 1000 * 10000; // 1000 nits
      hdr10.MinMasteringLuminance = 50; // 0.005 nits
      DX::Windowing()->SetHdrMetaData(hdr10);
      CLog::LogF(LOGINFO, "Switching to HDR rendering");
      DX::Windowing()->SetHdrColorSpace(DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020);
      m_HdrType = HDR_TYPE::HDR_HLG;
      m_lastHdr10 = hdr10;
    }
  }
  // SDR
  else
  {
    if (m_HdrType != HDR_TYPE::HDR_NONE_SDR)
    {
      // Switch to SDR rendering
      CLog::LogF(LOGINFO, "Switching to SDR rendering");
      // not need set color space because is already set when swap chain is re-created
      if (m_AutoSwitchHDR)
      {
        if (DX::Windowing()->IsHDROutput())
          DX::Windowing()->ToggleHDR(); // Toggle display HDR OFF
      }
      else
      {
        DX::Windowing()->SetHdrColorSpace(DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709);
      }
      m_HdrType = HDR_TYPE::HDR_NONE_SDR;
      m_lastHdr10 = {};
    }
  }
}

DEBUG_INFO_VIDEO CRendererBase::GetDebugInfo(int idx)
{
  CRenderBuffer* rb = m_renderBuffers[idx];

  const char* px = av_get_pix_fmt_name(rb->pixelFormat);
  const char* pr = av_color_primaries_name(rb->primaries);
  const char* opr = av_color_primaries_name(rb->m_originalPrimaries);
  const char* tr = av_color_transfer_name(rb->color_transfer);

  const std::string pixel = px ? px : "unknown";

Review comment (suggestion):
ok but let's fix the comment not just the typo. I think it should be inside the if (m_AutoSwitchHDR) and something like
// color space already sdr or set by the swap chain re-creation

Code after:
      DXGI_HDR_METADATA_HDR10 hdr10 = {};
      hdr10.RedPrimary[0] = 34000; // Display P3 primaries
      hdr10.RedPrimary[1] = 16000;
      hdr10.GreenPrimary[0] = 13250;
      hdr10.GreenPrimary[1] = 34500;
      hdr10.BluePrimary[0] = 7500;
      hdr10.BluePrimary[1] = 3000;
      hdr10.WhitePoint[0] = 15635;
      hdr10.WhitePoint[1] = 16450;
      hdr10.MaxMasteringLuminance = 1000 * 10000; // 1000 nits
      hdr10.MinMasteringLuminance = 50; // 0.005 nits
      DX::Windowing()->SetHdrMetaData(hdr10);
      CLog::LogF(LOGINFO, "Switching to HDR rendering");
      DX::Windowing()->SetHdrColorSpace(DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020);
      m_HdrType = HDR_TYPE::HDR_HLG;
      m_lastHdr10 = hdr10;
    }
  }
  // SDR
  else
  {
    if (m_HdrType != HDR_TYPE::HDR_NONE_SDR)
    {
      // Switch to SDR rendering
      CLog::LogF(LOGINFO, "Switching to SDR rendering");
      if (m_AutoSwitchHDR)
      {
        // color space already sdr or set by the swap chain re-creation
        if (DX::Windowing()->IsHDROutput())
          DX::Windowing()->ToggleHDR(); // Toggle display HDR OFF
      }
      else
      {
        DX::Windowing()->SetHdrColorSpace(DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709);
      }
      m_HdrType = HDR_TYPE::HDR_NONE_SDR;
      m_lastHdr10 = {};
    }
  }
}

DEBUG_INFO_VIDEO CRendererBase::GetDebugInfo(int idx)
{
  CRenderBuffer* rb = m_renderBuffers[idx];

  const char* px = av_get_pix_fmt_name(rb->pixelFormat);
  const char* pr = av_color_primaries_name(rb->primaries);
  const char* opr = av_color_primaries_name(rb->m_originalPrimaries);
  const char* tr = av_color_transfer_name(rb->color_transfer);

  const std::string pixel = px ? px : "unknown";