YCbCr encoding format (YUV)

Source: Internet
Author: User

YCbCr is a commonly used color encoding solution for consumer video products such as DVDs, cameras, and digital TVs. YCbCr is sometimes called ycc .. 'Cbcr is also called ypbpr In the Analog Component Video (Analog Component Video. YCbCr is not an absolute color space, but a version of YUV compression and offset.

Differences between YCbCr and YUV

Just as the coordinate space is used to describe the coordinate set in ry, the color space is used to describe the color set in mathematics. The common three basic color models are RGB, CMYK, and YUV.

YCbCr is part of the ITU-r bt1601 recommendation during the development of the world's digital organization video standards. It is actually a version of YUV through scaling and offset. Among them, Y has the same meaning as Y in YUV. CB and Cr both refer to colors, but they only differ in the representation methods. In the YUV family, YCbCr is the most widely used member in computer systems. It is widely used in many fields and adopts JPEG and MPEG formats. Generally, YUV refers to YCbCr. YCbCr has many sampling formats, such as 4: 4: 4, 4: 2: 2, 4: 1: 1 and 4: 2: 0.

YUV

Video codecs

The video encoder requires video input in the yuv4: 2: 0 format. Therefore, video input preprocessing may be performed based on application requirements, that is, yuv4: 2 is scanned through the line (for example, from the camera) to YUV non-interlace scan conversion, only extract but not filter UV points. For video decoder, post-processing is also required to convert the decoded YUV data to RGB for display, including: YUV to RGB conversion; 16-bit or 12-bit RGB display format; rotate between 0 and 90 degrees for horizontal or vertical display. In addition, video codecs usually require the following functions and features:

Support MPEG-4 simple Class 0, 1 and 2;

Compatible with H.263 and MPEG-4 codec standard;

MPEG-4 Video Decoder supports the following options: AC/DC prediction, Reversible variable length encoding (RVLC), re-synchronization mark (RM), data split (DP) patented error hiding technology, support for 4 motion vectors (4mv) per Macro Block, free motion compensation, and decoding vos layer;

MPEG-4 Video Encoder options include: RVLC, RM, DP, support for each Macro Block 4 motion vectors (4mv) header extended code, support for bitrate Change During encoding, support for changing the Encoding Frame Rate During encoding, insert or not insert the starting code of the sequence of visual objects;

Supports insertion of I frames in the sequence during encoding;

Encoder auto-adaptive intra-frame refresh (air );

Supports multiple codecs and can be the sameCodeRun multiple decoder instances.

YCbCr

In YCbCr, y indicates the brightness component, CB indicates the blue color component, and CR indicates the red color component. The human eye is more sensitive to the Y component of the video. Therefore, after subsampling the color component to reduce the color component, the human eye will detect invisible changes in the image quality. The main subsampling formats are YCbCr, YCbCr, and YCbCr.

Represents 4 brightness components per 4 pixels, 2 color components (yyyycbcr), sampling only odd scanning lines, portable video devices (MPEG-4) and video conferencing (H.263) the most common format is. It indicates that each 4 pixels has four brightness components and four color components (yyyycbcrcbcr ), it is the most common format for DVD, digital TV, HDTV, and other consumer video devices. represents a full pixel dot matrix (yyyycbcrcbcrcbcrcbcr) for high-quality video applications, studios, and professional video products.

Edit the main sampling format of YUV in this section

The main sampling formats are YCbCr, and YCbCr. YCbCr is commonly used. It means that each vertex stores an 8-bit brightness value (that is, the Y value), and each 2x2 points stores a Cr and CB value, the image does not feel much changed to the naked eye. Therefore, the original RGB (R, G, and B are all 8bit unsigned) models. Each vertex requires 8x3 = 24 bits (such as the first image ). now, we only need 8 + (8/4) + (8/4) = 12 bites, and each point occupies 12 bites on average (such as the second figure ). In this way, the image data is halved.

The above only provides a theoretical example, which may be different in actual data storage. Below are several specific storage formats:

(1) YUV 4: 4

