Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
литература / Digital_Video_and_HD_Second_Edition_Algorithms_and_Interfaces.pdf
Скачиваний:
0
Добавлен:
13.05.2026
Размер:
38.02 Mб
Скачать

Eq 29.6

Eq 29.7

To obtain 8-bit BT.601 Y’CBCR from R’G’B’ ranging 0 to 1, scale the rows of the matrix in Equation 29.3 by the factors 219, 224, and 224, corresponding to the excursions of each of Y’, CB, and CR, respectively:

 

601Y’

16

 

 

65.481

128.553

 

 

24.966

R’

219

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

CB

= 128

 

+

 

37.797

 

74.203

112

 

· G’

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

C

R

 

128

 

112

 

93.786

 

 

18.214

B’

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Summing the top row of this matrix yields 219, the luma excursion. The lower two rows sum to zero. The two entries of 112 reflect the positive CB and CR extrema, at the blue and red primaries.

To recover R’G’B’ in the range [0…+1] from 8-bit BT.601 Y’CBCR, invert Equation 29.6:

R’

0.00456621

0

 

0.00625893

601Y’

 

16

 

 

 

 

 

 

 

 

 

219

 

 

 

 

G’

= 0.00456621

 

0.00153396

 

0.00318811

·

CB

 

 

128

 

 

 

 

 

 

 

0.00791071

0

 

 

CR

 

 

 

 

B’

0.00456621

 

 

 

 

128

 

You can determine the excursion that an encoding matrix is designed to produce – often 1, 219, 255, or 256 – by summing the coefficients in the top row. In Equation 29.8, the sum is 256. If you find an unexpected sum, suspect an error in the matrix.

Eq 29.8

This matrix contains entries larger than 256; the corresponding multipliers will need capability for more than 8 bits.

When rounding the matrix coefficients, take care to preserve the intended row sums, in this case, [1, 0, 0]. You must take care to prevent overflow due to roundoff error or other conditions: Use saturating arithmetic.

At the interface, after adding the offsets, clip all three components to the range 1 through 254 inclusive, to avoid the prohibited codes 0 and 255.

Y’CBCR from studio RGB

In studio equipment, 8-bit R’G’B’ components usually have the same 219 excursion as the luma component of Y’CBCR. To encode 8-bit BT.601 Y’CBCR from R’G’B’ in the range [0…219], scale the encoding matrix of Equation 29.6 by 256219:

219601Y'

 

 

 

16

 

 

1

 

 

76.544

150.272

29.184

 

 

 

219R'

 

 

 

 

 

 

CB

 

 

 

128

 

 

 

 

 

 

43.366

 

 

 

85.136

128.502

 

 

 

219G'

 

 

 

 

 

256

 

 

 

 

 

 

 

 

 

 

CR

 

 

 

128

 

 

 

 

128.502

 

107.604

 

 

20.898

 

 

 

219B'

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

For implementation in binary arithmetic, the multiplication by 1256 can be accomplished by shifting. To

364

DIGITAL VIDEO AND HD ALGORITHMS AND INTERFACES

decode to R’G’B’ in the range [0…219] from 8-bit BT.601 Y’CBCR, invert Equation 29.8:

 

219R’

 

 

256

0

350.901

 

 

219601Y’

 

16

 

 

 

 

 

 

Eq 29.9

G’

 

1

 

256

 

86.132

 

178.738

 

 

C

B

 

 

 

128

 

219

 

256

 

 

 

 

 

 

 

 

 

 

 

 

 

 

219B’

 

 

256

443.506

0

 

 

CR

 

 

 

128

 

 

 

 

 

 

The entries of 256 in this matrix indicate that the corresponding component can simply be added; there is no need for a multiplication operation. These transforms assume that the R’G’B’ components incorporate gamma correction, such as that specified by BT.709; see page 333.

Y’CBCR from computer RGB

In computing it is conventional to use 8-bit R’G’B’ components, with no headroom and no footroom: Black is at code 0 and white is at 255. To encode 8-bit BT.601 Y’CBCR from R’G’B’ in this range, scale the matrix of Equation 29.6 by 256255:

 

Y’

 

 

 

16

 

 

1

 

 

65.738

129057.

25.064

 

 

 

255R’

 

 

 

 

 

 

 

 

Eq 29.10

CB

 

 

 

128

 

 

 

 

 

37.945

 

74.494

112439.

 

 

 

255

 

 

 

 

 

256

 

 

 

 

 

 

 

CR

 

 

 

128

 

 

 

112439.

 

94.154

 

 

18.285

 

 

 

255B’

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

To decode R’G’B’ in the range [0…255] from 8-bit

BT.601 Y’CBCR, use the transform of Equation 29.11:

 

255R’

 

 

298082.

0

408.583

 

 

219601Y’

 

16

 

 

 

 

 

 

Eq 29.11

255G’

 

1

 

298082.

 

100291.

 

208120.

 

 

CB

 

 

 

128

 

256

 

 

 

 

255B’

 

298082.

516411.

0

 

 

CR

 

 

 

128

 

 

 

 

 

 

 

 

 

 

 

 

