codecs: vp9: Also consider render_width/height
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 1 Dec 2021 17:10:42 +0000 (12:10 -0500)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 2 Dec 2021 19:19:59 +0000 (19:19 +0000)
Also emits new_sequence if on keyframe and the render_width/height have
change. The subclass can always optimize this if the frame resolution
didn't change, the output caps needs to reflect this though.

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

subprojects/gst-plugins-bad/gst-libs/gst/codecs/gstvp9decoder.c

index 7d7537e..67fa8fb 100644 (file)
@@ -66,8 +66,10 @@ GST_DEBUG_CATEGORY (gst_vp9_decoder_debug);
 
 struct _GstVp9DecoderPrivate
 {
-  gint width;
-  gint height;
+  gint frame_width;
+  gint frame_height;
+  gint render_width;
+  gint render_height;
   GstVP9Profile profile;
 
   gboolean had_sequence;
@@ -145,6 +147,11 @@ gst_vp9_decoder_start (GstVideoDecoder * decoder)
   priv->parser = gst_vp9_stateful_parser_new ();
   priv->dpb = gst_vp9_dpb_new ();
   priv->wait_keyframe = TRUE;
+  priv->profile = GST_VP9_PROFILE_UNDEFINED;
+  priv->frame_width = 0;
+  priv->frame_height = 0;
+  priv->render_width = 0;
+  priv->render_height = 0;
 
   priv->output_queue =
       gst_queue_array_new_for_struct (sizeof (GstVp9DecoderOutputFrame), 1);
@@ -176,11 +183,21 @@ gst_vp9_decoder_check_codec_change (GstVp9Decoder * self,
   GstFlowReturn ret = GST_FLOW_OK;
   gboolean changed = FALSE;
 
-  if (priv->width != frame_hdr->width || priv->height != frame_hdr->height) {
-    GST_INFO_OBJECT (self, "resolution changed %dx%d", frame_hdr->width,
+  if (priv->frame_width != frame_hdr->width
+      || priv->frame_height != frame_hdr->height) {
+    GST_INFO_OBJECT (self, "frame resolution changed %dx%d", frame_hdr->width,
         frame_hdr->height);
-    priv->width = frame_hdr->width;
-    priv->height = frame_hdr->height;
+    priv->frame_width = frame_hdr->width;
+    priv->frame_height = frame_hdr->height;
+    changed = TRUE;
+  }
+
+  if (priv->render_width != frame_hdr->render_width
+      || priv->render_height != frame_hdr->render_height) {
+    GST_INFO_OBJECT (self, "render resolution changed %dx%d",
+        frame_hdr->render_width, frame_hdr->render_height);
+    priv->render_width = frame_hdr->render_width;
+    priv->render_height = frame_hdr->render_height;
     changed = TRUE;
   }
 
@@ -235,9 +252,6 @@ gst_vp9_decoder_set_format (GstVideoDecoder * decoder,
 
   self->input_state = gst_video_codec_state_ref (state);
 
-  priv->width = GST_VIDEO_INFO_WIDTH (&state->info);
-  priv->height = GST_VIDEO_INFO_HEIGHT (&state->info);
-
   query = gst_query_new_latency ();
   if (gst_pad_peer_query (GST_VIDEO_DECODER_SINK_PAD (self), query))
     gst_query_parse_latency (query, &priv->is_live, NULL, NULL);