The sampling rate of the three channels of YUV is the same. Therefore, in the generated image, the information of the three components of each pixel is complete (each component is usually 8 bits). After 8 bits quantization, each uncompressed pixel occupies 3 bytes.

The following four pixels are: [y0 U0 V0] [Y1 U1 V1] [Y2 U2 V2] [Y3 U3 V3]

The stored code stream is y0 U0 V0 Y1 U1 V1 Y2 U2 V2 Y3 U3 v3

(2) YUV

The sampling rate of each chromatic aberration channel is half of the brightness channel, so the color sampling rate in the horizontal direction is only half. For non-compressed 8-bit quantization images, each macro pixel consisting of two adjacent horizontal pixels occupies 4 bytes of memory.

The following four pixels are: [y0 U0 V0] [Y1 U1 V1] [Y2 U2 V2] [Y3 U3 V3]

The stored code stream is y0 U0 Y1 V1 Y2 U2 Y3 v3

The mapped pixel is: [y0 U0 V1] [Y1 U0 V1] [Y2 U2 V3] [Y3 U2 V3]

(3) YUV

The color sampling at is a sample of the color in the horizontal direction. This is acceptable for low-end users and consumer products. For a non-compressed 8-bit video, each macro pixel consisting of four adjacent horizontal pixels occupies 6 bytes of memory.

The following four pixels are: [y0 U0 V0] [Y1 U1 V1] [Y2 U2 V2] [Y3 U3 V3]

The stored code stream is y0 U0 Y1 Y2 V2 Y3.

The mapped pixel is: [y0 U0 V2] [Y1 U0 V2] [Y2 U0 V2] [Y3 U0 V2]

(4) yuv4: 2: 0

Doesn't mean only y, CB, and no Cr component. It means that for each scanned line, only one color component is stored at a sampling rate of 2 to 1. The adjacent scan lines store different color components. That is to say, if the line is, the next line is, And the next line is... and so on. For each color component, the sampling rate in both the horizontal and vertical directions is, so the color sampling rate is. For non-compressed 8-bit quantization videos, each macro pixel consisting of 2x2, 2 rows, and 2 columns of adjacent pixels occupies 6 bytes of memory.

The following eight pixels are: [y0 U0 V0] [Y1 U1 V1] [Y2 U2 V2] [Y3 U3 V3]

[Y5 U5 V5] [y6 U6 V6] [y7u7 V7] [Y8 u8 V8]

The stored code stream is y0 U0 Y1 Y2 U2 Y3.

Y5 V5 y6 y7 V7 Y8

The mapped pixel is: [y0 U0 V5] [Y1 U0 V5] [Y2 U2 V7] [Y3 U2 V7]

[Y5 U0 V5] [y6 U0 V5] [y7u2 V7] [Y8 U2 V7]

Mutual conversion between YCbCr and RGB

Y = 0.299r + 0.587G + 0.114b

CB = 0.564 (B-Y)

Cr = 0.713 (R-Y)

R = Y + 1.402cr

G = Y-0.344Cb-0.714Cr

B = Y + 1.772cb

YCbCr simulation component ypbpr

YCbCr is sometimes called ycc. Y' cbcr, which is also known as ypbpr in Analog Component Video.

'Cbcr signal (prior to scaling and offsets to place the signals into digital form) is called ypbpr, in addition, the gamma-adjusted RGB source must conform to the following two constants: kb and kr: ypbpr (analog version of y'cbcr) from R 'G' B 'ypbpr (analog version of y' cbcr) from R 'G' B '====================================== ========================================================== ====================================

Y' = Kr * R' + (1-Kr-KB) * G' + kb * B 'y'

PB = 0.5 * (B '-y')/(1-KB) Pb = 0.5 * (B'-y')/(1-KB)

PR = 0.5 * (R'-y')/(1-KR) Pr = 0.5 * (R'-y')/(1-KR)

........................................ ........................................ ........................

R', G', B 'in [0; 1] R', G', B' in [0; 1]

Y' in [0; 1] y' in [0; 1]

Pb in [-0.5; 0.5] Pb in [-0.5; 0.5]

PR in [-0.5; 0.5] PR in [-0.5; 0.5]

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.