yuv420p Format Analysis

Source: Internet
Author: User

Transferred from: https://my.oschina.net/u/589963/blog/167766


The YUV format typically has two main classes: the packaged (packed) format and the planar format. The former stores YUV components in the same array, usually several adjacent pixels to form a macro pixel (Macro-pixel), and the latter uses three arrays to store the YUV three components separately.

yuv420p (planar format) is stored in ffmpeg in the data[] array of the struct avframe

Data[0]-------y component data[1]------u component Data[2]-------V Component


YUV420P's memory structure:

4 y components correspond to 1 UV components


The YUV420 format is that each pixel retains a Y (luminance) component, and in the horizontal direction, not each row takes the U and V components, but a row only takes the U component, then the next line takes only the V component, repeating (i.e. 4:2:0, 4:0:2, 4:2:0, 4:0:2 ...), So 420 does not mean no V, but a line of sampling takes u only, and the other line samples only v. At the time of taking U and V, take a U or v between each of the two Y. However, from the 4x4 matrix column, there is only one U and V in each of the 4 matrix point y regions, so their ratio is 4:1. So for a pixel, RGB requires 8 * 3 = 24 bits, which is 3 bytes, while yuv420p,8 + 8/4 + 8/4 = 12 bits, which accounts for 2 bytes, where 8 refers to the Y component, and 8/4 refers to the U and V components.


YUV420 Memory Format:

YYYYYYYY UU VV------The most common

YYYYYYYY UU VV------Yes, but I haven't seen it in my development.




We use FFmpeg to store the yuv420p in a file, and then use some YUV player can play YUV raw data, seemingly VLC can not play YUV raw data:

data[] is stored in the YUV raw data (in the struct avframe, located in frame.h----ffmpeg)



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.