← Documents Documentation/userspace-api/media/v4l/pixfmt-v4l2.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API / Media / V4L

V4L2 단일 평면 포맷 구조체

영상 크기와 버퍼 배치, 확장 색도 필드, 포맷 플래그의 협상 규칙을 설명합니다.

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

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

1. 요약·해설

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

요약·해설

pixfmt-v4l2.rst:1-240

영상 크기와 버퍼 배치, 확장 색도 필드, 포맷 플래그의 협상 규칙을 설명합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2
3 ******************************
4 Single-planar format structure
5 ******************************
6
7 .. tabularcolumns:: |p{4.0cm}|p{2.6cm}|p{10.7cm}|
8
9 .. c:type:: v4l2_pix_format
10
11 .. cssclass:: longtable
12
13 .. flat-table:: struct v4l2_pix_format
14 :header-rows: 0
15 :stub-columns: 0
16 :widths: 1 1 2
17
18 * - __u32
19 - ``width``
20 - Image width in pixels.
21 * - __u32
22 - ``height``
23 - Image height in pixels. If ``field`` is one of ``V4L2_FIELD_TOP``,
24 ``V4L2_FIELD_BOTTOM`` or ``V4L2_FIELD_ALTERNATE`` then height
25 refers to the number of lines in the field, otherwise it refers to
26 the number of lines in the frame (which is twice the field height
27 for interlaced formats).
28 * - :cspan:`2` Applications set these fields to request an image
29 size, drivers return the closest possible values. In case of
30 planar formats the ``width`` and ``height`` applies to the largest
31 plane. To avoid ambiguities drivers must return values rounded up
32 to a multiple of the scale factor of any smaller planes. For
33 example when the image format is YUV 4:2:0, ``width`` and
34 ``height`` must be multiples of two.
35
36 For compressed formats that contain the resolution information encoded
37 inside the stream, when fed to a stateful mem2mem decoder, the fields
38 may be zero to rely on the decoder to detect the right values. For more
39 details see :ref:`decoder` and format descriptions.
40
41 For compressed formats on the CAPTURE side of a stateful mem2mem
42 encoder, the fields must be zero, since the coded size is expected to
43 be calculated internally by the encoder itself, based on the OUTPUT
44 side. For more details see :ref:`encoder` and format descriptions.
45 * - __u32
46 - ``pixelformat``
47 - The pixel format or type of compression, set by the application.
48 This is a little endian
49 :ref:`four character code <v4l2-fourcc>`. V4L2 defines standard
50 RGB formats in :ref:`pixfmt-rgb`, YUV formats in
51 :ref:`yuv-formats`, and reserved codes in
52 :ref:`reserved-formats`
53 * - __u32
54 - ``field``
55 - Field order, from enum :c:type:`v4l2_field`.
56 Video images are typically interlaced. Applications can request to
57 capture or output only the top or bottom field, or both fields
58 interlaced or sequentially stored in one buffer or alternating in
59 separate buffers. Drivers return the actual field order selected.
60 For more details on fields see :ref:`field-order`.
61 * - __u32
62 - ``bytesperline``
63 - Distance in bytes between the leftmost pixels in two adjacent
64 lines.
65 * - :cspan:`2`
66
67 Both applications and drivers can set this field to request
68 padding bytes at the end of each line. Drivers however may ignore
69 the value requested by the application, returning ``width`` times
70 bytes per pixel or a larger value required by the hardware. That
71 implies applications can just set this field to zero to get a
72 reasonable default.
73
74 Video hardware may access padding bytes, therefore they must
75 reside in accessible memory. Consider cases where padding bytes
76 after the last line of an image cross a system page boundary.
77 Input devices may write padding bytes, the value is undefined.
78 Output devices ignore the contents of padding bytes.
79
80 When the image format is planar the ``bytesperline`` value applies
81 to the first plane and is divided by the same factor as the
82 ``width`` field for the other planes. For example the Cb and Cr
83 planes of a YUV 4:2:0 image have half as many padding bytes
84 following each line as the Y plane. To avoid ambiguities drivers
85 must return a ``bytesperline`` value rounded up to a multiple of
86 the scale factor.
87
88 For compressed formats the ``bytesperline`` value makes no sense.
89 Applications and drivers must set this to 0 in that case.
90 * - __u32
91 - ``sizeimage``
92 - Size in bytes of the buffer to hold a complete image, set by the
93 driver. Usually this is ``bytesperline`` times ``height``. When
94 the image consists of variable length compressed data this is the
95 number of bytes required by the codec to support the worst-case
96 compression scenario.
97
98 The driver will set the value for uncompressed images.
99
100 Clients are allowed to set the sizeimage field for variable length
101 compressed data flagged with ``V4L2_FMT_FLAG_COMPRESSED`` at
102 :ref:`VIDIOC_ENUM_FMT`, but the driver may ignore it and set the
103 value itself, or it may modify the provided value based on
104 alignment requirements or minimum/maximum size requirements.
105 If the client wants to leave this to the driver, then it should
106 set sizeimage to 0.
107 * - __u32
108 - ``colorspace``
109 - Image colorspace, from enum :c:type:`v4l2_colorspace`.
110 This information supplements the ``pixelformat`` and must be set
111 by the driver for capture streams and by the application for
112 output streams, see :ref:`colorspaces`. If the application sets the
113 flag ``V4L2_PIX_FMT_FLAG_SET_CSC`` then the application can set
114 this field for a capture stream to request a specific colorspace
115 for the captured image data. If the driver cannot handle requested
116 conversion, it will return another supported colorspace.
117 The driver indicates that colorspace conversion is supported by setting
118 the flag V4L2_FMT_FLAG_CSC_COLORSPACE in the corresponding struct
119 :c:type:`v4l2_fmtdesc` during enumeration. See :ref:`fmtdesc-flags`.
120 * - __u32
121 - ``priv``
122 - This field indicates whether the remaining fields of the
123 struct :c:type:`v4l2_pix_format`, also called the
124 extended fields, are valid. When set to
125 ``V4L2_PIX_FMT_PRIV_MAGIC``, it indicates that the extended fields
126 have been correctly initialized. When set to any other value it
127 indicates that the extended fields contain undefined values.
128
129 Applications that wish to use the pixel format extended fields
130 must first ensure that the feature is supported by querying the
131 device for the :ref:`V4L2_CAP_EXT_PIX_FORMAT <querycap>`
132 capability. If the capability isn't set the pixel format extended
133 fields are not supported and using the extended fields will lead
134 to undefined results.
135
136 To use the extended fields, applications must set the ``priv``
137 field to ``V4L2_PIX_FMT_PRIV_MAGIC``, initialize all the extended
138 fields and zero the unused bytes of the
139 struct :c:type:`v4l2_format` ``raw_data`` field.
140
141 When the ``priv`` field isn't set to ``V4L2_PIX_FMT_PRIV_MAGIC``
142 drivers must act as if all the extended fields were set to zero.
143 On return drivers must set the ``priv`` field to
144 ``V4L2_PIX_FMT_PRIV_MAGIC`` and all the extended fields to
145 applicable values.
146 * - __u32
147 - ``flags``
148 - Flags set by the application or driver, see :ref:`format-flags`.
149 * - union {
150 - (anonymous)
151 * - __u32
152 - ``ycbcr_enc``
153 - Y'CbCr encoding, from enum :c:type:`v4l2_ycbcr_encoding`.
154 This information supplements the ``colorspace`` and must be set by
155 the driver for capture streams and by the application for output
156 streams, see :ref:`colorspaces`. If the application sets the
157 flag ``V4L2_PIX_FMT_FLAG_SET_CSC`` then the application can set
158 this field for a capture stream to request a specific Y'CbCr encoding
159 for the captured image data. If the driver cannot handle requested
160 conversion, it will return another supported encoding.
161 This field is ignored for HSV pixelformats. The driver indicates that
162 ycbcr_enc conversion is supported by setting the flag
163 V4L2_FMT_FLAG_CSC_YCBCR_ENC in the corresponding struct
164 :c:type:`v4l2_fmtdesc` during enumeration. See :ref:`fmtdesc-flags`.
165 * - __u32
166 - ``hsv_enc``
167 - HSV encoding, from enum :c:type:`v4l2_hsv_encoding`.
168 This information supplements the ``colorspace`` and must be set by
169 the driver for capture streams and by the application for output
170 streams, see :ref:`colorspaces`. If the application sets the flag
171 ``V4L2_PIX_FMT_FLAG_SET_CSC`` then the application can set this
172 field for a capture stream to request a specific HSV encoding for the
173 captured image data. If the driver cannot handle requested
174 conversion, it will return another supported encoding.
175 This field is ignored for non-HSV pixelformats. The driver indicates
176 that hsv_enc conversion is supported by setting the flag
177 V4L2_FMT_FLAG_CSC_HSV_ENC in the corresponding struct
178 :c:type:`v4l2_fmtdesc` during enumeration. See :ref:`fmtdesc-flags`.
179 * - }
180 -
181 * - __u32
182 - ``quantization``
183 - Quantization range, from enum :c:type:`v4l2_quantization`.
184 This information supplements the ``colorspace`` and must be set by
185 the driver for capture streams and by the application for output
186 streams, see :ref:`colorspaces`. If the application sets the flag
187 ``V4L2_PIX_FMT_FLAG_SET_CSC`` then the application can set
188 this field for a capture stream to request a specific quantization
189 range for the captured image data. If the driver cannot handle requested
190 conversion, it will return another supported quantization.
191 The driver indicates that quantization conversion is supported by setting
192 the flag V4L2_FMT_FLAG_CSC_QUANTIZATION in the corresponding struct
193 :c:type:`v4l2_fmtdesc` during enumeration. See :ref:`fmtdesc-flags`.
194 * - __u32
195 - ``xfer_func``
196 - Transfer function, from enum :c:type:`v4l2_xfer_func`.
197 This information supplements the ``colorspace`` and must be set by
198 the driver for capture streams and by the application for output
199 streams, see :ref:`colorspaces`. If the application sets the flag
200 ``V4L2_PIX_FMT_FLAG_SET_CSC`` then the application can set
201 this field for a capture stream to request a specific transfer function
202 for the captured image data. If the driver cannot handle requested
203 conversion, it will return another supported transfer function.
204 The driver indicates that xfer_func conversion is supported by setting
205 the flag V4L2_FMT_FLAG_CSC_XFER_FUNC in the corresponding struct
206 :c:type:`v4l2_fmtdesc` during enumeration. See :ref:`fmtdesc-flags`.
207
208 .. tabularcolumns:: |p{6.8cm}|p{2.3cm}|p{8.2cm}|
209
210 .. _format-flags:
211
212 .. flat-table:: Format Flags
213 :header-rows: 0
214 :stub-columns: 0
215 :widths: 3 1 4
216
217 * - ``V4L2_PIX_FMT_FLAG_PREMUL_ALPHA``
218 - 0x00000001
219 - The color values are premultiplied by the alpha channel value. For
220 example, if a light blue pixel with 50% transparency was described
221 by RGBA values (128, 192, 255, 128), the same pixel described with
222 premultiplied colors would be described by RGBA values (64, 96,
223 128, 128)
224 * .. _`v4l2-pix-fmt-flag-set-csc`:
225
226 - ``V4L2_PIX_FMT_FLAG_SET_CSC``
227 - 0x00000002
228 - Set by the application. It is only used for capture and is
229 ignored for output streams. If set, then request the device to do
230 colorspace conversion from the received colorspace to the requested
231 colorspace values. If the colorimetry field (``colorspace``, ``xfer_func``,
232 ``ycbcr_enc``, ``hsv_enc`` or ``quantization``) is set to ``*_DEFAULT``,
233 then that colorimetry setting will remain unchanged from what was received.
234 So in order to change the quantization, only the ``quantization`` field shall
235 be set to non default value (``V4L2_QUANTIZATION_FULL_RANGE`` or
236 ``V4L2_QUANTIZATION_LIM_RANGE``) and all other colorimetry fields shall
237 be set to ``*_DEFAULT``.
238
239 To check which conversions are supported by the hardware for the current
240 pixel format, see :ref:`fmtdesc-flags`.
241

