From 0ef8be5321667bc51d71c229513530772334d043 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Mon, 2 May 2016 11:34:54 +0200 Subject: [PATCH] VideoPlayer: fix color range conversion for multi pass --- xbmc/cores/VideoRenderers/LinuxRendererGL.cpp | 5 ++-- .../VideoRenderers/LinuxRendererGLES.cpp | 2 +- .../VideoShaders/YUV2RGBShader.cpp | 7 +++--- .../VideoShaders/YUV2RGBShader.h | 23 +++++++++---------- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp index 6b1156f90..df705781b 100644 --- a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp +++ b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp @@ -840,7 +840,7 @@ void CLinuxRendererGL::UpdateVideoFilter() } GLSLOutput *out; - out = new GLSLOutput(3, m_useDithering, m_ditherDepth, m_fullRange); + out = new GLSLOutput(3, m_useDithering, m_ditherDepth, false); m_pVideoFilterShader = new ConvolutionFilterShader(m_scalingMethod, m_nonLinStretch, out); if (!m_pVideoFilterShader->CompileAndLink()) { @@ -913,7 +913,7 @@ void CLinuxRendererGL::LoadShaders(int field) m_pYUVShader = new YUV2RGBProgressiveShader(m_textureTarget==GL_TEXTURE_RECTANGLE_ARB, m_iFlags, m_format, m_nonLinStretch && m_renderQuality == RQ_SINGLEPASS, out); - m_pYUVShader->SetForceLimitedColorRange(false); + m_pYUVShader->SetConvertFullColorRange(m_fullRange); CLog::Log(LOGNOTICE, "GL: Selecting Single Pass YUV 2 RGB shader"); @@ -941,6 +941,7 @@ void CLinuxRendererGL::LoadShaders(int field) // create regular progressive scan shader m_pYUVShader = new YUV2RGBProgressiveShaderARB(m_textureTarget==GL_TEXTURE_RECTANGLE_ARB, m_iFlags, m_format); + m_pYUVShader->SetConvertFullColorRange(m_fullRange); CLog::Log(LOGNOTICE, "GL: Selecting Single Pass ARB YUV2RGB shader"); if (m_pYUVShader && m_pYUVShader->CompileAndLink()) diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp index 393ca6620..25986c760 100644 --- a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp +++ b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp @@ -928,7 +928,7 @@ void CLinuxRendererGLES::RenderSinglePass(int index, int field) pYUVShader->SetField(0); pYUVShader->SetMatrices(glMatrixProject.Get(), glMatrixModview.Get()); - pYUVShader->SetForceLimitedColorRange(false); + pYUVShader->SetConvertFullColorRange(!g_Windowing.UseLimitedColor()); pYUVShader->Enable(); GLubyte idx[4] = {0, 1, 3, 2}; //determines order of triangle strip diff --git a/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp b/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp index 5ebd4ca23..daa322b6d 100644 --- a/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp +++ b/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp @@ -24,7 +24,6 @@ #include "YUV2RGBShader.h" #include "settings/AdvancedSettings.h" #include "guilib/TransformMatrix.h" -#include "windowing/WindowingFactory.h" #include "utils/log.h" #if defined(HAS_GL) || defined(HAS_GLES) #include "utils/GLUtils.h" @@ -108,7 +107,7 @@ void CalculateYUVMatrix(TransformMatrix &matrix coef.m[row][col] = conv[col][row]; coef.identity = false; - if(g_Windowing.UseLimitedColor() || limited) + if (limited) { matrix *= TransformMatrix::CreateTranslation(+ 16.0f / 255 , + 16.0f / 255 @@ -289,7 +288,7 @@ bool BaseYUV2RGBGLSLShader::OnEnabled() GLfloat matrix[4][4]; // keep video levels - CalculateYUVMatrixGL(matrix, m_flags, m_format, m_black, m_contrast, m_forceLimitedColorRange); + CalculateYUVMatrixGL(matrix, m_flags, m_format, m_black, m_contrast, !m_convertFullRange); glUniformMatrix4fv(m_hMatrix, 1, GL_FALSE, (GLfloat*)matrix); #if HAS_GLES == 2 @@ -432,7 +431,7 @@ void YUV2RGBProgressiveShaderARB::OnCompiledAndLinked() bool YUV2RGBProgressiveShaderARB::OnEnabled() { GLfloat matrix[4][4]; - CalculateYUVMatrixGL(matrix, m_flags, m_format, m_black, m_contrast, false); + CalculateYUVMatrixGL(matrix, m_flags, m_format, m_black, m_contrast, !m_convertFullRange); for(int i=0;i<4;i++) glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, i diff --git a/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.h b/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.h index 8751cba9c..e390ce1ba 100644 --- a/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.h +++ b/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.h @@ -42,19 +42,18 @@ void CalculateYUVMatrix(TransformMatrix &matrix namespace Shaders { - class BaseYUV2RGBShader - : virtual public CShaderProgram + class BaseYUV2RGBShader : virtual public CShaderProgram { public: - BaseYUV2RGBShader() : m_forceLimitedColorRange(true) {}; - virtual ~BaseYUV2RGBShader() {}; - virtual void SetField(int field) {}; - virtual void SetWidth(int width) {}; + BaseYUV2RGBShader() : m_convertFullRange(false) {}; + virtual ~BaseYUV2RGBShader() {}; + virtual void SetField(int field) {}; + virtual void SetWidth(int width) {}; virtual void SetHeight(int width) {}; - virtual void SetBlack(float black) {}; - virtual void SetContrast(float contrast) {}; - virtual void SetNonLinStretch(float stretch){}; + virtual void SetBlack(float black) {}; + virtual void SetContrast(float contrast) {}; + virtual void SetNonLinStretch(float stretch) {}; #if HAS_GLES == 2 virtual GLint GetVertexLoc() { return 0; }; virtual GLint GetYcoordLoc() { return 0; }; @@ -62,12 +61,12 @@ namespace Shaders { virtual GLint GetVcoordLoc() { return 0; }; virtual void SetMatrices(GLfloat *p, GLfloat *m) {}; - virtual void SetAlpha(GLfloat alpha) {}; + virtual void SetAlpha(GLfloat alpha) {}; #endif - void SetForceLimitedColorRange(bool forceLimitedColorRange) { m_forceLimitedColorRange = forceLimitedColorRange; } + void SetConvertFullColorRange(bool convertFullRange) { m_convertFullRange = convertFullRange; } protected: - bool m_forceLimitedColorRange; + bool m_convertFullRange; };