gDPSetConvert [Macro]

Function

gDPSetConvert

Sets the matrix coefficients for converting from YUV pixels to RGB

Syntax

#include <ultra64.h>        /* gbi.h */
gDPSetConvert(Gfx *gdl, s32 k0, s32 k1, s32 k2, s32 k3, s32 k4, s32 k5)
gsDPSetConvert(         s32 k0, s32 k1, s32 k2, s32 k3, s32 k4, s32 k5)

Arguments

gdl
Display list pointer.
k0
K0 term of the YUV-RGB conversion matrix (9-bit precision, -256~255).
k1
K1 term of the YUV-RGB conversion matrix (9-bit precision, -256~255).
k2
K2 term of the YUV-RGB conversion matrix (9-bit precision, -256~255).
k3
K3 term of the YUV-RGB conversion matrix (9-bit precision, -256~255).
k4
K4 term of the YUV-RGB conversion matrix (9-bit precision, -256~255).
k5
K5 term of the YUV-RGB conversion matrix (9-bit precision, -256~255).

Description

Sets the matrix coefficients used to convert YUV pixels into RGB. Conceptually, the equations are as shown below:
R = C0 * (Y-16) + C1 * V
G = C0 * (Y-16) + C2 * U - C3 * V
B = C0 * (Y-16) + C4 * U

Color conversion in the RDP is performed via the texture filter (TF) and the color combiner (CC).
The following calculations are executed in the TF:
R' = Y + K0 * V
G' = Y + K1 * U + K2 * V
B' = Y + K3 * U

The following calculations are executed in the CC:
R = (R' - K4) * K5 + R'
G = (G' - K4) * K5 + G'
B = (B' - K4) * K5 + B'

The relationships between Cn and Kn are shown below:
K0 = C1/C0
K1 = C2/C0
K2 = C3/C0
K3 = C4/C0
K4 = 16 + 16/(C0 - 1.0)
K5 = C0 - 1.0

The values normally used for the conversion from YUV to RGB are shown below:
K0 = 175
K1 = -43
K2 = -89
K3 = 222
K4 = 114
K5 = 42

Note

The CC and TF must be appropriately set when executing a color conversion. To learn more about these settings, see gDPSetCombineMode and gDPSetTextureConvert.

For further details, see Sections 12.5.2 "Color Space Conversion" and 12.6 "CC: Color Combiner" in the N64 Programming Manual.

See Also

gDPSetCombineMode, gDPSetTextureConvert,

Revision History

02/01/99   Completely rewritten