[vlc-commits] [Git][videolan/vlc][master] 7 commits: d3d_shaders: generate the YUV to RGB matrices from the standard's values
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sat Aug 6 21:03:22 UTC 2022
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
748de28d by Steve Lhomme at 2022-08-06T20:11:46+00:00
d3d_shaders: generate the YUV to RGB matrices from the standard's values
The Kr and Kb values are defined in the 601/709/2020 standards.
The ranges for Y and U/V values in "studio" mode as well.
The BT2020 matrix is slightly different should give more accurate values.
- - - - -
ecd6cc11 by Steve Lhomme at 2022-08-06T20:11:46+00:00
d3d_shaders: generate YUV to RGB matrices for 10/12 bits sources
The shifts in values are slightly different than in 8 bits. The proper values
should be used to be more accurate.
- - - - -
1347d22b by Steve Lhomme at 2022-08-06T20:11:46+00:00
d3d_shaders: warn when we receive an unknown colorspace
This should never happen as the demuxer/packetizer/decoder/core should have
tried to get the most accurate value.
No need to set the same value twice.
- - - - -
f74d86e1 by Steve Lhomme at 2022-08-06T20:11:46+00:00
d3d_shaders: handle all full YUV to full RGB conversions
- - - - -
f4c9685d by Steve Lhomme at 2022-08-06T20:11:46+00:00
d3d_shaders: fix full YUV to full RGB conversion
The "black level" should not be adjusted in that case. The conversion matrix is
already converting [0,255] to [0,255] the "black levels" are the same. We only
need to do the achromacy conversion (128 shift of U/V).
We don't need to manual range adjust in the shader anymore as those shift
values are also taken in account in our color conversion matrices and in a
cleaner way (differentiation between Y and UV ranges).
- - - - -
a8912da0 by Steve Lhomme at 2022-08-06T20:11:46+00:00
d3d_dynamic_shader: remove range adjustment inside the shader
It should be handled better in the conversion matrices.
- - - - -
992d7b3f by Steve Lhomme at 2022-08-06T20:11:46+00:00
d3d_shaders: use the standards' values for black level and achromacy
- - - - -
2 changed files:
- modules/video_output/win32/d3d_dynamic_shader.c
- modules/video_output/win32/d3d_shaders.c
Changes:
=====================================
modules/video_output/win32/d3d_dynamic_shader.c
=====================================
@@ -170,14 +170,6 @@ inline float3 toneMapping(float3 rgb) {\n\
return rgb;\n\
}\n\
\n\
-inline float3 adjustRange(float3 rgb) {\n\
-#if (SRC_RANGE!=DST_RANGE)\n\
- return clamp((rgb + BLACK_LEVEL_SHIFT) * RANGE_FACTOR, MIN_BLACK_VALUE, MAX_WHITE_VALUE);\n\
-#else\n\
- return rgb;\n\
-#endif\n\
-}\n\
-\n\
inline float4 sampleTexture(SamplerState samplerState, float2 coords) {\n\
float4 sample;\n\
/* sampling routine in sample */\n\
@@ -266,7 +258,6 @@ float4 main( PS_INPUT In ) : SV_TARGET\n\
rgb = sourceToLinear(rgb);\n\
rgb = toneMapping(rgb);\n\
rgb = linearToDisplay(rgb);\n\
- rgb = adjustRange(rgb);\n\
return float4(rgb, saturate(sample.a * Opacity));\n\
}\n\
";
@@ -394,11 +385,6 @@ static HRESULT CompilePixelShaderBlob(vlc_object_t *o, const d3d_shader_compiler
const char *psz_src_to_linear,
const char *psz_linear_to_display,
const char *psz_tone_mapping,
- const char *psz_src_range, const char *psz_dst_range,
- const char *psz_black_level,
- const char *psz_range_factor,
- const char *psz_min_black,
- const char *psz_max_white,
d3d_shader_blob *pPSBlob)
{
if (var_InheritInteger(o, "verbose") >= 4)
@@ -410,12 +396,6 @@ static HRESULT CompilePixelShaderBlob(vlc_object_t *o, const d3d_shader_compiler
{ "SRC_TO_LINEAR", psz_src_to_linear },
{ "LINEAR_TO_DST", psz_linear_to_display },
{ "SAMPLE_TEXTURES", psz_sampler },
- { "SRC_RANGE", psz_src_range },
- { "DST_RANGE", psz_dst_range },
- { "BLACK_LEVEL_SHIFT", psz_black_level },
- { "RANGE_FACTOR", psz_range_factor },
- { "MIN_BLACK_VALUE", psz_min_black },
- { "MAX_WHITE_VALUE", psz_max_white },
{ NULL, NULL },
};
#ifndef NDEBUG
@@ -446,7 +426,6 @@ HRESULT (D3D_CompilePixelShader)(vlc_object_t *o, const d3d_shader_compiler_t *c
const char *psz_src_to_linear = DEFAULT_NOOP;
const char *psz_linear_to_display = DEFAULT_NOOP;
const char *psz_tone_mapping = DEFAULT_NOOP;
- const char *psz_src_range, *psz_dst_range;
shader_views[1] = 0;
if ( display->pixelFormat->formatTexture == DXGI_FORMAT_NV12 ||
@@ -625,83 +604,9 @@ HRESULT (D3D_CompilePixelShader)(vlc_object_t *o, const d3d_shader_compiler_t *c
bool dst_full_range = display->b_full_range;
if (!DxgiIsRGBFormat(dxgi_fmt) && DxgiIsRGBFormat(display->pixelFormat))
{
- /* the YUV->RGB conversion already output full range */
- if (!src_full_range)
- src_full_range = true; // account for this conversion
- else
- {
- if (!dst_full_range)
- msg_Warn(o, "unsupported display full range YUV on studio range RGB");
- dst_full_range = false; // force a conversion down
- }
- }
-
- int range_adjust = 0;
- psz_src_range = src_full_range ? "FULL_RANGE" : "STUDIO_RANGE";
- psz_dst_range = display->b_full_range ? "FULL_RANGE" : "STUDIO_RANGE";
- if (dst_full_range != src_full_range) {
- if (!src_full_range)
- range_adjust = 1; /* raise the source to full range */
- else
- range_adjust = -1; /* lower the source to studio range */
- }
-
- FLOAT black_level = 0;
- FLOAT range_factor = 1.0f;
- FLOAT itu_black_level = 0.f;
- FLOAT itu_white_level = 1.f;
- if (range_adjust != 0)
- {
- FLOAT itu_range_factor;
- switch (dxgi_fmt->bitsPerChannel)
- {
- case 8:
- /* Rec. ITU-R BT.709-6 §4.6 */
- itu_black_level = 16.f / 255.f;
- itu_white_level = 235.f / 255.f;
- itu_range_factor = (float)(235 - 16) / 255.f;
- break;
- case 10:
- /* Rec. ITU-R BT.709-6 §4.6 */
- itu_black_level = 64.f / 1023.f;
- itu_white_level = 940.f / 1023.f;
- itu_range_factor = (float)(940 - 64) / 1023.f;
- break;
- case 12:
- /* Rec. ITU-R BT.2020-2 Table 5 */
- itu_black_level = 256.f / 4095.f;
- itu_white_level = 3760.f / 4095.f;
- itu_range_factor = (float)(3760 - 256) / 4095.f;
- break;
- default:
- /* unknown bitdepth, use approximation for infinite bit depth */
- itu_black_level = 16.f / 256.f;
- itu_white_level = 235.f / 256.f;
- itu_range_factor = (float)(235 - 16) / 256.f;
- break;
- }
-
- if (range_adjust > 0)
- {
- /* expand the range from studio to full range */
- black_level -= itu_black_level;
- range_factor /= itu_range_factor;
- }
- else
- {
- /* shrink the range to studio range */
- black_level += itu_black_level;
- range_factor *= itu_range_factor;
- }
+ if (src_full_range && !dst_full_range)
+ msg_Warn(o, "unsupported display full range YUV on studio range RGB");
}
- char psz_black_level[20];
- char psz_range_factor[20];
- char psz_min_black[20];
- char psz_max_white[20];
- snprintf(psz_black_level, ARRAY_SIZE(psz_black_level), "%f", black_level);
- snprintf(psz_range_factor, ARRAY_SIZE(psz_range_factor), "%f", range_factor);
- snprintf(psz_min_black, ARRAY_SIZE(psz_min_black), "%f", itu_black_level);
- snprintf(psz_max_white, ARRAY_SIZE(psz_max_white), "%f", itu_white_level);
HRESULT hr;
hr = CompilePixelShaderBlob(o, compiler, feature_level,
@@ -709,8 +614,6 @@ HRESULT (D3D_CompilePixelShader)(vlc_object_t *o, const d3d_shader_compiler_t *c
psz_src_to_linear,
psz_linear_to_display,
psz_tone_mapping,
- psz_src_range, psz_dst_range,
- psz_black_level, psz_range_factor, psz_min_black, psz_max_white,
&pPSBlob[0]);
if (SUCCEEDED(hr) && psz_sampler[1])
{
@@ -719,8 +622,6 @@ HRESULT (D3D_CompilePixelShader)(vlc_object_t *o, const d3d_shader_compiler_t *c
psz_src_to_linear,
psz_linear_to_display,
psz_tone_mapping,
- psz_src_range, psz_dst_range,
- psz_black_level, psz_range_factor, psz_min_black, psz_max_white,
&pPSBlob[1]);
if (FAILED(hr))
D3D_ShaderBlobRelease(&pPSBlob[0]);
=====================================
modules/video_output/win32/d3d_shaders.c
=====================================
@@ -334,6 +334,87 @@ void D3D_SetupQuad(vlc_object_t *o, const video_format_t *fmt, d3d_quad_t *quad,
else
quad->shaderConstants->BoundaryY = (FLOAT) (fmt->i_visible_height - 1) / fmt->i_height;
+#define COLOR_CONSTANTS_601_KR 0.2990f
+#define COLOR_CONSTANTS_601_KB 0.1140f
+#define COLOR_CONSTANTS_601_KG (1.0f - COLOR_CONSTANTS_601_KR - COLOR_CONSTANTS_601_KB)
+
+#define COLOR_CONSTANTS_709_KR 0.2126f
+#define COLOR_CONSTANTS_709_KB 0.0722f
+#define COLOR_CONSTANTS_709_KG (1.0f - COLOR_CONSTANTS_709_KR - COLOR_CONSTANTS_709_KB)
+
+#define COLOR_CONSTANTS_2020_KR 0.2627f
+#define COLOR_CONSTANTS_2020_KB 0.0593f
+#define COLOR_CONSTANTS_2020_KG (1.0f - COLOR_CONSTANTS_2020_KR - COLOR_CONSTANTS_2020_KB)
+
+#define COLOR_SHIFT_STUDIO_8_MIN_Y 16
+#define COLOR_SHIFT_STUDIO_8_MAX_Y 235
+#define COLOR_SHIFT_STUDIO_8_MIN_UV 16
+#define COLOR_SHIFT_STUDIO_8_MAX_UV 240
+#define COLOR_SHIFT_STUDIO_8_UV ((double)128)
+#define COLOR_COEFF_STUDIO_8_Y ((double)(COLOR_SHIFT_STUDIO_8_MAX_Y - COLOR_SHIFT_STUDIO_8_MIN_Y))
+#define COLOR_COEFF_STUDIO_8_UV ((double)((COLOR_SHIFT_STUDIO_8_MAX_UV - COLOR_SHIFT_STUDIO_8_MIN_UV) / 2))
+
+#define COLOR_SHIFT_STUDIO_10_MIN_Y 64
+#define COLOR_SHIFT_STUDIO_10_MAX_Y 940
+#define COLOR_SHIFT_STUDIO_10_MIN_UV 64
+#define COLOR_SHIFT_STUDIO_10_MAX_UV 960
+#define COLOR_SHIFT_STUDIO_10_UV ((double)512)
+#define COLOR_COEFF_STUDIO_10_Y ((double)(COLOR_SHIFT_STUDIO_10_MAX_Y - COLOR_SHIFT_STUDIO_10_MIN_Y))
+#define COLOR_COEFF_STUDIO_10_UV ((double)((COLOR_SHIFT_STUDIO_10_MAX_UV - COLOR_SHIFT_STUDIO_10_MIN_UV) / 2))
+
+#define COLOR_SHIFT_STUDIO_12_MIN_Y 256
+#define COLOR_SHIFT_STUDIO_12_MAX_Y 3760
+#define COLOR_SHIFT_STUDIO_12_MIN_UV 256
+#define COLOR_SHIFT_STUDIO_12_MAX_UV 3840
+#define COLOR_SHIFT_STUDIO_12_UV ((double)2048)
+#define COLOR_COEFF_STUDIO_12_Y ((double)(COLOR_SHIFT_STUDIO_12_MAX_Y - COLOR_SHIFT_STUDIO_12_MIN_Y))
+#define COLOR_COEFF_STUDIO_12_UV ((double)((COLOR_SHIFT_STUDIO_12_MAX_UV - COLOR_SHIFT_STUDIO_12_MIN_UV) / 2))
+
+#define COLOR_COEFF_FULL_8_RGB ((double)255)
+#define COLOR_COEFF_FULL_10_RGB ((double)1023)
+#define COLOR_COEFF_FULL_12_RGB ((double)4095)
+
+#define COLOR_SHIFT_FULL_8_MIN_Y 0
+#define COLOR_SHIFT_FULL_8_MAX_Y COLOR_COEFF_FULL_8_RGB
+#define COLOR_COEFF_FULL_8_Y ((double)(COLOR_SHIFT_FULL_8_MAX_Y - COLOR_SHIFT_FULL_8_MIN_Y))
+#define COLOR_COEFF_FULL_8_UV ((double)(COLOR_SHIFT_FULL_8_MAX_Y - COLOR_SHIFT_FULL_8_MIN_Y) / 2.0f)
+#define COLOR_SHIFT_FULL_8_UV ((double)128)
+
+#define COLOR_SHIFT_FULL_10_MIN_Y 0
+#define COLOR_SHIFT_FULL_10_MAX_Y COLOR_COEFF_FULL_10_RGB
+#define COLOR_COEFF_FULL_10_Y ((double)(COLOR_SHIFT_FULL_10_MAX_Y - COLOR_SHIFT_FULL_10_MIN_Y))
+#define COLOR_COEFF_FULL_10_UV ((double)(COLOR_SHIFT_FULL_10_MAX_Y - COLOR_SHIFT_FULL_10_MIN_Y) / 2.0f)
+#define COLOR_SHIFT_FULL_10_UV ((double)512)
+
+#define COLOR_SHIFT_FULL_12_MIN_Y 0
+#define COLOR_SHIFT_FULL_12_MAX_Y COLOR_COEFF_FULL_12_RGB
+#define COLOR_COEFF_FULL_12_Y ((double)(COLOR_SHIFT_FULL_12_MAX_Y - COLOR_SHIFT_FULL_12_MIN_Y))
+#define COLOR_COEFF_FULL_12_UV ((double)(COLOR_SHIFT_FULL_12_MAX_Y - COLOR_SHIFT_FULL_12_MIN_Y) / 2.0f)
+#define COLOR_SHIFT_FULL_12_UV ((double)2048)
+
+#define COLOR_SHIFT_STUDIO_8_MIN_RGB 16
+#define COLOR_SHIFT_STUDIO_8_MAX_RGB 235
+#define COLOR_COEFF_STUDIO_8_RGB ((double)(COLOR_SHIFT_STUDIO_8_MAX_RGB - COLOR_SHIFT_STUDIO_8_MIN_RGB))
+
+
+#define COLOR_MATRIX_YUV2RGB(src, bits, yuv_range, rgb_range) \
+ static const FLOAT COLORSPACE_BT##src##_##yuv_range##_##bits##_TO_##rgb_range##_RGBA[4*3] = { \
+ COLOR_COEFF_##rgb_range##_##bits##_RGB / COLOR_COEFF_##yuv_range##_##bits##_Y, \
+ 0.f, \
+ COLOR_COEFF_##rgb_range##_##bits##_RGB / COLOR_COEFF_##yuv_range##_##bits##_UV * (1.f - COLOR_CONSTANTS_##src##_KR), \
+ 0.f, \
+ \
+ COLOR_COEFF_##rgb_range##_##bits##_RGB / COLOR_COEFF_##yuv_range##_##bits##_Y, \
+ - COLOR_COEFF_##rgb_range##_##bits##_RGB / COLOR_COEFF_##yuv_range##_##bits##_UV * (1.f - COLOR_CONSTANTS_##src##_KB) * COLOR_CONSTANTS_##src##_KB / COLOR_CONSTANTS_##src##_KG, \
+ - COLOR_COEFF_##rgb_range##_##bits##_RGB / COLOR_COEFF_##yuv_range##_##bits##_UV * (1.f - COLOR_CONSTANTS_##src##_KR) * COLOR_CONSTANTS_##src##_KR / COLOR_CONSTANTS_##src##_KG, \
+ 0.f, \
+ \
+ COLOR_COEFF_##rgb_range##_##bits##_RGB / COLOR_COEFF_##yuv_range##_##bits##_Y, \
+ COLOR_COEFF_##rgb_range##_##bits##_RGB / COLOR_COEFF_##yuv_range##_##bits##_UV * (1.f - COLOR_CONSTANTS_##src##_KB), \
+ 0.f, \
+ 0.f, \
+ };
+
const bool RGB_src_shader = DxgiIsRGBFormat(quad->textureFormat);
FLOAT itu_black_level = 0.f;
@@ -344,23 +425,24 @@ void D3D_SetupQuad(vlc_object_t *o, const video_format_t *fmt, d3d_quad_t *quad,
{
case 8:
/* Rec. ITU-R BT.709-6 ¶4.6 */
- itu_black_level = 16.f / 255.f;
- itu_achromacy = 128.f / 255.f;
+ itu_black_level = COLOR_SHIFT_STUDIO_8_MIN_Y / COLOR_SHIFT_FULL_8_MAX_Y;
+ itu_achromacy = COLOR_SHIFT_STUDIO_8_UV / COLOR_SHIFT_FULL_8_MAX_Y;
break;
case 10:
/* Rec. ITU-R BT.709-6 ¶4.6 */
- itu_black_level = 64.f / 1023.f;
- itu_achromacy = 512.f / 1023.f;
+ itu_black_level = COLOR_SHIFT_STUDIO_10_MIN_Y / COLOR_SHIFT_FULL_10_MAX_Y;
+ itu_achromacy = COLOR_SHIFT_STUDIO_10_UV / COLOR_SHIFT_FULL_10_MAX_Y;
break;
case 12:
/* Rec. ITU-R BT.2020-2 Table 5 */
- itu_black_level = 256.f / 4095.f;
- itu_achromacy = 2048.f / 4095.f;
+ itu_black_level = COLOR_SHIFT_STUDIO_12_MIN_Y / COLOR_SHIFT_FULL_12_MAX_Y;
+ itu_achromacy = COLOR_SHIFT_STUDIO_12_UV / COLOR_SHIFT_FULL_12_MAX_Y;
break;
default:
/* unknown bitdepth, use approximation for infinite bit depth */
- itu_black_level = 16.f / 256.f;
- itu_achromacy = 128.f / 256.f;
+ msg_Warn(o, "unsupported YUV bitdepth %u", (unsigned)quad->textureFormat->bitsPerChannel);
+ itu_black_level = 16.f / 256.f;
+ itu_achromacy = 128.f / 256.f;
break;
}
}
@@ -371,13 +453,25 @@ void D3D_SetupQuad(vlc_object_t *o, const video_format_t *fmt, d3d_quad_t *quad,
0.f, 0.f, 1.f, 0.f,
};
- /* matrices for studio range */
- /* see https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_conversion, in studio range */
- static const FLOAT COLORSPACE_BT601_YUV_TO_FULL_RGBA[4*3] = {
- 1.164383561643836f, 0.f, 1.596026785714286f, 0.f,
- 1.164383561643836f, -0.391762290094914f, -0.812967647237771f, 0.f,
- 1.164383561643836f, 2.017232142857142f, 0.f, 0.f,
- };
+
+ COLOR_MATRIX_YUV2RGB(601,8,STUDIO,FULL);
+ COLOR_MATRIX_YUV2RGB(709,8,STUDIO,FULL);
+ COLOR_MATRIX_YUV2RGB(2020,8,STUDIO,FULL);
+ COLOR_MATRIX_YUV2RGB(601,10,STUDIO,FULL);
+ COLOR_MATRIX_YUV2RGB(709,10,STUDIO,FULL);
+ COLOR_MATRIX_YUV2RGB(2020,10,STUDIO,FULL);
+ COLOR_MATRIX_YUV2RGB(601,12,STUDIO,FULL);
+ COLOR_MATRIX_YUV2RGB(709,12,STUDIO,FULL);
+ COLOR_MATRIX_YUV2RGB(2020,12,STUDIO,FULL);
+ COLOR_MATRIX_YUV2RGB(601,8,FULL,FULL);
+ COLOR_MATRIX_YUV2RGB(709,8,FULL,FULL);
+ COLOR_MATRIX_YUV2RGB(2020,8,FULL,FULL);
+ COLOR_MATRIX_YUV2RGB(601,10,FULL,FULL);
+ COLOR_MATRIX_YUV2RGB(709,10,FULL,FULL);
+ COLOR_MATRIX_YUV2RGB(2020,10,FULL,FULL);
+ COLOR_MATRIX_YUV2RGB(601,12,FULL,FULL);
+ COLOR_MATRIX_YUV2RGB(709,12,FULL,FULL);
+ COLOR_MATRIX_YUV2RGB(2020,12,FULL,FULL);
static const FLOAT COLORSPACE_FULL_RGBA_TO_BT601_YUV[4*3] = {
0.299000f, 0.587000f, 0.114000f, 0.f,
@@ -385,19 +479,6 @@ void D3D_SetupQuad(vlc_object_t *o, const video_format_t *fmt, d3d_quad_t *quad,
0.500000f, -0.418688f, -0.081312f, 0.f,
};
- /* see https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.709_conversion, in studio range */
- static const FLOAT COLORSPACE_BT709_YUV_TO_FULL_RGBA[4*3] = {
- 1.164383561643836f, 0.f, 1.792741071428571f, 0.f,
- 1.164383561643836f, -0.213248614273730f, -0.532909328559444f, 0.f,
- 1.164383561643836f, 2.112401785714286f, 0.f, 0.f,
- };
- /* see https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.2020_conversion, in studio range */
- static const FLOAT COLORSPACE_BT2020_YUV_TO_FULL_RGBA[4*3] = {
- 1.164383561643836f, 0.000000000000f, 1.678674107143f, 0.f,
- 1.164383561643836f, -0.127007098661f, -0.440987687946f, 0.f,
- 1.164383561643836f, 2.141772321429f, 0.000000000000f, 0.f,
- };
-
FLOAT WhitePoint[4*3];
memcpy(WhitePoint, IDENTITY_4X3, sizeof(WhitePoint));
@@ -417,29 +498,75 @@ void D3D_SetupQuad(vlc_object_t *o, const video_format_t *fmt, d3d_quad_t *quad,
{
switch (fmt->space){
case COLOR_SPACE_BT709:
- ppColorspace = COLORSPACE_BT709_YUV_TO_FULL_RGBA;
+ if (fmt->color_range == COLOR_RANGE_FULL)
+ {
+ if (quad->textureFormat->bitsPerChannel == 12)
+ ppColorspace = COLORSPACE_BT709_FULL_12_TO_FULL_RGBA;
+ else if (quad->textureFormat->bitsPerChannel == 10)
+ ppColorspace = COLORSPACE_BT709_FULL_10_TO_FULL_RGBA;
+ else
+ ppColorspace = COLORSPACE_BT709_FULL_8_TO_FULL_RGBA;
+ }
+ else
+ {
+ if (quad->textureFormat->bitsPerChannel == 12)
+ ppColorspace = COLORSPACE_BT709_STUDIO_12_TO_FULL_RGBA;
+ else if (quad->textureFormat->bitsPerChannel == 10)
+ ppColorspace = COLORSPACE_BT709_STUDIO_10_TO_FULL_RGBA;
+ else
+ ppColorspace = COLORSPACE_BT709_STUDIO_8_TO_FULL_RGBA;
+ }
break;
case COLOR_SPACE_BT2020:
- ppColorspace = COLORSPACE_BT2020_YUV_TO_FULL_RGBA;
+ if (fmt->color_range == COLOR_RANGE_FULL)
+ {
+ if (quad->textureFormat->bitsPerChannel == 12)
+ ppColorspace = COLORSPACE_BT2020_FULL_12_TO_FULL_RGBA;
+ else if (quad->textureFormat->bitsPerChannel == 10)
+ ppColorspace = COLORSPACE_BT2020_FULL_10_TO_FULL_RGBA;
+ else
+ ppColorspace = COLORSPACE_BT2020_FULL_8_TO_FULL_RGBA;
+ }
+ else
+ {
+ if (quad->textureFormat->bitsPerChannel == 12)
+ ppColorspace = COLORSPACE_BT2020_STUDIO_12_TO_FULL_RGBA;
+ else if (quad->textureFormat->bitsPerChannel == 10)
+ ppColorspace = COLORSPACE_BT2020_STUDIO_10_TO_FULL_RGBA;
+ else
+ ppColorspace = COLORSPACE_BT2020_STUDIO_8_TO_FULL_RGBA;
+ }
break;
case COLOR_SPACE_BT601:
- ppColorspace = COLORSPACE_BT601_YUV_TO_FULL_RGBA;
- break;
- default:
- case COLOR_SPACE_UNDEF:
- if( fmt->i_height > 576 )
+ if (fmt->color_range == COLOR_RANGE_FULL)
{
- ppColorspace = COLORSPACE_BT709_YUV_TO_FULL_RGBA;
+ if (quad->textureFormat->bitsPerChannel == 12)
+ ppColorspace = COLORSPACE_BT601_FULL_12_TO_FULL_RGBA;
+ else if (quad->textureFormat->bitsPerChannel == 10)
+ ppColorspace = COLORSPACE_BT601_FULL_10_TO_FULL_RGBA;
+ else
+ ppColorspace = COLORSPACE_BT601_FULL_8_TO_FULL_RGBA;
}
else
{
- ppColorspace = COLORSPACE_BT601_YUV_TO_FULL_RGBA;
+ if (quad->textureFormat->bitsPerChannel == 12)
+ ppColorspace = COLORSPACE_BT601_STUDIO_12_TO_FULL_RGBA;
+ else if (quad->textureFormat->bitsPerChannel == 10)
+ ppColorspace = COLORSPACE_BT601_STUDIO_10_TO_FULL_RGBA;
+ else
+ ppColorspace = COLORSPACE_BT601_STUDIO_8_TO_FULL_RGBA;
}
break;
+ default:
+ case COLOR_SPACE_UNDEF:
+ msg_Warn(o, "unknown colorspace, using BT709");
+ ppColorspace = COLORSPACE_BT709_STUDIO_8_TO_FULL_RGBA;
+ break;
}
/* all matrices work in studio range and output in full range */
- WhitePoint[0*4 + 3] = -itu_black_level;
+ if (fmt->color_range != COLOR_RANGE_FULL)
+ WhitePoint[0*4 + 3] = -itu_black_level;
WhitePoint[1*4 + 3] = -itu_achromacy;
WhitePoint[2*4 + 3] = -itu_achromacy;
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6e4467593cee40bc705f477598fbaefcffcc65b9...992d7b3f144b9857230f3889ac7c0bc3ae76c479
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6e4467593cee40bc705f477598fbaefcffcc65b9...992d7b3f144b9857230f3889ac7c0bc3ae76c479
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list