1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
9 Planar formats split luma and chroma data in separate memory regions. They
10 exist in two variants:
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.
16 - Fully planar formats use three planes to store the Y, Cb and Cr components
19 Within a plane, components are stored in pixel order, which may be linear or
20 tiled. Padding may be supported at the end of the lines, and the line stride of
21 the chroma planes may be constrained by the line stride of the luma plane.
23 Some planar formats allow planes to be placed in independent memory locations.
24 They 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
26 and applications that support the multi-planar API, described in
27 :ref:`planar-apis`. Unless explicitly documented as supporting non-contiguous
28 planes, formats require the planes to follow each other immediately in memory.
31 Semi-Planar YUV Formats
32 =======================
34 These formats are commonly referred to as NV formats (NV12, NV16, ...). They
35 use two planes, and store the luma components in the first plane and the chroma
36 components in the second plane. The Cb and Cr components are interleaved in the
37 chroma plane, with Cb and Cr always stored in pairs. The chroma order is
38 exposed as different formats.
40 For memory contiguous formats, the number of padding pixels at the end of the
41 chroma lines is identical to the padding of the luma lines. Without horizontal
42 subsampling, the chroma line stride (in bytes) is thus equal to twice the luma
43 line stride. With horizontal subsampling by 2, the chroma line stride is equal
44 to the luma line stride. Vertical subsampling doesn't affect the line stride.
46 For non-contiguous formats, no constraints are enforced by the format on the
47 relationship between the luma and chroma line padding and stride.
49 All components are stored with the same number of bits per component.
55 .. tabularcolumns:: |p{5.2cm}|p{1.0cm}|p{1.5cm}|p{1.9cm}|p{1.2cm}|p{1.8cm}|p{2.7cm}|
57 .. flat-table:: Overview of Semi-Planar YUV Formats
82 * - V4L2_PIX_FMT_NV12M
89 * - V4L2_PIX_FMT_NV21M
96 * - V4L2_PIX_FMT_NV12MT
105 * - V4L2_PIX_FMT_NV12MT_16X16
112 * - V4L2_PIX_FMT_NV16
119 * - V4L2_PIX_FMT_NV61
126 * - V4L2_PIX_FMT_NV16M
133 * - V4L2_PIX_FMT_NV61M
140 * - V4L2_PIX_FMT_NV24
147 * - V4L2_PIX_FMT_NV42
159 .. [1] Order of chroma samples in the second plane
160 .. [2] Indicates if planes have to be contiguous in memory or can be
162 .. [3] Macroblock size in pixels
165 **Color Sample Location:**
166 Chroma samples are :ref:`interstitially sited<yuv-chroma-centered>`
170 .. _V4L2-PIX-FMT-NV12:
171 .. _V4L2-PIX-FMT-NV21:
172 .. _V4L2-PIX-FMT-NV12M:
173 .. _V4L2-PIX-FMT-NV21M:
175 NV12, NV21, NV12M and NV21M
176 ---------------------------
178 Semi-planar YUV 4:2:0 formats. The chroma plane is subsampled by 2 in each
179 direction. Chroma lines contain half the number of pixels and the same number
180 of bytes as luma lines, and the chroma plane contains half the number of lines
183 .. flat-table:: Sample 4x4 NV12 Image
218 .. flat-table:: Sample 4x4 NV12M Image
255 .. _V4L2-PIX-FMT-NV12MT:
256 .. _V4L2-PIX-FMT-NV12MT-16X16:
258 NV12MT and MV12MT_16X16
259 -----------------------
261 Semi-planar YUV 4:2:0 formats, using macroblock tiling. The chroma plane is
262 subsampled by 2 in each direction. Chroma lines contain half the number of
263 pixels and the same number of bytes as luma lines, and the chroma plane
264 contains half the number of lines of the luma plane.
266 ``V4L2_PIX_FMT_NV12MT_16X16`` stores pixel in 2D 16x16 macroblocks, and stores
267 macroblocks linearly in memory. The line stride and image height must be
268 aligned to a multiple of 16. The layouts of the luma and chroma planes are
271 ``V4L2_PIX_FMT_NV12MT`` stores pixels in 2D 64x32 macroblocks, and stores 2x2
272 groups of macroblocks in Z-order in memory, alternating Z and mirrored Z shapes
273 horizontally. The line stride must be a multiple of 128 pixels to ensure an
274 integer number of Z shapes. The image height must be a multiple of 32 pixels.
275 If the vertical resolution is an odd number of macroblocks, the last row of
276 macroblocks is stored in linear order. The layouts of the luma and chroma
277 planes are identical.
281 .. kernel-figure:: nv12mt.svg
285 V4L2_PIX_FMT_NV12MT macroblock Z shape memory layout
289 .. kernel-figure:: nv12mt_example.svg
290 :alt: nv12mt_example.svg
293 Example V4L2_PIX_FMT_NV12MT memory layout of macroblocks
296 .. _V4L2-PIX-FMT-NV16:
297 .. _V4L2-PIX-FMT-NV61:
298 .. _V4L2-PIX-FMT-NV16M:
299 .. _V4L2-PIX-FMT-NV61M:
301 NV16, NV61, NV16M and NV61M
302 ---------------------------
304 Semi-planar YUV 4:2:2 formats. The chroma plane is subsampled by 2 in the
305 horizontal direction. Chroma lines contain half the number of pixels and the
306 same number of bytes as luma lines, and the chroma plane contains the same
307 number of lines as the luma plane.
309 .. flat-table:: Sample 4x4 NV16 Image
354 .. flat-table:: Sample 4x4 NV16M Image
401 .. _V4L2-PIX-FMT-NV24:
402 .. _V4L2-PIX-FMT-NV42:
407 Semi-planar YUV 4:4:4 formats. The chroma plane is not subsampled.
408 Chroma lines contain the same number of pixels and twice the
409 number of bytes as luma lines, and the chroma plane contains the same
410 number of lines as the luma plane.
412 .. flat-table:: Sample 4x4 NV24 Image
474 Fully Planar YUV Formats
475 ========================
477 These formats store the Y, Cb and Cr components in three separate planes. The
478 luma plane comes first, and the order of the two chroma planes varies between
479 formats. The two chroma planes always use the same subsampling.
481 For memory contiguous formats, the number of padding pixels at the end of the
482 chroma lines is identical to the padding of the luma lines. The chroma line
483 stride (in bytes) is thus equal to the luma line stride divided by the
484 horizontal subsampling factor. Vertical subsampling doesn't affect the line
487 For non-contiguous formats, no constraints are enforced by the format on the
488 relationship between the luma and chroma line padding and stride.
490 All components are stored with the same number of bits per component.
496 .. tabularcolumns:: |p{5.0cm}|p{1.1cm}|p{1.5cm}|p{2.2cm}|p{1.2cm}|p{3.7cm}|
498 .. flat-table:: Overview of Fully Planar YUV Formats
509 * - V4L2_PIX_FMT_YUV410
515 * - V4L2_PIX_FMT_YVU410
521 * - V4L2_PIX_FMT_YUV411P
527 * - V4L2_PIX_FMT_YUV420M
533 * - V4L2_PIX_FMT_YVU420M
539 * - V4L2_PIX_FMT_YUV420
545 * - V4L2_PIX_FMT_YVU420
551 * - V4L2_PIX_FMT_YUV422P
557 * - V4L2_PIX_FMT_YUV422M
563 * - V4L2_PIX_FMT_YVU422M
569 * - V4L2_PIX_FMT_YUV444M
575 * - V4L2_PIX_FMT_YVU444M
586 .. [4] Order of luma and chroma planes
587 .. [5] Indicates if planes have to be contiguous in memory or can be
591 **Color Sample Location:**
592 Chroma samples are :ref:`interstitially sited<yuv-chroma-centered>`
595 .. _V4L2-PIX-FMT-YUV410:
596 .. _V4L2-PIX-FMT-YVU410:
601 Planar YUV 4:1:0 formats. The chroma planes are subsampled by 4 in each
602 direction. Chroma lines contain a quarter of the number of pixels and bytes of
603 the luma lines, and the chroma planes contain a quarter of the number of lines
606 .. flat-table:: Sample 4x4 YUV410 Image
636 .. _V4L2-PIX-FMT-YUV411P:
641 Planar YUV 4:1:1 formats. The chroma planes are subsampled by 4 in the
642 horizontal direction. Chroma lines contain a quarter of the number of pixels
643 and bytes of the luma lines, and the chroma planes contain the same number of
644 lines as the luma plane.
646 .. flat-table:: Sample 4x4 YUV411P Image
688 .. _V4L2-PIX-FMT-YUV420:
689 .. _V4L2-PIX-FMT-YVU420:
690 .. _V4L2-PIX-FMT-YUV420M:
691 .. _V4L2-PIX-FMT-YVU420M:
693 YUV420, YVU420, YUV420M and YVU420M
694 -----------------------------------
696 Planar YUV 4:2:0 formats. The chroma planes are subsampled by 2 in each
697 direction. Chroma lines contain half of the number of pixels and bytes of the
698 luma lines, and the chroma planes contain half of the number of lines of the
701 .. flat-table:: Sample 4x4 YUV420 Image
738 .. flat-table:: Sample 4x4 YUV420M Image
778 .. _V4L2-PIX-FMT-YUV422P:
779 .. _V4L2-PIX-FMT-YUV422M:
780 .. _V4L2-PIX-FMT-YVU422M:
782 YUV422P, YUV422M and YVU422M
783 ----------------------------
785 Planar YUV 4:2:2 formats. The chroma planes are subsampled by 2 in the
786 horizontal direction. Chroma lines contain half of the number of pixels and
787 bytes of the luma lines, and the chroma planes contain the same number of lines
790 .. flat-table:: Sample 4x4 YUV422P Image
839 .. flat-table:: Sample 4x4 YUV422M Image
891 .. _V4L2-PIX-FMT-YUV444M:
892 .. _V4L2-PIX-FMT-YVU444M:
897 Planar YUV 4:4:4 formats. The chroma planes are no subsampled. Chroma lines
898 contain the same number of pixels and bytes of the luma lines, and the chroma
899 planes contain the same number of lines as the luma plane.
901 .. flat-table:: Sample 4x4 YUV444M Image