- updates to buildrequires - synced required versions with configure.ac - convert more buildrequires to pkgconfig() versions - enable libheif on Tumbleweed, since we have the version in TW with avif support, but not actual HEIF support unless libheif from packman is used. - added libheif-avif-only.patch: libheif based exporter will only offer the formats supported by the installed libheif (via runtime check) OBS-URL: https://build.opensuse.org/request/show/844181 OBS-URL: https://build.opensuse.org/package/show/graphics/gimp?expand=0&rev=48
275 lines
12 KiB
Diff
275 lines
12 KiB
Diff
diff --git a/plug-ins/common/file-heif.c b/plug-ins/common/file-heif.c
|
|
index 945951e5f4..e79419d5f0 100644
|
|
--- a/plug-ins/common/file-heif.c
|
|
+++ b/plug-ins/common/file-heif.c
|
|
@@ -47,7 +47,7 @@ struct _SaveParams
|
|
|
|
/* local function prototypes */
|
|
|
|
-static void query (void);
|
|
+static void init (void);
|
|
static void run (const gchar *name,
|
|
gint nparams,
|
|
const GimpParam *param,
|
|
@@ -73,9 +73,9 @@ static gboolean save_dialog (SaveParams *params,
|
|
|
|
GimpPlugInInfo PLUG_IN_INFO =
|
|
{
|
|
- NULL, /* init_proc */
|
|
+ init, /* init_proc */
|
|
NULL, /* quit_proc */
|
|
- query, /* query_proc */
|
|
+ NULL, /* query_proc */
|
|
run, /* run_proc */
|
|
};
|
|
|
|
@@ -84,7 +84,7 @@ MAIN ()
|
|
|
|
|
|
static void
|
|
-query (void)
|
|
+init (void)
|
|
{
|
|
static const GimpParamDef load_args[] =
|
|
{
|
|
@@ -110,87 +110,102 @@ query (void)
|
|
{ GIMP_PDB_INT32, "lossless", "Use lossless compression (0 = lossy, 1 = lossless)" }
|
|
};
|
|
|
|
- gimp_install_procedure (LOAD_PROC,
|
|
- _("Loads HEIF images"),
|
|
- _("Load image stored in HEIF format (High "
|
|
- "Efficiency Image File Format). Typical "
|
|
- "suffices for HEIF files are .heif, .heic."),
|
|
- "Dirk Farin <farin@struktur.de>",
|
|
- "Dirk Farin <farin@struktur.de>",
|
|
- "2018",
|
|
- _("HEIF/HEIC"),
|
|
- NULL,
|
|
- GIMP_PLUGIN,
|
|
- G_N_ELEMENTS (load_args),
|
|
- G_N_ELEMENTS (load_return_vals),
|
|
- load_args, load_return_vals);
|
|
-
|
|
- gimp_register_load_handler (LOAD_PROC,
|
|
- "heic,heif"
|
|
+ if (heif_have_decoder_for_format (heif_compression_HEVC)
|
|
#if LIBHEIF_HAVE_VERSION(1,8,0)
|
|
- ",avif"
|
|
+ || heif_have_decoder_for_format (heif_compression_AV1)
|
|
#endif
|
|
- , "");
|
|
- gimp_register_file_handler_mime (LOAD_PROC,
|
|
- "image/heif"
|
|
-#if LIBHEIF_HAVE_VERSION(1,8,0)
|
|
- ",image/avif"
|
|
-#endif
|
|
- );
|
|
- gimp_register_file_handler_uri (LOAD_PROC);
|
|
- /* HEIF is an ISOBMFF format whose "brand" (the value after "ftyp")
|
|
- * can be of various values.
|
|
- * See also: https://gitlab.gnome.org/GNOME/gimp/issues/2209
|
|
- */
|
|
- gimp_register_magic_load_handler (LOAD_PROC,
|
|
- "heif,heic"
|
|
-#if LIBHEIF_HAVE_VERSION(1,8,0)
|
|
- ",avif"
|
|
-#endif
|
|
- , "",
|
|
- "4,string,ftypheic,4,string,ftypheix,"
|
|
- "4,string,ftyphevc,4,string,ftypheim,"
|
|
- "4,string,ftypheis,4,string,ftyphevm,"
|
|
- "4,string,ftyphevs,4,string,ftypmif1,"
|
|
- "4,string,ftypmsf1"
|
|
+ )
|
|
+ {
|
|
+ GString *extensions = g_string_new (NULL);
|
|
+ GString *mimetypes = g_string_new (NULL);
|
|
+ GString *magic = g_string_new ("4,string,ftypmif1");
|
|
+
|
|
+ if (heif_have_decoder_for_format (heif_compression_HEVC))
|
|
+ {
|
|
+ g_string_append (extensions, "heic,heif");
|
|
+ g_string_append (mimetypes, "image/heif");
|
|
+ g_string_append (magic, ",4,string,ftypheic,4,string,ftypheix,"
|
|
+ "4,string,ftyphevc,4,string,ftypheim,"
|
|
+ "4,string,ftypheis,4,string,ftyphevm,"
|
|
+ "4,string,ftyphevs,4,string,ftypmsf1");
|
|
+ }
|
|
+
|
|
#if LIBHEIF_HAVE_VERSION(1,8,0)
|
|
- ",4,string,ftypavif"
|
|
+ if (heif_have_decoder_for_format (heif_compression_AV1))
|
|
+ {
|
|
+ g_string_append_printf (extensions, "%savif", extensions->len ? "," : "");
|
|
+ g_string_append_printf (mimetypes, "%simage/avif", mimetypes->len ? "," : "");
|
|
+ g_string_append (magic, ",4,string,ftypavif");
|
|
+ }
|
|
#endif
|
|
- );
|
|
-
|
|
- gimp_install_procedure (SAVE_PROC,
|
|
- _("Exports HEIF images"),
|
|
- _("Save image in HEIF format (High Efficiency "
|
|
- "Image File Format)."),
|
|
- "Dirk Farin <farin@struktur.de>",
|
|
- "Dirk Farin <farin@struktur.de>",
|
|
- "2018",
|
|
- _("HEIF/HEIC"),
|
|
- "RGB*",
|
|
- GIMP_PLUGIN,
|
|
- G_N_ELEMENTS (save_args), 0,
|
|
- save_args, NULL);
|
|
-
|
|
- gimp_register_save_handler (SAVE_PROC, "heic,heif", "");
|
|
- gimp_register_file_handler_mime (SAVE_PROC, "image/heif");
|
|
- gimp_register_file_handler_uri (SAVE_PROC);
|
|
+
|
|
+ gimp_install_procedure (LOAD_PROC,
|
|
+ _("Loads HEIF images"),
|
|
+ _("Load image stored in HEIF format (High "
|
|
+ "Efficiency Image File Format). Typical "
|
|
+ "suffices for HEIF files are .heif, .heic."),
|
|
+ "Dirk Farin <farin@struktur.de>",
|
|
+ "Dirk Farin <farin@struktur.de>",
|
|
+ "2018",
|
|
+ _("HEIF/HEIC"),
|
|
+ NULL,
|
|
+ GIMP_PLUGIN,
|
|
+ G_N_ELEMENTS (load_args),
|
|
+ G_N_ELEMENTS (load_return_vals),
|
|
+ load_args, load_return_vals);
|
|
+
|
|
+ gimp_register_load_handler (LOAD_PROC, extensions->str, "");
|
|
+ gimp_register_file_handler_mime (LOAD_PROC, mimetypes->str);
|
|
+ gimp_register_file_handler_uri (LOAD_PROC);
|
|
+
|
|
+ gimp_register_magic_load_handler (LOAD_PROC,
|
|
+ extensions->str, "",
|
|
+ magic->str);
|
|
+
|
|
+ g_string_free (magic, TRUE);
|
|
+ g_string_free (mimetypes, TRUE);
|
|
+ g_string_free (extensions, TRUE);
|
|
+ }
|
|
+
|
|
+ if (heif_have_encoder_for_format (heif_compression_HEVC))
|
|
+ {
|
|
+ gimp_install_procedure (SAVE_PROC,
|
|
+ _("Exports HEIF images"),
|
|
+ _("Save image in HEIF format (High Efficiency "
|
|
+ "Image File Format)."),
|
|
+ "Dirk Farin <farin@struktur.de>",
|
|
+ "Dirk Farin <farin@struktur.de>",
|
|
+ "2018",
|
|
+ _("HEIF/HEIC"),
|
|
+ "RGB*",
|
|
+ GIMP_PLUGIN,
|
|
+ G_N_ELEMENTS (save_args), 0,
|
|
+ save_args, NULL);
|
|
+
|
|
+ gimp_register_save_handler (SAVE_PROC, "heic,heif", "");
|
|
+ gimp_register_file_handler_mime (SAVE_PROC, "image/heif");
|
|
+ gimp_register_file_handler_uri (SAVE_PROC);
|
|
+ }
|
|
|
|
#if LIBHEIF_HAVE_VERSION(1,8,0)
|
|
- gimp_install_procedure (SAVE_PROC_AV1,
|
|
- "Exports AVIF images",
|
|
- "Save image in AV1 Image File Format (AVIF)",
|
|
- "Daniel Novomesky <dnovomesky@gmail.com>",
|
|
- "Daniel Novomesky <dnovomesky@gmail.com>",
|
|
- "2020",
|
|
- "HEIF/AVIF",
|
|
- "RGB*",
|
|
- GIMP_PLUGIN,
|
|
- G_N_ELEMENTS (save_args), 0,
|
|
- save_args, NULL);
|
|
-
|
|
- gimp_register_save_handler (SAVE_PROC_AV1, "avif", "");
|
|
- gimp_register_file_handler_mime (SAVE_PROC_AV1, "image/avif");
|
|
- gimp_register_file_handler_uri (SAVE_PROC_AV1);
|
|
+ if (heif_have_encoder_for_format (heif_compression_AV1))
|
|
+ {
|
|
+ gimp_install_procedure (SAVE_PROC_AV1,
|
|
+ _("Exports AVIF images"),
|
|
+ _("Save image in AV1 Image File Format (AVIF)"),
|
|
+ "Daniel Novomesky <dnovomesky@gmail.com>",
|
|
+ "Daniel Novomesky <dnovomesky@gmail.com>",
|
|
+ "2020",
|
|
+ "HEIF/AVIF",
|
|
+ "RGB*",
|
|
+ GIMP_PLUGIN,
|
|
+ G_N_ELEMENTS (save_args), 0,
|
|
+ save_args, NULL);
|
|
+
|
|
+ gimp_register_save_handler (SAVE_PROC_AV1, "avif", "");
|
|
+ gimp_register_file_handler_mime (SAVE_PROC_AV1, "image/avif");
|
|
+ gimp_register_file_handler_uri (SAVE_PROC_AV1);
|
|
+ }
|
|
#endif
|
|
}
|
|
|
|
@@ -1139,12 +1154,12 @@ load_image (GFile *file,
|
|
while (new_exif_size >= 4) /*Searching for TIFF Header*/
|
|
{
|
|
if (tiffheader[0] == tiffHeaderBE[0] && tiffheader[1] == tiffHeaderBE[1] &&
|
|
- tiffheader[2] == tiffHeaderBE[2] && tiffheader[2] == tiffHeaderBE[2])
|
|
+ tiffheader[2] == tiffHeaderBE[2] && tiffheader[3] == tiffHeaderBE[3])
|
|
{
|
|
break;
|
|
}
|
|
if (tiffheader[0] == tiffHeaderLE[0] && tiffheader[1] == tiffHeaderLE[1] &&
|
|
- tiffheader[2] == tiffHeaderLE[2] && tiffheader[2] == tiffHeaderLE[2])
|
|
+ tiffheader[2] == tiffHeaderLE[2] && tiffheader[3] == tiffHeaderLE[3])
|
|
{
|
|
break;
|
|
}
|
|
@@ -1525,6 +1540,17 @@ save_image (GFile *file,
|
|
heif_encoder_set_lossless (encoder, params->lossless);
|
|
/* heif_encoder_set_logging_level (encoder, logging_level); */
|
|
|
|
+#if LIBHEIF_HAVE_VERSION(1,9,0)
|
|
+ if (params->lossless && params->save_bit_depth == 8)
|
|
+ {
|
|
+ err = heif_encoder_set_parameter_string (encoder, "chroma", "444");
|
|
+ if (err.code != 0)
|
|
+ {
|
|
+ g_printerr ("Failed to set chroma=444 for %s encoder: %s", heif_encoder_get_name (encoder), err.message);
|
|
+ }
|
|
+ }
|
|
+#endif
|
|
+
|
|
err = heif_context_encode_image (context,
|
|
image,
|
|
encoder,
|
|
@@ -1984,7 +2010,7 @@ save_dialog (SaveParams *params,
|
|
frame = gimp_frame_new (NULL);
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
|
|
|
- lossless_button = gtk_check_button_new_with_mnemonic (_("Nearly _lossless (YUV420 format)"));
|
|
+ lossless_button = gtk_check_button_new_with_mnemonic (_("Nearly _lossless"));
|
|
gtk_frame_set_label_widget (GTK_FRAME (frame), lossless_button);
|
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
|
@@ -1998,7 +2024,7 @@ save_dialog (SaveParams *params,
|
|
gtk_range_set_value (GTK_RANGE (quality_slider), params->quality);
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lossless_button),
|
|
params->lossless);
|
|
- gtk_widget_set_sensitive (quality_slider, !params->lossless);
|
|
+ gtk_widget_set_sensitive (hbox, !params->lossless);
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), quality_slider);
|
|
|
|
g_signal_connect (lossless_button, "toggled",
|
|
@@ -2038,8 +2064,8 @@ save_dialog (SaveParams *params,
|
|
gtk_widget_show (label2);
|
|
|
|
combo = gimp_int_combo_box_new (_("8 bit/channel"), 8,
|
|
- _("10 bit/channel (HDR)"), 10,
|
|
- _("12 bit/channel (HDR)"), 12,
|
|
+ _("10 bit/channel"), 10,
|
|
+ _("12 bit/channel"), 12,
|
|
NULL);
|
|
gtk_table_attach (GTK_TABLE (table), combo, 1, 2, 0, 1,
|
|
GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|