[vlc-commits] video_output: move the aspect-ratio string parsing in a separate function

Steve Lhomme git at videolan.org
Thu Sep 3 07:47:42 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Sep  1 11:47:38 2020 +0200| [ef2c9f7818409ab17b13f276109f6dff4bf09e3f] | committer: Steve Lhomme

video_output: move the aspect-ratio string parsing in a separate function

We need to evaluate it on startup.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ef2c9f7818409ab17b13f276109f6dff4bf09e3f
---

 src/video_output/vout_intf.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index 630961125b..12e830d29d 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -523,6 +523,16 @@ static int CropBorderCallback(vlc_object_t *object, char const *cmd,
     return VLC_SUCCESS;
 }
 
+static bool GetAspectRatio(const char *ar_str, unsigned *num, unsigned *den)
+{
+    if (sscanf(ar_str, "%u:%u", num, den) == 2 &&
+        (num != 0) == (den != 0))
+        return true;
+    else if (*ar_str == '\0')
+        *num = *den = 0;
+    return false;
+}
+
 static int AspectCallback( vlc_object_t *object, char const *cmd,
                          vlc_value_t oldval, vlc_value_t newval, void *data )
 {
@@ -530,11 +540,8 @@ static int AspectCallback( vlc_object_t *object, char const *cmd,
     VLC_UNUSED(cmd); VLC_UNUSED(oldval); VLC_UNUSED(data);
     unsigned num, den;
 
-    if (sscanf(newval.psz_string, "%u:%u", &num, &den) == 2 &&
-        (num != 0) == (den != 0))
+    if (GetAspectRatio(newval.psz_string, &num, &den))
         vout_ChangeDisplayAspectRatio(vout, num, den);
-    else if (*newval.psz_string == '\0')
-        vout_ChangeDisplayAspectRatio(vout, 0, 0);
     return VLC_SUCCESS;
 }
 



More information about the vlc-commits mailing list