1From 6863269a4386d0428e7655945116d1ea72deb3c2 Mon Sep 17 00:00:00 2001 2From: Jeffy Chen <jeffy.chen@rock-chips.com> 3Date: Fri, 17 Sep 2021 13:20:24 +0800 4Subject: [PATCH 11/14] videoconvert: Support preferred formats 5 6Set env "GST_VIDEO_CONVERT_PREFERRED_FORMAT" to specify preferred 7formats, for example: 8export GST_VIDEO_CONVERT_PREFERRED_FORMAT=NV12:NV16 9 10Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> 11--- 12 gst/videoconvertscale/gstvideoconvertscale.c | 22 ++++++++++++++++++++ 13 1 file changed, 22 insertions(+) 14 15diff --git a/gst/videoconvertscale/gstvideoconvertscale.c b/gst/videoconvertscale/gstvideoconvertscale.c 16index d921b7f..ba905c5 100644 17--- a/gst/videoconvertscale/gstvideoconvertscale.c 18+++ b/gst/videoconvertscale/gstvideoconvertscale.c 19@@ -1044,6 +1044,28 @@ score_value (GstBaseTransform * base, const GstVideoFormatInfo * in_info, 20 loss += SCORE_DEPTH_LOSS; 21 } 22 23+ { 24+ const char *buf = g_getenv ("GST_VIDEO_CONVERT_PREFERRED_FORMAT"); 25+ if (buf) { 26+ const char *name = GST_VIDEO_FORMAT_INFO_NAME (t_info); 27+ int preferred_loss = 1; 28+ 29+ /* lower other formats */ 30+ loss += 1024; 31+ 32+ while (buf) { 33+ if (buf[0] == ':') 34+ buf++; 35+ 36+ if (!strncmp (buf, name, strlen (name))) 37+ loss = preferred_loss; 38+ 39+ buf = strchr (buf, ':'); 40+ preferred_loss++; 41+ } 42+ } 43+ } 44+ 45 GST_DEBUG_OBJECT (base, "score %s -> %s = %d", 46 GST_VIDEO_FORMAT_INFO_NAME (in_info), 47 GST_VIDEO_FORMAT_INFO_NAME (t_info), loss); 48-- 492.20.1 50 51