2
RawSpeed - RAW file decoder.
4
Copyright (C) 2009 Klaus Post
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
http://www.klauspost.com
23
#include "ByteStream.h"
29
#define BITS_PER_LONG_LONG (8*sizeof(uint64))
30
#define MIN_GET_BITS (BITS_PER_LONG_LONG-33) /* max value for long getBuffer */
34
// Note: Allocated buffer MUST be at least size+sizeof(uint32) large.
39
BitPumpMSB32(ByteStream *s);
40
BitPumpMSB32(const uchar8* _buffer, uint32 _size );
41
uint32 getBitsSafe(uint32 nbits);
44
void setAbsoluteOffset(uint32 offset); // Set offset in bytes
45
__inline uint32 getOffset() { return off-(mLeft>>3);}
46
__inline void checkPos() { if (off>size) throw IOException("Out of buffer read");}; // Check if we have a valid position
48
// Fill the buffer with at least 24 bits
51
__inline uint32 getBit() {
54
return (uint32)((mCurr >> (--mLeft)) & 1);
57
__inline uint32 getBits(uint32 nbits) {
62
return (uint32)((mCurr >> (mLeft -= (nbits))) & ((1 << nbits) - 1));
65
virtual ~BitPumpMSB32(void);
69
const uint32 size; // This if the end of buffer.
72
uint32 off; // Offset in bytes
76
} // namespace RawSpeed