From 89519e8809850fee0762146cb38c5fda1fc6d76c Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Wed, 9 Jan 2019 14:24:35 +0100 Subject: [PATCH] videoscale: Choose the best dimensions for fixed PAR We might not get an exact match for width or height if stepped ranges are involved. --- gst/videoscale/gstvideoscale.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gst/videoscale/gstvideoscale.c b/gst/videoscale/gstvideoscale.c index c4cc4379c3..66d0d21fb7 100644 --- a/gst/videoscale/gstvideoscale.c +++ b/gst/videoscale/gstvideoscale.c @@ -978,10 +978,14 @@ gst_video_scale_fixate_caps (GstBaseTransform * base, GstPadDirection direction, goto done; } - /* If all this failed, keep the height that was nearest to the orignal - * height and the nearest possible width. This changes the DAR but - * there's not much else to do here. + /* If all this failed, keep the dimensions with the DAR that was closest + * to the correct DAR. This changes the DAR but there's not much else to + * do here. */ + if (set_w * ABS (set_h - h) < ABS (f_w - w) * f_h) { + f_h = set_h; + f_w = set_w; + } gst_structure_set (outs, "width", G_TYPE_INT, f_w, "height", G_TYPE_INT, f_h, NULL); goto done;