History

[media] videodev2.h: improve colorspace support

Add support for the new AdobeRGB and BT.2020 colorspaces as needed for HDMI 2.0. Add support to specify the Y'CbCr encoding and quantization range explicitly.

Hans Verkuil committed 11 years ago

Commit d5735d61 parent ac61e371 file · +89 −10Browse files

Showing the changes to include/uapi/linux (1 of 1 file). Show all

Unified · Split

include/uapi/linux/videodev2.h+89−10
@@ -178,30 +178,103 @@ enum v4l2_memory { · 177 unmodified lines
178178
179179 /* see also http://vektor.theorem.ca/graphics/ycbcr/ */
180180 enum v4l2_colorspace {
181− /* ITU-R 601 -- broadcast NTSC/PAL */
181+ /* SMPTE 170M: used for broadcast NTSC/PAL SDTV */
182182 V4L2_COLORSPACE_SMPTE170M = 1,
183183
184− /* 1125-Line (US) HDTV */
184+ /* Obsolete pre-1998 SMPTE 240M HDTV standard, superseded by Rec 709 */
185185 V4L2_COLORSPACE_SMPTE240M = 2,
186186
187− /* HD and modern captures. */
187+ /* Rec.709: used for HDTV */
188188 V4L2_COLORSPACE_REC709 = 3,
189189
190− /* broken BT878 extents (601, luma range 16-253 instead of 16-235) */
190+ /*
191+ * Deprecated, do not use. No driver will ever return this. This was
192+ * based on a misunderstanding of the bt878 datasheet.
193+ */
191194 V4L2_COLORSPACE_BT878 = 4,
192195
193− /* These should be useful. Assume 601 extents. */
196+ /*
197+ * NTSC 1953 colorspace. This only makes sense when dealing with
198+ * really, really old NTSC recordings. Superseded by SMPTE 170M.
199+ */
194200 V4L2_COLORSPACE_470_SYSTEM_M = 5,
201+
202+ /*
203+ * EBU Tech 3213 PAL/SECAM colorspace. This only makes sense when
204+ * dealing with really old PAL/SECAM recordings. Superseded by
205+ * SMPTE 170M.
206+ */
195207 V4L2_COLORSPACE_470_SYSTEM_BG = 6,
196208
197− /* I know there will be cameras that send this. So, this is
198− * unspecified chromaticities and full 0-255 on each of the
199− * Y'CbCr components
209+ /*
210+ * Effectively shorthand for V4L2_COLORSPACE_SRGB, V4L2_YCBCR_ENC_601
211+ * and V4L2_QUANTIZATION_FULL_RANGE. To be used for (Motion-)JPEG.
200212 */
201213 V4L2_COLORSPACE_JPEG = 7,
202214
203− /* For RGB colourspaces, this is probably a good start. */
215+ /* For RGB colorspaces such as produces by most webcams. */
204216 V4L2_COLORSPACE_SRGB = 8,
217+
218+ /* AdobeRGB colorspace */
219+ V4L2_COLORSPACE_ADOBERGB = 9,
220+
221+ /* BT.2020 colorspace, used for UHDTV. */
222+ V4L2_COLORSPACE_BT2020 = 10,
223+};
224+
225+enum v4l2_ycbcr_encoding {
226+ /*
227+ * Mapping of V4L2_YCBCR_ENC_DEFAULT to actual encodings for the
228+ * various colorspaces:
229+ *
230+ * V4L2_COLORSPACE_SMPTE170M, V4L2_COLORSPACE_470_SYSTEM_M,
231+ * V4L2_COLORSPACE_470_SYSTEM_BG, V4L2_COLORSPACE_ADOBERGB and
232+ * V4L2_COLORSPACE_JPEG: V4L2_YCBCR_ENC_601
233+ *
234+ * V4L2_COLORSPACE_REC709: V4L2_YCBCR_ENC_709
235+ *
236+ * V4L2_COLORSPACE_SRGB: V4L2_YCBCR_ENC_SYCC
237+ *
238+ * V4L2_COLORSPACE_BT2020: V4L2_YCBCR_ENC_BT2020
239+ *
240+ * V4L2_COLORSPACE_SMPTE240M: V4L2_YCBCR_ENC_SMPTE240M
241+ */
242+ V4L2_YCBCR_ENC_DEFAULT = 0,
243+
244+ /* ITU-R 601 -- SDTV */
245+ V4L2_YCBCR_ENC_601 = 1,
246+
247+ /* Rec. 709 -- HDTV */
248+ V4L2_YCBCR_ENC_709 = 2,
249+
250+ /* ITU-R 601/EN 61966-2-4 Extended Gamut -- SDTV */
251+ V4L2_YCBCR_ENC_XV601 = 3,
252+
253+ /* Rec. 709/EN 61966-2-4 Extended Gamut -- HDTV */
254+ V4L2_YCBCR_ENC_XV709 = 4,
255+
256+ /* sYCC (Y'CbCr encoding of sRGB) */
257+ V4L2_YCBCR_ENC_SYCC = 5,
258+
259+ /* BT.2020 Non-constant Luminance Y'CbCr */
260+ V4L2_YCBCR_ENC_BT2020 = 6,
261+
262+ /* BT.2020 Constant Luminance Y'CbcCrc */
263+ V4L2_YCBCR_ENC_BT2020_CONST_LUM = 7,
264+
265+ /* SMPTE 240M -- Obsolete HDTV */
266+ V4L2_YCBCR_ENC_SMPTE240M = 8,
267+};
268+
269+enum v4l2_quantization {
270+ /*
271+ * The default for R'G'B' quantization is always full range. For
272+ * Y'CbCr the quantization is always limited range, except for
273+ * SYCC, XV601, XV709 or JPEG: those are full range.
274+ */
275+ V4L2_QUANTIZATION_DEFAULT = 0,
276+ V4L2_QUANTIZATION_FULL_RANGE = 1,
277+ V4L2_QUANTIZATION_LIM_RANGE = 2,
205278 };
206279
207280 enum v4l2_priority {
@@ -294,6 +367,8 @@ struct v4l2_pix_format { · 86 unmodified lines
294367 __u32 colorspace; /* enum v4l2_colorspace */
295368 __u32 priv; /* private data, depends on pixelformat */
296369 __u32 flags; /* format flags (V4L2_PIX_FMT_FLAG_*) */
370+ __u32 ycbcr_enc; /* enum v4l2_ycbcr_encoding */
371+ __u32 quantization; /* enum v4l2_quantization */
297372 };
298373
299374 /* Pixel format FOURCC depth Description */
@@ -1777,6 +1852,8 @@ struct v4l2_plane_pix_format { · 1477 unmodified lines
17771852 * @plane_fmt: per-plane information
17781853 * @num_planes: number of planes for this format
17791854 * @flags: format flags (V4L2_PIX_FMT_FLAG_*)
1855+ * @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding
1856+ * @quantization: enum v4l2_quantization, colorspace quantization
17801857 */
17811858 struct v4l2_pix_format_mplane {
17821859 __u32 width;
@@ -1788,7 +1865,9 @@ struct v4l2_pix_format_mplane { · 5 unmodified lines
17881865 struct v4l2_plane_pix_format plane_fmt[VIDEO_MAX_PLANES];
17891866 __u8 num_planes;
17901867 __u8 flags;
1791− __u8 reserved[10];
1868+ __u8 ycbcr_enc;
1869+ __u8 quantization;
1870+ __u8 reserved[8];
17921871 } __attribute__ ((packed));
17931872
17941873 /**