2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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 #include <FBaseObject.h>
19 #include <FMedia_BitWriter.h>
21 using namespace Tizen::Base;
23 namespace Tizen { namespace Media
26 static const unsigned char _LOG_2_TAB[256] = {
27 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
28 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
29 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
30 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
31 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
32 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
33 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
34 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
35 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
36 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
37 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
38 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
39 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
40 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
41 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
42 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
46 _BitWriter::_BitWriter(unsigned char* dest, int size)
57 _BitWriter::~_BitWriter(void)
63 _BitWriter::GetPosition(void)
69 _BitWriter::AlignByte(void)
81 _BitWriter::PutBits(int count, unsigned long bits)
85 PutBit((bool)((bits >> (count-1)) & 0x01));
91 _BitWriter::PutBit(bool bit)
108 _BitWriter::PutByte(unsigned char v)
117 unsigned char ml = _LOG_2_TAB[__mask];
118 __curr |= v >> (8 - ml);
124 _BitWriter::PutWord(unsigned short v)
126 PutByte((v >> 8) & 0x00ff);
127 PutByte((v ) & 0x00ff);
131 _BitWriter::PutDword(unsigned long v)
133 PutByte((unsigned char) ((v >> 24) & 0x00ff));
134 PutByte((unsigned char) ((v >> 16) & 0x00ff));
135 PutByte((unsigned char) ((v >> 8 ) & 0x00ff));
136 PutByte((unsigned char) ((v ) & 0x00ff));
140 _BitWriter::WriteByte(unsigned char v)