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 9999df5..fc59340 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 4b168bf..0a1ef5f 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 62b1ae8..411a707 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 53f616f..37cd691 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 53be567..7f17516 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 4520dcb..011220f 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 ed925ce..010c5d0 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 fe80575..6f7f930 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 f6f18cb..b35bd66 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)