Sophie

Sophie

distrib > CentOS > 6 > i386 > by-pkgid > cf93d8a8acdcc6fe2225039da0502495 > files > 2636

kernel-doc-2.6.32-131.17.1.el6.centos.plus.noarch.rpm

<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>Chapter&#160;2.&#160;Image Formats</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API" /><link rel="up" href="pt01.html" title="Part&#160;I.&#160;Video for Linux Two API Specification" /><link rel="prev" href="ch01s12.html" title="Streaming Parameters" /><link rel="next" href="ch02s02.html" title="Colorspaces" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&#160;2.&#160;Image Formats</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01s12.html">Prev</a>&#160;</td><th width="60%" align="center">Part&#160;I.&#160;Video for Linux Two API Specification</th><td width="20%" align="right">&#160;<a accesskey="n" href="ch02s02.html">Next</a></td></tr></table><hr /></div><div class="chapter" title="Chapter&#160;2.&#160;Image Formats"><div class="titlepage"><div><div><h2 class="title"><a id="pixfmt"></a>Chapter&#160;2.&#160;Image Formats</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="ch02.html#id2791648">Standard Image Formats</a></span></dt><dt><span class="section"><a href="ch02s02.html">Colorspaces</a></span></dt><dt><span class="section"><a href="ch02s03.html">Indexed Format</a></span></dt><dt><span class="section"><a href="ch02s04.html">RGB Formats</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="re01.html">Packed RGB formats</a></span><span class="refpurpose"> &#8212; Packed RGB formats</span></dt><dt><span class="refentrytitle"><a href="re02.html">V4L2_PIX_FMT_SBGGR8 ('BA81')</a></span><span class="refpurpose"> &#8212; Bayer RGB format</span></dt><dt><span class="refentrytitle"><a href="re03.html">V4L2_PIX_FMT_SGBRG8 ('GBRG')</a></span><span class="refpurpose"> &#8212; Bayer RGB format</span></dt><dt><span class="refentrytitle"><a href="re04.html">V4L2_PIX_FMT_SGRBG8 ('GRBG')</a></span><span class="refpurpose"> &#8212; Bayer RGB format</span></dt><dt><span class="refentrytitle"><a href="re05.html">V4L2_PIX_FMT_SBGGR16 ('BYR2')</a></span><span class="refpurpose"> &#8212; Bayer RGB format</span></dt></dl></dd><dt><span class="section"><a href="ch02s05.html">YUV Formats</a></span></dt><dd><dl><dt><span class="refentrytitle"><a href="re06.html">Packed YUV formats</a></span><span class="refpurpose"> &#8212; Packed YUV formats</span></dt><dt><span class="refentrytitle"><a href="re07.html">V4L2_PIX_FMT_GREY ('GREY')</a></span><span class="refpurpose"> &#8212; Grey-scale image</span></dt><dt><span class="refentrytitle"><a href="re08.html">V4L2_PIX_FMT_Y16 ('Y16 ')</a></span><span class="refpurpose"> &#8212; Grey-scale image</span></dt><dt><span class="refentrytitle"><a href="re09.html">V4L2_PIX_FMT_YUYV ('YUYV')</a></span><span class="refpurpose"> &#8212; Packed format with &#189; horizontal chroma
resolution, also known as YUV 4:2:2</span></dt><dt><span class="refentrytitle"><a href="re10.html">V4L2_PIX_FMT_UYVY ('UYVY')</a></span><span class="refpurpose"> &#8212; Variation of
<code class="constant">V4L2_PIX_FMT_YUYV</code> with different order of samples
in memory</span></dt><dt><span class="refentrytitle"><a href="re11.html">V4L2_PIX_FMT_YVYU ('YVYU')</a></span><span class="refpurpose"> &#8212; Variation of
<code class="constant">V4L2_PIX_FMT_YUYV</code> with different order of samples
in memory</span></dt><dt><span class="refentrytitle"><a href="re12.html">V4L2_PIX_FMT_VYUY ('VYUY')</a></span><span class="refpurpose"> &#8212; Variation of
<code class="constant">V4L2_PIX_FMT_YUYV</code> with different order of samples
in memory</span></dt><dt><span class="refentrytitle"><a href="re13.html">V4L2_PIX_FMT_Y41P ('Y41P')</a></span><span class="refpurpose"> &#8212; Format with &#188; horizontal chroma
resolution, also known as YUV 4:1:1</span></dt><dt><span class="refentrytitle"><a href="re14.html">V4L2_PIX_FMT_YVU420 ('YV12'), V4L2_PIX_FMT_YUV420 ('YU12')</a></span><span class="refpurpose"> &#8212; Planar formats with &#189; horizontal and
vertical chroma resolution, also known as YUV 4:2:0</span></dt><dt><span class="refentrytitle"><a href="re15.html">V4L2_PIX_FMT_YVU410 ('YVU9'), V4L2_PIX_FMT_YUV410 ('YUV9')</a></span><span class="refpurpose"> &#8212; Planar formats with &#188; horizontal and
vertical chroma resolution, also known as YUV 4:1:0</span></dt><dt><span class="refentrytitle"><a href="re16.html">V4L2_PIX_FMT_YUV422P ('422P')</a></span><span class="refpurpose"> &#8212; Format with &#189; horizontal chroma resolution,
also known as YUV 4:2:2. Planar layout as opposed to
<code class="constant">V4L2_PIX_FMT_YUYV</code></span></dt><dt><span class="refentrytitle"><a href="re17.html">V4L2_PIX_FMT_YUV411P ('411P')</a></span><span class="refpurpose"> &#8212; Format with &#188; horizontal chroma resolution,
also known as YUV 4:1:1. Planar layout as opposed to
<code class="constant">V4L2_PIX_FMT_Y41P</code></span></dt><dt><span class="refentrytitle"><a href="re18.html">V4L2_PIX_FMT_NV12 ('NV12'), V4L2_PIX_FMT_NV21 ('NV21')</a></span><span class="refpurpose"> &#8212; Formats with &#189; horizontal and vertical
chroma resolution, also known as YUV 4:2:0. One luminance and one
chrominance plane with alternating chroma samples as opposed to
<code class="constant">V4L2_PIX_FMT_YVU420</code></span></dt><dt><span class="refentrytitle"><a href="re19.html">V4L2_PIX_FMT_NV16 ('NV16'), V4L2_PIX_FMT_NV61 ('NV61')</a></span><span class="refpurpose"> &#8212; Formats with &#189; horizontal
chroma resolution, also known as YUV 4:2:2. One luminance and one
chrominance plane with alternating chroma samples as opposed to
<code class="constant">V4L2_PIX_FMT_YVU420</code></span></dt></dl></dd><dt><span class="section"><a href="ch02s06.html">Compressed Formats</a></span></dt><dt><span class="section"><a href="ch02s07.html">Reserved Format Identifiers</a></span></dt></dl></div><p>The V4L2 API was primarily designed for devices exchanging
image data with applications. The
<span class="structname">v4l2_pix_format</span> structure defines the format
and layout of an image in memory. Image formats are negotiated with
the <a class="link" href="re41.html" title="ioctl VIDIOC_G_FMT, VIDIOC_S_FMT, VIDIOC_TRY_FMT"><code class="constant">VIDIOC_S_FMT</code></a> ioctl. (The explanations here focus on video
capturing and output, for overlay frame buffer formats see also
<a class="link" href="re40.html" title="ioctl VIDIOC_G_FBUF, VIDIOC_S_FBUF"><code class="constant">VIDIOC_G_FBUF</code></a>.)</p><div class="table"><a id="v4l2-pix-format"></a><p class="title"><b>Table&#160;2.1.&#160;struct <span class="structname">v4l2_pix_format</span></b></p><div class="table-contents"><table summary="struct v4l2_pix_format" width="100%" border="0"><colgroup><col /><col /><col /></colgroup><tbody valign="top"><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>width</code></em></td><td valign="top">Image width in pixels.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>height</code></em></td><td valign="top">Image height in pixels.</td></tr><tr><td colspan="3" valign="top">Applications set these fields to
request an image size, drivers return the closest possible values. In
case of planar formats the <em class="structfield"><code>width</code></em> and
<em class="structfield"><code>height</code></em> applies to the largest plane. To
avoid ambiguities drivers must return values rounded up to a multiple
of the scale factor of any smaller planes. For example when the image
format is YUV 4:2:0, <em class="structfield"><code>width</code></em> and
<em class="structfield"><code>height</code></em> must be multiples of two.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>pixelformat</code></em></td><td valign="top">The pixel format or type of compression, set by the
application. This is a little endian <a class="link" href="re28.html#v4l2-fourcc">four character code</a>. V4L2 defines
standard RGB formats in <a class="xref" href="re01.html#rgb-formats" title="Table&#160;2.4.&#160;Packed RGB Image Formats">Table&#160;2.4, &#8220;Packed RGB Image Formats&#8221;</a>, YUV formats in <a class="xref" href="ch02s05.html" title="YUV Formats">the section called &#8220;YUV Formats&#8221;</a>, and reserved codes in <a class="xref" href="ch02s07.html#reserved-formats" title="Table&#160;2.8.&#160;Reserved Image Formats">Table&#160;2.8, &#8220;Reserved Image Formats&#8221;</a></td></tr><tr><td valign="top">enum&#160;<a class="link" href="ch03s06.html#v4l2-field" title="Table&#160;3.8.&#160;enum v4l2_field">v4l2_field</a></td><td valign="top"><em class="structfield"><code>field</code></em></td><td valign="top">Video images are typically interlaced. Applications
can request to capture or output only the top or bottom field, or both
fields interlaced or sequentially stored in one buffer or alternating
in separate buffers. Drivers return the actual field order selected.
For details see <a class="xref" href="ch03s06.html" title="Field Order">the section called &#8220;Field Order&#8221;</a>.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>bytesperline</code></em></td><td valign="top">Distance in bytes between the leftmost pixels in two
adjacent lines.</td></tr><tr><td colspan="3" valign="top"><p>Both applications and drivers
can set this field to request padding bytes at the end of each line.
Drivers however may ignore the value requested by the application,
returning <em class="structfield"><code>width</code></em> times bytes per pixel or a
larger value required by the hardware. That implies applications can
just set this field to zero to get a reasonable
default.</p><p>Video hardware may access padding bytes,
therefore they must reside in accessible memory. Consider cases where
padding bytes after the last line of an image cross a system page
boundary. Input devices may write padding bytes, the value is
undefined. Output devices ignore the contents of padding
bytes.</p><p>When the image format is planar the
<em class="structfield"><code>bytesperline</code></em> value applies to the largest
plane and is divided by the same factor as the
<em class="structfield"><code>width</code></em> field for any smaller planes. For
example the Cb and Cr planes of a YUV 4:2:0 image have half as many
padding bytes following each line as the Y plane. To avoid ambiguities
drivers must return a <em class="structfield"><code>bytesperline</code></em> value
rounded up to a multiple of the scale factor.</p></td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>sizeimage</code></em></td><td valign="top">Size in bytes of the buffer to hold a complete image,
set by the driver. Usually this is
<em class="structfield"><code>bytesperline</code></em> times
<em class="structfield"><code>height</code></em>. When the image consists of variable
length compressed data this is the maximum number of bytes required to
hold an image.</td></tr><tr><td valign="top">enum&#160;<a class="link" href="ch02s02.html#v4l2-colorspace" title="Table&#160;2.2.&#160;enum v4l2_colorspace">v4l2_colorspace</a></td><td valign="top"><em class="structfield"><code>colorspace</code></em></td><td valign="top">This information supplements the
<em class="structfield"><code>pixelformat</code></em> and must be set by the driver,
see <a class="xref" href="ch02s02.html" title="Colorspaces">the section called &#8220;Colorspaces&#8221;</a>.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>priv</code></em></td><td valign="top">Reserved for custom (driver defined) additional
information about formats. When not used drivers and applications must
set this field to zero.</td></tr></tbody></table></div></div><br class="table-break" /><div class="section" title="Standard Image Formats"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="id2791648"></a>Standard Image Formats</h2></div></div></div><p>In order to exchange images between drivers and
applications, it is necessary to have standard image data formats
which both sides will interpret the same way. V4L2 includes several
such formats, and this section is intended to be an unambiguous
specification of the standard image data formats in V4L2.</p><p>V4L2 drivers are not limited to these formats, however.
Driver-specific formats are possible. In that case the application may
depend on a codec to convert images to one of the standard formats
when needed. But the data can still be stored and retrieved in the
proprietary format. For example, a device may support a proprietary
compressed format. Applications can still capture and save the data in
the compressed format, saving much disk space, and later use a codec
to convert the images to the X Windows screen format when the video is
to be displayed.</p><p>Even so, ultimately, some standard formats are needed, so
the V4L2 specification would not be complete without well-defined
standard formats.</p><p>The V4L2 standard formats are mainly uncompressed formats. The
pixels are always arranged in memory from left to right, and from top
to bottom. The first byte of data in the image buffer is always for
the leftmost pixel of the topmost row. Following that is the pixel
immediately to its right, and so on until the end of the top row of
pixels. Following the rightmost pixel of the row there may be zero or
more bytes of padding to guarantee that each row of pixel data has a
certain alignment. Following the pad bytes, if any, is data for the
leftmost pixel of the second row from the top, and so on. The last row
has just as many pad bytes after it as the other rows.</p><p>In V4L2 each format has an identifier which looks like
<code class="constant">PIX_FMT_XXX</code>, defined in the <a class="link" href="apb.html" title="Appendix&#160;B.&#160;Video For Linux Two Header File">videodev.h</a> header file. These identifiers
represent <a class="link" href="re28.html#v4l2-fourcc">four character codes</a>
which are also listed below, however they are not the same as those
used in the Windows world.</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01s12.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="pt01.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="ch02s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Streaming Parameters&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Colorspaces</td></tr></table></div></body></html>