From ca385fbb8f5035053e372e9f0aeaa5579aee83e2 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 5 Aug 2023 17:54:28 +0200 Subject: [PATCH] Fix a crash with SVT-AV1. --- nageru/av1_encoder.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nageru/av1_encoder.cpp b/nageru/av1_encoder.cpp index e571184..ca9f7c3 100644 --- a/nageru/av1_encoder.cpp +++ b/nageru/av1_encoder.cpp @@ -132,6 +132,14 @@ void AV1Encoder::add_frame(int64_t pts, int64_t duration, YCbCrLumaCoefficients void AV1Encoder::init_av1() { EbSvtAv1EncConfiguration config; + + // svt_av1_enc_init_handle() is defined to fill config with the defaults; + // yet, seemingly, not everything is written, and some of it can cause + // Valgrind warnings and/or crashes. It should never hurt to put it + // into a known state beforehand, and it seems to fix the crashes, + // so we do that. + memset(&config, 0, sizeof(config)); + EbErrorType ret = svt_av1_enc_init_handle(&encoder, nullptr, &config); if (ret != EB_ErrorNone) { fprintf(stderr, "Error initializing SVT-AV1 handle (error %08x)\n", ret); -- 2.39.2