1 .. -*- coding: utf-8; mode: rst -*-
3 ****************************
4 Defining Colorspaces in V4L2
5 ****************************
7 In V4L2 colorspaces are defined by four values. The first is the
8 colorspace identifier (enum :c:type:`v4l2_colorspace`)
9 which defines the chromaticities, the default transfer function, the
10 default Y'CbCr encoding and the default quantization method. The second
11 is the transfer function identifier (enum
12 :c:type:`v4l2_xfer_func`) to specify non-standard
13 transfer functions. The third is the Y'CbCr encoding identifier (enum
14 :c:type:`v4l2_ycbcr_encoding`) to specify
15 non-standard Y'CbCr encodings and the fourth is the quantization
16 identifier (enum :c:type:`v4l2_quantization`) to
17 specify non-standard quantization methods. Most of the time only the
18 colorspace field of struct :c:type:`v4l2_pix_format`
19 or struct :c:type:`v4l2_pix_format_mplane`
20 needs to be filled in.
24 On :ref:`HSV formats <hsv-formats>` the *Hue* is defined as the angle on
25 the cylindrical color representation. Usually this angle is measured in
26 degrees, i.e. 0-360. When we map this angle value into 8 bits, there are
27 two basic ways to do it: Divide the angular value by 2 (0-179), or use the
28 whole range, 0-255, dividing the angular value by 1.41. The enum
29 :c:type:`v4l2_hsv_encoding` specifies which encoding is used.
31 .. note:: The default R'G'B' quantization is full range for all
32 colorspaces. HSV formats are always full range.
34 .. tabularcolumns:: |p{6.0cm}|p{11.5cm}|
36 .. c:type:: v4l2_colorspace
38 .. flat-table:: V4L2 Colorspaces
44 * - ``V4L2_COLORSPACE_DEFAULT``
45 - The default colorspace. This can be used by applications to let
46 the driver fill in the colorspace.
47 * - ``V4L2_COLORSPACE_SMPTE170M``
48 - See :ref:`col-smpte-170m`.
49 * - ``V4L2_COLORSPACE_REC709``
50 - See :ref:`col-rec709`.
51 * - ``V4L2_COLORSPACE_SRGB``
52 - See :ref:`col-srgb`.
53 * - ``V4L2_COLORSPACE_OPRGB``
54 - See :ref:`col-oprgb`.
55 * - ``V4L2_COLORSPACE_BT2020``
56 - See :ref:`col-bt2020`.
57 * - ``V4L2_COLORSPACE_DCI_P3``
58 - See :ref:`col-dcip3`.
59 * - ``V4L2_COLORSPACE_SMPTE240M``
60 - See :ref:`col-smpte-240m`.
61 * - ``V4L2_COLORSPACE_470_SYSTEM_M``
62 - See :ref:`col-sysm`.
63 * - ``V4L2_COLORSPACE_470_SYSTEM_BG``
64 - See :ref:`col-sysbg`.
65 * - ``V4L2_COLORSPACE_JPEG``
66 - See :ref:`col-jpeg`.
67 * - ``V4L2_COLORSPACE_RAW``
68 - The raw colorspace. This is used for raw image capture where the
69 image is minimally processed and is using the internal colorspace
70 of the device. The software that processes an image using this
71 'colorspace' will have to know the internals of the capture
76 .. c:type:: v4l2_xfer_func
78 .. tabularcolumns:: |p{5.5cm}|p{12.0cm}|
80 .. flat-table:: V4L2 Transfer Function
86 * - ``V4L2_XFER_FUNC_DEFAULT``
87 - Use the default transfer function as defined by the colorspace.
88 * - ``V4L2_XFER_FUNC_709``
89 - Use the Rec. 709 transfer function.
90 * - ``V4L2_XFER_FUNC_SRGB``
91 - Use the sRGB transfer function.
92 * - ``V4L2_XFER_FUNC_OPRGB``
93 - Use the opRGB transfer function.
94 * - ``V4L2_XFER_FUNC_SMPTE240M``
95 - Use the SMPTE 240M transfer function.
96 * - ``V4L2_XFER_FUNC_NONE``
97 - Do not use a transfer function (i.e. use linear RGB values).
98 * - ``V4L2_XFER_FUNC_DCI_P3``
99 - Use the DCI-P3 transfer function.
100 * - ``V4L2_XFER_FUNC_SMPTE2084``
101 - Use the SMPTE 2084 transfer function. See :ref:`xf-smpte-2084`.
105 .. c:type:: v4l2_ycbcr_encoding
107 .. tabularcolumns:: |p{6.5cm}|p{11.0cm}|
109 .. flat-table:: V4L2 Y'CbCr Encodings
115 * - ``V4L2_YCBCR_ENC_DEFAULT``
116 - Use the default Y'CbCr encoding as defined by the colorspace.
117 * - ``V4L2_YCBCR_ENC_601``
118 - Use the BT.601 Y'CbCr encoding.
119 * - ``V4L2_YCBCR_ENC_709``
120 - Use the Rec. 709 Y'CbCr encoding.
121 * - ``V4L2_YCBCR_ENC_XV601``
122 - Use the extended gamut xvYCC BT.601 encoding.
123 * - ``V4L2_YCBCR_ENC_XV709``
124 - Use the extended gamut xvYCC Rec. 709 encoding.
125 * - ``V4L2_YCBCR_ENC_BT2020``
126 - Use the default non-constant luminance BT.2020 Y'CbCr encoding.
127 * - ``V4L2_YCBCR_ENC_BT2020_CONST_LUM``
128 - Use the constant luminance BT.2020 Yc'CbcCrc encoding.
129 * - ``V4L2_YCBCR_ENC_SMPTE_240M``
130 - Use the SMPTE 240M Y'CbCr encoding.
134 .. c:type:: v4l2_hsv_encoding
136 .. tabularcolumns:: |p{6.5cm}|p{11.0cm}|
138 .. flat-table:: V4L2 HSV Encodings
144 * - ``V4L2_HSV_ENC_180``
145 - For the Hue, each LSB is two degrees.
146 * - ``V4L2_HSV_ENC_256``
147 - For the Hue, the 360 degrees are mapped into 8 bits, i.e. each
148 LSB is roughly 1.41 degrees.
152 .. c:type:: v4l2_quantization
154 .. tabularcolumns:: |p{6.5cm}|p{11.0cm}|
156 .. flat-table:: V4L2 Quantization Methods
162 * - ``V4L2_QUANTIZATION_DEFAULT``
163 - Use the default quantization encoding as defined by the
164 colorspace. This is always full range for R'G'B' and HSV.
165 It is usually limited range for Y'CbCr.
166 * - ``V4L2_QUANTIZATION_FULL_RANGE``
167 - Use the full range quantization encoding. I.e. the range [0…1] is
168 mapped to [0…255] (with possible clipping to [1…254] to avoid the
169 0x00 and 0xff values). Cb and Cr are mapped from [-0.5…0.5] to
170 [0…255] (with possible clipping to [1…254] to avoid the 0x00 and
172 * - ``V4L2_QUANTIZATION_LIM_RANGE``
173 - Use the limited range quantization encoding. I.e. the range [0…1]
174 is mapped to [16…235]. Cb and Cr are mapped from [-0.5…0.5] to
175 [16…240]. Limited Range cannot be used with HSV.