← Documents Documentation/userspace-api/media/v4l/field-order.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API / Media / V4L

Field Order

Progressive와 interlaced video의 spatial·temporal field order 및 buffer 형식을 설명합니다.

Source pathDocumentation/userspace-api/media/v4l/field-order.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

field-order.rst:1-165

Field order를 해석할 때 frame 안의 top/bottom 위치인 spatial order와 먼저 capture된 field를 나타내는 temporal order를 분리해야 합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2
3 .. _field-order:
4
5 ***********
6 Field Order
7 ***********
8
9 We have to distinguish between progressive and interlaced video.
10 Progressive video transmits all lines of a video image sequentially.
11 Interlaced video divides an image into two fields, containing only the
12 odd and even lines of the image, respectively. Alternating the so called
13 odd and even field are transmitted, and due to a small delay between
14 fields a cathode ray TV displays the lines interleaved, yielding the
15 original frame. This curious technique was invented because at refresh
16 rates similar to film the image would fade out too quickly. Transmitting
17 fields reduces the flicker without the necessity of doubling the frame
18 rate and with it the bandwidth required for each channel.
19
20 It is important to understand a video camera does not expose one frame
21 at a time, merely transmitting the frames separated into fields. The
22 fields are in fact captured at two different instances in time. An
23 object on screen may well move between one field and the next. For
24 applications analysing motion it is of paramount importance to recognize
25 which field of a frame is older, the *temporal order*.
26
27 When the driver provides or accepts images field by field rather than
28 interleaved, it is also important applications understand how the fields
29 combine to frames. We distinguish between top (aka odd) and bottom (aka
30 even) fields, the *spatial order*: The first line of the top field is
31 the first line of an interlaced frame, the first line of the bottom
32 field is the second line of that frame.
33
34 However because fields were captured one after the other, arguing
35 whether a frame commences with the top or bottom field is pointless. Any
36 two successive top and bottom, or bottom and top fields yield a valid
37 frame. Only when the source was progressive to begin with, e. g. when
38 transferring film to video, two fields may come from the same frame,
39 creating a natural order.
40
41 Counter to intuition the top field is not necessarily the older field.
42 Whether the older field contains the top or bottom lines is a convention
43 determined by the video standard. Hence the distinction between temporal
44 and spatial order of fields. The diagrams below should make this
45 clearer.
46
47 In V4L it is assumed that all video cameras transmit fields on the media
48 bus in the same order they were captured, so if the top field was
49 captured first (is the older field), the top field is also transmitted
50 first on the bus.
51
52 All video capture and output devices must report the current field
53 order. Some drivers may permit the selection of a different order, to
54 this end applications initialize the ``field`` field of struct
55 :c:type:`v4l2_pix_format` before calling the
56 :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl. If this is not desired it
57 should have the value ``V4L2_FIELD_ANY`` (0).
58
59
60 enum v4l2_field
61 ===============
62
63 .. c:type:: v4l2_field
64
65 .. tabularcolumns:: |p{5.8cm}|p{0.6cm}|p{10.9cm}|
66
67 .. cssclass:: longtable
68
69 .. flat-table::
70 :header-rows: 0
71 :stub-columns: 0
72 :widths: 3 1 4
73
74 * - ``V4L2_FIELD_ANY``
75 - 0
76 - Applications request this field order when any field format
77 is acceptable. Drivers choose depending on hardware capabilities or
78 e.g. the requested image size, and return the actual field order.
79 Drivers must never return ``V4L2_FIELD_ANY``.
80 If multiple field orders are possible the
81 driver must choose one of the possible field orders during
82 :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` or
83 :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>`. struct
84 :c:type:`v4l2_buffer` ``field`` can never be
85 ``V4L2_FIELD_ANY``.
86 * - ``V4L2_FIELD_NONE``
87 - 1
88 - Images are in progressive (frame-based) format, not interlaced
89 (field-based).
90 * - ``V4L2_FIELD_TOP``
91 - 2
92 - Images consist of the top (aka odd) field only.
93 * - ``V4L2_FIELD_BOTTOM``
94 - 3
95 - Images consist of the bottom (aka even) field only. Applications
96 may wish to prevent a device from capturing interlaced images
97 because they will have "comb" or "feathering" artefacts around
98 moving objects.
99 * - ``V4L2_FIELD_INTERLACED``
100 - 4
101 - Images contain both fields, interleaved line by line. The temporal
102 order of the fields (whether the top or bottom field is older)
103 depends on the current video standard. In M/NTSC the bottom
104 field is the older field. In all other standards the top field
105 is the older field.
106 * - ``V4L2_FIELD_SEQ_TB``
107 - 5
108 - Images contain both fields, the top field lines are stored first
109 in memory, immediately followed by the bottom field lines. Fields
110 are always stored in temporal order, the older one first in
111 memory. Image sizes refer to the frame, not fields.
112 * - ``V4L2_FIELD_SEQ_BT``
113 - 6
114 - Images contain both fields, the bottom field lines are stored
115 first in memory, immediately followed by the top field lines.
116 Fields are always stored in temporal order, the older one first in
117 memory. Image sizes refer to the frame, not fields.
118 * - ``V4L2_FIELD_ALTERNATE``
119 - 7
120 - The two fields of a frame are passed in separate buffers, in
121 temporal order, i. e. the older one first. To indicate the field
122 parity (whether the current field is a top or bottom field) the
123 driver or application, depending on data direction, must set
124 struct :c:type:`v4l2_buffer` ``field`` to
125 ``V4L2_FIELD_TOP`` or ``V4L2_FIELD_BOTTOM``. Any two successive
126 fields pair to build a frame. If fields are successive, without
127 any dropped fields between them (fields can drop individually),
128 can be determined from the struct
129 :c:type:`v4l2_buffer` ``sequence`` field. This
130 format cannot be selected when using the read/write I/O method
131 since there is no way to communicate if a field was a top or
132 bottom field.
133 * - ``V4L2_FIELD_INTERLACED_TB``
134 - 8
135 - Images contain both fields, interleaved line by line, top field
136 first. The top field is the older field.
137 * - ``V4L2_FIELD_INTERLACED_BT``
138 - 9
139 - Images contain both fields, interleaved line by line, top field
140 first. The bottom field is the older field.
141
142
143
144 .. _fieldseq-tb:
145
146 Field Order, Top Field First Transmitted
147 ========================================
148
149 .. kernel-figure:: fieldseq_tb.svg
150 :alt: fieldseq_tb.svg
151 :align: center
152
153 Field Order, Top Field First Transmitted
154
155
156 .. _fieldseq-bt:
157
158 Field Order, Bottom Field First Transmitted
159 ===========================================
160
161 .. kernel-figure:: fieldseq_bt.svg
162 :alt: fieldseq_bt.svg
163 :align: center
164
165 Field Order, Bottom Field First Transmitted
166

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Progressive와 interlaced field

