vo_opengl: use more precise gamma for BT.709 with color management

Change from gamma 2.2 to the slightly more precise 1/0.45 as per BT.709.

https://www.itu.int/rec/R-REC-BT.709-5-200204-I/en mentions a value of
γ=0.45 for the conceptual non-linear precorrection of video signals.

This is approximately the inverse of 2.22, and not 2.20 as the code had
been using until now.
This commit is contained in:
nand 2012-12-23 19:49:19 +01:00 committed by wm4
parent 6be50fa773
commit b32f2ef0d3
3 changed files with 7 additions and 7 deletions

View File

@ -325,8 +325,8 @@ opengl
Enable gamma-correct scaling by working in linear light. This Enable gamma-correct scaling by working in linear light. This
makes use of sRGB textures and framebuffers. makes use of sRGB textures and framebuffers.
This option forces the options 'indirect' and 'gamma'. This option forces the options 'indirect' and 'gamma'.
NOTE: for YUV colorspaces, gamma 2.2 is assumed. RGB input is always NOTE: for YUV colorspaces, gamma 1/0.45 (2.222) is assumed. RGB input
assumed to be in sRGB. is always assumed to be in sRGB.
This option is not really useful, as gamma-correct scaling has not much This option is not really useful, as gamma-correct scaling has not much
influence on typical video playback. Most visible effect comes from influence on typical video playback. Most visible effect comes from
slightly different gamma. slightly different gamma.

View File

@ -1908,7 +1908,7 @@ static bool load_icc(struct gl_priv *p, const char *icc_file,
.Green = {0.30, 0.60, 1.0}, .Green = {0.30, 0.60, 1.0},
.Blue = {0.15, 0.06, 1.0}, .Blue = {0.15, 0.06, 1.0},
}; };
cmsToneCurve *tonecurve = cmsBuildGamma(NULL, 2.2); cmsToneCurve *tonecurve = cmsBuildGamma(NULL, 1.0/0.45);
cmsHPROFILE vid_profile = cmsCreateRGBProfile(&d65, &bt709prim, cmsHPROFILE vid_profile = cmsCreateRGBProfile(&d65, &bt709prim,
(cmsToneCurve*[3]){tonecurve, tonecurve, tonecurve}); (cmsToneCurve*[3]){tonecurve, tonecurve, tonecurve});
cmsFreeToneCurve(tonecurve); cmsFreeToneCurve(tonecurve);
@ -2318,7 +2318,7 @@ static const char help_text[] =
" Enable gamma-correct scaling by working in linear light. This\n" " Enable gamma-correct scaling by working in linear light. This\n"
" makes use of sRGB textures and framebuffers.\n" " makes use of sRGB textures and framebuffers.\n"
" This option forces the options 'indirect' and 'gamma'.\n" " This option forces the options 'indirect' and 'gamma'.\n"
" NOTE: For YUV colorspaces, gamma 2.2 is assumed. RGB input is always\n" " NOTE: For YUV colorspaces, gamma 1/0.45 is assumed. RGB input is always\n"
" assumed to be in sRGB.\n" " assumed to be in sRGB.\n"
" pbo\n" " pbo\n"
" Enable use of PBOs. This is faster, but can sometimes lead to\n" " Enable use of PBOs. This is faster, but can sometimes lead to\n"

View File

@ -74,7 +74,7 @@ void main() {
#ifdef USE_OSD_LINEAR_CONV #ifdef USE_OSD_LINEAR_CONV
// If no 3dlut is being used, we need to pull up to linear light for // If no 3dlut is being used, we need to pull up to linear light for
// the sRGB function. *IF* 3dlut is used, we do not. // the sRGB function. *IF* 3dlut is used, we do not.
color.rgb = pow(color.rgb, vec3(2.2)); color.rgb = pow(color.rgb, vec3(1.0/0.45));
#endif #endif
#ifdef USE_OSD_3DLUT #ifdef USE_OSD_3DLUT
color = vec4(texture3D(lut_3d, color.rgb).rgb, color.a); color = vec4(texture3D(lut_3d, color.rgb).rgb, color.a);
@ -331,12 +331,12 @@ void main() {
color = mat3(colormatrix) * color + colormatrix[3]; color = mat3(colormatrix) * color + colormatrix[3];
#endif #endif
#ifdef USE_LINEAR_CONV #ifdef USE_LINEAR_CONV
color = pow(color, vec3(2.2)); color = pow(color, vec3(1.0/0.45));
#endif #endif
#ifdef USE_LINEAR_CONV_INV #ifdef USE_LINEAR_CONV_INV
// Convert from linear RGB to gamma RGB before putting it through the 3D-LUT // Convert from linear RGB to gamma RGB before putting it through the 3D-LUT
// in the final stage. // in the final stage.
color = pow(color, vec3(1.0/2.2)); color = pow(color, vec3(0.45));
#endif #endif
#ifdef USE_GAMMA_POW #ifdef USE_GAMMA_POW
color = pow(color, inv_gamma); color = pow(color, inv_gamma);