[vlc-devel] [PATCH] libvlc: provide the source video dimensions when updating the surface dimensions

Steve Lhomme robux4 at ycbcr.xyz
Tue Jun 4 12:35:41 CEST 2019


The host may decide to match the source video but it cannot do so if the resize
callback settled the window size (which is also the rendering dimension) for
good.
---
 include/vlc/libvlc_media_player.h       |  3 +++
 modules/video_output/win32/direct3d11.c | 18 ++++++++++++++++++
 modules/video_output/win32/direct3d9.c  | 18 ++++++++++++++++++
 3 files changed, 39 insertions(+)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index dcb0895663..f3da080bcf 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -664,6 +664,9 @@ typedef struct
     libvlc_video_color_space_t colorspace;              /** video color space */
     libvlc_video_color_primaries_t primaries;       /** video color primaries */
     libvlc_video_transfer_func_t transfer;        /** video transfer function */
+
+    unsigned source_width;                    /** original width of the video */
+    unsigned source_height;                  /** original height of the video */
 } libvlc_video_direct3d_cfg_t;
 
 typedef struct
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 44ba25fd0c..8eee856ac0 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -268,6 +268,24 @@ static int QueryDisplayFormat(vout_display_t *vd, const video_format_t *fmt)
 
     cfg.width  = sys->area.vdcfg.display.width;
     cfg.height = sys->area.vdcfg.display.height;
+    if (fmt->i_sar_den && fmt->i_sar_num)
+    {
+        if( fmt->i_sar_num >= fmt->i_sar_den )
+        {
+            cfg.source_width  = fmt->i_visible_width * fmt->i_sar_num / fmt->i_sar_den;
+            cfg.source_height = fmt->i_visible_height;
+        }
+        else
+        {
+            cfg.source_width  = fmt->i_visible_width;
+            cfg.source_height = fmt->i_visible_height * fmt->i_sar_den / fmt->i_sar_num;
+        }
+    }
+    else
+    {
+        cfg.source_width  = fmt->i_visible_width;
+        cfg.source_height = fmt->i_visible_height;
+    }
 
     switch (fmt->i_chroma)
     {
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 69a4665e3e..a155c8d165 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -579,6 +579,24 @@ static int UpdateOutput(vout_display_t *vd, const video_format_t *fmt)
     libvlc_video_direct3d_cfg_t cfg;
     cfg.width  = sys->area.vdcfg.display.width;
     cfg.height = sys->area.vdcfg.display.height;
+    if (fmt->i_sar_den && fmt->i_sar_num)
+    {
+        if( fmt->i_sar_num >= fmt->i_sar_den )
+        {
+            cfg.source_width  = fmt->i_visible_width * fmt->i_sar_num / fmt->i_sar_den;
+            cfg.source_height = fmt->i_visible_height;
+        }
+        else
+        {
+            cfg.source_width  = fmt->i_visible_width;
+            cfg.source_height = fmt->i_visible_height * fmt->i_sar_den / fmt->i_sar_num;
+        }
+    }
+    else
+    {
+        cfg.source_width  = fmt->i_visible_width;
+        cfg.source_height = fmt->i_visible_height;
+    }
 
     switch (fmt->i_chroma)
     {
-- 
2.17.1



More information about the vlc-devel mailing list