1-59

Progressive video는 한 영상의 모든 line을 순서대로 전송합니다. Interlaced video는 영상을 odd line의 top field와 even line의 bottom field로 나누고 두 field를 번갈아 전송합니다. CRT는 약간의 시간차를 둔 line을 서로 끼워 원래 frame으로 표시합니다. 이 방식은 frame rate와 channel bandwidth를 두 배로 늘리지 않고 film과 비슷한 refresh rate에서 flicker를 줄이기 위해 고안됐습니다.

카메라가 frame 하나를 한 시점에 노출한 뒤 field로 나누어 보내는 것은 아닙니다. 두 field는 실제로 서로 다른 시각에 capture되므로 물체가 그 사이에 움직일 수 있습니다. Motion analysis에서는 어느 field가 더 오래됐는지 나타내는 temporal order가 중요합니다.

Spatial order는 top(odd) field와 bottom(even) field가 frame line에 어떻게 결합되는지를 뜻합니다. Top field의 첫 line은 interlaced frame의 첫 line이고 bottom field의 첫 line은 둘째 line입니다. 그러나 연속 capture된 field라면 top-bottom 또는 bottom-top 어느 연속 쌍도 frame이 될 수 있습니다. Progressive source를 film-to-video로 나눈 경우처럼 두 field가 같은 frame에서 나올 때만 자연스러운 쌍이 생깁니다.

Top field가 반드시 더 오래된 field는 아닙니다. 어느 field가 먼저 capture됐는지는 video standard의 temporal convention이고, top/bottom은 spatial position입니다. V4L은 camera가 media bus에서 capture 순서대로 field를 전송한다고 가정합니다.

Spatial order
Top field line 0 -> frame line 0Bottom field line 0 -> frame line 1Top field line 1 -> frame line 2Bottom field line 1 -> frame line 3

Frame 안에서 top과 bottom field의 line이 차지하는 위치입니다.

모든 capture와 output 장치는 현재 field order를 보고해야 합니다. 다른 순서를 선택하려면 `VIDIOC_S_FMT` 전에 `v4l2_pix_format.field`를 초기화합니다. 특별한 요청이 없으면 `V4L2_FIELD_ANY`(0)를 사용합니다.

.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later

.. _field-order:

***********
Field Order
***********

