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.
51 .. flat-table:: Overview of Semi-Planar YUV Formats
76 * - V4L2_PIX_FMT_NV12M
83 * - V4L2_PIX_FMT_NV21M
90 * - V4L2_PIX_FMT_NV12MT
99 * - V4L2_PIX_FMT_NV12MT_16X16
106 * - V4L2_PIX_FMT_NV16
113 * - V4L2_PIX_FMT_NV61
120 * - V4L2_PIX_FMT_NV16M
127 * - V4L2_PIX_FMT_NV61M
134 * - V4L2_PIX_FMT_NV24
141 * - V4L2_PIX_FMT_NV42
151 .. [1] Order of chroma samples in the second plane
152 .. [2] Indicates if planes have to be contiguous in memory or can be
154 .. [3] Macroblock size in pixels
157 **Color Sample Location:**
158 Chroma samples are :ref:`interstitially sited<yuv-chroma-centered>`
162 .. _V4L2-PIX-FMT-NV12:
163 .. _V4L2-PIX-FMT-NV21:
164 .. _V4L2-PIX-FMT-NV12M:
165 .. _V4L2-PIX-FMT-NV21M:
167 NV12, NV21, NV12M and NV21M
168 ---------------------------
170 Semi-planar YUV 4:2:0 formats. The chroma plane is subsampled by 2 in each
171 direction. Chroma lines contain half the number of pixels and the same number
172 of bytes as luma lines, and the chroma plane contains half the number of lines
175 .. flat-table:: Sample 4x4 NV12 Image
210 .. flat-table:: Sample 4x4 NV12M Image
247 .. _V4L2-PIX-FMT-NV12MT:
248 .. _V4L2-PIX-FMT-NV12MT-16X16:
250 NV12MT and MV12MT_16X16
251 -----------------------
253 Semi-planar YUV 4:2:0 formats, using macroblock tiling. The chroma plane is
254 subsampled by 2 in each direction. Chroma lines contain half the number of
255 pixels and the same number of bytes as luma lines, and the chroma plane
256 contains half the number of lines of the luma plane.
258 ``V4L2_PIX_FMT_NV12MT_16X16`` stores pixel in 2D 16x16 macroblocks, and stores
259 macroblocks linearly in memory. The line stride and image height must be
260 aligned to a multiple of 16. The layouts of the luma and chroma planes are
263 ``V4L2_PIX_FMT_NV12MT`` stores pixels in 2D 64x32 macroblocks, and stores 2x2
264 groups of macroblocks in Z-order in memory, alternating Z and mirrored Z shapes
265 horizontally. The line stride must be a multiple of 128 pixels to ensure an
266 integer number of Z shapes. The image height must be a multiple of 32 pixels.
267 If the vertical resolution is an odd number of macroblocks, the last row of
268 macroblocks is stored in linear order. The layouts of the luma and chroma
269 planes are identical.
273 .. kernel-figure:: nv12mt.svg
277 V4L2_PIX_FMT_NV12MT macroblock Z shape memory layout
281 .. kernel-figure:: nv12mt_example.svg
282 :alt: nv12mt_example.svg
285 Example V4L2_PIX_FMT_NV12MT memory layout of macroblocks
288 .. _V4L2-PIX-FMT-NV16:
289 .. _V4L2-PIX-FMT-NV61:
290 .. _V4L2-PIX-FMT-NV16M:
291 .. _V4L2-PIX-FMT-NV61M:
293 NV16, NV61, NV16M and NV61M
294 ---------------------------
296 Semi-planar YUV 4:2:2 formats. The chroma plane is subsampled by 2 in the
297 horizontal direction. Chroma lines contain half the number of pixels and the
298 same number of bytes as luma lines, and the chroma plane contains the same
299 number of lines as the luma plane.
301 .. flat-table:: Sample 4x4 NV16 Image
346 .. flat-table:: Sample 4x4 NV16M Image
393 .. _V4L2-PIX-FMT-NV24:
394 .. _V4L2-PIX-FMT-NV42:
399 Semi-planar YUV 4:4:4 formats. The chroma plane is subsampled by 2 in the
400 horizontal direction. Chroma lines contain half the number of pixels and the
401 same number of bytes as luma lines, and the chroma plane contains the same
402 number of lines as the luma plane.
404 .. flat-table:: Sample 4x4 NV24 Image
466 Fully Planar YUV Formats
467 ========================
469 These formats store the Y, Cb and Cr components in three separate planes. The
470 luma plane comes first, and the order of the two chroma planes varies between
471 formats. The two chroma planes always use the same subsampling.
473 For memory contiguous formats, the number of padding pixels at the end of the
474 chroma lines is identical to the padding of the luma lines. The chroma line
475 stride (in bytes) is thus equal to the luma line stride divided by the
476 horizontal subsampling factor. Vertical subsampling doesn't affect the line
479 For non-contiguous formats, no constraints are enforced by the format on the
480 relationship between the luma and chroma line padding and stride.
482 All components are stored with the same number of bits per component.
484 .. flat-table:: Overview of Fully Planar YUV Formats
495 * - V4L2_PIX_FMT_YUV410
501 * - V4L2_PIX_FMT_YVU410
507 * - V4L2_PIX_FMT_YUV411P
513 * - V4L2_PIX_FMT_YUV420M
519 * - V4L2_PIX_FMT_YVU420M
525 * - V4L2_PIX_FMT_YUV420
531 * - V4L2_PIX_FMT_YVU420
537 * - V4L2_PIX_FMT_YUV422P
543 * - V4L2_PIX_FMT_YUV422M
549 * - V4L2_PIX_FMT_YVU422M
555 * - V4L2_PIX_FMT_YUV444M
561 * - V4L2_PIX_FMT_YVU444M
570 .. [4] Order of luma and chroma planes
571 .. [5] Indicates if planes have to be contiguous in memory or can be
575 **Color Sample Location:**
576 Chroma samples are :ref:`interstitially sited<yuv-chroma-centered>`
579 .. _V4L2-PIX-FMT-YUV410:
580 .. _V4L2-PIX-FMT-YVU410:
585 Planar YUV 4:1:0 formats. The chroma planes are subsampled by 4 in each
586 direction. Chroma lines contain a quarter of the number of pixels and bytes of
587 the luma lines, and the chroma planes contain a quarter of the number of lines
590 .. flat-table:: Sample 4x4 YUV410 Image
620 .. _V4L2-PIX-FMT-YUV411P:
625 Planar YUV 4:1:1 formats. The chroma planes are subsampled by 4 in the
626 horizontal direction. Chroma lines contain a quarter of the number of pixels
627 and bytes of the luma lines, and the chroma planes contain the same number of
628 lines as the luma plane.
630 .. flat-table:: Sample 4x4 YUV411P Image
672 .. _V4L2-PIX-FMT-YUV420:
673 .. _V4L2-PIX-FMT-YVU420:
674 .. _V4L2-PIX-FMT-YUV420M:
675 .. _V4L2-PIX-FMT-YVU420M:
677 YUV420, YVU420, YUV420M and YVU420M
678 -----------------------------------
680 Planar YUV 4:2:0 formats. The chroma planes are subsampled by 2 in each
681 direction. Chroma lines contain half of the number of pixels and bytes of the
682 luma lines, and the chroma planes contain half of the number of lines of the
685 .. flat-table:: Sample 4x4 YUV420 Image
722 .. flat-table:: Sample 4x4 YUV420M Image
762 .. _V4L2-PIX-FMT-YUV422P:
763 .. _V4L2-PIX-FMT-YUV422M:
764 .. _V4L2-PIX-FMT-YVU422M:
766 YUV422P, YUV422M and YVU422M
767 ----------------------------
769 Planar YUV 4:2:2 formats. The chroma planes are subsampled by 2 in the
770 horizontal direction. Chroma lines contain half of the number of pixels and
771 bytes of the luma lines, and the chroma planes contain the same number of lines
774 .. flat-table:: Sample 4x4 YUV422P Image
823 .. flat-table:: Sample 4x4 YUV422M Image
875 .. _V4L2-PIX-FMT-YUV444M:
876 .. _V4L2-PIX-FMT-YVU444M:
881 Planar YUV 4:4:4 formats. The chroma planes are no subsampled. Chroma lines
882 contain the same number of pixels and bytes of the luma lines, and the chroma
883 planes contain the same number of lines as the luma plane.
885 .. flat-table:: Sample 4x4 YUV444M Image