1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"> 2 <HTML 3 ><HEAD 4 ><TITLE 5 >Field Order</TITLE 6 ><META 7 NAME="GENERATOR" 8 CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK 9 REL="HOME" 10 TITLE="Video for Linux Two API Specification" 11 HREF="book1.htm"><LINK 12 REL="UP" 13 TITLE="Input/Output" 14 HREF="c5742.htm"><LINK 15 REL="PREVIOUS" 16 TITLE="Buffers" 17 HREF="x5953.htm"><LINK 18 REL="NEXT" 19 TITLE="Interfaces" 20 HREF="c6488.htm"></HEAD 21 ><BODY 22 CLASS="SECTION" 23 BGCOLOR="#FFFFFF" 24 TEXT="#000000" 25 LINK="#0000FF" 26 VLINK="#840084" 27 ALINK="#0000FF" 28 ><DIV 29 CLASS="NAVHEADER" 30 ><TABLE 31 SUMMARY="Header navigation table" 32 WIDTH="100%" 33 BORDER="0" 34 CELLPADDING="0" 35 CELLSPACING="0" 36 ><TR 37 ><TH 38 COLSPAN="3" 39 ALIGN="center" 40 >Video for Linux Two API Specification: Revision 0.24</TH 41 ></TR 42 ><TR 43 ><TD 44 WIDTH="10%" 45 ALIGN="left" 46 VALIGN="bottom" 47 ><A 48 HREF="x5953.htm" 49 ACCESSKEY="P" 50 >Prev</A 51 ></TD 52 ><TD 53 WIDTH="80%" 54 ALIGN="center" 55 VALIGN="bottom" 56 >Chapter 3. Input/Output</TD 57 ><TD 58 WIDTH="10%" 59 ALIGN="right" 60 VALIGN="bottom" 61 ><A 62 HREF="c6488.htm" 63 ACCESSKEY="N" 64 >Next</A 65 ></TD 66 ></TR 67 ></TABLE 68 ><HR 69 ALIGN="LEFT" 70 WIDTH="100%"></DIV 71 ><DIV 72 CLASS="SECTION" 73 ><H1 74 CLASS="SECTION" 75 ><A 76 NAME="FIELD-ORDER" 77 >3.6. Field Order</A 78 ></H1 79 ><P 80 >We have to distinguish between progressive and interlaced 81 video. Progressive video transmits all lines of a video image 82 sequentially. Interlaced video divides an image into two fields, 83 containing only the odd and even lines of the image, respectively. 84 Alternating the so called odd and even field are transmitted, and due 85 to a small delay between fields a cathode ray TV displays the lines 86 interleaved, yielding the original frame. This curious technique was 87 invented because at refresh rates similar to film the image would 88 fade out too quickly. Transmitting fields reduces the flicker without 89 the necessity of doubling the frame rate and with it the bandwidth 90 required for each channel.</P 91 ><P 92 >It is important to understand a video camera does not expose 93 one frame at a time, merely transmitting the frames separated into 94 fields. The fields are in fact captured at two different instances in 95 time. An object on screen may well move between one field and the 96 next. For applications analysing motion it is of paramount importance 97 to recognize which field of a frame is older, the <SPAN 98 CLASS="emphasis" 99 ><I 100 CLASS="EMPHASIS" 101 >temporal 102 order</I 103 ></SPAN 104 >.</P 105 ><P 106 >When the driver provides or accepts images field by field 107 rather than interleaved, it is also important applications understand 108 how the fields combine to frames. We distinguish between top and 109 bottom fields, the <SPAN 110 CLASS="emphasis" 111 ><I 112 CLASS="EMPHASIS" 113 >spatial order</I 114 ></SPAN 115 >: The first line 116 of the top field is the first line of an interlaced frame, the first 117 line of the bottom field is the second line of that frame.</P 118 ><P 119 >However because fields were captured one after the other, 120 arguing whether a frame commences with the top or bottom field is 121 pointless. Any two successive top and bottom, or bottom and top fields 122 yield a valid frame. Only when the source was progressive to begin 123 with, e. g. when transferring film to video, two fields may come from 124 the same frame, creating a natural order.</P 125 ><P 126 >Counter to intuition the top field is not necessarily the 127 older field. Whether the older field contains the top or bottom lines 128 is a convention determined by the video standard. Hence the 129 distinction between temporal and spatial order of fields. The diagrams 130 below should make this clearer.</P 131 ><P 132 >All video capture and output devices must report the current 133 field order. Some drivers may permit the selection of a different 134 order, to this end applications initialize the 135 <CODE 136 CLASS="STRUCTFIELD" 137 >field</CODE 138 > field of struct <A 139 HREF="c2030.htm#V4L2-PIX-FORMAT" 140 >v4l2_pix_format</A 141 > before 142 calling the <A 143 HREF="r10944.htm" 144 ><CODE 145 CLASS="CONSTANT" 146 >VIDIOC_S_FMT</CODE 147 ></A 148 > ioctl. If this is not desired it should 149 have the value <CODE 150 CLASS="CONSTANT" 151 >V4L2_FIELD_ANY</CODE 152 > (0).</P 153 ><DIV 154 CLASS="TABLE" 155 ><A 156 NAME="V4L2-FIELD" 157 ></A 158 ><P 159 ><B 160 >Table 3-8. enum v4l2_field</B 161 ></P 162 ><TABLE 163 BORDER="0" 164 FRAME="void" 165 WIDTH="100%" 166 CLASS="CALSTABLE" 167 ><COL 168 WIDTH="38%" 169 TITLE="C1"><COL 170 WIDTH="12%" 171 TITLE="C2"><COL 172 WIDTH="50%" 173 TITLE="C3"><TBODY 174 VALIGN="TOP" 175 ><TR 176 ><TD 177 ><CODE 178 CLASS="CONSTANT" 179 >V4L2_FIELD_ANY</CODE 180 ></TD 181 ><TD 182 >0</TD 183 ><TD 184 >Applications request this field order when any 185 one of the <CODE 186 CLASS="CONSTANT" 187 >V4L2_FIELD_NONE</CODE 188 >, 189 <CODE 190 CLASS="CONSTANT" 191 >V4L2_FIELD_TOP</CODE 192 >, 193 <CODE 194 CLASS="CONSTANT" 195 >V4L2_FIELD_BOTTOM</CODE 196 >, or 197 <CODE 198 CLASS="CONSTANT" 199 >V4L2_FIELD_INTERLACED</CODE 200 > formats is acceptable. 201 Drivers choose depending on hardware capabilities or e. g. the 202 requested image size, and return the actual field order. struct <A 203 HREF="x5953.htm#V4L2-BUFFER" 204 >v4l2_buffer</A 205 > 206 <CODE 207 CLASS="STRUCTFIELD" 208 >field</CODE 209 > can never be 210 <CODE 211 CLASS="CONSTANT" 212 >V4L2_FIELD_ANY</CODE 213 >.</TD 214 ></TR 215 ><TR 216 ><TD 217 ><CODE 218 CLASS="CONSTANT" 219 >V4L2_FIELD_NONE</CODE 220 ></TD 221 ><TD 222 >1</TD 223 ><TD 224 >Images are in progressive format, not interlaced. 225 The driver may also indicate this order when it cannot distinguish 226 between <CODE 227 CLASS="CONSTANT" 228 >V4L2_FIELD_TOP</CODE 229 > and 230 <CODE 231 CLASS="CONSTANT" 232 >V4L2_FIELD_BOTTOM</CODE 233 >.</TD 234 ></TR 235 ><TR 236 ><TD 237 ><CODE 238 CLASS="CONSTANT" 239 >V4L2_FIELD_TOP</CODE 240 ></TD 241 ><TD 242 >2</TD 243 ><TD 244 >Images consist of the top field only.</TD 245 ></TR 246 ><TR 247 ><TD 248 ><CODE 249 CLASS="CONSTANT" 250 >V4L2_FIELD_BOTTOM</CODE 251 ></TD 252 ><TD 253 >3</TD 254 ><TD 255 >Images consist of the bottom field only. 256 Applications may wish to prevent a device from capturing interlaced 257 images because they will have "comb" or "feathering" artefacts around 258 moving objects.</TD 259 ></TR 260 ><TR 261 ><TD 262 ><CODE 263 CLASS="CONSTANT" 264 >V4L2_FIELD_INTERLACED</CODE 265 ></TD 266 ><TD 267 >4</TD 268 ><TD 269 >Images contain both fields, interleaved line by 270 line. The temporal order of the fields (whether the top or bottom 271 field is first transmitted) depends on the current video standard. 272 M/NTSC transmits the bottom field first, all other standards the top 273 field first.</TD 274 ></TR 275 ><TR 276 ><TD 277 ><CODE 278 CLASS="CONSTANT" 279 >V4L2_FIELD_SEQ_TB</CODE 280 ></TD 281 ><TD 282 >5</TD 283 ><TD 284 >Images contain both fields, the top field lines 285 are stored first in memory, immediately followed by the bottom field 286 lines. Fields are always stored in temporal order, the older one first 287 in memory. Image sizes refer to the frame, not fields.</TD 288 ></TR 289 ><TR 290 ><TD 291 ><CODE 292 CLASS="CONSTANT" 293 >V4L2_FIELD_SEQ_BT</CODE 294 ></TD 295 ><TD 296 >6</TD 297 ><TD 298 >Images contain both fields, the bottom field 299 lines are stored first in memory, immediately followed by the top 300 field lines. Fields are always stored in temporal order, the older one 301 first in memory. Image sizes refer to the frame, not fields.</TD 302 ></TR 303 ><TR 304 ><TD 305 ><CODE 306 CLASS="CONSTANT" 307 >V4L2_FIELD_ALTERNATE</CODE 308 ></TD 309 ><TD 310 >7</TD 311 ><TD 312 >The two fields of a frame are passed in separate 313 buffers, in temporal order, i. e. the older one first. To indicate the field 314 parity (whether the current field is a top or bottom field) the driver 315 or application, depending on data direction, must set struct <A 316 HREF="x5953.htm#V4L2-BUFFER" 317 >v4l2_buffer</A 318 > 319 <CODE 320 CLASS="STRUCTFIELD" 321 >field</CODE 322 > to 323 <CODE 324 CLASS="CONSTANT" 325 >V4L2_FIELD_TOP</CODE 326 > or 327 <CODE 328 CLASS="CONSTANT" 329 >V4L2_FIELD_BOTTOM</CODE 330 >. Any two successive fields pair 331 to build a frame. If fields are successive, without any dropped fields 332 between them (fields can drop individually), can be determined from 333 the struct <A 334 HREF="x5953.htm#V4L2-BUFFER" 335 >v4l2_buffer</A 336 > <CODE 337 CLASS="STRUCTFIELD" 338 >sequence</CODE 339 > field. Image 340 sizes refer to the frame, not fields. This format cannot be selected 341 when using the read/write I/O method.</TD 342 ></TR 343 ><TR 344 ><TD 345 ><CODE 346 CLASS="CONSTANT" 347 >V4L2_FIELD_INTERLACED_TB</CODE 348 ></TD 349 ><TD 350 >8</TD 351 ><TD 352 >Images contain both fields, interleaved line by 353 line, top field first. The top field is transmitted first.</TD 354 ></TR 355 ><TR 356 ><TD 357 ><CODE 358 CLASS="CONSTANT" 359 >V4L2_FIELD_INTERLACED_BT</CODE 360 ></TD 361 ><TD 362 >9</TD 363 ><TD 364 >Images contain both fields, interleaved line by 365 line, top field first. The bottom field is transmitted first.</TD 366 ></TR 367 ></TBODY 368 ></TABLE 369 ></DIV 370 ><DIV 371 CLASS="FIGURE" 372 ><A 373 NAME="FIELDSEQ-TB" 374 ></A 375 ><P 376 ><B 377 >Figure 3-1. Field Order, Top Field First Transmitted</B 378 ></P 379 ><DIV 380 CLASS="MEDIAOBJECT" 381 ><P 382 ><IMG 383 SRC="fieldseq_tb.gif"></P 384 ></DIV 385 ></DIV 386 ><DIV 387 CLASS="FIGURE" 388 ><A 389 NAME="FIELDSEQ-BT" 390 ></A 391 ><P 392 ><B 393 >Figure 3-2. Field Order, Bottom Field First Transmitted</B 394 ></P 395 ><DIV 396 CLASS="MEDIAOBJECT" 397 ><P 398 ><IMG 399 SRC="fieldseq_bt.gif"></P 400 ></DIV 401 ></DIV 402 ></DIV 403 ><DIV 404 CLASS="NAVFOOTER" 405 ><HR 406 ALIGN="LEFT" 407 WIDTH="100%"><TABLE 408 SUMMARY="Footer navigation table" 409 WIDTH="100%" 410 BORDER="0" 411 CELLPADDING="0" 412 CELLSPACING="0" 413 ><TR 414 ><TD 415 WIDTH="33%" 416 ALIGN="left" 417 VALIGN="top" 418 ><A 419 HREF="x5953.htm" 420 ACCESSKEY="P" 421 >Prev</A 422 ></TD 423 ><TD 424 WIDTH="34%" 425 ALIGN="center" 426 VALIGN="top" 427 ><A 428 HREF="book1.htm" 429 ACCESSKEY="H" 430 >Home</A 431 ></TD 432 ><TD 433 WIDTH="33%" 434 ALIGN="right" 435 VALIGN="top" 436 ><A 437 HREF="c6488.htm" 438 ACCESSKEY="N" 439 >Next</A 440 ></TD 441 ></TR 442 ><TR 443 ><TD 444 WIDTH="33%" 445 ALIGN="left" 446 VALIGN="top" 447 >Buffers</TD 448 ><TD 449 WIDTH="34%" 450 ALIGN="center" 451 VALIGN="top" 452 ><A 453 HREF="c5742.htm" 454 ACCESSKEY="U" 455 >Up</A 456 ></TD 457 ><TD 458 WIDTH="33%" 459 ALIGN="right" 460 VALIGN="top" 461 >Interfaces</TD 462 ></TR 463 ></TABLE 464 ></DIV 465 ></BODY 466 ></HTML 467 > 468