video-color: Add ARIB STD-B67 transfer chracteristic function

It's known also as Rec. ITU-R BT.2100-1 hybrid log-gamma (HLG) used for
both SDR and HDR rendering.
This commit is contained in:
Seungha Yang 2019-05-05 21:02:55 +09:00
parent f7af199b4c
commit 59007d848a
2 changed files with 34 additions and 1 deletions

View file

@ -78,6 +78,7 @@ static const ColorimetryInfo colorimetry[] = {
MAKE_COLORIMETRY (BT2020, _16_235, BT2020, BT2020_12, BT2020),
MAKE_COLORIMETRY (BT2020_10, _16_235, BT2020, BT2020_10, BT2020),
MAKE_COLORIMETRY (BT2100_PQ, _16_235, BT2020, SMPTE2084, BT2020),
MAKE_COLORIMETRY (BT2100_HLG, _16_235, BT2020, ARIB_STD_B67, BT2020),
MAKE_COLORIMETRY (NONAME, _0_255, BT601, UNKNOWN, UNKNOWN),
MAKE_COLORIMETRY (NONAME, _UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN),
};
@ -492,6 +493,20 @@ gst_video_color_transfer_encode (GstVideoTransferFunction func, gdouble val)
res = pow ((c1 + c2 * Ln) / (1.0 + c3 * Ln), m);
break;
}
case GST_VIDEO_TRANSFER_ARIB_STD_B67:
{
gdouble a = 0.17883277;
gdouble b = 0.28466892;
gdouble c = 0.55991073;
/* For [0, 1] normalized source as defined by HEVC specification */
if (val > (1.0 / 12.0))
res = a * log (12.0 * val - b) + c;
else
res = sqrt (3.0 * val);
break;
}
}
return res;
}
@ -593,6 +608,19 @@ gst_video_color_transfer_decode (GstVideoTransferFunction func, gdouble val)
res = pow ((nm - c1) / (c2 - c3 * nm), ni);
break;
}
case GST_VIDEO_TRANSFER_ARIB_STD_B67:
{
gdouble a = 0.17883277;
gdouble b = 0.28466892;
gdouble c = 0.55991073;
if (val > 0.5)
res = (exp ((val - c) / a) + b) / 12.0;
else
res = val * val / 3.0;
break;
}
}
return res;
}

View file

@ -97,6 +97,9 @@ gboolean gst_video_color_matrix_get_Kr_Kb (GstVideoColorMatrix matrix, gdouble *
* @GST_VIDEO_TRANSFER_SMPTE2084: SMPTE ST 2084 for 10, 12, 14, and 16-bit systems.
* Known as perceptual quantization (PQ)
* Since: 1.18
* @GST_VIDEO_TRANSFER_ARIB_STD_B67: Association of Radio Industries and Businesses (ARIB)
* STD-B67 and Rec. ITU-R BT.2100-1 hybrid loggamma (HLG) system
* Since: 1.18
*
* The video transfer function defines the formula for converting between
* non-linear RGB (R'G'B') and linear RGB
@ -116,7 +119,8 @@ typedef enum {
GST_VIDEO_TRANSFER_BT2020_12,
GST_VIDEO_TRANSFER_ADOBERGB,
GST_VIDEO_TRANSFER_BT2020_10,
GST_VIDEO_TRANSFER_SMPTE2084
GST_VIDEO_TRANSFER_SMPTE2084,
GST_VIDEO_TRANSFER_ARIB_STD_B67
} GstVideoTransferFunction;
GST_VIDEO_API
@ -216,6 +220,7 @@ typedef struct {
#define GST_VIDEO_COLORIMETRY_BT2020 "bt2020"
#define GST_VIDEO_COLORIMETRY_BT2020_10 "bt2020-10"
#define GST_VIDEO_COLORIMETRY_BT2100_PQ "bt2100-pq"
#define GST_VIDEO_COLORIMETRY_BT2100_HLG "bt2100-hlg"
GST_VIDEO_API
gboolean gst_video_colorimetry_matches (const GstVideoColorimetry *cinfo, const gchar *color);