[vlc-commits] [Git][videolan/vlc][master] 8 commits: splitter: create display with correct window size

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Tue Jan 11 11:20:10 UTC 2022



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
3b77d4bb by Rémi Denis-Courmont at 2022-01-11T10:54:25+00:00
splitter: create display with correct window size

So far, the display was created without a requested size. Then its size
was immediately changed to that of the window.

With this change, the display is created directly with the correct size.
This matches the core video output behaviour.

- - - - -
dfe512fe by Rémi Denis-Courmont at 2022-01-11T10:54:25+00:00
display: ignore display size in default computation

In practice, this function is used to compensate mismatches between
the source format SAR and the display PAR and should only be based on
those parameters and the source format visible dimensions. Indeed, in
the two call sites of the function pass 0x0 as the display size.

In the vout_display_New() call site, the function is used to
work-around semi-broken window providers that do not provision a window
size, or only do so with a delay. Normally, it just copies the dimensions
from window_props.

Either way cfg->display dimensions are always zeroes.

Furthermore, the 3 hereto unused and hereby removed cases failed to
account for orientation correctly: from_source should have been false.

- - - - -
e84106dc by Rémi Denis-Courmont at 2022-01-11T10:54:25+00:00
display: avoid copy

This is no longer necessary.

- - - - -
958d2f56 by Rémi Denis-Courmont at 2022-01-11T10:54:25+00:00
display: partially inline vout_display_GetDefaultDisplaySize()

Only from vout_display_New() can (and should) the window size be used
rather than the ideal default display size. In the other call sites,
we actually want to compute the ideal size regardless of the actual
window size.

Take that case out of vout_display_GetDefaultDisplaySize() to enable
further refactoring. This is a non-functional change, except for the
added run-time warning.

- - - - -
494ab046 by Rémi Denis-Courmont at 2022-01-11T10:54:25+00:00
display: remove constant variable

- - - - -
20abc11d by Rémi Denis-Courmont at 2022-01-11T10:54:25+00:00
display: pass initial size in cfg.display

...rather than cfg.window_props. cfg.display was unused (always zeroes)
on vout_display_New() until this change.

This is consistent with vout_display_SetSize() affecting cfg.display
rather than cfg.window_props.

- - - - -
aaad9f9e by Rémi Denis-Courmont at 2022-01-11T10:54:25+00:00
display: reorder to simplify

No functional changes.

- - - - -
39c63441 by Rémi Denis-Courmont at 2022-01-11T10:54:25+00:00
display: remove window_props

They were always zeroes.

- - - - -


4 changed files:

- include/vlc_vout_display.h
- modules/video_output/splitter.c
- src/video_output/display.c
- src/video_output/video_output.c


Changes:

=====================================
include/vlc_vout_display.h
=====================================
@@ -99,18 +99,6 @@ 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;
 


=====================================
modules/video_output/splitter.c
=====================================
@@ -300,9 +300,14 @@ static int vlc_vidsplit_Open(vout_display_t *vd,
         }
 
         vdcfg.window = part->window;
+        vlc_sem_wait(&part->lock);
+        vdcfg.display.width = part->width;
+        vdcfg.display.height = part->height;
+
         vout_display_t *display = vout_display_New(obj, &output->fmt, ctx, &vdcfg,
                                                    modname, NULL);
         if (display == NULL) {
+            vlc_sem_post(&part->lock);
             vout_window_Disable(part->window);
             vout_window_Delete(part->window);
             splitter->i_output = i;
@@ -310,9 +315,7 @@ static int vlc_vidsplit_Open(vout_display_t *vd,
             return VLC_EGENERIC;
         }
 
-        vlc_sem_wait(&part->lock);
         part->display = display;
-        vout_display_SetSize(display, part->width, part->height);
         vlc_sem_post(&part->lock);
     }
 


=====================================
src/video_output/display.c
=====================================
@@ -75,29 +75,8 @@ void vout_display_GetDefaultDisplaySize(unsigned *width, unsigned *height,
                                         const video_format_t *source,
                                         const vout_display_cfg_t *cfg)
 {
-    bool from_source = true;
-    /* Requested by the user */
-    if (cfg->display.width != 0 && cfg->display.height != 0) {
-        *width  = cfg->display.width;
-        *height = cfg->display.height;
-    } else if (cfg->display.width != 0) {
-        *width  = cfg->display.width;
-        *height = (int64_t)source->i_visible_height * source->i_sar_den * cfg->display.width * cfg->display.sar.num /
-            source->i_visible_width / source->i_sar_num / cfg->display.sar.den;
-    } else if (cfg->display.height != 0) {
-        *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;
-    }
-    /* 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;
-        /* The dimensions are not initialized from the source format */
-        from_source = false;
-    }
     /* Use the original video size */
-    else if (source->i_sar_num >= source->i_sar_den) {
+    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 {
@@ -108,7 +87,7 @@ void vout_display_GetDefaultDisplaySize(unsigned *width, unsigned *height,
     *width  = *width  * cfg->zoom.num / cfg->zoom.den;
     *height = *height * cfg->zoom.num / cfg->zoom.den;
 
-    if (from_source && ORIENT_IS_SWAP(source->orientation)) {
+    if (ORIENT_IS_SWAP(source->orientation)) {
         /* Apply the source orientation only if the dimensions are initialized
          * from the source format */
         unsigned store = *width;
@@ -122,11 +101,6 @@ 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)
         return;
@@ -142,14 +116,9 @@ void vout_display_PlacePicture(vout_display_place_t *place,
     if (cfg->is_display_filled) {
         display_width  = cfg->display.width;
         display_height = cfg->display.height;
-    } else {
-        vout_display_cfg_t cfg_tmp = *cfg;
-
-        cfg_tmp.display.width  = 0;
-        cfg_tmp.display.height = 0;
+    } else
         vout_display_GetDefaultDisplaySize(&display_width, &display_height,
-                                           source, &cfg_tmp);
-    }
+                                           source, cfg);
 
     const unsigned width  = source->i_visible_width;
     const unsigned height = source->i_visible_height;
@@ -677,16 +646,15 @@ 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;
-    /* 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;
+
+    if (cfg->display.width == 0 || cfg->display.height == 0) {
+        /* Work around buggy window provider */
+        msg_Warn(parent, "window size missing");
+        vout_display_GetDefaultDisplaySize(&osys->cfg.display.width,
+                                           &osys->cfg.display.height,
+                                           source, cfg);
+    }
 
     osys->pool = NULL;
 


=====================================
src/video_output/video_output.c
=====================================
@@ -1647,8 +1647,8 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
     vlc_mutex_unlock(&sys->window_lock);
 
     /* Setup the window size, protected by the display_lock */
-    dcfg.window_props.width = sys->window_width;
-    dcfg.window_props.height = sys->window_height;
+    dcfg.display.width = sys->window_width;
+    dcfg.display.height = sys->window_height;
 
     sys->display = vout_OpenWrapper(&vout->obj, &sys->private, sys->splitter_name, &dcfg,
                                     &sys->original, vctx);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3dc5ed78966643bbba8ff4c3fb2785330f174263...39c634418a5040e0883d9ab48569c3123cc75e3a

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3dc5ed78966643bbba8ff4c3fb2785330f174263...39c634418a5040e0883d9ab48569c3123cc75e3a
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list