We have to distinguish between progressive and interlaced video.
Progressive video transmits all lines of a video image sequentially.
Interlaced video divides an image into two fields, containing only the
odd and even lines of the image, respectively. Alternating the so called
odd and even field are transmitted, and due to a small delay between
fields a cathode ray TV displays the lines interleaved, yielding the
original frame. This curious technique was invented because at refresh
rates similar to film the image would fade out too quickly. Transmitting
fields reduces the flicker without the necessity of doubling the frame
rate and with it the bandwidth required for each channel.

It is important to understand a video camera does not expose one frame
at a time, merely transmitting the frames separated into fields. The
fields are in fact captured at two different instances in time. An
object on screen may well move between one field and the next. For
applications analysing motion it is of paramount importance to recognize
which field of a frame is older, the *temporal order*.

When the driver provides or accepts images field by field rather than
interleaved, it is also important applications understand how the fields
combine to frames. We distinguish between top (aka odd) and bottom (aka
even) fields, the *spatial order*: The first line of the top field is
the first line of an interlaced frame, the first line of the bottom
field is the second line of that frame.

However because fields were captured one after the other, arguing
whether a frame commences with the top or bottom field is pointless. Any
two successive top and bottom, or bottom and top fields yield a valid
frame. Only when the source was progressive to begin with, e. g. when
transferring film to video, two fields may come from the same frame,
creating a natural order.

Counter to intuition the top field is not necessarily the older field.
Whether the older field contains the top or bottom lines is a convention
determined by the video standard. Hence the distinction between temporal
and spatial order of fields. The diagrams below should make this
clearer.

In V4L it is assumed that all video cameras transmit fields on the media
bus in the same order they were captured, so if the top field was
captured first (is the older field), the top field is also transmitted
first on the bus.

All video capture and output devices must report the current field
order. Some drivers may permit the selection of a different order, to
this end applications initialize the ``field`` field of struct
:c:type:`v4l2_pix_format` before calling the
:ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl. If this is not desired it
should have the value ``V4L2_FIELD_ANY`` (0).

`enum v4l2_field`

60-142
`v4l2_field` 값
항목설명
`V4L2_FIELD_ANY` (0)어떤 format도 허용한다는 application 요청값입니다. Driver는 hardware와 크기에 맞는 실제 순서를 골라 반환해야 하며 절대 ANY를 반환하면 안 됩니다. `v4l2_buffer.field`에도 사용할 수 없습니다.
`V4L2_FIELD_NONE` (1)Interlaced가 아닌 progressive frame format입니다.
`V4L2_FIELD_TOP` (2)Top 또는 odd field 하나만 포함합니다.
`V4L2_FIELD_BOTTOM` (3)Bottom 또는 even field 하나만 포함합니다. Field 한쪽만 capture하면 움직임 주변 comb 또는 feathering artefact를 피할 수 있습니다.
`V4L2_FIELD_INTERLACED` (4)두 field line을 번갈아 저장합니다. M/NTSC는 bottom이 더 오래됐고 다른 표준은 top이 더 오래됐습니다.
`V4L2_FIELD_SEQ_TB` (5)Top field의 모든 line 뒤에 bottom field line을 저장합니다. 오래된 field가 메모리에 먼저 오며 크기는 field가 아닌 frame 기준입니다.
`V4L2_FIELD_SEQ_BT` (6)Bottom field의 모든 line 뒤에 top field line을 저장합니다. 역시 오래된 field가 먼저 오고 크기는 frame 기준입니다.
`V4L2_FIELD_ALTERNATE` (7)두 field를 별도 buffer로 시간 순서대로 전달합니다. 각 buffer의 `field`에 TOP 또는 BOTTOM을 지정하고 `sequence`로 중간 field drop 여부를 판단합니다.
`V4L2_FIELD_INTERLACED_TB` (8)두 field를 line 단위로 교차 저장하고 top field가 더 오래됐습니다.
`V4L2_FIELD_INTERLACED_BT` (9)두 field를 line 단위로 교차 저장하되 bottom field가 더 오래됐습니다.

공간 배치, 시간 순서와 buffer 전달 방식을 함께 정의합니다.

`V4L2_FIELD_ANY` 요청에서 여러 순서가 가능하면 driver는 `VIDIOC_S_FMT` 또는 `VIDIOC_TRY_FMT` 중 하나를 선택해 실제 값을 반환합니다. `V4L2_FIELD_ALTERNATE`에서는 연속된 field 두 개가 한 frame을 이루지만 field는 개별적으로 drop될 수 있습니다. Top/bottom 정보를 전달할 방법이 없으므로 read/write I/O 방식에서는 ALTERNATE를 선택할 수 없습니다.

