Skip to content

Commit

Permalink
gbm: Set max bpc and color format for high bit depth videos
Browse files Browse the repository at this point in the history
  • Loading branch information
popcornmix committed Jul 1, 2021
1 parent fd5c67f commit d95c707
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
16 changes: 12 additions & 4 deletions xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,24 @@ extern "C"
namespace DRMPRIME
{

std::string GetColorimetry(const VideoPicture& picture)
std::string GetColorimetry(const VideoPicture& picture, bool ycc)
{
switch (picture.color_space)
{
case AVCOL_SPC_BT2020_CL:
case AVCOL_SPC_BT2020_NCL:
return "BT2020_RGB";
return ycc ? "BT2020_YCC" : "BT2020_RGB";
case AVCOL_SPC_SMPTE170M:
case AVCOL_SPC_BT470BG:
case AVCOL_SPC_FCC:
return "XVYCC_601";
case AVCOL_SPC_BT709:
return "XVYCC_709";
case AVCOL_SPC_RESERVED:
case AVCOL_SPC_UNSPECIFIED:
default:
return "Default";
}

return "Default";
}

std::string GetColorEncoding(const VideoPicture& picture)
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ enum hdmi_eotf
HDMI_EOTF_BT_2100_HLG,
};

std::string GetColorimetry(const VideoPicture& picture);
std::string GetColorimetry(const VideoPicture& picture, bool ycc);
std::string GetColorEncoding(const VideoPicture& picture);
std::string GetColorRange(const VideoPicture& picture);
uint8_t GetEOTF(const VideoPicture& picture);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ void CVideoLayerBridgeDRMPRIME::Disable()
m_DRM->AddProperty(connector, "Colorspace", value);
}

std::tie(result, value) = connector->GetPropertyValue("hdmi color formats", "Default");
if (result)
{
CLog::Log(LOGDEBUG, "CVideoLayerBridgeDRMPRIME::{} - setting connector hdmi color formats to Default", __FUNCTION__);
m_DRM->AddProperty(connector, "hdmi color formats", value);
}

result = m_DRM->AddProperty(connector, "max bpc", 8);
if (!result)
{
CLog::Log(LOGDEBUG, "CVideoLayerBridgeDRMPRIME::{} - failed to reset max bpc", __FUNCTION__);
}


// disable HDR metadata
if (connector->SupportsProperty("HDR_OUTPUT_METADATA"))
{
Expand Down Expand Up @@ -185,15 +199,38 @@ void CVideoLayerBridgeDRMPRIME::Configure(CVideoBufferDRMPRIME* buffer)

auto connector = m_DRM->GetConnector();

std::tie(result, value) = connector->GetPropertyValue("Colorspace", GetColorimetry(picture));
int bpc = 8;
bool ycc = false;
std::string color_format = "Default";

if (picture.colorBits > 8)
{
bpc = 12;
ycc = true;
color_format = "YCrCb422";
}

std::tie(result, value) = connector->GetPropertyValue("Colorspace", GetColorimetry(picture, ycc));
if (result)
{
CLog::Log(LOGDEBUG, "CVideoLayerBridgeDRMPRIME::{} - setting connector colorspace to {}", __FUNCTION__,
GetColorimetry(picture));
GetColorimetry(picture, ycc));
m_DRM->AddProperty(connector, "Colorspace", value);
m_DRM->SetActive(true);
}

result = m_DRM->AddProperty(connector, "max bpc", bpc);
CLog::Log(LOGDEBUG, "CVideoLayerBridgeDRMPRIME::{} - setting max bpc to {} ({})", __FUNCTION__,
bpc, result);
std::tie(result, value) = connector->GetPropertyValue("hdmi color formats", color_format);
if (result)
{
CLog::Log(LOGDEBUG, "CVideoLayerBridgeDRMPRIME::{} - setting connector hdmi color formats to {}",
__FUNCTION__, color_format);
m_DRM->AddProperty(connector, "hdmi color formats", value);
m_DRM->SetActive(true);
}

if (connector->SupportsProperty("HDR_OUTPUT_METADATA"))
{
m_hdr_metadata.metadata_type = HDMI_STATIC_METADATA_TYPE1;
Expand Down

0 comments on commit d95c707

Please sign in to comment.