gimp/0001-plug-ins-use-heif_init-heif_deinit.patch
Nils Philippsen 7fde2224db Fix loading HEVC-encoded HEIF images (#2189462)
Signed-off-by: Nils Philippsen <nils@tiptoe.de>
2023-08-20 23:59:01 +02:00

102 lines
2.6 KiB
Diff

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