1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Field Order</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API"><link rel="up" href="io.html" title="Chapter 3. Input/Output"><link rel="prev" href="buffer.html" title="Buffers"><link rel="next" href="devices.html" title="Chapter 4. Interfaces"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Field Order</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="buffer.html">Prev</a> </td><th width="60%" align="center">Chapter 3. Input/Output</th><td width="20%" align="right"> <a accesskey="n" href="devices.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="field-order"></a>Field Order</h2></div></div></div><p>We have to distinguish between progressive and interlaced 2video. Progressive video transmits all lines of a video image 3sequentially. Interlaced video divides an image into two fields, 4containing only the odd and even lines of the image, respectively. 5Alternating the so called odd and even field are transmitted, and due 6to a small delay between fields a cathode ray TV displays the lines 7interleaved, yielding the original frame. This curious technique was 8invented because at refresh rates similar to film the image would 9fade out too quickly. Transmitting fields reduces the flicker without 10the necessity of doubling the frame rate and with it the bandwidth 11required for each channel.</p><p>It is important to understand a video camera does not expose 12one frame at a time, merely transmitting the frames separated into 13fields. The fields are in fact captured at two different instances in 14time. An object on screen may well move between one field and the 15next. For applications analysing motion it is of paramount importance 16to recognize which field of a frame is older, the <span class="emphasis"><em>temporal 17order</em></span>.</p><p>When the driver provides or accepts images field by field 18rather than interleaved, it is also important applications understand 19how the fields combine to frames. We distinguish between top (aka odd) and 20bottom (aka even) fields, the <span class="emphasis"><em>spatial order</em></span>: The first line 21of the top field is the first line of an interlaced frame, the first 22line of the bottom field is the second line of that frame.</p><p>However because fields were captured one after the other, 23arguing whether a frame commences with the top or bottom field is 24pointless. Any two successive top and bottom, or bottom and top fields 25yield a valid frame. Only when the source was progressive to begin 26with, e. g. when transferring film to video, two fields may come from 27the same frame, creating a natural order.</p><p>Counter to intuition the top field is not necessarily the 28older field. Whether the older field contains the top or bottom lines 29is a convention determined by the video standard. Hence the 30distinction between temporal and spatial order of fields. The diagrams 31below should make this clearer.</p><p>All video capture and output devices must report the current 32field order. Some drivers may permit the selection of a different 33order, to this end applications initialize the 34<em class="structfield"><code>field</code></em> field of struct <a class="link" href="pixfmt.html#v4l2-pix-format" title="Table 2.1. struct v4l2_pix_format">v4l2_pix_format</a> before 35calling the <a class="link" href="vidioc-g-fmt.html" title="ioctl VIDIOC_G_FMT, VIDIOC_S_FMT, VIDIOC_TRY_FMT"><code class="constant">VIDIOC_S_FMT</code></a> ioctl. If this is not desired it should 36have the value <code class="constant">V4L2_FIELD_ANY</code> (0).</p><div class="table"><a name="v4l2-field"></a><p class="title"><b>Table 3.9. enum v4l2_field</b></p><div class="table-contents"><table summary="enum v4l2_field" width="100%" border="0"><colgroup><col class="c1"><col class="c2"><col class="c3"></colgroup><tbody valign="top"><tr><td valign="top"><code class="constant">V4L2_FIELD_ANY</code></td><td valign="top">0</td><td valign="top">Applications request this field order when any 37one of the <code class="constant">V4L2_FIELD_NONE</code>, 38<code class="constant">V4L2_FIELD_TOP</code>, 39<code class="constant">V4L2_FIELD_BOTTOM</code>, or 40<code class="constant">V4L2_FIELD_INTERLACED</code> formats is acceptable. 41Drivers choose depending on hardware capabilities or e. g. the 42requested image size, and return the actual field order. Drivers must 43never return <code class="constant">V4L2_FIELD_ANY</code>. If multiple 44field orders are possible the driver must choose one of the possible 45field orders during <a class="link" href="vidioc-g-fmt.html" title="ioctl VIDIOC_G_FMT, VIDIOC_S_FMT, VIDIOC_TRY_FMT"><code class="constant">VIDIOC_S_FMT</code></a> or <a class="link" href="vidioc-g-fmt.html" title="ioctl VIDIOC_G_FMT, VIDIOC_S_FMT, VIDIOC_TRY_FMT"><code class="constant">VIDIOC_TRY_FMT</code></a>. struct <a class="link" href="buffer.html#v4l2-buffer" title="Table 3.1. struct v4l2_buffer">v4l2_buffer</a> 46<em class="structfield"><code>field</code></em> can never be 47<code class="constant">V4L2_FIELD_ANY</code>.</td></tr><tr><td valign="top"><code class="constant">V4L2_FIELD_NONE</code></td><td valign="top">1</td><td valign="top">Images are in progressive format, not interlaced. 48The driver may also indicate this order when it cannot distinguish 49between <code class="constant">V4L2_FIELD_TOP</code> and 50<code class="constant">V4L2_FIELD_BOTTOM</code>.</td></tr><tr><td valign="top"><code class="constant">V4L2_FIELD_TOP</code></td><td valign="top">2</td><td valign="top">Images consist of the top (aka odd) field only.</td></tr><tr><td valign="top"><code class="constant">V4L2_FIELD_BOTTOM</code></td><td valign="top">3</td><td valign="top">Images consist of the bottom (aka even) field only. 51Applications may wish to prevent a device from capturing interlaced 52images because they will have "comb" or "feathering" artefacts around 53moving objects.</td></tr><tr><td valign="top"><code class="constant">V4L2_FIELD_INTERLACED</code></td><td valign="top">4</td><td valign="top">Images contain both fields, interleaved line by 54line. The temporal order of the fields (whether the top or bottom 55field is first transmitted) depends on the current video standard. 56M/NTSC transmits the bottom field first, all other standards the top 57field first.</td></tr><tr><td valign="top"><code class="constant">V4L2_FIELD_SEQ_TB</code></td><td valign="top">5</td><td valign="top">Images contain both fields, the top field lines 58are stored first in memory, immediately followed by the bottom field 59lines. Fields are always stored in temporal order, the older one first 60in memory. Image sizes refer to the frame, not fields.</td></tr><tr><td valign="top"><code class="constant">V4L2_FIELD_SEQ_BT</code></td><td valign="top">6</td><td valign="top">Images contain both fields, the bottom field 61lines are stored first in memory, immediately followed by the top 62field lines. Fields are always stored in temporal order, the older one 63first in memory. Image sizes refer to the frame, not fields.</td></tr><tr><td valign="top"><code class="constant">V4L2_FIELD_ALTERNATE</code></td><td valign="top">7</td><td valign="top">The two fields of a frame are passed in separate 64buffers, in temporal order, i. e. the older one first. To indicate the field 65parity (whether the current field is a top or bottom field) the driver 66or application, depending on data direction, must set struct <a class="link" href="buffer.html#v4l2-buffer" title="Table 3.1. struct v4l2_buffer">v4l2_buffer</a> 67<em class="structfield"><code>field</code></em> to 68<code class="constant">V4L2_FIELD_TOP</code> or 69<code class="constant">V4L2_FIELD_BOTTOM</code>. Any two successive fields pair 70to build a frame. If fields are successive, without any dropped fields 71between them (fields can drop individually), can be determined from 72the struct <a class="link" href="buffer.html#v4l2-buffer" title="Table 3.1. struct v4l2_buffer">v4l2_buffer</a> <em class="structfield"><code>sequence</code></em> field. This format 73cannot be selected when using the read/write I/O method since there 74is no way to communicate if a field was a top or bottom field.</td></tr><tr><td valign="top"><code class="constant">V4L2_FIELD_INTERLACED_TB</code></td><td valign="top">8</td><td valign="top">Images contain both fields, interleaved line by 75line, top field first. The top field is transmitted first.</td></tr><tr><td valign="top"><code class="constant">V4L2_FIELD_INTERLACED_BT</code></td><td valign="top">9</td><td valign="top">Images contain both fields, interleaved line by 76line, top field first. The bottom field is transmitted first.</td></tr></tbody></table></div></div><br class="table-break"><div class="figure"><a name="fieldseq-tb"></a><p class="title"><b>Figure 3.1. Field Order, Top Field First Transmitted</b></p><div class="figure-contents"><div class="mediaobject"><img src="fieldseq_tb.gif" alt="Field Order, Top Field First Transmitted"></div></div></div><br class="figure-break"><div class="figure"><a name="fieldseq-bt"></a><p class="title"><b>Figure 3.2. Field Order, Bottom Field First Transmitted</b></p><div class="figure-contents"><div class="mediaobject"><img src="fieldseq_bt.gif" alt="Field Order, Bottom Field First Transmitted"></div></div></div><br class="figure-break"></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="buffer.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="io.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="devices.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Buffers </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 4. Interfaces</td></tr></table></div></body></html> 77