mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-29 06:09:04 +08:00
5c45dc15b1
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@165 d0cd1f9f-072b-0410-8dd7-cf729c803f20
74 lines
2.4 KiB
C++
74 lines
2.4 KiB
C++
/**********************************************************************
|
|
* File: bitstrm.h (Formerly bits.h)
|
|
* Description: R_BITSTREAM and W_BITSTREAM class definitions.
|
|
* Author: Ray Smith
|
|
* Created: Tue Feb 19 10:44:22 GMT 1991
|
|
*
|
|
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
** you may not use this file except in compliance with the License.
|
|
** You may obtain a copy of the License at
|
|
** http://www.apache.org/licenses/LICENSE-2.0
|
|
** Unless required by applicable law or agreed to in writing, software
|
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
** See the License for the specific language governing permissions and
|
|
** limitations under the License.
|
|
*
|
|
**********************************************************************/
|
|
|
|
#ifndef BITSTRM_H
|
|
#define BITSTRM_H
|
|
|
|
#include "host.h"
|
|
|
|
#define BITBUFSIZE 8192 //bitstream buffer
|
|
|
|
class DLLSYM R_BITSTREAM
|
|
{
|
|
private:
|
|
int bitfd; //file descriptor
|
|
inT32 bitindex; //current byte
|
|
uinT32 bitword; //current word
|
|
inT32 bitbit; //current bit
|
|
inT32 bufsize; //size of buffer
|
|
uinT8 bitbuf[BITBUFSIZE]; //bitstream buffer
|
|
//for reading codes
|
|
static const uinT16 bitmasks[17];
|
|
|
|
public:
|
|
|
|
R_BITSTREAM() {
|
|
}; //Null constructor
|
|
|
|
uinT16 open( //open to read
|
|
int fd); //file to read
|
|
|
|
uinT16 read_code( //read a code
|
|
uinT8 length); //bits to lose
|
|
uinT16 masks( //read a code
|
|
inT32 index); //bits to lose
|
|
};
|
|
|
|
class DLLSYM W_BITSTREAM
|
|
{
|
|
private:
|
|
int bitfd; //file descriptor
|
|
inT32 bitindex; //current byte
|
|
uinT32 bitword; //current word
|
|
inT32 bitbit; //current bit
|
|
uinT8 bitbuf[BITBUFSIZE]; //bitstream buffer
|
|
|
|
public:
|
|
W_BITSTREAM() {
|
|
}; //Null constructor
|
|
|
|
void open( //open to write
|
|
int fd); //file to write
|
|
|
|
inT8 write_code( //write a code
|
|
uinT16 code, //code to write
|
|
uinT8 length); //bits to lose
|
|
};
|
|
#endif
|