_ZN10FuzzHelperC2EPKhm:
   22|    156|{
   23|    156|}
_ZN10FuzzHelper8doChecksEv:
   27|    156|{
   28|    156|    Pl_Discard discard;
   29|    156|    Pl_PNGFilter p("decode", &discard, Pl_PNGFilter::a_decode, 32, 1, 8);
   30|    156|    p.write(const_cast<unsigned char*>(data), size);
   31|    156|    p.finish();
   32|    156|}
_ZN10FuzzHelper3runEv:
   36|    156|{
   37|    156|    try {
   38|    156|        doChecks();
   39|    156|    } catch (std::runtime_error const& e) {
   40|      0|        std::cerr << "runtime_error: " << e.what() << std::endl;
   41|      0|    }
   42|    156|}
LLVMFuzzerTestOneInput:
   46|    156|{
   47|    156|    FuzzHelper f(data, size);
   48|    156|    f.run();
   49|    156|    return 0;
   50|    156|}

_ZN8PipelineD2Ev:
   53|    312|    virtual ~Pipeline() = default;

_ZN3QTC2TCEPKcS1_i:
   35|  14.1k|    {
   36|       |#ifndef QPDF_DISABLE_QTC
   37|       |        TC_real(scope, ccase, n);
   38|       |#endif // QPDF_DISABLE_QTC
   39|  14.1k|    }

_ZN5QUtil17make_shared_arrayIhEENSt3__110shared_ptrIT_EEm:
  181|    312|    {
  182|    312|        return std::shared_ptr<T>(new T[n], std::default_delete<T[]>());
  183|    312|    }

_ZN8PipelineC2EPKcPS_:
    9|    312|{
   10|    312|}
_ZN8Pipeline7getNextEb:
   14|   131k|{
   15|   131k|    if ((this->next == nullptr) && (!allow_null)) {
  ------------------
  |  Branch (15:9): [True: 0, False: 131k]
  |  Branch (15:36): [True: 0, False: 0]
  ------------------
   16|      0|        throw std::logic_error(
   17|      0|            this->identifier + ": Pipeline::getNext() called on pipeline with no next");
   18|      0|    }
   19|   131k|    return this->next;
   20|   131k|}

_ZN10Pl_DiscardC2Ev:
    7|    156|{
    8|    156|}
_ZN10Pl_DiscardD2Ev:
   11|    156|{
   12|       |    // Must be explicit and not inline -- see QPDF_DLL_CLASS in README-maintainer
   13|    156|}
_ZN10Pl_Discard5writeEPKhm:
   17|   131k|{
   18|   131k|}
_ZN10Pl_Discard6finishEv:
   22|    156|{
   23|    156|}

_ZN12Pl_PNGFilterC2EPKcP8PipelineNS_8action_eEjjj:
   35|    156|{
   36|    156|    if (samples_per_pixel < 1) {
  ------------------
  |  Branch (36:9): [True: 0, False: 156]
  ------------------
   37|      0|        throw std::runtime_error("PNGFilter created with invalid samples_per_pixel");
   38|      0|    }
   39|    156|    if (!((bits_per_sample == 1) || (bits_per_sample == 2) || (bits_per_sample == 4) ||
  ------------------
  |  Branch (39:11): [True: 0, False: 156]
  |  Branch (39:37): [True: 0, False: 156]
  |  Branch (39:63): [True: 0, False: 156]
  ------------------
   40|    156|          (bits_per_sample == 8) || (bits_per_sample == 16))) {
  ------------------
  |  Branch (40:11): [True: 156, False: 0]
  |  Branch (40:37): [True: 0, False: 0]
  ------------------
   41|      0|        throw std::runtime_error(
   42|      0|            "PNGFilter created with invalid bits_per_sample not 1, 2, 4, 8, or 16");
   43|      0|    }
   44|    156|    this->bytes_per_pixel = ((bits_per_sample * samples_per_pixel) + 7) / 8;
   45|    156|    unsigned long long bpr = ((columns * bits_per_sample * samples_per_pixel) + 7) / 8;
   46|    156|    if ((bpr == 0) || (bpr > (UINT_MAX - 1))) {
  ------------------
  |  Branch (46:9): [True: 0, False: 156]
  |  Branch (46:23): [True: 0, False: 156]
  ------------------
   47|      0|        throw std::runtime_error("PNGFilter created with invalid columns value");
   48|      0|    }
   49|    156|    if (memory_limit > 0 && bpr > (memory_limit / 2U)) {
  ------------------
  |  Branch (49:9): [True: 0, False: 156]
  |  Branch (49:29): [True: 0, False: 0]
  ------------------
   50|      0|        throw std::runtime_error("PNGFilter memory limit exceeded");
   51|      0|    }
   52|    156|    this->bytes_per_row = bpr & UINT_MAX;
   53|    156|    this->buf1 = QUtil::make_shared_array<unsigned char>(this->bytes_per_row + 1);
   54|    156|    this->buf2 = QUtil::make_shared_array<unsigned char>(this->bytes_per_row + 1);
   55|    156|    memset(this->buf1.get(), 0, this->bytes_per_row + 1);
   56|    156|    memset(this->buf2.get(), 0, this->bytes_per_row + 1);
   57|    156|    this->cur_row = this->buf1.get();
   58|    156|    this->prev_row = this->buf2.get();
   59|       |
   60|       |    // number of bytes per incoming row
   61|    156|    this->incoming = (action == a_encode ? this->bytes_per_row : this->bytes_per_row + 1);
  ------------------
  |  Branch (61:23): [True: 0, False: 156]
  ------------------
   62|    156|}