3. 한국어 전문 번역

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

영상 크기, 픽셀 포맷, 필드 순서

1-60

`v4l2_pix_format`은 단일 평면 영상의 크기, 저장 방식, 버퍼 크기와 색도 정보를 기술합니다. 애플리케이션은 희망 값을 요청하고 드라이버는 하드웨어가 지원하는 가장 가까운 실제 값을 돌려줍니다.

기본 영상 속성
항목한국어 설명
`__u32 width`픽셀 단위 영상 너비입니다.
`__u32 height`픽셀 단위 영상 높이입니다. `field`가 `V4L2_FIELD_TOP`, `V4L2_FIELD_BOTTOM`, `V4L2_FIELD_ALTERNATE` 중 하나이면 한 필드의 행 수를 뜻합니다. 그 밖에는 프레임의 행 수이며, 인터레이스 포맷에서는 필드 높이의 두 배입니다.
크기 협상애플리케이션이 크기를 요청하면 드라이버가 가장 가까운 값을 반환합니다. 평면형 포맷에서는 가장 큰 평면을 기준으로 하며, 작은 평면의 축소 비율에 맞는 배수로 올림해야 합니다. 예를 들어 YUV 4:2:0의 너비와 높이는 2의 배수여야 합니다.
상태 유지형 디코더해상도 정보가 압축 스트림 안에 있는 포맷을 상태 유지형 mem2mem 디코더에 넣을 때는, 디코더가 값을 감지하도록 너비와 높이를 0으로 둘 수 있습니다.
상태 유지형 인코더CAPTURE 쪽 압축 포맷의 너비와 높이는 0이어야 합니다. 코딩된 크기는 OUTPUT 쪽을 바탕으로 인코더가 내부에서 계산합니다.
`__u32 pixelformat`애플리케이션이 설정하는 픽셀 포맷 또는 압축 종류입니다. 리틀 엔디언 FourCC이며 표준 RGB, YUV 및 예약 포맷 코드를 사용합니다.
`__u32 field``v4l2_field` 열거형의 필드 순서입니다. 위·아래 필드 하나만, 한 버퍼에서 인터레이스 또는 순차 저장한 두 필드, 서로 다른 버퍼에 번갈아 저장한 필드를 요청할 수 있습니다. 드라이버는 실제로 선택한 순서를 반환합니다.

