[vlc-commits] vout: add window properties in vout_display_cfg_t

Thomas Guillem git at videolan.org
Mon Mar 30 09:55:43 CEST 2020


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Mar 26 16:15:39 2020 +0100| [eac402705c341b28b01c15fc16041e5c728c2d38] | committer: Thomas Guillem

vout: add window properties in vout_display_cfg_t

It should be used before the initialisation of the vd plugin. During the
lifetime of the vd plugin, only cfg->display size should be used.

Refs #22674

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

 include/vlc_vout_display.h | 13 +++++++++++++
 src/video_output/display.c | 27 +++++++++++++++++++++++----
 2 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index cd183fb56c..b6282b052b 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -86,6 +86,7 @@ typedef struct vlc_video_align {
  * window, as follows:
  * - If \ref is_display_filled is set,
  *   the video size is fitted to the display size.
+ * - If \ref window size is valid, the video size is set to the window size,
  * - Otherwise, the video size is determined from the original video format,
  *   multiplied by the zoom factor.
  */
@@ -102,6 +103,18 @@ typedef struct vout_display_cfg {
         vlc_rational_t sar; /**< Requested sample aspect ratio */
     } display;
 
+    /**
+     * Window properties
+     *
+     * Should be ignored from display modules.
+     */
+    struct {
+        /** Current window width */
+        unsigned width;
+        /** Current window height */
+        unsigned height;
+    } window_props;
+
     /** Alignment of the video within the window */
     vlc_video_align_t align;
 
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 76d49ee240..8fd444168d 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -102,6 +102,7 @@ void vout_display_GetDefaultDisplaySize(unsigned *width, unsigned *height,
                                         const video_format_t *source,
                                         const vout_display_cfg_t *cfg)
 {
+    /* Requested by the user */
     if (cfg->display.width != 0 && cfg->display.height != 0) {
         *width  = cfg->display.width;
         *height = cfg->display.height;
@@ -113,7 +114,14 @@ void vout_display_GetDefaultDisplaySize(unsigned *width, unsigned *height,
         *width  = (int64_t)source->i_visible_width * source->i_sar_num * cfg->display.height * cfg->display.sar.den /
             source->i_visible_height / source->i_sar_den / cfg->display.sar.num;
         *height = cfg->display.height;
-    } else if (source->i_sar_num >= source->i_sar_den) {
+    }
+    /* Size reported by the window module */
+    else if (cfg->window_props.width != 0 && cfg->window_props.height != 0) {
+        *width = cfg->window_props.width;
+        *height = cfg->window_props.height;
+    }
+    /* Use the original video size */
+    else if (source->i_sar_num >= source->i_sar_den) {
         *width  = (int64_t)source->i_visible_width * source->i_sar_num * cfg->display.sar.den / source->i_sar_den / cfg->display.sar.num;
         *height = source->i_visible_height;
     } else {
@@ -137,6 +145,10 @@ void vout_display_PlacePicture(vout_display_place_t *place,
                                const video_format_t *source,
                                const vout_display_cfg_t *cfg)
 {
+    /* vout_display_PlacePicture() is called from vd plugins. They should not
+     * care about the initial window properties. */
+    assert(cfg->window_props.width == 0 && cfg->window_props.height == 0);
+
     /* */
     memset(place, 0, sizeof(*place));
     if (cfg->display.width == 0 || cfg->display.height == 0)
@@ -733,10 +745,17 @@ vout_display_t *vout_display_New(vlc_object_t *parent,
     if (unlikely(osys == NULL))
         return NULL;
 
+    unsigned display_width, display_height;
+    vout_display_GetDefaultDisplaySize(&display_width, &display_height,
+                                       source, cfg);
+
     osys->cfg = *cfg;
-    vout_display_GetDefaultDisplaySize(&osys->cfg.display.width,
-                                       &osys->cfg.display.height,
-                                       source, &osys->cfg);
+    /* The window size was used for the initial setup. Now it can be dropped in
+     * favor of the calculated display size. */
+    osys->cfg.display.width = display_width;
+    osys->cfg.display.height = display_height;
+    osys->cfg.window_props.width = osys->cfg.window_props.height = 0;
+
 #ifdef _WIN32
     osys->reset_pictures = false;
 #endif



More information about the vlc-commits mailing list