← Documents Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst GitHub 원문 ↗

Linux 6.18.37 · 사용자 공간 API

VIDIOC_ENUM_FMT ioctl

V4L2 이미지 형식을 순서대로 열거하는 방법과 media-controller 기반 mbus_code 필터, v4l2_fmtdesc 필드, 형식 플래그와 오류 조건을 설명합니다.

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

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

1. 요약·해설

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

요약·해설

vidioc-enum-fmt.rst:1-266

V4L2 이미지 형식을 순서대로 열거하는 방법과 media-controller 기반 mbus_code 필터, v4l2_fmtdesc 필드, 형식 플래그와 오류 조건을 설명합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: V4L
3
4 .. _VIDIOC_ENUM_FMT:
5
6 *********************
7 ioctl VIDIOC_ENUM_FMT
8 *********************
9
10 Name
11 ====
12
13 VIDIOC_ENUM_FMT - Enumerate image formats
14
15 Synopsis
16 ========
17
18 .. c:macro:: VIDIOC_ENUM_FMT
19
20 ``int ioctl(int fd, VIDIOC_ENUM_FMT, struct v4l2_fmtdesc *argp)``
21
22 Arguments
23 =========
24
25 ``fd``
26 File descriptor returned by :c:func:`open()`.
27
28 ``argp``
29 Pointer to struct :c:type:`v4l2_fmtdesc`.
30
31 Description
32 ===========
33
34 To enumerate image formats applications initialize the ``type``, ``mbus_code``
35 and ``index`` fields of struct :c:type:`v4l2_fmtdesc` and call
36 the :ref:`VIDIOC_ENUM_FMT` ioctl with a pointer to this structure. Drivers
37 fill the rest of the structure or return an ``EINVAL`` error code. All
38 formats are enumerable by beginning at index zero and incrementing by
39 one until ``EINVAL`` is returned. If applicable, drivers shall return
40 formats in preference order, where preferred formats are returned before
41 (that is, with lower ``index`` value) less-preferred formats.
42
43 Depending on the ``V4L2_CAP_IO_MC`` :ref:`capability <device-capabilities>`,
44 the ``mbus_code`` field is handled differently:
45
46 1) ``V4L2_CAP_IO_MC`` is not set (also known as a 'video-node-centric' driver)
47
48 Applications shall initialize the ``mbus_code`` field to zero and drivers
49 shall ignore the value of the field.
50
51 Drivers shall enumerate all image formats.
52
53 .. note::
54
55 After switching the input or output the list of enumerated image
56 formats may be different.
57
58 2) ``V4L2_CAP_IO_MC`` is set (also known as an 'MC-centric' driver)
59
60 If the ``mbus_code`` field is zero, then all image formats
61 shall be enumerated.
62
63 If the ``mbus_code`` field is initialized to a valid (non-zero)
64 :ref:`media bus format code <v4l2-mbus-pixelcode>`, then drivers
65 shall restrict enumeration to only the image formats that can produce
66 (for video output devices) or be produced from (for video capture
67 devices) that media bus code. If the ``mbus_code`` is unsupported by
68 the driver, then ``EINVAL`` shall be returned.
69
70 Regardless of the value of the ``mbus_code`` field, the enumerated image
71 formats shall not depend on the active configuration of the video device
72 or device pipeline.
73
74 .. c:type:: v4l2_fmtdesc
75
76 .. cssclass:: longtable
77
78 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
79
80 .. flat-table:: struct v4l2_fmtdesc
81 :header-rows: 0
82 :stub-columns: 0
83 :widths: 1 1 2
84
85 * - __u32
86 - ``index``
87 - Number of the format in the enumeration, set by the application.
88 This is in no way related to the ``pixelformat`` field.
89 When the index is ORed with ``V4L2_FMTDESC_FLAG_ENUM_ALL`` the
90 driver clears the flag and enumerates all the possible formats,
91 ignoring any limitations from the current configuration. Drivers
92 which do not support this flag always return an ``EINVAL``
93 error code without clearing this flag.
94 Formats enumerated when using ``V4L2_FMTDESC_FLAG_ENUM_ALL`` flag
95 shouldn't be used when calling :c:func:`VIDIOC_ENUM_FRAMESIZES`
96 or :c:func:`VIDIOC_ENUM_FRAMEINTERVALS`.
97 ``V4L2_FMTDESC_FLAG_ENUM_ALL`` should only be used by drivers that
98 can return different format list depending on this flag.
99 * - __u32
100 - ``type``
101 - Type of the data stream, set by the application. Only these types
102 are valid here: ``V4L2_BUF_TYPE_VIDEO_CAPTURE``,
103 ``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``,
104 ``V4L2_BUF_TYPE_VIDEO_OUTPUT``,
105 ``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``,
106 ``V4L2_BUF_TYPE_VIDEO_OVERLAY``,
107 ``V4L2_BUF_TYPE_SDR_CAPTURE``,
108 ``V4L2_BUF_TYPE_SDR_OUTPUT``,
109 ``V4L2_BUF_TYPE_META_CAPTURE`` and
110 ``V4L2_BUF_TYPE_META_OUTPUT``.
111 See :c:type:`v4l2_buf_type`.
112 * - __u32
113 - ``flags``
114 - See :ref:`fmtdesc-flags`
115 * - __u8
116 - ``description``\ [32]
117 - Description of the format, a NUL-terminated ASCII string. This
118 information is intended for the user, for example: "YUV 4:2:2".
119 * - __u32
120 - ``pixelformat``
121 - The image format identifier. This is a four character code as
122 computed by the v4l2_fourcc() macro:
123 * - :cspan:`2`
124
125 .. _v4l2-fourcc:
126
127 ``#define v4l2_fourcc(a,b,c,d)``
128
129 ``(((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24))``
130
131 Several image formats are already defined by this specification in
132 :ref:`pixfmt`.
133
134 .. attention::
135
136 These codes are not the same as those used
137 in the Windows world.
138 * - __u32
139 - ``mbus_code``
140 - Media bus code restricting the enumerated formats, set by the
141 application. Only applicable to drivers that advertise the
142 ``V4L2_CAP_IO_MC`` :ref:`capability <device-capabilities>`, shall be 0
143 otherwise.
144 * - __u32
145 - ``reserved``\ [3]
146 - Reserved for future extensions. Drivers must set the array to
147 zero.
148
149
150 .. tabularcolumns:: |p{8.4cm}|p{1.8cm}|p{7.1cm}|
151
152 .. cssclass:: longtable
153
154 .. _fmtdesc-flags:
155
156 .. flat-table:: Image Format Description Flags
157 :header-rows: 0
158 :stub-columns: 0
159 :widths: 3 1 4
160
161 * - ``V4L2_FMT_FLAG_COMPRESSED``
162 - 0x0001
163 - This is a compressed format.
164 * - ``V4L2_FMT_FLAG_EMULATED``
165 - 0x0002
166 - This format is not native to the device but emulated through
167 software (usually libv4l2), where possible try to use a native
168 format instead for better performance.
169 * - ``V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM``
170 - 0x0004
171 - The hardware decoder for this compressed bytestream format (aka coded
172 format) is capable of parsing a continuous bytestream. Applications do
173 not need to parse the bytestream themselves to find the boundaries
174 between frames/fields.
175
176 This flag can only be used in combination with the
177 ``V4L2_FMT_FLAG_COMPRESSED`` flag, since this applies to compressed
178 formats only. This flag is valid for stateful decoders only.
179 * - ``V4L2_FMT_FLAG_DYN_RESOLUTION``
180 - 0x0008
181 - Dynamic resolution switching is supported by the device for this
182 compressed bytestream format (aka coded format). It will notify the user
183 via the event ``V4L2_EVENT_SOURCE_CHANGE`` when changes in the video
184 parameters are detected.
185
186 This flag can only be used in combination with the
187 ``V4L2_FMT_FLAG_COMPRESSED`` flag, since this applies to
188 compressed formats only. This flag is valid for stateful codecs only.
189 * - ``V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL``
190 - 0x0010
191 - The hardware encoder supports setting the ``CAPTURE`` coded frame
192 interval separately from the ``OUTPUT`` raw frame interval.
193 Setting the ``OUTPUT`` raw frame interval with :ref:`VIDIOC_S_PARM <VIDIOC_G_PARM>`
194 also sets the ``CAPTURE`` coded frame interval to the same value.
195 If this flag is set, then the ``CAPTURE`` coded frame interval can be
196 set to a different value afterwards. This is typically used for
197 offline encoding where the ``OUTPUT`` raw frame interval is used as
198 a hint for reserving hardware encoder resources and the ``CAPTURE`` coded
199 frame interval is the actual frame rate embedded in the encoded video
200 stream.
201
202 This flag can only be used in combination with the
203 ``V4L2_FMT_FLAG_COMPRESSED`` flag, since this applies to
204 compressed formats only. This flag is valid for stateful encoders only.
205 * - ``V4L2_FMT_FLAG_CSC_COLORSPACE``
206 - 0x0020
207 - The driver allows the application to try to change the default
208 colorspace. This flag is relevant only for capture devices.
209 The application can ask to configure the colorspace of the capture device
210 when calling the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl with
211 :ref:`V4L2_PIX_FMT_FLAG_SET_CSC <v4l2-pix-fmt-flag-set-csc>` set.
212 * - ``V4L2_FMT_FLAG_CSC_XFER_FUNC``
213 - 0x0040
214 - The driver allows the application to try to change the default
215 transfer function. This flag is relevant only for capture devices.
216 The application can ask to configure the transfer function of the capture
217 device when calling the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl with
218 :ref:`V4L2_PIX_FMT_FLAG_SET_CSC <v4l2-pix-fmt-flag-set-csc>` set.
219 * - ``V4L2_FMT_FLAG_CSC_YCBCR_ENC``
220 - 0x0080
221 - The driver allows the application to try to change the default
222 Y'CbCr encoding. This flag is relevant only for capture devices.
223 The application can ask to configure the Y'CbCr encoding of the capture device
224 when calling the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl with
225 :ref:`V4L2_PIX_FMT_FLAG_SET_CSC <v4l2-pix-fmt-flag-set-csc>` set.
226 * - ``V4L2_FMT_FLAG_CSC_HSV_ENC``
227 - 0x0080
228 - The driver allows the application to try to change the default
229 HSV encoding. This flag is relevant only for capture devices.
230 The application can ask to configure the HSV encoding of the capture device
231 when calling the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl with
232 :ref:`V4L2_PIX_FMT_FLAG_SET_CSC <v4l2-pix-fmt-flag-set-csc>` set.
233 * - ``V4L2_FMT_FLAG_CSC_QUANTIZATION``
234 - 0x0100
235 - The driver allows the application to try to change the default
236 quantization. This flag is relevant only for capture devices.
237 The application can ask to configure the quantization of the capture
238 device when calling the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl with
239 :ref:`V4L2_PIX_FMT_FLAG_SET_CSC <v4l2-pix-fmt-flag-set-csc>` set.
240 * - ``V4L2_FMT_FLAG_META_LINE_BASED``
241 - 0x0200
242 - The metadata format is line-based. In this case the ``width``,
243 ``height`` and ``bytesperline`` fields of :c:type:`v4l2_meta_format` are
244 valid. The buffer consists of ``height`` lines, each having ``width``
245 Data Units of data and the offset (in bytes) between the beginning of
246 each two consecutive lines is ``bytesperline``.
247 * - ``V4L2_FMTDESC_FLAG_ENUM_ALL``
248 - 0x80000000
249 - When the applications ORs ``index`` with ``V4L2_FMTDESC_FLAG_ENUM_ALL`` flag
250 the driver enumerates all the possible pixel formats without taking care
251 of any already set configuration. Drivers which do not support this flag,
252 always return ``EINVAL`` without clearing this flag.
253
254 Return Value
255 ============
256
257 On success 0 is returned, on error -1 and the ``errno`` variable is set
258 appropriately. The generic error codes are described at the
259 :ref:`Generic Error Codes <gen-errors>` chapter.
260
261 EINVAL
262 The struct :c:type:`v4l2_fmtdesc` ``type`` is not
263 supported or the ``index`` is out of bounds.
264
265 If ``V4L2_CAP_IO_MC`` is set and the specified ``mbus_code``
266 is unsupported, then also return this error code.
267

3. 한국어 전문 번역

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

목적, 호출 형식과 인자

1-33

`VIDIOC_ENUM_FMT`는 비디오 장치가 지원하는 이미지 형식을 열거하는 ioctl입니다. 호출 형식은 `int ioctl(int fd, VIDIOC_ENUM_FMT, struct v4l2_fmtdesc *argp)`이며, 성공할 때마다 요청한 순번의 형식 설명을 `v4l2_fmtdesc`에 돌려줍니다.

`fd`는 `open()`이 반환한 파일 디스크립터이고, `argp`는 응용 프로그램이 조회 조건을 채운 `struct v4l2_fmtdesc`를 가리킵니다. 형식 열거는 스트림 유형별로 수행되므로 호출 전에 `type`을 반드시 지정해야 합니다.

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

.. _VIDIOC_ENUM_FMT:

*********************
ioctl VIDIOC_ENUM_FMT
*********************

Name
====

VIDIOC_ENUM_FMT - Enumerate image formats

Synopsis
========

.. c:macro:: VIDIOC_ENUM_FMT

``int ioctl(int fd, VIDIOC_ENUM_FMT, struct v4l2_fmtdesc *argp)``

Arguments
=========

``fd``
    File descriptor returned by :c:func:`open()`.

``argp``
    Pointer to struct :c:type:`v4l2_fmtdesc`.

Description
===========

형식 열거 절차와 media-controller 조건

34-75

응용 프로그램은 `type`, `mbus_code`, `index`를 초기화한 뒤 `VIDIOC_ENUM_FMT`를 호출합니다. 드라이버는 나머지 필드를 채우거나 `EINVAL`을 반환합니다. 모든 형식은 `index` 0부터 시작해 한 번에 1씩 증가시키며, `EINVAL`이 반환될 때까지 조회합니다.

드라이버가 선호도를 제공할 수 있다면 더 선호하는 형식을 더 낮은 `index`로 먼저 반환해야 합니다. 다만 `index`는 단순한 열거 순번이며 `pixelformat` 값과는 아무 관계가 없습니다.

`V4L2_CAP_IO_MC`가 설정되지 않은 video-node-centric 드라이버에서는 응용 프로그램이 `mbus_code`를 0으로 설정해야 하고 드라이버는 그 값을 무시합니다. 드라이버는 모든 이미지 형식을 열거하며, 입력이나 출력을 전환한 뒤에는 목록이 달라질 수 있습니다.

`V4L2_CAP_IO_MC`가 설정된 MC-centric 드라이버에서 `mbus_code`가 0이면 모든 이미지 형식을 열거합니다. 유효한 0이 아닌 media bus 형식 코드를 지정하면, 출력 장치에서는 해당 bus 코드를 생성할 수 있는 이미지 형식만, 캡처 장치에서는 해당 bus 코드로부터 생성될 수 있는 이미지 형식만 반환합니다. 지원하지 않는 코드는 `EINVAL`입니다.

MC-centric 드라이버의 열거 결과는 `mbus_code` 값과 무관하게 비디오 장치나 장치 파이프라인의 현재 활성 구성에 의존해서는 안 됩니다. 이는 토폴로지 협상 전에 가능한 형식 집합을 안정적으로 조사할 수 있게 하는 규칙입니다.

이미지 형식 열거
스트림의 type 선택드라이버 유형에 맞춰 mbus_code 설정index=0으로 VIDIOC_ENUM_FMT 호출반환된 flags, description, pixelformat 기록index를 1 증가시켜 반복EINVAL에서 열거 종료

일반 열거와 media bus 코드 제한을 포함한 호출 순서입니다.

To enumerate image formats applications initialize the ``type``, ``mbus_code``
and ``index`` fields of struct :c:type:`v4l2_fmtdesc` and call
the :ref:`VIDIOC_ENUM_FMT` ioctl with a pointer to this structure. Drivers
fill the rest of the structure or return an ``EINVAL`` error code. All
formats are enumerable by beginning at index zero and incrementing by
one until ``EINVAL`` is returned. If applicable, drivers shall return
formats in preference order, where preferred formats are returned before
(that is, with lower ``index`` value) less-preferred formats.

Depending on the ``V4L2_CAP_IO_MC`` :ref:`capability <device-capabilities>`,
the ``mbus_code`` field is handled differently:

1) ``V4L2_CAP_IO_MC`` is not set (also known as a 'video-node-centric' driver)

   Applications shall initialize the ``mbus_code`` field to zero and drivers
   shall ignore the value of the field.

   Drivers shall enumerate all image formats.

   .. note::

      After switching the input or output the list of enumerated image
      formats may be different.

