1 .. Permission is granted to copy, distribute and/or modify this
2 .. document under the terms of the GNU Free Documentation License,
3 .. Version 1.1 or any later version published by the Free Software
4 .. Foundation, with no Invariant Sections, no Front-Cover Texts
5 .. and no Back-Cover Texts. A copy of the license is included at
6 .. Documentation/media/uapi/fdl-appendix.rst.
8 .. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
10 ****************************
11 Defining Colorspaces in V4L2
12 ****************************
14 In V4L2 colorspaces are defined by four values. The first is the
15 colorspace identifier (enum :c:type:`v4l2_colorspace`)
16 which defines the chromaticities, the default transfer function, the
17 default Y'CbCr encoding and the default quantization method. The second
18 is the transfer function identifier (enum
19 :c:type:`v4l2_xfer_func`) to specify non-standard
20 transfer functions. The third is the Y'CbCr encoding identifier (enum
21 :c:type:`v4l2_ycbcr_encoding`) to specify
22 non-standard Y'CbCr encodings and the fourth is the quantization
23 identifier (enum :c:type:`v4l2_quantization`) to
24 specify non-standard quantization methods. Most of the time only the
25 colorspace field of struct :c:type:`v4l2_pix_format`
26 or struct :c:type:`v4l2_pix_format_mplane`
27 needs to be filled in.
31 On :ref:`HSV formats <hsv-formats>` the *Hue* is defined as the angle on
32 the cylindrical color representation. Usually this angle is measured in
33 degrees, i.e. 0-360. When we map this angle value into 8 bits, there are
34 two basic ways to do it: Divide the angular value by 2 (0-179), or use the
35 whole range, 0-255, dividing the angular value by 1.41. The enum
36 :c:type:`v4l2_hsv_encoding` specifies which encoding is used.
38 .. note:: The default R'G'B' quantization is full range for all
39 colorspaces except for BT.2020 which uses limited range R'G'B'
42 .. tabularcolumns:: |p{6.0cm}|p{11.5cm}|
44 .. c:type:: v4l2_colorspace
46 .. flat-table:: V4L2 Colorspaces
52 * - ``V4L2_COLORSPACE_DEFAULT``
53 - The default colorspace. This can be used by applications to let
54 the driver fill in the colorspace.
55 * - ``V4L2_COLORSPACE_SMPTE170M``
56 - See :ref:`col-smpte-170m`.
57 * - ``V4L2_COLORSPACE_REC709``
58 - See :ref:`col-rec709`.
59 * - ``V4L2_COLORSPACE_SRGB``
60 - See :ref:`col-srgb`.
61 * - ``V4L2_COLORSPACE_OPRGB``
62 - See :ref:`col-oprgb`.
63 * - ``V4L2_COLORSPACE_BT2020``
64 - See :ref:`col-bt2020`.
65 * - ``V4L2_COLORSPACE_DCI_P3``
66 - See :ref:`col-dcip3`.
67 * - ``V4L2_COLORSPACE_SMPTE240M``
68 - See :ref:`col-smpte-240m`.
69 * - ``V4L2_COLORSPACE_470_SYSTEM_M``
70 - See :ref:`col-sysm`.
71 * - ``V4L2_COLORSPACE_470_SYSTEM_BG``
72 - See :ref:`col-sysbg`.
73 * - ``V4L2_COLORSPACE_JPEG``
74 - See :ref:`col-jpeg`.
75 * - ``V4L2_COLORSPACE_RAW``
76 - The raw colorspace. This is used for raw image capture where the
77 image is minimally processed and is using the internal colorspace
78 of the device. The software that processes an image using this
79 'colorspace' will have to know the internals of the capture
84 .. c:type:: v4l2_xfer_func
86 .. tabularcolumns:: |p{5.5cm}|p{12.0cm}|
88 .. flat-table:: V4L2 Transfer Function
94 * - ``V4L2_XFER_FUNC_DEFAULT``
95 - Use the default transfer function as defined by the colorspace.
96 * - ``V4L2_XFER_FUNC_709``
97 - Use the Rec. 709 transfer function.
98 * - ``V4L2_XFER_FUNC_SRGB``
99 - Use the sRGB transfer function.
100 * - ``V4L2_XFER_FUNC_OPRGB``
101 - Use the opRGB transfer function.
102 * - ``V4L2_XFER_FUNC_SMPTE240M``
103 - Use the SMPTE 240M transfer function.
104 * - ``V4L2_XFER_FUNC_NONE``
105 - Do not use a transfer function (i.e. use linear RGB values).
106 * - ``V4L2_XFER_FUNC_DCI_P3``
107 - Use the DCI-P3 transfer function.
108 * - ``V4L2_XFER_FUNC_SMPTE2084``
109 - Use the SMPTE 2084 transfer function. See :ref:`xf-smpte-2084`.
113 .. c:type:: v4l2_ycbcr_encoding
115 .. tabularcolumns:: |p{6.5cm}|p{11.0cm}|
117 .. flat-table:: V4L2 Y'CbCr Encodings
123 * - ``V4L2_YCBCR_ENC_DEFAULT``
124 - Use the default Y'CbCr encoding as defined by the colorspace.
125 * - ``V4L2_YCBCR_ENC_601``
126 - Use the BT.601 Y'CbCr encoding.
127 * - ``V4L2_YCBCR_ENC_709``
128 - Use the Rec. 709 Y'CbCr encoding.
129 * - ``V4L2_YCBCR_ENC_XV601``
130 - Use the extended gamut xvYCC BT.601 encoding.
131 * - ``V4L2_YCBCR_ENC_XV709``
132 - Use the extended gamut xvYCC Rec. 709 encoding.
133 * - ``V4L2_YCBCR_ENC_BT2020``
134 - Use the default non-constant luminance BT.2020 Y'CbCr encoding.
135 * - ``V4L2_YCBCR_ENC_BT2020_CONST_LUM``
136 - Use the constant luminance BT.2020 Yc'CbcCrc encoding.
137 * - ``V4L2_YCBCR_ENC_SMPTE_240M``
138 - Use the SMPTE 240M Y'CbCr encoding.
142 .. c:type:: v4l2_hsv_encoding
144 .. tabularcolumns:: |p{6.5cm}|p{11.0cm}|
146 .. flat-table:: V4L2 HSV Encodings
152 * - ``V4L2_HSV_ENC_180``
153 - For the Hue, each LSB is two degrees.
154 * - ``V4L2_HSV_ENC_256``
155 - For the Hue, the 360 degrees are mapped into 8 bits, i.e. each
156 LSB is roughly 1.41 degrees.
160 .. c:type:: v4l2_quantization
162 .. tabularcolumns:: |p{6.5cm}|p{11.0cm}|
164 .. flat-table:: V4L2 Quantization Methods
170 * - ``V4L2_QUANTIZATION_DEFAULT``
171 - Use the default quantization encoding as defined by the
172 colorspace. This is always full range for R'G'B' (except for the
173 BT.2020 colorspace) and HSV. It is usually limited range for Y'CbCr.
174 * - ``V4L2_QUANTIZATION_FULL_RANGE``
175 - Use the full range quantization encoding. I.e. the range [0…1] is
176 mapped to [0…255] (with possible clipping to [1…254] to avoid the
177 0x00 and 0xff values). Cb and Cr are mapped from [-0.5…0.5] to
178 [0…255] (with possible clipping to [1…254] to avoid the 0x00 and
180 * - ``V4L2_QUANTIZATION_LIM_RANGE``
181 - Use the limited range quantization encoding. I.e. the range [0…1]
182 is mapped to [16…235]. Cb and Cr are mapped from [-0.5…0.5] to