Coverage Report

Created: 2026-01-09 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qpdf/libqpdf/BitWriter.cc
Line
Count
Source
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
4.33k
    pl(pl)
9
4.33k
{
10
4.33k
}
11
12
void
13
BitWriter::writeBits(unsigned long long val, size_t bits)
14
2.05M
{
15
2.05M
    write_bits(this->ch, this->bit_offset, val, bits, this->pl);
16
2.05M
}
17
18
void
19
BitWriter::writeBitsSigned(long long val, size_t bits)
20
2.05M
{
21
2.05M
    unsigned long long uval = 0;
22
2.05M
    if (val < 0) {
23
830k
        uval = (1ULL << bits) + static_cast<unsigned long long>(val);
24
1.22M
    } else {
25
1.22M
        uval = static_cast<unsigned long long>(val);
26
1.22M
    }
27
2.05M
    writeBits(uval, bits);
28
2.05M
}
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
4.32k
{
39
4.32k
    if (bit_offset < 7) {
40
582
        size_t bits_to_write = bit_offset + 1;
41
582
        write_bits(this->ch, this->bit_offset, 0, bits_to_write, this->pl);
42
582
    }
43
4.32k
}