Original Post
Does anybody know how to write a bit stream in C/C++?
:o)
quote:
Original post by Pellanor
I don't suppose you could point me towards some resources on the topic?
// unwritten stream area must be prezeroed
void ClassHuffman::EmitCode(unsigned long dwCode,
char nCodeLen,
unsigned char *pStream,
unsigned long *dwBitPtr)
{
unsigned long dwBytePtr;
unsigned short wInBytePtr;
char i;
unsigned char chMask;
dwBytePtr = *dwBitPtr >> 3;
wInBytePtr = (unsigned short)(*dwBitPtr % 8);
for(i=0; i<nCodeLen; i++){
chMask = (unsigned short)(dwCode >> i) & 0x01;
if(chMask){
pStream[dwBytePtr] |= (chMask<<wInBytePtr);
}
(*dwBitPtr)++;
dwBytePtr = *dwBitPtr >> 3;
wInBytePtr = (unsigned short)(*dwBitPtr % 8);
}
}
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more