[gimp] plug-ins: some cleaning in HEIF plug-in.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: some cleaning in HEIF plug-in.
- Date: Mon, 1 Jul 2019 17:30:51 +0000 (UTC)
commit f4af95ab9530b8fb4bd551080bb6b520f4b0f346
Author: Jehan <jehan girinstud io>
Date: Mon Jul 1 19:14:28 2019 +0200
plug-ins: some cleaning in HEIF plug-in.
heif_chroma_interleaved_24|32bit are deprecated values replaced by
heif_chroma_interleaved_RGB(A).
Also we allocated a HEIF context twice (i.e. leaking it).
Finally it's better to initialize heif_image and heif_encoder variables
to NULL because these may not be set if creation functions fail (and
it's better to fail with NULL than with garbled unset contents).
plug-ins/common/file-heif.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
---
diff --git a/plug-ins/common/file-heif.c b/plug-ins/common/file-heif.c
index d6892fac4e..78ad9a6568 100644
--- a/plug-ins/common/file-heif.c
+++ b/plug-ins/common/file-heif.c
@@ -350,8 +350,8 @@ load_image (GFile *file,
gsize bytes_read;
struct heif_context *ctx;
struct heif_error err;
- struct heif_image_handle *handle = NULL;
- struct heif_image *img = NULL;
+ struct heif_image_handle *handle = NULL;
+ struct heif_image *img = NULL;
GimpColorProfile *profile = NULL;
gint n_images;
heif_item_id primary;
@@ -480,8 +480,8 @@ load_image (GFile *file,
err = heif_decode_image (handle,
&img,
heif_colorspace_RGB,
- has_alpha ? heif_chroma_interleaved_32bit :
- heif_chroma_interleaved_24bit,
+ has_alpha ? heif_chroma_interleaved_RGBA :
+ heif_chroma_interleaved_RGB,
NULL);
if (err.code)
{
@@ -685,8 +685,8 @@ save_image (GFile *file,
{
struct heif_image *image = NULL;
struct heif_context *context = heif_context_alloc ();
- struct heif_encoder *encoder;
- struct heif_image_handle *handle;
+ struct heif_encoder *encoder = NULL;
+ struct heif_image_handle *handle = NULL;
struct heif_writer writer;
struct heif_error err;
GOutputStream *output;
@@ -802,8 +802,6 @@ save_image (GFile *file,
/* encode to HEIF file */
- context = heif_context_alloc ();
-
err = heif_context_get_encoder_for_format (context,
heif_compression_HEVC,
&encoder);
@@ -903,14 +901,14 @@ load_thumbnails (struct heif_context *heif,
for (i = 0; i < n_images; i++)
{
- struct heif_image_handle *handle;
+ struct heif_image_handle *handle = NULL;
struct heif_error err;
gint width;
gint height;
- struct heif_image_handle *thumbnail_handle;
+ struct heif_image_handle *thumbnail_handle = NULL;
heif_item_id thumbnail_ID;
gint n_thumbnails;
- struct heif_image *thumbnail_img;
+ struct heif_image *thumbnail_img = NULL;
gint thumbnail_width;
gint thumbnail_height;
@@ -978,7 +976,7 @@ load_thumbnails (struct heif_context *heif,
err = heif_decode_image (thumbnail_handle,
&thumbnail_img,
heif_colorspace_RGB,
- heif_chroma_interleaved_24bit,
+ heif_chroma_interleaved_RGB,
NULL);
if (err.code)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]