mirror of
https://github.com/qpdf/qpdf.git
synced 2024-11-16 01:27:07 +00:00
33dbe43e4e
git-svn-id: svn+q:///qpdf/trunk@698 71b93d88-0707-0410-a8cf-f5a4172ac649
48 lines
774 B
C++
48 lines
774 B
C++
#include <qpdf/BitStream.hh>
|
|
|
|
// See comments in bits.cc
|
|
#define BITS_READ 1
|
|
#include "bits.icc"
|
|
|
|
DLL_EXPORT
|
|
BitStream::BitStream(unsigned char const* p, int nbytes) :
|
|
start(p),
|
|
nbytes(nbytes)
|
|
{
|
|
reset();
|
|
}
|
|
|
|
DLL_EXPORT
|
|
void
|
|
BitStream::reset()
|
|
{
|
|
p = start;
|
|
bit_offset = 7;
|
|
bits_available = 8 * nbytes;
|
|
}
|
|
|
|
DLL_EXPORT
|
|
unsigned long
|
|
BitStream::getBits(int nbits)
|
|
{
|
|
return read_bits(this->p, this->bit_offset,
|
|
this->bits_available, nbits);
|
|
}
|
|
|
|
DLL_EXPORT
|
|
void
|
|
BitStream::skipToNextByte()
|
|
{
|
|
if (bit_offset != 7)
|
|
{
|
|
unsigned int bits_to_skip = bit_offset + 1;
|
|
if (bits_available < bits_to_skip)
|
|
{
|
|
throw QEXC::Internal("overflow skipping to next byte in bitstream");
|
|
}
|
|
bit_offset = 7;
|
|
++p;
|
|
bits_available -= bits_to_skip;
|
|
}
|
|
}
|