va: h264dec: Set the GstVideoAlignment correctly.

We should set GstVideoAlignment based on the sequence's crop information.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2298>
This commit is contained in:
He Junyan 2021-06-18 10:37:06 +08:00 committed by GStreamer Marge Bot
parent 027726d6c8
commit abf6c51e83

View 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* */
}