diff --git a/src/codec_rav1e.c b/src/codec_rav1e.c index c048a41f8d..c39c9a6754 100644 --- a/src/codec_rav1e.c +++ b/src/codec_rav1e.c @@ -88,11 +88,6 @@ static avifResult rav1eCodecEncodeImage(avifCodec * codec, RaFrame * rav1eFrame = NULL; if (!codec->internal->rav1eContext) { - if (codec->csOptions->count > 0) { - // None are currently supported! - return AVIF_RESULT_INVALID_CODEC_SPECIFIC_OPTION; - } - const avifBool supports400 = rav1eSupports400(); RaPixelRange rav1eRange; if (alpha) { @@ -182,6 +177,14 @@ static avifResult rav1eCodecEncodeImage(avifCodec * codec, goto cleanup; } } + for (uint32_t i = 0; i < codec->csOptions->count; ++i) { + avifCodecSpecificOption * entry = &codec->csOptions->entries[i]; + if (rav1e_config_parse(rav1eConfig, entry->key, entry->value) < 0) { + avifDiagnosticsPrintf(codec->diag, "Invalid value for %s: %s.", entry->key, entry->value); + result = AVIF_RESULT_INVALID_CODEC_SPECIFIC_OPTION; + goto cleanup; + } + } rav1e_config_set_color_description(rav1eConfig, (RaMatrixCoefficients)image->matrixCoefficients, diff --git a/src/codec_svt.c b/src/codec_svt.c index ea9efc2b51..193f244a1e 100644 --- a/src/codec_svt.c +++ b/src/codec_svt.c @@ -185,6 +185,23 @@ static avifResult svtCodecEncodeImage(avifCodec * codec, svt_config->intra_period_length = encoder->keyframeInterval - 1; } +#if SVT_AV1_CHECK_VERSION(0, 9, 1) + for (uint32_t i = 0; i < codec->csOptions->count; ++i) { + avifCodecSpecificOption * entry = &codec->csOptions->entries[i]; + if (svt_av1_enc_parse_parameter(svt_config, entry->key, entry->value) < 0) { + avifDiagnosticsPrintf(codec->diag, "Invalid value for %s: %s.", entry->key, entry->value); + result = AVIF_RESULT_INVALID_CODEC_SPECIFIC_OPTION; + goto cleanup; + } + } +#else + if (codec->csOptions->count > 0) { + avifDiagnosticsPrintf(codec->diag, "SVT-AV1 does not support setting options"); + result = AVIF_RESULT_INVALID_CODEC_SPECIFIC_OPTION; + goto cleanup; + } +#endif + res = svt_av1_enc_set_parameter(codec->internal->svt_encoder, svt_config); if (res == EB_ErrorBadParameter) { goto cleanup; diff --git a/tests/test_cmd.sh b/tests/test_cmd.sh index 0756b53c96..cff85b4b88 100755 --- a/tests/test_cmd.sh +++ b/tests/test_cmd.sh @@ -66,6 +66,16 @@ cleanup() { trap cleanup EXIT pushd ${TMP_DIR} + # Test options. + echo "Testing options" + for pair in aom,end-usage,cbr avm,end-usage,cbr rav1e,tiles,1 svt,film-grain,0; do + IFS=','; set -- $pair + if "${AVIFENC}" --help | grep $1' \['; then + "${AVIFENC}" -s 10 -q 85 -c $1 -a foo=1 "${INPUT_Y4M}" "${ENCODED_FILE}" > "${OUT_MSG}" && exit 1 + "${AVIFENC}" -s 10 -q 85 -c $1 -a $2=$3 "${INPUT_Y4M}" "${ENCODED_FILE}" > "${OUT_MSG}" + fi + done + # Lossy test. The decoded pixels should be different from the original image. echo "Testing basic lossy" "${AVIFENC}" -s 8 "${INPUT_Y4M}" -o "${ENCODED_FILE}"