2
#include "BitPumpMSB.h"
4
RawSpeed - RAW file decoder.
6
Copyright (C) 2009 Klaus Post
8
This library is free software; you can redistribute it and/or
9
modify it under the terms of the GNU Lesser General Public
10
License as published by the Free Software Foundation; either
11
version 2 of the License, or (at your option) any later version.
13
This library is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
Lesser General Public License for more details.
18
You should have received a copy of the GNU Lesser General Public
19
License along with this library; if not, write to the Free Software
20
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
http://www.klauspost.com
27
/*** Used for entropy encoded sections ***/
30
BitPumpMSB::BitPumpMSB(ByteStream *s):
31
buffer(s->getData()), size(s->getRemainSize() + sizeof(uint32)), mLeft(0), mCurr(0), off(0) {
35
BitPumpMSB::BitPumpMSB(const uchar8* _buffer, uint32 _size) :
36
buffer(_buffer), size(_size + sizeof(uint32)), mLeft(0), mCurr(0), off(0) {
40
__inline void BitPumpMSB::init() {
44
uint32 BitPumpMSB::getBitSafe() {
50
return (mCurr >> (--mLeft)) & 1;
53
uint32 BitPumpMSB::getBitsSafe(unsigned int nbits) {
54
if (nbits > MIN_GET_BITS)
55
throw IOException("Too many bits requested");
62
return ((mCurr >> (mLeft -= (nbits)))) & ((1 << nbits) - 1);
66
uchar8 BitPumpMSB::getByteSafe() {
72
return ((mCurr >> (mLeft -= 8))) & 0xff;
75
void BitPumpMSB::setAbsoluteOffset(unsigned int offset) {
77
throw IOException("Offset set out of buffer");
87
BitPumpMSB::~BitPumpMSB(void) {
90
} // namespace RawSpeed