[vlc-devel] [PATCH 6/7] vout: add window properties in vout_display_cfg_t

Thomas Guillem thomas at gllm.fr
Thu Mar 26 16:33:52 CET 2020


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
---
 include/vlc_vout_display.h |  9 +++++++++
 src/video_output/display.c | 29 +++++++++++++++++++++++++----
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 7d748813a9..2e32edf5d3 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.
  */
@@ -101,6 +102,14 @@ 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, if valid (>0), height need to be valid. */
+        unsigned width;
+        /** Current window height, if valid (>0), width need to be valid. */
+        unsigned height;
+    } window;
+
     /** 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 9ef2cd5a41..648ddae9c1 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -102,6 +102,9 @@ void vout_display_GetDefaultDisplaySize(unsigned *width, unsigned *height,
                                         const video_format_t *source,
                                         const vout_display_cfg_t *cfg)
 {
+    assert((cfg->window.width == 0) == (cfg->window.height == 0));
+
+    /* Requested by the user */
     if (cfg->display.width != 0 && cfg->display.height != 0) {
         *width  = cfg->display.width;
         *height = cfg->display.height;
@@ -113,7 +116,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.width != 0) {
+        *width = cfg->window.width;
+        *height = cfg->window.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 +147,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.width == 0 && cfg->window.height == 0);
+
     /* */
     memset(place, 0, sizeof(*place));
     if (cfg->display.width == 0 || cfg->display.height == 0)
@@ -734,10 +748,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.width = osys->cfg.window.height = 0;
+
 #ifdef _WIN32
     osys->reset_pictures = false;
 #endif
-- 
2.20.1



More information about the vlc-devel mailing list