2 * Copyright (C) <2011> Wim Taymans <wim.taymans@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #ifndef __GST_VIDEO_COLOR_H__
21 #define __GST_VIDEO_COLOR_H__
25 #include <gst/video/video-format.h>
31 * @GST_VIDEO_COLOR_RANGE_UNKNOWN: unknown range
32 * @GST_VIDEO_COLOR_RANGE_0_255: [0..255] for 8 bit components
33 * @GST_VIDEO_COLOR_RANGE_16_235: [16..235] for 8 bit components. Chroma has
36 * Possible color range values. These constants are defined for 8 bit color
37 * values and can be scaled for other bit depths.
40 GST_VIDEO_COLOR_RANGE_UNKNOWN = 0,
41 GST_VIDEO_COLOR_RANGE_0_255,
42 GST_VIDEO_COLOR_RANGE_16_235
46 * GstVideoColorMatrix:
47 * @GST_VIDEO_COLOR_MATRIX_UNKNOWN: unknown matrix
48 * @GST_VIDEO_COLOR_MATRIX_RGB: identity matrix
49 * @GST_VIDEO_COLOR_MATRIX_FCC: FCC color matrix
50 * @GST_VIDEO_COLOR_MATRIX_BT709: ITU-R BT.709 color matrix
51 * @GST_VIDEO_COLOR_MATRIX_BT601: ITU-R BT.601 color matrix
52 * @GST_VIDEO_COLOR_MATRIX_SMPTE240M: SMPTE 240M color matrix
53 * @GST_VIDEO_COLOR_MATRIX_BT2020: ITU-R BT.2020 color matrix. Since: 1.6.
55 * The color matrix is used to convert between Y'PbPr and
56 * non-linear RGB (R'G'B')
59 GST_VIDEO_COLOR_MATRIX_UNKNOWN = 0,
60 GST_VIDEO_COLOR_MATRIX_RGB,
61 GST_VIDEO_COLOR_MATRIX_FCC,
62 GST_VIDEO_COLOR_MATRIX_BT709,
63 GST_VIDEO_COLOR_MATRIX_BT601,
64 GST_VIDEO_COLOR_MATRIX_SMPTE240M,
65 GST_VIDEO_COLOR_MATRIX_BT2020
66 } GstVideoColorMatrix;
68 gboolean gst_video_color_matrix_get_Kr_Kb (GstVideoColorMatrix matrix, gdouble * Kr, gdouble * Kb);
71 * GstVideoTransferFunction:
72 * @GST_VIDEO_TRANSFER_UNKNOWN: unknown transfer function
73 * @GST_VIDEO_TRANSFER_GAMMA10: linear RGB, gamma 1.0 curve
74 * @GST_VIDEO_TRANSFER_GAMMA18: Gamma 1.8 curve
75 * @GST_VIDEO_TRANSFER_GAMMA20: Gamma 2.0 curve
76 * @GST_VIDEO_TRANSFER_GAMMA22: Gamma 2.2 curve
77 * @GST_VIDEO_TRANSFER_BT709: Gamma 2.2 curve with a linear segment in the lower
79 * @GST_VIDEO_TRANSFER_SMPTE240M: Gamma 2.2 curve with a linear segment in the
81 * @GST_VIDEO_TRANSFER_SRGB: Gamma 2.4 curve with a linear segment in the lower
83 * @GST_VIDEO_TRANSFER_GAMMA28: Gamma 2.8 curve
84 * @GST_VIDEO_TRANSFER_LOG100: Logarithmic transfer characteristic
86 * @GST_VIDEO_TRANSFER_LOG316: Logarithmic transfer characteristic
88 * @GST_VIDEO_TRANSFER_BT2020_12: Gamma 2.2 curve with a linear segment in the lower
89 * range. Used for BT.2020 with 12 bits per
90 * component. Since: 1.6.
92 * The video transfer function defines the formula for converting between
93 * non-linear RGB (R'G'B') and linear RGB
96 GST_VIDEO_TRANSFER_UNKNOWN = 0,
97 GST_VIDEO_TRANSFER_GAMMA10,
98 GST_VIDEO_TRANSFER_GAMMA18,
99 GST_VIDEO_TRANSFER_GAMMA20,
100 GST_VIDEO_TRANSFER_GAMMA22,
101 GST_VIDEO_TRANSFER_BT709,
102 GST_VIDEO_TRANSFER_SMPTE240M,
103 GST_VIDEO_TRANSFER_SRGB,
104 GST_VIDEO_TRANSFER_GAMMA28,
105 GST_VIDEO_TRANSFER_LOG100,
106 GST_VIDEO_TRANSFER_LOG316,
107 GST_VIDEO_TRANSFER_BT2020_12
108 } GstVideoTransferFunction;
110 gdouble gst_video_color_transfer_encode (GstVideoTransferFunction func, gdouble val);
111 gdouble gst_video_color_transfer_decode (GstVideoTransferFunction func, gdouble val);
114 * GstVideoColorPrimaries:
115 * @GST_VIDEO_COLOR_PRIMARIES_UNKNOWN: unknown color primaries
116 * @GST_VIDEO_COLOR_PRIMARIES_BT709: BT709 primaries
117 * @GST_VIDEO_COLOR_PRIMARIES_BT470M: BT470M primaries
118 * @GST_VIDEO_COLOR_PRIMARIES_BT470BG: BT470BG primaries
119 * @GST_VIDEO_COLOR_PRIMARIES_SMPTE170M: SMPTE170M primaries
120 * @GST_VIDEO_COLOR_PRIMARIES_SMPTE240M: SMPTE240M primaries
121 * @GST_VIDEO_COLOR_PRIMARIES_FILM: Generic film
122 * @GST_VIDEO_COLOR_PRIMARIES_BT2020: BT2020 primaries. Since: 1.6.
124 * The color primaries define the how to transform linear RGB values to and from
125 * the CIE XYZ colorspace.
128 GST_VIDEO_COLOR_PRIMARIES_UNKNOWN = 0,
129 GST_VIDEO_COLOR_PRIMARIES_BT709,
130 GST_VIDEO_COLOR_PRIMARIES_BT470M,
131 GST_VIDEO_COLOR_PRIMARIES_BT470BG,
132 GST_VIDEO_COLOR_PRIMARIES_SMPTE170M,
133 GST_VIDEO_COLOR_PRIMARIES_SMPTE240M,
134 GST_VIDEO_COLOR_PRIMARIES_FILM,
135 GST_VIDEO_COLOR_PRIMARIES_BT2020
136 } GstVideoColorPrimaries;
139 * GstVideoColorPrimariesInfo:
140 * @primaries: a #GstVideoColorPrimaries
141 * @Wx: reference white x coordinate
142 * @Wy: reference white y coordinate
143 * @Rx: red x coordinate
144 * @Ry: red y coordinate
145 * @Gx: green x coordinate
146 * @Gy: green y coordinate
147 * @Bx: blue x coordinate
148 * @By: blue y coordinate
150 * Structure describing the chromaticity coordinates of an RGB system. These
151 * values can be used to construct a matrix to transform RGB to and from the
157 GstVideoColorPrimaries primaries;
162 } GstVideoColorPrimariesInfo;
164 const GstVideoColorPrimariesInfo *
165 gst_video_color_primaries_get_info (GstVideoColorPrimaries primaries);
168 * GstVideoColorimetry:
169 * @range: the color range. This is the valid range for the samples.
170 * It is used to convert the samples to Y'PbPr values.
171 * @matrix: the color matrix. Used to convert between Y'PbPr and
172 * non-linear RGB (R'G'B')
173 * @transfer: the transfer function. used to convert between R'G'B' and RGB
174 * @primaries: color primaries. used to convert between R'G'B' and CIE XYZ
176 * Structure describing the color info.
179 GstVideoColorRange range;
180 GstVideoColorMatrix matrix;
181 GstVideoTransferFunction transfer;
182 GstVideoColorPrimaries primaries;
183 } GstVideoColorimetry;
185 /* predefined colorimetry */
186 #define GST_VIDEO_COLORIMETRY_BT601 "bt601"
187 #define GST_VIDEO_COLORIMETRY_BT709 "bt709"
188 #define GST_VIDEO_COLORIMETRY_SMPTE240M "smpte240m"
189 #define GST_VIDEO_COLORIMETRY_SRGB "sRGB"
190 #define GST_VIDEO_COLORIMETRY_BT2020 "bt2020"
192 gboolean gst_video_colorimetry_matches (GstVideoColorimetry *cinfo, const gchar *color);
193 gboolean gst_video_colorimetry_from_string (GstVideoColorimetry *cinfo, const gchar *color);
194 gchar * gst_video_colorimetry_to_string (GstVideoColorimetry *cinfo);
195 gboolean gst_video_colorimetry_is_equal (const GstVideoColorimetry *cinfo, const GstVideoColorimetry *other);
197 /* compute offset and scale */
198 void gst_video_color_range_offsets (GstVideoColorRange range,
199 const GstVideoFormatInfo *info,
200 gint offset[GST_VIDEO_MAX_COMPONENTS],
201 gint scale[GST_VIDEO_MAX_COMPONENTS]);
206 #endif /* __GST_VIDEO_COLOR_H__ */