[vlc-devel] [PATCH 2/7] display: don't rotate the source format to estimate the display dimensions

Steve Lhomme robux4 at ycbcr.xyz
Fri Nov 13 16:56:29 CET 2020


In PlacePicture we need the actual display dimensions but GetDefaultDisplaySize
already takes in account the rotation to swap the width/height if the source is
rotated that way.

We also don't need to rotate the full video format if the source is a 360 video
which is going to use the full display area anyway.
---
 src/video_output/display.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/video_output/display.c b/src/video_output/display.c
index 0ddfc3bd452..11e14d7cb8a 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -131,10 +131,6 @@ void vout_display_PlacePicture(vout_display_place_t *place,
     unsigned display_width;
     unsigned display_height;
 
-    video_format_t source_rot;
-    video_format_ApplyRotation(&source_rot, source);
-    source = &source_rot;
-
     if (cfg->is_display_filled) {
         display_width  = cfg->display.width;
         display_height = cfg->display.height;
@@ -147,14 +143,19 @@ void vout_display_PlacePicture(vout_display_place_t *place,
                                            source, &cfg_tmp);
     }
 
-    const unsigned width  = source->i_visible_width;
-    const unsigned height = source->i_visible_height;
-    /* Compute the height if we use the width to fill up display_width */
-    const int64_t scaled_height = (int64_t)height * display_width  * cfg->display.sar.num * source->i_sar_den / (width  * source->i_sar_num * cfg->display.sar.den);
-    /* And the same but switching width/height */
-    const int64_t scaled_width  = (int64_t)width  * display_height * cfg->display.sar.den * source->i_sar_num / (height * source->i_sar_den * cfg->display.sar.num);
+    if (likely(source->projection_mode == PROJECTION_MODE_RECTANGULAR)) {
+        video_format_t vd_source_rot;
+        video_format_ApplyRotation(&vd_source_rot, source);
+
+        const unsigned width  = vd_source_rot.i_visible_width;
+        const unsigned height = vd_source_rot.i_visible_height;
+        /* Compute the height if we use the width to fill up display_width */
+        const int64_t scaled_height = (int64_t)height * cfg->display.sar.num * vd_source_rot.i_sar_den * display_width
+                                            / (width  * cfg->display.sar.den * vd_source_rot.i_sar_num);
+        /* And the same but switching width/height */
+        const int64_t scaled_width  = (int64_t)width  * vd_source_rot.i_sar_num * cfg->display.sar.den * display_height
+                                            / (height * vd_source_rot.i_sar_den * cfg->display.sar.num);
 
-    if (source->projection_mode == PROJECTION_MODE_RECTANGULAR) {
         /* We keep the solution that avoid filling outside the display */
         if (scaled_width <= cfg->display.width) {
             place->width  = scaled_width;
-- 
2.26.2



More information about the vlc-devel mailing list