`width`와 `height`는 평면 축소 비율과 필드 저장 방식까지 반영해야 합니다.

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

******************************
Single-planar format structure
******************************

.. tabularcolumns:: |p{4.0cm}|p{2.6cm}|p{10.7cm}|

.. c:type:: v4l2_pix_format

.. cssclass:: longtable

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

    * - __u32
      - ``width``
      - Image width in pixels.
    * - __u32
      - ``height``
      - Image height in pixels. If ``field`` is one of ``V4L2_FIELD_TOP``,
	``V4L2_FIELD_BOTTOM`` or ``V4L2_FIELD_ALTERNATE`` then height
	refers to the number of lines in the field, otherwise it refers to
	the number of lines in the frame (which is twice the field height
	for interlaced formats).
    * - :cspan:`2` Applications set these fields to request an image
	size, drivers return the closest possible values. In case of
	planar formats the ``width`` and ``height`` 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, ``width`` and
	``height`` must be multiples of two.

	For compressed formats that contain the resolution information encoded
	inside the stream, when fed to a stateful mem2mem decoder, the fields
	may be zero to rely on the decoder to detect the right values. For more
	details see :ref:`decoder` and format descriptions.

	For compressed formats on the CAPTURE side of a stateful mem2mem
	encoder, the fields must be zero, since the coded size is expected to
	be calculated internally by the encoder itself, based on the OUTPUT
	side. For more details see :ref:`encoder` and format descriptions.
    * - __u32
      - ``pixelformat``
      - The pixel format or type of compression, set by the application.
	This is a little endian
	:ref:`four character code <v4l2-fourcc>`. V4L2 defines standard
	RGB formats in :ref:`pixfmt-rgb`, YUV formats in
	:ref:`yuv-formats`, and reserved codes in
	:ref:`reserved-formats`
    * - __u32
      - ``field``
      - Field order, from enum :c:type:`v4l2_field`.
        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 more details on fields see :ref:`field-order`.

