Skip to content

Commit

Permalink
VideoPlayer: fix color range conversion for multi pass
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta authored and Kwiboo committed Nov 17, 2016
1 parent e05d946 commit 0ef8be5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
5 changes: 3 additions & 2 deletions xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
23 changes: 11 additions & 12 deletions xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,31 @@ 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; };
virtual GLint GetUcoordLoc() { return 0; };
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;
};


Expand Down

0 comments on commit 0ef8be5

Please sign in to comment.