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
2424 * @colorspace: colorspace of the data (from enum v4l2_colorspace)
2525 * @ycbcr_enc: YCbCr encoding of the data (from enum v4l2_ycbcr_encoding)
2626 * @quantization: quantization of the data (from enum v4l2_quantization)
27+ * @xfer_func: transfer function of the data (from enum v4l2_xfer_func)
2728 */
2829 struct v4l2_mbus_framefmt {
2930 __u32 width;
@@ -33,7 +34,8 @@ struct v4l2_mbus_framefmt { · 3 unmodified lines
3334 __u32 colorspace;
3435 __u16 ycbcr_enc;
3536 __u16 quantization;
36− __u32 reserved[6];
37+ __u16 xfer_func;
38+ __u16 reserved[11];
3739 };
3840
3941 #ifndef __KERNEL__
include/uapi/linux/videodev2.h+40−1
@@ -240,6 +240,42 @@ enum v4l2_colorspace { · 239 unmodified lines
240240 ((is_sdtv) ? V4L2_COLORSPACE_SMPTE170M : \
241241 ((is_hdtv) ? V4L2_COLORSPACE_REC709 : V4L2_COLORSPACE_SRGB))
242242
243+enum 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+
243279 enum v4l2_ycbcr_encoding {
244280 /*
245281 * Mapping of V4L2_YCBCR_ENC_DEFAULT to actual encodings for the
@@ -409,6 +445,7 @@ struct v4l2_pix_format { · 163 unmodified lines
409445 __u32 flags; /* format flags (V4L2_PIX_FMT_FLAG_*) */
410446 __u32 ycbcr_enc; /* enum v4l2_ycbcr_encoding */
411447 __u32 quantization; /* enum v4l2_quantization */
448+ __u32 xfer_func; /* enum v4l2_xfer_func */
412449 };
413450
414451 /* Pixel format FOURCC depth Description */
@@ -1907,6 +1944,7 @@ struct v4l2_plane_pix_format { · 1492 unmodified lines
19071944 * @flags: format flags (V4L2_PIX_FMT_FLAG_*)
19081945 * @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding
19091946 * @quantization: enum v4l2_quantization, colorspace quantization
1947+ * @xfer_func: enum v4l2_xfer_func, colorspace transfer function
19101948 */
19111949 struct v4l2_pix_format_mplane {
19121950 __u32 width;
@@ -1920,7 +1958,8 @@ struct v4l2_pix_format_mplane { · 7 unmodified lines
19201958 __u8 flags;
19211959 __u8 ycbcr_enc;
19221960 __u8 quantization;
1923− __u8 reserved[8];
1961+ __u8 xfer_func;
1962+ __u8 reserved[7];
19241963 } __attribute__ ((packed));
19251964
19261965 /**