행 간격, 버퍼 크기, 색공간

61-119
버퍼 배치와 색공간
필드 또는 조건한국어 설명
`__u32 bytesperline`인접한 두 행의 가장 왼쪽 픽셀 사이 거리입니다. 애플리케이션과 드라이버 모두 행 끝 패딩을 요청할 수 있지만 드라이버는 요청을 무시하고 `width × 픽셀당 바이트 수` 또는 하드웨어가 요구하는 더 큰 값을 반환할 수 있습니다. 애플리케이션은 0을 설정해 합리적인 기본값을 받을 수 있습니다.
패딩 메모리영상 하드웨어가 패딩 바이트에도 접근할 수 있으므로 패딩은 실제 접근 가능한 메모리에 있어야 합니다. 특히 마지막 행 뒤 패딩이 시스템 페이지 경계를 넘는 경우를 고려해야 합니다. 입력 장치는 정의되지 않은 값을 패딩에 쓸 수 있고, 출력 장치는 패딩 내용을 무시합니다.
평면형 행 간격`bytesperline`은 첫 번째 평면에 적용하며 다른 평면에서는 `width`와 같은 축소 비율로 나눕니다. YUV 4:2:0의 Cb·Cr 평면은 Y 평면의 절반만큼 행 끝 패딩을 둡니다. 드라이버는 축소 비율의 배수로 올림한 값을 반환해야 합니다.
압축 포맷 행 간격압축 포맷에는 행 간격이 의미가 없으므로 애플리케이션과 드라이버 모두 0으로 설정해야 합니다.
`__u32 sizeimage`완전한 영상 하나를 담는 버퍼 크기이며 드라이버가 설정합니다. 보통 `bytesperline × height`입니다. 가변 길이 압축 데이터라면 최악의 압축 상황을 지원하는 크기입니다. 비압축 영상은 드라이버가 정합니다. 압축 플래그가 있는 포맷은 클라이언트가 제안할 수 있지만 드라이버가 무시하거나 정렬 및 최소·최대 조건에 맞춰 바꿀 수 있습니다. 드라이버에 맡기려면 0을 설정합니다.
`__u32 colorspace``v4l2_colorspace` 열거형의 영상 색공간으로 `pixelformat`을 보충합니다. 캡처 스트림은 드라이버가, 출력 스트림은 애플리케이션이 설정합니다. 캡처에서 `V4L2_PIX_FMT_FLAG_SET_CSC`를 지정하면 특정 색공간으로 변환해 달라고 요청할 수 있습니다. 요청을 처리할 수 없으면 드라이버가 지원 가능한 다른 색공간을 반환합니다. 지원 여부는 열거 중 `V4L2_FMT_FLAG_CSC_COLORSPACE`로 알립니다.

