00001 /********************************************************************** 00002 * File: bitstrm.h (Formerly bits.h) 00003 * Description: R_BITSTREAM and W_BITSTREAM class definitions. 00004 * Author: Ray Smith 00005 * Created: Tue Feb 19 10:44:22 GMT 1991 00006 * 00007 * (C) Copyright 1991, Hewlett-Packard Ltd. 00008 ** Licensed under the Apache License, Version 2.0 (the "License"); 00009 ** you may not use this file except in compliance with the License. 00010 ** You may obtain a copy of the License at 00011 ** http://www.apache.org/licenses/LICENSE-2.0 00012 ** Unless required by applicable law or agreed to in writing, software 00013 ** distributed under the License is distributed on an "AS IS" BASIS, 00014 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 ** See the License for the specific language governing permissions and 00016 ** limitations under the License. 00017 * 00018 **********************************************************************/ 00019 00020 #ifndef BITSTRM_H 00021 #define BITSTRM_H 00022 00023 #include "host.h" 00024 00025 #define BITBUFSIZE 8192 //bitstream buffer 00026 00027 class DLLSYM R_BITSTREAM 00028 { 00029 private: 00030 int bitfd; //file descriptor 00031 inT32 bitindex; //current byte 00032 uinT32 bitword; //current word 00033 inT32 bitbit; //current bit 00034 inT32 bufsize; //size of buffer 00035 uinT8 bitbuf[BITBUFSIZE]; //bitstream buffer 00036 //for reading codes 00037 static const uinT16 bitmasks[17]; 00038 00039 public: 00040 00041 R_BITSTREAM() { 00042 }; //Null constructor 00043 00044 uinT16 open( //open to read 00045 int fd); //file to read 00046 00047 uinT16 read_code( //read a code 00048 uinT8 length); //bits to lose 00049 uinT16 masks( //read a code 00050 inT32 index); //bits to lose 00051 }; 00052 00053 class DLLSYM W_BITSTREAM 00054 { 00055 private: 00056 int bitfd; //file descriptor 00057 inT32 bitindex; //current byte 00058 uinT32 bitword; //current word 00059 inT32 bitbit; //current bit 00060 uinT8 bitbuf[BITBUFSIZE]; //bitstream buffer 00061 00062 public: 00063 W_BITSTREAM() { 00064 }; //Null constructor 00065 00066 void open( //open to write 00067 int fd); //file to write 00068 00069 inT8 write_code( //write a code 00070 uinT16 code, //code to write 00071 uinT8 length); //bits to lose 00072 }; 00073 #endif