2) ``V4L2_CAP_IO_MC`` is set (also known as an 'MC-centric' driver)

   If the ``mbus_code`` field is zero, then all image formats
   shall be enumerated.

   If the ``mbus_code`` field is initialized to a valid (non-zero)
   :ref:`media bus format code <v4l2-mbus-pixelcode>`, then drivers
   shall restrict enumeration to only the image formats that can produce
   (for video output devices) or be produced from (for video capture
   devices) that media bus code. If the ``mbus_code`` is unsupported by
   the driver, then ``EINVAL`` shall be returned.

   Regardless of the value of the ``mbus_code`` field, the enumerated image
   formats shall not depend on the active configuration of the video device
   or device pipeline.

.. c:type:: v4l2_fmtdesc

v4l2_fmtdesc 구조체와 FOURCC

76-159
struct v4l2_fmtdesc
형식필드의미
`__u32``index`응용 프로그램이 지정하는 열거 순번. `pixelformat`와 무관하며 `V4L2_FMTDESC_FLAG_ENUM_ALL`을 OR할 수 있음
`__u32``type`응용 프로그램이 지정하는 데이터 스트림 유형
`__u32``flags`드라이버가 반환하는 이미지 형식 특성 플래그
`__u8[32]``description`사용자 표시용 NUL 종료 ASCII 설명 문자열, 예: `YUV 4:2:2`
`__u32``pixelformat``v4l2_fourcc()`로 계산하는 네 문자 이미지 형식 식별자
`__u32``mbus_code`MC-centric 드라이버에서 열거 범위를 제한하는 media bus 코드; 그 밖에는 0
`__u32[3]``reserved`미래 확장용이며 드라이버가 전부 0으로 설정

