aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/BitStream.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libqpdf/BitStream.cc')
-rw-r--r--libqpdf/BitStream.cc31
1 files changed, 11 insertions, 20 deletions
diff --git a/libqpdf/BitStream.cc b/libqpdf/BitStream.cc
index d0e991df..504e35c4 100644
--- a/libqpdf/BitStream.cc
+++ b/libqpdf/BitStream.cc
@@ -18,8 +18,7 @@ BitStream::reset()
{
p = start;
bit_offset = 7;
- if (QIntC::to_uint(nbytes) > static_cast<unsigned int>(-1) / 8)
- {
+ if (QIntC::to_uint(nbytes) > static_cast<unsigned int>(-1) / 8) {
throw std::runtime_error("array too large for bitstream");
}
bits_available = 8 * nbytes;
@@ -28,22 +27,18 @@ BitStream::reset()
unsigned long long
BitStream::getBits(size_t nbits)
{
- return read_bits(this->p, this->bit_offset,
- this->bits_available, nbits);
+ return read_bits(this->p, this->bit_offset, this->bits_available, nbits);
}
long long
BitStream::getBitsSigned(size_t nbits)
{
- unsigned long long bits = read_bits(this->p, this->bit_offset,
- this->bits_available, nbits);
+ unsigned long long bits =
+ read_bits(this->p, this->bit_offset, this->bits_available, nbits);
long long result = 0;
- if (static_cast<long long>(bits) > 1LL << (nbits - 1))
- {
- result = static_cast<long long>(bits -(1ULL << nbits));
- }
- else
- {
+ if (static_cast<long long>(bits) > 1LL << (nbits - 1)) {
+ result = static_cast<long long>(bits - (1ULL << nbits));
+ } else {
result = static_cast<long long>(bits);
}
return result;
@@ -52,20 +47,16 @@ BitStream::getBitsSigned(size_t nbits)
int
BitStream::getBitsInt(size_t nbits)
{
- return static_cast<int>(
- QIntC::to_uint(
- read_bits(this->p, this->bit_offset,
- this->bits_available, nbits)));
+ return static_cast<int>(QIntC::to_uint(
+ read_bits(this->p, this->bit_offset, this->bits_available, nbits)));
}
void
BitStream::skipToNextByte()
{
- if (bit_offset != 7)
- {
+ if (bit_offset != 7) {
size_t bits_to_skip = bit_offset + 1;
- if (bits_available < bits_to_skip)
- {
+ if (bits_available < bits_to_skip) {
throw std::logic_error(
"INTERNAL ERROR: overflow skipping to next byte in bitstream");
}