aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rusak <lorusak@gmail.com>2018-06-12 17:38:34 -0700
committerLukas Rusak <lorusak@gmail.com>2018-09-25 16:19:54 -0700
commit0a39604d1b2b0e645c86cc7d2cac00ff368e2014 (patch)
tree2ed7270e6615a2e237672895e4d8ea999105178d
parent3238e00357d40352a8dd6f2478fe1c4255bb5a76 (diff)
CDRMPRIMETexture: add methods to convert colorspace and colorrange to egl formats
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.cpp38
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.h5
-rw-r--r--xbmc/utils/EGLImage.cpp15
-rw-r--r--xbmc/utils/EGLImage.h2
4 files changed, 53 insertions, 7 deletions
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.cpp
index 5ae9ffc77d..91809f8ebe 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.cpp
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.cpp
@@ -8,6 +8,8 @@
#include "DRMPRIMEEGL.h"
+#include "utils/log.h"
+
void CDRMPRIMETexture::Init(EGLDisplay eglDisplay)
{
m_eglImage.reset(new CEGLImage(eglDisplay));
@@ -40,6 +42,8 @@ bool CDRMPRIMETexture::Map(CVideoBufferDRMPRIME *buffer)
attribs.width = m_texWidth;
attribs.height = m_texHeight;
attribs.format = layer->format;
+ attribs.colorSpace = GetColorSpace(buffer->GetColorEncoding());
+ attribs.colorRange = GetColorRange(buffer->GetColorRange());
attribs.planes = planes;
if (!m_eglImage->CreateImage(attribs))
@@ -73,3 +77,37 @@ 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:
+ return EGL_ITU_REC709_EXT;
+ default:
+ CLog::Log(LOGERROR, "CEGLImage::%s - failed to get colorspace for: %d", __FUNCTION__, colorSpace);
+ break;
+ }
+
+ return -1;
+}
+
+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:
+ return EGL_YUV_NARROW_RANGE_EXT;
+ default:
+ CLog::Log(LOGERROR, "CEGLImage::%s - failed to get colorrange for: %d", __FUNCTION__, colorRange);
+ break;
+ }
+
+ return -1;
+}
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.h b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.h
index 8904cebdf7..abc4890acb 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.h
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/DRMPRIMEEGL.h
@@ -31,4 +31,9 @@ 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/utils/EGLImage.cpp b/xbmc/utils/EGLImage.cpp
index 5f50f4c86a..4f07aa6692 100644
--- a/xbmc/utils/EGLImage.cpp
+++ b/xbmc/utils/EGLImage.cpp
@@ -7,11 +7,10 @@
*/
#include "EGLImage.h"
+
#include "EGLUtils.h"
#include "log.h"
-/* --- CEGLImage -------------------------------------------*/
-
namespace
{
const EGLint eglDmabufPlaneFdAttr[CEGLImage::MAX_NUM_PLANES] =
@@ -67,11 +66,13 @@ bool CEGLImage::CreateImage(EglAttrs imageAttrs)
{EGL_HEIGHT, imageAttrs.height},
{EGL_LINUX_DRM_FOURCC_EXT, static_cast<EGLint>(imageAttrs.format)}});
- /* this should be configurable at a later point */
- attribs.Add({{EGL_YUV_COLOR_SPACE_HINT_EXT, EGL_ITU_REC709_EXT},
- {EGL_SAMPLE_RANGE_HINT_EXT, EGL_YUV_NARROW_RANGE_EXT},
- {EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT, EGL_YUV_CHROMA_SITING_0_EXT},
- {EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT, EGL_YUV_CHROMA_SITING_0_EXT}});
+ if (imageAttrs.colorSpace != 0 && imageAttrs.colorRange != 0)
+ {
+ attribs.Add({{EGL_YUV_COLOR_SPACE_HINT_EXT, imageAttrs.colorSpace},
+ {EGL_SAMPLE_RANGE_HINT_EXT, imageAttrs.colorRange},
+ {EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT, EGL_YUV_CHROMA_SITING_0_EXT},
+ {EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT, EGL_YUV_CHROMA_SITING_0_EXT}});
+ }
for (int i = 0; i < MAX_NUM_PLANES; i++)
{
diff --git a/xbmc/utils/EGLImage.h b/xbmc/utils/EGLImage.h
index 6dcc44bd0d..14e7b056be 100644
--- a/xbmc/utils/EGLImage.h
+++ b/xbmc/utils/EGLImage.h
@@ -34,6 +34,8 @@ public:
int width{0};
int height{0};
uint32_t format{0};
+ int colorSpace{0};
+ int colorRange{0};
std::array<EglPlane, MAX_NUM_PLANES> planes;
};