< Previous | Contents | Next >
To declare constant memory, use CONSTANT . For example:
CONSTANT float NORM[] = {1.0f / 3.0f, 1.0f / 3.0f, 1.0f / 3.0f};
To pass the constant memory as a function argument, use the CONSTANTREF qualifier, e.g.:
DEVICE float DoSomething( CONSTANTREF float* p_Params)
A float value must have the âfâ character at the end (e.g. 1.2f).
A Simple DCT LUT Example
The following code shows an example of how to create a simple color gain transformation using the DCT LUT syntax.
// Example to demonstrate simple color gain transformation
DEVICE float3 transform(float p_R, float p_G, float p_B)
{
const float r = p_R * 1.2f; const float g = p_G * 1.1f; const float b = p_B * 1.2f; return make_float3(r, g, b);
}
A Matrix DCT LUT Example
The following code shows an example of creating a matrix transform using the DCT LUT syntax.
// Example to demonstrate the usage of user defined matrix type to transform RGB to YUV in Rec. 709
CONSTANT float RGBToYUVMat[9] = { 0.2126f , 0.7152f , 0.0722f,
-0.09991f, -0.33609f, 0.436f, 0.615f , -0.55861f, -0.05639f };
DEVICE float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p_R, float p_G, float p_B)
{
float3 result;
p_B; p_B; p_B;
result.x = RGBToYUVMat[0] * p_R + RGBToYUVMat[1] * p_G + RGBToYUVMat[2] * result.y = RGBToYUVMat[3] * p_R + RGBToYUVMat[4] * p_G + RGBToYUVMat[5] * result.z = RGBToYUVMat[6] * p_R + RGBToYUVMat[7] * p_G + RGBToYUVMat[8] *
return result;
}