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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3957>
This commit is contained in:
Sebastian Dröge 2023-02-14 13:00:40 +02:00 committed by Sebastian Dröge
parent a14f8008fb
commit cfb14c4b5d

View file

@ -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);