From b5ec728942599797aa3b5bebfd9a74c0c0aa5299 Mon Sep 17 00:00:00 2001 From: Daniel Novomesky Date: Tue, 5 Jan 2021 15:55:20 +0100 Subject: [PATCH] Add support for SVT-AV1 encoder --- src/file-avif-dialog.c | 89 +++++++++++++++++++++++++++++++++--------- src/file-avif.c | 2 +- 2 files changed, 71 insertions(+), 20 deletions(-) diff --git a/src/file-avif-dialog.c b/src/file-avif-dialog.c index 24b222e..efe51af 100644 --- a/src/file-avif-dialog.c +++ b/src/file-avif-dialog.c @@ -92,42 +92,93 @@ avifplugin_create_codec_store (GObject *config) avifCodecChoice codec_choice = AVIF_CODEC_CHOICE_AUTO; const char *codec_aom; const char *codec_rav1e; + const char *codec_svt; g_object_get (config, "av1-encoder", &codec_choice, NULL); codec_aom = avifCodecName (AVIF_CODEC_CHOICE_AOM, AVIF_CODEC_FLAG_CAN_ENCODE); codec_rav1e = avifCodecName (AVIF_CODEC_CHOICE_RAV1E, AVIF_CODEC_FLAG_CAN_ENCODE); + codec_svt = avifCodecName (AVIF_CODEC_CHOICE_SVT, AVIF_CODEC_FLAG_CAN_ENCODE); if ( (! codec_aom && codec_choice == AVIF_CODEC_CHOICE_AOM) || - (! codec_rav1e && codec_choice == AVIF_CODEC_CHOICE_RAV1E)) /* if the selected encoder is not available, select auto */ + (! codec_rav1e && codec_choice == AVIF_CODEC_CHOICE_RAV1E) || + (! codec_svt && codec_choice == AVIF_CODEC_CHOICE_SVT)) /* if the selected encoder is not available, select auto */ { codec_choice = AVIF_CODEC_CHOICE_AUTO; g_object_set (config, "av1-encoder", codec_choice, NULL); } - if (codec_aom && codec_rav1e) /* both encoders are available */ + if (codec_aom) /* AOM encoder available */ { - return gimp_int_store_new ("(auto)", AVIF_CODEC_CHOICE_AUTO, - codec_aom, AVIF_CODEC_CHOICE_AOM, - codec_rav1e, AVIF_CODEC_CHOICE_RAV1E, - NULL); - } - else if (codec_aom && ! codec_rav1e) /* only AOM is available */ - { - return gimp_int_store_new ("(auto)", AVIF_CODEC_CHOICE_AUTO, - codec_aom, AVIF_CODEC_CHOICE_AOM, - NULL); + if (codec_rav1e) /* RAV1E available */ + { + if (codec_svt) /* SVT available */ + { + return gimp_int_store_new ("(auto)", AVIF_CODEC_CHOICE_AUTO, + codec_aom, AVIF_CODEC_CHOICE_AOM, + codec_rav1e, AVIF_CODEC_CHOICE_RAV1E, + codec_svt, AVIF_CODEC_CHOICE_SVT, + NULL); + } + else /* SVT not available */ + { + return gimp_int_store_new ("(auto)", AVIF_CODEC_CHOICE_AUTO, + codec_aom, AVIF_CODEC_CHOICE_AOM, + codec_rav1e, AVIF_CODEC_CHOICE_RAV1E, + NULL); + } + } + else /* RAV1E not available */ + { + if (codec_svt) /* SVT available */ + { + return gimp_int_store_new ("(auto)", AVIF_CODEC_CHOICE_AUTO, + codec_aom, AVIF_CODEC_CHOICE_AOM, + codec_svt, AVIF_CODEC_CHOICE_SVT, + NULL); + } + else /* SVT not available */ + { + return gimp_int_store_new ("(auto)", AVIF_CODEC_CHOICE_AUTO, + codec_aom, AVIF_CODEC_CHOICE_AOM, + NULL); + } + } } - else if (! codec_aom && codec_rav1e) /* only RAV1E is available */ + else /* AOM not available */ { - return gimp_int_store_new ("(auto)", AVIF_CODEC_CHOICE_AUTO, - codec_rav1e, AVIF_CODEC_CHOICE_RAV1E, - NULL); + if (codec_rav1e) /* RAV1E available */ + { + if (codec_svt) /* SVT available */ + { + return gimp_int_store_new ("(auto)", AVIF_CODEC_CHOICE_AUTO, + codec_rav1e, AVIF_CODEC_CHOICE_RAV1E, + codec_svt, AVIF_CODEC_CHOICE_SVT, + NULL); + } + else /* SVT not available */ + { + return gimp_int_store_new ("(auto)", AVIF_CODEC_CHOICE_AUTO, + codec_rav1e, AVIF_CODEC_CHOICE_RAV1E, + NULL); + } + } + else /* RAV1E not available */ + { + if (codec_svt) /* SVT available */ + { + return gimp_int_store_new ("(auto)", AVIF_CODEC_CHOICE_AUTO, + codec_svt, AVIF_CODEC_CHOICE_SVT, + NULL); + } + else /* SVT not available */ + { + return gimp_int_store_new ("(auto)", AVIF_CODEC_CHOICE_AUTO, + NULL); + } + } } - /* no known encoders were detected */ - return gimp_int_store_new ("(auto)", AVIF_CODEC_CHOICE_AUTO, - NULL); } gboolean save_dialog (GimpImage *image, diff --git a/src/file-avif.c b/src/file-avif.c index f733393..6b33dc3 100644 --- a/src/file-avif.c +++ b/src/file-avif.c @@ -217,7 +217,7 @@ avif_create_procedure (GimpPlugIn *plug_in, GIMP_PROC_ARG_INT (procedure, "av1-encoder", "AV1 encoder", "Select encoder for AV1 stream", - AVIF_CODEC_CHOICE_AUTO, AVIF_CODEC_CHOICE_RAV1E, AVIF_CODEC_CHOICE_AUTO, + AVIF_CODEC_CHOICE_AUTO, AVIF_CODEC_CHOICE_SVT, AVIF_CODEC_CHOICE_AUTO, G_PARAM_READWRITE); GIMP_PROC_ARG_INT (procedure, "encoder-speed",