aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Blake <oak99sky@yahoo.co.uk>2020-12-06 09:38:53 +0000
committerGitHub <noreply@github.com>2020-12-06 09:38:53 +0000
commit72d16f54ecc75c4ec224d9ee6d0a92905aa78327 (patch)
tree158e8efed6dd21e8bb4855ce23da0f3b6d983f9c
parent1d1581dc7f39634c9ea19ad416ab80b869359368 (diff)
parent9b8f600127f033a3c606d80e5008a9e8a42c96e2 (diff)
Merge pull request #18858 from lrusak/drm-object-corrections
[linux] drm object changes
-rw-r--r--xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.cpp18
-rw-r--r--xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h17
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.cpp66
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.h4
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp13
-rw-r--r--xbmc/windowing/gbm/drm/DRMAtomic.cpp28
-rw-r--r--xbmc/windowing/gbm/drm/DRMObject.cpp76
-rw-r--r--xbmc/windowing/gbm/drm/DRMObject.h10
8 files changed, 102 insertions, 130 deletions
diff --git a/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.cpp b/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.cpp
index 25da2de9e9..b85097d37b 100644
--- a/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.cpp
+++ b/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.cpp
@@ -19,34 +19,34 @@ extern "C"
namespace DRMPRIME
{
-int GetColorEncoding(const VideoPicture& picture)
+std::string GetColorEncoding(const VideoPicture& picture)
{
switch (picture.color_space)
{
case AVCOL_SPC_BT2020_CL:
case AVCOL_SPC_BT2020_NCL:
- return DRM_COLOR_YCBCR_BT2020;
+ return "ITU-R BT.2020 YCbCr";
case AVCOL_SPC_SMPTE170M:
case AVCOL_SPC_BT470BG:
case AVCOL_SPC_FCC:
- return DRM_COLOR_YCBCR_BT601;
+ return "ITU-R BT.601 YCbCr";
case AVCOL_SPC_BT709:
- return DRM_COLOR_YCBCR_BT709;
+ return "ITU-R BT.709 YCbCr";
case AVCOL_SPC_RESERVED:
case AVCOL_SPC_UNSPECIFIED:
default:
if (picture.iWidth > 1024 || picture.iHeight >= 600)
- return DRM_COLOR_YCBCR_BT709;
+ return "ITU-R BT.709 YCbCr";
else
- return DRM_COLOR_YCBCR_BT601;
+ return "ITU-R BT.601 YCbCr";
}
}
-int GetColorRange(const VideoPicture& picture)
+std::string GetColorRange(const VideoPicture& picture)
{
if (picture.color_range)
- return DRM_COLOR_YCBCR_FULL_RANGE;
- return DRM_COLOR_YCBCR_LIMITED_RANGE;
+ return "YCbCr full range";
+ return "YCbCr limited range";
}
uint8_t GetEOTF(const VideoPicture& picture)
diff --git a/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h b/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h
index 822c00fd20..ebced6f5ef 100644
--- a/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h
+++ b/xbmc/cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h
@@ -21,19 +21,6 @@ extern "C"
namespace DRMPRIME
{
-// Color enums is copied from linux include/drm/drm_color_mgmt.h (strangely not part of uapi)
-enum drm_color_encoding
-{
- DRM_COLOR_YCBCR_BT601,
- DRM_COLOR_YCBCR_BT709,
- DRM_COLOR_YCBCR_BT2020,
-};
-enum drm_color_range
-{
- DRM_COLOR_YCBCR_LIMITED_RANGE,
- DRM_COLOR_YCBCR_FULL_RANGE,
-};
-
// HDR enums is copied from linux include/linux/hdmi.h (strangely not part of uapi)
enum hdmi_metadata_type
{
@@ -47,8 +34,8 @@ enum hdmi_eotf
HDMI_EOTF_BT_2100_HLG,
};
-int GetColorEncoding(const VideoPicture& picture);
-int GetColorRange(const VideoPicture& picture);
+std::string GetColorEncoding(const VideoPicture& picture);
+std::string GetColorRange(const VideoPicture& picture);
uint8_t GetEOTF(const VideoPicture& picture);
const AVMasteringDisplayMetadata* GetMasteringDisplayMetadata(const VideoPicture& picture);
const AVContentLightMetadata* GetContentLightMetadata(const VideoPicture& picture);
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.cpp
index d60adf4889..dfc34dd6be 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.cpp
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.cpp
@@ -12,6 +12,42 @@
using namespace DRMPRIME;
+namespace
+{
+
+int GetEGLColorSpace(const VideoPicture& picture)
+{
+ switch (picture.color_space)
+ {
+ case AVCOL_SPC_BT2020_CL:
+ case AVCOL_SPC_BT2020_NCL:
+ return EGL_ITU_REC2020_EXT;
+ case AVCOL_SPC_SMPTE170M:
+ case AVCOL_SPC_BT470BG:
+ case AVCOL_SPC_FCC:
+ return EGL_ITU_REC601_EXT;
+ case AVCOL_SPC_BT709:
+ return EGL_ITU_REC709_EXT;
+ case AVCOL_SPC_RESERVED:
+ case AVCOL_SPC_UNSPECIFIED:
+ default:
+ if (picture.iWidth > 1024 || picture.iHeight >= 600)
+ return EGL_ITU_REC709_EXT;
+ else
+ return EGL_ITU_REC601_EXT;
+ }
+}
+
+int GetEGLColorRange(const VideoPicture& picture)
+{
+ if (picture.color_range)
+ return EGL_YUV_FULL_RANGE_EXT;
+
+ return EGL_YUV_NARROW_RANGE_EXT;
+}
+
+} // namespace
+
CDRMPRIMETexture::~CDRMPRIMETexture()
{
glDeleteTextures(1, &m_texture);
@@ -55,8 +91,8 @@ bool CDRMPRIMETexture::Map(CVideoBufferDRMPRIME* buffer)
attribs.width = m_texWidth;
attribs.height = m_texHeight;
attribs.format = layer->format;
- attribs.colorSpace = GetColorSpace(DRMPRIME::GetColorEncoding(buffer->GetPicture()));
- attribs.colorRange = GetColorRange(DRMPRIME::GetColorRange(buffer->GetPicture()));
+ attribs.colorSpace = GetEGLColorSpace(buffer->GetPicture());
+ attribs.colorRange = GetEGLColorRange(buffer->GetPicture());
attribs.planes = planes;
if (!m_eglImage->CreateImage(attribs))
@@ -94,29 +130,3 @@ void CDRMPRIMETexture::Unmap()
m_primebuffer->Release();
m_primebuffer = nullptr;
}
-
-int CDRMPRIMETexture::GetColorSpace(int colorSpace)
-{
- switch (colorSpace)
- {
- case DRM_COLOR_YCBCR_BT2020:
- return EGL_ITU_REC2020_EXT;
- case DRM_COLOR_YCBCR_BT601:
- return EGL_ITU_REC601_EXT;
- case DRM_COLOR_YCBCR_BT709:
- default:
- return EGL_ITU_REC709_EXT;
- }
-}
-
-int CDRMPRIMETexture::GetColorRange(int colorRange)
-{
- switch (colorRange)
- {
- case DRM_COLOR_YCBCR_FULL_RANGE:
- return EGL_YUV_FULL_RANGE_EXT;
- case DRM_COLOR_YCBCR_LIMITED_RANGE:
- default:
- return EGL_YUV_NARROW_RANGE_EXT;
- }
-}
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.h b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.h
index d39c5f2b96..e1e1310f28 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.h
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.h
@@ -35,8 +35,4 @@ protected:
GLuint m_texture{0};
int m_texWidth{0};
int m_texHeight{0};
-
-private:
- static int GetColorSpace(int colorSpace);
- static int GetColorRange(int colorRange);
};
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp
index 1f514c659a..4f07ffc0b8 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp
@@ -161,11 +161,16 @@ void CVideoLayerBridgeDRMPRIME::Configure(CVideoBufferDRMPRIME* buffer)
const VideoPicture& picture = buffer->GetPicture();
auto plane = m_DRM->GetVideoPlane();
- if (plane->SupportsPropertyAndValue("COLOR_ENCODING", GetColorEncoding(picture)))
- m_DRM->AddProperty(plane, "COLOR_ENCODING", GetColorEncoding(picture));
- if (plane->SupportsPropertyAndValue("COLOR_RANGE", GetColorRange(picture)))
- m_DRM->AddProperty(plane, "COLOR_RANGE", GetColorRange(picture));
+ bool result;
+ uint64_t value;
+ std::tie(result, value) = plane->GetPropertyValue("COLOR_ENCODING", GetColorEncoding(picture));
+ if (result)
+ m_DRM->AddProperty(plane, "COLOR_ENCODING", value);
+
+ std::tie(result, value) = plane->GetPropertyValue("COLOR_RANGE", GetColorRange(picture));
+ if (result)
+ m_DRM->AddProperty(plane, "COLOR_RANGE", value);
auto connector = m_DRM->GetConnector();
if (connector->SupportsProperty("HDR_OUTPUT_METADATA"))
diff --git a/xbmc/windowing/gbm/drm/DRMAtomic.cpp b/xbmc/windowing/gbm/drm/DRMAtomic.cpp
index 9270aa7e99..37166b8dcd 100644
--- a/xbmc/windowing/gbm/drm/DRMAtomic.cpp
+++ b/xbmc/windowing/gbm/drm/DRMAtomic.cpp
@@ -46,19 +46,21 @@ uint32_t GetScalingFactor(uint32_t srcWidth,
bool CDRMAtomic::SetScalingFilter(CDRMObject* object, const char* name, const char* type)
{
- uint64_t filter_type{};
- if (m_gui_plane->GetPropertyValue(name, type, filter_type))
- {
- if (AddProperty(object, name, filter_type))
- {
- uint32_t mar_scale_factor =
- GetScalingFactor(m_width, m_height, m_mode->hdisplay, m_mode->vdisplay);
- AddProperty(object, "CRTC_W", (mar_scale_factor * m_width));
- AddProperty(object, "CRTC_H", (mar_scale_factor * m_height));
- return true;
- }
- }
- return false;
+ bool result;
+ uint64_t value;
+ std::tie(result, value) = m_gui_plane->GetPropertyValue(name, type);
+ if (!result)
+ return false;
+
+ if (!AddProperty(object, name, value))
+ return false;
+
+ uint32_t mar_scale_factor =
+ GetScalingFactor(m_width, m_height, m_mode->hdisplay, m_mode->vdisplay);
+ AddProperty(object, "CRTC_W", (mar_scale_factor * m_width));
+ AddProperty(object, "CRTC_H", (mar_scale_factor * m_height));
+
+ return true;
}
void CDRMAtomic::DrmAtomicCommit(int fb_id, int flags, bool rendered, bool videoLayer)
diff --git a/xbmc/windowing/gbm/drm/DRMObject.cpp b/xbmc/windowing/gbm/drm/DRMObject.cpp
index 6449cfd86e..7d27c6f059 100644
--- a/xbmc/windowing/gbm/drm/DRMObject.cpp
+++ b/xbmc/windowing/gbm/drm/DRMObject.cpp
@@ -8,7 +8,6 @@
#include "DRMObject.h"
-#include "utils/StringUtils.h"
#include "utils/log.h"
#include <algorithm>
@@ -54,11 +53,10 @@ std::string CDRMObject::GetPropertyName(uint32_t propertyId) const
return "invalid property";
}
-uint32_t CDRMObject::GetPropertyId(const char* name) const
+uint32_t CDRMObject::GetPropertyId(const std::string& name) const
{
- auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), [&name](auto& prop) {
- return StringUtils::EqualsNoCase(prop->name, name);
- });
+ auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(),
+ [&name](auto& prop) { return prop->name == name; });
if (property != m_propsInfo.end())
return property->get()->prop_id;
@@ -82,37 +80,36 @@ bool CDRMObject::GetProperties(uint32_t id, uint32_t type)
return true;
}
-bool CDRMObject::GetPropertyValue(std::string name, const std::string& type, uint64_t& value) const
+//! @todo: improve with c++17
+std::tuple<bool, uint64_t> CDRMObject::GetPropertyValue(const std::string& name,
+ const std::string& valueName) const
{
- auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), [&name](auto& prop) {
- return StringUtils::EqualsNoCase(prop->name, name);
- });
+ auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(),
+ [&name](auto& prop) { return prop->name == name; });
if (property == m_propsInfo.end())
- return false;
+ return std::make_tuple(false, 0);
auto prop = property->get();
- if (drm_property_type_is(prop, DRM_MODE_PROP_ENUM) != 0)
+ if (!static_cast<bool>(drm_property_type_is(prop, DRM_MODE_PROP_ENUM)))
+ return std::make_tuple(false, 0);
+
+ for (int j = 0; j < prop->count_enums; j++)
{
- for (int j = 0; j < prop->count_enums; j++)
- {
- if (std::strcmp(prop->enums[j].name, type.c_str()) == 0)
- {
- value = prop->enums[j].value;
- return true;
- }
- }
+ if (prop->enums[j].name != valueName)
+ continue;
+
+ return {true, prop->enums[j].value};
}
- return false;
+ return std::make_tuple(false, 0);
}
-bool CDRMObject::SetProperty(const char* name, uint64_t value)
+bool CDRMObject::SetProperty(const std::string& name, uint64_t value)
{
- auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), [&name](auto& prop) {
- return StringUtils::EqualsNoCase(prop->name, name);
- });
+ auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(),
+ [&name](auto& prop) { return prop->name == name; });
if (property != m_propsInfo.end())
{
@@ -124,38 +121,13 @@ bool CDRMObject::SetProperty(const char* name, uint64_t value)
return false;
}
-bool CDRMObject::SupportsProperty(const char* name)
+bool CDRMObject::SupportsProperty(const std::string& name)
{
- auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), [&name](auto& prop) {
- return StringUtils::EqualsNoCase(prop->name, name);
- });
+ auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(),
+ [&name](auto& prop) { return prop->name == name; });
if (property != m_propsInfo.end())
return true;
return false;
}
-
-bool CDRMObject::SupportsPropertyAndValue(const char* name, uint64_t value)
-{
- auto property = std::find_if(m_propsInfo.begin(), m_propsInfo.end(), [&name](auto& prop) {
- return StringUtils::EqualsNoCase(prop->name, name);
- });
-
- if (property != m_propsInfo.end())
- {
- if (drm_property_type_is(property->get(), DRM_MODE_PROP_ENUM) != 0)
- {
- for (int j = 0; j < property->get()->count_enums; j++)
- {
- if (property->get()->enums[j].value == value)
- return true;
- }
- }
-
- CLog::Log(LOGDEBUG, "CDRMObject::{} - property '{}' does not support value '{}'", __FUNCTION__,
- name, value);
- }
-
- return false;
-}
diff --git a/xbmc/windowing/gbm/drm/DRMObject.h b/xbmc/windowing/gbm/drm/DRMObject.h
index 836418813f..e2ae32652c 100644
--- a/xbmc/windowing/gbm/drm/DRMObject.h
+++ b/xbmc/windowing/gbm/drm/DRMObject.h
@@ -33,12 +33,12 @@ public:
std::string GetPropertyName(uint32_t propertyId) const;
uint32_t GetId() const { return m_id; }
- uint32_t GetPropertyId(const char* name) const;
- bool GetPropertyValue(std::string name, const std::string& type, uint64_t& value) const;
+ uint32_t GetPropertyId(const std::string& name) const;
+ std::tuple<bool, uint64_t> GetPropertyValue(const std::string& name,
+ const std::string& valueName) const;
- bool SetProperty(const char* name, uint64_t value);
- bool SupportsProperty(const char* name);
- bool SupportsPropertyAndValue(const char* name, uint64_t value);
+ bool SetProperty(const std::string& name, uint64_t value);
+ bool SupportsProperty(const std::string& name);
protected:
explicit CDRMObject(int fd);