[vlc-devel] [PATCH 23/23] libvlc: use a different name for each variant of the host surface format

Steve Lhomme robux4 at ycbcr.xyz
Thu Feb 6 08:21:06 CET 2020


Now that we use a union we can differentiate each properly.

In particular the D3D9 is an unsigned FourCC.

It's still not as strongly typed as it could be (no DXGI_FORMAT for example).
---
 doc/libvlc/QtGL/qtvlcwidget.cpp              | 2 +-
 doc/libvlc/d3d11_player.cpp                  | 2 +-
 doc/libvlc/d3d9_player.c                     | 2 +-
 doc/libvlc/sdl_opengl_player.cpp             | 2 +-
 include/vlc/libvlc_media_player.h            | 6 +++---
 modules/video_output/vgl.c                   | 2 +-
 modules/video_output/win32/d3d11_swapchain.c | 2 +-
 modules/video_output/win32/direct3d11.c      | 2 +-
 modules/video_output/win32/direct3d9.c       | 2 +-
 9 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/doc/libvlc/QtGL/qtvlcwidget.cpp b/doc/libvlc/QtGL/qtvlcwidget.cpp
index bf621167910..59eca34fe89 100644
--- a/doc/libvlc/QtGL/qtvlcwidget.cpp
+++ b/doc/libvlc/QtGL/qtvlcwidget.cpp
@@ -54,7 +54,7 @@ public:
 
         that->mBuffers[that->m_idx_render]->bind();
 
-        render_cfg->surface_format = GL_RGBA;
+        render_cfg->opengl_format = GL_RGBA;
         render_cfg->full_range = true;
         render_cfg->colorspace = libvlc_video_colorspace_BT709;
         render_cfg->primaries  = libvlc_video_primaries_BT709;
