[vlc-devel] [PATCH 05/18] libvlc: merge libvlc_video_render_cfg_t and libvlc_video_direct3d_cfg_t

Steve Lhomme robux4 at ycbcr.xyz
Tue Feb 4 16:26:00 CET 2020


The OpenGL callbacks can now tell the bitdepth request, the full/studio range,
the color space/primary/transfer.

For now we only support 8-bits full range BT.709 rendering.
---
 doc/libvlc/d3d11_player.cpp                  |  2 +-
 doc/libvlc/d3d9_player.c                     |  2 +-
 include/vlc/libvlc_media_player.h            | 20 +++++++-------------
 modules/video_output/vgl.c                   |  4 +++-
 modules/video_output/win32/d3d11_swapchain.c |  6 +++---
 modules/video_output/win32/d3d11_swapchain.h |  2 +-
 modules/video_output/win32/direct3d11.c      |  2 +-
 modules/video_output/win32/direct3d9.c       |  4 ++--
 8 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/doc/libvlc/d3d11_player.cpp b/doc/libvlc/d3d11_player.cpp
index a7aa522750f..d6feba29aa0 100644
--- a/doc/libvlc/d3d11_player.cpp
+++ b/doc/libvlc/d3d11_player.cpp
@@ -346,7 +346,7 @@ static void release_direct3d(struct render_context *ctx)
     list_dxgi_leaks();
 }
 
