3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.tizenopensource.org/license
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.
18 #ifndef _BIT_WRITER_H_
19 #define _BIT_WRITER_H_
24 : public Osp::Base::Object
27 BitWriter(unsigned char* dest, int size)
38 virtual ~BitWriter() { }
40 int GetPosition() { return __pos; }
53 void PutBits(int count, unsigned long bits)
57 PutBit((bool) ((bits >> (count - 1)) & 0x01));
76 void PutByte(unsigned char v)
85 unsigned char ml = log2_tab[__mask];
86 __curr |= v >> (8 - ml);
91 void PutWord(unsigned short v)
93 PutByte((v >> 8) & 0x00ff);
94 PutByte((v) & 0x00ff);
97 void PutDword(unsigned long v)
99 PutByte((unsigned char) ((v >> 24) & 0x00ff));
100 PutByte((unsigned char) ((v >> 16) & 0x00ff));
101 PutByte((unsigned char) ((v >> 8) & 0x00ff));
102 PutByte((unsigned char) ((v) & 0x00ff));
106 void WriteByte(unsigned char v)
118 unsigned char __curr;
119 unsigned char __mask;
120 unsigned char* __pBuf;
124 static const unsigned char log2_tab[256];
127 #endif // _BIT_WRITER_H_