mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 10:41:04 +00:00
video-color: Add SMPTE ST 2084 support and BT 2100 colorimetry
SMPTE ST 2084 transfer characteristics (a.k.a ITU-R BT.2100-1 perceptual quantization, PQ) is used for various HDR standard. With ST 2084, we can represent BT 2100 (Rec. 2100). BT 2100 defines various aspect of HDR such as resolution, transfer functions, matrix, primaries and etc. It uses BT2020 color space (primaries and matrix) with PQ or HLG transfer functions.
This commit is contained in:
parent
9d2f9d16a1
commit
f7af199b4c
2 changed files with 33 additions and 1 deletions
|
@ -77,6 +77,7 @@ static const ColorimetryInfo colorimetry[] = {
|
|||
MAKE_COLORIMETRY (SRGB, _0_255, RGB, SRGB, BT709),
|
||||
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 (NONAME, _0_255, BT601, UNKNOWN, UNKNOWN),
|
||||
MAKE_COLORIMETRY (NONAME, _UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN),
|
||||
};
|
||||
|
@ -477,6 +478,20 @@ gst_video_color_transfer_encode (GstVideoTransferFunction func, gdouble val)
|
|||
case GST_VIDEO_TRANSFER_ADOBERGB:
|
||||
res = pow (val, 1.0 / 2.19921875);
|
||||
break;
|
||||
case GST_VIDEO_TRANSFER_SMPTE2084:
|
||||
{
|
||||
gdouble c1 = 3424.0 / 4096.0; /* c3 - c2 + 1 */
|
||||
gdouble c2 = 32 * 2413 / 4096.0;
|
||||
gdouble c3 = 32 * 2392 / 4096.0;
|
||||
gdouble m = 128 * 2523 / 4096.0;
|
||||
gdouble n = 0.25 * 2610 / 4096.0;
|
||||
gdouble Ln = pow (val, n);
|
||||
|
||||
/* val equal to 1 for peak white is ordinarily intended to
|
||||
* correspond to a reference output luminance level of 10000 cd/m^2 */
|
||||
res = pow ((c1 + c2 * Ln) / (1.0 + c3 * Ln), m);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -566,6 +581,18 @@ gst_video_color_transfer_decode (GstVideoTransferFunction func, gdouble val)
|
|||
case GST_VIDEO_TRANSFER_ADOBERGB:
|
||||
res = pow (val, 2.19921875);
|
||||
break;
|
||||
case GST_VIDEO_TRANSFER_SMPTE2084:
|
||||
{
|
||||
gdouble c1 = 3424.0 / 4096.0; /* c3 - c2 + 1 */
|
||||
gdouble c2 = 32 * 2413 / 4096.0;
|
||||
gdouble c3 = 32 * 2392 / 4096.0;
|
||||
gdouble mi = 1 / (128 * 2523 / 4096.0);
|
||||
gdouble ni = 1 / (0.25 * 2610 / 4096.0);
|
||||
gdouble nm = pow (val, mi);
|
||||
|
||||
res = pow ((nm - c1) / (c2 - c3 * nm), ni);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -94,6 +94,9 @@ gboolean gst_video_color_matrix_get_Kr_Kb (GstVideoColorMatrix matrix, gdouble *
|
|||
* (functionally the same as the values
|
||||
* GST_VIDEO_TRANSFER_BT709 and GST_VIDEO_TRANSFER_BT2020_12).
|
||||
* Since: 1.18
|
||||
* @GST_VIDEO_TRANSFER_SMPTE2084: SMPTE ST 2084 for 10, 12, 14, and 16-bit systems.
|
||||
* Known as perceptual quantization (PQ)
|
||||
* Since: 1.18
|
||||
*
|
||||
* The video transfer function defines the formula for converting between
|
||||
* non-linear RGB (R'G'B') and linear RGB
|
||||
|
@ -112,7 +115,8 @@ typedef enum {
|
|||
GST_VIDEO_TRANSFER_LOG316,
|
||||
GST_VIDEO_TRANSFER_BT2020_12,
|
||||
GST_VIDEO_TRANSFER_ADOBERGB,
|
||||
GST_VIDEO_TRANSFER_BT2020_10
|
||||
GST_VIDEO_TRANSFER_BT2020_10,
|
||||
GST_VIDEO_TRANSFER_SMPTE2084
|
||||
} GstVideoTransferFunction;
|
||||
|
||||
GST_VIDEO_API
|
||||
|
@ -211,6 +215,7 @@ typedef struct {
|
|||
#define GST_VIDEO_COLORIMETRY_SRGB "sRGB"
|
||||
#define GST_VIDEO_COLORIMETRY_BT2020 "bt2020"
|
||||
#define GST_VIDEO_COLORIMETRY_BT2020_10 "bt2020-10"
|
||||
#define GST_VIDEO_COLORIMETRY_BT2100_PQ "bt2100-pq"
|
||||
|
||||
GST_VIDEO_API
|
||||
gboolean gst_video_colorimetry_matches (const GstVideoColorimetry *cinfo, const gchar *color);
|
||||
|
|
Loading…
Reference in a new issue