Fix loading HEVC-encoded HEIF images (#2189462)

Signed-off-by: Nils Philippsen <nils@tiptoe.de>
This commit is contained in:
Nils Philippsen 2023-08-20 23:55:29 +02:00
parent 2c7600377b
commit 7fde2224db
2 changed files with 108 additions and 1 deletions

View File

@ -0,0 +1,101 @@
From bb06322b490d5b942d4289c3cf2b78a535d20840 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Novomesk=C3=BD?= <dnovomesky@gmail.com>
Date: Mon, 24 Apr 2023 18:07:19 +0200
Subject: [PATCH] plug-ins: use heif_init/heif_deinit
---
plug-ins/common/file-heif.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/plug-ins/common/file-heif.c b/plug-ins/common/file-heif.c
index 9564355f4f..97b0a9153c 100644
--- a/plug-ins/common/file-heif.c
+++ b/plug-ins/common/file-heif.c
@@ -110,6 +110,10 @@ init (void)
{ GIMP_PDB_INT32, "lossless", "Use lossless compression (0 = lossy, 1 = lossless)" }
};
+#if LIBHEIF_HAVE_VERSION(1,13,0)
+ heif_init (NULL);
+#endif
+
if (heif_have_decoder_for_format (heif_compression_HEVC)
#if LIBHEIF_HAVE_VERSION(1,8,0)
|| heif_have_decoder_for_format (heif_compression_AV1)
@@ -207,6 +211,10 @@ init (void)
gimp_register_file_handler_uri (SAVE_PROC_AV1);
}
#endif
+
+#if LIBHEIF_HAVE_VERSION(1,13,0)
+ heif_deinit ();
+#endif
}
#define LOAD_HEIF_CANCEL -2
@@ -252,8 +260,16 @@ run (const gchar *name,
{
gint32 image_ID;
+#if LIBHEIF_HAVE_VERSION(1,13,0)
+ heif_init (NULL);
+#endif
+
image_ID = load_image (file, interactive, &error);
+#if LIBHEIF_HAVE_VERSION(1,13,0)
+ heif_deinit ();
+#endif
+
if (image_ID >= 0)
{
*nreturn_vals = 2;
@@ -341,6 +357,10 @@ run (const gchar *name,
{
GFile *file = g_file_new_for_uri (param[3].data.d_string);
+#if LIBHEIF_HAVE_VERSION(1,13,0)
+ heif_init (NULL);
+#endif
+
if (save_image (file, image_ID, drawable_ID,
&params,
&error,
@@ -359,6 +379,11 @@ run (const gchar *name,
{
status = GIMP_PDB_EXECUTION_ERROR;
}
+
+#if LIBHEIF_HAVE_VERSION(1,13,0)
+ heif_deinit ();
+#endif
+
g_object_unref (file);
}
@@ -437,6 +462,10 @@ run (const gchar *name,
{
GFile *file = g_file_new_for_uri (param[3].data.d_string);
+#if LIBHEIF_HAVE_VERSION(1,13,0)
+ heif_init (NULL);
+#endif
+
if (save_image (file, image_ID, drawable_ID,
&params,
&error,
@@ -448,6 +477,11 @@ run (const gchar *name,
{
status = GIMP_PDB_EXECUTION_ERROR;
}
+
+#if LIBHEIF_HAVE_VERSION(1,13,0)
+ heif_deinit ();
+#endif
+
g_object_unref (file);
}
--
2.41.0

View File

@ -197,6 +197,10 @@ Patch100: gimp-2.10.24-external-help-browser.patch
Patch101: gimp-configure-c99.patch
# fix loading HEVC-encoded HEIF images
# patch from upstream: https://gitlab.gnome.org/GNOME/gimp/-/merge_requests/905
Patch102: 0001-plug-ins-use-heif_init-heif_deinit.patch
%description
GIMP (GNU Image Manipulation Program) is a powerful image composition and
editing program, which can be extremely useful for creating logos and other
@ -283,11 +287,13 @@ EOF
%patch 100 -p1 -b .external-help-browser
%endif
%patch 101 -p1
%patch 101 -p1 -b .configure-c99
# Avoid re-running autotools.
touch -r aclocal.m4 configure*
%patch 102 -p1 -b .heif
%build
# allow python2 package for RHEL-8
export RHEL_ALLOW_PYTHON2_FOR_BUILD=1