diff options
author | Haihua Hu <jared.hu@nxp.com> | 2024-03-27 15:21:56 +0900 |
---|---|---|
committer | GStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2024-03-28 12:53:01 +0000 |
commit | 37e3a38ba952e55053ac8bc0598f74378f909437 (patch) | |
tree | 79c2b61692044301faafcd598090059ebc3585a8 | |
parent | d0cfada15edff5d52a794c41822555536632d21d (diff) |
if the calculated "distance" of caps A and B from the preference are
equal, need to keep the original order instead of swap them
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6451>
-rw-r--r-- | subprojects/gst-plugins-good/sys/v4l2/gstv4l2src.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2src.c b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2src.c index 68d8f7f873..beac542d95 100644 --- a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2src.c +++ b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2src.c @@ -448,6 +448,7 @@ gst_v4l2src_fixed_caps_compare (GstCaps * caps_a, GstCaps * caps_b, gint a_fps_n = G_MAXINT, a_fps_d = 1; gint b_fps_n = G_MAXINT, b_fps_d = 1; gint a_distance, b_distance; + gint ret = 0; a = gst_caps_get_structure (caps_a, 0); b = gst_caps_get_structure (caps_b, 0); @@ -468,7 +469,11 @@ gst_v4l2src_fixed_caps_compare (GstCaps * caps_a, GstCaps * caps_b, a_distance = ABS (aw * ah - pref->width * pref->height); b_distance = ABS (bw * bh - pref->width * pref->height); - gint ret = a_distance - b_distance; + /* If the distance are equivalent, maintain the order */ + if (a_distance == b_distance) + ret = 1; + else + ret = a_distance - b_distance; GST_TRACE ("Placing %" GST_PTR_FORMAT " %s %" GST_PTR_FORMAT, caps_a, ret > 0 ? "after" : "before", caps_b); |