| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include "ConversionMatrix.h" |
| 12 |
#include "ShaderFormats.h" |
| 13 |
#include "cores/VideoSettings.h" |
| 14 |
#include "guilib/Shader.h" |
| 15 |
#include "utils/TransformMatrix.h" |
| 16 |
|
| 17 |
extern "C" { |
| 18 |
#include <libavutil/mastering_display_metadata.h> |
| 19 |
#include <libavutil/pixfmt.h> |
| 20 |
} |
| 21 |
|
| 22 |
namespace Shaders { |
| 23 |
namespace GLES |
| 24 |
{ |
| 25 |
|
| 26 |
class BaseYUV2RGBGLSLShader : public CGLSLShaderProgram |
| 27 |
{ |
| 28 |
public: |
| 29 |
BaseYUV2RGBGLSLShader(EShaderFormat format, |
| 30 |
AVColorPrimaries dst, |
| 31 |
AVColorPrimaries src, |
| 32 |
bool toneMap, |
| 33 |
ETONEMAPMETHOD toneMapMethod); |
| 34 |
~BaseYUV2RGBGLSLShader() override; |
| 35 |
void SetField(int field) { m_field = field; } |
| 36 |
void SetWidth(int w) { m_width = w; } |
| 37 |
void SetHeight(int h) { m_height = h; } |
| 38 |
|
| 39 |
void SetColParams(AVColorSpace colSpace, int bits, bool limited, int textureBits); |
| 40 |
void SetBlack(float black) { m_black = black; } |
| 41 |
void SetContrast(float contrast) { m_contrast = contrast; } |
| 42 |
void SetConvertFullColorRange(bool convertFullRange) { m_convertFullRange = convertFullRange; } |
| 43 |
void SetDisplayMetadata(bool hasDisplayMetadata, |
| 44 |
const AVMasteringDisplayMetadata& displayMetadata, |
| 45 |
bool hasLightMetadata, |
| 46 |
AVContentLightMetadata lightMetadata); |
| 47 |
void SetToneMapParam(float param) { m_toneMappingParam = param; } |
| 48 |
|
| 49 |
GLint GetVertexLoc() { return m_hVertex; } |
| 50 |
GLint GetYcoordLoc() { return m_hYcoord; } |
| 51 |
GLint GetUcoordLoc() { return m_hUcoord; } |
| 52 |
GLint GetVcoordLoc() { return m_hVcoord; } |
| 53 |
|
| 54 |
void SetMatrices(const GLfloat *p, const GLfloat *m) { m_proj = p; m_model = m; } |
| 55 |
void SetAlpha(GLfloat alpha) { m_alpha = alpha; } |
| 56 |
|
| 57 |
protected: |
| 58 |
void OnCompiledAndLinked() override; |
| 59 |
bool OnEnabled() override; |
| 60 |
void OnDisabled() override; |
| 61 |
void Free(); |
| 62 |
|
| 63 |
EShaderFormat m_format; |
| 64 |
int m_width; |
| 65 |
int m_height; |
| 66 |
int m_field; |
| 67 |
bool m_hasDisplayMetadata{false}; |
| 68 |
AVMasteringDisplayMetadata m_displayMetadata; |
| 69 |
bool m_hasLightMetadata{false}; |
| 70 |
AVContentLightMetadata m_lightMetadata; |
| 71 |
bool m_toneMapping{false}; |
| 72 |
ETONEMAPMETHOD m_toneMappingMethod{VS_TONEMAPMETHOD_REINHARD}; |
| 73 |
float m_toneMappingParam{1.0}; |
| 74 |
|
| 75 |
bool m_colorConversion{false}; |
| 76 |
|
| 77 |
float m_black; |
| 78 |
float m_contrast; |
| 79 |
|
| 80 |
std::string m_defines; |
| 81 |
|
| 82 |
CConvertMatrix m_convMatrix; |
| 83 |
|
| 84 |
|
| 85 |
GLint m_hYTex{-1}; |
| 86 |
GLint m_hUTex{-1}; |
| 87 |
GLint m_hVTex{-1}; |
| 88 |
GLint m_hYuvMat{-1}; |
| 89 |
GLint m_hStep{-1}; |
| 90 |
GLint m_hGammaSrc{-1}; |
| 91 |
GLint m_hGammaDstInv{-1}; |
| 92 |
GLint m_hPrimMat{-1}; |
| 93 |
GLint m_hToneP1{-1}; |
| 94 |
GLint m_hCoefsDst{-1}; |
| 95 |
GLint m_hLuminance = -1; |
| 96 |
|
| 97 |
GLint m_hVertex{-1}; |
| 98 |
GLint m_hYcoord{-1}; |
| 99 |
GLint m_hUcoord{-1}; |
| 100 |
GLint m_hVcoord{-1}; |
| 101 |
GLint m_hProj{-1}; |
| 102 |
GLint m_hModel{-1}; |
| 103 |
GLint m_hAlpha{-1}; |
| 104 |
|
| 105 |
const GLfloat *m_proj{nullptr}; |
| 106 |
const GLfloat *m_model{nullptr}; |
| 107 |
GLfloat m_alpha{1.0f}; |
| 108 |
|
| 109 |
bool m_convertFullRange; |
| 110 |
}; |
| 111 |
|
| 112 |
class YUV2RGBProgressiveShader : public BaseYUV2RGBGLSLShader |
| 113 |
{ |
| 114 |
public: |
| 115 |
YUV2RGBProgressiveShader(EShaderFormat format, |
| 116 |
AVColorPrimaries dstPrimaries, |
| 117 |
AVColorPrimaries srcPrimaries, |
| 118 |
bool toneMap, |
| 119 |
ETONEMAPMETHOD toneMapMethod); |
| 120 |
}; |
| 121 |
|
| 122 |
class YUV2RGBBobShader : public BaseYUV2RGBGLSLShader |
| 123 |
{ |
| 124 |
public: |
| 125 |
YUV2RGBBobShader(EShaderFormat format, |
| 126 |
AVColorPrimaries dstPrimaries, |
| 127 |
AVColorPrimaries srcPrimaries, |
| 128 |
bool toneMap, |
| 129 |
ETONEMAPMETHOD toneMapMethod); |
| 130 |
void OnCompiledAndLinked() override; |
| 131 |
bool OnEnabled() override; |
| 132 |
|
| 133 |
GLint m_hStepX = -1; |
| 134 |
GLint m_hStepY = -1; |
| 135 |
GLint m_hField = -1; |
| 136 |
}; |
| 137 |
|
| 138 |
} |
| 139 |
} |