tags: audio and video YUV420 NV12 ffmpeg
The YUV model defines a color space based on one brightness (Y component) and two chromaticities (UV components). The most common format is YUV420, which is divided into two types: YUV420P and YUV420SP.
YUV420P is the plane plane mode, and the Y, U, and V components are in different planes, that is, the data is stored in 3 arrays in ffmpeg.
It can be subdivided into YU12 and YV12.
The data distribution of this format is shown in the figure below. Y data is stored in data[0], U data is stored in data[1], and V data is stored in data[2].
Among them, Y, U, and V with the same color are a set of data, such as Y1, Y2, Y3, and Y4 share a set of U1 and V1.

The data distribution of this format is shown in the figure below. Y data is stored in data[0], V data is stored in data[1], and U data is stored in data[2].

YUV420SP is a semi-planar mode, that is, Y and UV are divided into two planes, but UV (CbCr) is interleaved instead of divided into three planes. That is, data is stored in 2 arrays in ffmpeg.
It can be subdivided into NV12 and NV21.
The data distribution of this format is shown in the figure below. Y data is stored in data[0], and U and V data are stored in data[1].

The data distribution of this format is shown in the figure below. Y data is stored in data[0], and U and V data are stored in data[1].

When actually storing data, in order to facilitate calculation, the data is often aligned, so the real data is stored as shown in the figure below.
Take YU12 as an example, other formats are similar.

references:
The YUV420 has a package, as described above. At the same time, there is a planar format, that is, Y, U, V is separately stored, each component accounts for a place, where Y is width * height, and hal...
1. Coordinate rotation: Suppose I want to rotate the angle b along the center of the image M, then I need to move the center of the image M to coincide with the center of the coordinate axis (otherwis...
BMP to RGB RGB to YU12 (YUV420P) YU12 to NV12 YU12 to NV21 NV12 to YU12 NV21 to YU12 Download link of complete project code: Upload later...
demoAVCaptureSessionNeed to modify the path plus/, adjust the path The obtained h264 isAVCCFormatted, cannot be used by VLC clientsRTSPPlay in mode, but can play locally. So looking for a breakthrough...
The above is NV21 to rgb, then how to write NV12 to rgb? Very simple, you can exchange the u and v code....
First, YV12 format description Second, NV12 format description Third, YUV420 format list Fourth, NV12 turn RGB24 Kenergy function implementation Reference: NV12 format turn RGB's CUDA implement...
Note that the ">>" and "<<" shift operators have lower priority than addition and subtraction;...
The data data callback from the callback method onPreviewFrame(byte[] data, Camera camera) of the Camera.PreviewCallback interface is NV21 image data, and the Android phone recognizes NV12 image data,...
### Date: 2017/5/25 ### Author: Soaringlee I420:YUV420p, the planar format, is stored in three independent arrays in the memory, first the Y array, then the U array, and finally the V array. The physi...