응용 프로그램 입력 필드와 드라이버 반환 필드를 원문 순서대로 정리합니다.

`type`에 허용되는 값은 `V4L2_BUF_TYPE_VIDEO_CAPTURE`, `V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE`, `V4L2_BUF_TYPE_VIDEO_OUTPUT`, `V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE`, `V4L2_BUF_TYPE_VIDEO_OVERLAY`, `V4L2_BUF_TYPE_SDR_CAPTURE`, `V4L2_BUF_TYPE_SDR_OUTPUT`, `V4L2_BUF_TYPE_META_CAPTURE`, `V4L2_BUF_TYPE_META_OUTPUT`입니다.

`index`에 `V4L2_FMTDESC_FLAG_ENUM_ALL`을 OR하면 드라이버는 비트를 지우고 현재 구성의 제약을 무시한 모든 가능한 형식을 열거합니다. 이 기능을 지원하지 않는 드라이버는 플래그를 지우지 않은 채 항상 `EINVAL`을 반환합니다. 이 플래그로 얻은 형식은 `VIDIOC_ENUM_FRAMESIZES`나 `VIDIOC_ENUM_FRAMEINTERVALS` 호출에 사용하면 안 됩니다.

`pixelformat`는 `v4l2_fourcc(a,b,c,d)`가 각 문자를 0, 8, 16, 24비트 위치에 배치해 만드는 32비트 FOURCC입니다. 사양에 이미 정의된 형식은 pixel format 장에서 확인할 수 있으며, 이 코드 체계는 Windows에서 사용하는 코드와 같지 않다는 점에 주의해야 합니다.

