cicp: Fill in some more transfer functions

Handle gamma 2.2 and gamma 2.8.
This commit is contained in:
Matthias Clasen 2024-07-28 11:55:23 -04:00
parent d2028c7323
commit 50ea9450ea
4 changed files with 41 additions and 5 deletions

View File

@ -160,10 +160,10 @@ gdk_cicp_params_class_init (GdkCicpParamsClass *klass)
* GdkCicpParams:color-primaries:
*
* Supported values:
* 1 - sRGB
* 1 - BT.709 / sRGB
* 2 - unspecified
* 5 - PAL
* 6,7 - NTSC
* 6,7 - BT.601 / NTSC
* 9 - BT.2020
* 10 - CIE XYZ
* 12 - Display P3
@ -179,12 +179,14 @@ gdk_cicp_params_class_init (GdkCicpParamsClass *klass)
* GdkCicpParams:transfer-function:
*
* Supported values:
* 1,6,14,15 - BT.709
* 1,6,14,15 - BT.709, BT.601, BT.2020
* 2 - unspecified
* 4 - gamma 2.2
* 5 - gamma 2.8
* 8 - linear
* 13 - sRGB
* 16 - PQ
* 18 - HLG
* 16 - BT.2100 PQ
* 18 - BT.2100 HLG
*
* Since: 4.16
*/

View File

@ -38,6 +38,30 @@ srgb_eotf (float v)
return v / 12.92f;
}
static inline float
gamma22_oetf (float v)
{
return powf (v, 1.f / 2.2f);
}
static inline float
gamma22_eotf (float v)
{
return powf (v, 2.2f);
}
static inline float
gamma28_oetf (float v)
{
return powf (v, 1.f / 2.8f);
}
static inline float
gamma28_eotf (float v)
{
return powf (v, 2.8f);
}
static inline float
pq_eotf (float v)
{

View File

@ -626,6 +626,14 @@ gdk_color_state_new_for_cicp (const GdkCicp *cicp,
eotf = bt709_eotf;
oetf = bt709_oetf;
break;
case 4:
eotf = gamma22_eotf;
oetf = gamma22_oetf;
break;
case 5:
eotf = gamma28_eotf;
oetf = gamma28_oetf;
break;
case 8:
eotf = NONE;
oetf = NONE;

View File

@ -18,6 +18,8 @@ TransferTest transfers[] = {
{ "pq", pq_oetf, pq_eotf },
{ "bt709", bt709_oetf, bt709_eotf },
{ "hlg", hlg_oetf, hlg_eotf },
{ "gamma22", gamma22_oetf, gamma22_eotf },
{ "gamma28", gamma28_oetf, gamma28_eotf },
};
static void