From cfb14c4b5df33153b68c9c10e6586ee8c07772b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 14 Feb 2023 13:00:40 +0200 Subject: [PATCH] svtav1enc: Drain and completely reallocate the encoder instance on caps changes The encoder does not support reconfiguration, and only deinitializing it and then initializing it again causes deadlocks. Also only reconfigure and drain the encoder if the video info has actually changed. Part-of: --- subprojects/gst-plugins-bad/ext/svtav1/gstsvtav1enc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/svtav1/gstsvtav1enc.c b/subprojects/gst-plugins-bad/ext/svtav1/gstsvtav1enc.c index cc634f6b3a..7eac6fc5ae 100644 --- a/subprojects/gst-plugins-bad/ext/svtav1/gstsvtav1enc.c +++ b/subprojects/gst-plugins-bad/ext/svtav1/gstsvtav1enc.c @@ -988,9 +988,13 @@ gst_svtav1enc_set_format (GstVideoEncoder * encoder, GstVideoCodecState * state) GstVideoCodecState *output_state; GST_DEBUG_OBJECT (svtav1enc, "set_format"); - if (svtav1enc->state) { - gst_video_codec_state_unref (svtav1enc->state); - svt_av1_enc_deinit (svtav1enc->svt_encoder); + if (svtav1enc->state + && !gst_video_info_is_equal (&svtav1enc->state->info, &state->info)) { + gst_svtav1enc_finish (encoder); + gst_svtav1enc_stop (encoder); + gst_svtav1enc_close (encoder); + gst_svtav1enc_open (encoder); + gst_svtav1enc_start (encoder); } svtav1enc->state = gst_video_codec_state_ref (state);