.. cssclass:: longtable

.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|

.. flat-table:: struct v4l2_fmtdesc
    :header-rows:  0
    :stub-columns: 0
    :widths:       1 1 2

    * - __u32
      - ``index``
      - Number of the format in the enumeration, set by the application.
        This is in no way related to the ``pixelformat`` field.
        When the index is ORed with ``V4L2_FMTDESC_FLAG_ENUM_ALL`` the
        driver clears the flag and enumerates all the possible formats,
        ignoring any limitations from the current configuration. Drivers
        which do not support this flag always return an ``EINVAL``
        error code without clearing this flag.
        Formats enumerated when using ``V4L2_FMTDESC_FLAG_ENUM_ALL`` flag
        shouldn't be used when calling :c:func:`VIDIOC_ENUM_FRAMESIZES`
        or :c:func:`VIDIOC_ENUM_FRAMEINTERVALS`.
        ``V4L2_FMTDESC_FLAG_ENUM_ALL`` should only be used by drivers that
        can return different format list depending on this flag.
    * - __u32
      - ``type``
      - Type of the data stream, set by the application. Only these types
	are valid here: ``V4L2_BUF_TYPE_VIDEO_CAPTURE``,
	``V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE``,
	``V4L2_BUF_TYPE_VIDEO_OUTPUT``,
	``V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE``,
	``V4L2_BUF_TYPE_VIDEO_OVERLAY``,
	``V4L2_BUF_TYPE_SDR_CAPTURE``,
	``V4L2_BUF_TYPE_SDR_OUTPUT``,
	``V4L2_BUF_TYPE_META_CAPTURE`` and
	``V4L2_BUF_TYPE_META_OUTPUT``.
	See :c:type:`v4l2_buf_type`.
    * - __u32
      - ``flags``
      - See :ref:`fmtdesc-flags`
    * - __u8
      - ``description``\ [32]
      - Description of the format, a NUL-terminated ASCII string. This
	information is intended for the user, for example: "YUV 4:2:2".
    * - __u32
      - ``pixelformat``
      - The image format identifier. This is a four character code as
	computed by the v4l2_fourcc() macro:
    * - :cspan:`2`

	.. _v4l2-fourcc:

	``#define v4l2_fourcc(a,b,c,d)``

	``(((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24))``

	Several image formats are already defined by this specification in
	:ref:`pixfmt`.

	.. attention::

	   These codes are not the same as those used
	   in the Windows world.
    * - __u32
      - ``mbus_code``
      - Media bus code restricting the enumerated formats, set by the
        application. Only applicable to drivers that advertise the
        ``V4L2_CAP_IO_MC`` :ref:`capability <device-capabilities>`, shall be 0
        otherwise.
    * - __u32
      - ``reserved``\ [3]
      - Reserved for future extensions. Drivers must set the array to
	zero.


.. tabularcolumns:: |p{8.4cm}|p{1.8cm}|p{7.1cm}|

.. cssclass:: longtable

.. _fmtdesc-flags:

.. flat-table:: Image Format Description Flags
    :header-rows:  0
    :stub-columns: 0
    :widths:       3 1 4

이미지 형식 설명 플래그

160-251
Image Format Description Flags
플래그의미
`V4L2_FMT_FLAG_COMPRESSED``0x0001`압축 형식
`V4L2_FMT_FLAG_EMULATED``0x0002`장치 고유 형식이 아니라 소프트웨어, 보통 libv4l2로 에뮬레이션됨. 성능을 위해 가능하면 고유 형식을 우선 사용
`V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM``0x0004`하드웨어 디코더가 연속 압축 bytestream을 파싱하므로 응용 프로그램이 frame/field 경계를 찾을 필요가 없음
`V4L2_FMT_FLAG_DYN_RESOLUTION``0x0008`압축 bytestream의 동적 해상도 전환을 지원하며 영상 매개변수 변화 시 `V4L2_EVENT_SOURCE_CHANGE`로 통지
`V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL``0x0010`하드웨어 인코더가 CAPTURE coded frame interval을 OUTPUT raw frame interval과 별도로 설정하도록 지원
`V4L2_FMT_FLAG_CSC_COLORSPACE``0x0020`캡처 장치에서 응용 프로그램이 기본 colorspace 변경을 시도할 수 있음
`V4L2_FMT_FLAG_CSC_XFER_FUNC``0x0040`캡처 장치에서 응용 프로그램이 기본 transfer function 변경을 시도할 수 있음
`V4L2_FMT_FLAG_CSC_YCBCR_ENC``0x0080`캡처 장치에서 응용 프로그램이 기본 Y'CbCr encoding 변경을 시도할 수 있음
`V4L2_FMT_FLAG_CSC_HSV_ENC``0x0080`캡처 장치에서 응용 프로그램이 기본 HSV encoding 변경을 시도할 수 있음
`V4L2_FMT_FLAG_CSC_QUANTIZATION``0x0100`캡처 장치에서 응용 프로그램이 기본 quantization 변경을 시도할 수 있음
`V4L2_FMT_FLAG_META_LINE_BASED``0x0200`line-based metadata 형식. `v4l2_meta_format`의 width, height, bytesperline이 유효
`V4L2_FMTDESC_FLAG_ENUM_ALL``0x80000000`현재 설정된 구성을 고려하지 않고 가능한 모든 pixel format을 열거

`flags`가 나타내는 압축, 코덱, 색 공간, 메타데이터 및 열거 특성입니다.

`V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM`과 `V4L2_FMT_FLAG_DYN_RESOLUTION`은 압축 형식에만 적용되므로 `V4L2_FMT_FLAG_COMPRESSED`와 함께 사용하며, 전자는 stateful decoder에만, 후자는 stateful codec에만 유효합니다.

`V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL`도 압축 형식의 stateful encoder에만 유효합니다. `VIDIOC_S_PARM`으로 OUTPUT raw frame interval을 설정하면 CAPTURE coded frame interval도 같은 값이 되지만, 이 플래그가 있으면 이후 CAPTURE 값을 다르게 설정할 수 있습니다. 오프라인 인코딩에서는 OUTPUT 값이 하드웨어 자원 예약 힌트이고 CAPTURE 값이 인코딩 스트림에 기록되는 실제 frame rate가 됩니다.

색 변환 관련 네 플래그는 캡처 장치에서만 의미가 있습니다. 응용 프로그램은 `V4L2_PIX_FMT_FLAG_SET_CSC`를 설정한 `VIDIOC_S_FMT` 호출로 colorspace, transfer function, Y'CbCr 또는 HSV encoding, quantization의 기본값 변경을 요청할 수 있으며, 플래그는 드라이버가 그 시도를 허용함을 나타냅니다.

`V4L2_FMT_FLAG_META_LINE_BASED`가 있으면 버퍼는 `height`개의 줄로 구성되고 각 줄에는 `width`개의 Data Unit이 있습니다. 연속한 두 줄 시작점 사이의 바이트 오프셋은 `bytesperline`입니다.

`V4L2_FMTDESC_FLAG_ENUM_ALL`을 지원하지 않는 드라이버는 이 비트를 지우지 않고 `EINVAL`을 반환합니다. 이 플래그는 플래그 유무에 따라 서로 다른 형식 목록을 실제로 반환할 수 있는 드라이버에서만 사용해야 합니다.


    * - ``V4L2_FMT_FLAG_COMPRESSED``
      - 0x0001
      - This is a compressed format.
    * - ``V4L2_FMT_FLAG_EMULATED``
      - 0x0002
      - This format is not native to the device but emulated through
	software (usually libv4l2), where possible try to use a native
	format instead for better performance.
    * - ``V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM``
      - 0x0004
      - The hardware decoder for this compressed bytestream format (aka coded
	format) is capable of parsing a continuous bytestream. Applications do
	not need to parse the bytestream themselves to find the boundaries
	between frames/fields.

	This flag can only be used in combination with the
	``V4L2_FMT_FLAG_COMPRESSED`` flag, since this applies to compressed
	formats only. This flag is valid for stateful decoders only.
    * - ``V4L2_FMT_FLAG_DYN_RESOLUTION``
      - 0x0008
      - Dynamic resolution switching is supported by the device for this
	compressed bytestream format (aka coded format). It will notify the user
	via the event ``V4L2_EVENT_SOURCE_CHANGE`` when changes in the video
	parameters are detected.

	This flag can only be used in combination with the
	``V4L2_FMT_FLAG_COMPRESSED`` flag, since this applies to
	compressed formats only. This flag is valid for stateful codecs only.
    * - ``V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL``
      - 0x0010
      - The hardware encoder supports setting the ``CAPTURE`` coded frame
	interval separately from the ``OUTPUT`` raw frame interval.
	Setting the ``OUTPUT`` raw frame interval with :ref:`VIDIOC_S_PARM <VIDIOC_G_PARM>`
	also sets the ``CAPTURE`` coded frame interval to the same value.
	If this flag is set, then the ``CAPTURE`` coded frame interval can be
	set to a different value afterwards. This is typically used for
	offline encoding where the ``OUTPUT`` raw frame interval is used as
	a hint for reserving hardware encoder resources and the ``CAPTURE`` coded
	frame interval is the actual frame rate embedded in the encoded video
	stream.

	This flag can only be used in combination with the
	``V4L2_FMT_FLAG_COMPRESSED`` flag, since this applies to
        compressed formats only. This flag is valid for stateful encoders only.
    * - ``V4L2_FMT_FLAG_CSC_COLORSPACE``
      - 0x0020
      - The driver allows the application to try to change the default
	colorspace. This flag is relevant only for capture devices.
	The application can ask to configure the colorspace of the capture device
	when calling the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl with
	:ref:`V4L2_PIX_FMT_FLAG_SET_CSC <v4l2-pix-fmt-flag-set-csc>` set.
    * - ``V4L2_FMT_FLAG_CSC_XFER_FUNC``
      - 0x0040
      - The driver allows the application to try to change the default
	transfer function. This flag is relevant only for capture devices.
	The application can ask to configure the transfer function of the capture
	device when calling the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl with
	:ref:`V4L2_PIX_FMT_FLAG_SET_CSC <v4l2-pix-fmt-flag-set-csc>` set.
    * - ``V4L2_FMT_FLAG_CSC_YCBCR_ENC``
      - 0x0080
      - The driver allows the application to try to change the default
	Y'CbCr encoding. This flag is relevant only for capture devices.
	The application can ask to configure the Y'CbCr encoding of the capture device
	when calling the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl with
	:ref:`V4L2_PIX_FMT_FLAG_SET_CSC <v4l2-pix-fmt-flag-set-csc>` set.
    * - ``V4L2_FMT_FLAG_CSC_HSV_ENC``
      - 0x0080
      - The driver allows the application to try to change the default
	HSV encoding. This flag is relevant only for capture devices.
	The application can ask to configure the HSV encoding of the capture device
	when calling the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl with
	:ref:`V4L2_PIX_FMT_FLAG_SET_CSC <v4l2-pix-fmt-flag-set-csc>` set.
    * - ``V4L2_FMT_FLAG_CSC_QUANTIZATION``
      - 0x0100
      - The driver allows the application to try to change the default
	quantization. This flag is relevant only for capture devices.
	The application can ask to configure the quantization of the capture
	device when calling the :ref:`VIDIOC_S_FMT <VIDIOC_G_FMT>` ioctl with
	:ref:`V4L2_PIX_FMT_FLAG_SET_CSC <v4l2-pix-fmt-flag-set-csc>` set.
    * - ``V4L2_FMT_FLAG_META_LINE_BASED``
      - 0x0200
      - The metadata format is line-based. In this case the ``width``,
	``height`` and ``bytesperline`` fields of :c:type:`v4l2_meta_format` are
	valid. The buffer consists of ``height`` lines, each having ``width``
	Data Units of data and the offset (in bytes) between the beginning of
	each two consecutive lines is ``bytesperline``.
    * - ``V4L2_FMTDESC_FLAG_ENUM_ALL``
      - 0x80000000
      - When the applications ORs ``index`` with ``V4L2_FMTDESC_FLAG_ENUM_ALL`` flag
        the driver enumerates all the possible pixel formats without taking care
        of any already set configuration. Drivers which do not support this flag,

반환값과 EINVAL 조건

252-266

성공하면 0을 반환합니다. 실패하면 -1을 반환하고 `errno`를 적절한 값으로 설정하며, 공통 오류는 Generic Error Codes 장의 정의를 따릅니다.

VIDIOC_ENUM_FMT 오류
errno조건
`EINVAL``v4l2_fmtdesc.type`을 지원하지 않거나 `index`가 범위를 벗어남
`EINVAL``V4L2_CAP_IO_MC`가 설정된 장치에서 지정한 `mbus_code`를 지원하지 않음

열거가 끝났거나 요청 조건을 지원하지 않을 때의 오류입니다.

        always return ``EINVAL`` without clearing this flag.

Return Value
============

On success 0 is returned, on error -1 and the ``errno`` variable is set
appropriately. The generic error codes are described at the
:ref:`Generic Error Codes <gen-errors>` chapter.

EINVAL
    The struct :c:type:`v4l2_fmtdesc` ``type`` is not
    supported or the ``index`` is out of bounds.

    If ``V4L2_CAP_IO_MC`` is set and the specified ``mbus_code``
    is unsupported, then also return this error code.