xref: /OK3568_Linux_fs/kernel/Documentation/userspace-api/media/v4l/pixfmt-nv12mt.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun.. _V4L2-PIX-FMT-NV12MT:
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun****************************
6*4882a593SmuzhiyunV4L2_PIX_FMT_NV12MT ('TM12')
7*4882a593Smuzhiyun****************************
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunFormats with ½ horizontal and vertical chroma resolution. This format
10*4882a593Smuzhiyunhas two planes - one for luminance and one for chrominance. Chroma
11*4882a593Smuzhiyunsamples are interleaved. The difference to ``V4L2_PIX_FMT_NV12`` is the
12*4882a593Smuzhiyunmemory layout. Pixels are grouped in macroblocks of 64x32 size. The
13*4882a593Smuzhiyunorder of macroblocks in memory is also not standard.
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunDescription
17*4882a593Smuzhiyun===========
18*4882a593Smuzhiyun
19*4882a593SmuzhiyunThis is the two-plane versions of the YUV 4:2:0 format where data is
20*4882a593Smuzhiyungrouped into 64x32 macroblocks. The three components are separated into
21*4882a593Smuzhiyuntwo sub-images or planes. The Y plane has one byte per pixel and pixels
22*4882a593Smuzhiyunare grouped into 64x32 macroblocks. The CbCr plane has the same width,
23*4882a593Smuzhiyunin bytes, as the Y plane (and the image), but is half as tall in pixels.
24*4882a593SmuzhiyunThe chroma plane is also grouped into 64x32 macroblocks.
25*4882a593Smuzhiyun
26*4882a593SmuzhiyunWidth of the buffer has to be aligned to the multiple of 128, and height
27*4882a593Smuzhiyunalignment is 32. Every four adjacent buffers - two horizontally and two
28*4882a593Smuzhiyunvertically are grouped together and are located in memory in Z or
29*4882a593Smuzhiyunflipped Z order.
30*4882a593Smuzhiyun
31*4882a593SmuzhiyunLayout of macroblocks in memory is presented in the following figure.
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun.. _nv12mt:
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun.. kernel-figure:: nv12mt.svg
37*4882a593Smuzhiyun    :alt:    nv12mt.svg
38*4882a593Smuzhiyun    :align:  center
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun    V4L2_PIX_FMT_NV12MT macroblock Z shape memory layout
41*4882a593Smuzhiyun
42*4882a593SmuzhiyunThe requirement that width is multiple of 128 is implemented because,
43*4882a593Smuzhiyunthe Z shape cannot be cut in half horizontally. In case the vertical
44*4882a593Smuzhiyunresolution of macroblocks is odd then the last row of macroblocks is
45*4882a593Smuzhiyunarranged in a linear order.
46*4882a593Smuzhiyun
47*4882a593SmuzhiyunIn case of chroma the layout is identical. Cb and Cr samples are
48*4882a593Smuzhiyuninterleaved. Height of the buffer is aligned to 32.
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun.. _nv12mt_ex:
52*4882a593Smuzhiyun
53*4882a593Smuzhiyun.. kernel-figure:: nv12mt_example.svg
54*4882a593Smuzhiyun    :alt:    nv12mt_example.svg
55*4882a593Smuzhiyun    :align:  center
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun    Example V4L2_PIX_FMT_NV12MT memory layout of macroblocks
58*4882a593Smuzhiyun
59*4882a593SmuzhiyunMemory layout of macroblocks of ``V4L2_PIX_FMT_NV12MT`` format in most
60*4882a593Smuzhiyunextreme case.
61