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

Linux 6.18.37 · Userspace API / Media / V4L

Packed YUV 형식

4:4:4·4:2:2·4:1:1 packed YUV의 byte/word 순서와 chroma 위치를 설명합니다.

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

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

1. 요약·해설

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

요약·해설

pixfmt-packed-yuv.rst:1-482

Packed YUV는 subsampling 비율과 FourCC에 따라 Y·Cb·Cr·alpha/padding의 memory 순서를 정하며 10-bit 이상 4:2:2는 16-bit little-endian word를 사용합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2
3 .. _packed-yuv:
4
5 ******************
6 Packed YUV formats
7 ******************
8
9 Similarly to the packed RGB formats, the packed YUV formats store the Y, Cb and
10 Cr components consecutively in memory. They may apply subsampling to the chroma
11 components and thus differ in how they interlave the three components.
12
13 .. note::
14
15 - In all the tables that follow, bit 7 is the most significant bit in a byte.
16 - 'Y', 'Cb' and 'Cr' denote bits of the luma, blue chroma (also known as
17 'U') and red chroma (also known as 'V') components respectively. 'A'
18 denotes bits of the alpha component (if supported by the format), and 'X'
19 denotes padding bits.
20
21
22 4:4:4 Subsampling
23 =================
24
25 These formats do not subsample the chroma components and store each pixels as a
26 full triplet of Y, Cb and Cr values.
27
28 The next table lists the packed YUV 4:4:4 formats with less than 8 bits per
29 component. They are named based on the order of the Y, Cb and Cr components as
30 seen in a 16-bit word, which is then stored in memory in little endian byte
31 order, and on the number of bits for each component. For instance the YUV565
32 format stores a pixel in a 16-bit word [15:0] laid out at as [Y'\ :sub:`4-0`
33 Cb\ :sub:`5-0` Cr\ :sub:`4-0`], and stored in memory in two bytes,
34 [Cb\ :sub:`2-0` Cr\ :sub:`4-0`] followed by [Y'\ :sub:`4-0` Cb\ :sub:`5-3`].
35
36 .. raw:: latex
37
38 \begingroup
39 \scriptsize
40 \setlength{\tabcolsep}{2pt}
41
42 .. tabularcolumns:: |p{3.5cm}|p{0.96cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|
43
44 .. flat-table:: Packed YUV 4:4:4 Image Formats (less than 8bpc)
45 :header-rows: 2
46 :stub-columns: 0
47
48 * - Identifier
49 - Code
50
51 - :cspan:`7` Byte 0 in memory
52
53 - :cspan:`7` Byte 1
54
55 * -
56 -
57 - 7
58 - 6
59 - 5
60 - 4
61 - 3
62 - 2
63 - 1
64 - 0
65
66 - 7
67 - 6
68 - 5
69 - 4
70 - 3
71 - 2
72 - 1
73 - 0
74
75 * .. _V4L2-PIX-FMT-YUV444:
76
77 - ``V4L2_PIX_FMT_YUV444``
78 - 'Y444'
79
80 - Cb\ :sub:`3`
81 - Cb\ :sub:`2`
82 - Cb\ :sub:`1`
83 - Cb\ :sub:`0`
84 - Cr\ :sub:`3`
85 - Cr\ :sub:`2`
86 - Cr\ :sub:`1`
87 - Cr\ :sub:`0`
88
89 - a\ :sub:`3`
90 - a\ :sub:`2`
91 - a\ :sub:`1`
92 - a\ :sub:`0`
93 - Y'\ :sub:`3`
94 - Y'\ :sub:`2`
95 - Y'\ :sub:`1`
96 - Y'\ :sub:`0`
97
98 * .. _V4L2-PIX-FMT-YUV555:
99
100 - ``V4L2_PIX_FMT_YUV555``
101 - 'YUVO'
102
103 - Cb\ :sub:`2`
104 - Cb\ :sub:`1`
105 - Cb\ :sub:`0`
106 - Cr\ :sub:`4`
107 - Cr\ :sub:`3`
108 - Cr\ :sub:`2`
109 - Cr\ :sub:`1`
110 - Cr\ :sub:`0`
111
112 - a
113 - Y'\ :sub:`4`
114 - Y'\ :sub:`3`
115 - Y'\ :sub:`2`
116 - Y'\ :sub:`1`
117 - Y'\ :sub:`0`
118 - Cb\ :sub:`4`
119 - Cb\ :sub:`3`
120
121 * .. _V4L2-PIX-FMT-YUV565:
122
123 - ``V4L2_PIX_FMT_YUV565``
124 - 'YUVP'
125
126 - Cb\ :sub:`2`
127 - Cb\ :sub:`1`
128 - Cb\ :sub:`0`
129 - Cr\ :sub:`4`
130 - Cr\ :sub:`3`
131 - Cr\ :sub:`2`
132 - Cr\ :sub:`1`
133 - Cr\ :sub:`0`
134
135 - Y'\ :sub:`4`
136 - Y'\ :sub:`3`
137 - Y'\ :sub:`2`
138 - Y'\ :sub:`1`
139 - Y'\ :sub:`0`
140 - Cb\ :sub:`5`
141 - Cb\ :sub:`4`
142 - Cb\ :sub:`3`
143
144 .. raw:: latex
145
146 \endgroup
147
148 .. note::
149
150 For the YUV444 and YUV555 formats, the value of alpha bits is undefined
151 when reading from the driver, ignored when writing to the driver, except
152 when alpha blending has been negotiated for a :ref:`Video Overlay
153 <overlay>` or :ref:`Video Output Overlay <osd>`.
154
155
156 The next table lists the packed YUV 4:4:4 formats with 8 bits per component.
157 They are named based on the order of the Y, Cb and Cr components as stored in
158 memory, and on the total number of bits per pixel. For instance, the VUYX32
159 format stores a pixel with Cr\ :sub:`7-0` in the first byte, Cb\ :sub:`7-0` in
160 the second byte and Y'\ :sub:`7-0` in the third byte.
161
162 .. flat-table:: Packed YUV Image Formats (8bpc)
163 :header-rows: 1
164 :stub-columns: 0
165
166 * - Identifier
167 - Code
168 - Byte 0
169 - Byte 1
170 - Byte 2
171 - Byte 3
172
173 * .. _V4L2-PIX-FMT-YUV32:
174
175 - ``V4L2_PIX_FMT_YUV32``
176 - 'YUV4'
177
178 - A\ :sub:`7-0`
179 - Y'\ :sub:`7-0`
180 - Cb\ :sub:`7-0`
181 - Cr\ :sub:`7-0`
182
183 * .. _V4L2-PIX-FMT-AYUV32:
184
185 - ``V4L2_PIX_FMT_AYUV32``
186 - 'AYUV'
187
188 - A\ :sub:`7-0`
189 - Y'\ :sub:`7-0`
190 - Cb\ :sub:`7-0`
191 - Cr\ :sub:`7-0`
192
193 * .. _V4L2-PIX-FMT-XYUV32:
194
195 - ``V4L2_PIX_FMT_XYUV32``
196 - 'XYUV'
197
198 - X\ :sub:`7-0`
199 - Y'\ :sub:`7-0`
200 - Cb\ :sub:`7-0`
201 - Cr\ :sub:`7-0`
202
203 * .. _V4L2-PIX-FMT-VUYA32:
204
205 - ``V4L2_PIX_FMT_VUYA32``
206 - 'VUYA'
207
208 - Cr\ :sub:`7-0`
209 - Cb\ :sub:`7-0`
210 - Y'\ :sub:`7-0`
211 - A\ :sub:`7-0`
212
213 * .. _V4L2-PIX-FMT-VUYX32:
214
215 - ``V4L2_PIX_FMT_VUYX32``
216 - 'VUYX'
217
218 - Cr\ :sub:`7-0`
219 - Cb\ :sub:`7-0`
220 - Y'\ :sub:`7-0`
221 - X\ :sub:`7-0`
222
223 * .. _V4L2-PIX-FMT-YUVA32:
224
225 - ``V4L2_PIX_FMT_YUVA32``
226 - 'YUVA'
227
228 - Y'\ :sub:`7-0`
229 - Cb\ :sub:`7-0`
230 - Cr\ :sub:`7-0`
231 - A\ :sub:`7-0`
232
233 * .. _V4L2-PIX-FMT-YUVX32:
234
235 - ``V4L2_PIX_FMT_YUVX32``
236 - 'YUVX'
237
238 - Y'\ :sub:`7-0`
239 - Cb\ :sub:`7-0`
240 - Cr\ :sub:`7-0`
241 - X\ :sub:`7-0`
242
243 * .. _V4L2-PIX-FMT-YUV24:
244
245 - ``V4L2_PIX_FMT_YUV24``
246 - 'YUV3'
247
248 - Y'\ :sub:`7-0`
249 - Cb\ :sub:`7-0`
250 - Cr\ :sub:`7-0`
251 - -\
252
253 .. note::
254
255 - The alpha component is expected to contain a meaningful value that can be
256 used by drivers and applications.
257 - The padding bits contain undefined values that must be ignored by all
258 applications and drivers.
259
260 The next table lists the packed YUV 4:4:4 formats with 12 bits per component.
261 Expand the bits per component to 16 bits, data in the high bits, zeros in the low bits,
262 arranged in little endian order, storing 1 pixel in 6 bytes.
263
264 .. flat-table:: Packed YUV 4:4:4 Image Formats (12bpc)
265 :header-rows: 1
266 :stub-columns: 0
267
268 * - Identifier
269 - Code
270 - Byte 1-0
271 - Byte 3-2
272 - Byte 5-4
273 - Byte 7-6
274 - Byte 9-8
275 - Byte 11-10
276
277 * .. _V4L2-PIX-FMT-YUV48-12:
278
279 - ``V4L2_PIX_FMT_YUV48_12``
280 - 'Y312'
281
282 - Y'\ :sub:`0`
283 - Cb\ :sub:`0`
284 - Cr\ :sub:`0`
285 - Y'\ :sub:`1`
286 - Cb\ :sub:`1`
287 - Cr\ :sub:`1`
288
289 4:2:2 Subsampling
290 =================
291
292 These formats, commonly referred to as YUYV or YUY2, subsample the chroma
293 components horizontally by 2, storing 2 pixels in a container. The container
294 is 32-bits for 8-bit formats, and 64-bits for 10+-bit formats.
295
296 The packed YUYV formats with more than 8 bits per component are stored as four
297 16-bit little-endian words. Each word's most significant bits contain one
298 component, and the least significant bits are zero padding.
299
300 .. raw:: latex
301
302 \footnotesize
303
304 .. tabularcolumns:: |p{3.4cm}|p{1.2cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|
305
306 .. flat-table:: Packed YUV 4:2:2 Formats in 32-bit container
307 :header-rows: 1
308 :stub-columns: 0
309
310 * - Identifier
311 - Code
312 - Byte 0
313 - Byte 1
314 - Byte 2
315 - Byte 3
316 - Byte 4
317 - Byte 5
318 - Byte 6
319 - Byte 7
320 * .. _V4L2-PIX-FMT-UYVY:
321
322 - ``V4L2_PIX_FMT_UYVY``
323 - 'UYVY'
324
325 - Cb\ :sub:`0`
326 - Y'\ :sub:`0`
327 - Cr\ :sub:`0`
328 - Y'\ :sub:`1`
329 - Cb\ :sub:`2`
330 - Y'\ :sub:`2`
331 - Cr\ :sub:`2`
332 - Y'\ :sub:`3`
333 * .. _V4L2-PIX-FMT-VYUY:
334
335 - ``V4L2_PIX_FMT_VYUY``
336 - 'VYUY'
337
338 - Cr\ :sub:`0`
339 - Y'\ :sub:`0`
340 - Cb\ :sub:`0`
341 - Y'\ :sub:`1`
342 - Cr\ :sub:`2`
343 - Y'\ :sub:`2`
344 - Cb\ :sub:`2`
345 - Y'\ :sub:`3`
346 * .. _V4L2-PIX-FMT-YUYV:
347
348 - ``V4L2_PIX_FMT_YUYV``
349 - 'YUYV'
350
351 - Y'\ :sub:`0`
352 - Cb\ :sub:`0`
353 - Y'\ :sub:`1`
354 - Cr\ :sub:`0`
355 - Y'\ :sub:`2`
356 - Cb\ :sub:`2`
357 - Y'\ :sub:`3`
358 - Cr\ :sub:`2`
359 * .. _V4L2-PIX-FMT-YVYU:
360
361 - ``V4L2_PIX_FMT_YVYU``
362 - 'YVYU'
363
364 - Y'\ :sub:`0`
365 - Cr\ :sub:`0`
366 - Y'\ :sub:`1`
367 - Cb\ :sub:`0`
368 - Y'\ :sub:`2`
369 - Cr\ :sub:`2`
370 - Y'\ :sub:`3`
371 - Cb\ :sub:`2`
372
373 .. tabularcolumns:: |p{3.4cm}|p{1.2cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|
374
375 .. flat-table:: Packed YUV 4:2:2 Formats in 64-bit container
376 :header-rows: 1
377 :stub-columns: 0
378
379 * - Identifier
380 - Code
381 - Word 0
382 - Word 1
383 - Word 2
384 - Word 3
385 * .. _V4L2-PIX-FMT-Y210:
386
387 - ``V4L2_PIX_FMT_Y210``
388 - 'Y210'
389
390 - Y'\ :sub:`0` (bits 15-6)
391 - Cb\ :sub:`0` (bits 15-6)
392 - Y'\ :sub:`1` (bits 15-6)
393 - Cr\ :sub:`0` (bits 15-6)
394 * .. _V4L2-PIX-FMT-Y212:
395
396 - ``V4L2_PIX_FMT_Y212``
397 - 'Y212'
398
399 - Y'\ :sub:`0` (bits 15-4)
400 - Cb\ :sub:`0` (bits 15-4)
401 - Y'\ :sub:`1` (bits 15-4)
402 - Cr\ :sub:`0` (bits 15-4)
403 * .. _V4L2-PIX-FMT-Y216:
404
405 - ``V4L2_PIX_FMT_Y216``
406 - 'Y216'
407
408 - Y'\ :sub:`0` (bits 15-0)
409 - Cb\ :sub:`0` (bits 15-0)
410 - Y'\ :sub:`1` (bits 15-0)
411 - Cr\ :sub:`0` (bits 15-0)
412
413 .. raw:: latex
414
415 \normalsize
416
417 **Color Sample Location:**
418 Chroma samples are :ref:`interstitially sited<yuv-chroma-centered>`
419 horizontally.
420
421
422 4:1:1 Subsampling
423 =================
424
425 This format subsamples the chroma components horizontally by 4, storing 8
426 pixels in 12 bytes.
427
428 .. raw:: latex
429
430 \scriptsize
431
432 .. tabularcolumns:: |p{2.9cm}|p{0.8cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|
433
434 .. flat-table:: Packed YUV 4:1:1 Formats
435 :header-rows: 1
436 :stub-columns: 0
437
438 * - Identifier
439 - Code
440 - Byte 0
441 - Byte 1
442 - Byte 2
443 - Byte 3
444 - Byte 4
445 - Byte 5
446 - Byte 6
447 - Byte 7
448 - Byte 8
449 - Byte 9
450 - Byte 10
451 - Byte 11
452 * .. _V4L2-PIX-FMT-Y41P:
453
454 - ``V4L2_PIX_FMT_Y41P``
455 - 'Y41P'
456
457 - Cb\ :sub:`0`
458 - Y'\ :sub:`0`
459 - Cr\ :sub:`0`
460 - Y'\ :sub:`1`
461 - Cb\ :sub:`4`
462 - Y'\ :sub:`2`
463 - Cr\ :sub:`4`
464 - Y'\ :sub:`3`
465 - Y'\ :sub:`4`
466 - Y'\ :sub:`5`
467 - Y'\ :sub:`6`
468 - Y'\ :sub:`7`
469
470 .. raw:: latex
471
472 \normalsize
473
474 .. note::
475
476 Do not confuse ``V4L2_PIX_FMT_Y41P`` with
477 :ref:`V4L2_PIX_FMT_YUV411P <V4L2-PIX-FMT-YUV411P>`. Y41P is derived from
478 "YUV 4:1:1 **packed**", while YUV411P stands for "YUV 4:1:1 **planar**".
479
480 **Color Sample Location:**
481 Chroma samples are :ref:`interstitially sited<yuv-chroma-centered>`
482 horizontally.
483

3. 한국어 전문 번역

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

Component 표기와 packing 원칙

1-21

Packed RGB와 마찬가지로 packed YUV는 Y, Cb, Cr component를 memory에 연속 저장합니다. Chroma component에 subsampling을 적용할 수 있으므로 세 component를 interleave하는 순서와 한 chroma sample이 담당하는 luma pixel 수가 형식마다 달라집니다.

표기 규칙
항목설명
bit 7각 byte의 most significant bit
Yluma component bit
Cb / Ublue chroma component bit
Cr / Vred chroma component bit
A지원되는 경우 alpha component bit
X의미 없는 padding bit

뒤의 모든 표에서 공통으로 쓰는 bit 표기입니다.

Packed YUV 해석 순서
Subsampling 비율 확인Memory byte 순서 확인Little-endian word 형식이면 word 내부 bit 배치 복원Y와 공유 Cb/Cr sample 결합Alpha 또는 padding 처리

FourCC 하나를 실제 sample로 읽는 기준입니다.

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

.. _packed-yuv:

******************
Packed YUV formats
******************

Similarly to the packed RGB formats, the packed YUV formats store the Y, Cb and
Cr components consecutively in memory. They may apply subsampling to the chroma
components and thus differ in how they interlave the three components.

.. note::

   - In all the tables that follow, bit 7 is the most significant bit in a byte.
   - 'Y', 'Cb' and 'Cr' denote bits of the luma, blue chroma (also known as
     'U') and red chroma (also known as 'V') components respectively. 'A'
     denotes bits of the alpha component (if supported by the format), and 'X'
     denotes padding bits.

4:4:4, component당 8 bit 미만

22-153

4:4:4 형식은 chroma를 subsampling하지 않으므로 pixel마다 Y, Cb, Cr triplet 전체를 저장합니다. Component당 8 bit 미만인 형식 이름은 16-bit word에서 보이는 Y/Cb/Cr 순서와 각 bit 수를 반영하며, 완성된 word는 little-endian byte 순서로 memory에 저장됩니다.

예를 들어 YUV565의 16-bit word `[15:0]`은 `[Y'[4:0] Cb[5:0] Cr[4:0]]`이고 memory에서는 먼저 `[Cb[2:0] Cr[4:0]]`, 다음 byte에 `[Y'[4:0] Cb[5:3]]`가 옵니다.

Packed YUV 4:4:4, 16-bit memory 배치
Identifier / CodeByte 0 → Byte 1
`V4L2_PIX_FMT_YUV444` / `Y444`Byte 0=`Cb[3:0] Cr[3:0]`; Byte 1=`A[3:0] Y'[3:0]`
`V4L2_PIX_FMT_YUV555` / `YUVO`Byte 0=`Cb[2:0] Cr[4:0]`; Byte 1=`A Y'[4:0] Cb[4:3]`
`V4L2_PIX_FMT_YUV565` / `YUVP`Byte 0=`Cb[2:0] Cr[4:0]`; Byte 1=`Y'[4:0] Cb[5:3]`

Byte 0이 낮은 주소입니다.

YUV444와 YUV555를 driver에서 읽을 때 alpha bit 값은 정의되지 않고 driver에 쓸 때는 무시됩니다. 예외는 Video Overlay 또는 Video Output Overlay에서 alpha blending을 협상한 경우이며, 이때만 alpha bit가 실제 blending 값으로 쓰입니다.

Alpha bit 처리
항목설명
일반 capture readYUV444/YUV555 alpha 값은 undefined
일반 output writeDriver가 alpha 값을 무시
Overlay alpha blending 협상Alpha bit를 유효한 blending 값으로 사용

Overlay 협상 여부가 alpha 의미를 바꿉니다.

4:4:4 Subsampling
=================

These formats do not subsample the chroma components and store each pixels as a
full triplet of Y, Cb and Cr values.

The next table lists the packed YUV 4:4:4 formats with less than 8 bits per
component. They are named based on the order of the Y, Cb and Cr components as
seen in a 16-bit word, which is then stored in memory in little endian byte
order, and on the number of bits for each component. For instance the YUV565
format stores a pixel in a 16-bit word [15:0] laid out at as [Y'\ :sub:`4-0`
Cb\ :sub:`5-0` Cr\ :sub:`4-0`], and stored in memory in two bytes,
[Cb\ :sub:`2-0` Cr\ :sub:`4-0`] followed by [Y'\ :sub:`4-0` Cb\ :sub:`5-3`].

.. raw:: latex

    \begingroup
    \scriptsize
    \setlength{\tabcolsep}{2pt}

.. tabularcolumns:: |p{3.5cm}|p{0.96cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|p{0.52cm}|

.. flat-table:: Packed YUV 4:4:4 Image Formats (less than 8bpc)
    :header-rows:  2
    :stub-columns: 0

    * - Identifier
      - Code

      - :cspan:`7` Byte 0 in memory

      - :cspan:`7` Byte 1

    * -
      -
      - 7
      - 6
      - 5
      - 4
      - 3
      - 2
      - 1
      - 0

      - 7
      - 6
      - 5
      - 4
      - 3
      - 2
      - 1
      - 0

    * .. _V4L2-PIX-FMT-YUV444:

      - ``V4L2_PIX_FMT_YUV444``
      - 'Y444'

      - Cb\ :sub:`3`
      - Cb\ :sub:`2`
      - Cb\ :sub:`1`
      - Cb\ :sub:`0`
      - Cr\ :sub:`3`
      - Cr\ :sub:`2`
      - Cr\ :sub:`1`
      - Cr\ :sub:`0`

      - a\ :sub:`3`
      - a\ :sub:`2`
      - a\ :sub:`1`
      - a\ :sub:`0`
      - Y'\ :sub:`3`
      - Y'\ :sub:`2`
      - Y'\ :sub:`1`
      - Y'\ :sub:`0`

    * .. _V4L2-PIX-FMT-YUV555:

      - ``V4L2_PIX_FMT_YUV555``
      - 'YUVO'

      - Cb\ :sub:`2`
      - Cb\ :sub:`1`
      - Cb\ :sub:`0`
      - Cr\ :sub:`4`
      - Cr\ :sub:`3`
      - Cr\ :sub:`2`
      - Cr\ :sub:`1`
      - Cr\ :sub:`0`

      - a
      - Y'\ :sub:`4`
      - Y'\ :sub:`3`
      - Y'\ :sub:`2`
      - Y'\ :sub:`1`
      - Y'\ :sub:`0`
      - Cb\ :sub:`4`
      - Cb\ :sub:`3`

    * .. _V4L2-PIX-FMT-YUV565:

      - ``V4L2_PIX_FMT_YUV565``
      - 'YUVP'

      - Cb\ :sub:`2`
      - Cb\ :sub:`1`
      - Cb\ :sub:`0`
      - Cr\ :sub:`4`
      - Cr\ :sub:`3`
      - Cr\ :sub:`2`
      - Cr\ :sub:`1`
      - Cr\ :sub:`0`

      - Y'\ :sub:`4`
      - Y'\ :sub:`3`
      - Y'\ :sub:`2`
      - Y'\ :sub:`1`
      - Y'\ :sub:`0`
      - Cb\ :sub:`5`
      - Cb\ :sub:`4`
      - Cb\ :sub:`3`

.. raw:: latex

    \endgroup

.. note::

    For the YUV444 and YUV555 formats, the value of alpha bits is undefined
    when reading from the driver, ignored when writing to the driver, except
    when alpha blending has been negotiated for a :ref:`Video Overlay
    <overlay>` or :ref:`Video Output Overlay <osd>`.

4:4:4, 8·12 bpc

154-288

8-bpc 형식 이름은 memory에 저장되는 Y, Cb, Cr 순서와 pixel당 총 bit 수를 반영합니다. 예를 들어 VUYX32는 첫 byte에 Cr, 둘째 byte에 Cb, 셋째 byte에 Y를 저장하고 마지막 byte는 padding입니다.

Packed YUV 4:4:4, 8-bpc
Identifier / CodeMemory byte 순서
`V4L2_PIX_FMT_YUV32` / `YUV4`Byte 0=A, Byte 1=Y, Byte 2=Cb, Byte 3=Cr
`V4L2_PIX_FMT_AYUV32` / `AYUV`Byte 0=A, Byte 1=Y, Byte 2=Cb, Byte 3=Cr
`V4L2_PIX_FMT_XYUV32` / `XYUV`Byte 0=X, Byte 1=Y, Byte 2=Cb, Byte 3=Cr
`V4L2_PIX_FMT_VUYA32` / `VUYA`Byte 0=Cr, Byte 1=Cb, Byte 2=Y, Byte 3=A
`V4L2_PIX_FMT_VUYX32` / `VUYX`Byte 0=Cr, Byte 1=Cb, Byte 2=Y, Byte 3=X
`V4L2_PIX_FMT_YUVA32` / `YUVA`Byte 0=Y, Byte 1=Cb, Byte 2=Cr, Byte 3=A
`V4L2_PIX_FMT_YUVX32` / `YUVX`Byte 0=Y, Byte 1=Cb, Byte 2=Cr, Byte 3=X
`V4L2_PIX_FMT_YUV24` / `YUV3`Byte 0=Y, Byte 1=Cb, Byte 2=Cr; 넷째 byte 없음

A는 의미 있는 alpha이고 X는 반드시 무시해야 하는 padding입니다.

Alpha component에는 driver와 application이 실제로 사용할 수 있는 의미 있는 값을 넣어야 합니다. 반대로 X padding bit의 값은 정의되지 않으므로 모든 driver와 application이 무시해야 합니다.

`V4L2_PIX_FMT_YUV48_12` (`Y312`)는 component당 12 bit를 16-bit word의 상위 12 bit로 확장하고 하위 4 bit를 0으로 채웁니다. Word는 little-endian이며 pixel 하나가 Y, Cb, Cr 세 word, 즉 6 byte를 차지합니다. 원문 표는 연속 pixel 0과 1을 `Y0 Cb0 Cr0 Y1 Cb1 Cr1` 순서로 보여 줍니다.

YUV48_12 word 배치
Little-endian word12-bit component
Byte 1-0Y'0
Byte 3-2Cb0
Byte 5-4Cr0
Byte 7-6Y'1
Byte 9-8Cb1
Byte 11-10Cr1

각 16-bit word의 high 12 bit만 sample이고 low 4 bit는 0입니다.



The next table lists the packed YUV 4:4:4 formats with 8 bits per component.
They are named based on the order of the Y, Cb and Cr components as stored in
memory, and on the total number of bits per pixel. For instance, the VUYX32
format stores a pixel with Cr\ :sub:`7-0` in the first byte, Cb\ :sub:`7-0` in
the second byte and Y'\ :sub:`7-0` in the third byte.

.. flat-table:: Packed YUV Image Formats (8bpc)
    :header-rows: 1
    :stub-columns: 0

    * - Identifier
      - Code
      - Byte 0
      - Byte 1
      - Byte 2
      - Byte 3

    * .. _V4L2-PIX-FMT-YUV32:

      - ``V4L2_PIX_FMT_YUV32``
      - 'YUV4'

      - A\ :sub:`7-0`
      - Y'\ :sub:`7-0`
      - Cb\ :sub:`7-0`
      - Cr\ :sub:`7-0`

    * .. _V4L2-PIX-FMT-AYUV32:

      - ``V4L2_PIX_FMT_AYUV32``
      - 'AYUV'

      - A\ :sub:`7-0`
      - Y'\ :sub:`7-0`
      - Cb\ :sub:`7-0`
      - Cr\ :sub:`7-0`

    * .. _V4L2-PIX-FMT-XYUV32:

      - ``V4L2_PIX_FMT_XYUV32``
      - 'XYUV'

      - X\ :sub:`7-0`
      - Y'\ :sub:`7-0`
      - Cb\ :sub:`7-0`
      - Cr\ :sub:`7-0`

    * .. _V4L2-PIX-FMT-VUYA32:

      - ``V4L2_PIX_FMT_VUYA32``
      - 'VUYA'

      - Cr\ :sub:`7-0`
      - Cb\ :sub:`7-0`
      - Y'\ :sub:`7-0`
      - A\ :sub:`7-0`

    * .. _V4L2-PIX-FMT-VUYX32:

      - ``V4L2_PIX_FMT_VUYX32``
      - 'VUYX'

      - Cr\ :sub:`7-0`
      - Cb\ :sub:`7-0`
      - Y'\ :sub:`7-0`
      - X\ :sub:`7-0`

    * .. _V4L2-PIX-FMT-YUVA32:

      - ``V4L2_PIX_FMT_YUVA32``
      - 'YUVA'

      - Y'\ :sub:`7-0`
      - Cb\ :sub:`7-0`
      - Cr\ :sub:`7-0`
      - A\ :sub:`7-0`

    * .. _V4L2-PIX-FMT-YUVX32:

      - ``V4L2_PIX_FMT_YUVX32``
      - 'YUVX'

      - Y'\ :sub:`7-0`
      - Cb\ :sub:`7-0`
      - Cr\ :sub:`7-0`
      - X\ :sub:`7-0`

    * .. _V4L2-PIX-FMT-YUV24:

      - ``V4L2_PIX_FMT_YUV24``
      - 'YUV3'

      - Y'\ :sub:`7-0`
      - Cb\ :sub:`7-0`
      - Cr\ :sub:`7-0`
      - -\

.. note::

    - The alpha component is expected to contain a meaningful value that can be
      used by drivers and applications.
    - The padding bits contain undefined values that must be ignored by all
      applications and drivers.

The next table lists the packed YUV 4:4:4 formats with 12 bits per component.
Expand the bits per component to 16 bits, data in the high bits, zeros in the low bits,
arranged in little endian order, storing 1 pixel in 6 bytes.

.. flat-table:: Packed YUV 4:4:4 Image Formats (12bpc)
    :header-rows: 1
    :stub-columns: 0

    * - Identifier
      - Code
      - Byte 1-0
      - Byte 3-2
      - Byte 5-4
      - Byte 7-6
      - Byte 9-8
      - Byte 11-10

    * .. _V4L2-PIX-FMT-YUV48-12:

      - ``V4L2_PIX_FMT_YUV48_12``
      - 'Y312'

      - Y'\ :sub:`0`
      - Cb\ :sub:`0`
      - Cr\ :sub:`0`
      - Y'\ :sub:`1`
      - Cb\ :sub:`1`
      - Cr\ :sub:`1`

4:2:2 packed container

289-421

4:2:2 형식은 chroma를 수평으로 2:1 subsampling하고 pixel 두 개를 한 container에 저장합니다. 8-bit 형식의 container는 32 bit이고 10 bit 이상 형식은 64 bit입니다. 8-bit 표는 이해를 돕기 위해 연속 네 pixel, 즉 두 container의 byte 순서를 보여 줍니다.

Packed YUV 4:2:2, 8-bit
Identifier / CodeByte 0 → Byte 7
`V4L2_PIX_FMT_UYVY` / `UYVY`Cb0 Y0 Cr0 Y1 | Cb2 Y2 Cr2 Y3
`V4L2_PIX_FMT_VYUY` / `VYUY`Cr0 Y0 Cb0 Y1 | Cr2 Y2 Cb2 Y3
`V4L2_PIX_FMT_YUYV` / `YUYV`Y0 Cb0 Y1 Cr0 | Y2 Cb2 Y3 Cr2
`V4L2_PIX_FMT_YVYU` / `YVYU`Y0 Cr0 Y1 Cb0 | Y2 Cr2 Y3 Cb2

Chroma index 0은 Y0·Y1, index 2는 Y2·Y3에 공유됩니다.

Component당 8 bit보다 큰 packed YUYV 형식은 16-bit little-endian word 네 개로 저장합니다. 각 word의 most significant bit 쪽에 component를 놓고 남는 least significant bit는 0 padding입니다.

Packed YUV 4:2:2, 64-bit container
Identifier / CodeWord 0=Y0, 1=Cb0, 2=Y1, 3=Cr0
`V4L2_PIX_FMT_Y210` / `Y210`각 word bits 15:6에 10-bit component, bits 5:0은 0
`V4L2_PIX_FMT_Y212` / `Y212`각 word bits 15:4에 12-bit component, bits 3:0은 0
`V4L2_PIX_FMT_Y216` / `Y216`각 word bits 15:0에 16-bit component

모두 Word 0..3이 Y0, Cb0, Y1, Cr0 순서입니다.

4:2:2 chroma sample은 수평 방향에서 두 luma sample 사이에 놓이는 interstitially sited, 즉 centered 위치를 사용합니다.

4:2:2 두 pixel 복원
Container에서 Y0·Y1 분리공유 Cb0·Cr0 분리Centered chroma 위치 적용(Y0,Cb0,Cr0)과 (Y1,Cb0,Cr0) 복원

한 Cb/Cr pair를 두 luma pixel에 결합합니다.

4:2:2 Subsampling
=================

These formats, commonly referred to as YUYV or YUY2, subsample the chroma
components horizontally by 2, storing 2 pixels in a container. The container
is 32-bits for 8-bit formats, and 64-bits for 10+-bit formats.

The packed YUYV formats with more than 8 bits per component are stored as four
16-bit little-endian words. Each word's most significant bits contain one
component, and the least significant bits are zero padding.

.. raw:: latex

    \footnotesize

.. tabularcolumns:: |p{3.4cm}|p{1.2cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|

.. flat-table:: Packed YUV 4:2:2 Formats in 32-bit container
    :header-rows: 1
    :stub-columns: 0

    * - Identifier
      - Code
      - Byte 0
      - Byte 1
      - Byte 2
      - Byte 3
      - Byte 4
      - Byte 5
      - Byte 6
      - Byte 7
    * .. _V4L2-PIX-FMT-UYVY:

      - ``V4L2_PIX_FMT_UYVY``
      - 'UYVY'

      - Cb\ :sub:`0`
      - Y'\ :sub:`0`
      - Cr\ :sub:`0`
      - Y'\ :sub:`1`
      - Cb\ :sub:`2`
      - Y'\ :sub:`2`
      - Cr\ :sub:`2`
      - Y'\ :sub:`3`
    * .. _V4L2-PIX-FMT-VYUY:

      - ``V4L2_PIX_FMT_VYUY``
      - 'VYUY'

      - Cr\ :sub:`0`
      - Y'\ :sub:`0`
      - Cb\ :sub:`0`
      - Y'\ :sub:`1`
      - Cr\ :sub:`2`
      - Y'\ :sub:`2`
      - Cb\ :sub:`2`
      - Y'\ :sub:`3`
    * .. _V4L2-PIX-FMT-YUYV:

      - ``V4L2_PIX_FMT_YUYV``
      - 'YUYV'

      - Y'\ :sub:`0`
      - Cb\ :sub:`0`
      - Y'\ :sub:`1`
      - Cr\ :sub:`0`
      - Y'\ :sub:`2`
      - Cb\ :sub:`2`
      - Y'\ :sub:`3`
      - Cr\ :sub:`2`
    * .. _V4L2-PIX-FMT-YVYU:

      - ``V4L2_PIX_FMT_YVYU``
      - 'YVYU'

      - Y'\ :sub:`0`
      - Cr\ :sub:`0`
      - Y'\ :sub:`1`
      - Cb\ :sub:`0`
      - Y'\ :sub:`2`
      - Cr\ :sub:`2`
      - Y'\ :sub:`3`
      - Cb\ :sub:`2`

.. tabularcolumns:: |p{3.4cm}|p{1.2cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|

.. flat-table:: Packed YUV 4:2:2 Formats in 64-bit container
    :header-rows: 1
    :stub-columns: 0

    * - Identifier
      - Code
      - Word 0
      - Word 1
      - Word 2
      - Word 3
    * .. _V4L2-PIX-FMT-Y210:

      - ``V4L2_PIX_FMT_Y210``
      - 'Y210'

      - Y'\ :sub:`0` (bits 15-6)
      - Cb\ :sub:`0` (bits 15-6)
      - Y'\ :sub:`1` (bits 15-6)
      - Cr\ :sub:`0` (bits 15-6)
    * .. _V4L2-PIX-FMT-Y212:

      - ``V4L2_PIX_FMT_Y212``
      - 'Y212'

      - Y'\ :sub:`0` (bits 15-4)
      - Cb\ :sub:`0` (bits 15-4)
      - Y'\ :sub:`1` (bits 15-4)
      - Cr\ :sub:`0` (bits 15-4)
    * .. _V4L2-PIX-FMT-Y216:

      - ``V4L2_PIX_FMT_Y216``
      - 'Y216'

      - Y'\ :sub:`0` (bits 15-0)
      - Cb\ :sub:`0` (bits 15-0)
      - Y'\ :sub:`1` (bits 15-0)
      - Cr\ :sub:`0` (bits 15-0)

.. raw:: latex

    \normalsize

**Color Sample Location:**
Chroma samples are :ref:`interstitially sited<yuv-chroma-centered>`
horizontally.

4:1:1 Y41P packing

422-482

4:1:1 형식은 chroma를 수평으로 4:1 subsampling하며 pixel 8개를 12 byte에 저장합니다. `V4L2_PIX_FMT_Y41P` (`Y41P`)의 두 chroma pair는 각각 luma pixel 네 개에 공유됩니다.

Y41P 12-byte 배치
항목설명
Byte 0..3Cb0, Y0, Cr0, Y1
Byte 4..7Cb4, Y2, Cr4, Y3
Byte 8..11Y4, Y5, Y6, Y7
Cb0/Cr0 공유Y0, Y1, Y2, Y3
Cb4/Cr4 공유Y4, Y5, Y6, Y7

Pixel 8개를 나타내는 byte 순서입니다.

`V4L2_PIX_FMT_Y41P`를 `V4L2_PIX_FMT_YUV411P`와 혼동하면 안 됩니다. Y41P는 YUV 4:1:1 packed에서 유래하지만 YUV411P는 YUV 4:1:1 planar를 뜻합니다.

4:1:1 chroma sample 역시 수평 방향에서 interstitially sited, 즉 centered 위치를 사용합니다.

4:1:1 Subsampling
=================

This format subsamples the chroma components horizontally by 4, storing 8
pixels in 12 bytes.

.. raw:: latex

    \scriptsize

.. tabularcolumns:: |p{2.9cm}|p{0.8cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|

.. flat-table:: Packed YUV 4:1:1 Formats
    :header-rows: 1
    :stub-columns: 0

    * - Identifier
      - Code
      - Byte 0
      - Byte 1
      - Byte 2
      - Byte 3
      - Byte 4
      - Byte 5
      - Byte 6
      - Byte 7
      - Byte 8
      - Byte 9
      - Byte 10
      - Byte 11
    * .. _V4L2-PIX-FMT-Y41P:

      - ``V4L2_PIX_FMT_Y41P``
      - 'Y41P'

      - Cb\ :sub:`0`
      - Y'\ :sub:`0`
      - Cr\ :sub:`0`
      - Y'\ :sub:`1`
      - Cb\ :sub:`4`
      - Y'\ :sub:`2`
      - Cr\ :sub:`4`
      - Y'\ :sub:`3`
      - Y'\ :sub:`4`
      - Y'\ :sub:`5`
      - Y'\ :sub:`6`
      - Y'\ :sub:`7`

.. raw:: latex

    \normalsize

.. note::

    Do not confuse ``V4L2_PIX_FMT_Y41P`` with
    :ref:`V4L2_PIX_FMT_YUV411P <V4L2-PIX-FMT-YUV411P>`. Y41P is derived from
    "YUV 4:1:1 **packed**", while YUV411P stands for "YUV 4:1:1 **planar**".

**Color Sample Location:**
Chroma samples are :ref:`interstitially sited<yuv-chroma-centered>`
horizontally.