메모리 접근 범위와 압축 포맷의 예외를 함께 확인해야 합니다.

    * - __u32
      - ``bytesperline``
      - Distance in bytes between the leftmost pixels in two adjacent
	lines.
    * - :cspan:`2`

	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 ``width`` 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.

	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.

	When the image format is planar the ``bytesperline`` value applies
	to the first plane and is divided by the same factor as the
	``width`` field for the other 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 ``bytesperline`` value rounded up to a multiple of
	the scale factor.

	For compressed formats the ``bytesperline`` value makes no sense.
	Applications and drivers must set this to 0 in that case.
    * - __u32
      - ``sizeimage``
      - Size in bytes of the buffer to hold a complete image, set by the
	driver. Usually this is ``bytesperline`` times ``height``. When
	the image consists of variable length compressed data this is the
	number of bytes required by the codec to support the worst-case
	compression scenario.

	The driver will set the value for uncompressed images.

	Clients are allowed to set the sizeimage field for variable length
	compressed data flagged with ``V4L2_FMT_FLAG_COMPRESSED`` at
	:ref:`VIDIOC_ENUM_FMT`, but the driver may ignore it and set the
	value itself, or it may modify the provided value based on
	alignment requirements or minimum/maximum size requirements.
	If the client wants to leave this to the driver, then it should
	set sizeimage to 0.
    * - __u32
      - ``colorspace``
      - Image colorspace, from enum :c:type:`v4l2_colorspace`.
        This information supplements the ``pixelformat`` and must be set
	by the driver for capture streams and by the application for
	output streams, see :ref:`colorspaces`. If the application sets the
	flag ``V4L2_PIX_FMT_FLAG_SET_CSC`` then the application can set
	this field for a capture stream to request a specific colorspace
	for the captured image data. If the driver cannot handle requested
	conversion, it will return another supported colorspace.
	The driver indicates that colorspace conversion is supported by setting
	the flag V4L2_FMT_FLAG_CSC_COLORSPACE in the corresponding struct
	:c:type:`v4l2_fmtdesc` during enumeration. See :ref:`fmtdesc-flags`.

