From 671d9fed3a8c3dca76aceee5549175ff1b321193 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Thu, 17 Sep 2020 17:39:25 -0400 Subject: [PATCH] kmssink: Do not source using padded width/height The width/height from the video meta can be padded width, height. But when sourcing from padded buffer, we only want to use the valid pixels. This rectangle is from the crop meta, orther it is deduces from the caps. The width and height from the caps is save in the parent class, use these instead of the GstVideoInfo when settting the src rectangle. This fixes an issue with 1080p video displaying repeated or green at the padded bottom 8 lines (seen with v4l2codecs). Part-of: --- sys/kms/gstkmssink.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sys/kms/gstkmssink.c b/sys/kms/gstkmssink.c index e9e3fe9977..db983439e9 100644 --- a/sys/kms/gstkmssink.c +++ b/sys/kms/gstkmssink.c @@ -1569,6 +1569,7 @@ gst_kms_sink_show_frame (GstVideoSink * vsink, GstBuffer * buf) GstVideoInfo *vinfo; GstVideoCropMeta *crop; GstVideoRectangle src = { 0, }; + gint video_width, video_height; GstVideoRectangle dst = { 0, }; GstVideoRectangle result; GstFlowReturn res; @@ -1580,13 +1581,13 @@ gst_kms_sink_show_frame (GstVideoSink * vsink, GstBuffer * buf) if (buf) { buffer = gst_kms_sink_get_input_buffer (self, buf); vinfo = &self->vinfo; - src.w = GST_VIDEO_SINK_WIDTH (self); - src.h = GST_VIDEO_SINK_HEIGHT (self); + video_width = src.w = GST_VIDEO_SINK_WIDTH (self); + video_height = src.h = GST_VIDEO_SINK_HEIGHT (self); } else if (self->last_buffer) { buffer = gst_buffer_ref (self->last_buffer); vinfo = &self->last_vinfo; - src.w = self->last_width; - src.h = self->last_height; + video_width = src.w = self->last_width; + video_height = src.h = self->last_height; } /* Make sure buf is not used accidentally */ @@ -1633,8 +1634,8 @@ retry_set_plane: src.w = crop->width; src.h = crop->height; } else { - src.w = GST_VIDEO_INFO_WIDTH (vinfo); - src.h = GST_VIDEO_INFO_HEIGHT (vinfo); + src.w = video_width; + src.h = video_height; } /* handle out of screen case */