Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[sfrench/cifs-2.6.git] / Documentation / media / uapi / v4l / colorspaces-defs.rst
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.
7 ..
8 .. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
9
10 ****************************
11 Defining Colorspaces in V4L2
12 ****************************
13
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.
28
29 .. _hsv-colorspace:
30
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.
37
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'
40    quantization.
41
42 .. tabularcolumns:: |p{6.7cm}|p{10.8cm}|
43
44 .. c:type:: v4l2_colorspace
45
46 .. flat-table:: V4L2 Colorspaces
47     :header-rows:  1
48     :stub-columns: 0
49
50     * - Identifier
51       - Details
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
80         device.
81
82
83
84 .. c:type:: v4l2_xfer_func
85
86 .. tabularcolumns:: |p{5.5cm}|p{12.0cm}|
87
88 .. flat-table:: V4L2 Transfer Function
89     :header-rows:  1
90     :stub-columns: 0
91
92     * - Identifier
93       - Details
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`.
110
111
112
113 .. c:type:: v4l2_ycbcr_encoding
114
115 .. tabularcolumns:: |p{7.2cm}|p{10.3cm}|
116
117 .. flat-table:: V4L2 Y'CbCr Encodings
118     :header-rows:  1
119     :stub-columns: 0
120
121     * - Identifier
122       - Details
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.
139
140
141
142 .. c:type:: v4l2_hsv_encoding
143
144 .. tabularcolumns:: |p{6.5cm}|p{11.0cm}|
145
146 .. flat-table:: V4L2 HSV Encodings
147     :header-rows:  1
148     :stub-columns: 0
149
150     * - Identifier
151       - Details
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.
157
158
159
160 .. c:type:: v4l2_quantization
161
162 .. tabularcolumns:: |p{6.5cm}|p{11.0cm}|
163
164 .. flat-table:: V4L2 Quantization Methods
165     :header-rows:  1
166     :stub-columns: 0
167
168     * - Identifier
169       - Details
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
179         0xff values).
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
183         [16…240].