확장 필드와 색도 정보

120-207

`priv` 뒤의 항목은 확장 필드입니다. 기능 지원을 확인하고 매직 값을 설정한 뒤 모든 확장 필드와 사용하지 않는 원시 데이터 바이트를 초기화해야만 정의된 결과를 얻을 수 있습니다.

확장 필드
필드한국어 설명
`__u32 priv``V4L2_PIX_FMT_PRIV_MAGIC`이면 나머지 확장 필드가 올바르게 초기화되었음을 뜻합니다. 다른 값이면 확장 필드는 정의되지 않은 값을 담고 있습니다. 먼저 `V4L2_CAP_EXT_PIX_FORMAT` 기능을 조회해야 하며, 지원하지 않는 장치에서 확장 필드를 사용하면 결과가 정의되지 않습니다.
초기화 계약애플리케이션은 `priv`에 매직 값을 쓰고 모든 확장 필드를 초기화하며 `v4l2_format.raw_data`의 사용하지 않는 바이트를 0으로 만들어야 합니다. 매직 값이 아니면 드라이버는 모든 확장 필드가 0인 것처럼 처리해야 합니다. 반환할 때 드라이버는 매직 값과 적용 가능한 확장 필드 값을 채웁니다.
`__u32 flags`애플리케이션 또는 드라이버가 설정하는 포맷 플래그입니다.
`__u32 ycbcr_enc`익명 공용체의 `v4l2_ycbcr_encoding` 값입니다. 캡처는 드라이버가, 출력은 애플리케이션이 설정합니다. 캡처의 CSC 요청을 처리할 수 없으면 지원하는 다른 인코딩을 반환합니다. HSV 픽셀 포맷에서는 무시하며, 변환 지원은 `V4L2_FMT_FLAG_CSC_YCBCR_ENC`로 알립니다.
`__u32 hsv_enc`익명 공용체의 `v4l2_hsv_encoding` 값입니다. 캡처·출력 방향과 CSC 대체 규칙은 `ycbcr_enc`와 같습니다. HSV가 아닌 픽셀 포맷에서는 무시하며, 지원은 `V4L2_FMT_FLAG_CSC_HSV_ENC`로 알립니다.
`__u32 quantization``v4l2_quantization` 열거형의 양자화 범위입니다. 캡처는 드라이버가, 출력은 애플리케이션이 설정합니다. CSC 요청을 처리할 수 없으면 지원하는 다른 양자화 값을 반환하며, 지원은 `V4L2_FMT_FLAG_CSC_QUANTIZATION`으로 알립니다.
`__u32 xfer_func``v4l2_xfer_func` 열거형의 전달 함수입니다. 캡처·출력 방향과 CSC 대체 규칙이 동일하며, 지원은 `V4L2_FMT_FLAG_CSC_XFER_FUNC`로 알립니다.

색도 변환 요청은 캡처 스트림에서만 `V4L2_PIX_FMT_FLAG_SET_CSC`와 함께 사용합니다.

