Tizen 2.1 base
[sdk/ide/native-sample.git] / samples / native / partner / cpp / Sample / Tizen C++ / MediaApp / MediaApp / project / src / Codec / BitReader.h
1 //
2 // Tizen C++ SDK
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.tizenopensource.org/license
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 #ifndef _BIT_READER_H_
19 #define _BIT_READER_H_
20
21 #include <FBase.h>
22
23 class BitReader
24         : public Osp::Base::Object
25 {
26 public:
27         BitReader();
28         virtual ~BitReader();
29
30         result Construct(const byte* pBuf, int size);
31         unsigned long GetBits(unsigned long size);
32         void SkipBits(int size);
33         bool GetBit();
34         unsigned char SetByteAlign();
35         unsigned long GetProcessedBytes();
36
37 protected:
38         void EndBitReader();
39         unsigned long long ReadNbyte(unsigned char* buf, int n);
40         void ClearBits(unsigned long bits);
41         void ClearBitsEx(unsigned long bits);
42
43 private:
44         unsigned long __bufa;
45         unsigned long __bufb;
46         unsigned long __bitsLeft;
47         unsigned long __bufferSize;   /* size of the buffer in bytes */
48         unsigned long __bytesUsed;
49         unsigned char __noMoreReading;
50         unsigned char __error;
51         unsigned char* __start;
52         unsigned char* __tail;
53         unsigned char* __buffer;
54 };
55
56
57 #endif // _BIT_READER_H_