_ZN12Pl_PNGFilter5writeEPKhm:
   72|    156|{
   73|    156|    size_t left = this->incoming - this->pos;
   74|    156|    size_t offset = 0;
   75|   131k|    while (len >= left) {
  ------------------
  |  Branch (75:12): [True: 131k, False: 156]
  ------------------
   76|       |        // finish off current row
   77|   131k|        memcpy(this->cur_row + this->pos, data + offset, left);
   78|   131k|        offset += left;
   79|   131k|        len -= left;
   80|       |
   81|   131k|        processRow();
   82|       |
   83|       |        // Swap rows
   84|   131k|        unsigned char* t = this->prev_row;
   85|   131k|        this->prev_row = this->cur_row;
   86|   131k|        this->cur_row = t ? t : this->buf2.get();
  ------------------
  |  Branch (86:25): [True: 131k, False: 0]
  ------------------
   87|   131k|        memset(this->cur_row, 0, this->bytes_per_row + 1);
   88|   131k|        left = this->incoming;
   89|   131k|        this->pos = 0;
   90|   131k|    }
   91|    156|    if (len) {
  ------------------
  |  Branch (91:9): [True: 141, False: 15]
  ------------------
   92|    141|        memcpy(this->cur_row + this->pos, data + offset, len);
   93|    141|    }
   94|    156|    this->pos += len;
   95|    156|}
_ZN12Pl_PNGFilter10processRowEv:
   99|   131k|{
  100|   131k|    if (this->action == a_encode) {
  ------------------
  |  Branch (100:9): [True: 0, False: 131k]
  ------------------
  101|      0|        encodeRow();
  102|   131k|    } else {
  103|   131k|        decodeRow();
  104|   131k|    }
  105|   131k|}
_ZN12Pl_PNGFilter9decodeRowEv:
  109|   131k|{
  110|   131k|    int filter = this->cur_row[0];
  111|   131k|    if (this->prev_row) {
  ------------------
  |  Branch (111:9): [True: 131k, False: 0]
  ------------------
  112|   131k|        switch (filter) {
  113|  89.8k|        case 0:
  ------------------
  |  Branch (113:9): [True: 89.8k, False: 41.5k]
  ------------------
  114|  89.8k|            break;
  115|  3.82k|        case 1:
  ------------------
  |  Branch (115:9): [True: 3.82k, False: 127k]
  ------------------
  116|  3.82k|            this->decodeSub();
  117|  3.82k|            break;
  118|  3.47k|        case 2:
  ------------------
  |  Branch (118:9): [True: 3.47k, False: 127k]
  ------------------
  119|  3.47k|            this->decodeUp();
  120|  3.47k|            break;
  121|  3.73k|        case 3:
  ------------------
  |  Branch (121:9): [True: 3.73k, False: 127k]
  ------------------
  122|  3.73k|            this->decodeAverage();
  123|  3.73k|            break;
  124|  3.13k|        case 4:
  ------------------
  |  Branch (124:9): [True: 3.13k, False: 128k]
  ------------------
  125|  3.13k|            this->decodePaeth();
  126|  3.13k|            break;
  127|  27.4k|        default:
  ------------------
  |  Branch (127:9): [True: 27.4k, False: 104k]
  ------------------
  128|       |            // ignore
  129|  27.4k|            break;
  130|   131k|        }
  131|   131k|    }
  132|       |
  133|   131k|    getNext()->write(this->cur_row + 1, this->bytes_per_row);
  134|   131k|}
_ZN12Pl_PNGFilter9decodeSubEv:
  138|  3.82k|{
  139|  3.82k|    QTC::TC("libtests", "Pl_PNGFilter decodeSub");
  140|  3.82k|    unsigned char* buffer = this->cur_row + 1;
  141|  3.82k|    unsigned int bpp = this->bytes_per_pixel;
  142|       |
  143|   126k|    for (unsigned int i = 0; i < this->bytes_per_row; ++i) {
  ------------------
  |  Branch (143:30): [True: 122k, False: 3.82k]
  ------------------
  144|   122k|        unsigned char left = 0;
  145|       |
  146|   122k|        if (i >= bpp) {
  ------------------
  |  Branch (146:13): [True: 118k, False: 3.82k]
  ------------------
  147|   118k|            left = buffer[i - bpp];
  148|   118k|        }
  149|       |
  150|   122k|        buffer[i] = static_cast<unsigned char>(buffer[i] + left);
  151|   122k|    }
  152|  3.82k|}
