[vlc-commits] vout: get SAR from internal configuration

Rémi Denis-Courmont git at videolan.org
Sat Jan 26 19:51:16 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jan 26 13:59:12 2019 +0200| [97901eaaf53fb1d6a04690a478a498c3b0b73c8f] | committer: Rémi Denis-Courmont

vout: get SAR from internal configuration

...rather than reading an object variable.

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

 src/video_output/video_output.c | 38 ++++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 1aca086e62..90c834fa10 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -110,7 +110,7 @@ static bool VideoFormatIsCropArEqual(video_format_t *dst,
            dst->i_visible_height == src->i_visible_height;
 }
 
-static void vout_display_window_GetSize(vlc_object_t *obj,
+static void vout_display_SizeWindow(vlc_object_t *obj,
     const video_format_t *restrict source,
     const vout_display_cfg_t *restrict cfg,
     unsigned *restrict width, unsigned *restrict height)
@@ -153,17 +153,6 @@ static void vout_display_window_GetSize(vlc_object_t *obj,
         free(crop);
     }
 
-    char *aspect = crop ? NULL : var_InheritString(obj, "aspect-ratio");
-    if (aspect != NULL) {
-        unsigned num, den;
-
-        if (sscanf(aspect, "%u:%u", &num, &den) == 2 && num > 0 && den > 0)
-            w = h * num / den;
-        else
-            msg_Warn(obj, "Unknown aspect format (%s)", aspect);
-        free(aspect);
-    }
-
     /* Adjust video size for orientation and pixel A/R. */
     if (ORIENT_IS_SWAP(source->orientation)) {
         unsigned x = w;
@@ -192,6 +181,25 @@ static void vout_display_window_GetSize(vlc_object_t *obj,
     *height = (h * cfg->zoom.num) / cfg->zoom.den;
 }
 
+static void vout_SizeWindow(vout_thread_t *vout, unsigned *restrict width,
+                            unsigned *restrict height)
+{
+    vout_thread_sys_t *sys = vout->p;
+    video_format_t source;
+
+    video_format_Copy(&source, &sys->original);
+    if (sys->source.dar.num > 0 && sys->source.dar.den > 0) {
+        unsigned num = sys->source.dar.num * source.i_visible_height;
+        unsigned den = sys->source.dar.den * source.i_visible_width;
+
+        vlc_ureduce(&source.i_sar_num, &source.i_sar_den, num, den, 0);
+    }
+
+    /* If the vout thread is running, the window lock must be held here. */
+    vout_display_SizeWindow(VLC_OBJECT(vout), &source, &sys->display_cfg,
+                            width, height);
+}
+
 static vout_thread_t *VoutCreate(vlc_object_t *object,
                                  const vout_configuration_t *cfg)
 {
@@ -276,8 +284,7 @@ static vout_thread_t *VoutCreate(vlc_object_t *object,
     };
 
     VoutGetDisplayCfg(vout, &sys->display_cfg);
-    vout_display_window_GetSize(VLC_OBJECT(vout), cfg->fmt, &sys->display_cfg,
-                                &wcfg.width, &wcfg.height);
+    vout_SizeWindow(vout, &wcfg.width, &wcfg.height);
 
     if (sys->display_cfg.window != NULL
      && vout_window_Enable(sys->display_cfg.window, &wcfg)) {
@@ -632,8 +639,7 @@ static void vout_ControlUpdateWindowSize(vout_thread_t *vout)
     if (likely(window != NULL)) {
         unsigned width, height;
 
-        vout_display_window_GetSize(VLC_OBJECT(window), &vout->p->original,
-                                    &vout->p->display_cfg, &width, &height);
+        vout_SizeWindow(vout, &width, &height);
         msg_Dbg(window, "requested size: %ux%u", width, height);
         vout_window_SetSize(window, width, height);
     }



More information about the vlc-commits mailing list