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;
69 gboolean gst_video_color_matrix_get_Kr_Kb (GstVideoColorMatrix matrix, gdouble * Kr, gdouble * Kb);
72 * GstVideoTransferFunction:
73 * @GST_VIDEO_TRANSFER_UNKNOWN: unknown transfer function
74 * @GST_VIDEO_TRANSFER_GAMMA10: linear RGB, gamma 1.0 curve
75 * @GST_VIDEO_TRANSFER_GAMMA18: Gamma 1.8 curve
76 * @GST_VIDEO_TRANSFER_GAMMA20: Gamma 2.0 curve
77 * @GST_VIDEO_TRANSFER_GAMMA22: Gamma 2.2 curve
78 * @GST_VIDEO_TRANSFER_BT709: Gamma 2.2 curve with a linear segment in the lower
80 * @GST_VIDEO_TRANSFER_SMPTE240M: Gamma 2.2 curve with a linear segment in the
82 * @GST_VIDEO_TRANSFER_SRGB: Gamma 2.4 curve with a linear segment in the lower
84 * @GST_VIDEO_TRANSFER_GAMMA28: Gamma 2.8 curve
85 * @GST_VIDEO_TRANSFER_LOG100: Logarithmic transfer characteristic
87 * @GST_VIDEO_TRANSFER_LOG316: Logarithmic transfer characteristic
89 * @GST_VIDEO_TRANSFER_BT2020_12: Gamma 2.2 curve with a linear segment in the lower
90 * range. Used for BT.2020 with 12 bits per
91 * component. Since: 1.6
92 * @GST_VIDEO_TRANSFER_ADOBERGB: Gamma 2.19921875. Since: 1.8
94 * The video transfer function defines the formula for converting between
95 * non-linear RGB (R'G'B') and linear RGB
98 GST_VIDEO_TRANSFER_UNKNOWN = 0,
99 GST_VIDEO_TRANSFER_GAMMA10,
100 GST_VIDEO_TRANSFER_GAMMA18,
101 GST_VIDEO_TRANSFER_GAMMA20,
102 GST_VIDEO_TRANSFER_GAMMA22,
103 GST_VIDEO_TRANSFER_BT709,
104 GST_VIDEO_TRANSFER_SMPTE240M,
105 GST_VIDEO_TRANSFER_SRGB,
106 GST_VIDEO_TRANSFER_GAMMA28,
107 GST_VIDEO_TRANSFER_LOG100,
108 GST_VIDEO_TRANSFER_LOG316,
109 GST_VIDEO_TRANSFER_BT2020_12,
110 GST_VIDEO_TRANSFER_ADOBERGB
111 } GstVideoTransferFunction;
114 gdouble gst_video_color_transfer_encode (GstVideoTransferFunction func, gdouble val);
117 gdouble gst_video_color_transfer_decode (GstVideoTransferFunction func, gdouble val);
120 * GstVideoColorPrimaries:
121 * @GST_VIDEO_COLOR_PRIMARIES_UNKNOWN: unknown color primaries
122 * @GST_VIDEO_COLOR_PRIMARIES_BT709: BT709 primaries
123 * @GST_VIDEO_COLOR_PRIMARIES_BT470M: BT470M primaries
124 * @GST_VIDEO_COLOR_PRIMARIES_BT470BG: BT470BG primaries
125 * @GST_VIDEO_COLOR_PRIMARIES_SMPTE170M: SMPTE170M primaries
126 * @GST_VIDEO_COLOR_PRIMARIES_SMPTE240M: SMPTE240M primaries
127 * @GST_VIDEO_COLOR_PRIMARIES_FILM: Generic film
128 * @GST_VIDEO_COLOR_PRIMARIES_BT2020: BT2020 primaries. Since: 1.6
129 * @GST_VIDEO_COLOR_PRIMARIES_ADOBERGB: Adobe RGB primaries. Since: 1.8
131 * The color primaries define the how to transform linear RGB values to and from
132 * the CIE XYZ colorspace.
135 GST_VIDEO_COLOR_PRIMARIES_UNKNOWN = 0,
136 GST_VIDEO_COLOR_PRIMARIES_BT709,
137 GST_VIDEO_COLOR_PRIMARIES_BT470M,
138 GST_VIDEO_COLOR_PRIMARIES_BT470BG,
139 GST_VIDEO_COLOR_PRIMARIES_SMPTE170M,
140 GST_VIDEO_COLOR_PRIMARIES_SMPTE240M,
141 GST_VIDEO_COLOR_PRIMARIES_FILM,
142 GST_VIDEO_COLOR_PRIMARIES_BT2020,
143 GST_VIDEO_COLOR_PRIMARIES_ADOBERGB
144 } GstVideoColorPrimaries;
147 * GstVideoColorPrimariesInfo:
148 * @primaries: a #GstVideoColorPrimaries
149 * @Wx: reference white x coordinate
150 * @Wy: reference white y coordinate
151 * @Rx: red x coordinate
152 * @Ry: red y coordinate
153 * @Gx: green x coordinate
154 * @Gy: green y coordinate
155 * @Bx: blue x coordinate
156 * @By: blue y coordinate
158 * Structure describing the chromaticity coordinates of an RGB system. These
159 * values can be used to construct a matrix to transform RGB to and from the
165 GstVideoColorPrimaries primaries;
170 } GstVideoColorPrimariesInfo;
173 const GstVideoColorPrimariesInfo *
174 gst_video_color_primaries_get_info (GstVideoColorPrimaries primaries);
177 * GstVideoColorimetry:
178 * @range: the color range. This is the valid range for the samples.
179 * It is used to convert the samples to Y'PbPr values.
180 * @matrix: the color matrix. Used to convert between Y'PbPr and
181 * non-linear RGB (R'G'B')
182 * @transfer: the transfer function. used to convert between R'G'B' and RGB
183 * @primaries: color primaries. used to convert between R'G'B' and CIE XYZ
185 * Structure describing the color info.
188 GstVideoColorRange range;
189 GstVideoColorMatrix matrix;
190 GstVideoTransferFunction transfer;
191 GstVideoColorPrimaries primaries;
192 } GstVideoColorimetry;
194 /* predefined colorimetry */
195 #define GST_VIDEO_COLORIMETRY_BT601 "bt601"
196 #define GST_VIDEO_COLORIMETRY_BT709 "bt709"
197 #define GST_VIDEO_COLORIMETRY_SMPTE240M "smpte240m"
198 #define GST_VIDEO_COLORIMETRY_SRGB "sRGB"
199 #define GST_VIDEO_COLORIMETRY_BT2020 "bt2020"
202 gboolean gst_video_colorimetry_matches (const GstVideoColorimetry *cinfo, const gchar *color);
205 gboolean gst_video_colorimetry_from_string (GstVideoColorimetry *cinfo, const gchar *color);
208 gchar * gst_video_colorimetry_to_string (const GstVideoColorimetry *cinfo);
211 gboolean gst_video_colorimetry_is_equal (const GstVideoColorimetry *cinfo, const GstVideoColorimetry *other);
213 /* compute offset and scale */
216 void gst_video_color_range_offsets (GstVideoColorRange range,
217 const GstVideoFormatInfo *info,
218 gint offset[GST_VIDEO_MAX_COMPONENTS],
219 gint scale[GST_VIDEO_MAX_COMPONENTS]);
224 #endif /* __GST_VIDEO_COLOR_H__ */