#include <bitstrm.h>
Definition at line 61 of file bitstrm.h.
W_BITSTREAM::W_BITSTREAM | ( | ) | [inline] |
void W_BITSTREAM::open | ( | int | fd | ) |
Add a code to the bitstream.
Definition at line 107 of file bitstrm.cpp.
References bitbit, bitbuf, BITBUFSIZE, bitfd, bitindex, bitword, ERRCODE::error(), LOG, NULL, and WRITEFAILED.
00110 { 00111 if (length == 0) { 00112 //flushing 00113 if (bitbit > 0) 00114 //get last byte 00115 bitbuf[bitindex++] = (UINT8) bitword; 00116 if ((bitindex > 0) && 00117 (write (bitfd, (char *) bitbuf, bitindex * sizeof (UINT8)) != 00118 (INT32) (bitindex * sizeof (UINT8)))) { 00119 WRITEFAILED.error ("W_BITSTREAM::write_code", LOG, "Flushing"); 00120 return -1; 00121 } 00122 } 00123 else { 00124 bitword |= code << bitbit; //add new code 00125 bitbit += length; 00126 while (bitbit >= 8) { 00127 //get next byte 00128 bitbuf[bitindex++] = (UINT8) bitword; 00129 bitbit -= 8; 00130 bitword >>= 8; 00131 if (bitindex >= BITBUFSIZE) { 00132 if (write (bitfd, (char *) bitbuf, bitindex * sizeof (UINT8)) 00133 != (INT32) (bitindex * sizeof (UINT8))) { 00134 WRITEFAILED.error ("W_BITSTREAM::write_code", LOG, NULL); 00135 return -1; 00136 } 00137 bitindex = 0; //newly filled buffer 00138 } 00139 } 00140 } 00141 return 0; //success 00142 }
INT32 W_BITSTREAM::bitbit [private] |
UINT8 W_BITSTREAM::bitbuf[BITBUFSIZE] [private] |
int W_BITSTREAM::bitfd [private] |
INT32 W_BITSTREAM::bitindex [private] |
UINT32 W_BITSTREAM::bitword [private] |