va: Handle input caps change.
authorVictor Manuel Jaquez Leal <vjaquez@igalia.com>
Mon, 28 Nov 2022 19:42:29 +0000 (20:42 +0100)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Thu, 1 Dec 2022 18:54:14 +0000 (18:54 +0000)
Update output caps if it's notified by baseclass

See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3328

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3480>

subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c
subprojects/gst-plugins-bad/sys/va/gstvabasedec.c
subprojects/gst-plugins-bad/sys/va/gstvabasedec.h
subprojects/gst-plugins-bad/sys/va/gstvah264dec.c
subprojects/gst-plugins-bad/sys/va/gstvah265dec.c
subprojects/gst-plugins-bad/sys/va/gstvajpegdec.c
subprojects/gst-plugins-bad/sys/va/gstvampeg2dec.c
subprojects/gst-plugins-bad/sys/va/gstvavp8dec.c
subprojects/gst-plugins-bad/sys/va/gstvavp9dec.c

index 9999df5a103f7084591b1c8c92261f18670219a0..fc593409c21c34b64e4e7b95e311d16f47c6a3ef 100644 (file)
@@ -955,7 +955,7 @@ gst_va_av1_dec_output_picture (GstAV1Decoder * decoder,
     frame->output_buffer = gst_buffer_ref (pic->gstbuffer);
   }
 
-  ret = gst_va_base_dec_process_output (base, frame, 0);
+  ret = gst_va_base_dec_process_output (base, frame, picture->discont_state, 0);
   gst_av1_picture_unref (picture);
 
   if (ret)
index 4b168bfe3abef7885dc4fb4486d97d0faa30f0a4..0a1ef5f0f8bdd4d58fb1b38c086c3c059f006518 100644 (file)
@@ -1061,10 +1061,27 @@ fail:
 
 gboolean
 gst_va_base_dec_process_output (GstVaBaseDec * base, GstVideoCodecFrame * frame,
-    GstVideoBufferFlags buffer_flags)
+    GstVideoCodecState * input_state, GstVideoBufferFlags buffer_flags)
 {
   GstVideoDecoder *vdec = GST_VIDEO_DECODER (base);
 
+  if (input_state) {
+
+    g_assert (GST_VIDEO_INFO_WIDTH (&input_state->info) ==
+        GST_VIDEO_INFO_WIDTH (&base->input_state->info)
+        && GST_VIDEO_INFO_HEIGHT (&input_state->info) ==
+        GST_VIDEO_INFO_HEIGHT (&input_state->info));
+
+    g_clear_pointer (&base->input_state, gst_video_codec_state_unref);
+    base->input_state = gst_video_codec_state_ref (input_state);
+
+    base->need_negotiation = TRUE;
+    if (!gst_video_decoder_negotiate (vdec)) {
+      GST_ERROR_OBJECT (base, "Could not re-negotiate with updated state");
+      return GST_FLOW_ERROR;
+    }
+  }
+
   if (base->copy_frames)
     gst_va_base_dec_copy_output_buffer (base, frame);
 
index 62b1ae81611823e1dc99aaf08ff182073dbd3fd7..411a7072bf61057f0da3c2c5ad06494b5a74cce9 100644 (file)
@@ -137,6 +137,7 @@ gboolean              gst_va_base_dec_copy_output_buffer  (GstVaBaseDec * base,
                                                            GstVideoCodecFrame * codec_frame);
 gboolean              gst_va_base_dec_process_output      (GstVaBaseDec * base,
                                                            GstVideoCodecFrame * frame,
+                                                           GstVideoCodecState * input_state,
                                                            GstVideoBufferFlags buffer_flags);
 GstFlowReturn         gst_va_base_dec_prepare_output_frame (GstVaBaseDec * base,
                                                             GstVideoCodecFrame * frame);
index 53f616f9ada2385c7dc8132a2da82dac0562ad29..37cd6918f7e8cc57dc2673eb528da3669e91de8d 100644 (file)
@@ -123,7 +123,8 @@ gst_va_h264_dec_output_picture (GstH264Decoder * decoder,
   GST_LOG_OBJECT (self,
       "Outputting picture %p (poc %d)", picture, picture->pic_order_cnt);
 
-  ret = gst_va_base_dec_process_output (base, frame, picture->buffer_flags);
+  ret = gst_va_base_dec_process_output (base, frame, picture->discont_state,
+      picture->buffer_flags);
   gst_h264_picture_unref (picture);
 
   if (ret)
index 53be56792c62bd55bb311036c148ecd96727cfea..7f17516bba70cb857e5c20407ce0682323a21cb7 100644 (file)
@@ -240,7 +240,8 @@ gst_va_h265_dec_output_picture (GstH265Decoder * decoder,
 
   gst_buffer_replace (&frame->output_buffer, va_pic->gstbuffer);
 
-  ret = gst_va_base_dec_process_output (base, frame, picture->buffer_flags);
+  ret = gst_va_base_dec_process_output (base, frame, picture->discont_state,
+      picture->buffer_flags);
   gst_h265_picture_unref (picture);
 
   if (ret)
index 4520dcbae1d11bf3706f2a412167c26115191924..011220f0a148fb752936211495429333516394b8 100644 (file)
@@ -322,7 +322,7 @@ gst_va_jpeg_dec_output_picture (GstJpegDecoder * decoder,
   GstVaBaseDec *base = GST_VA_BASE_DEC (decoder);
   GstVideoDecoder *vdec = GST_VIDEO_DECODER (decoder);
 
-  if (gst_va_base_dec_process_output (base, frame, 0))
+  if (gst_va_base_dec_process_output (base, frame, NULL, 0))
     return gst_video_decoder_finish_frame (vdec, frame);
   return GST_FLOW_ERROR;
 }
index ed925ce57c43ae6216587598fed735b4dd671e8c..010c5d0dfd601e4781d564f2a8337c6a1f025ee8 100644 (file)
@@ -518,7 +518,8 @@ gst_va_mpeg2_dec_output_picture (GstMpeg2Decoder * decoder,
   GST_LOG_OBJECT (self,
       "Outputting picture %p (poc %d)", picture, picture->pic_order_cnt);
 
-  ret = gst_va_base_dec_process_output (base, frame, picture->buffer_flags);
+  ret = gst_va_base_dec_process_output (base, frame, picture->discont_state,
+      picture->buffer_flags);
   gst_mpeg2_picture_unref (picture);
 
   if (ret)
index fe805752096f8a4517a3d19ba50ed98a38025b29..6f7f930a43022f219c3f1c951a74eb00d3625f9a 100644 (file)
@@ -398,7 +398,7 @@ gst_va_vp8_dec_output_picture (GstVp8Decoder * decoder,
       "Outputting picture %p (system_frame_number %d)",
       picture, picture->system_frame_number);
 
-  ret = gst_va_base_dec_process_output (base, frame, 0);
+  ret = gst_va_base_dec_process_output (base, frame, picture->discont_state, 0);
   gst_vp8_picture_unref (picture);
 
   if (ret)
index f6f18cb206d9f83716a14b1c79d67158c1ae81e8..b35bd66f307cfbc1e2acf9d76c995d4ebfaf0e00 100644 (file)
@@ -506,7 +506,7 @@ gst_va_vp9_dec_output_picture (GstVp9Decoder * decoder,
 
   GST_LOG_OBJECT (self, "Outputting picture %p", picture);
 
-  ret = gst_va_base_dec_process_output (base, frame, 0);
+  ret = gst_va_base_dec_process_output (base, frame, picture->discont_state, 0);
   gst_vp9_picture_unref (picture);
 
   if (ret)