Skip to content

Commit

Permalink
Add support for SVT-AV1 encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
novomesk committed Jan 5, 2021
1 parent 59ebb14 commit b5ec728
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 20 deletions.
89 changes: 70 additions & 19 deletions src/file-avif-dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/file-avif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit b5ec728

Please sign in to comment.