HYL_OK3568_LINUX/buildroot/package/gstreamer1/gst1-plugins-bad/0042-kmssink-Avoid-src-size-overflow.patch
2025-05-10 21:49:39 +08:00

40 lines
1.2 KiB
Diff

From 7a7ca574d5805dfa89efd35f1c38d6582a77dd7a Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Fri, 12 May 2023 09:38:03 +0800
Subject: [PATCH 42/42] kmssink: Avoid src size overflow
The scaled video source size might overflow in
gst_kms_sink_calculate_display_ratio()
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
sys/kms/gstkmssink.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/sys/kms/gstkmssink.c b/sys/kms/gstkmssink.c
index 48d3f5b..bf26793 100644
--- a/sys/kms/gstkmssink.c
+++ b/sys/kms/gstkmssink.c
@@ -1706,6 +1706,18 @@ gst_kms_sink_calculate_display_ratio (GstKMSSink * self, GstVideoInfo * vinfo,
*scaled_height = video_height;
}
+ if (*scaled_width > video_width) {
+ GST_DEBUG_OBJECT (self, "keeping video width");
+ *scaled_width = video_width;
+ *scaled_height = (guint)
+ gst_util_uint64_scale_int (video_width, dar_d, dar_n);
+ } else if (*scaled_height > video_height) {
+ GST_DEBUG_OBJECT (self, "keeping video height");
+ *scaled_width = (guint)
+ gst_util_uint64_scale_int (video_height, dar_n, dar_d);
+ *scaled_height = video_height;
+ }
+
out:
GST_DEBUG_OBJECT (self, "scaling to %dx%d", *scaled_width, *scaled_height);
--
2.20.1