1.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2
3.. planar-yuv:
4
5******************
6Planar YUV formats
7******************
8
9Planar formats split luma and chroma data in separate memory regions. They
10exist in two variants:
11
12- Semi-planar formats use two planes. The first plane is the luma plane and
13  stores the Y components. The second plane is the chroma plane and stores the
14  Cb and Cr components interleaved.
15
16- Fully planar formats use three planes to store the Y, Cb and Cr components
17  separately.
18
19Within a plane, components are stored in pixel order, which may be linear or
20tiled. Padding may be supported at the end of the lines, and the line stride of
21the chroma planes may be constrained by the line stride of the luma plane.
22
23Some planar formats allow planes to be placed in independent memory locations.
24They are identified by an 'M' suffix in their name (such as in
25``V4L2_PIX_FMT_NV12M``). Those formats are intended to be used only in drivers
26and applications that support the multi-planar API, described in
27:ref:`planar-apis`. Unless explicitly documented as supporting non-contiguous
28planes, formats require the planes to follow each other immediately in memory.
29
30
31Semi-Planar YUV Formats
32=======================
33
34These formats are commonly referred to as NV formats (NV12, NV16, ...). They
35use two planes, and store the luma components in the first plane and the chroma
36components in the second plane. The Cb and Cr components are interleaved in the
37chroma plane, with Cb and Cr always stored in pairs. The chroma order is
38exposed as different formats.
39
40For memory contiguous formats, the number of padding pixels at the end of the
41chroma lines is identical to the padding of the luma lines. Without horizontal
42subsampling, the chroma line stride (in bytes) is thus equal to twice the luma
43line stride. With horizontal subsampling by 2, the chroma line stride is equal
44to the luma line stride. Vertical subsampling doesn't affect the line stride.
45
46For non-contiguous formats, no constraints are enforced by the format on the
47relationship between the luma and chroma line padding and stride.
48
49All components are stored with the same number of bits per component.
50
51.. raw:: latex
52
53    \footnotesize
54
55.. tabularcolumns:: |p{5.2cm}|p{1.0cm}|p{1.5cm}|p{1.9cm}|p{1.2cm}|p{1.8cm}|p{2.7cm}|
56
57.. flat-table:: Overview of Semi-Planar YUV Formats
58    :header-rows:  1
59    :stub-columns: 0
60
61    * - Identifier
62      - Code
63      - Bits per component
64      - Subsampling
65      - Chroma order [1]_
66      - Contiguous [2]_
67      - Tiling [3]_
68    * - V4L2_PIX_FMT_NV12
69      - 'NV12'
70      - 8
71      - 4:2:0
72      - Cb, Cr
73      - Yes
74      - Linear
75    * - V4L2_PIX_FMT_NV21
76      - 'NV21'
77      - 8
78      - 4:2:0
79      - Cr, Cb
80      - Yes
81      - Linear
82    * - V4L2_PIX_FMT_NV12M
83      - 'NM12'
84      - 8
85      - 4:2:0
86      - Cb, Cr
87      - No
88      - Linear
89    * - V4L2_PIX_FMT_NV21M
90      - 'NM21'
91      - 8
92      - 4:2:0
93      - Cr, Cb
94      - No
95      - Linear
96    * - V4L2_PIX_FMT_NV12MT
97      - 'TM12'
98      - 8
99      - 4:2:0
100      - Cb, Cr
101      - No
102      - 64x32 tiles
103
104        Horizontal Z order
105    * - V4L2_PIX_FMT_NV12MT_16X16
106      - 'VM12'
107      - 8
108      - 4:2:2
109      - Cb, Cr
110      - No
111      - 16x16 tiles
112    * - V4L2_PIX_FMT_P010
113      - 'P010'
114      - 10
115      - 4:2:0
116      - Cb, Cr
117      - Yes
118      - Linear
119    * - V4L2_PIX_FMT_P010_4L4
120      - 'T010'
121      - 10
122      - 4:2:0
123      - Cb, Cr
124      - Yes
125      - 4x4 tiles
126    * - V4L2_PIX_FMT_P012
127      - 'P012'
128      - 12
129      - 4:2:0
130      - Cb, Cr
131      - Yes
132      - Linear
133    * - V4L2_PIX_FMT_P012M
134      - 'PM12'
135      - 12
136      - 4:2:0
137      - Cb, Cr
138      - No
139      - Linear
140    * - V4L2_PIX_FMT_NV15_4L4
141      - 'VT15'
142      - 15
143      - 4:2:0
144      - Cb, Cr
145      - Yes
146      - 4x4 tiles
147    * - V4L2_PIX_FMT_NV16
148      - 'NV16'
149      - 8
150      - 4:2:2
151      - Cb, Cr
152      - Yes
153      - Linear
154    * - V4L2_PIX_FMT_NV61
155      - 'NV61'
156      - 8
157      - 4:2:2
158      - Cr, Cb
159      - Yes
160      - Linear
161    * - V4L2_PIX_FMT_NV16M
162      - 'NM16'
163      - 8
164      - 4:2:2
165      - Cb, Cr
166      - No
167      - Linear
168    * - V4L2_PIX_FMT_NV61M
169      - 'NM61'
170      - 8
171      - 4:2:2
172      - Cr, Cb
173      - No
174      - Linear
175    * - V4L2_PIX_FMT_NV24
176      - 'NV24'
177      - 8
178      - 4:4:4
179      - Cb, Cr
180      - Yes
181      - Linear
182    * - V4L2_PIX_FMT_NV42
183      - 'NV42'
184      - 8
185      - 4:4:4
186      - Cr, Cb
187      - Yes
188      - Linear
189
190.. raw:: latex
191
192    \normalsize
193
194.. [1] Order of chroma samples in the second plane
195.. [2] Indicates if planes have to be contiguous in memory or can be
196       disjoint
197.. [3] Macroblock size in pixels
198
199
200**Color Sample Location:**
201Chroma samples are :ref:`interstitially sited<yuv-chroma-centered>`
202horizontally.
203
204
205.. _V4L2-PIX-FMT-NV12:
206.. _V4L2-PIX-FMT-NV21:
207.. _V4L2-PIX-FMT-NV12M:
208.. _V4L2-PIX-FMT-NV21M:
209.. _V4L2-PIX-FMT-P010:
210
211NV12, NV21, NV12M and NV21M
212---------------------------
213
214Semi-planar YUV 4:2:0 formats. The chroma plane is subsampled by 2 in each
215direction. Chroma lines contain half the number of pixels and the same number
216of bytes as luma lines, and the chroma plane contains half the number of lines
217of the luma plane.
218
219.. flat-table:: Sample 4x4 NV12 Image
220    :header-rows:  0
221    :stub-columns: 0
222
223    * - start + 0:
224      - Y'\ :sub:`00`
225      - Y'\ :sub:`01`
226      - Y'\ :sub:`02`
227      - Y'\ :sub:`03`
228    * - start + 4:
229      - Y'\ :sub:`10`
230      - Y'\ :sub:`11`
231      - Y'\ :sub:`12`
232      - Y'\ :sub:`13`
233    * - start + 8:
234      - Y'\ :sub:`20`
235      - Y'\ :sub:`21`
236      - Y'\ :sub:`22`
237      - Y'\ :sub:`23`
238    * - start + 12:
239      - Y'\ :sub:`30`
240      - Y'\ :sub:`31`
241      - Y'\ :sub:`32`
242      - Y'\ :sub:`33`
243    * - start + 16:
244      - Cb\ :sub:`00`
245      - Cr\ :sub:`00`
246      - Cb\ :sub:`01`
247      - Cr\ :sub:`01`
248    * - start + 20:
249      - Cb\ :sub:`10`
250      - Cr\ :sub:`10`
251      - Cb\ :sub:`11`
252      - Cr\ :sub:`11`
253
254.. flat-table:: Sample 4x4 NV12M Image
255    :header-rows:  0
256    :stub-columns: 0
257
258    * - start0 + 0:
259      - Y'\ :sub:`00`
260      - Y'\ :sub:`01`
261      - Y'\ :sub:`02`
262      - Y'\ :sub:`03`
263    * - start0 + 4:
264      - Y'\ :sub:`10`
265      - Y'\ :sub:`11`
266      - Y'\ :sub:`12`
267      - Y'\ :sub:`13`
268    * - start0 + 8:
269      - Y'\ :sub:`20`
270      - Y'\ :sub:`21`
271      - Y'\ :sub:`22`
272      - Y'\ :sub:`23`
273    * - start0 + 12:
274      - Y'\ :sub:`30`
275      - Y'\ :sub:`31`
276      - Y'\ :sub:`32`
277      - Y'\ :sub:`33`
278    * -
279    * - start1 + 0:
280      - Cb\ :sub:`00`
281      - Cr\ :sub:`00`
282      - Cb\ :sub:`01`
283      - Cr\ :sub:`01`
284    * - start1 + 4:
285      - Cb\ :sub:`10`
286      - Cr\ :sub:`10`
287      - Cb\ :sub:`11`
288      - Cr\ :sub:`11`
289
290
291.. _V4L2-PIX-FMT-NV12MT:
292.. _V4L2-PIX-FMT-NV12MT-16X16:
293.. _V4L2-PIX-FMT-NV12-4L4:
294.. _V4L2-PIX-FMT-NV12-16L16:
295.. _V4L2-PIX-FMT-NV12-32L32:
296.. _V4L2-PIX-FMT-NV12M-8L128:
297.. _V4L2-PIX-FMT-NV12-8L128:
298.. _V4L2-PIX-FMT-NV12M-10BE-8L128:
299.. _V4L2-PIX-FMT-NV12-10BE-8L128:
300.. _V4L2-PIX-FMT-MM21:
301
302Tiled NV12
303----------
304
305Semi-planar YUV 4:2:0 formats, using macroblock tiling. The chroma plane is
306subsampled by 2 in each direction. Chroma lines contain half the number of
307pixels and the same number of bytes as luma lines, and the chroma plane
308contains half the number of lines of the luma plane. Each tile follows the
309previous one linearly in memory (from left to right, top to bottom).
310
311``V4L2_PIX_FMT_NV12MT_16X16`` is similar to ``V4L2_PIX_FMT_NV12M`` but stores
312pixels in 2D 16x16 tiles, and stores tiles linearly in memory.
313The line stride and image height must be aligned to a multiple of 16.
314The layouts of the luma and chroma planes are identical.
315
316``V4L2_PIX_FMT_NV12MT`` is similar to ``V4L2_PIX_FMT_NV12M`` but stores
317pixels in 2D 64x32 tiles, and stores 2x2 groups of tiles in
318Z-order in memory, alternating Z and mirrored Z shapes horizontally.
319The line stride must be a multiple of 128 pixels to ensure an
320integer number of Z shapes. The image height must be a multiple of 32 pixels.
321If the vertical resolution is an odd number of tiles, the last row of
322tiles is stored in linear order. The layouts of the luma and chroma
323planes are identical.
324
325``V4L2_PIX_FMT_NV12_4L4`` stores pixels in 4x4 tiles, and stores
326tiles linearly in memory. The line stride and image height must be
327aligned to a multiple of 4. The layouts of the luma and chroma planes are
328identical.
329
330``V4L2_PIX_FMT_NV12_16L16`` stores pixels in 16x16 tiles, and stores
331tiles linearly in memory. The line stride and image height must be
332aligned to a multiple of 16. The layouts of the luma and chroma planes are
333identical.
334
335``V4L2_PIX_FMT_NV12_32L32`` stores pixels in 32x32 tiles, and stores
336tiles linearly in memory. The line stride and image height must be
337aligned to a multiple of 32. The layouts of the luma and chroma planes are
338identical.
339
340``V4L2_PIX_FMT_NV12M_8L128`` is similar to ``V4L2_PIX_FMT_NV12M`` but stores
341pixels in 2D 8x128 tiles, and stores tiles linearly in memory.
342The image height must be aligned to a multiple of 128.
343The layouts of the luma and chroma planes are identical.
344
345``V4L2_PIX_FMT_NV12_8L128`` is similar to ``V4L2_PIX_FMT_NV12M_8L128`` but stores
346two planes in one memory.
347
348``V4L2_PIX_FMT_NV12M_10BE_8L128`` is similar to ``V4L2_PIX_FMT_NV12M`` but stores
34910 bits pixels in 2D 8x128 tiles, and stores tiles linearly in memory.
350the data is arranged in big endian order.
351The image height must be aligned to a multiple of 128.
352The layouts of the luma and chroma planes are identical.
353Note the tile size is 8bytes multiplied by 128 bytes,
354it means that the low bits and high bits of one pixel may be in different tiles.
355The 10 bit pixels are packed, so 5 bytes contain 4 10-bit pixels layout like
356this (for luma):
357byte 0: Y0(bits 9-2)
358byte 1: Y0(bits 1-0) Y1(bits 9-4)
359byte 2: Y1(bits 3-0) Y2(bits 9-6)
360byte 3: Y2(bits 5-0) Y3(bits 9-8)
361byte 4: Y3(bits 7-0)
362
363``V4L2_PIX_FMT_NV12_10BE_8L128`` is similar to ``V4L2_PIX_FMT_NV12M_10BE_8L128`` but stores
364two planes in one memory.
365
366``V4L2_PIX_FMT_MM21`` store luma pixel in 16x32 tiles, and chroma pixels
367in 16x16 tiles. The line stride must be aligned to a multiple of 16 and the
368image height must be aligned to a multiple of 32. The number of luma and chroma
369tiles are identical, even though the tile size differ. The image is formed of
370two non-contiguous planes.
371
372.. _nv12mt:
373
374.. kernel-figure:: nv12mt.svg
375    :alt:    nv12mt.svg
376    :align:  center
377
378    V4L2_PIX_FMT_NV12MT macroblock Z shape memory layout
379
380.. _nv12mt_ex:
381
382.. kernel-figure:: nv12mt_example.svg
383    :alt:    nv12mt_example.svg
384    :align:  center
385
386    Example V4L2_PIX_FMT_NV12MT memory layout of tiles
387
388.. _V4L2-PIX-FMT-NV15-4L4:
389
390Tiled NV15
391----------
392
393Semi-planar 10-bit YUV 4:2:0 formats, using 4x4 tiling.
394All components are packed without any padding between each other.
395As a side-effect, each group of 4 components are stored over 5 bytes
396(YYYY or UVUV = 4 * 10 bits = 40 bits = 5 bytes).
397
398.. _V4L2-PIX-FMT-NV16:
399.. _V4L2-PIX-FMT-NV61:
400.. _V4L2-PIX-FMT-NV16M:
401.. _V4L2-PIX-FMT-NV61M:
402
403NV16, NV61, NV16M and NV61M
404---------------------------
405
406Semi-planar YUV 4:2:2 formats. The chroma plane is subsampled by 2 in the
407horizontal direction. Chroma lines contain half the number of pixels and the
408same number of bytes as luma lines, and the chroma plane contains the same
409number of lines as the luma plane.
410
411.. flat-table:: Sample 4x4 NV16 Image
412    :header-rows:  0
413    :stub-columns: 0
414
415    * - start + 0:
416      - Y'\ :sub:`00`
417      - Y'\ :sub:`01`
418      - Y'\ :sub:`02`
419      - Y'\ :sub:`03`
420    * - start + 4:
421      - Y'\ :sub:`10`
422      - Y'\ :sub:`11`
423      - Y'\ :sub:`12`
424      - Y'\ :sub:`13`
425    * - start + 8:
426      - Y'\ :sub:`20`
427      - Y'\ :sub:`21`
428      - Y'\ :sub:`22`
429      - Y'\ :sub:`23`
430    * - start + 12:
431      - Y'\ :sub:`30`
432      - Y'\ :sub:`31`
433      - Y'\ :sub:`32`
434      - Y'\ :sub:`33`
435    * - start + 16:
436      - Cb\ :sub:`00`
437      - Cr\ :sub:`00`
438      - Cb\ :sub:`01`
439      - Cr\ :sub:`01`
440    * - start + 20:
441      - Cb\ :sub:`10`
442      - Cr\ :sub:`10`
443      - Cb\ :sub:`11`
444      - Cr\ :sub:`11`
445    * - start + 24:
446      - Cb\ :sub:`20`
447      - Cr\ :sub:`20`
448      - Cb\ :sub:`21`
449      - Cr\ :sub:`21`
450    * - start + 28:
451      - Cb\ :sub:`30`
452      - Cr\ :sub:`30`
453      - Cb\ :sub:`31`
454      - Cr\ :sub:`31`
455
456.. flat-table:: Sample 4x4 NV16M Image
457    :header-rows:  0
458    :stub-columns: 0
459
460    * - start0 + 0:
461      - Y'\ :sub:`00`
462      - Y'\ :sub:`01`
463      - Y'\ :sub:`02`
464      - Y'\ :sub:`03`
465    * - start0 + 4:
466      - Y'\ :sub:`10`
467      - Y'\ :sub:`11`
468      - Y'\ :sub:`12`
469      - Y'\ :sub:`13`
470    * - start0 + 8:
471      - Y'\ :sub:`20`
472      - Y'\ :sub:`21`
473      - Y'\ :sub:`22`
474      - Y'\ :sub:`23`
475    * - start0 + 12:
476      - Y'\ :sub:`30`
477      - Y'\ :sub:`31`
478      - Y'\ :sub:`32`
479      - Y'\ :sub:`33`
480    * -
481    * - start1 + 0:
482      - Cb\ :sub:`00`
483      - Cr\ :sub:`00`
484      - Cb\ :sub:`02`
485      - Cr\ :sub:`02`
486    * - start1 + 4:
487      - Cb\ :sub:`10`
488      - Cr\ :sub:`10`
489      - Cb\ :sub:`12`
490      - Cr\ :sub:`12`
491    * - start1 + 8:
492      - Cb\ :sub:`20`
493      - Cr\ :sub:`20`
494      - Cb\ :sub:`22`
495      - Cr\ :sub:`22`
496    * - start1 + 12:
497      - Cb\ :sub:`30`
498      - Cr\ :sub:`30`
499      - Cb\ :sub:`32`
500      - Cr\ :sub:`32`
501
502
503.. _V4L2-PIX-FMT-NV24:
504.. _V4L2-PIX-FMT-NV42:
505
506NV24 and NV42
507-------------
508
509Semi-planar YUV 4:4:4 formats. The chroma plane is not subsampled.
510Chroma lines contain the same number of pixels and twice the
511number of bytes as luma lines, and the chroma plane contains the same
512number of lines as the luma plane.
513
514.. flat-table:: Sample 4x4 NV24 Image
515    :header-rows:  0
516    :stub-columns: 0
517
518    * - start + 0:
519      - Y'\ :sub:`00`
520      - Y'\ :sub:`01`
521      - Y'\ :sub:`02`
522      - Y'\ :sub:`03`
523    * - start + 4:
524      - Y'\ :sub:`10`
525      - Y'\ :sub:`11`
526      - Y'\ :sub:`12`
527      - Y'\ :sub:`13`
528    * - start + 8:
529      - Y'\ :sub:`20`
530      - Y'\ :sub:`21`
531      - Y'\ :sub:`22`
532      - Y'\ :sub:`23`
533    * - start + 12:
534      - Y'\ :sub:`30`
535      - Y'\ :sub:`31`
536      - Y'\ :sub:`32`
537      - Y'\ :sub:`33`
538    * - start + 16:
539      - Cb\ :sub:`00`
540      - Cr\ :sub:`00`
541      - Cb\ :sub:`01`
542      - Cr\ :sub:`01`
543      - Cb\ :sub:`02`
544      - Cr\ :sub:`02`
545      - Cb\ :sub:`03`
546      - Cr\ :sub:`03`
547    * - start + 24:
548      - Cb\ :sub:`10`
549      - Cr\ :sub:`10`
550      - Cb\ :sub:`11`
551      - Cr\ :sub:`11`
552      - Cb\ :sub:`12`
553      - Cr\ :sub:`12`
554      - Cb\ :sub:`13`
555      - Cr\ :sub:`13`
556    * - start + 32:
557      - Cb\ :sub:`20`
558      - Cr\ :sub:`20`
559      - Cb\ :sub:`21`
560      - Cr\ :sub:`21`
561      - Cb\ :sub:`22`
562      - Cr\ :sub:`22`
563      - Cb\ :sub:`23`
564      - Cr\ :sub:`23`
565    * - start + 40:
566      - Cb\ :sub:`30`
567      - Cr\ :sub:`30`
568      - Cb\ :sub:`31`
569      - Cr\ :sub:`31`
570      - Cb\ :sub:`32`
571      - Cr\ :sub:`32`
572      - Cb\ :sub:`33`
573      - Cr\ :sub:`33`
574
575.. _V4L2_PIX_FMT_P010:
576.. _V4L2-PIX-FMT-P010-4L4:
577
578P010 and tiled P010
579-------------------
580
581P010 is like NV12 with 10 bits per component, expanded to 16 bits.
582Data in the 10 high bits, zeros in the 6 low bits, arranged in little endian order.
583
584.. flat-table:: Sample 4x4 P010 Image
585    :header-rows:  0
586    :stub-columns: 0
587
588    * - start + 0:
589      - Y'\ :sub:`00`
590      - Y'\ :sub:`01`
591      - Y'\ :sub:`02`
592      - Y'\ :sub:`03`
593    * - start + 8:
594      - Y'\ :sub:`10`
595      - Y'\ :sub:`11`
596      - Y'\ :sub:`12`
597      - Y'\ :sub:`13`
598    * - start + 16:
599      - Y'\ :sub:`20`
600      - Y'\ :sub:`21`
601      - Y'\ :sub:`22`
602      - Y'\ :sub:`23`
603    * - start + 24:
604      - Y'\ :sub:`30`
605      - Y'\ :sub:`31`
606      - Y'\ :sub:`32`
607      - Y'\ :sub:`33`
608    * - start + 32:
609      - Cb\ :sub:`00`
610      - Cr\ :sub:`00`
611      - Cb\ :sub:`01`
612      - Cr\ :sub:`01`
613    * - start + 40:
614      - Cb\ :sub:`10`
615      - Cr\ :sub:`10`
616      - Cb\ :sub:`11`
617      - Cr\ :sub:`11`
618
619.. _V4L2-PIX-FMT-P012:
620.. _V4L2-PIX-FMT-P012M:
621
622P012 and P012M
623--------------
624
625P012 is like NV12 with 12 bits per component, expanded to 16 bits.
626Data in the 12 high bits, zeros in the 4 low bits, arranged in little endian order.
627
628.. flat-table:: Sample 4x4 P012 Image
629    :header-rows:  0
630    :stub-columns: 0
631
632    * - start + 0:
633      - Y'\ :sub:`00`
634      - Y'\ :sub:`01`
635      - Y'\ :sub:`02`
636      - Y'\ :sub:`03`
637    * - start + 8:
638      - Y'\ :sub:`10`
639      - Y'\ :sub:`11`
640      - Y'\ :sub:`12`
641      - Y'\ :sub:`13`
642    * - start + 16:
643      - Y'\ :sub:`20`
644      - Y'\ :sub:`21`
645      - Y'\ :sub:`22`
646      - Y'\ :sub:`23`
647    * - start + 24:
648      - Y'\ :sub:`30`
649      - Y'\ :sub:`31`
650      - Y'\ :sub:`32`
651      - Y'\ :sub:`33`
652    * - start + 32:
653      - Cb\ :sub:`00`
654      - Cr\ :sub:`00`
655      - Cb\ :sub:`01`
656      - Cr\ :sub:`01`
657    * - start + 40:
658      - Cb\ :sub:`10`
659      - Cr\ :sub:`10`
660      - Cb\ :sub:`11`
661      - Cr\ :sub:`11`
662
663.. flat-table:: Sample 4x4 P012M Image
664    :header-rows:  0
665    :stub-columns: 0
666
667    * - start0 + 0:
668      - Y'\ :sub:`00`
669      - Y'\ :sub:`01`
670      - Y'\ :sub:`02`
671      - Y'\ :sub:`03`
672    * - start0 + 8:
673      - Y'\ :sub:`10`
674      - Y'\ :sub:`11`
675      - Y'\ :sub:`12`
676      - Y'\ :sub:`13`
677    * - start0 + 16:
678      - Y'\ :sub:`20`
679      - Y'\ :sub:`21`
680      - Y'\ :sub:`22`
681      - Y'\ :sub:`23`
682    * - start0 + 24:
683      - Y'\ :sub:`30`
684      - Y'\ :sub:`31`
685      - Y'\ :sub:`32`
686      - Y'\ :sub:`33`
687    * -
688    * - start1 + 0:
689      - Cb\ :sub:`00`
690      - Cr\ :sub:`00`
691      - Cb\ :sub:`01`
692      - Cr\ :sub:`01`
693    * - start1 + 8:
694      - Cb\ :sub:`10`
695      - Cr\ :sub:`10`
696      - Cb\ :sub:`11`
697      - Cr\ :sub:`11`
698
699
700Fully Planar YUV Formats
701========================
702
703These formats store the Y, Cb and Cr components in three separate planes. The
704luma plane comes first, and the order of the two chroma planes varies between
705formats. The two chroma planes always use the same subsampling.
706
707For memory contiguous formats, the number of padding pixels at the end of the
708chroma lines is identical to the padding of the luma lines. The chroma line
709stride (in bytes) is thus equal to the luma line stride divided by the
710horizontal subsampling factor. Vertical subsampling doesn't affect the line
711stride.
712
713For non-contiguous formats, no constraints are enforced by the format on the
714relationship between the luma and chroma line padding and stride.
715
716All components are stored with the same number of bits per component.
717
718``V4L2_PIX_FMT_P010_4L4`` stores pixels in 4x4 tiles, and stores tiles linearly
719in memory. The line stride must be aligned to multiple of 8 and image height to
720a multiple of 4. The layouts of the luma and chroma planes are identical.
721
722.. raw:: latex
723
724    \small
725
726.. tabularcolumns:: |p{5.0cm}|p{1.1cm}|p{1.5cm}|p{2.2cm}|p{1.2cm}|p{3.7cm}|
727
728.. flat-table:: Overview of Fully Planar YUV Formats
729    :header-rows:  1
730    :stub-columns: 0
731
732    * - Identifier
733      - Code
734      - Bits per component
735      - Subsampling
736      - Planes order [4]_
737      - Contiguous [5]_
738
739    * - V4L2_PIX_FMT_YUV410
740      - 'YUV9'
741      - 8
742      - 4:1:0
743      - Y, Cb, Cr
744      - Yes
745    * - V4L2_PIX_FMT_YVU410
746      - 'YVU9'
747      - 8
748      - 4:1:0
749      - Y, Cr, Cb
750      - Yes
751    * - V4L2_PIX_FMT_YUV411P
752      - '411P'
753      - 8
754      - 4:1:1
755      - Y, Cb, Cr
756      - Yes
757    * - V4L2_PIX_FMT_YUV420M
758      - 'YM12'
759      - 8
760      - 4:2:0
761      - Y, Cb, Cr
762      - No
763    * - V4L2_PIX_FMT_YVU420M
764      - 'YM21'
765      - 8
766      - 4:2:0
767      - Y, Cr, Cb
768      - No
769    * - V4L2_PIX_FMT_YUV420
770      - 'YU12'
771      - 8
772      - 4:2:0
773      - Y, Cb, Cr
774      - Yes
775    * - V4L2_PIX_FMT_YVU420
776      - 'YV12'
777      - 8
778      - 4:2:0
779      - Y, Cr, Cb
780      - Yes
781    * - V4L2_PIX_FMT_YUV422P
782      - '422P'
783      - 8
784      - 4:2:2
785      - Y, Cb, Cr
786      - Yes
787    * - V4L2_PIX_FMT_YUV422M
788      - 'YM16'
789      - 8
790      - 4:2:2
791      - Y, Cb, Cr
792      - No
793    * - V4L2_PIX_FMT_YVU422M
794      - 'YM61'
795      - 8
796      - 4:2:2
797      - Y, Cr, Cb
798      - No
799    * - V4L2_PIX_FMT_YUV444M
800      - 'YM24'
801      - 8
802      - 4:4:4
803      - Y, Cb, Cr
804      - No
805    * - V4L2_PIX_FMT_YVU444M
806      - 'YM42'
807      - 8
808      - 4:4:4
809      - Y, Cr, Cb
810      - No
811
812.. raw:: latex
813
814    \normalsize
815
816.. [4] Order of luma and chroma planes
817.. [5] Indicates if planes have to be contiguous in memory or can be
818       disjoint
819
820
821**Color Sample Location:**
822Chroma samples are :ref:`interstitially sited<yuv-chroma-centered>`
823horizontally.
824
825.. _V4L2-PIX-FMT-YUV410:
826.. _V4L2-PIX-FMT-YVU410:
827
828YUV410 and YVU410
829-----------------
830
831Planar YUV 4:1:0 formats. The chroma planes are subsampled by 4 in each
832direction. Chroma lines contain a quarter of the number of pixels and bytes of
833the luma lines, and the chroma planes contain a quarter of the number of lines
834of the luma plane.
835
836.. flat-table:: Sample 4x4 YUV410 Image
837    :header-rows:  0
838    :stub-columns: 0
839
840    * - start + 0:
841      - Y'\ :sub:`00`
842      - Y'\ :sub:`01`
843      - Y'\ :sub:`02`
844      - Y'\ :sub:`03`
845    * - start + 4:
846      - Y'\ :sub:`10`
847      - Y'\ :sub:`11`
848      - Y'\ :sub:`12`
849      - Y'\ :sub:`13`
850    * - start + 8:
851      - Y'\ :sub:`20`
852      - Y'\ :sub:`21`
853      - Y'\ :sub:`22`
854      - Y'\ :sub:`23`
855    * - start + 12:
856      - Y'\ :sub:`30`
857      - Y'\ :sub:`31`
858      - Y'\ :sub:`32`
859      - Y'\ :sub:`33`
860    * - start + 16:
861      - Cr\ :sub:`00`
862    * - start + 17:
863      - Cb\ :sub:`00`
864
865
866.. _V4L2-PIX-FMT-YUV411P:
867
868YUV411P
869-------
870
871Planar YUV 4:1:1 formats. The chroma planes are subsampled by 4 in the
872horizontal direction. Chroma lines contain a quarter of the number of pixels
873and bytes of the luma lines, and the chroma planes contain the same number of
874lines as the luma plane.
875
876.. flat-table:: Sample 4x4 YUV411P Image
877    :header-rows:  0
878    :stub-columns: 0
879
880    * - start + 0:
881      - Y'\ :sub:`00`
882      - Y'\ :sub:`01`
883      - Y'\ :sub:`02`
884      - Y'\ :sub:`03`
885    * - start + 4:
886      - Y'\ :sub:`10`
887      - Y'\ :sub:`11`
888      - Y'\ :sub:`12`
889      - Y'\ :sub:`13`
890    * - start + 8:
891      - Y'\ :sub:`20`
892      - Y'\ :sub:`21`
893      - Y'\ :sub:`22`
894      - Y'\ :sub:`23`
895    * - start + 12:
896      - Y'\ :sub:`30`
897      - Y'\ :sub:`31`
898      - Y'\ :sub:`32`
899      - Y'\ :sub:`33`
900    * - start + 16:
901      - Cb\ :sub:`00`
902    * - start + 17:
903      - Cb\ :sub:`10`
904    * - start + 18:
905      - Cb\ :sub:`20`
906    * - start + 19:
907      - Cb\ :sub:`30`
908    * - start + 20:
909      - Cr\ :sub:`00`
910    * - start + 21:
911      - Cr\ :sub:`10`
912    * - start + 22:
913      - Cr\ :sub:`20`
914    * - start + 23:
915      - Cr\ :sub:`30`
916
917
918.. _V4L2-PIX-FMT-YUV420:
919.. _V4L2-PIX-FMT-YVU420:
920.. _V4L2-PIX-FMT-YUV420M:
921.. _V4L2-PIX-FMT-YVU420M:
922
923YUV420, YVU420, YUV420M and YVU420M
924-----------------------------------
925
926Planar YUV 4:2:0 formats. The chroma planes are subsampled by 2 in each
927direction. Chroma lines contain half of the number of pixels and bytes of the
928luma lines, and the chroma planes contain half of the number of lines of the
929luma plane.
930
931.. flat-table:: Sample 4x4 YUV420 Image
932    :header-rows:  0
933    :stub-columns: 0
934
935    * - start + 0:
936      - Y'\ :sub:`00`
937      - Y'\ :sub:`01`
938      - Y'\ :sub:`02`
939      - Y'\ :sub:`03`
940    * - start + 4:
941      - Y'\ :sub:`10`
942      - Y'\ :sub:`11`
943      - Y'\ :sub:`12`
944      - Y'\ :sub:`13`
945    * - start + 8:
946      - Y'\ :sub:`20`
947      - Y'\ :sub:`21`
948      - Y'\ :sub:`22`
949      - Y'\ :sub:`23`
950    * - start + 12:
951      - Y'\ :sub:`30`
952      - Y'\ :sub:`31`
953      - Y'\ :sub:`32`
954      - Y'\ :sub:`33`
955    * - start + 16:
956      - Cr\ :sub:`00`
957      - Cr\ :sub:`01`
958    * - start + 18:
959      - Cr\ :sub:`10`
960      - Cr\ :sub:`11`
961    * - start + 20:
962      - Cb\ :sub:`00`
963      - Cb\ :sub:`01`
964    * - start + 22:
965      - Cb\ :sub:`10`
966      - Cb\ :sub:`11`
967
968.. flat-table:: Sample 4x4 YUV420M Image
969    :header-rows:  0
970    :stub-columns: 0
971
972    * - start0 + 0:
973      - Y'\ :sub:`00`
974      - Y'\ :sub:`01`
975      - Y'\ :sub:`02`
976      - Y'\ :sub:`03`
977    * - start0 + 4:
978      - Y'\ :sub:`10`
979      - Y'\ :sub:`11`
980      - Y'\ :sub:`12`
981      - Y'\ :sub:`13`
982    * - start0 + 8:
983      - Y'\ :sub:`20`
984      - Y'\ :sub:`21`
985      - Y'\ :sub:`22`
986      - Y'\ :sub:`23`
987    * - start0 + 12:
988      - Y'\ :sub:`30`
989      - Y'\ :sub:`31`
990      - Y'\ :sub:`32`
991      - Y'\ :sub:`33`
992    * -
993    * - start1 + 0:
994      - Cb\ :sub:`00`
995      - Cb\ :sub:`01`
996    * - start1 + 2:
997      - Cb\ :sub:`10`
998      - Cb\ :sub:`11`
999    * -
1000    * - start2 + 0:
1001      - Cr\ :sub:`00`
1002      - Cr\ :sub:`01`
1003    * - start2 + 2:
1004      - Cr\ :sub:`10`
1005      - Cr\ :sub:`11`
1006
1007
1008.. _V4L2-PIX-FMT-YUV422P:
1009.. _V4L2-PIX-FMT-YUV422M:
1010.. _V4L2-PIX-FMT-YVU422M:
1011
1012YUV422P, YUV422M and YVU422M
1013----------------------------
1014
1015Planar YUV 4:2:2 formats. The chroma planes are subsampled by 2 in the
1016horizontal direction. Chroma lines contain half of the number of pixels and
1017bytes of the luma lines, and the chroma planes contain the same number of lines
1018as the luma plane.
1019
1020.. flat-table:: Sample 4x4 YUV422P Image
1021    :header-rows:  0
1022    :stub-columns: 0
1023
1024    * - start + 0:
1025      - Y'\ :sub:`00`
1026      - Y'\ :sub:`01`
1027      - Y'\ :sub:`02`
1028      - Y'\ :sub:`03`
1029    * - start + 4:
1030      - Y'\ :sub:`10`
1031      - Y'\ :sub:`11`
1032      - Y'\ :sub:`12`
1033      - Y'\ :sub:`13`
1034    * - start + 8:
1035      - Y'\ :sub:`20`
1036      - Y'\ :sub:`21`
1037      - Y'\ :sub:`22`
1038      - Y'\ :sub:`23`
1039    * - start + 12:
1040      - Y'\ :sub:`30`
1041      - Y'\ :sub:`31`
1042      - Y'\ :sub:`32`
1043      - Y'\ :sub:`33`
1044    * - start + 16:
1045      - Cb\ :sub:`00`
1046      - Cb\ :sub:`01`
1047    * - start + 18:
1048      - Cb\ :sub:`10`
1049      - Cb\ :sub:`11`
1050    * - start + 20:
1051      - Cb\ :sub:`20`
1052      - Cb\ :sub:`21`
1053    * - start + 22:
1054      - Cb\ :sub:`30`
1055      - Cb\ :sub:`31`
1056    * - start + 24:
1057      - Cr\ :sub:`00`
1058      - Cr\ :sub:`01`
1059    * - start + 26:
1060      - Cr\ :sub:`10`
1061      - Cr\ :sub:`11`
1062    * - start + 28:
1063      - Cr\ :sub:`20`
1064      - Cr\ :sub:`21`
1065    * - start + 30:
1066      - Cr\ :sub:`30`
1067      - Cr\ :sub:`31`
1068
1069.. flat-table:: Sample 4x4 YUV422M Image
1070    :header-rows:  0
1071    :stub-columns: 0
1072
1073    * - start0 + 0:
1074      - Y'\ :sub:`00`
1075      - Y'\ :sub:`01`
1076      - Y'\ :sub:`02`
1077      - Y'\ :sub:`03`
1078    * - start0 + 4:
1079      - Y'\ :sub:`10`
1080      - Y'\ :sub:`11`
1081      - Y'\ :sub:`12`
1082      - Y'\ :sub:`13`
1083    * - start0 + 8:
1084      - Y'\ :sub:`20`
1085      - Y'\ :sub:`21`
1086      - Y'\ :sub:`22`
1087      - Y'\ :sub:`23`
1088    * - start0 + 12:
1089      - Y'\ :sub:`30`
1090      - Y'\ :sub:`31`
1091      - Y'\ :sub:`32`
1092      - Y'\ :sub:`33`
1093    * -
1094    * - start1 + 0:
1095      - Cb\ :sub:`00`
1096      - Cb\ :sub:`01`
1097    * - start1 + 2:
1098      - Cb\ :sub:`10`
1099      - Cb\ :sub:`11`
1100    * - start1 + 4:
1101      - Cb\ :sub:`20`
1102      - Cb\ :sub:`21`
1103    * - start1 + 6:
1104      - Cb\ :sub:`30`
1105      - Cb\ :sub:`31`
1106    * -
1107    * - start2 + 0:
1108      - Cr\ :sub:`00`
1109      - Cr\ :sub:`01`
1110    * - start2 + 2:
1111      - Cr\ :sub:`10`
1112      - Cr\ :sub:`11`
1113    * - start2 + 4:
1114      - Cr\ :sub:`20`
1115      - Cr\ :sub:`21`
1116    * - start2 + 6:
1117      - Cr\ :sub:`30`
1118      - Cr\ :sub:`31`
1119
1120
1121.. _V4L2-PIX-FMT-YUV444M:
1122.. _V4L2-PIX-FMT-YVU444M:
1123
1124YUV444M and YVU444M
1125-------------------
1126
1127Planar YUV 4:4:4 formats. The chroma planes are no subsampled. Chroma lines
1128contain the same number of pixels and bytes of the luma lines, and the chroma
1129planes contain the same number of lines as the luma plane.
1130
1131.. flat-table:: Sample 4x4 YUV444M Image
1132    :header-rows:  0
1133    :stub-columns: 0
1134
1135    * - start0 + 0:
1136      - Y'\ :sub:`00`
1137      - Y'\ :sub:`01`
1138      - Y'\ :sub:`02`
1139      - Y'\ :sub:`03`
1140    * - start0 + 4:
1141      - Y'\ :sub:`10`
1142      - Y'\ :sub:`11`
1143      - Y'\ :sub:`12`
1144      - Y'\ :sub:`13`
1145    * - start0 + 8:
1146      - Y'\ :sub:`20`
1147      - Y'\ :sub:`21`
1148      - Y'\ :sub:`22`
1149      - Y'\ :sub:`23`
1150    * - start0 + 12:
1151      - Y'\ :sub:`30`
1152      - Y'\ :sub:`31`
1153      - Y'\ :sub:`32`
1154      - Y'\ :sub:`33`
1155    * -
1156    * - start1 + 0:
1157      - Cb\ :sub:`00`
1158      - Cb\ :sub:`01`
1159      - Cb\ :sub:`02`
1160      - Cb\ :sub:`03`
1161    * - start1 + 4:
1162      - Cb\ :sub:`10`
1163      - Cb\ :sub:`11`
1164      - Cb\ :sub:`12`
1165      - Cb\ :sub:`13`
1166    * - start1 + 8:
1167      - Cb\ :sub:`20`
1168      - Cb\ :sub:`21`
1169      - Cb\ :sub:`22`
1170      - Cb\ :sub:`23`
1171    * - start1 + 12:
1172      - Cb\ :sub:`20`
1173      - Cb\ :sub:`21`
1174      - Cb\ :sub:`32`
1175      - Cb\ :sub:`33`
1176    * -
1177    * - start2 + 0:
1178      - Cr\ :sub:`00`
1179      - Cr\ :sub:`01`
1180      - Cr\ :sub:`02`
1181      - Cr\ :sub:`03`
1182    * - start2 + 4:
1183      - Cr\ :sub:`10`
1184      - Cr\ :sub:`11`
1185      - Cr\ :sub:`12`
1186      - Cr\ :sub:`13`
1187    * - start2 + 8:
1188      - Cr\ :sub:`20`
1189      - Cr\ :sub:`21`
1190      - Cr\ :sub:`22`
1191      - Cr\ :sub:`23`
1192    * - start2 + 12:
1193      - Cr\ :sub:`30`
1194      - Cr\ :sub:`31`
1195      - Cr\ :sub:`32`
1196      - Cr\ :sub:`33`
1197