1 <title>Image Formats</title>
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>
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>
22 <entry><structfield>width</structfield></entry>
23 <entry>Image width in pixels.</entry>
27 <entry><structfield>height</structfield></entry>
28 <entry>Image height in pixels.</entry>
31 <entry spanname="hspan">Applications set these fields to
32 request an image size, drivers return the closest possible values. In
33 case of planar formats the <structfield>width</structfield> and
34 <structfield>height</structfield> applies to the largest plane. To
35 avoid ambiguities drivers must return values rounded up to a multiple
36 of the scale factor of any smaller planes. For example when the image
37 format is YUV 4:2:0, <structfield>width</structfield> and
38 <structfield>height</structfield> must be multiples of two.</entry>
42 <entry><structfield>pixelformat</structfield></entry>
43 <entry>The pixel format or type of compression, set by the
44 application. This is a little endian <link
45 linkend="v4l2-fourcc">four character code</link>. V4L2 defines
46 standard RGB formats in <xref linkend="rgb-formats" />, YUV formats in <xref
47 linkend="yuv-formats" />, and reserved codes in <xref
48 linkend="reserved-formats" /></entry>
51 <entry>&v4l2-field;</entry>
52 <entry><structfield>field</structfield></entry>
53 <entry>Video images are typically interlaced. Applications
54 can request to capture or output only the top or bottom field, or both
55 fields interlaced or sequentially stored in one buffer or alternating
56 in separate buffers. Drivers return the actual field order selected.
57 For details see <xref linkend="field-order" />.</entry>
61 <entry><structfield>bytesperline</structfield></entry>
62 <entry>Distance in bytes between the leftmost pixels in two
63 adjacent lines.</entry>
66 <entry spanname="hspan"><para>Both applications and drivers
67 can set this field to request padding bytes at the end of each line.
68 Drivers however may ignore the value requested by the application,
69 returning <structfield>width</structfield> times bytes per pixel or a
70 larger value required by the hardware. That implies applications can
71 just set this field to zero to get a reasonable
72 default.</para><para>Video hardware may access padding bytes,
73 therefore they must reside in accessible memory. Consider cases where
74 padding bytes after the last line of an image cross a system page
75 boundary. Input devices may write padding bytes, the value is
76 undefined. Output devices ignore the contents of padding
77 bytes.</para><para>When the image format is planar the
78 <structfield>bytesperline</structfield> value applies to the largest
79 plane and is divided by the same factor as the
80 <structfield>width</structfield> field for any smaller planes. For
81 example the Cb and Cr planes of a YUV 4:2:0 image have half as many
82 padding bytes following each line as the Y plane. To avoid ambiguities
83 drivers must return a <structfield>bytesperline</structfield> value
84 rounded up to a multiple of the scale factor.</para></entry>
88 <entry><structfield>sizeimage</structfield></entry>
89 <entry>Size in bytes of the buffer to hold a complete image,
90 set by the driver. Usually this is
91 <structfield>bytesperline</structfield> times
92 <structfield>height</structfield>. When the image consists of variable
93 length compressed data this is the maximum number of bytes required to
94 hold an image.</entry>
97 <entry>&v4l2-colorspace;</entry>
98 <entry><structfield>colorspace</structfield></entry>
99 <entry>This information supplements the
100 <structfield>pixelformat</structfield> and must be set by the driver,
101 see <xref linkend="colorspaces" />.</entry>
105 <entry><structfield>priv</structfield></entry>
106 <entry><para>This field indicates whether the remaining fields of the
107 <structname>v4l2_pix_format</structname> structure, also called the extended
108 fields, are valid. When set to <constant>V4L2_PIX_FMT_PRIV_MAGIC</constant>, it
109 indicates that the extended fields have been correctly initialized. When set to
110 any other value it indicates that the extended fields contain undefined values.
112 <para>Applications that wish to use the pixel format extended fields must first
113 ensure that the feature is supported by querying the device for the
114 <link linkend="querycap"><constant>V4L2_CAP_EXT_PIX_FORMAT</constant></link>
115 capability. If the capability isn't set the pixel format extended fields are not
116 supported and using the extended fields will lead to undefined results.</para>
117 <para>To use the extended fields, applications must set the
118 <structfield>priv</structfield> field to
119 <constant>V4L2_PIX_FMT_PRIV_MAGIC</constant>, initialize all the extended fields
120 and zero the unused bytes of the <structname>v4l2_format</structname>
121 <structfield>raw_data</structfield> field.</para>
122 <para>When the <structfield>priv</structfield> field isn't set to
123 <constant>V4L2_PIX_FMT_PRIV_MAGIC</constant> drivers must act as if all the
124 extended fields were set to zero. On return drivers must set the
125 <structfield>priv</structfield> field to
126 <constant>V4L2_PIX_FMT_PRIV_MAGIC</constant> and all the extended field to
127 applicable values.</para></entry>
131 <entry><structfield>flags</structfield></entry>
132 <entry>Flags set by the application or driver, see <xref
133 linkend="format-flags" />.</entry>
141 <title>Multi-planar format structures</title>
142 <para>The <structname>v4l2_plane_pix_format</structname> structures define
143 size and layout for each of the planes in a multi-planar format.
144 The <structname>v4l2_pix_format_mplane</structname> structure contains
145 information common to all planes (such as image width and height) and
146 an array of <structname>v4l2_plane_pix_format</structname> structures,
147 describing all planes of that format.</para>
148 <table pgwide="1" frame="none" id="v4l2-plane-pix-format">
149 <title>struct <structname>v4l2_plane_pix_format</structname></title>
155 <entry><structfield>sizeimage</structfield></entry>
156 <entry>Maximum size in bytes required for image data in this plane.
161 <entry><structfield>bytesperline</structfield></entry>
162 <entry>Distance in bytes between the leftmost pixels in two adjacent
167 <entry><structfield>reserved[7]</structfield></entry>
168 <entry>Reserved for future extensions. Should be zeroed by the
174 <table pgwide="1" frame="none" id="v4l2-pix-format-mplane">
175 <title>struct <structname>v4l2_pix_format_mplane</structname></title>
181 <entry><structfield>width</structfield></entry>
182 <entry>Image width in pixels.</entry>
186 <entry><structfield>height</structfield></entry>
187 <entry>Image height in pixels.</entry>
191 <entry><structfield>pixelformat</structfield></entry>
192 <entry>The pixel format. Both single- and multi-planar four character
193 codes can be used.</entry>
196 <entry>&v4l2-field;</entry>
197 <entry><structfield>field</structfield></entry>
198 <entry>See &v4l2-pix-format;.</entry>
201 <entry>&v4l2-colorspace;</entry>
202 <entry><structfield>colorspace</structfield></entry>
203 <entry>See &v4l2-pix-format;.</entry>
206 <entry>&v4l2-plane-pix-format;</entry>
207 <entry><structfield>plane_fmt[VIDEO_MAX_PLANES]</structfield></entry>
208 <entry>An array of structures describing format of each plane this
209 pixel format consists of. The number of valid entries in this array
210 has to be put in the <structfield>num_planes</structfield>
215 <entry><structfield>num_planes</structfield></entry>
216 <entry>Number of planes (i.e. separate memory buffers) for this format
217 and the number of valid entries in the
218 <structfield>plane_fmt</structfield> array.</entry>
222 <entry><structfield>flags</structfield></entry>
223 <entry>Flags set by the application or driver, see <xref
224 linkend="format-flags" />.</entry>
228 <entry><structfield>reserved[10]</structfield></entry>
229 <entry>Reserved for future extensions. Should be zeroed by the
238 <title>Standard Image Formats</title>
240 <para>In order to exchange images between drivers and
241 applications, it is necessary to have standard image data formats
242 which both sides will interpret the same way. V4L2 includes several
243 such formats, and this section is intended to be an unambiguous
244 specification of the standard image data formats in V4L2.</para>
246 <para>V4L2 drivers are not limited to these formats, however.
247 Driver-specific formats are possible. In that case the application may
248 depend on a codec to convert images to one of the standard formats
249 when needed. But the data can still be stored and retrieved in the
250 proprietary format. For example, a device may support a proprietary
251 compressed format. Applications can still capture and save the data in
252 the compressed format, saving much disk space, and later use a codec
253 to convert the images to the X Windows screen format when the video is
254 to be displayed.</para>
256 <para>Even so, ultimately, some standard formats are needed, so
257 the V4L2 specification would not be complete without well-defined
258 standard formats.</para>
260 <para>The V4L2 standard formats are mainly uncompressed formats. The
261 pixels are always arranged in memory from left to right, and from top
262 to bottom. The first byte of data in the image buffer is always for
263 the leftmost pixel of the topmost row. Following that is the pixel
264 immediately to its right, and so on until the end of the top row of
265 pixels. Following the rightmost pixel of the row there may be zero or
266 more bytes of padding to guarantee that each row of pixel data has a
267 certain alignment. Following the pad bytes, if any, is data for the
268 leftmost pixel of the second row from the top, and so on. The last row
269 has just as many pad bytes after it as the other rows.</para>
271 <para>In V4L2 each format has an identifier which looks like
272 <constant>PIX_FMT_XXX</constant>, defined in the <link
273 linkend="videodev">videodev.h</link> header file. These identifiers
274 represent <link linkend="v4l2-fourcc">four character (FourCC) codes</link>
275 which are also listed below, however they are not the same as those
276 used in the Windows world.</para>
278 <para>For some formats, data is stored in separate, discontiguous
279 memory buffers. Those formats are identified by a separate set of FourCC codes
280 and are referred to as "multi-planar formats". For example, a YUV422 frame is
281 normally stored in one memory buffer, but it can also be placed in two or three
282 separate buffers, with Y component in one buffer and CbCr components in another
283 in the 2-planar version or with each component in its own buffer in the
284 3-planar case. Those sub-buffers are referred to as "planes".</para>
287 <section id="colorspaces">
288 <title>Colorspaces</title>
292 <!-- See proposal by Billy Biggs, video4linux-list@redhat.com
293 on 11 Oct 2002, subject: "Re: [V4L] Re: v4l2 api", and
294 http://vektor.theorem.ca/graphics/ycbcr/ and
295 http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html -->
300 <term>Gamma Correction</term>
303 <para>E'<subscript>R</subscript> = f(R)</para>
304 <para>E'<subscript>G</subscript> = f(G)</para>
305 <para>E'<subscript>B</subscript> = f(B)</para>
309 <term>Construction of luminance and color-difference
313 <para>E'<subscript>Y</subscript> =
314 Coeff<subscript>R</subscript> E'<subscript>R</subscript>
315 + Coeff<subscript>G</subscript> E'<subscript>G</subscript>
316 + Coeff<subscript>B</subscript> E'<subscript>B</subscript></para>
317 <para>(E'<subscript>R</subscript> - E'<subscript>Y</subscript>) = E'<subscript>R</subscript>
318 - Coeff<subscript>R</subscript> E'<subscript>R</subscript>
319 - Coeff<subscript>G</subscript> E'<subscript>G</subscript>
320 - Coeff<subscript>B</subscript> E'<subscript>B</subscript></para>
321 <para>(E'<subscript>B</subscript> - E'<subscript>Y</subscript>) = E'<subscript>B</subscript>
322 - Coeff<subscript>R</subscript> E'<subscript>R</subscript>
323 - Coeff<subscript>G</subscript> E'<subscript>G</subscript>
324 - Coeff<subscript>B</subscript> E'<subscript>B</subscript></para>
328 <term>Re-normalized color-difference signals</term>
330 <para>The color-difference signals are scaled back to unity
331 range [-0.5;+0.5]:</para>
332 <para>K<subscript>B</subscript> = 0.5 / (1 - Coeff<subscript>B</subscript>)</para>
333 <para>K<subscript>R</subscript> = 0.5 / (1 - Coeff<subscript>R</subscript>)</para>
334 <para>P<subscript>B</subscript> =
335 K<subscript>B</subscript> (E'<subscript>B</subscript> - E'<subscript>Y</subscript>) =
336 0.5 (Coeff<subscript>R</subscript> / Coeff<subscript>B</subscript>) E'<subscript>R</subscript>
337 + 0.5 (Coeff<subscript>G</subscript> / Coeff<subscript>B</subscript>) E'<subscript>G</subscript>
338 + 0.5 E'<subscript>B</subscript></para>
339 <para>P<subscript>R</subscript> =
340 K<subscript>R</subscript> (E'<subscript>R</subscript> - E'<subscript>Y</subscript>) =
341 0.5 E'<subscript>R</subscript>
342 + 0.5 (Coeff<subscript>G</subscript> / Coeff<subscript>R</subscript>) E'<subscript>G</subscript>
343 + 0.5 (Coeff<subscript>B</subscript> / Coeff<subscript>R</subscript>) E'<subscript>B</subscript></para>
347 <term>Quantization</term>
350 <para>Y' = (Lum. Levels - 1) · E'<subscript>Y</subscript> + Lum. Offset</para>
351 <para>C<subscript>B</subscript> = (Chrom. Levels - 1)
352 · P<subscript>B</subscript> + Chrom. Offset</para>
353 <para>C<subscript>R</subscript> = (Chrom. Levels - 1)
354 · P<subscript>R</subscript> + Chrom. Offset</para>
355 <para>Rounding to the nearest integer and clamping to the range
356 [0;255] finally yields the digital color components Y'CbCr
357 stored in YUV images.</para>
364 <title>ITU-R Rec. BT.601 color conversion</title>
366 <para>Forward Transformation</para>
369 int ER, EG, EB; /* gamma corrected RGB input [0;255] */
370 int Y1, Cb, Cr; /* output [0;255] */
372 double r, g, b; /* temporaries */
378 int r = x; /* round to nearest */
380 if (r < 0) return 0;
381 else if (r > 255) return 255;
389 y1 = 0.299 * r + 0.587 * g + 0.114 * b;
390 pb = -0.169 * r - 0.331 * g + 0.5 * b;
391 pr = 0.5 * r - 0.419 * g - 0.081 * b;
393 Y1 = clamp (219 * y1 + 16);
394 Cb = clamp (224 * pb + 128);
395 Cr = clamp (224 * pr + 128);
399 y1 = 0.299 * ER + 0.587 * EG + 0.114 * EB;
401 Y1 = clamp ( (219 / 255.0) * y1 + 16);
402 Cb = clamp (((224 / 255.0) / (2 - 2 * 0.114)) * (EB - y1) + 128);
403 Cr = clamp (((224 / 255.0) / (2 - 2 * 0.299)) * (ER - y1) + 128);
406 <para>Inverse Transformation</para>
409 int Y1, Cb, Cr; /* gamma pre-corrected input [0;255] */
410 int ER, EG, EB; /* output [0;255] */
412 double r, g, b; /* temporaries */
418 int r = x; /* round to nearest */
420 if (r < 0) return 0;
421 else if (r > 255) return 255;
425 y1 = (Y1 - 16) / 219.0;
426 pb = (Cb - 128) / 224.0;
427 pr = (Cr - 128) / 224.0;
429 r = 1.0 * y1 + 0 * pb + 1.402 * pr;
430 g = 1.0 * y1 - 0.344 * pb - 0.714 * pr;
431 b = 1.0 * y1 + 1.772 * pb + 0 * pr;
433 ER = clamp (r * 255); /* [ok? one should prob. limit y1,pb,pr] */
434 EG = clamp (g * 255);
435 EB = clamp (b * 255);
439 <table pgwide="1" id="v4l2-colorspace" orient="land">
440 <title>enum v4l2_colorspace</title>
441 <tgroup cols="11" align="center">
442 <colspec align="left" />
443 <colspec align="center" />
444 <colspec align="left" />
445 <colspec colname="cr" />
446 <colspec colname="cg" />
447 <colspec colname="cb" />
448 <colspec colname="wp" />
449 <colspec colname="gc" />
450 <colspec colname="lum" />
451 <colspec colname="qy" />
452 <colspec colname="qc" />
453 <spanspec namest="cr" nameend="cb" spanname="chrom" />
454 <spanspec namest="qy" nameend="qc" spanname="quant" />
455 <spanspec namest="lum" nameend="qc" spanname="spam" />
458 <entry morerows="1">Identifier</entry>
459 <entry morerows="1">Value</entry>
460 <entry morerows="1">Description</entry>
461 <entry spanname="chrom">Chromaticities<footnote>
462 <para>The coordinates of the color primaries are
463 given in the CIE system (1931)</para>
465 <entry morerows="1">White Point</entry>
466 <entry morerows="1">Gamma Correction</entry>
467 <entry morerows="1">Luminance E'<subscript>Y</subscript></entry>
468 <entry spanname="quant">Quantization</entry>
475 <entry>Cb, Cr</entry>
480 <entry><constant>V4L2_COLORSPACE_SMPTE170M</constant></entry>
482 <entry>NTSC/PAL according to <xref linkend="smpte170m" />,
483 <xref linkend="itu601" /></entry>
484 <entry>x = 0.630, y = 0.340</entry>
485 <entry>x = 0.310, y = 0.595</entry>
486 <entry>x = 0.155, y = 0.070</entry>
487 <entry>x = 0.3127, y = 0.3290,
488 Illuminant D<subscript>65</subscript></entry>
489 <entry>E' = 4.5 I for I ≤0.018,
490 1.099 I<superscript>0.45</superscript> - 0.099 for 0.018 < I</entry>
491 <entry>0.299 E'<subscript>R</subscript>
492 + 0.587 E'<subscript>G</subscript>
493 + 0.114 E'<subscript>B</subscript></entry>
494 <entry>219 E'<subscript>Y</subscript> + 16</entry>
495 <entry>224 P<subscript>B,R</subscript> + 128</entry>
498 <entry><constant>V4L2_COLORSPACE_SMPTE240M</constant></entry>
500 <entry>1125-Line (US) HDTV, see <xref
501 linkend="smpte240m" /></entry>
502 <entry>x = 0.630, y = 0.340</entry>
503 <entry>x = 0.310, y = 0.595</entry>
504 <entry>x = 0.155, y = 0.070</entry>
505 <entry>x = 0.3127, y = 0.3290,
506 Illuminant D<subscript>65</subscript></entry>
507 <entry>E' = 4 I for I ≤0.0228,
508 1.1115 I<superscript>0.45</superscript> - 0.1115 for 0.0228 < I</entry>
509 <entry>0.212 E'<subscript>R</subscript>
510 + 0.701 E'<subscript>G</subscript>
511 + 0.087 E'<subscript>B</subscript></entry>
512 <entry>219 E'<subscript>Y</subscript> + 16</entry>
513 <entry>224 P<subscript>B,R</subscript> + 128</entry>
516 <entry><constant>V4L2_COLORSPACE_REC709</constant></entry>
518 <entry>HDTV and modern devices, see <xref
519 linkend="itu709" /></entry>
520 <entry>x = 0.640, y = 0.330</entry>
521 <entry>x = 0.300, y = 0.600</entry>
522 <entry>x = 0.150, y = 0.060</entry>
523 <entry>x = 0.3127, y = 0.3290,
524 Illuminant D<subscript>65</subscript></entry>
525 <entry>E' = 4.5 I for I ≤0.018,
526 1.099 I<superscript>0.45</superscript> - 0.099 for 0.018 < I</entry>
527 <entry>0.2125 E'<subscript>R</subscript>
528 + 0.7154 E'<subscript>G</subscript>
529 + 0.0721 E'<subscript>B</subscript></entry>
530 <entry>219 E'<subscript>Y</subscript> + 16</entry>
531 <entry>224 P<subscript>B,R</subscript> + 128</entry>
534 <entry><constant>V4L2_COLORSPACE_BT878</constant></entry>
536 <entry>Broken Bt878 extents<footnote>
537 <para>The ubiquitous Bt878 video capture chip
538 quantizes E'<subscript>Y</subscript> to 238 levels, yielding a range
539 of Y' = 16 … 253, unlike Rec. 601 Y' = 16 …
540 235. This is not a typo in the Bt878 documentation, it has been
541 implemented in silicon. The chroma extents are unclear.</para>
542 </footnote>, <xref linkend="itu601" /></entry>
548 <entry>0.299 E'<subscript>R</subscript>
549 + 0.587 E'<subscript>G</subscript>
550 + 0.114 E'<subscript>B</subscript></entry>
551 <entry><emphasis>237</emphasis> E'<subscript>Y</subscript> + 16</entry>
552 <entry>224 P<subscript>B,R</subscript> + 128 (probably)</entry>
555 <entry><constant>V4L2_COLORSPACE_470_SYSTEM_M</constant></entry>
557 <entry>M/NTSC<footnote>
558 <para>No identifier exists for M/PAL which uses
559 the chromaticities of M/NTSC, the remaining parameters are equal to B and
561 </footnote> according to <xref linkend="itu470" />, <xref
562 linkend="itu601" /></entry>
563 <entry>x = 0.67, y = 0.33</entry>
564 <entry>x = 0.21, y = 0.71</entry>
565 <entry>x = 0.14, y = 0.08</entry>
566 <entry>x = 0.310, y = 0.316, Illuminant C</entry>
568 <entry>0.299 E'<subscript>R</subscript>
569 + 0.587 E'<subscript>G</subscript>
570 + 0.114 E'<subscript>B</subscript></entry>
571 <entry>219 E'<subscript>Y</subscript> + 16</entry>
572 <entry>224 P<subscript>B,R</subscript> + 128</entry>
575 <entry><constant>V4L2_COLORSPACE_470_SYSTEM_BG</constant></entry>
577 <entry>625-line PAL and SECAM systems according to <xref
578 linkend="itu470" />, <xref linkend="itu601" /></entry>
579 <entry>x = 0.64, y = 0.33</entry>
580 <entry>x = 0.29, y = 0.60</entry>
581 <entry>x = 0.15, y = 0.06</entry>
582 <entry>x = 0.313, y = 0.329,
583 Illuminant D<subscript>65</subscript></entry>
585 <entry>0.299 E'<subscript>R</subscript>
586 + 0.587 E'<subscript>G</subscript>
587 + 0.114 E'<subscript>B</subscript></entry>
588 <entry>219 E'<subscript>Y</subscript> + 16</entry>
589 <entry>224 P<subscript>B,R</subscript> + 128</entry>
592 <entry><constant>V4L2_COLORSPACE_JPEG</constant></entry>
594 <entry>JPEG Y'CbCr, see <xref linkend="jfif" />, <xref linkend="itu601" /></entry>
600 <entry>0.299 E'<subscript>R</subscript>
601 + 0.587 E'<subscript>G</subscript>
602 + 0.114 E'<subscript>B</subscript></entry>
603 <entry>256 E'<subscript>Y</subscript> + 16<footnote>
604 <para>Note JFIF quantizes
605 Y'P<subscript>B</subscript>P<subscript>R</subscript> in range [0;+1] and
606 [-0.5;+0.5] to <emphasis>257</emphasis> levels, however Y'CbCr signals
607 are still clamped to [0;255].</para>
609 <entry>256 P<subscript>B,R</subscript> + 128</entry>
612 <entry><constant>V4L2_COLORSPACE_SRGB</constant></entry>
615 <entry>x = 0.640, y = 0.330</entry>
616 <entry>x = 0.300, y = 0.600</entry>
617 <entry>x = 0.150, y = 0.060</entry>
618 <entry>x = 0.3127, y = 0.3290,
619 Illuminant D<subscript>65</subscript></entry>
620 <entry>E' = 4.5 I for I ≤0.018,
621 1.099 I<superscript>0.45</superscript> - 0.099 for 0.018 < I</entry>
622 <entry spanname="spam">n/a</entry>
629 <section id="pixfmt-indexed">
630 <title>Indexed Format</title>
632 <para>In this format each pixel is represented by an 8 bit index
633 into a 256 entry ARGB palette. It is intended for <link
634 linkend="osd">Video Output Overlays</link> only. There are no ioctls to
635 access the palette, this must be done with ioctls of the Linux framebuffer API.</para>
637 <table pgwide="0" frame="none">
638 <title>Indexed Image Format</title>
639 <tgroup cols="37" align="center">
640 <colspec colname="id" align="left" />
641 <colspec colname="fourcc" />
642 <colspec colname="bit" />
644 <colspec colnum="4" colname="b07" align="center" />
645 <colspec colnum="5" colname="b06" align="center" />
646 <colspec colnum="6" colname="b05" align="center" />
647 <colspec colnum="7" colname="b04" align="center" />
648 <colspec colnum="8" colname="b03" align="center" />
649 <colspec colnum="9" colname="b02" align="center" />
650 <colspec colnum="10" colname="b01" align="center" />
651 <colspec colnum="11" colname="b00" align="center" />
653 <spanspec namest="b07" nameend="b00" spanname="b0" />
654 <spanspec namest="b17" nameend="b10" spanname="b1" />
655 <spanspec namest="b27" nameend="b20" spanname="b2" />
656 <spanspec namest="b37" nameend="b30" spanname="b3" />
659 <entry>Identifier</entry>
661 <entry> </entry>
662 <entry spanname="b0">Byte 0</entry>
665 <entry> </entry>
666 <entry> </entry>
679 <row id="V4L2-PIX-FMT-PAL8">
680 <entry><constant>V4L2_PIX_FMT_PAL8</constant></entry>
681 <entry>'PAL8'</entry>
683 <entry>i<subscript>7</subscript></entry>
684 <entry>i<subscript>6</subscript></entry>
685 <entry>i<subscript>5</subscript></entry>
686 <entry>i<subscript>4</subscript></entry>
687 <entry>i<subscript>3</subscript></entry>
688 <entry>i<subscript>2</subscript></entry>
689 <entry>i<subscript>1</subscript></entry>
690 <entry>i<subscript>0</subscript></entry>
697 <section id="pixfmt-rgb">
698 <title>RGB Formats</title>
712 <section id="yuv-formats">
713 <title>YUV Formats</title>
715 <para>YUV is the format native to TV broadcast and composite video
716 signals. It separates the brightness information (Y) from the color
717 information (U and V or Cb and Cr). The color information consists of
718 red and blue <emphasis>color difference</emphasis> signals, this way
719 the green component can be reconstructed by subtracting from the
720 brightness component. See <xref linkend="colorspaces" /> for conversion
721 examples. YUV was chosen because early television would only transmit
722 brightness information. To add color in a way compatible with existing
723 receivers a new signal carrier was added to transmit the color
724 difference signals. Secondary in the YUV format the U and V components
725 usually have lower resolution than the Y component. This is an analog
726 video compression technique taking advantage of a property of the
727 human visual system, being more sensitive to brightness
758 <title>Compressed Formats</title>
760 <table pgwide="1" frame="none" id="compressed-formats">
761 <title>Compressed Image Formats</title>
762 <tgroup cols="3" align="left">
766 <entry>Identifier</entry>
768 <entry>Details</entry>
772 <row id="V4L2-PIX-FMT-JPEG">
773 <entry><constant>V4L2_PIX_FMT_JPEG</constant></entry>
774 <entry>'JPEG'</entry>
775 <entry>TBD. See also &VIDIOC-G-JPEGCOMP;,
776 &VIDIOC-S-JPEGCOMP;.</entry>
778 <row id="V4L2-PIX-FMT-MPEG">
779 <entry><constant>V4L2_PIX_FMT_MPEG</constant></entry>
780 <entry>'MPEG'</entry>
781 <entry>MPEG multiplexed stream. The actual format is determined by
782 extended control <constant>V4L2_CID_MPEG_STREAM_TYPE</constant>, see
783 <xref linkend="mpeg-control-id" />.</entry>
785 <row id="V4L2-PIX-FMT-H264">
786 <entry><constant>V4L2_PIX_FMT_H264</constant></entry>
787 <entry>'H264'</entry>
788 <entry>H264 video elementary stream with start codes.</entry>
790 <row id="V4L2-PIX-FMT-H264-NO-SC">
791 <entry><constant>V4L2_PIX_FMT_H264_NO_SC</constant></entry>
792 <entry>'AVC1'</entry>
793 <entry>H264 video elementary stream without start codes.</entry>
795 <row id="V4L2-PIX-FMT-H264-MVC">
796 <entry><constant>V4L2_PIX_FMT_H264_MVC</constant></entry>
798 <entry>H264 MVC video elementary stream.</entry>
800 <row id="V4L2-PIX-FMT-H263">
801 <entry><constant>V4L2_PIX_FMT_H263</constant></entry>
802 <entry>'H263'</entry>
803 <entry>H263 video elementary stream.</entry>
805 <row id="V4L2-PIX-FMT-MPEG1">
806 <entry><constant>V4L2_PIX_FMT_MPEG1</constant></entry>
807 <entry>'MPG1'</entry>
808 <entry>MPEG1 video elementary stream.</entry>
810 <row id="V4L2-PIX-FMT-MPEG2">
811 <entry><constant>V4L2_PIX_FMT_MPEG2</constant></entry>
812 <entry>'MPG2'</entry>
813 <entry>MPEG2 video elementary stream.</entry>
815 <row id="V4L2-PIX-FMT-MPEG4">
816 <entry><constant>V4L2_PIX_FMT_MPEG4</constant></entry>
817 <entry>'MPG4'</entry>
818 <entry>MPEG4 video elementary stream.</entry>
820 <row id="V4L2-PIX-FMT-XVID">
821 <entry><constant>V4L2_PIX_FMT_XVID</constant></entry>
822 <entry>'XVID'</entry>
823 <entry>Xvid video elementary stream.</entry>
825 <row id="V4L2-PIX-FMT-VC1-ANNEX-G">
826 <entry><constant>V4L2_PIX_FMT_VC1_ANNEX_G</constant></entry>
827 <entry>'VC1G'</entry>
828 <entry>VC1, SMPTE 421M Annex G compliant stream.</entry>
830 <row id="V4L2-PIX-FMT-VC1-ANNEX-L">
831 <entry><constant>V4L2_PIX_FMT_VC1_ANNEX_L</constant></entry>
832 <entry>'VC1L'</entry>
833 <entry>VC1, SMPTE 421M Annex L compliant stream.</entry>
835 <row id="V4L2-PIX-FMT-VP8">
836 <entry><constant>V4L2_PIX_FMT_VP8</constant></entry>
838 <entry>VP8 video elementary stream.</entry>
845 <section id="pixfmt-reserved">
846 <title>Reserved Format Identifiers</title>
848 <para>These formats are not defined by this specification, they
849 are just listed for reference and to avoid naming conflicts. If you
850 want to register your own format, send an e-mail to the linux-media mailing
851 list &v4l-ml; for inclusion in the <filename>videodev2.h</filename>
852 file. If you want to share your format with other developers add a
853 link to your documentation and send a copy to the linux-media mailing list
854 for inclusion in this section. If you think your format should be listed
855 in a standard format section please make a proposal on the linux-media mailing
858 <table pgwide="1" frame="none" id="reserved-formats">
859 <title>Reserved Image Formats</title>
860 <tgroup cols="3" align="left">
864 <entry>Identifier</entry>
866 <entry>Details</entry>
870 <row id="V4L2-PIX-FMT-DV">
871 <entry><constant>V4L2_PIX_FMT_DV</constant></entry>
872 <entry>'dvsd'</entry>
873 <entry>unknown</entry>
875 <row id="V4L2-PIX-FMT-ET61X251">
876 <entry><constant>V4L2_PIX_FMT_ET61X251</constant></entry>
877 <entry>'E625'</entry>
878 <entry>Compressed format of the ET61X251 driver.</entry>
880 <row id="V4L2-PIX-FMT-HI240">
881 <entry><constant>V4L2_PIX_FMT_HI240</constant></entry>
882 <entry>'HI24'</entry>
883 <entry><para>8 bit RGB format used by the BTTV driver.</para></entry>
885 <row id="V4L2-PIX-FMT-HM12">
886 <entry><constant>V4L2_PIX_FMT_HM12</constant></entry>
887 <entry>'HM12'</entry>
888 <entry><para>YUV 4:2:0 format used by the
889 IVTV driver, <ulink url="http://www.ivtvdriver.org/">
890 http://www.ivtvdriver.org/</ulink></para><para>The format is documented in the
891 kernel sources in the file <filename>Documentation/video4linux/cx2341x/README.hm12</filename>
894 <row id="V4L2-PIX-FMT-CPIA1">
895 <entry><constant>V4L2_PIX_FMT_CPIA1</constant></entry>
896 <entry>'CPIA'</entry>
897 <entry>YUV format used by the gspca cpia1 driver.</entry>
899 <row id="V4L2-PIX-FMT-JPGL">
900 <entry><constant>V4L2_PIX_FMT_JPGL</constant></entry>
901 <entry>'JPGL'</entry>
902 <entry>JPEG-Light format (Pegasus Lossless JPEG)
903 used in Divio webcams NW 80x.</entry>
905 <row id="V4L2-PIX-FMT-SPCA501">
906 <entry><constant>V4L2_PIX_FMT_SPCA501</constant></entry>
907 <entry>'S501'</entry>
908 <entry>YUYV per line used by the gspca driver.</entry>
910 <row id="V4L2-PIX-FMT-SPCA505">
911 <entry><constant>V4L2_PIX_FMT_SPCA505</constant></entry>
912 <entry>'S505'</entry>
913 <entry>YYUV per line used by the gspca driver.</entry>
915 <row id="V4L2-PIX-FMT-SPCA508">
916 <entry><constant>V4L2_PIX_FMT_SPCA508</constant></entry>
917 <entry>'S508'</entry>
918 <entry>YUVY per line used by the gspca driver.</entry>
920 <row id="V4L2-PIX-FMT-SPCA561">
921 <entry><constant>V4L2_PIX_FMT_SPCA561</constant></entry>
922 <entry>'S561'</entry>
923 <entry>Compressed GBRG Bayer format used by the gspca driver.</entry>
925 <row id="V4L2-PIX-FMT-PAC207">
926 <entry><constant>V4L2_PIX_FMT_PAC207</constant></entry>
927 <entry>'P207'</entry>
928 <entry>Compressed BGGR Bayer format used by the gspca driver.</entry>
930 <row id="V4L2-PIX-FMT-MR97310A">
931 <entry><constant>V4L2_PIX_FMT_MR97310A</constant></entry>
932 <entry>'M310'</entry>
933 <entry>Compressed BGGR Bayer format used by the gspca driver.</entry>
935 <row id="V4L2-PIX-FMT-JL2005BCD">
936 <entry><constant>V4L2_PIX_FMT_JL2005BCD</constant></entry>
937 <entry>'JL20'</entry>
938 <entry>JPEG compressed RGGB Bayer format used by the gspca driver.</entry>
940 <row id="V4L2-PIX-FMT-OV511">
941 <entry><constant>V4L2_PIX_FMT_OV511</constant></entry>
942 <entry>'O511'</entry>
943 <entry>OV511 JPEG format used by the gspca driver.</entry>
945 <row id="V4L2-PIX-FMT-OV518">
946 <entry><constant>V4L2_PIX_FMT_OV518</constant></entry>
947 <entry>'O518'</entry>
948 <entry>OV518 JPEG format used by the gspca driver.</entry>
950 <row id="V4L2-PIX-FMT-PJPG">
951 <entry><constant>V4L2_PIX_FMT_PJPG</constant></entry>
952 <entry>'PJPG'</entry>
953 <entry>Pixart 73xx JPEG format used by the gspca driver.</entry>
955 <row id="V4L2-PIX-FMT-SE401">
956 <entry><constant>V4L2_PIX_FMT_SE401</constant></entry>
957 <entry>'S401'</entry>
958 <entry>Compressed RGB format used by the gspca se401 driver</entry>
960 <row id="V4L2-PIX-FMT-SQ905C">
961 <entry><constant>V4L2_PIX_FMT_SQ905C</constant></entry>
962 <entry>'905C'</entry>
963 <entry>Compressed RGGB bayer format used by the gspca driver.</entry>
965 <row id="V4L2-PIX-FMT-MJPEG">
966 <entry><constant>V4L2_PIX_FMT_MJPEG</constant></entry>
967 <entry>'MJPG'</entry>
968 <entry>Compressed format used by the Zoran driver</entry>
970 <row id="V4L2-PIX-FMT-PWC1">
971 <entry><constant>V4L2_PIX_FMT_PWC1</constant></entry>
972 <entry>'PWC1'</entry>
973 <entry>Compressed format of the PWC driver.</entry>
975 <row id="V4L2-PIX-FMT-PWC2">
976 <entry><constant>V4L2_PIX_FMT_PWC2</constant></entry>
977 <entry>'PWC2'</entry>
978 <entry>Compressed format of the PWC driver.</entry>
980 <row id="V4L2-PIX-FMT-SN9C10X">
981 <entry><constant>V4L2_PIX_FMT_SN9C10X</constant></entry>
982 <entry>'S910'</entry>
983 <entry>Compressed format of the SN9C102 driver.</entry>
985 <row id="V4L2-PIX-FMT-SN9C20X-I420">
986 <entry><constant>V4L2_PIX_FMT_SN9C20X_I420</constant></entry>
987 <entry>'S920'</entry>
988 <entry>YUV 4:2:0 format of the gspca sn9c20x driver.</entry>
990 <row id="V4L2-PIX-FMT-SN9C2028">
991 <entry><constant>V4L2_PIX_FMT_SN9C2028</constant></entry>
992 <entry>'SONX'</entry>
993 <entry>Compressed GBRG bayer format of the gspca sn9c2028 driver.</entry>
995 <row id="V4L2-PIX-FMT-STV0680">
996 <entry><constant>V4L2_PIX_FMT_STV0680</constant></entry>
997 <entry>'S680'</entry>
998 <entry>Bayer format of the gspca stv0680 driver.</entry>
1000 <row id="V4L2-PIX-FMT-WNVA">
1001 <entry><constant>V4L2_PIX_FMT_WNVA</constant></entry>
1002 <entry>'WNVA'</entry>
1003 <entry><para>Used by the Winnov Videum driver, <ulink
1004 url="http://www.thedirks.org/winnov/">
1005 http://www.thedirks.org/winnov/</ulink></para></entry>
1007 <row id="V4L2-PIX-FMT-TM6000">
1008 <entry><constant>V4L2_PIX_FMT_TM6000</constant></entry>
1009 <entry>'TM60'</entry>
1010 <entry><para>Used by Trident tm6000</para></entry>
1012 <row id="V4L2-PIX-FMT-CIT-YYVYUY">
1013 <entry><constant>V4L2_PIX_FMT_CIT_YYVYUY</constant></entry>
1014 <entry>'CITV'</entry>
1015 <entry><para>Used by xirlink CIT, found at IBM webcams.</para>
1016 <para>Uses one line of Y then 1 line of VYUY</para>
1019 <row id="V4L2-PIX-FMT-KONICA420">
1020 <entry><constant>V4L2_PIX_FMT_KONICA420</constant></entry>
1021 <entry>'KONI'</entry>
1022 <entry><para>Used by Konica webcams.</para>
1023 <para>YUV420 planar in blocks of 256 pixels.</para>
1026 <row id="V4L2-PIX-FMT-YYUV">
1027 <entry><constant>V4L2_PIX_FMT_YYUV</constant></entry>
1028 <entry>'YYUV'</entry>
1029 <entry>unknown</entry>
1031 <row id="V4L2-PIX-FMT-Y4">
1032 <entry><constant>V4L2_PIX_FMT_Y4</constant></entry>
1033 <entry>'Y04 '</entry>
1034 <entry>Old 4-bit greyscale format. Only the most significant 4 bits of each byte are used,
1035 the other bits are set to 0.</entry>
1037 <row id="V4L2-PIX-FMT-Y6">
1038 <entry><constant>V4L2_PIX_FMT_Y6</constant></entry>
1039 <entry>'Y06 '</entry>
1040 <entry>Old 6-bit greyscale format. Only the most significant 6 bits of each byte are used,
1041 the other bits are set to 0.</entry>
1043 <row id="V4L2-PIX-FMT-S5C-UYVY-JPG">
1044 <entry><constant>V4L2_PIX_FMT_S5C_UYVY_JPG</constant></entry>
1045 <entry>'S5CI'</entry>
1046 <entry>Two-planar format used by Samsung S5C73MX cameras. The
1047 first plane contains interleaved JPEG and UYVY image data, followed by meta data
1048 in form of an array of offsets to the UYVY data blocks. The actual pointer array
1049 follows immediately the interleaved JPEG/UYVY data, the number of entries in
1050 this array equals the height of the UYVY image. Each entry is a 4-byte unsigned
1051 integer in big endian order and it's an offset to a single pixel line of the
1052 UYVY image. The first plane can start either with JPEG or UYVY data chunk. The
1053 size of a single UYVY block equals the UYVY image's width multiplied by 2. The
1054 size of a JPEG chunk depends on the image and can vary with each line.
1055 <para>The second plane, at an offset of 4084 bytes, contains a 4-byte offset to
1056 the pointer array in the first plane. This offset is followed by a 4-byte value
1057 indicating size of the pointer array. All numbers in the second plane are also
1058 in big endian order. Remaining data in the second plane is undefined. The
1059 information in the second plane allows to easily find location of the pointer
1060 array, which can be different for each frame. The size of the pointer array is
1061 constant for given UYVY image height.</para>
1062 <para>In order to extract UYVY and JPEG frames an application can initially set
1063 a data pointer to the start of first plane and then add an offset from the first
1064 entry of the pointers table. Such a pointer indicates start of an UYVY image
1065 pixel line. Whole UYVY line can be copied to a separate buffer. These steps
1066 should be repeated for each line, i.e. the number of entries in the pointer
1067 array. Anything what's in between the UYVY lines is JPEG data and should be
1068 concatenated to form the JPEG stream. </para>
1075 <table frame="none" pgwide="1" id="format-flags">
1076 <title>Format Flags</title>
1079 <tbody valign="top">
1081 <entry><constant>V4L2_PIX_FMT_FLAG_PREMUL_ALPHA</constant></entry>
1082 <entry>0x00000001</entry>
1083 <entry>The pixel values are premultiplied by the alpha channel value.</entry>