Coverage Report

Created: 2024-09-08 06:05

/src/qpdf/libqpdf/BitWriter.cc
Line
Count
Source (jump to first uncovered line)
1
#include <qpdf/BitWriter.hh>
2
3
// See comments in bits_functions.hh
4
#define BITS_WRITE 1
5
#include <qpdf/bits_functions.hh>
6
7
BitWriter::BitWriter(Pipeline* pl) :
8
    pl(pl),
9
    ch(0),
10
    bit_offset(7)
11
0
{
12
0
}
13
14
void
15
BitWriter::writeBits(unsigned long long val, size_t bits)
16
0
{
17
0
    write_bits(this->ch, this->bit_offset, val, bits, this->pl);
18
0
}
19
20
void
21
BitWriter::writeBitsSigned(long long val, size_t bits)
22
0
{
23
0
    unsigned long long uval = 0;
24
0
    if (val < 0) {
25
0
        uval = (1ULL << bits) + static_cast<unsigned long long>(val);
26
0
    } else {
27
0
        uval = static_cast<unsigned long long>(val);
28
0
    }
29
0
    writeBits(uval, bits);
30
0
}
31
32
void
33
BitWriter::writeBitsInt(int val, size_t bits)
34
0
{
35
0
    writeBits(static_cast<unsigned long long>(val), bits);
36
0
}
37
38
void
39
BitWriter::flush()
40
0
{
41
0
    if (bit_offset < 7) {
42
0
        size_t bits_to_write = bit_offset + 1;
43
0
        write_bits(this->ch, this->bit_offset, 0, bits_to_write, this->pl);
44
0
    }
45
0
}