diff --git a/doc/libvlc/d3d11_player.cpp b/doc/libvlc/d3d11_player.cpp
index 19244408dd7..97e1dbd97a3 100644
--- a/doc/libvlc/d3d11_player.cpp
+++ b/doc/libvlc/d3d11_player.cpp
@@ -402,7 +402,7 @@ static bool UpdateOutput_cb( void *opaque, const libvlc_video_render_cfg_t *cfg,
 
     ctx->d3dctxVLC->OMSetRenderTargets( 1, &ctx->resized.textureRenderTarget, NULL );
 
-    out->surface_format = renderFormat;
+    out->dxgi_format    = renderFormat;
     out->full_range     = true;
     out->colorspace     = libvlc_video_colorspace_BT709;
     out->primaries      = libvlc_video_primaries_BT709;
diff --git a/doc/libvlc/d3d9_player.c b/doc/libvlc/d3d9_player.c
index 6ce33181301..4b925df52aa 100644
--- a/doc/libvlc/d3d9_player.c
+++ b/doc/libvlc/d3d9_player.c
@@ -134,7 +134,7 @@ static bool Resize(struct render_context *ctx, unsigned width, unsigned height,
     hr = IDirect3DDevice9_SetRenderTarget(ctx->libvlc_d3d, 0, ctx->sharedRenderSurface);
     if (FAILED(hr)) return false;
 
-    out->surface_format = d3ddm.Format;
+    out->d3d9_format    = d3ddm.Format;
     out->full_range     = true;
     out->colorspace     = libvlc_video_colorspace_BT709;
     out->primaries      = libvlc_video_primaries_BT709;
diff --git a/doc/libvlc/sdl_opengl_player.cpp b/doc/libvlc/sdl_opengl_player.cpp
index ba6b4be872e..bb1c0a303d2 100644
--- a/doc/libvlc/sdl_opengl_player.cpp
+++ b/doc/libvlc/sdl_opengl_player.cpp
@@ -150,7 +150,7 @@ public:
 
         glBindFramebuffer(GL_FRAMEBUFFER, that->m_fbo[that->m_idx_render]);
 
-        render_cfg->surface_format = GL_RGBA;
+        render_cfg->opengl_format = GL_RGBA;
         render_cfg->full_range = true;
         render_cfg->colorspace = libvlc_video_colorspace_BT709;
         render_cfg->primaries  = libvlc_video_primaries_BT709;
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index a0ac7a1e9fa..fa5147a2ae3 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -565,9 +565,9 @@ typedef struct
 typedef struct
 {
     union {
-        int surface_format;  /** the rendering DXGI_FORMAT for \ref libvlc_video_direct3d_engine_d3d11,
-                            D3DFORMAT for \ref libvlc_video_direct3d_engine_d3d9,
-                            GL_RGBA or GL_RGB for \ref libvlc_video_engine_opengl and
+        int dxgi_format;  /** the rendering DXGI_FORMAT for \ref libvlc_video_direct3d_engine_d3d11*/
+        uint32_t d3d9_format;  /** the rendering D3DFORMAT for \ref libvlc_video_direct3d_engine_d3d9 */
+        int opengl_format;  /** the rendering GLint GL_RGBA or GL_RGB for \ref libvlc_video_engine_opengl and
                             for \ref libvlc_video_engine_gles2 */
         void *p_surface; /** currently unused */
     };
diff --git a/modules/video_output/vgl.c b/modules/video_output/vgl.c
index 5f03498e689..7602ef309e1 100644
--- a/modules/video_output/vgl.c
+++ b/modules/video_output/vgl.c
@@ -90,7 +90,7 @@ static void Resize(vlc_gl_t * gl, unsigned w, unsigned h)
     libvlc_video_output_cfg_t render_cfg;
     sys->resizeCb(sys->opaque, &output_cfg, &render_cfg);
     ReleaseCurrent(gl);
-    assert(render_cfg.surface_format == GL_RGBA);
+    assert(render_cfg.opengl_format == GL_RGBA);
     assert(render_cfg.full_range == true);
     assert(render_cfg.colorspace == libvlc_video_colorspace_BT709);
     assert(render_cfg.primaries  == libvlc_video_primaries_BT709);
diff --git a/modules/video_output/win32/d3d11_swapchain.c b/modules/video_output/win32/d3d11_swapchain.c
index a810b4ab64d..06a43b7e937 100644
--- a/modules/video_output/win32/d3d11_swapchain.c
+++ b/modules/video_output/win32/d3d11_swapchain.c
@@ -475,7 +475,7 @@ bool LocalSwapchainUpdateOutput( void *opaque, const libvlc_video_render_cfg_t *
     struct d3d11_local_swapchain *display = opaque;
     if ( !UpdateSwapchain( display, cfg ) )
         return false;
-    out->surface_format = display->pixelFormat->formatTexture;
+    out->dxgi_format    = display->pixelFormat->formatTexture;
     out->full_range     = display->colorspace->b_full_range;
     out->colorspace     = (libvlc_video_color_space_t)     display->colorspace->color;
     out->primaries      = (libvlc_video_color_primaries_t) display->colorspace->primaries;
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 996542021c5..8f615765c3f 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -157,7 +157,7 @@ static int UpdateDisplayFormat(vout_display_t *vd, libvlc_video_output_cfg_t *ou
     for (const d3d_format_t *output_format = GetRenderFormatList();
          output_format->name != NULL; ++output_format)
     {
-        if (output_format->formatTexture == (DXGI_FORMAT)out->surface_format &&
+        if (output_format->formatTexture == (DXGI_FORMAT)out->dxgi_format &&
             !is_d3d11_opaque(output_format->fourcc))
         {
             new_display.pixelFormat = output_format;
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index ed047ef30d6..60be882aa5c 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -1508,7 +1508,7 @@ VLC_CONFIG_STRING_ENUM(FindShadersCallback)
 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;
+    out->d3d9_format = vd->sys->d3d9_device->d3ddev.BufferFormat;
     return true;
 }
 
-- 
2.17.1



More information about the vlc-devel mailing list