1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
10 // Intel License Agreement
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
22 // * Redistribution's in binary form must reproduce the above copyright notice,
23 // this list of conditions and the following disclaimer in the documentation
24 // and/or other materials provided with the distribution.
26 // * The name of Intel Corporation may not be used to endorse or promote products
27 // derived from this software without specific prior written permission.
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
47 #define LITTLE_ENDIAN /* intel-like uchar order */
49 #define BIG_ENDIAN /* motorolla-like uchar order */
52 #pragma warning( disable: 4711 )
54 #define RBS_THROW_EOS -123 /* <end of stream> exception code */
55 #define RBS_THROW_FORB -124 /* <forrbidden huffman code> exception code */
56 #define RBS_HUFF_FORB 2047 /* forrbidden huffman code "value" */
58 typedef unsigned char uchar;
60 // class RBaseStream - base class for other reading streams.
68 virtual bool Open( const char* filename );
70 void SetBlockSize( int block_size, int unGetsize = 4 );
72 void SetPos( int pos );
74 void Skip( int bytes );
87 virtual void ReadBlock();
88 virtual void Release();
89 virtual void Allocate();
93 // class RLByteStream - uchar-oriented stream.
94 // l in prefix means that the least significant uchar of a multi-uchar value goes first
95 class RLByteStream : public RBaseStream
99 void GetBytes( void* buffer, int length, int* readed = 0 );
104 // class RMBitStream - uchar-oriented stream.
105 // m in prefix means that the most significant uchar of a multi-uchar value go first
106 class RMByteStream : public RLByteStream
113 // class RLBitStream - bit-oriented stream.
114 // l in prefix means that the least significant bit of a multi-bit value goes first
115 class RLBitStream : public RBaseStream
118 void SetPos( int pos );
121 int Show( int bits );
122 int GetHuff( const short* table );
123 void Move( int shift );
124 void Skip( int bytes );
128 virtual void ReadBlock();
131 // class RMBitStream - bit-oriented stream.
132 // m in prefix means that the most significant bit of a multi-bit value goes first
133 class RMBitStream : public RLBitStream
136 void SetPos( int pos );
139 int Show( int bits );
140 int GetHuff( const short* table );
141 void Move( int shift );
142 void Skip( int bytes );
145 virtual void ReadBlock();
149 int* bs_create_source_huffman_table( const uchar* src, int* dst,
150 int max_bits, int first_bits );
151 bool bs_create_decode_huffman_table( const int* src, short* dst, int max_size );
152 void bs_bswap_block( uchar *start, uchar *end );
154 extern unsigned long bs_bits_masks[];
156 #endif/*_BITSTRM_H_*/