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