Coverage Report

Created: 2025-07-01 06:10

/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
0
    pl(pl)
9
0
{
10
0
}
11
12
void
13
BitWriter::writeBits(unsigned long long val, size_t bits)
14
0
{
15
0
    write_bits(this->ch, this->bit_offset, val, bits, this->pl);
16
0
}
17
18
void
19
BitWriter::writeBitsSigned(long long val, size_t bits)
20
0
{
21
0
    unsigned long long uval = 0;
22
0
    if (val < 0) {
23
0
        uval = (1ULL << bits) + static_cast<unsigned long long>(val);
24
0
    } else {
25
0
        uval = static_cast<unsigned long long>(val);
26
0
    }
27
0
    writeBits(uval, bits);
28
0
}
29
30
void
31
BitWriter::writeBitsInt(int val, size_t bits)
32
0
{
33
0
    writeBits(static_cast<unsigned long long>(val), bits);
34
0
}
35
36
void
37
BitWriter::flush()
38
0
{
39
0
    if (bit_offset < 7) {
40
0
        size_t bits_to_write = bit_offset + 1;
41
0
        write_bits(this->ch, this->bit_offset, 0, bits_to_write, this->pl);
42
0
    }
43
0
}