History

[media] videodev2.h: add support for transfer functions

In the past the transfer function was implied by the colorspace. However, it is an independent entity in its own right. Add support for explicitly choosing the transfer function. This change will allow us to represent linear RGB (as is used by openGL), and it will make it easier to work with decoded video material since most codecs store the transfer function as a separate property as well.

Hans Verkuil committed 11 years ago

Commit 74fdcb21 parent af8a8194 files · +50 −6Browse files

Showing the changes to include/uapi (2 of 4 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/v4l2-mediabus.h +3 −1
  2. include/uapi/linux/videodev2.h +40 −1
include/uapi/linux/v4l2-mediabus.h+3−1
@@ -24,6 +24,7 @@ · 23 unmodified lines
24 * @colorspace: colorspace of the data (from enum v4l2_colorspace)24 * @colorspace: colorspace of the data (from enum v4l2_colorspace)
25 * @ycbcr_enc: YCbCr encoding of the data (from enum v4l2_ycbcr_encoding)25 * @ycbcr_enc: YCbCr encoding of the data (from enum v4l2_ycbcr_encoding)
26 * @quantization: quantization of the data (from enum v4l2_quantization)26 * @quantization: quantization of the data (from enum v4l2_quantization)
27 * @xfer_func: transfer function of the data (from enum v4l2_xfer_func)
27 */28 */
28struct v4l2_mbus_framefmt {29struct v4l2_mbus_framefmt {
29 __u32 width;30 __u32 width;
@@ -33,7 +34,8 @@ struct v4l2_mbus_framefmt { · 3 unmodified lines
33 __u32 colorspace;34 __u32 colorspace;
34 __u16 ycbcr_enc;35 __u16 ycbcr_enc;
35 __u16 quantization;36 __u16 quantization;
36 __u32 reserved[6];37 __u16 xfer_func;
38 __u16 reserved[11];
37};39};
38 40
39#ifndef __KERNEL__41#ifndef __KERNEL__
include/uapi/linux/videodev2.h+40−1
@@ -240,6 +240,42 @@ enum v4l2_colorspace { · 239 unmodified lines
240 ((is_sdtv) ? V4L2_COLORSPACE_SMPTE170M : \240 ((is_sdtv) ? V4L2_COLORSPACE_SMPTE170M : \
241 ((is_hdtv) ? V4L2_COLORSPACE_REC709 : V4L2_COLORSPACE_SRGB))241 ((is_hdtv) ? V4L2_COLORSPACE_REC709 : V4L2_COLORSPACE_SRGB))
242 242
243enum v4l2_xfer_func {
244 /*
245 * Mapping of V4L2_XFER_FUNC_DEFAULT to actual transfer functions
246 * for the various colorspaces:
247 *
248 * V4L2_COLORSPACE_SMPTE170M, V4L2_COLORSPACE_470_SYSTEM_M,
249 * V4L2_COLORSPACE_470_SYSTEM_BG, V4L2_COLORSPACE_REC709 and
250 * V4L2_COLORSPACE_BT2020: V4L2_XFER_FUNC_709
251 *
252 * V4L2_COLORSPACE_SRGB, V4L2_COLORSPACE_JPEG: V4L2_XFER_FUNC_SRGB
253 *
254 * V4L2_COLORSPACE_ADOBERGB: V4L2_XFER_FUNC_ADOBERGB
255 *
256 * V4L2_COLORSPACE_SMPTE240M: V4L2_XFER_FUNC_SMPTE240M
257 *
258 * V4L2_COLORSPACE_RAW: V4L2_XFER_FUNC_NONE
259 */
260 V4L2_XFER_FUNC_DEFAULT = 0,
261 V4L2_XFER_FUNC_709 = 1,
262 V4L2_XFER_FUNC_SRGB = 2,
263 V4L2_XFER_FUNC_ADOBERGB = 3,
264 V4L2_XFER_FUNC_SMPTE240M = 4,
265 V4L2_XFER_FUNC_NONE = 5,
266};
267
268/*
269 * Determine how XFER_FUNC_DEFAULT should map to a proper transfer function.
270 * This depends on the colorspace.
271 */
272#define V4L2_MAP_XFER_FUNC_DEFAULT(colsp) \
273 ((colsp) == V4L2_XFER_FUNC_ADOBERGB ? V4L2_XFER_FUNC_ADOBERGB : \
274 ((colsp) == V4L2_COLORSPACE_SMPTE240M ? V4L2_XFER_FUNC_SMPTE240M : \
275 ((colsp) == V4L2_COLORSPACE_RAW ? V4L2_XFER_FUNC_NONE : \
276 ((colsp) == V4L2_COLORSPACE_SRGB || (colsp) == V4L2_COLORSPACE_JPEG ? \
277 V4L2_XFER_FUNC_SRGB : V4L2_XFER_FUNC_709))))
278
243enum v4l2_ycbcr_encoding {279enum v4l2_ycbcr_encoding {
244 /*280 /*
245 * Mapping of V4L2_YCBCR_ENC_DEFAULT to actual encodings for the281 * Mapping of V4L2_YCBCR_ENC_DEFAULT to actual encodings for the
@@ -409,6 +445,7 @@ struct v4l2_pix_format { · 163 unmodified lines
409 __u32 flags; /* format flags (V4L2_PIX_FMT_FLAG_*) */445 __u32 flags; /* format flags (V4L2_PIX_FMT_FLAG_*) */
410 __u32 ycbcr_enc; /* enum v4l2_ycbcr_encoding */446 __u32 ycbcr_enc; /* enum v4l2_ycbcr_encoding */
411 __u32 quantization; /* enum v4l2_quantization */447 __u32 quantization; /* enum v4l2_quantization */
448 __u32 xfer_func; /* enum v4l2_xfer_func */
412};449};
413 450
414/* Pixel format FOURCC depth Description */451/* Pixel format FOURCC depth Description */
@@ -1907,6 +1944,7 @@ struct v4l2_plane_pix_format { · 1492 unmodified lines
1907 * @flags: format flags (V4L2_PIX_FMT_FLAG_*)1944 * @flags: format flags (V4L2_PIX_FMT_FLAG_*)
1908 * @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding1945 * @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding
1909 * @quantization: enum v4l2_quantization, colorspace quantization1946 * @quantization: enum v4l2_quantization, colorspace quantization
1947 * @xfer_func: enum v4l2_xfer_func, colorspace transfer function
1910 */1948 */
1911struct v4l2_pix_format_mplane {1949struct v4l2_pix_format_mplane {
1912 __u32 width;1950 __u32 width;
@@ -1920,7 +1958,8 @@ struct v4l2_pix_format_mplane { · 7 unmodified lines
1920 __u8 flags;1958 __u8 flags;
1921 __u8 ycbcr_enc;1959 __u8 ycbcr_enc;
1922 __u8 quantization;1960 __u8 quantization;
1923 __u8 reserved[8];1961 __u8 xfer_func;
1962 __u8 reserved[7];
1924} __attribute__ ((packed));1963} __attribute__ ((packed));
1925 1964
1926/**1965/**