Game Development Reference
In-Depth Information
void ComputeFDCT(uint GroupIndex, uint3 GroupThreadID)
{
DCT_MatrixTmp[GroupIndex] = 0;
[unroll] for ( int k=0;k<8;k++)
DCT_MatrixTmp[GroupIndex] += DCT_matrix[GroupThreadID.y*8+k] *
TransformedPixelData[k*8+GroupThreadID.x];
GroupMemoryBarrierWithGroupSync();
DCT_Coefficients[GroupIndex] = 0;
[unroll] for ( int k=0;k<8;k++)
DCT_Coefficients[GroupIndex] += DCT_MatrixTmp[GroupThreadID.y*8+k] *
DCT_matrix_transpose[k*8+GroupThreadID.x];
GroupMemoryBarrierWithGroupSync();
}
Listing 2.5. Forward cosine transform computed in parallel.
void ComputeQuantization(uint GroupIndex)
{
//Divide and round to nearest integer.
QuantizedComponents[GroupIndex] =
round( DCT_Coefficients[ZigZagIndices[GroupIndex]] /
Quantization_Table[GroupIndex]);
}
Listing 2.6. Quantization code.
void StreamCompactQuantizedData(uint GroupIndex)
{
//Set to 0 when a DC component or AC == 0.
if (GroupIndex > 0 && QuantizedComponents[GroupIndex] != 0)
ScanArray[GroupIndex] = 1;
else
ScanArray[GroupIndex] = 0;
GroupMemoryBarrierWithGroupSync();
Scan(GroupIndex);
if (GroupIndex > 0 && QuantizedComponents[GroupIndex] != 0)
{
RemappedValues[ScanArray[GroupIndex]] = QuantizedComponents[GroupIndex];
PrevIndex[ScanArray[GroupIndex]] = GroupIndex;
}
GroupMemoryBarrierWithGroupSync();
}
Listing 2.7. Calculate run-length zeros and stream compact AC coecients.
 
 
Search Nedrilad ::




Custom Search