Merge branches 'fixes' and 'misc' into for-linus
[sfrench/cifs-2.6.git] / Documentation / media / uapi / v4l / pixfmt-006.rst
1 .. -*- coding: utf-8; mode: rst -*-
2
3 ****************************
4 Defining Colorspaces in V4L2
5 ****************************
6
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.
21
22 .. _hsv-colorspace:
23
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.
30
31 .. note:: The default R'G'B' quantization is full range for all
32    colorspaces except for BT.2020 which uses limited range R'G'B'
33    quantization.
34
35 .. tabularcolumns:: |p{6.0cm}|p{11.5cm}|
36
37 .. c:type:: v4l2_colorspace
38
39 .. flat-table:: V4L2 Colorspaces
40     :header-rows:  1
41     :stub-columns: 0
42
43     * - Identifier
44       - Details
45     * - ``V4L2_COLORSPACE_DEFAULT``
46       - The default colorspace. This can be used by applications to let
47         the driver fill in the colorspace.
48     * - ``V4L2_COLORSPACE_SMPTE170M``
49       - See :ref:`col-smpte-170m`.
50     * - ``V4L2_COLORSPACE_REC709``
51       - See :ref:`col-rec709`.
52     * - ``V4L2_COLORSPACE_SRGB``
53       - See :ref:`col-srgb`.
54     * - ``V4L2_COLORSPACE_ADOBERGB``
55       - See :ref:`col-adobergb`.
56     * - ``V4L2_COLORSPACE_BT2020``
57       - See :ref:`col-bt2020`.
58     * - ``V4L2_COLORSPACE_DCI_P3``
59       - See :ref:`col-dcip3`.
60     * - ``V4L2_COLORSPACE_SMPTE240M``
61       - See :ref:`col-smpte-240m`.
62     * - ``V4L2_COLORSPACE_470_SYSTEM_M``
63       - See :ref:`col-sysm`.
64     * - ``V4L2_COLORSPACE_470_SYSTEM_BG``
65       - See :ref:`col-sysbg`.
66     * - ``V4L2_COLORSPACE_JPEG``
67       - See :ref:`col-jpeg`.
68     * - ``V4L2_COLORSPACE_RAW``
69       - The raw colorspace. This is used for raw image capture where the
70         image is minimally processed and is using the internal colorspace
71         of the device. The software that processes an image using this
72         'colorspace' will have to know the internals of the capture
73         device.
74
75
76
77 .. c:type:: v4l2_xfer_func
78
79 .. flat-table:: V4L2 Transfer Function
80     :header-rows:  1
81     :stub-columns: 0
82
83     * - Identifier
84       - Details
85     * - ``V4L2_XFER_FUNC_DEFAULT``
86       - Use the default transfer function as defined by the colorspace.
87     * - ``V4L2_XFER_FUNC_709``
88       - Use the Rec. 709 transfer function.
89     * - ``V4L2_XFER_FUNC_SRGB``
90       - Use the sRGB transfer function.
91     * - ``V4L2_XFER_FUNC_ADOBERGB``
92       - Use the AdobeRGB transfer function.
93     * - ``V4L2_XFER_FUNC_SMPTE240M``
94       - Use the SMPTE 240M transfer function.
95     * - ``V4L2_XFER_FUNC_NONE``
96       - Do not use a transfer function (i.e. use linear RGB values).
97     * - ``V4L2_XFER_FUNC_DCI_P3``
98       - Use the DCI-P3 transfer function.
99     * - ``V4L2_XFER_FUNC_SMPTE2084``
100       - Use the SMPTE 2084 transfer function.
101
102
103
104 .. c:type:: v4l2_ycbcr_encoding
105
106 .. tabularcolumns:: |p{6.5cm}|p{11.0cm}|
107
108 .. flat-table:: V4L2 Y'CbCr Encodings
109     :header-rows:  1
110     :stub-columns: 0
111
112     * - Identifier
113       - Details
114     * - ``V4L2_YCBCR_ENC_DEFAULT``
115       - Use the default Y'CbCr encoding as defined by the colorspace.
116     * - ``V4L2_YCBCR_ENC_601``
117       - Use the BT.601 Y'CbCr encoding.
118     * - ``V4L2_YCBCR_ENC_709``
119       - Use the Rec. 709 Y'CbCr encoding.
120     * - ``V4L2_YCBCR_ENC_XV601``
121       - Use the extended gamut xvYCC BT.601 encoding.
122     * - ``V4L2_YCBCR_ENC_XV709``
123       - Use the extended gamut xvYCC Rec. 709 encoding.
124     * - ``V4L2_YCBCR_ENC_BT2020``
125       - Use the default non-constant luminance BT.2020 Y'CbCr encoding.
126     * - ``V4L2_YCBCR_ENC_BT2020_CONST_LUM``
127       - Use the constant luminance BT.2020 Yc'CbcCrc encoding.
128     * - ``V4L2_YCBCR_ENC_SMPTE_240M``
129       - Use the SMPTE 240M Y'CbCr encoding.
130
131
132
133 .. c:type:: v4l2_hsv_encoding
134
135 .. tabularcolumns:: |p{6.5cm}|p{11.0cm}|
136
137 .. flat-table:: V4L2 HSV Encodings
138     :header-rows:  1
139     :stub-columns: 0
140
141     * - Identifier
142       - Details
143     * - ``V4L2_HSV_ENC_180``
144       - For the Hue, each LSB is two degrees.
145     * - ``V4L2_HSV_ENC_256``
146       - For the Hue, the 360 degrees are mapped into 8 bits, i.e. each
147         LSB is roughly 1.41 degrees.
148
149
150
151 .. c:type:: v4l2_quantization
152
153 .. tabularcolumns:: |p{6.5cm}|p{11.0cm}|
154
155 .. flat-table:: V4L2 Quantization Methods
156     :header-rows:  1
157     :stub-columns: 0
158
159     * - Identifier
160       - Details
161     * - ``V4L2_QUANTIZATION_DEFAULT``
162       - Use the default quantization encoding as defined by the
163         colorspace. This is always full range for R'G'B' (except for the
164         BT.2020 colorspace) and HSV. It is usually limited range for Y'CbCr.
165     * - ``V4L2_QUANTIZATION_FULL_RANGE``
166       - Use the full range quantization encoding. I.e. the range [0…1] is
167         mapped to [0…255] (with possible clipping to [1…254] to avoid the
168         0x00 and 0xff values). Cb and Cr are mapped from [-0.5…0.5] to
169         [0…255] (with possible clipping to [1…254] to avoid the 0x00 and
170         0xff values).
171     * - ``V4L2_QUANTIZATION_LIM_RANGE``
172       - Use the limited range quantization encoding. I.e. the range [0…1]
173         is mapped to [16…235]. Cb and Cr are mapped from [-0.5…0.5] to
174         [16…240].