[vlc-commits] video_output: read the user aspect-ratio values before creating the display

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


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

video_output: read the user aspect-ratio values before creating the display

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

 src/video_output/video_output.c  | 8 ++++++++
 src/video_output/vout_internal.h | 1 +
 src/video_output/vout_intf.c     | 2 +-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index de03a3a044..b973712735 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -2198,6 +2198,14 @@ static int EnableWindowLocked(vout_thread_sys_t *vout, const video_format_t *ori
 
 static void vout_InitSource(vout_thread_sys_t *vout)
 {
+    char *psz_ar = var_InheritString(&vout->obj, "aspect-ratio");
+    if (psz_ar) {
+        unsigned num, den;
+        if (!GetAspectRatio(psz_ar, &num, &den))
+            vout_SetAspectRatio(vout, num, den);
+        free(psz_ar);
+    }
+
     char *psz_crop = var_InheritString(&vout->obj, "crop");
     if (psz_crop) {
         unsigned num, den;
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index 54eb4a7c0a..35da512581 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -108,6 +108,7 @@ bool GetCropMode(const char *crop_str, enum vout_crop_mode *mode,
                         unsigned *num, unsigned *den,
                         unsigned *x, unsigned *y,
                         unsigned *width, unsigned *height );
+bool GetAspectRatio(const char *ar_str, unsigned *num, unsigned *den);
 
 /* TODO to move them to vlc_vout.h */
 void vout_ChangeFullscreen(vout_thread_t *, const char *id);
diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index 12e830d29d..6446fd916c 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -523,7 +523,7 @@ static int CropBorderCallback(vlc_object_t *object, char const *cmd,
     return VLC_SUCCESS;
 }
 
-static bool GetAspectRatio(const char *ar_str, unsigned *num, unsigned *den)
+bool GetAspectRatio(const char *ar_str, unsigned *num, unsigned *den)
 {
     if (sscanf(ar_str, "%u:%u", num, den) == 2 &&
         (num != 0) == (den != 0))



More information about the vlc-commits mailing list