
2. Real-Time JPEG Compression Using DirectCompute 347
float Get_YCbCr_Component_From_RGB( float3 RGB)
{
#ifdef COMPONENT_Y
return dot(RGB, float3 (0.299 ,0.587 ,0.114)) * 255.0 f;
#elif COMPONENT_CB
return dot(RGB, float3 ( -0.168736 , -0.331264 ,0.5)) * 255.0 f + 128.0 f;
#elif COMPONENT_CR
return dot(RGB, float3 (0.5 , -0.418688 , -0.081312)) * 255.0 f + 128.0 f;
#endif
}
Listing 2.4. RGB to YC
b
C
r
conversion.
ter finished execution, each group has computed one 8 × 8 block of partial JPEG
data that is later processed by the CPU. One
Dispatch method call per color
plane is invoked. All relevant shader resources are set before each invocation.
Compute color transfo ...