W_BITSTREAM Class Reference

#include <bitstrm.h>

List of all members.


Detailed Description

Class for writing image after processing.

Definition at line 61 of file bitstrm.h.

Public Member Functions

Private Attributes


Constructor & Destructor Documentation

W_BITSTREAM::W_BITSTREAM (  )  [inline]

Definition at line 76 of file bitstrm.h.

00076                   { 
00077     };                           //Null constructor


Member Function Documentation

void W_BITSTREAM::open ( int  fd  ) 

Establish a bitstream for writing.

Definition at line 94 of file bitstrm.cpp.

References bitbit, bitfd, bitindex, and bitword.

00096                         {
00097   bitfd = fd;
00098   bitindex = 0;
00099   bitword = 0;
00100   bitbit = 0;
00101 }

INT8 W_BITSTREAM::write_code ( UINT16  code,
UINT8  length 
)

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 }


Member Data Documentation

INT32 W_BITSTREAM::bitbit [private]

Current bit.

Definition at line 71 of file bitstrm.h.

Referenced by open(), and write_code().

UINT8 W_BITSTREAM::bitbuf[BITBUFSIZE] [private]

Bitstream buffer.

Definition at line 73 of file bitstrm.h.

Referenced by write_code().

int W_BITSTREAM::bitfd [private]

File descriptor.

Definition at line 65 of file bitstrm.h.

Referenced by open(), and write_code().

INT32 W_BITSTREAM::bitindex [private]

Current byte.

Definition at line 67 of file bitstrm.h.

Referenced by open(), and write_code().

UINT32 W_BITSTREAM::bitword [private]

Current word.

Definition at line 69 of file bitstrm.h.

Referenced by open(), and write_code().


The documentation for this class was generated from the following files:
Generated on Wed Feb 28 19:49:34 2007 for Tesseract by  doxygen 1.5.1