확장 필드 사용 절차
`V4L2_CAP_EXT_PIX_FORMAT` 지원 여부를 조회합니다.`priv = V4L2_PIX_FMT_PRIV_MAGIC`으로 설정하고 모든 확장 필드를 초기화합니다.`v4l2_format.raw_data`에서 사용하지 않는 바이트를 0으로 만듭니다.호출 뒤 드라이버가 반환한 매직 값과 실제 적용 값을 확인합니다.

초기화 여부를 `priv` 하나로 추측하지 말고 장치 기능부터 확인합니다.

    * - __u32
      - ``priv``
      - This field indicates whether the remaining fields of the
	struct :c:type:`v4l2_pix_format`, also called the
	extended fields, are valid. When set to
	``V4L2_PIX_FMT_PRIV_MAGIC``, it indicates that the extended fields
	have been correctly initialized. When set to any other value it
	indicates that the extended fields contain undefined values.

	Applications that wish to use the pixel format extended fields
	must first ensure that the feature is supported by querying the
	device for the :ref:`V4L2_CAP_EXT_PIX_FORMAT <querycap>`
	capability. If the capability isn't set the pixel format extended
	fields are not supported and using the extended fields will lead
	to undefined results.

	To use the extended fields, applications must set the ``priv``
	field to ``V4L2_PIX_FMT_PRIV_MAGIC``, initialize all the extended
	fields and zero the unused bytes of the
	struct :c:type:`v4l2_format` ``raw_data`` field.

	When the ``priv`` field isn't set to ``V4L2_PIX_FMT_PRIV_MAGIC``
	drivers must act as if all the extended fields were set to zero.
	On return drivers must set the ``priv`` field to
	``V4L2_PIX_FMT_PRIV_MAGIC`` and all the extended fields to
	applicable values.
    * - __u32
      - ``flags``
      - Flags set by the application or driver, see :ref:`format-flags`.
    * - union {
      - (anonymous)
    * - __u32
      - ``ycbcr_enc``
      - Y'CbCr encoding, from enum :c:type:`v4l2_ycbcr_encoding`.
        This information supplements the ``colorspace`` and must be set by
	the driver for capture streams and by the application for output
	streams, see :ref:`colorspaces`. If the application sets the
	flag ``V4L2_PIX_FMT_FLAG_SET_CSC`` then the application can set
	this field for a capture stream to request a specific Y'CbCr encoding
	for the captured image data. If the driver cannot handle requested
	conversion, it will return another supported encoding.
	This field is ignored for HSV pixelformats. The driver indicates that
	ycbcr_enc conversion is supported by setting the flag
	V4L2_FMT_FLAG_CSC_YCBCR_ENC in the corresponding struct
	:c:type:`v4l2_fmtdesc` during enumeration. See :ref:`fmtdesc-flags`.
    * - __u32
      - ``hsv_enc``
      - HSV encoding, from enum :c:type:`v4l2_hsv_encoding`.
        This information supplements the ``colorspace`` and must be set by
	the driver for capture streams and by the application for output
	streams, see :ref:`colorspaces`. If the application sets the flag
	``V4L2_PIX_FMT_FLAG_SET_CSC`` then the application can set this
	field for a capture stream to request a specific HSV encoding for the
	captured image data. If the driver cannot handle requested
	conversion, it will return another supported encoding.
	This field is ignored for non-HSV pixelformats. The driver indicates
	that hsv_enc conversion is supported by setting the flag
	V4L2_FMT_FLAG_CSC_HSV_ENC in the corresponding struct
	:c:type:`v4l2_fmtdesc` during enumeration. See :ref:`fmtdesc-flags`.
    * - }
      -
    * - __u32
      - ``quantization``
      - Quantization range, from enum :c:type:`v4l2_quantization`.
        This information supplements the ``colorspace`` and must be set by
	the driver for capture streams and by the application for output
	streams, see :ref:`colorspaces`. If the application sets the flag
	``V4L2_PIX_FMT_FLAG_SET_CSC`` then the application can set
	this field for a capture stream to request a specific quantization
	range for the captured image data. If the driver cannot handle requested
	conversion, it will return another supported quantization.
	The driver indicates that quantization conversion is supported by setting
	the flag V4L2_FMT_FLAG_CSC_QUANTIZATION in the corresponding struct
	:c:type:`v4l2_fmtdesc` during enumeration. See :ref:`fmtdesc-flags`.
    * - __u32
      - ``xfer_func``
      - Transfer function, from enum :c:type:`v4l2_xfer_func`.
        This information supplements the ``colorspace`` and must be set by
	the driver for capture streams and by the application for output
	streams, see :ref:`colorspaces`. If the application sets the flag
	``V4L2_PIX_FMT_FLAG_SET_CSC`` then the application can set
	this field for a capture stream to request a specific transfer function
	for the captured image data. If the driver cannot handle requested
	conversion, it will return another supported transfer function.
	The driver indicates that xfer_func conversion is supported by setting
	the flag V4L2_FMT_FLAG_CSC_XFER_FUNC in the corresponding struct
	:c:type:`v4l2_fmtdesc` during enumeration. See :ref:`fmtdesc-flags`.

