[vlc-devel] [PATCH] Support for rotated MP4 Movies (bug #2882)

Matthias Keiser matthias at tristan-inc.com
Thu Feb 6 23:21:53 CET 2014


From ff4d4b5bf739e13ec2fc6bb85c6cda1b2aae8ad9 Mon Sep 17 00:00:00 2001
From: Matthias Keiser <matthias at tristan-inc.com>
Date: Thu, 6 Feb 2014 16:30:41 +0100
Subject: [PATCH 12/13] vout_display_GetDefaultDisplaySize,
 vout_display_PlacePicture: take into account video rotation.

---
 src/video_output/display.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/video_output/display.c b/src/video_output/display.c
index b268c18..19548e6 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -197,6 +197,12 @@ 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(source->orientation == ORIENT_ROTATED_90 || source->orientation == ORIENT_ROTATED_270) {
+        unsigned store = *width;
+        *width = *height;
+        *height = store;
+    }
 }
 
 /* */
@@ -214,6 +220,10 @@ void vout_display_PlacePicture(vout_display_place_t *place,
     unsigned display_width;
     unsigned display_height;
 
+    video_format_t sourceRot;
+    video_format_t *p_sourceRot = &sourceRot;
+    video_format_ApplyRotation(source, p_sourceRot);
+
     if (cfg->is_display_filled) {
         display_width  = cfg->display.width;
         display_height = cfg->display.height;
@@ -223,7 +233,7 @@ void vout_display_PlacePicture(vout_display_place_t *place,
         cfg_tmp.display.width  = 0;
         cfg_tmp.display.height = 0;
         vout_display_GetDefaultDisplaySize(&display_width, &display_height,
-                                           source, &cfg_tmp);
+                                           p_sourceRot, &cfg_tmp);
 
         if (do_clipping) {
             display_width  = __MIN(display_width,  cfg->display.width);
@@ -231,12 +241,12 @@ void vout_display_PlacePicture(vout_display_place_t *place,
         }
     }
 
-    const unsigned width  = source->i_visible_width;
-    const unsigned height = source->i_visible_height;
+    const unsigned width  = p_sourceRot->i_visible_width;
+    const unsigned height = p_sourceRot->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;
+    const int64_t scaled_height = (int64_t)height * display_width  * cfg->display.sar.num * p_sourceRot->i_sar_den / width  / p_sourceRot->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;
+    const int64_t scaled_width  = (int64_t)width  * display_height * cfg->display.sar.den * p_sourceRot->i_sar_num / height / p_sourceRot->i_sar_den / cfg->display.sar.num;
 
     /* We keep the solution that avoid filling outside the display */
     if (scaled_width <= cfg->display.width) {
-- 
1.8.3.4 (Apple Git-47)





More information about the vlc-devel mailing list