[vlc-devel] [PATCH v2 2/3] video_output:display: allow some vout to handle the source aspect ratio/crop before display

Steve Lhomme robux4 at ycbcr.xyz
Wed Aug 22 09:42:27 CEST 2018


Rather than waiting for the next display loop which may itself request another change.
---
 include/vlc_vout_display.h |  1 +
 src/video_output/display.c | 34 ++++++++++++++++++++++++++++++----
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
index 86eb1bced0..f8149e7e45 100644
--- a/include/vlc_vout_display.h
+++ b/include/vlc_vout_display.h
@@ -112,6 +112,7 @@ typedef struct {
     bool is_slow;                           /* The picture memory has slow read/write */
     bool has_double_click;                  /* Is double-click generated */
     bool has_pictures_invalid;              /* Will VOUT_DISPLAY_EVENT_PICTURES_INVALID be used */
+    int dynamic_src;                        /* bitmask of VOUT_DISPLAY_CHANGE_SOURCE_xxx supported dynamically */
     const vlc_fourcc_t *subpicture_chromas; /* List of supported chromas for subpicture rendering. */
 } vout_display_info_t;
 
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 36704f46af..9a711bb539 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -92,6 +92,7 @@ static vout_display_t *vout_display_New(vlc_object_t *obj,
     vd->info.is_slow = false;
     vd->info.has_double_click = false;
     vd->info.has_pictures_invalid = false;
+    vd->info.dynamic_src = 0;
     vd->info.subpicture_chromas = NULL;
 
     vd->cfg = cfg;
@@ -820,6 +821,7 @@ void vout_FilterFlush(vout_display_t *vd)
 void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t *source)
 {
     vout_display_owner_sys_t *osys = vd->owner.sys;
+    bool fit_window= false;
 
     if (source->i_sar_num * osys->source.i_sar_den !=
         source->i_sar_den * osys->source.i_sar_num) {
@@ -830,9 +832,17 @@ void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t
                     osys->source.i_sar_num, osys->source.i_sar_den, 0);
 
         /* FIXME it will override any AR that the user would have forced */
-        osys->ch_sar = true;
-        osys->sar.num = osys->source.i_sar_num;
-        osys->sar.den = osys->source.i_sar_den;
+        if (vd->info.dynamic_src & (1<<VOUT_DISPLAY_CHANGE_SOURCE_ASPECT))
+        {
+            UpdateSourceAspect(vd);
+            fit_window = true;
+        }
+        else
+        {
+            osys->ch_sar = true;
+            osys->sar.num = osys->source.i_sar_num;
+            osys->sar.den = osys->source.i_sar_den;
+        }
     }
     if (source->i_x_offset       != osys->source.i_x_offset ||
         source->i_y_offset       != osys->source.i_y_offset ||
@@ -843,8 +853,24 @@ void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t
 
         /* Force the vout to reapply the current user crop settings over the new decoder
          * crop settings. */
-        osys->ch_crop = true;
+        if (vd->info.dynamic_src & (1<<VOUT_DISPLAY_CHANGE_SOURCE_CROP))
+        {
+            UpdateSourceCrop(vd);
+            fit_window = true;
+        }
+        else
+        {
+            osys->ch_crop = true;
+        }
+    } else if (osys->ch_crop &&
+               vd->info.dynamic_src & (1<<VOUT_DISPLAY_CHANGE_SOURCE_CROP))
+    {
+        UpdateSourceCrop(vd);
+        fit_window = true;
     }
+
+    if (fit_window)
+        VoutDisplayFitWindow(vd, false);
 }
 
 void vout_SetDisplaySize(vout_display_t *vd, unsigned width, unsigned height)
-- 
2.17.0



More information about the vlc-devel mailing list