포맷 플래그

208-240
Format Flags
플래그한국어 설명
`V4L2_PIX_FMT_FLAG_PREMUL_ALPHA``0x00000001`색상 값이 알파 채널 값으로 미리 곱해졌음을 뜻합니다. 예를 들어 50% 투명도의 밝은 파랑 RGBA `(128, 192, 255, 128)`은 사전 곱셈 형식에서 `(64, 96, 128, 128)`이 됩니다.
`V4L2_PIX_FMT_FLAG_SET_CSC``0x00000002`애플리케이션이 설정하며 캡처에서만 사용하고 출력 스트림에서는 무시합니다. 수신한 색공간에서 요청한 색도 값으로 장치가 변환하도록 요구합니다. `colorspace`, `xfer_func`, `ycbcr_enc`, `hsv_enc`, `quantization` 중 `*_DEFAULT`인 항목은 수신값을 그대로 유지합니다. 특정 항목만 바꾸려면 그 항목만 기본값이 아닌 값으로 설정합니다. 하드웨어가 현재 픽셀 포맷에서 지원하는 변환은 `fmtdesc-flags`를 확인합니다.

알파 사전 곱셈과 캡처 색공간 변환 요청을 구분합니다.

양자화만 바꾸려면 `quantization`을 `V4L2_QUANTIZATION_FULL_RANGE` 또는 `V4L2_QUANTIZATION_LIM_RANGE`로 설정하고, 다른 모든 색도 필드는 `*_DEFAULT`로 둡니다.

.. tabularcolumns:: |p{6.8cm}|p{2.3cm}|p{8.2cm}|

.. _format-flags:

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

    * - ``V4L2_PIX_FMT_FLAG_PREMUL_ALPHA``
      - 0x00000001
      - The color values are premultiplied by the alpha channel value. For
        example, if a light blue pixel with 50% transparency was described
	by RGBA values (128, 192, 255, 128), the same pixel described with
	premultiplied colors would be described by RGBA values (64, 96,
	128, 128)
    * .. _`v4l2-pix-fmt-flag-set-csc`:

      - ``V4L2_PIX_FMT_FLAG_SET_CSC``
      - 0x00000002
      - Set by the application. It is only used for capture and is
        ignored for output streams. If set, then request the device to do
	colorspace conversion from the received colorspace to the requested
	colorspace values. If the colorimetry field (``colorspace``, ``xfer_func``,
	``ycbcr_enc``, ``hsv_enc`` or ``quantization``) is set to ``*_DEFAULT``,
	then that colorimetry setting will remain unchanged from what was received.
	So in order to change the quantization, only the ``quantization`` field shall
	be set to non default value (``V4L2_QUANTIZATION_FULL_RANGE`` or
	``V4L2_QUANTIZATION_LIM_RANGE``) and all other colorimetry fields shall
	be set to ``*_DEFAULT``.

	To check which conversions are supported by the hardware for the current
	pixel format, see :ref:`fmtdesc-flags`.