Skip to content

Commit e649830

Browse files
authored
Make code compatible with SVT-AV1 3.0 (#2607)
1 parent 29f4eb7 commit e649830

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

cmake/Modules/LocalSvt.cmake

+6
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ else()
5757
set(CMAKE_OUTPUT_DIRECTORY_ORIG "${CMAKE_OUTPUT_DIRECTORY}")
5858
set(CMAKE_OUTPUT_DIRECTORY "${SVT_BINARY_DIR}" CACHE INTERNAL "")
5959

60+
if(CMAKE_INTERPROCEDURAL_OPTIMIZATION)
61+
set(SVT_AV1_LTO ON)
62+
else()
63+
set(SVT_AV1_LTO OFF)
64+
endif()
65+
6066
avif_fetchcontent_populate_cmake(svt)
6167

6268
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_ORIG} CACHE STRING "" FORCE)

src/codec_svt.c

+10-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "svt-av1/EbSvtAv1Enc.h"
99

10+
#include <stdbool.h>
1011
#include <stdint.h>
1112
#include <string.h>
1213

@@ -114,7 +115,11 @@ static avifResult svtCodecEncodeImage(avifCodec * codec,
114115
// See https://gitlab.com/AOMediaCodec/SVT-AV1/-/issues/1697.
115116
memset(svt_config, 0, sizeof(EbSvtAv1EncConfiguration));
116117

118+
#if SVT_AV1_CHECK_VERSION(3, 0, 0)
119+
res = svt_av1_enc_init_handle(&codec->internal->svt_encoder, svt_config);
120+
#else
117121
res = svt_av1_enc_init_handle(&codec->internal->svt_encoder, NULL, svt_config);
122+
#endif
118123
if (res != EB_ErrorNone) {
119124
goto cleanup;
120125
}
@@ -124,15 +129,13 @@ static avifResult svtCodecEncodeImage(avifCodec * codec,
124129
#if !SVT_AV1_CHECK_VERSION(0, 9, 0)
125130
svt_config->is_16bit_pipeline = image->depth > 8;
126131
#endif
127-
128-
// Follow comment in svt header: set if input is HDR10 BT2020 using SMPTE ST2084 (PQ).
129-
svt_config->high_dynamic_range_input = (image->depth == 10 && image->colorPrimaries == AVIF_COLOR_PRIMARIES_BT2020 &&
130-
image->transferCharacteristics == AVIF_TRANSFER_CHARACTERISTICS_SMPTE2084 &&
131-
image->matrixCoefficients == AVIF_MATRIX_COEFFICIENTS_BT2020_NCL);
132-
133132
svt_config->source_width = image->width;
134133
svt_config->source_height = image->height;
134+
#if SVT_AV1_CHECK_VERSION(3, 0, 0)
135+
svt_config->level_of_parallelism = encoder->maxThreads;
136+
#else
135137
svt_config->logical_processors = encoder->maxThreads;
138+
#endif
136139
svt_config->enable_adaptive_quantization = 2;
137140
// disable 2-pass
138141
#if SVT_AV1_CHECK_VERSION(0, 9, 0)
@@ -175,7 +178,7 @@ static avifResult svtCodecEncodeImage(avifCodec * codec,
175178

176179
// In order for SVT-AV1 to force keyframes by setting pic_type to
177180
// EB_AV1_KEY_PICTURE on any frame, force_key_frames has to be set.
178-
svt_config->force_key_frames = TRUE;
181+
svt_config->force_key_frames = true;
179182

180183
// keyframeInterval == 1 case is handled when encoding each frame by
181184
// setting pic_type to EB_AV1_KEY_PICTURE. For keyframeInterval > 1,

0 commit comments

Comments
 (0)