Submitted By: Douglas R. Reno Date: 2026-02-20 Updated Date: 2026-05-10 Initial Package Version: 1.21.2 Upstream Status: Applied Origin: Upstream (PR #1680) Description: Fixes building libheif with SVT-AV1-4.0 and later. Note that users need to have enabled the SVT-AV1 encoder at compile time via the Command Explanations. Update Description: Updated the patch to work with SVT-AV1-4.1, which was needed to fix another build failure. This is the same PR, but the PR was not updated to support SVT-AV1-4.1 until long after the last patch was created. It has since been merged upstream. diff -Naurp libheif-1.21.2.orig/libheif/plugins/encoder_svt.cc libheif-1.21.2/libheif/plugins/encoder_svt.cc --- libheif-1.21.2.orig/libheif/plugins/encoder_svt.cc 2026-01-16 02:03:07.000000000 -0600 +++ libheif-1.21.2/libheif/plugins/encoder_svt.cc 2026-05-10 17:11:58.820444281 -0500 @@ -838,8 +838,32 @@ static heif_error svt_start_sequence_enc // svt_config.force_key_frames = true; TODO: this does not seem to work (see all [1]) #if 1 +#if SVT_AV1_CHECK_VERSION(4, 1, 0) + switch (options->gop_structure) { + case heif_sequence_gop_structure_intra_only: + //svt_config.pred_structure = 1; // LOW_DELAY + break; + case heif_sequence_gop_structure_lowdelay: + //svt_config.pred_structure = 1; // LOW_DELAY + break; + case heif_sequence_gop_structure_unrestricted: + svt_config.pred_structure = PredStructure::RANDOM_ACCESS; + break; + } +#elif SVT_AV1_CHECK_VERSION(4, 0, 0) + switch (options->gop_structure) { + case heif_sequence_gop_structure_intra_only: + //svt_config.pred_structure = 1; // LOW_DELAY + break; + case heif_sequence_gop_structure_lowdelay: + //svt_config.pred_structure = 1; // LOW_DELAY + break; + case heif_sequence_gop_structure_unrestricted: + svt_config.pred_structure = 2; // RANDOM_ACCESS + break; + } +#else // TODO: setting pref_structure to SVT_AV1_PRED_LOW_DELAY_B hangs the encoder - switch (options->gop_structure) { case heif_sequence_gop_structure_intra_only: //svt_config.pred_structure = SvtAv1PredStructure::SVT_AV1_PRED_LOW_DELAY_B; @@ -851,6 +875,7 @@ static heif_error svt_start_sequence_enc svt_config.pred_structure = SvtAv1PredStructure::SVT_AV1_PRED_RANDOM_ACCESS; break; } +#endif if (options->keyframe_distance_max) { svt_config.intra_period_length = options->keyframe_distance_max; // TODO -1 ? @@ -858,9 +883,10 @@ static heif_error svt_start_sequence_enc #endif } else { - // TODO: enable when https://gitlab.com/AOMediaCodec/SVT-AV1/-/issues/2245 is resolved - // svt_config.avif = true; - // encoder->still_image_mode = true; +#if SVT_AV1_CHECK_VERSION(4, 0, 0) + svt_config.avif = true; + encoder->still_image_mode = true; +#endif } if (color_format == EB_YUV422 || bitdepth_y > 10) { @@ -920,7 +946,7 @@ static heif_error read_encoder_output_pa /* TODO: this is a hack * When using - * svt_config.pred_structure = SvtAv1PredStructure::SVT_AV1_PRED_LOW_DELAY_B; + * svt_config.pred_structure = 1; // LOW_DELAY * svt_av1_enc_get_packet() hangs on the second call. As a workaround, we can leave the * loop when we got the image: */