AN9717: YCbCr to RGB Considerations (Multimedia)

YCbCr to RGB Considerations
TM
Application Note
March 1997
AN9717
Author: Keith Jack
Introduction
Converting 4:2:2 to 4:4:4 YCbCr
Many video ICs now generate 4:2:2 YCbCr video data. The
YCbCr color space was developed as part of ITU-R BT.601
(formerly CCIR 601) during the development of a world-wide
digital component video standard.
Prior to converting YCbCr data to R´G´B´ data, the 4:2:2
YCbCr data must be converted to 4:4:4 YCbCr data. For the
YCbCr to RGB conversion process, each Y sample must
have a corresponding Cb and Cr sample.
Some of these video ICs also generate digital RGB video
data, using lookup tables to assist with the YCbCr to RGB
conversion. By understanding the YCbCr to RGB conversion
process, the lookup tables can be eliminated, resulting in a
substantial cost savings.
Figure 1 illustrates the positioning of YCbCr samples for the
4:4:4 format. Each sample has a Y, a Cb, and a Cr value.
Each sample is typically 8 bits (consumer applications) or 10
bits (professional editing applications) per component.
This application note covers some of the considerations for
converting the YCbCr data to RGB data without the use of
lookup tables. The process basically consists of three steps:
1. 4:2:2 to 4:4:4 YCbCr Conversion
2. 4:4:4 YCbCr to RGB Conversion
3. Linear RGB Generation
Figure 2 illustrates the positioning of YCbCr samples for the
4:2:2 format. For every two horizontal Y samples, there is
one Cb and Cr sample. Each sample is typically 8 bits (consumer applications) or 10 bits (professional editing applications) per component.
The 4:2:2 to 4:4:4 conversion consists of generating interpolated Cb and Cr data for those Y samples that have no Cb
and Cr data. Although complex interpolation filtering is specified in BT.601, most NTSC and PAL video decoder chips
(such as the HMP8115) use simple linear interpolation. This
is usually acceptable since the bandwidth of the color data is
0.6MHz-1.3MHz, rather than the 3.375MHz bandwidth specified by BT.601.
†
FIGURE 1. 4:4:4 YCbCr SAMPLING STRUCTURE FOR A
625-LINE INTERLACED SYSTEM
1
FIGURE 2. 4:2:2 YCbCr SAMPLING STRUCTURE FOR A
625-LINE INTERLACED SYSTEM
CAUTION: These devices are sensitive to electrostatic discharge; follow proper IC Handling Procedures.
1-888-INTERSIL or 321-724-7143 | Intersil (and design) is a trademark of Intersil Americas Inc.
Copyright © Intersil Americas Inc. 2001. All Rights Reserved
R´G´B´ Generation
Linear RGB Generation
BT.601 defines Y to have a nominal range of 16-235 (blackwhite); Cb and Cr are defined to have a nominal range of 16240, with 128 corresponding to zero. YCbCr is also defined to
have been derived from gamma-corrected RGB (R´G´B´) data.
PCs usually prefer to use the linear RGB data format due to
the amount of software already written and the simplified algorithms. Gamma correction for the display monitor may then
done real-time in the GUI acceleration chip. Therefore, it may
be desirable to remove the gamma information from the
R´G´B´ data.
The BT.601 equations are used by many video ICs to convert between digital R´G´B´ data and YCbCr are:
Y = (77/256)R´ + (150/256)G´ + (29/256)B´
Cb = -(44/256)R´ - (87/256)G´ + (131/256)B´ + 128
Cr = (131/256)R´ - (110/256)G´ - (21/256)B´ + 128
R´ = Y + 1.371(Cr - 128)
G´ = Y - 0.698(Cr - 128) - 0.336(Cb - 128)
B´ = Y + 1.732(Cb - 128)
When performing YCbCr to R´G´B´ conversion using the
above equations, note that the resulting R´G´B´ values have
a nominal range of 16-235 (black-white). Occasional excursions into the 0-15 and 236-255 values are possible due to Y
and CbCr occasionally going outside the 16-235 and 16-240
ranges, respectively, due to video processing, rounding
errors, and noise.
However, if the 24-bit R´G´B´ data are to have a range of 0255 (black-white), as is commonly found in PCs, the following equations (used by the HMP8115) should be used to
maintain the correct black and white levels:
Y = 0.257R´ + 0.504G´ + 0.098B´ + 16
Cb = -0.148R´ - 0.291G´ + 0.439B´ + 128
Cr = 0.439R´ - 0.368G´ - 0.071B´ + 128
R´ = 1.164(Y - 16) + 1.596(Cr - 128)
G´ = 1.164(Y - 16) - 0.813(Cr - 128) 0.392(Cb - 128)
B´ = 1.164(Y - 16) + 2.017(Cb - 128)
For the YCbCr to R´G´B´ equations, the R´G´B´ values must
be saturated at the 0 and 255 levels due to occasional
excursions outside the nominal YCbCr ranges.
NTSC video is pre-corrected using a gamma of 2.2. Thus, to
generate 24-bit linear RGB data:
for (R´, G´, B´) < 21
R = ((R´/255) / 4.5) * 255
G = ((G´/255) / 4.5) * 255
B = ((B´/255) / 4.5) * 255
for (R´, G´, B´) ≥ 21
R = 255* (((R´/255) + 0.099) / 1.099)2.2
G = 255 * (((G´/255) + 0.099) / 1.099)2.2
B = 255 * (((B´/255) + 0.099) / 1.099)2.2
PAL video specifies a gamma of 2.8, although a value of 2.2
is now commonly used. If the video is pre-corrected using a
gamma of 2.8, the following equations may be used to generate 24-bit linear RGB data:
R = 255 * (R´/255)2.8
G = 255 * (G´/255)2.8
B = 255 * (B´/255)2.8
Many modern PAL video decoders, such as the HMP8115,
allow the selection of either the 2.2 or 2.8 gamma factor to
be used for calculations.
Summary
This Application Note discusses some of the considerations
for converting YCbCr video data to digital RGB. To ensure
proper black and white levels for the PC environment, the
basic BT.601 YCbCr to RGB equations should be slightly
modified to generate the full 0-255 RGB range. The generation of linear RGB data should also be optional, and is easily
implemented.
All Intersil U.S. products are manufactured, assembled and tested utilizing ISO9000 quality systems.
Intersil Corporation’s quality certifications can be viewed at www.intersil.com/design/quality
Intersil products are sold by description only. Intersil Corporation reserves the right to make changes in circuit design, software and/or specifications at any time without
notice. Accordingly, the reader is cautioned to verify that data sheets are current before placing orders. Information furnished by Intersil is believed to be accurate and
reliable. However, no responsibility is assumed by Intersil or its subsidiaries for its use; nor for any infringements of patents or other rights of third parties which may result
from its use. No license is granted by implication or otherwise under any patent or patent rights of Intersil or its subsidiaries.
For information regarding Intersil Corporation and its products, see www.intersil.com
2