BT.601 Y’CBCR uses the extremes of the coding range to handle signal overshoot and undershoot. Clipping is required when decoding to an R’G’B’ range that has no headroom or footroom.

“Full-swing” Y’CBCR

The Y’CBCR coding used in JPEG/JFIF stillframes in computing conventionally uses “full-swing” coding with no footroom and no headroom. Luma (Y’) is scaled to an excursion of 255 and represented in 8 bits: Black is at code 0 and white is at code 255. Obviously, luma codes 0 and 255 are not prohibited! Colour difference

CHAPTER 29

COMPONENT VIDEO COLOUR CODING FOR SD

365

Figure 29.5 CBCR “fullrange” components used in JPEG/JFIF are shown. CB and CRare scaled to ±127.5; however, they are encoded into a two’s complement range of -128 to +127. Chroma codes +127.5 are clipped; fully saturated blue and red cannot be preserved. No provision is made for undershoot or overshoot. The accompanying luma signal ranges 0 through 255.

R

 

CR axis

 

127.5

Mg

 

 

Yl

 

127.5

 

 

-127.5

0

B

 

 

G

 

Cy

 

 

-127.5

 

CR code +127.5 clipped; 100% red not coded

CB code +127.5 clipped; 100% blue not coded

CB axis

(clipped)

+127.5

+127

0

-128

components are scaled to an excursion of ±127.5; each colour difference component nominally has the same excursion as luma. However, an offset of +128 is applied (instead of the +127.5 that you might expect), apparently so that pure grey has an integer code value. The +128 offset causes pure blue and pure red to take post-offset values of 255.5, which clip. Figure 29.4 shows the transfer function of the colour difference

0quantizer, emphasizing that pre-offset chroma code

Figure 29.4 A “full-swing” CBCR quantizer is used in JPEG/JFIF. Code +127.5 – required to represent pure blue or red – is clipped.

Eq 29.12

+127.5 (pure blue, or pure red) causes clipping. As

a consequence, pure blue and pure red are liable to fail to make the “round-trip” accurately through JPEG/JFIF compression and decompression. Figure 29.5 above shows the full-range CBCR colour difference plane.

To encode from R’G’B’ in the range [0…255] into 8-bit Y’CBCR, with luma in the range [0…255] and CB and CR each ranging ±128, use this transform:

 

 

 

 

 

 

76.544

150.272

29.184

 

 

255R

 

 

601Y

 

 

 

255

 

=

1

 

43.366

85.136

128.502

 

 

 

 

 

C

 

 

 

G

256

255

 

B

 

 

 

128.502

107.604

20.898

 

 

B

 

 

C

 

 

 

 

 

 

 

 

 

R

 

 

 

 

 

 

 

 

 

255

 

 

To decode into R’G’B’ in the range [0…255] from fullrange 8-bit Y’CBCR, use the transform in Equation 29.13:

 

 

 

R'

 

1

256

0

357.510

601Y'

Eq 29.13

 

255

 

 

 

 

 

 

 

255

 

 

255G'

=

 

256

87.755

182.105

C

 

256

 

 

 

 

 

 

451.860

0

 

 

B

 

 

 

255B'

 

 

256

 

 

C

 

 

 

 

 

 

 

 

 

 

 

 

R

 

366

DIGITAL VIDEO AND HD ALGORITHMS AND INTERFACES

Y’UV, Y’IQ confusion

Ihave detailed Y’PBPR and Y’CBCR. These are both based on [B’-Y’, R’-Y’] components, but they have different

scale factors suitable for component analog and component digital interface, respectively.

Colour differences pairs [U, V] and [I, Q] are also based on B’-Y’ and R’-Y’, but have yet another set of scale factors. UV scaling – or IQ scaling and rotation – is appropriate only when the signals are destined for composite encoding, as in NTSC or PAL.

Unfortunately, the notation Y’UV – or worse, YUV – is sometimes loosely applied to any form of colour difference coding based on [B’-Y’, R’-Y’]. Do not be misled by video equipment having connectors labelled Y’UV or Y’, B’-Y’, R’-Y’, or these symbols without primes, or by JPEG being described as utilizing Y’UV coding. In fact

the analog connectors convey signals with Y’PBPR scaling, and the JPEG standard itself specifies what

Iwould denote 255601Y’CBCR.

When the term Y’UV (or YUV) is encountered in a computer graphics or image-processing context, usually BT.601 Y’CBCR is meant, but beware!

Any image data supposedly coded to the original 1953 NTSC primaries is suspect, because it has been roughly four decades since any equipment using these primaries has been built.

Generally no mention is made of the transfer function of the underlying R’G’B’ components, and no account is taken of the nonlinear formation of luma.

When the term Y’IQ (or YIQ) is encountered, beware!

Image data supposedly coded in Y’IQ is suspect since no analog or digital interface for Y’IQ components has ever been standardized.

NTSC encoders and decoders built since 1970 have been based upon Y’UV components, not Y’IQ. Contrary to much published information, Y’IQ components have not been used for “NTSC” for about 4 decades.

CHAPTER 29

COMPONENT VIDEO COLOUR CODING FOR SD

367

This page intentionally left blank

Соседние файлы в папке литература