[vlc-devel] [PATCH 7/9] video_output: crop the dimensions of SideBySide/TopBottom sources

Steve Lhomme robux4 at ycbcr.xyz
Sat Oct 27 08:46:33 CEST 2018


Except when the user selects the original mode.
---
 src/video_output/display.c | 96 +++++++++++++++++++++++++++++++++-----
 1 file changed, 85 insertions(+), 11 deletions(-)

diff --git a/src/video_output/display.c b/src/video_output/display.c
index bba22dd6c2..f347700643 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -783,15 +783,87 @@ void vout_FilterFlush(vout_display_t *vd)
         filter_chain_VideoFlush(osys->converters);
 }
 
+static void AdjustMultiviewSAR(vout_display_owner_sys_t *osys)
+{
+    if (osys->source.multiview_mode == MULTIVIEW_STEREO_SBS)
+    {
+        switch (osys->stereo_mode)
+        {
+        case VIDEO_STEREO_OUTPUT_RIGHT_ONLY:
+        case VIDEO_STEREO_OUTPUT_AUTO:
+        case VIDEO_STEREO_OUTPUT_LEFT_ONLY:
+            osys->sar.num *= 2;
+            break;
+        case VIDEO_STEREO_OUTPUT_ORIGINAL:
+        default:
+            break;
+        }
+    }
+    else if (osys->source.multiview_mode == MULTIVIEW_STEREO_TB)
+    {
+        switch (osys->stereo_mode)
+        {
+        case VIDEO_STEREO_OUTPUT_RIGHT_ONLY:
+        case VIDEO_STEREO_OUTPUT_AUTO:
+        case VIDEO_STEREO_OUTPUT_LEFT_ONLY:
+            osys->sar.den *= 2;
+            break;
+        case VIDEO_STEREO_OUTPUT_ORIGINAL:
+        default:
+            break;
+        }
+    }
+}
+
 void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t *source)
 {
     vout_display_owner_sys_t *osys = vd->owner.sys;
 
-    if (source->i_sar_num * osys->source.i_sar_den !=
-        source->i_sar_den * osys->source.i_sar_num) {
+    video_format_t fmt = *source;
+
+    /* adjust the display dimensions of the source for the multiview mode */
+    if (source->multiview_mode == MULTIVIEW_STEREO_SBS)
+    {
+        switch (osys->stereo_mode)
+        {
+        case VIDEO_STEREO_OUTPUT_RIGHT_ONLY:
+            fmt.i_x_offset += source->i_visible_width / 2;
+            /* fallthrough */
+        case VIDEO_STEREO_OUTPUT_AUTO:
+        case VIDEO_STEREO_OUTPUT_LEFT_ONLY:
+            fmt.i_visible_width = source->i_visible_width / 2;
+            fmt.i_sar_num *= 2;
+            break;
+        case VIDEO_STEREO_OUTPUT_ORIGINAL:
+        default:
+            break;
+        }
+    }
+    else if (source->multiview_mode == MULTIVIEW_STEREO_TB)
+    {
+        switch (osys->stereo_mode)
+        {
+        case VIDEO_STEREO_OUTPUT_RIGHT_ONLY:
+            fmt.i_y_offset += source->i_visible_height / 2;
+            /* fallthrough */
+        case VIDEO_STEREO_OUTPUT_AUTO:
+        case VIDEO_STEREO_OUTPUT_LEFT_ONLY:
+            fmt.i_visible_height = source->i_visible_height / 2;
+            fmt.i_sar_den *= 2;
+            break;
+        case VIDEO_STEREO_OUTPUT_ORIGINAL:
+        default:
+            break;
+        }
+    }
+
+    osys->source.multiview_mode = fmt.multiview_mode;
 
-        osys->source.i_sar_num = source->i_sar_num;
-        osys->source.i_sar_den = source->i_sar_den;
+
+    if (fmt.i_sar_num * osys->source.i_sar_den !=
+        fmt.i_sar_den * osys->source.i_sar_num) {
+        osys->source.i_sar_num = fmt.i_sar_num;
+        osys->source.i_sar_den = fmt.i_sar_den;
         vlc_ureduce(&osys->source.i_sar_num, &osys->source.i_sar_den,
                     osys->source.i_sar_num, osys->source.i_sar_den, 0);
 
@@ -800,14 +872,13 @@ void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t
         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 ||
-        source->i_visible_width  != osys->source.i_visible_width ||
-        source->i_visible_height != osys->source.i_visible_height ||
-        source->multiview_mode   != osys->source.multiview_mode ) {
 
-        video_format_CopyCrop(&osys->source, source);
-        osys->source.multiview_mode = source->multiview_mode;
+    if (osys->source.i_visible_width  != fmt.i_visible_width ||
+        osys->source.i_visible_height != fmt.i_visible_height ||
+        osys->source.i_x_offset       != fmt.i_x_offset ||
+        osys->source.i_y_offset       != fmt.i_y_offset)
+    {
+        video_format_CopyCrop( &osys->source, &fmt );
 
         /* Force the vout to reapply the current user crop settings over the new decoder
          * crop settings. */
@@ -881,6 +952,8 @@ void vout_SetDisplayAspect(vout_display_t *vd, unsigned dar_num, unsigned dar_de
         osys->ch_sar = true;
         osys->sar.num = sar_num;
         osys->sar.den = sar_den;
+
+        AdjustMultiviewSAR(osys);
     }
 }
 void vout_SetDisplayCrop(vout_display_t *vd,
@@ -1013,6 +1086,7 @@ static vout_display_t *DisplayNew(vout_thread_t *vout,
     if (osys->sar.num != source->i_sar_num ||
         osys->sar.den != source->i_sar_den)
         osys->ch_sar = true;
+    vout_UpdateDisplaySourceProperties(p_display, source);
 
     var_SetBool(osys->vout, "viewpoint-changeable",
                 p_display->fmt.projection_mode != PROJECTION_MODE_RECTANGULAR);
-- 
2.17.0



More information about the vlc-devel mailing list