OSDN Git Service

do not assume pHYs chunk is available in QPngHandler
authorIvailo Monev <xakepa10@gmail.com>
Tue, 23 May 2023 20:15:04 +0000 (23:15 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Tue, 23 May 2023 20:25:42 +0000 (23:25 +0300)
read benchmark results:
********* Start testing of tst_QImageReader *********
Config: Using QTest library 4.13.0, Katie 4.13.0
PASS  : tst_QImageReader::initTestCase()
RESULT   : tst_QImageReader::readImage():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench.kat":
     0.460 msecs per iteration (total: 230, iterations: 500)
RESULT   : tst_QImageReader::readImage():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench-large.kat":
     12.35 msecs per iteration (total: 6,177, iterations: 500)
RESULT   : tst_QImageReader::readImage():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench-transparent.kat":
     4.630 msecs per iteration (total: 2,315, iterations: 500)
RESULT   : tst_QImageReader::readImage():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench.png":
     1.69 msecs per iteration (total: 845, iterations: 500)
RESULT   : tst_QImageReader::readImage():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench-large.png":
     21.014 msecs per iteration (total: 10,507, iterations: 500)
RESULT   : tst_QImageReader::readImage():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench-transparent.png":
     11.17 msecs per iteration (total: 5,585, iterations: 500)
RESULT   : tst_QImageReader::readImage():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench.ppm":
     0.756 msecs per iteration (total: 378, iterations: 500)
RESULT   : tst_QImageReader::readImage():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench-large.ppm":
     2.958 msecs per iteration (total: 1,479, iterations: 500)
RESULT   : tst_QImageReader::readImage():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench-transparent.ppm":
     2.664 msecs per iteration (total: 1,332, iterations: 500)
RESULT   : tst_QImageReader::readImage():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench.svg":
     10.77 msecs per iteration (total: 5,385, iterations: 500)
RESULT   : tst_QImageReader::readImage():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench.xpm":
     8.344 msecs per iteration (total: 4,172, iterations: 500)
RESULT   : tst_QImageReader::readImage():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench-large.xpm":
     76.738 msecs per iteration (total: 38,369, iterations: 500)
RESULT   : tst_QImageReader::readImage():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench-transparent.xpm":
     65.280 msecs per iteration (total: 32,640, iterations: 500)
PASS  : tst_QImageReader::readImage()
RESULT   : tst_QImageReader::setScaledSize():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench.kat":
     1.98 msecs per iteration (total: 990, iterations: 500)
RESULT   : tst_QImageReader::setScaledSize():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench-large.kat":
     13.31 msecs per iteration (total: 6,657, iterations: 500)
RESULT   : tst_QImageReader::setScaledSize():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench-transparent.kat":
     5.590 msecs per iteration (total: 2,795, iterations: 500)
RESULT   : tst_QImageReader::setScaledSize():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench.png":
     3.218 msecs per iteration (total: 1,609, iterations: 500)
RESULT   : tst_QImageReader::setScaledSize():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench-large.png":
     23.224 msecs per iteration (total: 11,612, iterations: 500)
RESULT   : tst_QImageReader::setScaledSize():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench-transparent.png":
     12.72 msecs per iteration (total: 6,362, iterations: 500)
RESULT   : tst_QImageReader::setScaledSize():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench.ppm":
     1.64 msecs per iteration (total: 822, iterations: 500)
RESULT   : tst_QImageReader::setScaledSize():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench-large.ppm":
     3.898 msecs per iteration (total: 1,949, iterations: 500)
RESULT   : tst_QImageReader::setScaledSize():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench-transparent.ppm":
     3.630 msecs per iteration (total: 1,815, iterations: 500)
RESULT   : tst_QImageReader::setScaledSize():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench.svg":
     9.304 msecs per iteration (total: 4,652, iterations: 500)
RESULT   : tst_QImageReader::setScaledSize():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench.xpm":
     9.858 msecs per iteration (total: 4,929, iterations: 500)
RESULT   : tst_QImageReader::setScaledSize():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench-large.xpm":
     77.880 msecs per iteration (total: 38,940, iterations: 500)
RESULT   : tst_QImageReader::setScaledSize():"/home/smil3y/katie/tests/benchmarks/gui/image/qimagereader//images/bench-transparent.xpm":
     66.030 msecs per iteration (total: 33,015, iterations: 500)
PASS  : tst_QImageReader::setScaledSize()
PASS  : tst_QImageReader::cleanupTestCase()
Totals: 4 passed, 0 failed, 0 skipped
********* Finished testing of tst_QImageReader *********

write benchmark results:
********* Start testing of tst_QImageWriter *********
Config: Using QTest library 4.13.0, Katie 4.13.0
PASS  : tst_QImageWriter::initTestCase()
RESULT   : tst_QImageWriter::writeImage():"kat":
     2.450 msecs per iteration (total: 1,225, iterations: 500)
RESULT   : tst_QImageWriter::writeImage():"png":
     16.28 msecs per iteration (total: 8,142, iterations: 500)
RESULT   : tst_QImageWriter::writeImage():"ppm":
     7.176 msecs per iteration (total: 3,588, iterations: 500)
PASS  : tst_QImageWriter::writeImage()
PASS  : tst_QImageWriter::cleanupTestCase()
Totals: 3 passed, 0 failed, 0 skipped
********* Finished testing of tst_QImageWriter *********

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/gui/image/qpnghandler.cpp

index f1fea65..44e74bc 100644 (file)
@@ -50,7 +50,7 @@ int spng_write_proc(spng_ctx *ctx, void *user, void *dst_src, size_t length)
     // qDebug() << Q_FUNC_INFO << length;
     Q_UNUSED(ctx);
     QIODevice* iodevice = static_cast<QIODevice*>(user);
-    char* src = static_cast<char*>(dst_src);
+    const char* src = static_cast<char*>(dst_src);
     const qint64 result = iodevice->write(src, length);
     if (result <= 0) {
         return SPNG_IO_ERROR;
@@ -109,7 +109,7 @@ bool QPngHandler::read(QImage *image)
     struct spng_phys spngphys;
     ::memset(&spngphys, 0, sizeof(struct spng_phys));
     spngresult = spng_get_phys(spngctx, &spngphys);
-    if (Q_UNLIKELY(spngresult != SPNG_OK)) {
+    if (Q_UNLIKELY(spngresult != SPNG_OK && spngresult != SPNG_ECHUNKAVAIL)) {
         qWarning("QPngHandler::read() Could not get pHYs: %s", spng_strerror(spngresult));
         spng_ctx_free(spngctx);
         return false;