From b8b980f400e5bb58dfbfd7be0447ee59129ba48f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Novomesk=C3=BD?= Date: Fri, 6 Oct 2023 13:03:28 +0200 Subject: [PATCH] avif: support repetition count and minor performance optimizations. --- src/imageformats/avif.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/imageformats/avif.cpp b/src/imageformats/avif.cpp index 9775dcb..058eab9 100644 --- a/src/imageformats/avif.cpp +++ b/src/imageformats/avif.cpp @@ -330,6 +330,10 @@ bool QAVIFHandler::decode_one_frame() avifRGBImage rgb; avifRGBImageSetDefaults(&rgb, m_decoder->image); +#if AVIF_VERSION >= 1000000 + rgb.maxThreads = m_decoder->maxThreads; +#endif + if (m_decoder->image->depth > 8) { rgb.depth = 16; rgb.format = AVIF_RGB_FORMAT_RGBA; @@ -714,9 +718,9 @@ bool QAVIFHandler::write(const QImage &image) if (save_depth == 8) { save_depth = 10; if (tmpcolorimage.hasAlphaChannel()) { - tmpcolorimage = tmpcolorimage.convertToFormat(QImage::Format_RGBA64); + tmpcolorimage.convertTo(QImage::Format_RGBA64); } else { - tmpcolorimage = tmpcolorimage.convertToFormat(QImage::Format_RGBX64); + tmpcolorimage.convertTo(QImage::Format_RGBX64); } } @@ -1039,6 +1043,11 @@ int QAVIFHandler::loopCount() const return 0; } +#if AVIF_VERSION >= 1000000 + if (m_decoder->repetitionCount >= 0) { + return m_decoder->repetitionCount; + } +#endif // Endless loop to work around https://github.com/AOMediaCodec/libavif/issues/347 return -1; }