HYL_OK3568_LINUX/buildroot/package/gstreamer1/gst1-plugins-base/0011-videoconvert-Support-preferred-formats.patch
2025-05-10 21:49:39 +08:00

51 lines
1.5 KiB
Diff

From 6863269a4386d0428e7655945116d1ea72deb3c2 Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Fri, 17 Sep 2021 13:20:24 +0800
Subject: [PATCH 11/14] videoconvert: Support preferred formats
Set env "GST_VIDEO_CONVERT_PREFERRED_FORMAT" to specify preferred
formats, for example:
export GST_VIDEO_CONVERT_PREFERRED_FORMAT=NV12:NV16
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
gst/videoconvertscale/gstvideoconvertscale.c | 22 ++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/gst/videoconvertscale/gstvideoconvertscale.c b/gst/videoconvertscale/gstvideoconvertscale.c
index d921b7f..ba905c5 100644
--- a/gst/videoconvertscale/gstvideoconvertscale.c
+++ b/gst/videoconvertscale/gstvideoconvertscale.c
@@ -1044,6 +1044,28 @@ score_value (GstBaseTransform * base, const GstVideoFormatInfo * in_info,
loss += SCORE_DEPTH_LOSS;
}
+ {
+ const char *buf = g_getenv ("GST_VIDEO_CONVERT_PREFERRED_FORMAT");
+ if (buf) {
+ const char *name = GST_VIDEO_FORMAT_INFO_NAME (t_info);
+ int preferred_loss = 1;
+
+ /* lower other formats */
+ loss += 1024;
+
+ while (buf) {
+ if (buf[0] == ':')
+ buf++;
+
+ if (!strncmp (buf, name, strlen (name)))
+ loss = preferred_loss;
+
+ buf = strchr (buf, ':');
+ preferred_loss++;
+ }
+ }
+ }
+
GST_DEBUG_OBJECT (base, "score %s -> %s = %d",
GST_VIDEO_FORMAT_INFO_NAME (in_info),
GST_VIDEO_FORMAT_INFO_NAME (t_info), loss);
--
2.20.1