R_BITSTREAM Class Reference

#include <bitstrm.h>

List of all members.


Detailed Description

Class for reading image for processing.

Definition at line 31 of file bitstrm.h.

Public Member Functions

Private Attributes

Static Private Attributes


Constructor & Destructor Documentation

R_BITSTREAM::R_BITSTREAM (  )  [inline]

Definition at line 45 of file bitstrm.h.

00045                   { 
00046     };                           //Null constructor


Member Function Documentation

UINT16 R_BITSTREAM::masks ( INT32  index  ) 

Read a code from the static member.

Definition at line 84 of file bitstrm.cpp.

References bitmasks.

Referenced by read_tif_image().

00086                            {
00087   return bitmasks[index];
00088 }

UINT16 R_BITSTREAM::open ( int  fd  ) 

Establish a bitstream for reading.

Definition at line 38 of file bitstrm.cpp.

References bitbit, bitbuf, BITBUFSIZE, bitfd, bitindex, bitword, bufsize, ERRCODE::error(), LOG, NULL, and READFAILED.

Referenced by read_tif_image().

00040                           {
00041   bitfd = fd;
00042   bufsize = read (fd, (char *) bitbuf, BITBUFSIZE * sizeof (UINT8));
00043   //fill buffer
00044   if (bufsize < 0) {
00045     READFAILED.error ("R_BITSTREAM::open", LOG, NULL);
00046     return 0;
00047   }
00048   bitword = bitbuf[0] | (bitbuf[1] << 8);
00049   bitindex = 2;
00050   bitbit = 16;
00051   return (UINT16) bitword;
00052 }

UINT16 R_BITSTREAM::read_code ( UINT8  length  ) 

Remove a code from the bitstream.

Definition at line 58 of file bitstrm.cpp.

References bitbit, bitbuf, BITBUFSIZE, bitfd, bitindex, bitword, bufsize, ERRCODE::error(), LOG, NULL, and READFAILED.

Referenced by read_eol(), and read_tif_image().

00060                                {
00061   bitbit -= length;              //no of bits left
00062   bitword >>= length;            //remove bits
00063   while (bitbit < 16) {
00064                                  //get next byte
00065     bitword |= bitbuf[bitindex++] << bitbit;
00066     bitbit += 8;
00067     if (bitindex >= bufsize) {
00068       bufsize =
00069         read (bitfd, (char *) bitbuf, BITBUFSIZE * sizeof (UINT8));
00070       if (bufsize < 0) {
00071         READFAILED.error ("R_BITSTREAM::read_code", LOG, NULL);
00072         return 0;
00073       }
00074       bitindex = 0;              //newly filled buffer
00075     }
00076   }
00077   return (UINT16) bitword;
00078 }


Member Data Documentation

INT32 R_BITSTREAM::bitbit [private]

Definition at line 37 of file bitstrm.h.

Referenced by open(), and read_code().

UINT8 R_BITSTREAM::bitbuf[BITBUFSIZE] [private]

Definition at line 39 of file bitstrm.h.

Referenced by open(), and read_code().

int R_BITSTREAM::bitfd [private]

Definition at line 34 of file bitstrm.h.

Referenced by open(), and read_code().

INT32 R_BITSTREAM::bitindex [private]

Definition at line 35 of file bitstrm.h.

Referenced by open(), and read_code().

const UINT16 R_BITSTREAM::bitmasks [static, private]

Used in R_BITSTREAM::masks

Definition at line 41 of file bitstrm.h.

Referenced by masks().

UINT32 R_BITSTREAM::bitword [private]

Definition at line 36 of file bitstrm.h.

Referenced by open(), and read_code().

INT32 R_BITSTREAM::bufsize [private]

Definition at line 38 of file bitstrm.h.

Referenced by open(), and read_code().


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