ALTERNATE buffer 조립
오래된 field buffer 수신`v4l2_buffer.field`에서 TOP/BOTTOM 확인다음 field buffer 수신`sequence`가 연속인지 검사Parity가 반대면 두 field를 frame으로 결합

시간 순서와 parity를 모두 확인해야 정확한 frame을 복원할 수 있습니다.

enum v4l2_field
===============

.. c:type:: v4l2_field

.. tabularcolumns:: |p{5.8cm}|p{0.6cm}|p{10.9cm}|

.. cssclass:: longtable

.. flat-table::
    :header-rows:  0
    :stub-columns: 0
    :widths:       3 1 4

    * - ``V4L2_FIELD_ANY``
      - 0
      - Applications request this field order when any field format
	is acceptable. Drivers choose depending on hardware capabilities or
	e.g. the requested image size, and return the actual field order.
	Drivers must never return ``V4L2_FIELD_ANY``.
	If multiple field orders are possible the
	driver must choose one of the possible field orders during
	:ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` or
	:ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>`. struct
	:c:type:`v4l2_buffer` ``field`` can never be
	``V4L2_FIELD_ANY``.
    * - ``V4L2_FIELD_NONE``
      - 1
      - Images are in progressive (frame-based) format, not interlaced
        (field-based).
    * - ``V4L2_FIELD_TOP``
      - 2
      - Images consist of the top (aka odd) field only.
    * - ``V4L2_FIELD_BOTTOM``
      - 3
      - Images consist of the bottom (aka even) field only. Applications
	may wish to prevent a device from capturing interlaced images
	because they will have "comb" or "feathering" artefacts around
	moving objects.
    * - ``V4L2_FIELD_INTERLACED``
      - 4
      - Images contain both fields, interleaved line by line. The temporal
	order of the fields (whether the top or bottom field is older)
	depends on the current video standard. In M/NTSC the bottom
	field is the older field. In all other standards the top field
	is the older field.
    * - ``V4L2_FIELD_SEQ_TB``
      - 5
      - Images contain both fields, the top field lines are stored first
	in memory, immediately followed by the bottom field lines. Fields
	are always stored in temporal order, the older one first in
	memory. Image sizes refer to the frame, not fields.
    * - ``V4L2_FIELD_SEQ_BT``
      - 6
      - Images contain both fields, the bottom field lines are stored
	first in memory, immediately followed by the top field lines.
	Fields are always stored in temporal order, the older one first in
	memory. Image sizes refer to the frame, not fields.
    * - ``V4L2_FIELD_ALTERNATE``
      - 7
      - The two fields of a frame are passed in separate buffers, in
	temporal order, i. e. the older one first. To indicate the field
	parity (whether the current field is a top or bottom field) the
	driver or application, depending on data direction, must set
	struct :c:type:`v4l2_buffer` ``field`` to
	``V4L2_FIELD_TOP`` or ``V4L2_FIELD_BOTTOM``. Any two successive
	fields pair to build a frame. If fields are successive, without
	any dropped fields between them (fields can drop individually),
	can be determined from the struct
	:c:type:`v4l2_buffer` ``sequence`` field. This
	format cannot be selected when using the read/write I/O method
	since there is no way to communicate if a field was a top or
	bottom field.
    * - ``V4L2_FIELD_INTERLACED_TB``
      - 8
      - Images contain both fields, interleaved line by line, top field
	first. The top field is the older field.
    * - ``V4L2_FIELD_INTERLACED_BT``
      - 9
      - Images contain both fields, interleaved line by line, top field
	first. The bottom field is the older field.

Top-first와 bottom-first 전송 도식

143-165

`fieldseq_tb.svg`는 top field가 먼저 capture되어 bus에서도 먼저 전송되는 순서를 보여 줍니다. `fieldseq_bt.svg`는 bottom field가 먼저 capture되고 먼저 전송되는 경우를 보여 줍니다. 두 그림 모두 spatial line 위치와 temporal age를 혼동하지 않는 것이 핵심입니다.

Field 전송 비교
경우Temporal order와 bus order
Top field firstOlder top -> newer bottom, bus에서도 top -> bottom
Bottom field firstOlder bottom -> newer top, bus에서도 bottom -> top

V4L은 capture한 순서와 media bus 전송 순서가 같다고 가정합니다.


.. _fieldseq-tb:

Field Order, Top Field First Transmitted
========================================

.. kernel-figure:: fieldseq_tb.svg
    :alt:    fieldseq_tb.svg
    :align:  center

    Field Order, Top Field First Transmitted


.. _fieldseq-bt:

Field Order, Bottom Field First Transmitted
===========================================

.. kernel-figure:: fieldseq_bt.svg
    :alt:    fieldseq_bt.svg
    :align:  center

    Field Order, Bottom Field First Transmitted