summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMoody Liu <mooodyhunter@outlook.com>2022-06-17 23:58:18 +0100
committerMoody Liu <mooodyhunter@outlook.com>2022-06-21 16:20:52 +0100
commit4011d03f84d19bdfa6e30b6b7a6792f90b30a259 (patch)
tree65583672a3a100ed0e3dfb5b4243d90558c25f00 /src
parent1020f70055200795e6d5fcd0886fcd562fcc52ba (diff)
downloadqtimageformats-4011d03f84d19bdfa6e30b6b7a6792f90b30a259.tar.gz
jp2: use new APIs for jasper 3
using new APIs prevents the runtime deprecated warning. also note the memory limit is now set to 500MB Task-number: QTBUG-104398 Pick-to: 6.4 6.3 6.2 5.15 Change-Id: I1b307ec33c6a540a5fb9121214d89a73a509a0d3 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/imageformats/jp2/qjp2handler.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/plugins/imageformats/jp2/qjp2handler.cpp b/src/plugins/imageformats/jp2/qjp2handler.cpp
index 4e3308d..fe08995 100644
--- a/src/plugins/imageformats/jp2/qjp2handler.cpp
+++ b/src/plugins/imageformats/jp2/qjp2handler.cpp
@@ -7,6 +7,7 @@
#include "qimage.h"
#include "qvariant.h"
#include "qcolor.h"
+#include "qimagereader.h"
#include <jasper/jasper.h>
#include <math.h> // for pow
@@ -297,16 +298,46 @@ private:
Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
: jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
{
+#if JAS_VERSION_MAJOR < 3
if (jas_init()) {
jasperOk = false;
qDebug("Jasper Library initialization failed");
}
+#else
+ jas_conf_clear();
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
+#else
+ // 128MB seems to be enough.
+ jas_conf_set_max_mem_usage(128 * 1024 * 1024);
+#endif
+ if (jas_init_library()) {
+ jasperOk = false;
+ qDebug("Jasper library initialization failed");
+ }
+ if (jas_init_thread()) {
+ jas_cleanup_library();
+ jasperOk = false;
+ qDebug("Jasper thread initialization failed");
+ }
+#endif
}
Jpeg2000JasperReader::~Jpeg2000JasperReader()
{
+#if JAS_VERSION_MAJOR < 3
if (jasperOk)
jas_cleanup();
+#else
+ if (jasperOk) {
+ if (jas_cleanup_thread()) {
+ qDebug("Jasper thread cleanup failed");
+ }
+ if (jas_cleanup_library()) {
+ qDebug("Jasper library cleanup failed");
+ }
+ }
+#endif
}
/*! \internal