va: h264dec: Set the GstVideoAlignment correctly.
authorHe Junyan <junyan.he@intel.com>
Fri, 18 Jun 2021 02:37:06 +0000 (10:37 +0800)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 28 Jun 2021 15:16:39 +0000 (15:16 +0000)
We should set GstVideoAlignment based on the sequence's crop information.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2298>

sys/va/gstvah264dec.c

index 571eddf..69535a1 100644 (file)
@@ -643,6 +643,7 @@ gst_va_h264_dec_new_sequence (GstH264Decoder * decoder, const GstH264SPS * sps,
   VAProfile profile;
   gint display_width;
   gint display_height;
+  gint padding_left, padding_right, padding_top, padding_bottom;
   guint rt_format;
   gboolean negotiation_needed = FALSE;
   gboolean interlaced;
@@ -653,9 +654,14 @@ gst_va_h264_dec_new_sequence (GstH264Decoder * decoder, const GstH264SPS * sps,
   if (sps->frame_cropping_flag) {
     display_width = sps->crop_rect_width;
     display_height = sps->crop_rect_height;
+    padding_left = sps->crop_rect_x;
+    padding_right = sps->width - sps->crop_rect_x - display_width;
+    padding_top = sps->crop_rect_y;
+    padding_bottom = sps->height - sps->crop_rect_y - display_height;
   } else {
     display_width = sps->width;
     display_height = sps->height;
+    padding_left = padding_right = padding_top = padding_bottom = 0;
   }
 
   profile = _get_profile (self, sps, max_dpb_size);
@@ -701,9 +707,19 @@ gst_va_h264_dec_new_sequence (GstH264Decoder * decoder, const GstH264SPS * sps,
       || base->height < self->coded_height;
   if (base->need_valign) {
     /* *INDENT-OFF* */
+    if (base->valign.padding_left != padding_left ||
+        base->valign.padding_right != padding_right ||
+        base->valign.padding_top != padding_top ||
+        base->valign.padding_bottom != padding_bottom) {
+      negotiation_needed = TRUE;
+      GST_INFO_OBJECT (self, "crop rect changed to (%d,%d)-->(%d,%d)",
+          padding_left, padding_top, padding_right, padding_bottom);
+    }
     base->valign = (GstVideoAlignment) {
-      .padding_bottom = self->coded_height - base->height,
-      .padding_right = self->coded_width - base->width,
+      .padding_left = padding_left,
+      .padding_right = padding_right,
+      .padding_top = padding_top,
+      .padding_bottom = padding_bottom,
     };
     /* *INDENT-ON* */
   }