• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**********************************************************************
2  * File:        bitstrm.h  (Formerly bits.h)
3  * Description: R_BITSTREAM and W_BITSTREAM class definitions.
4  * Author:					Ray Smith
5  * Created:					Tue Feb 19 10:44:22 GMT 1991
6  *
7  * (C) Copyright 1991, Hewlett-Packard Ltd.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  *
18  **********************************************************************/
19 
20 #ifndef           BITSTRM_H
21 #define           BITSTRM_H
22 
23 #include          "host.h"
24 
25 #define BITBUFSIZE      8192     //bitstream buffer
26 
27 class DLLSYM R_BITSTREAM
28 {
29   private:
30     int bitfd;                   //file descriptor
31     inT32 bitindex;              //current byte
32     uinT32 bitword;              //current word
33     inT32 bitbit;                //current bit
34     inT32 bufsize;               //size of buffer
35     uinT8 bitbuf[BITBUFSIZE];    //bitstream buffer
36                                  //for reading codes
37     static const uinT16 bitmasks[17];
38 
39   public:
40 
R_BITSTREAM()41     R_BITSTREAM() {
42     };                           //Null constructor
43 
44     uinT16 open(          //open to read
45                 int fd);  //file to read
46 
47     uinT16 read_code(                //read a code
48                      uinT8 length);  //bits to lose
49     uinT16 masks(               //read a code
50                  inT32 index);  //bits to lose
51 };
52 
53 class DLLSYM W_BITSTREAM
54 {
55   private:
56     int bitfd;                   //file descriptor
57     inT32 bitindex;              //current byte
58     uinT32 bitword;              //current word
59     inT32 bitbit;                //current bit
60     uinT8 bitbuf[BITBUFSIZE];    //bitstream buffer
61 
62   public:
W_BITSTREAM()63     W_BITSTREAM() {
64     };                           //Null constructor
65 
66     void open(          //open to write
67               int fd);  //file to write
68 
69     inT8 write_code(                //write a code
70                     uinT16 code,    //code to write
71                     uinT8 length);  //bits to lose
72 };
73 #endif
74