2008-04-29 12:55:25 +00:00
|
|
|
// Read bits from a bit stream. See BitWriter for writing.
|
|
|
|
|
2018-08-12 18:07:22 +00:00
|
|
|
#ifndef BITSTREAM_HH
|
|
|
|
#define BITSTREAM_HH
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2009-10-19 20:17:14 +00:00
|
|
|
#include <qpdf/DLL.h>
|
2019-06-21 03:35:23 +00:00
|
|
|
#include <stddef.h>
|
2009-09-26 15:19:12 +00:00
|
|
|
|
2009-10-21 00:27:24 +00:00
|
|
|
class BitStream
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2019-06-21 03:35:23 +00:00
|
|
|
BitStream(unsigned char const* p, size_t nbytes);
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2008-04-29 12:55:25 +00:00
|
|
|
void reset();
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2019-06-21 03:35:23 +00:00
|
|
|
unsigned long long getBits(size_t nbits);
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2019-06-21 03:35:23 +00:00
|
|
|
long long getBitsSigned(size_t nbits);
|
|
|
|
// Only call getBitsInt when requesting a number of bits that will
|
|
|
|
// definitely fit in an int.
|
|
|
|
QPDF_DLL
|
|
|
|
int getBitsInt(size_t nbits);
|
2018-01-13 23:13:18 +00:00
|
|
|
QPDF_DLL
|
2008-04-29 12:55:25 +00:00
|
|
|
void skipToNextByte();
|
|
|
|
|
|
|
|
private:
|
|
|
|
unsigned char const* start;
|
2019-06-21 03:35:23 +00:00
|
|
|
size_t nbytes;
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
unsigned char const* p;
|
2019-06-21 03:35:23 +00:00
|
|
|
size_t bit_offset;
|
|
|
|
size_t bits_available;
|
2008-04-29 12:55:25 +00:00
|
|
|
};
|
|
|
|
|
2018-08-12 18:07:22 +00:00
|
|
|
#endif // BITSTREAM_HH
|