^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) .. _V4L2-PIX-FMT-NV12MT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) ****************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) V4L2_PIX_FMT_NV12MT ('TM12')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) ****************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) Formats with ½ horizontal and vertical chroma resolution. This format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) has two planes - one for luminance and one for chrominance. Chroma
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) samples are interleaved. The difference to ``V4L2_PIX_FMT_NV12`` is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) memory layout. Pixels are grouped in macroblocks of 64x32 size. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) order of macroblocks in memory is also not standard.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) This is the two-plane versions of the YUV 4:2:0 format where data is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) grouped into 64x32 macroblocks. The three components are separated into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) two sub-images or planes. The Y plane has one byte per pixel and pixels
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) are grouped into 64x32 macroblocks. The CbCr plane has the same width,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) in bytes, as the Y plane (and the image), but is half as tall in pixels.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) The chroma plane is also grouped into 64x32 macroblocks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) Width of the buffer has to be aligned to the multiple of 128, and height
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) alignment is 32. Every four adjacent buffers - two horizontally and two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) vertically are grouped together and are located in memory in Z or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) flipped Z order.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) Layout of macroblocks in memory is presented in the following figure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) .. _nv12mt:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) .. kernel-figure:: nv12mt.svg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) :alt: nv12mt.svg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) :align: center
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) V4L2_PIX_FMT_NV12MT macroblock Z shape memory layout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) The requirement that width is multiple of 128 is implemented because,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) the Z shape cannot be cut in half horizontally. In case the vertical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) resolution of macroblocks is odd then the last row of macroblocks is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) arranged in a linear order.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) In case of chroma the layout is identical. Cb and Cr samples are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) interleaved. Height of the buffer is aligned to 32.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) .. _nv12mt_ex:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) .. kernel-figure:: nv12mt_example.svg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) :alt: nv12mt_example.svg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) :align: center
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) Example V4L2_PIX_FMT_NV12MT memory layout of macroblocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) Memory layout of macroblocks of ``V4L2_PIX_FMT_NV12MT`` format in most
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) extreme case.