msdkenc: renegotiate when video info changes
authorJulien Isorce <jisorce@oblong.com>
Thu, 26 Dec 2019 21:31:50 +0000 (13:31 -0800)
committerJulien Isorce <julien.isorce@gmail.com>
Mon, 6 Jan 2020 01:13:28 +0000 (01:13 +0000)
Renegotiation was implemented for bitrate change. We can re-use
the same sequence when video info changes except that this can be
executed right away when receiving the new input format. I.e. no
need to wait for the next call to handle_frame.

sys/msdk/gstmsdkenc.c

index 6218736..fad4357 100644 (file)
@@ -1097,8 +1097,14 @@ gst_msdkenc_set_format (GstVideoEncoder * encoder, GstVideoCodecState * state)
   GstMsdkEncClass *klass = GST_MSDKENC_GET_CLASS (thiz);
 
   if (state) {
-    if (thiz->input_state)
+    if (thiz->input_state) {
+      if (!gst_video_info_is_equal (&thiz->input_state->info, &state->info)) {
+        GST_INFO_OBJECT (thiz, "Re-init the encoder as info changed");
+        gst_msdkenc_flush_frames (thiz, FALSE);
+        gst_msdkenc_close_encoder (thiz);
+      }
       gst_video_codec_state_unref (thiz->input_state);
+    }
     thiz->input_state = gst_video_codec_state_ref (state);
   }