-static bool UpdateOutput_cb( void *opaque, const libvlc_video_direct3d_cfg_t *cfg, libvlc_video_output_cfg_t *out )
+static bool UpdateOutput_cb( void *opaque, const libvlc_video_render_cfg_t *cfg, libvlc_video_output_cfg_t *out )
 {
     struct render_context *ctx = static_cast<struct render_context *>( opaque );
 
diff --git a/doc/libvlc/d3d9_player.c b/doc/libvlc/d3d9_player.c
index 46a088377d4..17dfc51d1b2 100644
--- a/doc/libvlc/d3d9_player.c
+++ b/doc/libvlc/d3d9_player.c
@@ -236,7 +236,7 @@ static void Resize_cb( void *opaque,
     LeaveCriticalSection(&ctx->sizeLock);
 }
 
-static bool UpdateOutput_cb( void *opaque, const libvlc_video_direct3d_cfg_t *cfg, libvlc_video_output_cfg_t *out )
+static bool UpdateOutput_cb( void *opaque, const libvlc_video_render_cfg_t *cfg, libvlc_video_output_cfg_t *out )
 {
     struct render_context *ctx = opaque;
     return Resize(ctx, cfg->width, cfg->height, (IDirect3DDevice9*)cfg->device, out);
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 62224450f13..8ba12cc5098 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -525,6 +525,12 @@ typedef struct
 {
     unsigned width;                        /** rendering video width in pixel */
     unsigned height;                      /** rendering video height in pixel */
+    unsigned bitdepth;      /** rendering video bit depth in bits per channel */
+    bool full_range;          /** video is full range or studio/limited range */
+    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 */
+    void *device;   /** device used for rendering, IDirect3DDevice9* for D3D9 */
 } libvlc_video_render_cfg_t;
 
 typedef struct
@@ -721,18 +727,6 @@ typedef void( *libvlc_video_direct3d_set_resize_cb )( void *opaque,
                                                       void (*report_size_change)(void *report_opaque, unsigned width, unsigned height),
                                                       void *report_opaque );
 
-typedef struct
-{
-    unsigned width;                        /** rendering video width in pixel */
-    unsigned height;                      /** rendering video height in pixel */
-    unsigned bitdepth;      /** rendering video bit depth in bits per channel */
-    bool full_range;          /** video is full range or studio/limited range */
-    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 */
-    void *device;   /** device used for rendering, IDirect3DDevice9* for D3D9 */
-} libvlc_video_direct3d_cfg_t;
-
 /** Update the rendering output setup.
  *
  * \param opaque private pointer set on the opaque parameter of @a libvlc_video_direct3d_device_setup_cb() [IN]
@@ -749,7 +743,7 @@ typedef struct
  * set in the output structure.
  */
 typedef bool( *libvlc_video_direct3d_update_output_cb )( void *opaque,
-                                                         const libvlc_video_direct3d_cfg_t *cfg,
+                                                         const libvlc_video_render_cfg_t *cfg,
                                                          libvlc_video_output_cfg_t *output );
 
 /** Tell the host the rendering for the given plane is about to start
diff --git a/modules/video_output/vgl.c b/modules/video_output/vgl.c
index 783cd016938..e8e8f353d17 100644
--- a/modules/video_output/vgl.c
+++ b/modules/video_output/vgl.c
@@ -83,7 +83,9 @@ static void Resize(vlc_gl_t * gl, unsigned w, unsigned h)
 
     MakeCurrent(gl);
     libvlc_video_render_cfg_t output_cfg = {
-        w, h,
+        w, h, 8, true,
+        libvlc_video_colorspace_BT709, libvlc_video_primaries_BT709,
+        libvlc_video_transfer_func_SRGB, NULL,
     };
     libvlc_video_output_cfg_t render_cfg;
     sys->resizeCb(sys->opaque, &output_cfg, &render_cfg);
diff --git a/modules/video_output/win32/d3d11_swapchain.c b/modules/video_output/win32/d3d11_swapchain.c
index 7115b559c2f..43f76be4065 100644
--- a/modules/video_output/win32/d3d11_swapchain.c
+++ b/modules/video_output/win32/d3d11_swapchain.c
@@ -141,7 +141,7 @@ static bool canHandleConversion(const dxgi_color_space *src, const dxgi_color_sp
 }
 #endif
 
-static void SelectSwapchainColorspace(struct d3d11_local_swapchain *display, const libvlc_video_direct3d_cfg_t *cfg)
+static void SelectSwapchainColorspace(struct d3d11_local_swapchain *display, const libvlc_video_render_cfg_t *cfg)
 {
     HRESULT hr;
     int best = 0;
@@ -314,7 +314,7 @@ static void CreateSwapchain(struct d3d11_local_swapchain *display, UINT width, U
 }
 #endif /* !VLC_WINSTORE_APP */
 
-static bool UpdateSwapchain( struct d3d11_local_swapchain *display, const libvlc_video_direct3d_cfg_t *cfg )
+static bool UpdateSwapchain( struct d3d11_local_swapchain *display, const libvlc_video_render_cfg_t *cfg )
 {
     ID3D11Texture2D* pBackBuffer;
     HRESULT hr;
@@ -470,7 +470,7 @@ void LocalSwapchainSwap( void *opaque )
     }
 }
 
-bool LocalSwapchainUpdateOutput( void *opaque, const libvlc_video_direct3d_cfg_t *cfg, libvlc_video_output_cfg_t *out )
+bool LocalSwapchainUpdateOutput( void *opaque, const libvlc_video_render_cfg_t *cfg, libvlc_video_output_cfg_t *out )
 {
     struct d3d11_local_swapchain *display = opaque;
     if ( !UpdateSwapchain( display, cfg ) )
diff --git a/modules/video_output/win32/d3d11_swapchain.h b/modules/video_output/win32/d3d11_swapchain.h
index b7cf0b6d290..6f1af2c5735 100644
--- a/modules/video_output/win32/d3d11_swapchain.h
+++ b/modules/video_output/win32/d3d11_swapchain.h
@@ -32,7 +32,7 @@ void *CreateLocalSwapchainHandle(vlc_object_t *, HWND, ID3D11DeviceContext *);
 
 void LocalSwapchainCleanupDevice( void *opaque );
 void LocalSwapchainSwap( void *opaque );
-bool LocalSwapchainUpdateOutput( void *opaque, const libvlc_video_direct3d_cfg_t *cfg, libvlc_video_output_cfg_t *out );
+bool LocalSwapchainUpdateOutput( void *opaque, const libvlc_video_render_cfg_t *cfg, libvlc_video_output_cfg_t *out );
 bool LocalSwapchainStartEndRendering( void *opaque, bool enter, const libvlc_video_frame_hdr10_metadata_t *p_hdr10 );
 bool LocalSwapchainSelectPlane( void *opaque, size_t plane );
 
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 258d906550a..8d2583fecb5 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -211,7 +211,7 @@ static int UpdateDisplayFormat(vout_display_t *vd, libvlc_video_output_cfg_t *ou
 static int QueryDisplayFormat(vout_display_t *vd, const video_format_t *fmt)
 {
     vout_display_sys_t *sys = vd->sys;
-    libvlc_video_direct3d_cfg_t cfg;
+    libvlc_video_render_cfg_t cfg;
 
     cfg.width  = sys->area.vdcfg.display.width;
     cfg.height = sys->area.vdcfg.display.height;
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 8af69f5a296..87e072688f2 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -472,7 +472,7 @@ static void Direct3D9DestroyResources(vout_display_t *vd)
 static int UpdateOutput(vout_display_t *vd, const video_format_t *fmt)
 {
     vout_display_sys_t *sys = vd->sys;
-    libvlc_video_direct3d_cfg_t cfg;
+    libvlc_video_render_cfg_t cfg;
     cfg.width  = sys->area.vdcfg.display.width;
     cfg.height = sys->area.vdcfg.display.height;
 
@@ -1505,7 +1505,7 @@ static int FindShadersCallback(const char *name, char ***values, char ***descs)
 
 VLC_CONFIG_STRING_ENUM(FindShadersCallback)
 
-static bool LocalSwapchainUpdateOutput( void *opaque, const libvlc_video_direct3d_cfg_t *cfg, libvlc_video_output_cfg_t *out )
+static bool LocalSwapchainUpdateOutput( void *opaque, const libvlc_video_render_cfg_t *cfg, libvlc_video_output_cfg_t *out )
 {
     vout_display_t *vd = opaque;
     out->surface_format = vd->sys->d3d9_device->d3ddev.BufferFormat;
-- 
2.17.1



More information about the vlc-devel mailing list