plug-ins: prefer AOM encoder for AVIF export
Name of the used encoder is printed during export, It can be: aom, rav1e, x265
This commit is contained in:

committed by
Daniel Novomeský

parent
398dbbe01b
commit
1d44b45f09
@ -1243,6 +1243,8 @@ save_image (GFile *file,
|
|||||||
struct heif_image *image = NULL;
|
struct heif_image *image = NULL;
|
||||||
struct heif_context *context = heif_context_alloc ();
|
struct heif_context *context = heif_context_alloc ();
|
||||||
struct heif_encoder *encoder = NULL;
|
struct heif_encoder *encoder = NULL;
|
||||||
|
const struct heif_encoder_descriptor *encoder_descriptor;
|
||||||
|
const char *encoder_name;
|
||||||
struct heif_image_handle *handle = NULL;
|
struct heif_image_handle *handle = NULL;
|
||||||
struct heif_writer writer;
|
struct heif_writer writer;
|
||||||
struct heif_error err;
|
struct heif_error err;
|
||||||
@ -1265,8 +1267,50 @@ save_image (GFile *file,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_progress_init_printf (_("Exporting '%s'"),
|
if (compression == heif_compression_HEVC)
|
||||||
g_file_get_parse_name (file));
|
{
|
||||||
|
if (heif_context_get_encoder_descriptors (context,
|
||||||
|
heif_compression_HEVC,
|
||||||
|
NULL,
|
||||||
|
&encoder_descriptor, 1) == 1)
|
||||||
|
{
|
||||||
|
encoder_name = heif_encoder_descriptor_get_id_name (encoder_descriptor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||||
|
"Unable to find suitable HEIF encoder");
|
||||||
|
heif_context_free (context);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else /* AV1 compression */
|
||||||
|
{
|
||||||
|
if (heif_context_get_encoder_descriptors (context,
|
||||||
|
compression,
|
||||||
|
"aom", /* we prefer aom rather than rav1e */
|
||||||
|
&encoder_descriptor, 1) == 1)
|
||||||
|
{
|
||||||
|
encoder_name = heif_encoder_descriptor_get_id_name (encoder_descriptor);
|
||||||
|
}
|
||||||
|
else if (heif_context_get_encoder_descriptors (context,
|
||||||
|
compression,
|
||||||
|
NULL,
|
||||||
|
&encoder_descriptor, 1) == 1)
|
||||||
|
{
|
||||||
|
encoder_name = heif_encoder_descriptor_get_id_name (encoder_descriptor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||||
|
"Unable to find suitable AVIF encoder");
|
||||||
|
heif_context_free (context);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gimp_progress_init_printf (_("Exporting '%s' using %s encoder"),
|
||||||
|
g_file_get_parse_name (file), encoder_name);
|
||||||
|
|
||||||
width = gimp_drawable_width (drawable_ID);
|
width = gimp_drawable_width (drawable_ID);
|
||||||
height = gimp_drawable_height (drawable_ID);
|
height = gimp_drawable_height (drawable_ID);
|
||||||
@ -1523,14 +1567,14 @@ save_image (GFile *file,
|
|||||||
|
|
||||||
/* encode to HEIF file */
|
/* encode to HEIF file */
|
||||||
|
|
||||||
err = heif_context_get_encoder_for_format (context,
|
err = heif_context_get_encoder (context,
|
||||||
compression,
|
encoder_descriptor,
|
||||||
&encoder);
|
&encoder);
|
||||||
|
|
||||||
if (err.code != 0)
|
if (err.code != 0)
|
||||||
{
|
{
|
||||||
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||||
"Unable to find suitable HEIF encoder");
|
"Unable to get an encoder instance");
|
||||||
heif_image_release (image);
|
heif_image_release (image);
|
||||||
heif_context_free (context);
|
heif_context_free (context);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1556,7 +1600,7 @@ save_image (GFile *file,
|
|||||||
err = heif_encoder_set_parameter_string (encoder, "chroma", "444");
|
err = heif_encoder_set_parameter_string (encoder, "chroma", "444");
|
||||||
if (err.code != 0)
|
if (err.code != 0)
|
||||||
{
|
{
|
||||||
g_printerr ("Failed to set chroma=444 for %s encoder: %s", heif_encoder_get_name (encoder), err.message);
|
g_printerr ("Failed to set chroma=444 for %s encoder: %s", encoder_name, err.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user