Submitted By: Douglas R. Reno Date: 2026-02-20 Initial Package Version: 1.21.2 Upstream Status: Pending 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. 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-02-20 00:09:22.177940505 -0600 @@ -838,8 +838,20 @@ 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, 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 +863,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 +871,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 +934,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: */