4–7
The formulas for RGB to YCbCr conversion are:
Yd = 0.2126*Rd + 0.7152*Gd + 0.0722*Bd
Cb = –0.1172*Rd – 0.3942*Gd + 0.5114*Bd + 512
Cr = 0.5114*Rd – 0.4646*Gd – 0.0468*Bd + 512
To program the red coefficient of channel 1 (Y) with the value of 0.2126 the following must be done:
1.
Realize that this is a positive value so the sign bit of the integer part is 0. (bit 5 of csc_ric1 = 0)
2.
Note that there is no integer portion of the coefficient (bit 4–bit 0 = 00000).
3.
The binary representation of the fractional part can be constructed directly from the binary equivalent of the
fractional part multiplied by 1024 (0.2126
× 1024 = 217.7), rounded to the nearest integer (218) and
represented as a binary 10-bit number (00 1101 1010).
Using the above method all the registers for the CSC blocks can be programmed with the correct value for RGB to
YCbCr conversion. Below is a complete list of register values for the above conversion.
0.2126 –> csc_ric1 = 00 0000
csc_rfc1 = 00 1101 1010
0.7152 –> csc_gic1 = 00 0000
csc_gfc1 = 10 1101 1100
0.0722 –> csc_bic1 = 00 0000
csc_bfc1 = 00 0100 1010
–0.1172 –> csc_ric2 = 10 0000
csc_rfc2 = 00 0111 1000
–0.3942 –> csc_gic2 = 10 0000
csc_gfc2 = 01 1001 0100
0.5114 –> csc_bic2 = 00 0000
csc_bfc2 = 10 0000 1100
0.5114 –> csc_ric3 = 00 0000
csc_rfc3 = 10 0000 1100
–0.4646 –> csc_gic3 = 10 0000
csc_gfc3 = 01 1101 1100
–0.0468 –> csc_bic3 = 10 0000
csc_bfc3 = 00 0011 0000
For the offsets necessary in the second and third equation the csc_offset<n> registers need to be programmed. We
need to add 512 to the Cb and Cr channels. The value to be programmed is
1/4 of this offset in a signed magnitude
representation, thus 128 or csc_offset2 = csc_offset3 = 00 1000 0000.
Packing these individual registers into the I2C register map, the programmed values are:
SUBADDRESS
REGISTER NAME
VALUE
SUBADDRESS
REGISTER NAME
VALUE
0x04
csc_r11
0000 0000
0x0F
csc_g32
1101 1100
0x05
csc_r12
1101 1010
0x10
csc_b11
0000 0000
0x06
csc_r21
1000 0000
0x11
csc_b12
0100 1010
0x07
csc_r22
0111 1000
0x12
csc_b21
0000 0010
0x08
csc_r31
0000 0010
0x13
csc_b22
0000 1100
0x09
csc_r32
0000 1100
0x14
csc_b31
1000 0000
0x0A
csc_g11
0000 0010
0x15
csc_b32
0011 0000
0x0B
csc_g12
1101 1100
0x16
csc_offs1
0000 0000
0x0C
csc_g21
1000 0001
0x17
csc_offs12
0000 1000
0x0D
csc_g22
1001 0100
0x18
csc_offs23
0000 0010
0x0E
csc_g31
1000 0001
0x19
csc_offs3
0000 0000
CSC configuration example: HDTV YCbCr to HDTV RGB
Gd = –0.4577*Cr + Yd – 0.1831*Cb +328 (= 0.6408*128*4)
Bd = 0*Cr + Yd + 1.8142* Cb – 929 (= –1.8142*128*4)
Rd = 1.5396* Cr +Yd +0*Cb – 788 (= –1.5396*128*4)