_ZN12Pl_PNGFilter8decodeUpEv:
  156|  3.47k|{
  157|  3.47k|    QTC::TC("libtests", "Pl_PNGFilter decodeUp");
  158|  3.47k|    unsigned char* buffer = this->cur_row + 1;
  159|  3.47k|    unsigned char* above_buffer = this->prev_row + 1;
  160|       |
  161|   114k|    for (unsigned int i = 0; i < this->bytes_per_row; ++i) {
  ------------------
  |  Branch (161:30): [True: 111k, False: 3.47k]
  ------------------
  162|   111k|        unsigned char up = above_buffer[i];
  163|   111k|        buffer[i] = static_cast<unsigned char>(buffer[i] + up);
  164|   111k|    }
  165|  3.47k|}
_ZN12Pl_PNGFilter13decodeAverageEv:
  169|  3.73k|{
  170|  3.73k|    QTC::TC("libtests", "Pl_PNGFilter decodeAverage");
  171|  3.73k|    unsigned char* buffer = this->cur_row + 1;
  172|  3.73k|    unsigned char* above_buffer = this->prev_row + 1;
  173|  3.73k|    unsigned int bpp = this->bytes_per_pixel;
  174|       |
  175|   123k|    for (unsigned int i = 0; i < this->bytes_per_row; ++i) {
  ------------------
  |  Branch (175:30): [True: 119k, False: 3.73k]
  ------------------
  176|   119k|        int left = 0;
  177|   119k|        int up = 0;
  178|       |
  179|   119k|        if (i >= bpp) {
  ------------------
  |  Branch (179:13): [True: 115k, False: 3.73k]
  ------------------
  180|   115k|            left = buffer[i - bpp];
  181|   115k|        }
  182|       |
  183|   119k|        up = above_buffer[i];
  184|   119k|        buffer[i] = static_cast<unsigned char>(buffer[i] + (left + up) / 2);
  185|   119k|    }
  186|  3.73k|}
_ZN12Pl_PNGFilter11decodePaethEv:
  190|  3.13k|{
  191|  3.13k|    QTC::TC("libtests", "Pl_PNGFilter decodePaeth");
  192|  3.13k|    unsigned char* buffer = this->cur_row + 1;
  193|  3.13k|    unsigned char* above_buffer = this->prev_row + 1;
  194|  3.13k|    unsigned int bpp = this->bytes_per_pixel;
  195|       |
  196|   103k|    for (unsigned int i = 0; i < this->bytes_per_row; ++i) {
  ------------------
  |  Branch (196:30): [True: 100k, False: 3.13k]
  ------------------
  197|   100k|        int left = 0;
  198|   100k|        int up = above_buffer[i];
  199|   100k|        int upper_left = 0;
  200|       |
  201|   100k|        if (i >= bpp) {
  ------------------
  |  Branch (201:13): [True: 97.2k, False: 3.13k]
  ------------------
  202|  97.2k|            left = buffer[i - bpp];
  203|  97.2k|            upper_left = above_buffer[i - bpp];
  204|  97.2k|        }
  205|       |
  206|   100k|        buffer[i] =
  207|   100k|            static_cast<unsigned char>(buffer[i] + this->PaethPredictor(left, up, upper_left));
  208|   100k|    }
  209|  3.13k|}
_ZN12Pl_PNGFilter14PaethPredictorEiii:
  213|   100k|{
  214|   100k|    int p = a + b - c;
  215|   100k|    int pa = abs_diff(p, a);
  216|   100k|    int pb = abs_diff(p, b);
  217|   100k|    int pc = abs_diff(p, c);
  218|       |
  219|   100k|    if (pa <= pb && pa <= pc) {
  ------------------
  |  Branch (219:9): [True: 75.8k, False: 24.5k]
  |  Branch (219:21): [True: 74.3k, False: 1.54k]
  ------------------
  220|  74.3k|        return a;
  221|  74.3k|    }
  222|  26.0k|    if (pb <= pc) {
  ------------------
  |  Branch (222:9): [True: 23.4k, False: 2.64k]
  ------------------
  223|  23.4k|        return b;
  224|  23.4k|    }
  225|  2.64k|    return c;
  226|  26.0k|}
_ZN12Pl_PNGFilter6finishEv:
  246|    156|{
  247|    156|    if (this->pos) {
  ------------------
  |  Branch (247:9): [True: 141, False: 15]
  ------------------
  248|       |        // write partial row
  249|    141|        processRow();
  250|    141|    }
  251|    156|    this->prev_row = nullptr;
  252|    156|    this->cur_row = buf1.get();
  253|    156|    this->pos = 0;
  254|    156|    memset(this->cur_row, 0, this->bytes_per_row + 1);
  255|       |
  256|    156|    getNext()->finish();
  257|    156|}
Pl_PNGFilter.cc:_ZL8abs_diffii:
   17|   301k|{
   18|   301k|    return a > b ? a - b : b - a;
  ------------------
  |  Branch (18:12): [True: 223k, False: 77.8k]
  ------------------
   19|   301k|}

_ZN12Pl_PNGFilterD2Ev:
   25|    156|    ~Pl_PNGFilter() override = default;

