Skip to content

Commit

Permalink
WIP: try SVT-AV1 pre 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vrabaud committed Feb 11, 2025
1 parent 906a8a5 commit 8623f73
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion cmake/Modules/LocalSvt.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(AVIF_SVT_GIT_TAG "v2.3.0")
set(AVIF_SVT_GIT_TAG "a1db9475bd19cae409322874d0f8cdc5c93c328d")

set(LIB_FILENAME "${AVIF_SOURCE_DIR}/ext/SVT-AV1/Bin/Release/${AVIF_LIBRARY_PREFIX}SvtAv1Enc${CMAKE_STATIC_LIBRARY_SUFFIX}")

Expand Down Expand Up @@ -45,6 +45,7 @@ else()
GIT_TAG "${AVIF_SVT_GIT_TAG}"
UPDATE_COMMAND ""
GIT_SHALLOW ON
PATCH_COMMAND sed -i.bak -e "s/SVT_AV1_VERSION_MAJOR 2/SVT_AV1_VERSION_MAJOR 3/g" Source/API/EbSvtAv1.h
)

set(BUILD_DEC OFF CACHE BOOL "")
Expand All @@ -57,6 +58,11 @@ else()
set(CMAKE_OUTPUT_DIRECTORY_ORIG "${CMAKE_OUTPUT_DIRECTORY}")
set(CMAKE_OUTPUT_DIRECTORY "${SVT_BINARY_DIR}" CACHE INTERNAL "")

# For now, this creates compilation issues:
# _deps/svt-build/libSvtAv1Enc.a: error adding symbols: file format not recognized
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
set(SVT_AV1_LTO OFF)

avif_fetchcontent_populate_cmake(svt)

set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_ORIG} CACHE STRING "" FORCE)
Expand Down
10 changes: 9 additions & 1 deletion src/codec_svt.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ static avifResult svtCodecEncodeImage(avifCodec * codec,
// See https://gitlab.com/AOMediaCodec/SVT-AV1/-/issues/1697.
memset(svt_config, 0, sizeof(EbSvtAv1EncConfiguration));

#if SVT_AV1_CHECK_VERSION(3, 0, 0)
res = svt_av1_enc_init_handle(&codec->internal->svt_encoder, svt_config);
#else
res = svt_av1_enc_init_handle(&codec->internal->svt_encoder, NULL, svt_config);
#endif
if (res != EB_ErrorNone) {
goto cleanup;
}
Expand All @@ -125,14 +129,18 @@ static avifResult svtCodecEncodeImage(avifCodec * codec,
svt_config->is_16bit_pipeline = image->depth > 8;
#endif

#if !SVT_AV1_CHECK_VERSION(1, 5, 0)
// Follow comment in svt header: set if input is HDR10 BT2020 using SMPTE ST2084 (PQ).
svt_config->high_dynamic_range_input = (image->depth == 10 && image->colorPrimaries == AVIF_COLOR_PRIMARIES_BT2020 &&
image->transferCharacteristics == AVIF_TRANSFER_CHARACTERISTICS_SMPTE2084 &&
image->matrixCoefficients == AVIF_MATRIX_COEFFICIENTS_BT2020_NCL);
#endif

svt_config->source_width = image->width;
svt_config->source_height = image->height;
svt_config->logical_processors = encoder->maxThreads;
#if SVT_AV1_CHECK_VERSION(3, 0, 0)
svt_config->level_of_parallelism = encoder->maxThreads;
#endif
svt_config->enable_adaptive_quantization = 2;
// disable 2-pass
#if SVT_AV1_CHECK_VERSION(0, 9, 0)
Expand Down

0 comments on commit 8623f73

Please sign in to comment.