Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux...
[cascardo/linux.git] / Documentation / DocBook / media / v4l / pixfmt.xml
1   <title>Image Formats</title>
2
3   <para>The V4L2 API was primarily designed for devices exchanging
4 image data with applications. The
5 <structname>v4l2_pix_format</structname> and <structname>v4l2_pix_format_mplane
6 </structname> structures define the format and layout of an image in memory.
7 The former is used with the single-planar API, while the latter is used with the
8 multi-planar version (see <xref linkend="planar-apis"/>). Image formats are
9 negotiated with the &VIDIOC-S-FMT; ioctl. (The explanations here focus on video
10 capturing and output, for overlay frame buffer formats see also
11 &VIDIOC-G-FBUF;.)</para>
12
13 <section>
14   <title>Single-planar format structure</title>
15   <table pgwide="1" frame="none" id="v4l2-pix-format">
16     <title>struct <structname>v4l2_pix_format</structname></title>
17     <tgroup cols="3">
18       &cs-str;
19       <tbody valign="top">
20         <row>
21           <entry>__u32</entry>
22           <entry><structfield>width</structfield></entry>
23           <entry>Image width in pixels.</entry>
24         </row>
25         <row>
26           <entry>__u32</entry>
27           <entry><structfield>height</structfield></entry>
28           <entry>Image height in pixels. If <structfield>field</structfield> is
29           one of <constant>V4L2_FIELD_TOP</constant>, <constant>V4L2_FIELD_BOTTOM</constant>
30           or <constant>V4L2_FIELD_ALTERNATE</constant> then height refers to the
31           number of lines in the field, otherwise it refers to the number of
32           lines in the frame (which is twice the field height for interlaced
33           formats).</entry>
34         </row>
35         <row>
36           <entry spanname="hspan">Applications set these fields to
37 request an image size, drivers return the closest possible values. In
38 case of planar formats the <structfield>width</structfield> and
39 <structfield>height</structfield> applies to the largest plane. To
40 avoid ambiguities drivers must return values rounded up to a multiple
41 of the scale factor of any smaller planes. For example when the image
42 format is YUV 4:2:0, <structfield>width</structfield> and
43 <structfield>height</structfield> must be multiples of two.</entry>
44         </row>
45         <row>
46           <entry>__u32</entry>
47           <entry><structfield>pixelformat</structfield></entry>
48           <entry>The pixel format or type of compression, set by the
49 application. This is a little endian <link
50 linkend="v4l2-fourcc">four character code</link>. V4L2 defines
51 standard RGB formats in <xref linkend="rgb-formats" />, YUV formats in <xref
52 linkend="yuv-formats" />, and reserved codes in <xref
53 linkend="reserved-formats" /></entry>
54         </row>
55         <row>
56           <entry>&v4l2-field;</entry>
57           <entry><structfield>field</structfield></entry>
58           <entry>Video images are typically interlaced. Applications
59 can request to capture or output only the top or bottom field, or both
60 fields interlaced or sequentially stored in one buffer or alternating
61 in separate buffers. Drivers return the actual field order selected.
62 For more details on fields see <xref linkend="field-order" />.</entry>
63         </row>
64         <row>
65           <entry>__u32</entry>
66           <entry><structfield>bytesperline</structfield></entry>
67           <entry>Distance in bytes between the leftmost pixels in two
68 adjacent lines.</entry>
69         </row>
70         <row>
71           <entry spanname="hspan"><para>Both applications and drivers
72 can set this field to request padding bytes at the end of each line.
73 Drivers however may ignore the value requested by the application,
74 returning <structfield>width</structfield> times bytes per pixel or a
75 larger value required by the hardware. That implies applications can
76 just set this field to zero to get a reasonable
77 default.</para><para>Video hardware may access padding bytes,
78 therefore they must reside in accessible memory. Consider cases where
79 padding bytes after the last line of an image cross a system page
80 boundary. Input devices may write padding bytes, the value is
81 undefined. Output devices ignore the contents of padding
82 bytes.</para><para>When the image format is planar the
83 <structfield>bytesperline</structfield> value applies to the largest
84 plane and is divided by the same factor as the
85 <structfield>width</structfield> field for any smaller planes. For
86 example the Cb and Cr planes of a YUV 4:2:0 image have half as many
87 padding bytes following each line as the Y plane. To avoid ambiguities
88 drivers must return a <structfield>bytesperline</structfield> value
89 rounded up to a multiple of the scale factor.</para>
90 <para>For compressed formats the <structfield>bytesperline</structfield>
91 value makes no sense. Applications and drivers must set this to 0 in
92 that case.</para></entry>
93         </row>
94         <row>
95           <entry>__u32</entry>
96           <entry><structfield>sizeimage</structfield></entry>
97           <entry>Size in bytes of the buffer to hold a complete image,
98 set by the driver. Usually this is
99 <structfield>bytesperline</structfield> times
100 <structfield>height</structfield>. When the image consists of variable
101 length compressed data this is the maximum number of bytes required to
102 hold an image.</entry>
103         </row>
104         <row>
105           <entry>&v4l2-colorspace;</entry>
106           <entry><structfield>colorspace</structfield></entry>
107           <entry>This information supplements the
108 <structfield>pixelformat</structfield> and must be set by the driver for
109 capture streams and by the application for output streams,
110 see <xref linkend="colorspaces" />.</entry>
111         </row>
112         <row>
113           <entry>__u32</entry>
114           <entry><structfield>priv</structfield></entry>
115           <entry><para>This field indicates whether the remaining fields of the
116 <structname>v4l2_pix_format</structname> structure, also called the extended
117 fields, are valid. When set to <constant>V4L2_PIX_FMT_PRIV_MAGIC</constant>, it
118 indicates that the extended fields have been correctly initialized. When set to
119 any other value it indicates that the extended fields contain undefined values.
120 </para>
121 <para>Applications that wish to use the pixel format extended fields must first
122 ensure that the feature is supported by querying the device for the
123 <link linkend="querycap"><constant>V4L2_CAP_EXT_PIX_FORMAT</constant></link>
124 capability. If the capability isn't set the pixel format extended fields are not
125 supported and using the extended fields will lead to undefined results.</para>
126 <para>To use the extended fields, applications must set the
127 <structfield>priv</structfield> field to
128 <constant>V4L2_PIX_FMT_PRIV_MAGIC</constant>, initialize all the extended fields
129 and zero the unused bytes of the <structname>v4l2_format</structname>
130 <structfield>raw_data</structfield> field.</para>
131 <para>When the <structfield>priv</structfield> field isn't set to
132 <constant>V4L2_PIX_FMT_PRIV_MAGIC</constant> drivers must act as if all the
133 extended fields were set to zero. On return drivers must set the
134 <structfield>priv</structfield> field to
135 <constant>V4L2_PIX_FMT_PRIV_MAGIC</constant> and all the extended fields to
136 applicable values.</para></entry>
137         </row>
138         <row>
139           <entry>__u32</entry>
140           <entry><structfield>flags</structfield></entry>
141             <entry>Flags set by the application or driver, see <xref
142 linkend="format-flags" />.</entry>
143         </row>
144       </tbody>
145     </tgroup>
146   </table>
147 </section>
148
149 <section>
150   <title>Multi-planar format structures</title>
151   <para>The <structname>v4l2_plane_pix_format</structname> structures define
152     size and layout for each of the planes in a multi-planar format.
153     The <structname>v4l2_pix_format_mplane</structname> structure contains
154     information common to all planes (such as image width and height) and
155     an array of <structname>v4l2_plane_pix_format</structname> structures,
156     describing all planes of that format.</para>
157   <table pgwide="1" frame="none" id="v4l2-plane-pix-format">
158     <title>struct <structname>v4l2_plane_pix_format</structname></title>
159     <tgroup cols="3">
160       &cs-str;
161       <tbody valign="top">
162         <row>
163           <entry>__u32</entry>
164           <entry><structfield>sizeimage</structfield></entry>
165           <entry>Maximum size in bytes required for image data in this plane.
166           </entry>
167         </row>
168         <row>
169           <entry>__u16</entry>
170           <entry><structfield>bytesperline</structfield></entry>
171           <entry>Distance in bytes between the leftmost pixels in two adjacent
172             lines. See &v4l2-pix-format;.</entry>
173         </row>
174         <row>
175           <entry>__u16</entry>
176           <entry><structfield>reserved[7]</structfield></entry>
177           <entry>Reserved for future extensions. Should be zeroed by the
178            application.</entry>
179         </row>
180       </tbody>
181     </tgroup>
182   </table>
183   <table pgwide="1" frame="none" id="v4l2-pix-format-mplane">
184     <title>struct <structname>v4l2_pix_format_mplane</structname></title>
185     <tgroup cols="3">
186       &cs-str;
187       <tbody valign="top">
188         <row>
189           <entry>__u32</entry>
190           <entry><structfield>width</structfield></entry>
191           <entry>Image width in pixels. See &v4l2-pix-format;.</entry>
192         </row>
193         <row>
194           <entry>__u32</entry>
195           <entry><structfield>height</structfield></entry>
196           <entry>Image height in pixels. See &v4l2-pix-format;.</entry>
197         </row>
198         <row>
199           <entry>__u32</entry>
200           <entry><structfield>pixelformat</structfield></entry>
201           <entry>The pixel format. Both single- and multi-planar four character
202 codes can be used.</entry>
203         </row>
204         <row>
205           <entry>&v4l2-field;</entry>
206           <entry><structfield>field</structfield></entry>
207           <entry>See &v4l2-pix-format;.</entry>
208         </row>
209         <row>
210           <entry>&v4l2-colorspace;</entry>
211           <entry><structfield>colorspace</structfield></entry>
212           <entry>See &v4l2-pix-format;.</entry>
213         </row>
214         <row>
215           <entry>&v4l2-plane-pix-format;</entry>
216           <entry><structfield>plane_fmt[VIDEO_MAX_PLANES]</structfield></entry>
217           <entry>An array of structures describing format of each plane this
218           pixel format consists of. The number of valid entries in this array
219           has to be put in the <structfield>num_planes</structfield>
220           field.</entry>
221         </row>
222         <row>
223           <entry>__u8</entry>
224           <entry><structfield>num_planes</structfield></entry>
225           <entry>Number of planes (i.e. separate memory buffers) for this format
226           and the number of valid entries in the
227           <structfield>plane_fmt</structfield> array.</entry>
228         </row>
229         <row>
230           <entry>__u8</entry>
231           <entry><structfield>flags</structfield></entry>
232           <entry>Flags set by the application or driver, see <xref
233 linkend="format-flags" />.</entry>
234         </row>
235         <row>
236           <entry>__u8</entry>
237           <entry><structfield>reserved[10]</structfield></entry>
238           <entry>Reserved for future extensions. Should be zeroed by the
239            application.</entry>
240         </row>
241       </tbody>
242     </tgroup>
243   </table>
244 </section>
245
246   <section>
247     <title>Standard Image Formats</title>
248
249     <para>In order to exchange images between drivers and
250 applications, it is necessary to have standard image data formats
251 which both sides will interpret the same way. V4L2 includes several
252 such formats, and this section is intended to be an unambiguous
253 specification of the standard image data formats in V4L2.</para>
254
255     <para>V4L2 drivers are not limited to these formats, however.
256 Driver-specific formats are possible. In that case the application may
257 depend on a codec to convert images to one of the standard formats
258 when needed. But the data can still be stored and retrieved in the
259 proprietary format. For example, a device may support a proprietary
260 compressed format. Applications can still capture and save the data in
261 the compressed format, saving much disk space, and later use a codec
262 to convert the images to the X Windows screen format when the video is
263 to be displayed.</para>
264
265     <para>Even so, ultimately, some standard formats are needed, so
266 the V4L2 specification would not be complete without well-defined
267 standard formats.</para>
268
269     <para>The V4L2 standard formats are mainly uncompressed formats. The
270 pixels are always arranged in memory from left to right, and from top
271 to bottom. The first byte of data in the image buffer is always for
272 the leftmost pixel of the topmost row. Following that is the pixel
273 immediately to its right, and so on until the end of the top row of
274 pixels. Following the rightmost pixel of the row there may be zero or
275 more bytes of padding to guarantee that each row of pixel data has a
276 certain alignment. Following the pad bytes, if any, is data for the
277 leftmost pixel of the second row from the top, and so on. The last row
278 has just as many pad bytes after it as the other rows.</para>
279
280     <para>In V4L2 each format has an identifier which looks like
281 <constant>PIX_FMT_XXX</constant>, defined in the <link
282 linkend="videodev">videodev2.h</link> header file. These identifiers
283 represent <link linkend="v4l2-fourcc">four character (FourCC) codes</link>
284 which are also listed below, however they are not the same as those
285 used in the Windows world.</para>
286
287     <para>For some formats, data is stored in separate, discontiguous
288 memory buffers. Those formats are identified by a separate set of FourCC codes
289 and are referred to as "multi-planar formats". For example, a YUV422 frame is
290 normally stored in one memory buffer, but it can also be placed in two or three
291 separate buffers, with Y component in one buffer and CbCr components in another
292 in the 2-planar version or with each component in its own buffer in the
293 3-planar case. Those sub-buffers are referred to as "planes".</para>
294   </section>
295
296   <section id="colorspaces">
297     <title>Colorspaces</title>
298
299     <para>'Color' is a very complex concept and depends on physics, chemistry and
300 biology. Just because you have three numbers that describe the 'red', 'green'
301 and 'blue' components of the color of a pixel does not mean that you can accurately
302 display that color. A colorspace defines what it actually <emphasis>means</emphasis>
303 to have an RGB value of e.g. (255,&nbsp;0,&nbsp;0). That is, which color should be
304 reproduced on the screen in a perfectly calibrated environment.</para>
305
306     <para>In order to do that we first need to have a good definition of
307 color, i.e. some way to uniquely and unambiguously define a color so that someone
308 else can reproduce it. Human color vision is trichromatic since the human eye has
309 color receptors that are sensitive to three different wavelengths of light. Hence
310 the need to use three numbers to describe color. Be glad you are not a mantis shrimp
311 as those are sensitive to 12 different wavelengths, so instead of RGB we would be
312 using the ABCDEFGHIJKL colorspace...</para>
313
314     <para>Color exists only in the eye and brain and is the result of how strongly
315 color receptors are stimulated. This is based on the Spectral
316 Power Distribution (SPD) which is a graph showing the intensity (radiant power)
317 of the light at wavelengths covering the visible spectrum as it enters the eye.
318 The science of colorimetry is about the relationship between the SPD and color as
319 perceived by the human brain.</para>
320
321     <para>Since the human eye has only three color receptors it is perfectly
322 possible that different SPDs will result in the same stimulation of those receptors
323 and are perceived as the same color, even though the SPD of the light is
324 different.</para>
325
326    <para>In the 1920s experiments were devised to determine the relationship
327 between SPDs and the perceived color and that resulted in the CIE 1931 standard
328 that defines spectral weighting functions that model the perception of color.
329 Specifically that standard defines functions that can take an SPD and calculate
330 the stimulus for each color receptor. After some further mathematical transforms
331 these stimuli are known as the <emphasis>CIE XYZ tristimulus</emphasis> values
332 and these X, Y and Z values describe a color as perceived by a human unambiguously.
333 These X, Y and Z values are all in the range [0&hellip;1].</para>
334
335    <para>The Y value in the CIE XYZ colorspace corresponds to luminance. Often
336 the CIE XYZ colorspace is transformed to the normalized CIE xyY colorspace:</para>
337
338    <para>x = X / (X + Y + Z)</para>
339    <para>y = Y / (X + Y + Z)</para>
340
341    <para>The x and y values are the chromaticity coordinates and can be used to
342 define a color without the luminance component Y. It is very confusing to
343 have such similar names for these colorspaces. Just be aware that if colors
344 are specified with lower case 'x' and 'y', then the CIE xyY colorspace is
345 used. Upper case 'X' and 'Y' refer to the CIE XYZ colorspace. Also, y has nothing
346 to do with luminance. Together x and y specify a color, and Y the luminance.
347 That is really all you need to remember from a practical point of view. At
348 the end of this section you will find reading resources that go into much more
349 detail if you are interested.
350 </para>
351
352    <para>A monitor or TV will reproduce colors by emitting light at three
353 different wavelengths, the combination of which will stimulate the color receptors
354 in the eye and thus cause the perception of color. Historically these wavelengths
355 were defined by the red, green and blue phosphors used in the displays. These
356 <emphasis>color primaries</emphasis> are part of what defines a colorspace.</para>
357
358     <para>Different display devices will have different primaries and some
359 primaries are more suitable for some display technologies than others. This has
360 resulted in a variety of colorspaces that are used for different display
361 technologies or uses. To define a colorspace you need to define the three
362 color primaries (these are typically defined as x,&nbsp;y chromaticity coordinates
363 from the CIE xyY colorspace) but also the white reference: that is the color obtained
364 when all three primaries are at maximum power. This determines the relative power
365 or energy of the primaries. This is usually chosen to be close to daylight which has
366 been defined as the CIE D65 Illuminant.</para>
367
368     <para>To recapitulate: the CIE XYZ colorspace uniquely identifies colors.
369 Other colorspaces are defined by three chromaticity coordinates defined in the
370 CIE xyY colorspace. Based on those a 3x3 matrix can be constructed that
371 transforms CIE XYZ colors to colors in the new colorspace.
372 </para>
373
374     <para>Both the CIE XYZ and the RGB colorspace that are derived from the
375 specific chromaticity primaries are linear colorspaces. But neither the eye,
376 nor display technology is linear. Doubling the values of all components in
377 the linear colorspace will not be perceived as twice the intensity of the color.
378 So each colorspace also defines a transfer function that takes a linear color
379 component value and transforms it to the non-linear component value, which is a
380 closer match to the non-linear performance of both the eye and displays. Linear
381 component values are denoted RGB, non-linear are denoted as R'G'B'. In general
382 colors used in graphics are all R'G'B', except in openGL which uses linear RGB.
383 Special care should be taken when dealing with openGL to provide linear RGB colors
384 or to use the built-in openGL support to apply the inverse transfer function.</para>
385
386     <para>The final piece that defines a colorspace is a function that
387 transforms non-linear R'G'B' to non-linear Y'CbCr. This function is determined
388 by the so-called luma coefficients. There may be multiple possible Y'CbCr
389 encodings allowed for the same colorspace. Many encodings of color
390 prefer to use luma (Y') and chroma (CbCr) instead of R'G'B'. Since the human
391 eye is more sensitive to differences in luminance than in color this encoding
392 allows one to reduce the amount of color information compared to the luma
393 data. Note that the luma (Y') is unrelated to the Y in the CIE XYZ colorspace.
394 Also note that Y'CbCr is often called YCbCr or YUV even though these are
395 strictly speaking wrong.</para>
396
397     <para>Sometimes people confuse Y'CbCr as being a colorspace. This is not
398 correct, it is just an encoding of an R'G'B' color into luma and chroma
399 values. The underlying colorspace that is associated with the R'G'B' color
400 is also associated with the Y'CbCr color.</para>
401
402     <para>The final step is how the RGB, R'G'B' or Y'CbCr values are
403 quantized. The CIE XYZ colorspace where X, Y and Z are in the range
404 [0&hellip;1] describes all colors that humans can perceive, but the transform to
405 another colorspace will produce colors that are outside the [0&hellip;1] range.
406 Once clamped to the [0&hellip;1] range those colors can no longer be reproduced
407 in that colorspace. This clamping is what reduces the extent or gamut of the
408 colorspace. How the range of [0&hellip;1] is translated to integer values in the
409 range of [0&hellip;255] (or higher, depending on the color depth) is called the
410 quantization. This is <emphasis>not</emphasis> part of the colorspace
411 definition. In practice RGB or R'G'B' values are full range, i.e. they
412 use the full [0&hellip;255] range. Y'CbCr values on the other hand are limited
413 range with Y' using [16&hellip;235] and Cb and Cr using [16&hellip;240].</para>
414
415     <para>Unfortunately, in some cases limited range RGB is also used
416 where the components use the range [16&hellip;235]. And full range Y'CbCr also exists
417 using the [0&hellip;255] range.</para>
418
419     <para>In order to correctly interpret a color you need to know the
420 quantization range, whether it is R'G'B' or Y'CbCr, the used Y'CbCr encoding
421 and the colorspace.
422 From that information you can calculate the corresponding CIE XYZ color
423 and map that again to whatever colorspace your display device uses.</para>
424
425     <para>The colorspace definition itself consists of the three
426 chromaticity primaries, the white reference chromaticity, a transfer
427 function and the luma coefficients needed to transform R'G'B' to Y'CbCr. While
428 some colorspace standards correctly define all four, quite often the colorspace
429 standard only defines some, and you have to rely on other standards for
430 the missing pieces. The fact that colorspaces are often a mix of different
431 standards also led to very confusing naming conventions where the name of
432 a standard was used to name a colorspace when in fact that standard was
433 part of various other colorspaces as well.</para>
434
435     <para>If you want to read more about colors and colorspaces, then the
436 following resources are useful: <xref linkend="poynton" /> is a good practical
437 book for video engineers, <xref linkend="colimg" /> has a much broader scope and
438 describes many more aspects of color (physics, chemistry, biology, etc.).
439 The <ulink url="http://www.brucelindbloom.com">http://www.brucelindbloom.com</ulink>
440 website is an excellent resource, especially with respect to the mathematics behind
441 colorspace conversions. The wikipedia <ulink url="http://en.wikipedia.org/wiki/CIE_1931_color_space#CIE_xy_chromaticity_diagram_and_the_CIE_xyY_color_space">CIE 1931 colorspace</ulink> article
442 is also very useful.</para>
443   </section>
444
445   <section>
446     <title>Defining Colorspaces in V4L2</title>
447     <para>In V4L2 colorspaces are defined by three values. The first is the colorspace
448 identifier (&v4l2-colorspace;) which defines the chromaticities, the transfer
449 function, the default Y'CbCr encoding and the default quantization method. The second
450 is the Y'CbCr encoding identifier (&v4l2-ycbcr-encoding;) to specify non-standard
451 Y'CbCr encodings and the third is the quantization identifier (&v4l2-quantization;)
452 to specify non-standard quantization methods. Most of the time only the colorspace
453 field of &v4l2-pix-format; or &v4l2-pix-format-mplane; needs to be filled in. Note
454 that the default R'G'B' quantization is always full range for all colorspaces,
455 so this won't be mentioned explicitly for each colorspace description.</para>
456
457     <table pgwide="1" frame="none" id="v4l2-colorspace">
458       <title>V4L2 Colorspaces</title>
459       <tgroup cols="2" align="left">
460         &cs-def;
461         <thead>
462           <row>
463             <entry>Identifier</entry>
464             <entry>Details</entry>
465           </row>
466         </thead>
467         <tbody valign="top">
468           <row>
469             <entry><constant>V4L2_COLORSPACE_SMPTE170M</constant></entry>
470             <entry>See <xref linkend="col-smpte-170m" />.</entry>
471           </row>
472           <row>
473             <entry><constant>V4L2_COLORSPACE_REC709</constant></entry>
474             <entry>See <xref linkend="col-rec709" />.</entry>
475           </row>
476           <row>
477             <entry><constant>V4L2_COLORSPACE_SRGB</constant></entry>
478             <entry>See <xref linkend="col-srgb" />.</entry>
479           </row>
480           <row>
481             <entry><constant>V4L2_COLORSPACE_ADOBERGB</constant></entry>
482             <entry>See <xref linkend="col-adobergb" />.</entry>
483           </row>
484           <row>
485             <entry><constant>V4L2_COLORSPACE_BT2020</constant></entry>
486             <entry>See <xref linkend="col-bt2020" />.</entry>
487           </row>
488           <row>
489             <entry><constant>V4L2_COLORSPACE_SMPTE240M</constant></entry>
490             <entry>See <xref linkend="col-smpte-240m" />.</entry>
491           </row>
492           <row>
493             <entry><constant>V4L2_COLORSPACE_470_SYSTEM_M</constant></entry>
494             <entry>See <xref linkend="col-sysm" />.</entry>
495           </row>
496           <row>
497             <entry><constant>V4L2_COLORSPACE_470_SYSTEM_BG</constant></entry>
498             <entry>See <xref linkend="col-sysbg" />.</entry>
499           </row>
500           <row>
501             <entry><constant>V4L2_COLORSPACE_JPEG</constant></entry>
502             <entry>See <xref linkend="col-jpeg" />.</entry>
503           </row>
504         </tbody>
505       </tgroup>
506     </table>
507
508     <table pgwide="1" frame="none" id="v4l2-ycbcr-encoding">
509       <title>V4L2 Y'CbCr Encodings</title>
510       <tgroup cols="2" align="left">
511         &cs-def;
512         <thead>
513           <row>
514             <entry>Identifier</entry>
515             <entry>Details</entry>
516           </row>
517         </thead>
518         <tbody valign="top">
519           <row>
520             <entry><constant>V4L2_YCBCR_ENC_DEFAULT</constant></entry>
521             <entry>Use the default Y'CbCr encoding as defined by the colorspace.</entry>
522           </row>
523           <row>
524             <entry><constant>V4L2_YCBCR_ENC_601</constant></entry>
525             <entry>Use the BT.601 Y'CbCr encoding.</entry>
526           </row>
527           <row>
528             <entry><constant>V4L2_YCBCR_ENC_709</constant></entry>
529             <entry>Use the Rec. 709 Y'CbCr encoding.</entry>
530           </row>
531           <row>
532             <entry><constant>V4L2_YCBCR_ENC_XV601</constant></entry>
533             <entry>Use the extended gamut xvYCC BT.601 encoding.</entry>
534           </row>
535           <row>
536             <entry><constant>V4L2_YCBCR_ENC_XV709</constant></entry>
537             <entry>Use the extended gamut xvYCC Rec. 709 encoding.</entry>
538           </row>
539           <row>
540             <entry><constant>V4L2_YCBCR_ENC_SYCC</constant></entry>
541             <entry>Use the extended gamut sYCC encoding.</entry>
542           </row>
543           <row>
544             <entry><constant>V4L2_YCBCR_ENC_BT2020</constant></entry>
545             <entry>Use the default non-constant luminance BT.2020 Y'CbCr encoding.</entry>
546           </row>
547           <row>
548             <entry><constant>V4L2_YCBCR_ENC_BT2020_CONST_LUM</constant></entry>
549             <entry>Use the constant luminance BT.2020 Yc'CbcCrc encoding.</entry>
550           </row>
551         </tbody>
552       </tgroup>
553     </table>
554
555     <table pgwide="1" frame="none" id="v4l2-quantization">
556       <title>V4L2 Quantization Methods</title>
557       <tgroup cols="2" align="left">
558         &cs-def;
559         <thead>
560           <row>
561             <entry>Identifier</entry>
562             <entry>Details</entry>
563           </row>
564         </thead>
565         <tbody valign="top">
566           <row>
567             <entry><constant>V4L2_QUANTIZATION_DEFAULT</constant></entry>
568             <entry>Use the default quantization encoding as defined by the colorspace.
569 This is always full range for R'G'B' and usually limited range for Y'CbCr.</entry>
570           </row>
571           <row>
572             <entry><constant>V4L2_QUANTIZATION_FULL_RANGE</constant></entry>
573             <entry>Use the full range quantization encoding. I.e. the range [0&hellip;1]
574 is mapped to [0&hellip;255] (with possible clipping to [1&hellip;254] to avoid the
575 0x00 and 0xff values). Cb and Cr are mapped from [-0.5&hellip;0.5] to [0&hellip;255]
576 (with possible clipping to [1&hellip;254] to avoid the 0x00 and 0xff values).</entry>
577           </row>
578           <row>
579             <entry><constant>V4L2_QUANTIZATION_LIM_RANGE</constant></entry>
580             <entry>Use the limited range quantization encoding. I.e. the range [0&hellip;1]
581 is mapped to [16&hellip;235]. Cb and Cr are mapped from [-0.5&hellip;0.5] to [16&hellip;240].
582 </entry>
583           </row>
584         </tbody>
585       </tgroup>
586     </table>
587   </section>
588
589   <section>
590     <title>Detailed Colorspace Descriptions</title>
591     <section>
592       <title id="col-smpte-170m">Colorspace SMPTE 170M (<constant>V4L2_COLORSPACE_SMPTE170M</constant>)</title>
593       <para>The <xref linkend="smpte170m" /> standard defines the colorspace used by NTSC and PAL and by SDTV
594 in general. The default Y'CbCr encoding is <constant>V4L2_YCBCR_ENC_601</constant>.
595 The default Y'CbCr quantization is limited range. The chromaticities of the primary colors and
596 the white reference are:</para>
597       <table frame="none">
598         <title>SMPTE 170M Chromaticities</title>
599         <tgroup cols="3" align="left">
600           &cs-str;
601         <thead>
602           <row>
603             <entry>Color</entry>
604             <entry>x</entry>
605             <entry>y</entry>
606           </row>
607         </thead>
608           <tbody valign="top">
609             <row>
610               <entry>Red</entry>
611               <entry>0.630</entry>
612               <entry>0.340</entry>
613             </row>
614             <row>
615               <entry>Green</entry>
616               <entry>0.310</entry>
617               <entry>0.595</entry>
618             </row>
619             <row>
620               <entry>Blue</entry>
621               <entry>0.155</entry>
622               <entry>0.070</entry>
623             </row>
624             <row>
625               <entry>White Reference (D65)</entry>
626               <entry>0.3127</entry>
627               <entry>0.3290</entry>
628             </row>
629           </tbody>
630         </tgroup>
631       </table>
632       <para>The red, green and blue chromaticities are also often referred to
633 as the SMPTE C set, so this colorspace is sometimes called SMPTE C as well.</para>
634       <variablelist>
635         <varlistentry>
636           <term>The transfer function defined for SMPTE 170M is the same as the
637 one defined in Rec. 709. Normally L is in the range [0&hellip;1], but for the extended
638 gamut xvYCC encoding values outside that range are allowed.</term>
639           <listitem>
640             <para>L' = -1.099(-L)<superscript>0.45</superscript>&nbsp;+&nbsp;0.099&nbsp;for&nbsp;L&nbsp;&le;&nbsp;-0.018</para>
641             <para>L' = 4.5L&nbsp;for&nbsp;-0.018&nbsp;&lt;&nbsp;L&nbsp;&lt;&nbsp;0.018</para>
642             <para>L' = 1.099L<superscript>0.45</superscript>&nbsp;-&nbsp;0.099&nbsp;for&nbsp;L&nbsp;&ge;&nbsp;0.018</para>
643           </listitem>
644         </varlistentry>
645       </variablelist>
646       <variablelist>
647         <varlistentry>
648           <term>Inverse Transfer function:</term>
649           <listitem>
650             <para>L = -((L'&nbsp;-&nbsp;0.099)&nbsp;/&nbsp;-1.099)<superscript>1/0.45</superscript>&nbsp;for&nbsp;L'&nbsp;&le;&nbsp;-0.081</para>
651             <para>L = L'&nbsp;/&nbsp;4.5&nbsp;for&nbsp;-0.081&nbsp;&lt;&nbsp;L'&nbsp;&lt;&nbsp;0.081</para>
652             <para>L = ((L'&nbsp;+&nbsp;0.099)&nbsp;/&nbsp;1.099)<superscript>1/0.45</superscript>&nbsp;for&nbsp;L'&nbsp;&ge;&nbsp;0.081</para>
653           </listitem>
654         </varlistentry>
655       </variablelist>
656       <variablelist>
657         <varlistentry>
658           <term>The luminance (Y') and color difference (Cb and Cr) are obtained with
659 the following <constant>V4L2_YCBCR_ENC_601</constant> encoding:</term>
660           <listitem>
661             <para>Y'&nbsp;=&nbsp;0.299R'&nbsp;+&nbsp;0.587G'&nbsp;+&nbsp;0.114B'</para>
662             <para>Cb&nbsp;=&nbsp;-0.169R'&nbsp;-&nbsp;0.331G'&nbsp;+&nbsp;0.5B'</para>
663             <para>Cr&nbsp;=&nbsp;0.5R'&nbsp;-&nbsp;0.419G'&nbsp;-&nbsp;0.081B'</para>
664           </listitem>
665         </varlistentry>
666       </variablelist>
667       <para>Y' is clamped to the range [0&hellip;1] and Cb and Cr are
668 clamped to the range [-0.5&hellip;0.5]. This conversion to Y'CbCr is identical to the one
669 defined in the <xref linkend="itu601" /> standard and this colorspace is sometimes called BT.601 as well, even
670 though BT.601 does not mention any color primaries.</para>
671       <para>The default quantization is limited range, but full range is possible although
672 rarely seen.</para>
673       <para>The <constant>V4L2_YCBCR_ENC_601</constant> encoding as described above is the
674 default for this colorspace, but it can be overridden with <constant>V4L2_YCBCR_ENC_709</constant>,
675 in which case the Rec. 709 Y'CbCr encoding is used.</para>
676       <variablelist>
677         <varlistentry>
678           <term>The xvYCC 601 encoding (<constant>V4L2_YCBCR_ENC_XV601</constant>, <xref linkend="xvycc" />) is similar
679 to the BT.601 encoding, but it allows for R', G' and B' values that are outside the range
680 [0&hellip;1]. The resulting Y', Cb and Cr values are scaled and offset:</term>
681           <listitem>
682             <para>Y'&nbsp;=&nbsp;(219&nbsp;/&nbsp;255)&nbsp;*&nbsp;(0.299R'&nbsp;+&nbsp;0.587G'&nbsp;+&nbsp;0.114B')&nbsp;+&nbsp;(16&nbsp;/&nbsp;255)</para>
683             <para>Cb&nbsp;=&nbsp;(224&nbsp;/&nbsp;255)&nbsp;*&nbsp;(-0.169R'&nbsp;-&nbsp;0.331G'&nbsp;+&nbsp;0.5B')</para>
684             <para>Cr&nbsp;=&nbsp;(224&nbsp;/&nbsp;255)&nbsp;*&nbsp;(0.5R'&nbsp;-&nbsp;0.419G'&nbsp;-&nbsp;0.081B')</para>
685           </listitem>
686         </varlistentry>
687       </variablelist>
688       <para>Y' is clamped to the range [0&hellip;1] and Cb and Cr are clamped
689 to the range [-0.5&hellip;0.5]. The non-standard xvYCC 709 encoding can also be used by selecting
690 <constant>V4L2_YCBCR_ENC_XV709</constant>. The xvYCC encodings always use full range
691 quantization.</para>
692     </section>
693
694     <section>
695       <title id="col-rec709">Colorspace Rec. 709 (<constant>V4L2_COLORSPACE_REC709</constant>)</title>
696       <para>The <xref linkend="itu709" /> standard defines the colorspace used by HDTV in general. The default
697 Y'CbCr encoding is <constant>V4L2_YCBCR_ENC_709</constant>. The default Y'CbCr quantization is
698 limited range. The chromaticities of the primary colors and the white reference are:</para>
699       <table frame="none">
700         <title>Rec. 709 Chromaticities</title>
701         <tgroup cols="3" align="left">
702           &cs-str;
703         <thead>
704           <row>
705             <entry>Color</entry>
706             <entry>x</entry>
707             <entry>y</entry>
708           </row>
709         </thead>
710           <tbody valign="top">
711             <row>
712               <entry>Red</entry>
713               <entry>0.640</entry>
714               <entry>0.330</entry>
715             </row>
716             <row>
717               <entry>Green</entry>
718               <entry>0.300</entry>
719               <entry>0.600</entry>
720             </row>
721             <row>
722               <entry>Blue</entry>
723               <entry>0.150</entry>
724               <entry>0.060</entry>
725             </row>
726             <row>
727               <entry>White Reference (D65)</entry>
728               <entry>0.3127</entry>
729               <entry>0.3290</entry>
730             </row>
731           </tbody>
732         </tgroup>
733       </table>
734       <para>The full name of this standard is Rec. ITU-R BT.709-5.</para>
735       <variablelist>
736         <varlistentry>
737           <term>Transfer function. Normally L is in the range [0&hellip;1], but for the extended
738 gamut xvYCC encoding values outside that range are allowed.</term>
739           <listitem>
740             <para>L' = -1.099(-L)<superscript>0.45</superscript>&nbsp;+&nbsp;0.099&nbsp;for&nbsp;L&nbsp;&le;&nbsp;-0.018</para>
741             <para>L' = 4.5L&nbsp;for&nbsp;-0.018&nbsp;&lt;&nbsp;L&nbsp;&lt;&nbsp;0.018</para>
742             <para>L' = 1.099L<superscript>0.45</superscript>&nbsp;-&nbsp;0.099&nbsp;for&nbsp;L&nbsp;&ge;&nbsp;0.018</para>
743           </listitem>
744         </varlistentry>
745       </variablelist>
746       <variablelist>
747         <varlistentry>
748           <term>Inverse Transfer function:</term>
749           <listitem>
750             <para>L = -((L'&nbsp;-&nbsp;0.099)&nbsp;/&nbsp;-1.099)<superscript>1/0.45</superscript>&nbsp;for&nbsp;L'&nbsp;&le;&nbsp;-0.081</para>
751             <para>L = L'&nbsp;/&nbsp;4.5&nbsp;for&nbsp;-0.081&nbsp;&lt;&nbsp;L'&nbsp;&lt;&nbsp;0.081</para>
752             <para>L = ((L'&nbsp;+&nbsp;0.099)&nbsp;/&nbsp;1.099)<superscript>1/0.45</superscript>&nbsp;for&nbsp;L'&nbsp;&ge;&nbsp;0.081</para>
753           </listitem>
754         </varlistentry>
755       </variablelist>
756       <variablelist>
757         <varlistentry>
758           <term>The luminance (Y') and color difference (Cb and Cr) are obtained with the following
759 <constant>V4L2_YCBCR_ENC_709</constant> encoding:</term>
760           <listitem>
761             <para>Y'&nbsp;=&nbsp;0.2126R'&nbsp;+&nbsp;0.7152G'&nbsp;+&nbsp;0.0722B'</para>
762             <para>Cb&nbsp;=&nbsp;-0.1146R'&nbsp;-&nbsp;0.3854G'&nbsp;+&nbsp;0.5B'</para>
763             <para>Cr&nbsp;=&nbsp;0.5R'&nbsp;-&nbsp;0.4542G'&nbsp;-&nbsp;0.0458B'</para>
764           </listitem>
765         </varlistentry>
766       </variablelist>
767       <para>Y' is clamped to the range [0&hellip;1] and Cb and Cr are
768 clamped to the range [-0.5&hellip;0.5].</para>
769       <para>The default quantization is limited range, but full range is possible although
770 rarely seen.</para>
771       <para>The <constant>V4L2_YCBCR_ENC_709</constant> encoding described above is the default
772 for this colorspace, but it can be overridden with <constant>V4L2_YCBCR_ENC_601</constant>, in which
773 case the BT.601 Y'CbCr encoding is used.</para>
774       <variablelist>
775         <varlistentry>
776           <term>The xvYCC 709 encoding (<constant>V4L2_YCBCR_ENC_XV709</constant>, <xref linkend="xvycc" />)
777 is similar to the Rec. 709 encoding, but it allows for R', G' and B' values that are outside the range
778 [0&hellip;1]. The resulting Y', Cb and Cr values are scaled and offset:</term>
779           <listitem>
780             <para>Y'&nbsp;=&nbsp;(219&nbsp;/&nbsp;255)&nbsp;*&nbsp;(0.2126R'&nbsp;+&nbsp;0.7152G'&nbsp;+&nbsp;0.0722B')&nbsp;+&nbsp;(16&nbsp;/&nbsp;255)</para>
781             <para>Cb&nbsp;=&nbsp;(224&nbsp;/&nbsp;255)&nbsp;*&nbsp;(-0.1146R'&nbsp;-&nbsp;0.3854G'&nbsp;+&nbsp;0.5B')</para>
782             <para>Cr&nbsp;=&nbsp;(224&nbsp;/&nbsp;255)&nbsp;*&nbsp;(0.5R'&nbsp;-&nbsp;0.4542G'&nbsp;-&nbsp;0.0458B')</para>
783           </listitem>
784         </varlistentry>
785       </variablelist>
786       <para>Y' is clamped to the range [0&hellip;1] and Cb and Cr are clamped
787 to the range [-0.5&hellip;0.5]. The non-standard xvYCC 601 encoding can also be used by
788 selecting <constant>V4L2_YCBCR_ENC_XV601</constant>. The xvYCC encodings always use full
789 range quantization.</para>
790     </section>
791
792     <section>
793       <title id="col-srgb">Colorspace sRGB (<constant>V4L2_COLORSPACE_SRGB</constant>)</title>
794       <para>The <xref linkend="srgb" /> standard defines the colorspace used by most webcams and computer graphics. The
795 default Y'CbCr encoding is <constant>V4L2_YCBCR_ENC_SYCC</constant>. The default Y'CbCr quantization
796 is full range. The chromaticities of the primary colors and the white reference are:</para>
797       <table frame="none">
798         <title>sRGB Chromaticities</title>
799         <tgroup cols="3" align="left">
800           &cs-str;
801         <thead>
802           <row>
803             <entry>Color</entry>
804             <entry>x</entry>
805             <entry>y</entry>
806           </row>
807         </thead>
808           <tbody valign="top">
809             <row>
810               <entry>Red</entry>
811               <entry>0.640</entry>
812               <entry>0.330</entry>
813             </row>
814             <row>
815               <entry>Green</entry>
816               <entry>0.300</entry>
817               <entry>0.600</entry>
818             </row>
819             <row>
820               <entry>Blue</entry>
821               <entry>0.150</entry>
822               <entry>0.060</entry>
823             </row>
824             <row>
825               <entry>White Reference (D65)</entry>
826               <entry>0.3127</entry>
827               <entry>0.3290</entry>
828             </row>
829           </tbody>
830         </tgroup>
831       </table>
832       <para>These chromaticities are identical to the Rec. 709 colorspace.</para>
833       <variablelist>
834         <varlistentry>
835           <term>Transfer function. Note that negative values for L are only used by the Y'CbCr conversion.</term>
836           <listitem>
837             <para>L' = -1.055(-L)<superscript>1/2.4</superscript>&nbsp;+&nbsp;0.055&nbsp;for&nbsp;L&nbsp;&lt;&nbsp;-0.0031308</para>
838             <para>L' = 12.92L&nbsp;for&nbsp;-0.0031308&nbsp;&le;&nbsp;L&nbsp;&le;&nbsp;0.0031308</para>
839             <para>L' = 1.055L<superscript>1/2.4</superscript>&nbsp;-&nbsp;0.055&nbsp;for&nbsp;0.0031308&nbsp;&lt;&nbsp;L&nbsp;&le;&nbsp;1</para>
840           </listitem>
841         </varlistentry>
842         <varlistentry>
843           <term>Inverse Transfer function:</term>
844           <listitem>
845             <para>L = -((-L'&nbsp;+&nbsp;0.055)&nbsp;/&nbsp;1.055)<superscript>2.4</superscript>&nbsp;for&nbsp;L'&nbsp;&lt;&nbsp;-0.04045</para>
846             <para>L = L'&nbsp;/&nbsp;12.92&nbsp;for&nbsp;-0.04045&nbsp;&le;&nbsp;L'&nbsp;&le;&nbsp;0.04045</para>
847             <para>L = ((L'&nbsp;+&nbsp;0.055)&nbsp;/&nbsp;1.055)<superscript>2.4</superscript>&nbsp;for&nbsp;L'&nbsp;&gt;&nbsp;0.04045</para>
848           </listitem>
849         </varlistentry>
850       </variablelist>
851       <variablelist>
852         <varlistentry>
853           <term>The luminance (Y') and color difference (Cb and Cr) are obtained with the following
854 <constant>V4L2_YCBCR_ENC_SYCC</constant> encoding as defined by <xref linkend="sycc" />:</term>
855           <listitem>
856             <para>Y'&nbsp;=&nbsp;0.2990R'&nbsp;+&nbsp;0.5870G'&nbsp;+&nbsp;0.1140B'</para>
857             <para>Cb&nbsp;=&nbsp;-0.1687R'&nbsp;-&nbsp;0.3313G'&nbsp;+&nbsp;0.5B'</para>
858             <para>Cr&nbsp;=&nbsp;0.5R'&nbsp;-&nbsp;0.4187G'&nbsp;-&nbsp;0.0813B'</para>
859           </listitem>
860         </varlistentry>
861       </variablelist>
862       <para>Y' is clamped to the range [0&hellip;1] and Cb and Cr are clamped
863 to the range [-0.5&hellip;0.5]. The <constant>V4L2_YCBCR_ENC_SYCC</constant> quantization is always
864 full range. Although this Y'CbCr encoding looks very similar to the <constant>V4L2_YCBCR_ENC_XV601</constant>
865 encoding, it is not. The <constant>V4L2_YCBCR_ENC_XV601</constant> scales and offsets the Y'CbCr
866 values before quantization, but this encoding does not do that.</para>
867     </section>
868
869     <section>
870       <title id="col-adobergb">Colorspace Adobe RGB (<constant>V4L2_COLORSPACE_ADOBERGB</constant>)</title>
871       <para>The <xref linkend="adobergb" /> standard defines the colorspace used by computer graphics
872 that use the AdobeRGB colorspace. This is also known as the <xref linkend="oprgb" /> standard.
873 The default Y'CbCr encoding is <constant>V4L2_YCBCR_ENC_601</constant>. The default Y'CbCr
874 quantization is limited range. The chromaticities of the primary colors and the white reference
875 are:</para>
876       <table frame="none">
877         <title>Adobe RGB Chromaticities</title>
878         <tgroup cols="3" align="left">
879           &cs-str;
880         <thead>
881           <row>
882             <entry>Color</entry>
883             <entry>x</entry>
884             <entry>y</entry>
885           </row>
886         </thead>
887           <tbody valign="top">
888             <row>
889               <entry>Red</entry>
890               <entry>0.6400</entry>
891               <entry>0.3300</entry>
892             </row>
893             <row>
894               <entry>Green</entry>
895               <entry>0.2100</entry>
896               <entry>0.7100</entry>
897             </row>
898             <row>
899               <entry>Blue</entry>
900               <entry>0.1500</entry>
901               <entry>0.0600</entry>
902             </row>
903             <row>
904               <entry>White Reference (D65)</entry>
905               <entry>0.3127</entry>
906               <entry>0.3290</entry>
907             </row>
908           </tbody>
909         </tgroup>
910       </table>
911       <variablelist>
912         <varlistentry>
913           <term>Transfer function:</term>
914           <listitem>
915             <para>L' = L<superscript>1/2.19921875</superscript></para>
916           </listitem>
917         </varlistentry>
918         <varlistentry>
919           <term>Inverse Transfer function:</term>
920           <listitem>
921             <para>L = L'<superscript>2.19921875</superscript></para>
922           </listitem>
923         </varlistentry>
924       </variablelist>
925       <variablelist>
926         <varlistentry>
927           <term>The luminance (Y') and color difference (Cb and Cr) are obtained with the
928 following <constant>V4L2_YCBCR_ENC_601</constant> encoding:</term>
929           <listitem>
930             <para>Y'&nbsp;=&nbsp;0.299R'&nbsp;+&nbsp;0.587G'&nbsp;+&nbsp;0.114B'</para>
931             <para>Cb&nbsp;=&nbsp;-0.169R'&nbsp;-&nbsp;0.331G'&nbsp;+&nbsp;0.5B'</para>
932             <para>Cr&nbsp;=&nbsp;0.5R'&nbsp;-&nbsp;0.419G'&nbsp;-&nbsp;0.081B'</para>
933           </listitem>
934         </varlistentry>
935       </variablelist>
936       <para>Y' is clamped to the range [0&hellip;1] and Cb and Cr are
937 clamped to the range [-0.5&hellip;0.5]. This transform is identical to one defined in
938 SMPTE 170M/BT.601. The Y'CbCr quantization is limited range.</para>
939     </section>
940
941     <section>
942       <title id="col-bt2020">Colorspace BT.2020 (<constant>V4L2_COLORSPACE_BT2020</constant>)</title>
943       <para>The <xref linkend="itu2020" /> standard defines the colorspace used by Ultra-high definition
944 television (UHDTV). The default Y'CbCr encoding is <constant>V4L2_YCBCR_ENC_BT2020</constant>.
945 The default Y'CbCr quantization is limited range. The chromaticities of the primary colors and
946 the white reference are:</para>
947       <table frame="none">
948         <title>BT.2020 Chromaticities</title>
949         <tgroup cols="3" align="left">
950           &cs-str;
951         <thead>
952           <row>
953             <entry>Color</entry>
954             <entry>x</entry>
955             <entry>y</entry>
956           </row>
957         </thead>
958           <tbody valign="top">
959             <row>
960               <entry>Red</entry>
961               <entry>0.708</entry>
962               <entry>0.292</entry>
963             </row>
964             <row>
965               <entry>Green</entry>
966               <entry>0.170</entry>
967               <entry>0.797</entry>
968             </row>
969             <row>
970               <entry>Blue</entry>
971               <entry>0.131</entry>
972               <entry>0.046</entry>
973             </row>
974             <row>
975               <entry>White Reference (D65)</entry>
976               <entry>0.3127</entry>
977               <entry>0.3290</entry>
978             </row>
979           </tbody>
980         </tgroup>
981       </table>
982       <variablelist>
983         <varlistentry>
984           <term>Transfer function (same as Rec. 709):</term>
985           <listitem>
986             <para>L' = 4.5L&nbsp;for&nbsp;0&nbsp;&le;&nbsp;L&nbsp;&lt;&nbsp;0.018</para>
987             <para>L' = 1.099L<superscript>0.45</superscript>&nbsp;-&nbsp;0.099&nbsp;for&nbsp;0.018&nbsp;&le;&nbsp;L&nbsp;&le;&nbsp;1</para>
988           </listitem>
989         </varlistentry>
990         <varlistentry>
991           <term>Inverse Transfer function:</term>
992           <listitem>
993             <para>L = L'&nbsp;/&nbsp;4.5&nbsp;for&nbsp;L'&nbsp;&lt;&nbsp;0.081</para>
994             <para>L = ((L'&nbsp;+&nbsp;0.099)&nbsp;/&nbsp;1.099)<superscript>1/0.45</superscript>&nbsp;for&nbsp;L'&nbsp;&ge;&nbsp;0.081</para>
995           </listitem>
996         </varlistentry>
997       </variablelist>
998       <variablelist>
999         <varlistentry>
1000           <term>The luminance (Y') and color difference (Cb and Cr) are obtained with the
1001 following <constant>V4L2_YCBCR_ENC_BT2020</constant> encoding:</term>
1002           <listitem>
1003             <para>Y'&nbsp;=&nbsp;0.2627R'&nbsp;+&nbsp;0.6789G'&nbsp;+&nbsp;0.0593B'</para>
1004             <para>Cb&nbsp;=&nbsp;-0.1396R'&nbsp;-&nbsp;0.3604G'&nbsp;+&nbsp;0.5B'</para>
1005             <para>Cr&nbsp;=&nbsp;0.5R'&nbsp;-&nbsp;0.4598G'&nbsp;-&nbsp;0.0402B'</para>
1006           </listitem>
1007         </varlistentry>
1008       </variablelist>
1009       <para>Y' is clamped to the range [0&hellip;1] and Cb and Cr are
1010 clamped to the range [-0.5&hellip;0.5]. The Y'CbCr quantization is limited range.</para>
1011       <para>There is also an alternate constant luminance R'G'B' to Yc'CbcCrc
1012 (<constant>V4L2_YCBCR_ENC_BT2020_CONST_LUM</constant>) encoding:</para>
1013       <variablelist>
1014         <varlistentry>
1015           <term>Luma:</term>
1016           <listitem>
1017             <para>Yc'&nbsp;=&nbsp;(0.2627R&nbsp;+&nbsp;0.6789G&nbsp;+&nbsp;0.0593B)'</para>
1018           </listitem>
1019         </varlistentry>
1020       </variablelist>
1021       <variablelist>
1022         <varlistentry>
1023           <term>B'&nbsp;-&nbsp;Yc'&nbsp;&le;&nbsp;0:</term>
1024           <listitem>
1025             <para>Cbc&nbsp;=&nbsp;(B'&nbsp;-&nbsp;Y')&nbsp;/&nbsp;1.9404</para>
1026           </listitem>
1027         </varlistentry>
1028       </variablelist>
1029       <variablelist>
1030         <varlistentry>
1031           <term>B'&nbsp;-&nbsp;Yc'&nbsp;&gt;&nbsp;0:</term>
1032           <listitem>
1033             <para>Cbc&nbsp;=&nbsp;(B'&nbsp;-&nbsp;Y')&nbsp;/&nbsp;1.5816</para>
1034           </listitem>
1035         </varlistentry>
1036       </variablelist>
1037       <variablelist>
1038         <varlistentry>
1039           <term>R'&nbsp;-&nbsp;Yc'&nbsp;&le;&nbsp;0:</term>
1040           <listitem>
1041             <para>Crc&nbsp;=&nbsp;(R'&nbsp;-&nbsp;Y')&nbsp;/&nbsp;1.7184</para>
1042           </listitem>
1043         </varlistentry>
1044       </variablelist>
1045       <variablelist>
1046         <varlistentry>
1047           <term>R'&nbsp;-&nbsp;Yc'&nbsp;&gt;&nbsp;0:</term>
1048           <listitem>
1049             <para>Crc&nbsp;=&nbsp;(R'&nbsp;-&nbsp;Y')&nbsp;/&nbsp;0.9936</para>
1050           </listitem>
1051         </varlistentry>
1052       </variablelist>
1053       <para>Yc' is clamped to the range [0&hellip;1] and Cbc and Crc are
1054 clamped to the range [-0.5&hellip;0.5]. The Yc'CbcCrc quantization is limited range.</para>
1055     </section>
1056
1057     <section>
1058       <title id="col-smpte-240m">Colorspace SMPTE 240M (<constant>V4L2_COLORSPACE_SMPTE240M</constant>)</title>
1059       <para>The <xref linkend="smpte240m" /> standard was an interim standard used during the early days of HDTV (1988-1998).
1060 It has been superseded by Rec. 709. The default Y'CbCr encoding is <constant>V4L2_YCBCR_ENC_SMPTE240M</constant>.
1061 The default Y'CbCr quantization is limited range. The chromaticities of the primary colors and the
1062 white reference are:</para>
1063       <table frame="none">
1064         <title>SMPTE 240M Chromaticities</title>
1065         <tgroup cols="3" align="left">
1066           &cs-str;
1067         <thead>
1068           <row>
1069             <entry>Color</entry>
1070             <entry>x</entry>
1071             <entry>y</entry>
1072           </row>
1073         </thead>
1074           <tbody valign="top">
1075             <row>
1076               <entry>Red</entry>
1077               <entry>0.630</entry>
1078               <entry>0.340</entry>
1079             </row>
1080             <row>
1081               <entry>Green</entry>
1082               <entry>0.310</entry>
1083               <entry>0.595</entry>
1084             </row>
1085             <row>
1086               <entry>Blue</entry>
1087               <entry>0.155</entry>
1088               <entry>0.070</entry>
1089             </row>
1090             <row>
1091               <entry>White Reference (D65)</entry>
1092               <entry>0.3127</entry>
1093               <entry>0.3290</entry>
1094             </row>
1095           </tbody>
1096         </tgroup>
1097       </table>
1098       <para>These chromaticities are identical to the SMPTE 170M colorspace.</para>
1099       <variablelist>
1100         <varlistentry>
1101           <term>Transfer function:</term>
1102           <listitem>
1103             <para>L' = 4L&nbsp;for&nbsp;0&nbsp;&le;&nbsp;L&nbsp;&lt;&nbsp;0.0228</para>
1104             <para>L' = 1.1115L<superscript>0.45</superscript>&nbsp;-&nbsp;0.1115&nbsp;for&nbsp;0.0228&nbsp;&le;&nbsp;L&nbsp;&le;&nbsp;1</para>
1105           </listitem>
1106         </varlistentry>
1107         <varlistentry>
1108           <term>Inverse Transfer function:</term>
1109           <listitem>
1110             <para>L = L'&nbsp;/&nbsp;4&nbsp;for&nbsp;0&nbsp;&le;&nbsp;L'&nbsp;&lt;&nbsp;0.0913</para>
1111             <para>L = ((L'&nbsp;+&nbsp;0.1115)&nbsp;/&nbsp;1.1115)<superscript>1/0.45</superscript>&nbsp;for&nbsp;L'&nbsp;&ge;&nbsp;0.0913</para>
1112           </listitem>
1113         </varlistentry>
1114       </variablelist>
1115       <variablelist>
1116         <varlistentry>
1117           <term>The luminance (Y') and color difference (Cb and Cr) are obtained with the
1118 following <constant>V4L2_YCBCR_ENC_SMPTE240M</constant> encoding:</term>
1119           <listitem>
1120             <para>Y'&nbsp;=&nbsp;0.2122R'&nbsp;+&nbsp;0.7013G'&nbsp;+&nbsp;0.0865B'</para>
1121             <para>Cb&nbsp;=&nbsp;-0.1161R'&nbsp;-&nbsp;0.3839G'&nbsp;+&nbsp;0.5B'</para>
1122             <para>Cr&nbsp;=&nbsp;0.5R'&nbsp;-&nbsp;0.4451G'&nbsp;-&nbsp;0.0549B'</para>
1123           </listitem>
1124         </varlistentry>
1125       </variablelist>
1126       <para>Yc' is clamped to the range [0&hellip;1] and Cbc and Crc are
1127 clamped to the range [-0.5&hellip;0.5]. The Y'CbCr quantization is limited range.</para>
1128     </section>
1129
1130     <section>
1131       <title id="col-sysm">Colorspace NTSC 1953 (<constant>V4L2_COLORSPACE_470_SYSTEM_M</constant>)</title>
1132       <para>This standard defines the colorspace used by NTSC in 1953. In practice this
1133 colorspace is obsolete and SMPTE 170M should be used instead. The default Y'CbCr encoding
1134 is <constant>V4L2_YCBCR_ENC_601</constant>. The default Y'CbCr quantization is limited range.
1135 The chromaticities of the primary colors and the white reference are:</para>
1136       <table frame="none">
1137         <title>NTSC 1953 Chromaticities</title>
1138         <tgroup cols="3" align="left">
1139           &cs-str;
1140         <thead>
1141           <row>
1142             <entry>Color</entry>
1143             <entry>x</entry>
1144             <entry>y</entry>
1145           </row>
1146         </thead>
1147           <tbody valign="top">
1148             <row>
1149               <entry>Red</entry>
1150               <entry>0.67</entry>
1151               <entry>0.33</entry>
1152             </row>
1153             <row>
1154               <entry>Green</entry>
1155               <entry>0.21</entry>
1156               <entry>0.71</entry>
1157             </row>
1158             <row>
1159               <entry>Blue</entry>
1160               <entry>0.14</entry>
1161               <entry>0.08</entry>
1162             </row>
1163             <row>
1164               <entry>White Reference (C)</entry>
1165               <entry>0.310</entry>
1166               <entry>0.316</entry>
1167             </row>
1168           </tbody>
1169         </tgroup>
1170       </table>
1171       <para>Note that this colorspace uses Illuminant C instead of D65 as the
1172 white reference. To correctly convert an image in this colorspace to another
1173 that uses D65 you need to apply a chromatic adaptation algorithm such as the
1174 Bradford method.</para>
1175       <variablelist>
1176         <varlistentry>
1177           <term>The transfer function was never properly defined for NTSC 1953. The
1178 Rec. 709 transfer function is recommended in the literature:</term>
1179           <listitem>
1180             <para>L' = 4.5L&nbsp;for&nbsp;0&nbsp;&le;&nbsp;L&nbsp;&lt;&nbsp;0.018</para>
1181             <para>L' = 1.099L<superscript>0.45</superscript>&nbsp;-&nbsp;0.099&nbsp;for&nbsp;0.018&nbsp;&le;&nbsp;L&nbsp;&le;&nbsp;1</para>
1182           </listitem>
1183         </varlistentry>
1184         <varlistentry>
1185           <term>Inverse Transfer function:</term>
1186           <listitem>
1187             <para>L = L'&nbsp;/&nbsp;4.5&nbsp;for&nbsp;L'&nbsp;&lt;&nbsp;0.081</para>
1188             <para>L = ((L'&nbsp;+&nbsp;0.099)&nbsp;/&nbsp;1.099)<superscript>1/0.45</superscript>&nbsp;for&nbsp;L'&nbsp;&ge;&nbsp;0.081</para>
1189           </listitem>
1190         </varlistentry>
1191       </variablelist>
1192       <variablelist>
1193         <varlistentry>
1194           <term>The luminance (Y') and color difference (Cb and Cr) are obtained with the
1195 following <constant>V4L2_YCBCR_ENC_601</constant> encoding:</term>
1196           <listitem>
1197             <para>Y'&nbsp;=&nbsp;0.299R'&nbsp;+&nbsp;0.587G'&nbsp;+&nbsp;0.114B'</para>
1198             <para>Cb&nbsp;=&nbsp;-0.169R'&nbsp;-&nbsp;0.331G'&nbsp;+&nbsp;0.5B'</para>
1199             <para>Cr&nbsp;=&nbsp;0.5R'&nbsp;-&nbsp;0.419G'&nbsp;-&nbsp;0.081B'</para>
1200           </listitem>
1201         </varlistentry>
1202       </variablelist>
1203       <para>Y' is clamped to the range [0&hellip;1] and Cb and Cr are
1204 clamped to the range [-0.5&hellip;0.5]. The Y'CbCr quantization is limited range.
1205 This transform is identical to one defined in SMPTE 170M/BT.601.</para>
1206     </section>
1207
1208     <section>
1209       <title id="col-sysbg">Colorspace EBU Tech. 3213 (<constant>V4L2_COLORSPACE_470_SYSTEM_BG</constant>)</title>
1210       <para>The <xref linkend="tech3213" /> standard defines the colorspace used by PAL/SECAM in 1975. In practice this
1211 colorspace is obsolete and SMPTE 170M should be used instead. The default Y'CbCr encoding
1212 is <constant>V4L2_YCBCR_ENC_601</constant>. The default Y'CbCr quantization is limited range.
1213 The chromaticities of the primary colors and the white reference are:</para>
1214       <table frame="none">
1215         <title>EBU Tech. 3213 Chromaticities</title>
1216         <tgroup cols="3" align="left">
1217           &cs-str;
1218         <thead>
1219           <row>
1220             <entry>Color</entry>
1221             <entry>x</entry>
1222             <entry>y</entry>
1223           </row>
1224         </thead>
1225           <tbody valign="top">
1226             <row>
1227               <entry>Red</entry>
1228               <entry>0.64</entry>
1229               <entry>0.33</entry>
1230             </row>
1231             <row>
1232               <entry>Green</entry>
1233               <entry>0.29</entry>
1234               <entry>0.60</entry>
1235             </row>
1236             <row>
1237               <entry>Blue</entry>
1238               <entry>0.15</entry>
1239               <entry>0.06</entry>
1240             </row>
1241             <row>
1242               <entry>White Reference (D65)</entry>
1243               <entry>0.3127</entry>
1244               <entry>0.3290</entry>
1245             </row>
1246           </tbody>
1247         </tgroup>
1248       </table>
1249       <variablelist>
1250         <varlistentry>
1251           <term>The transfer function was never properly defined for this colorspace.
1252 The Rec. 709 transfer function is recommended in the literature:</term>
1253           <listitem>
1254             <para>L' = 4.5L&nbsp;for&nbsp;0&nbsp;&le;&nbsp;L&nbsp;&lt;&nbsp;0.018</para>
1255             <para>L' = 1.099L<superscript>0.45</superscript>&nbsp;-&nbsp;0.099&nbsp;for&nbsp;0.018&nbsp;&le;&nbsp;L&nbsp;&le;&nbsp;1</para>
1256           </listitem>
1257         </varlistentry>
1258         <varlistentry>
1259           <term>Inverse Transfer function:</term>
1260           <listitem>
1261             <para>L = L'&nbsp;/&nbsp;4.5&nbsp;for&nbsp;L'&nbsp;&lt;&nbsp;0.081</para>
1262             <para>L = ((L'&nbsp;+&nbsp;0.099)&nbsp;/&nbsp;1.099)<superscript>1/0.45</superscript>&nbsp;for&nbsp;L'&nbsp;&ge;&nbsp;0.081</para>
1263           </listitem>
1264         </varlistentry>
1265       </variablelist>
1266       <variablelist>
1267         <varlistentry>
1268           <term>The luminance (Y') and color difference (Cb and Cr) are obtained with the
1269 following <constant>V4L2_YCBCR_ENC_601</constant> encoding:</term>
1270           <listitem>
1271             <para>Y'&nbsp;=&nbsp;0.299R'&nbsp;+&nbsp;0.587G'&nbsp;+&nbsp;0.114B'</para>
1272             <para>Cb&nbsp;=&nbsp;-0.169R'&nbsp;-&nbsp;0.331G'&nbsp;+&nbsp;0.5B'</para>
1273             <para>Cr&nbsp;=&nbsp;0.5R'&nbsp;-&nbsp;0.419G'&nbsp;-&nbsp;0.081B'</para>
1274           </listitem>
1275         </varlistentry>
1276       </variablelist>
1277       <para>Y' is clamped to the range [0&hellip;1] and Cb and Cr are
1278 clamped to the range [-0.5&hellip;0.5]. The Y'CbCr quantization is limited range.
1279 This transform is identical to one defined in SMPTE 170M/BT.601.</para>
1280     </section>
1281
1282     <section>
1283       <title id="col-jpeg">Colorspace JPEG (<constant>V4L2_COLORSPACE_JPEG</constant>)</title>
1284       <para>This colorspace defines the colorspace used by most (Motion-)JPEG formats. The chromaticities
1285 of the primary colors and the white reference are identical to sRGB. The Y'CbCr encoding is
1286 <constant>V4L2_YCBCR_ENC_601</constant> with full range quantization where
1287 Y' is scaled to [0&hellip;255] and Cb/Cr are scaled to [-128&hellip;128] and
1288 then clipped to [-128&hellip;127].</para>
1289       <para>Note that the JPEG standard does not actually store colorspace information.
1290 So if something other than sRGB is used, then the driver will have to set that information
1291 explicitly. Effectively <constant>V4L2_COLORSPACE_JPEG</constant> can be considered to be
1292 an abbreviation for <constant>V4L2_COLORSPACE_SRGB</constant>, <constant>V4L2_YCBCR_ENC_601</constant>
1293 and <constant>V4L2_QUANTIZATION_FULL_RANGE</constant>.</para>
1294     </section>
1295
1296   </section>
1297
1298   <section id="pixfmt-indexed">
1299     <title>Indexed Format</title>
1300
1301     <para>In this format each pixel is represented by an 8 bit index
1302 into a 256 entry ARGB palette. It is intended for <link
1303 linkend="osd">Video Output Overlays</link> only. There are no ioctls to
1304 access the palette, this must be done with ioctls of the Linux framebuffer API.</para>
1305
1306     <table pgwide="0" frame="none">
1307       <title>Indexed Image Format</title>
1308       <tgroup cols="37" align="center">
1309         <colspec colname="id" align="left" />
1310         <colspec colname="fourcc" />
1311         <colspec colname="bit" />
1312
1313         <colspec colnum="4" colname="b07" align="center" />
1314         <colspec colnum="5" colname="b06" align="center" />
1315         <colspec colnum="6" colname="b05" align="center" />
1316         <colspec colnum="7" colname="b04" align="center" />
1317         <colspec colnum="8" colname="b03" align="center" />
1318         <colspec colnum="9" colname="b02" align="center" />
1319         <colspec colnum="10" colname="b01" align="center" />
1320         <colspec colnum="11" colname="b00" align="center" />
1321
1322         <spanspec namest="b07" nameend="b00" spanname="b0" />
1323         <spanspec namest="b17" nameend="b10" spanname="b1" />
1324         <spanspec namest="b27" nameend="b20" spanname="b2" />
1325         <spanspec namest="b37" nameend="b30" spanname="b3" />
1326         <thead>
1327           <row>
1328             <entry>Identifier</entry>
1329             <entry>Code</entry>
1330             <entry>&nbsp;</entry>
1331             <entry spanname="b0">Byte&nbsp;0</entry>
1332           </row>
1333           <row>
1334             <entry>&nbsp;</entry>
1335             <entry>&nbsp;</entry>
1336             <entry>Bit</entry>
1337             <entry>7</entry>
1338             <entry>6</entry>
1339             <entry>5</entry>
1340             <entry>4</entry>
1341             <entry>3</entry>
1342             <entry>2</entry>
1343             <entry>1</entry>
1344             <entry>0</entry>
1345           </row>
1346         </thead>
1347         <tbody valign="top">
1348           <row id="V4L2-PIX-FMT-PAL8">
1349             <entry><constant>V4L2_PIX_FMT_PAL8</constant></entry>
1350             <entry>'PAL8'</entry>
1351             <entry></entry>
1352             <entry>i<subscript>7</subscript></entry>
1353             <entry>i<subscript>6</subscript></entry>
1354             <entry>i<subscript>5</subscript></entry>
1355             <entry>i<subscript>4</subscript></entry>
1356             <entry>i<subscript>3</subscript></entry>
1357             <entry>i<subscript>2</subscript></entry>
1358             <entry>i<subscript>1</subscript></entry>
1359             <entry>i<subscript>0</subscript></entry>
1360           </row>
1361         </tbody>
1362       </tgroup>
1363     </table>
1364   </section>
1365
1366   <section id="pixfmt-rgb">
1367     <title>RGB Formats</title>
1368
1369     &sub-packed-rgb;
1370     &sub-sbggr8;
1371     &sub-sgbrg8;
1372     &sub-sgrbg8;
1373     &sub-srggb8;
1374     &sub-sbggr16;
1375     &sub-srggb10;
1376     &sub-srggb10alaw8;
1377     &sub-srggb10dpcm8;
1378     &sub-srggb12;
1379   </section>
1380
1381   <section id="yuv-formats">
1382     <title>YUV Formats</title>
1383
1384     <para>YUV is the format native to TV broadcast and composite video
1385 signals. It separates the brightness information (Y) from the color
1386 information (U and V or Cb and Cr). The color information consists of
1387 red and blue <emphasis>color difference</emphasis> signals, this way
1388 the green component can be reconstructed by subtracting from the
1389 brightness component. See <xref linkend="colorspaces" /> for conversion
1390 examples. YUV was chosen because early television would only transmit
1391 brightness information. To add color in a way compatible with existing
1392 receivers a new signal carrier was added to transmit the color
1393 difference signals. Secondary in the YUV format the U and V components
1394 usually have lower resolution than the Y component. This is an analog
1395 video compression technique taking advantage of a property of the
1396 human visual system, being more sensitive to brightness
1397 information.</para>
1398
1399     &sub-packed-yuv;
1400     &sub-grey;
1401     &sub-y10;
1402     &sub-y12;
1403     &sub-y10b;
1404     &sub-y16;
1405     &sub-uv8;
1406     &sub-yuyv;
1407     &sub-uyvy;
1408     &sub-yvyu;
1409     &sub-vyuy;
1410     &sub-y41p;
1411     &sub-yuv420;
1412     &sub-yuv420m;
1413     &sub-yvu420m;
1414     &sub-yuv410;
1415     &sub-yuv422p;
1416     &sub-yuv411p;
1417     &sub-nv12;
1418     &sub-nv12m;
1419     &sub-nv12mt;
1420     &sub-nv16;
1421     &sub-nv16m;
1422     &sub-nv24;
1423     &sub-m420;
1424   </section>
1425
1426   <section>
1427     <title>Compressed Formats</title>
1428
1429     <table pgwide="1" frame="none" id="compressed-formats">
1430       <title>Compressed Image Formats</title>
1431       <tgroup cols="3" align="left">
1432         &cs-def;
1433         <thead>
1434           <row>
1435             <entry>Identifier</entry>
1436             <entry>Code</entry>
1437             <entry>Details</entry>
1438           </row>
1439         </thead>
1440         <tbody valign="top">
1441          <row id="V4L2-PIX-FMT-JPEG">
1442             <entry><constant>V4L2_PIX_FMT_JPEG</constant></entry>
1443             <entry>'JPEG'</entry>
1444             <entry>TBD. See also &VIDIOC-G-JPEGCOMP;,
1445             &VIDIOC-S-JPEGCOMP;.</entry>
1446           </row>
1447           <row id="V4L2-PIX-FMT-MPEG">
1448             <entry><constant>V4L2_PIX_FMT_MPEG</constant></entry>
1449             <entry>'MPEG'</entry>
1450             <entry>MPEG multiplexed stream. The actual format is determined by
1451 extended control <constant>V4L2_CID_MPEG_STREAM_TYPE</constant>, see
1452 <xref linkend="mpeg-control-id" />.</entry>
1453           </row>
1454           <row id="V4L2-PIX-FMT-H264">
1455                 <entry><constant>V4L2_PIX_FMT_H264</constant></entry>
1456                 <entry>'H264'</entry>
1457                 <entry>H264 video elementary stream with start codes.</entry>
1458           </row>
1459           <row id="V4L2-PIX-FMT-H264-NO-SC">
1460                 <entry><constant>V4L2_PIX_FMT_H264_NO_SC</constant></entry>
1461                 <entry>'AVC1'</entry>
1462                 <entry>H264 video elementary stream without start codes.</entry>
1463           </row>
1464           <row id="V4L2-PIX-FMT-H264-MVC">
1465                 <entry><constant>V4L2_PIX_FMT_H264_MVC</constant></entry>
1466                 <entry>'M264'</entry>
1467                 <entry>H264 MVC video elementary stream.</entry>
1468           </row>
1469           <row id="V4L2-PIX-FMT-H263">
1470                 <entry><constant>V4L2_PIX_FMT_H263</constant></entry>
1471                 <entry>'H263'</entry>
1472                 <entry>H263 video elementary stream.</entry>
1473           </row>
1474           <row id="V4L2-PIX-FMT-MPEG1">
1475                 <entry><constant>V4L2_PIX_FMT_MPEG1</constant></entry>
1476                 <entry>'MPG1'</entry>
1477                 <entry>MPEG1 video elementary stream.</entry>
1478           </row>
1479           <row id="V4L2-PIX-FMT-MPEG2">
1480                 <entry><constant>V4L2_PIX_FMT_MPEG2</constant></entry>
1481                 <entry>'MPG2'</entry>
1482                 <entry>MPEG2 video elementary stream.</entry>
1483           </row>
1484           <row id="V4L2-PIX-FMT-MPEG4">
1485                 <entry><constant>V4L2_PIX_FMT_MPEG4</constant></entry>
1486                 <entry>'MPG4'</entry>
1487                 <entry>MPEG4 video elementary stream.</entry>
1488           </row>
1489           <row id="V4L2-PIX-FMT-XVID">
1490                 <entry><constant>V4L2_PIX_FMT_XVID</constant></entry>
1491                 <entry>'XVID'</entry>
1492                 <entry>Xvid video elementary stream.</entry>
1493           </row>
1494           <row id="V4L2-PIX-FMT-VC1-ANNEX-G">
1495                 <entry><constant>V4L2_PIX_FMT_VC1_ANNEX_G</constant></entry>
1496                 <entry>'VC1G'</entry>
1497                 <entry>VC1, SMPTE 421M Annex G compliant stream.</entry>
1498           </row>
1499           <row id="V4L2-PIX-FMT-VC1-ANNEX-L">
1500                 <entry><constant>V4L2_PIX_FMT_VC1_ANNEX_L</constant></entry>
1501                 <entry>'VC1L'</entry>
1502                 <entry>VC1, SMPTE 421M Annex L compliant stream.</entry>
1503           </row>
1504           <row id="V4L2-PIX-FMT-VP8">
1505                 <entry><constant>V4L2_PIX_FMT_VP8</constant></entry>
1506                 <entry>'VP80'</entry>
1507                 <entry>VP8 video elementary stream.</entry>
1508           </row>
1509         </tbody>
1510       </tgroup>
1511     </table>
1512   </section>
1513
1514   <section id="sdr-formats">
1515     <title>SDR Formats</title>
1516
1517     <para>These formats are used for <link linkend="sdr">SDR Capture</link>
1518 interface only.</para>
1519
1520     &sub-sdr-cu08;
1521     &sub-sdr-cu16le;
1522     &sub-sdr-cs08;
1523     &sub-sdr-cs14le;
1524     &sub-sdr-ru12le;
1525
1526   </section>
1527
1528   <section id="pixfmt-reserved">
1529     <title>Reserved Format Identifiers</title>
1530
1531     <para>These formats are not defined by this specification, they
1532 are just listed for reference and to avoid naming conflicts. If you
1533 want to register your own format, send an e-mail to the linux-media mailing
1534 list &v4l-ml; for inclusion in the <filename>videodev2.h</filename>
1535 file. If you want to share your format with other developers add a
1536 link to your documentation and send a copy to the linux-media mailing list
1537 for inclusion in this section. If you think your format should be listed
1538 in a standard format section please make a proposal on the linux-media mailing
1539 list.</para>
1540
1541     <table pgwide="1" frame="none" id="reserved-formats">
1542       <title>Reserved Image Formats</title>
1543       <tgroup cols="3" align="left">
1544         &cs-def;
1545         <thead>
1546           <row>
1547             <entry>Identifier</entry>
1548             <entry>Code</entry>
1549             <entry>Details</entry>
1550           </row>
1551         </thead>
1552         <tbody valign="top">
1553           <row id="V4L2-PIX-FMT-DV">
1554             <entry><constant>V4L2_PIX_FMT_DV</constant></entry>
1555             <entry>'dvsd'</entry>
1556             <entry>unknown</entry>
1557           </row>
1558           <row id="V4L2-PIX-FMT-ET61X251">
1559             <entry><constant>V4L2_PIX_FMT_ET61X251</constant></entry>
1560             <entry>'E625'</entry>
1561             <entry>Compressed format of the ET61X251 driver.</entry>
1562           </row>
1563           <row id="V4L2-PIX-FMT-HI240">
1564             <entry><constant>V4L2_PIX_FMT_HI240</constant></entry>
1565             <entry>'HI24'</entry>
1566             <entry><para>8 bit RGB format used by the BTTV driver.</para></entry>
1567           </row>
1568           <row id="V4L2-PIX-FMT-HM12">
1569             <entry><constant>V4L2_PIX_FMT_HM12</constant></entry>
1570             <entry>'HM12'</entry>
1571             <entry><para>YUV 4:2:0 format used by the
1572 IVTV driver, <ulink url="http://www.ivtvdriver.org/">
1573 http://www.ivtvdriver.org/</ulink></para><para>The format is documented in the
1574 kernel sources in the file <filename>Documentation/video4linux/cx2341x/README.hm12</filename>
1575 </para></entry>
1576           </row>
1577           <row id="V4L2-PIX-FMT-CPIA1">
1578             <entry><constant>V4L2_PIX_FMT_CPIA1</constant></entry>
1579             <entry>'CPIA'</entry>
1580             <entry>YUV format used by the gspca cpia1 driver.</entry>
1581           </row>
1582           <row id="V4L2-PIX-FMT-JPGL">
1583             <entry><constant>V4L2_PIX_FMT_JPGL</constant></entry>
1584             <entry>'JPGL'</entry>
1585             <entry>JPEG-Light format (Pegasus Lossless JPEG)
1586                         used in Divio webcams NW 80x.</entry>
1587           </row>
1588           <row id="V4L2-PIX-FMT-SPCA501">
1589             <entry><constant>V4L2_PIX_FMT_SPCA501</constant></entry>
1590             <entry>'S501'</entry>
1591             <entry>YUYV per line used by the gspca driver.</entry>
1592           </row>
1593           <row id="V4L2-PIX-FMT-SPCA505">
1594             <entry><constant>V4L2_PIX_FMT_SPCA505</constant></entry>
1595             <entry>'S505'</entry>
1596             <entry>YYUV per line used by the gspca driver.</entry>
1597           </row>
1598           <row id="V4L2-PIX-FMT-SPCA508">
1599             <entry><constant>V4L2_PIX_FMT_SPCA508</constant></entry>
1600             <entry>'S508'</entry>
1601             <entry>YUVY per line used by the gspca driver.</entry>
1602           </row>
1603           <row id="V4L2-PIX-FMT-SPCA561">
1604             <entry><constant>V4L2_PIX_FMT_SPCA561</constant></entry>
1605             <entry>'S561'</entry>
1606             <entry>Compressed GBRG Bayer format used by the gspca driver.</entry>
1607           </row>
1608           <row id="V4L2-PIX-FMT-PAC207">
1609             <entry><constant>V4L2_PIX_FMT_PAC207</constant></entry>
1610             <entry>'P207'</entry>
1611             <entry>Compressed BGGR Bayer format used by the gspca driver.</entry>
1612           </row>
1613           <row id="V4L2-PIX-FMT-MR97310A">
1614             <entry><constant>V4L2_PIX_FMT_MR97310A</constant></entry>
1615             <entry>'M310'</entry>
1616             <entry>Compressed BGGR Bayer format used by the gspca driver.</entry>
1617           </row>
1618           <row id="V4L2-PIX-FMT-JL2005BCD">
1619             <entry><constant>V4L2_PIX_FMT_JL2005BCD</constant></entry>
1620             <entry>'JL20'</entry>
1621             <entry>JPEG compressed RGGB Bayer format used by the gspca driver.</entry>
1622           </row>
1623           <row id="V4L2-PIX-FMT-OV511">
1624             <entry><constant>V4L2_PIX_FMT_OV511</constant></entry>
1625             <entry>'O511'</entry>
1626             <entry>OV511 JPEG format used by the gspca driver.</entry>
1627           </row>
1628           <row id="V4L2-PIX-FMT-OV518">
1629             <entry><constant>V4L2_PIX_FMT_OV518</constant></entry>
1630             <entry>'O518'</entry>
1631             <entry>OV518 JPEG format used by the gspca driver.</entry>
1632           </row>
1633           <row id="V4L2-PIX-FMT-PJPG">
1634             <entry><constant>V4L2_PIX_FMT_PJPG</constant></entry>
1635             <entry>'PJPG'</entry>
1636             <entry>Pixart 73xx JPEG format used by the gspca driver.</entry>
1637           </row>
1638           <row id="V4L2-PIX-FMT-SE401">
1639             <entry><constant>V4L2_PIX_FMT_SE401</constant></entry>
1640             <entry>'S401'</entry>
1641             <entry>Compressed RGB format used by the gspca se401 driver</entry>
1642           </row>
1643           <row id="V4L2-PIX-FMT-SQ905C">
1644             <entry><constant>V4L2_PIX_FMT_SQ905C</constant></entry>
1645             <entry>'905C'</entry>
1646             <entry>Compressed RGGB bayer format used by the gspca driver.</entry>
1647           </row>
1648           <row id="V4L2-PIX-FMT-MJPEG">
1649             <entry><constant>V4L2_PIX_FMT_MJPEG</constant></entry>
1650             <entry>'MJPG'</entry>
1651             <entry>Compressed format used by the Zoran driver</entry>
1652           </row>
1653           <row id="V4L2-PIX-FMT-PWC1">
1654             <entry><constant>V4L2_PIX_FMT_PWC1</constant></entry>
1655             <entry>'PWC1'</entry>
1656             <entry>Compressed format of the PWC driver.</entry>
1657           </row>
1658           <row id="V4L2-PIX-FMT-PWC2">
1659             <entry><constant>V4L2_PIX_FMT_PWC2</constant></entry>
1660             <entry>'PWC2'</entry>
1661             <entry>Compressed format of the PWC driver.</entry>
1662           </row>
1663           <row id="V4L2-PIX-FMT-SN9C10X">
1664             <entry><constant>V4L2_PIX_FMT_SN9C10X</constant></entry>
1665             <entry>'S910'</entry>
1666             <entry>Compressed format of the SN9C102 driver.</entry>
1667           </row>
1668           <row id="V4L2-PIX-FMT-SN9C20X-I420">
1669             <entry><constant>V4L2_PIX_FMT_SN9C20X_I420</constant></entry>
1670             <entry>'S920'</entry>
1671             <entry>YUV 4:2:0 format of the gspca sn9c20x driver.</entry>
1672           </row>
1673           <row id="V4L2-PIX-FMT-SN9C2028">
1674             <entry><constant>V4L2_PIX_FMT_SN9C2028</constant></entry>
1675             <entry>'SONX'</entry>
1676             <entry>Compressed GBRG bayer format of the gspca sn9c2028 driver.</entry>
1677           </row>
1678           <row id="V4L2-PIX-FMT-STV0680">
1679             <entry><constant>V4L2_PIX_FMT_STV0680</constant></entry>
1680             <entry>'S680'</entry>
1681             <entry>Bayer format of the gspca stv0680 driver.</entry>
1682           </row>
1683           <row id="V4L2-PIX-FMT-WNVA">
1684             <entry><constant>V4L2_PIX_FMT_WNVA</constant></entry>
1685             <entry>'WNVA'</entry>
1686             <entry><para>Used by the Winnov Videum driver, <ulink
1687 url="http://www.thedirks.org/winnov/">
1688 http://www.thedirks.org/winnov/</ulink></para></entry>
1689           </row>
1690           <row id="V4L2-PIX-FMT-TM6000">
1691             <entry><constant>V4L2_PIX_FMT_TM6000</constant></entry>
1692             <entry>'TM60'</entry>
1693             <entry><para>Used by Trident tm6000</para></entry>
1694           </row>
1695           <row id="V4L2-PIX-FMT-CIT-YYVYUY">
1696             <entry><constant>V4L2_PIX_FMT_CIT_YYVYUY</constant></entry>
1697             <entry>'CITV'</entry>
1698             <entry><para>Used by xirlink CIT, found at IBM webcams.</para>
1699                    <para>Uses one line of Y then 1 line of VYUY</para>
1700             </entry>
1701           </row>
1702           <row id="V4L2-PIX-FMT-KONICA420">
1703             <entry><constant>V4L2_PIX_FMT_KONICA420</constant></entry>
1704             <entry>'KONI'</entry>
1705             <entry><para>Used by Konica webcams.</para>
1706                    <para>YUV420 planar in blocks of 256 pixels.</para>
1707             </entry>
1708           </row>
1709           <row id="V4L2-PIX-FMT-YYUV">
1710             <entry><constant>V4L2_PIX_FMT_YYUV</constant></entry>
1711             <entry>'YYUV'</entry>
1712             <entry>unknown</entry>
1713           </row>
1714           <row id="V4L2-PIX-FMT-Y4">
1715             <entry><constant>V4L2_PIX_FMT_Y4</constant></entry>
1716             <entry>'Y04 '</entry>
1717             <entry>Old 4-bit greyscale format. Only the most significant 4 bits of each byte are used,
1718 the other bits are set to 0.</entry>
1719           </row>
1720           <row id="V4L2-PIX-FMT-Y6">
1721             <entry><constant>V4L2_PIX_FMT_Y6</constant></entry>
1722             <entry>'Y06 '</entry>
1723             <entry>Old 6-bit greyscale format. Only the most significant 6 bits of each byte are used,
1724 the other bits are set to 0.</entry>
1725           </row>
1726           <row id="V4L2-PIX-FMT-S5C-UYVY-JPG">
1727             <entry><constant>V4L2_PIX_FMT_S5C_UYVY_JPG</constant></entry>
1728             <entry>'S5CI'</entry>
1729             <entry>Two-planar format used by Samsung S5C73MX cameras. The
1730 first plane contains interleaved JPEG and UYVY image data, followed by meta data
1731 in form of an array of offsets to the UYVY data blocks. The actual pointer array
1732 follows immediately the interleaved JPEG/UYVY data, the number of entries in
1733 this array equals the height of the UYVY image. Each entry is a 4-byte unsigned
1734 integer in big endian order and it's an offset to a single pixel line of the
1735 UYVY image. The first plane can start either with JPEG or UYVY data chunk. The
1736 size of a single UYVY block equals the UYVY image's width multiplied by 2. The
1737 size of a JPEG chunk depends on the image and can vary with each line.
1738 <para>The second plane, at an offset of 4084 bytes, contains a 4-byte offset to
1739 the pointer array in the first plane. This offset is followed by a 4-byte value
1740 indicating size of the pointer array. All numbers in the second plane are also
1741 in big endian order. Remaining data in the second plane is undefined. The
1742 information in the second plane allows to easily find location of the pointer
1743 array, which can be different for each frame. The size of the pointer array is
1744 constant for given UYVY image height.</para>
1745 <para>In order to extract UYVY and JPEG frames an application can initially set
1746 a data pointer to the start of first plane and then add an offset from the first
1747 entry of the pointers table. Such a pointer indicates start of an UYVY image
1748 pixel line. Whole UYVY line can be copied to a separate buffer. These steps
1749 should be repeated for each line, i.e. the number of entries in the pointer
1750 array. Anything what's in between the UYVY lines is JPEG data and should be
1751 concatenated to form the JPEG stream. </para>
1752 </entry>
1753           </row>
1754         </tbody>
1755       </tgroup>
1756     </table>
1757
1758     <table frame="none" pgwide="1" id="format-flags">
1759       <title>Format Flags</title>
1760       <tgroup cols="3">
1761         &cs-def;
1762         <tbody valign="top">
1763           <row>
1764             <entry><constant>V4L2_PIX_FMT_FLAG_PREMUL_ALPHA</constant></entry>
1765             <entry>0x00000001</entry>
1766             <entry>The color values are premultiplied by the alpha channel
1767 value. For example, if a light blue pixel with 50% transparency was described by
1768 RGBA values (128, 192, 255, 128), the same pixel described with premultiplied
1769 colors would be described by RGBA values (64, 96, 128, 128) </entry>
1770           </row>
1771         </tbody>
1772       </tgroup>
1773     </table>
1774   </section>