Game Development Reference
In-Depth Information
//AC symbol 1
result.BS[3] = AC_Huffman[((PrecedingZeros % 16) << 4) + nbits];
//AC symbol 2
if (tmp < 0) tmp--;
result.BS[4] = (nbits << 16) | (tmp & (mask[nbits] - 1));
//Insert end of block (EOB) symbol?
if (PrevIndex[GroupIndex] != 63 && RemappedValues[GroupIndex+1] == 0)
{
result.BS[5] = M_EOB;
}
}
//Calculate total bit count.
[unroll] for ( int i=0;i<6;i++)
{
if (result.BS[i] != 0)
{
result.NumEntropyBits += (result.BS[i] >> 16);
}
}
return result;
}
Listing 2.8. Construction of bit strings.
Entropy code AC coe cients. When using precomputed Huffman tables, VLE on
GPU hardware has previously been shown to be ecient [Balevic 09]. Each
constructed bit string is appended to a bit stream in shared memory. Bits are
appended using the atomic intrinsic function InterlockedOr .Whena lthreads
have finished entropy coding, as seen in Listing 2.9, the final block output is copied
to device memory. The last group thread is also responsible for outputting the
bit count of the AC entropy data.
void EntropyCodeAC(uint GroupIndex, BSResult result)
{
ScanArray[GroupIndex] = result.NumEntropyBits;
Scan(GroupIndex);
uint bitpos = ScanArray[GroupIndex];
[unroll] for ( int i=0;i<6;i++)
{
if (result.BS[i] != 0)
{
Write(result.BS[i], bitpos);
bitpos += result.BS[i] >> 16;
}
}
GroupMemoryBarrierWithGroupSync();
}
Listing 2.9. Entropy coding of group AC coecients.
 
Search Nedrilad ::




Custom Search