]> git.sesse.net Git - nageru/blobdiff - nageru/av1_encoder.cpp
Fix a crash with SVT-AV1.
[nageru] / nageru / av1_encoder.cpp
index e571184585f33a5637b958d07215f0ef98dfab20..ca9f7c3d4f34480727a238bfe2ad65dc7ebab7be 100644 (file)
@@ -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);