[vlc-commits] [Git][videolan/vlc][master] 7 commits: contrib: mingw64: patch dxvahd.h before mingw-w64 11

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Mar 21 16:36:29 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
96a19e94 by Steve Lhomme at 2023-03-21T15:35:57+00:00
contrib: mingw64: patch dxvahd.h before mingw-w64 11

The releases before 11 had bogus dxvahd
DXVAHD_STREAM_STATE_xxx_COLOR_SPACE_DATA structures. This was confusing the
initialization with LLVM.

- - - - -
a7de762a by Steve Lhomme at 2023-03-21T15:35:57+00:00
d3d9: fully initialize DXVAHD_BLT_STATE_OUTPUT_COLOR_SPACE_DATA

Although we set all known usable bits, it seems that leaving reserved bits
"uninitialized" doesn't work in some case. In particular with LLVM builds,
which results in bogus output.

Co-authored-by: Pierre Lamot <pierre at videolabs.io>

- - - - -
367b7e8e by Steve Lhomme at 2023-03-21T15:35:57+00:00
d3d9: fully initialize DXVAHD_BLT_STATE_INPUT_COLOR_SPACE_DATA

Although we set all known usable bits, it seems that leaving reserved bits
"uninitialized" doesn't work in some case. In particular with LLVM builds,
which results in bogus output.

- - - - -
b86fbe2e by Steve Lhomme at 2023-03-21T15:35:57+00:00
d3d9: explicitly set the processing input type

We do the processing on video files, not "graphics" generated sources.

- - - - -
dd8297d2 by Steve Lhomme at 2023-03-21T15:35:57+00:00
d3d9: use the official typedef for DXVAHD_CreateDevice()

It doesn't exist in mingw so we define it in that case.

- - - - -
2e335eba by Steve Lhomme at 2023-03-21T15:35:57+00:00
interop_dxva2: add comments about the processor output values

The same code in direct3d9 uses an output format that can vary.

- - - - -
3e838637 by Steve Lhomme at 2023-03-21T15:35:57+00:00
interop_dxva2: use container_of instead of object cast

- - - - -


5 changed files:

- + contrib/src/mingw64/0001-headers-Update-to-Wine-master-and-regenerate-H-from-.patch
- + contrib/src/mingw64/0002-headers-dxvahd-Regenerate-H-from-IDL.patch
- contrib/src/mingw64/rules.mak
- modules/video_output/opengl/interop_dxva2.c
- modules/video_output/win32/direct3d9.c


Changes:

=====================================
contrib/src/mingw64/0001-headers-Update-to-Wine-master-and-regenerate-H-from-.patch
=====================================
@@ -0,0 +1,62 @@
+From d4249c712991ab191f05968470b34587cc716a53 Mon Sep 17 00:00:00 2001
+From: LIU Hao <lh_mouse at 126.com>
+Date: Sat, 18 Mar 2023 14:59:38 +0800
+Subject: [PATCH 1/2] headers: Update to Wine master and regenerate H from IDL
+ (edited)
+
+Signed-off-by: LIU Hao <lh_mouse at 126.com>
+
+edited:
+* only kept the dxvahd.h changes
+---
+ mingw-w64-headers/include/dxvahd.h | 27 +++++++++++++++++++--------
+ 1 file changed, 19 insertions(+), 8 deletions(-)
+
+diff --git a/mingw-w64-headers/include/dxvahd.h b/mingw-w64-headers/include/dxvahd.h
+index 71b027863..aaff9400c 100644
+--- a/mingw-w64-headers/include/dxvahd.h
++++ b/mingw-w64-headers/include/dxvahd.h
+@@ -251,10 +251,16 @@ typedef struct _DXVAHD_BLT_STATE_CONSTRICTION_DATA {
+     SIZE Size;
+ } DXVAHD_BLT_STATE_CONSTRICTION_DATA;
+ typedef struct _DXVAHD_BLT_STATE_OUTPUT_COLOR_SPACE_DATA {
+-    UINT Usage : 1;
+-    UINT RGB_Range : 1;
+-    UINT YCbCr_Matrix : 1;
+-    UINT YCbCr_xvYCC : 1;
++    __C89_NAMELESS union {
++        __C89_NAMELESS struct {
++            UINT Usage : 1;
++            UINT RGB_Range : 1;
++            UINT YCbCr_Matrix : 1;
++            UINT YCbCr_xvYCC : 1;
++            UINT Reserved : 28;
++        } __C89_NAMELESSSTRUCTNAME;
++        UINT Value;
++    } __C89_NAMELESSUNIONNAME;
+ } DXVAHD_BLT_STATE_OUTPUT_COLOR_SPACE_DATA;
+ typedef struct _DXVAHD_BLT_STATE_PRIVATE_DATA {
+     GUID Guid;
+@@ -332,10 +338,15 @@ typedef struct _DXVAHD_STREAM_STATE_FRAME_FORMAT_DATA {
+     DXVAHD_FRAME_FORMAT FrameFormat;
+ } DXVAHD_STREAM_STATE_FRAME_FORMAT_DATA;
+ typedef struct _DXVAHD_STREAM_STATE_INPUT_COLOR_SPACE_DATA {
+-    UINT Type : 1;
+-    UINT RGB_Range : 1;
+-    UINT YCbCr_Matrix : 1;
+-    UINT YCbCr_xvYCC : 1;
++    __C89_NAMELESS union {
++        __C89_NAMELESS struct {
++            UINT Type : 1;
++            UINT RGB_Range : 1;
++            UINT YCbCr_Matrix : 1;
++            UINT YCbCr_xvYCC : 1;
++        } __C89_NAMELESSSTRUCTNAME;
++        UINT Value;
++    } __C89_NAMELESSUNIONNAME;
+ } DXVAHD_STREAM_STATE_INPUT_COLOR_SPACE_DATA;
+ typedef struct _DXVAHD_STREAM_STATE_LUMA_KEY_DATA {
+     WINBOOL Enable;
+-- 
+2.37.3.windows.1
+


=====================================
contrib/src/mingw64/0002-headers-dxvahd-Regenerate-H-from-IDL.patch
=====================================
@@ -0,0 +1,25 @@
+From d12847294d570acc97790c7a02fb44a73850f347 Mon Sep 17 00:00:00 2001
+From: LIU Hao <lh_mouse at 126.com>
+Date: Sat, 18 Mar 2023 17:19:02 +0800
+Subject: [PATCH 2/2] headers/dxvahd: Regenerate H from IDL
+
+Signed-off-by: LIU Hao <lh_mouse at 126.com>
+---
+ mingw-w64-headers/include/dxvahd.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/mingw-w64-headers/include/dxvahd.h b/mingw-w64-headers/include/dxvahd.h
+index aaff9400c..6bcd753dd 100644
+--- a/mingw-w64-headers/include/dxvahd.h
++++ b/mingw-w64-headers/include/dxvahd.h
+@@ -344,6 +344,7 @@ typedef struct _DXVAHD_STREAM_STATE_INPUT_COLOR_SPACE_DATA {
+             UINT RGB_Range : 1;
+             UINT YCbCr_Matrix : 1;
+             UINT YCbCr_xvYCC : 1;
++            UINT Reserved : 28;
+         } __C89_NAMELESSSTRUCTNAME;
+         UINT Value;
+     } __C89_NAMELESSUNIONNAME;
+-- 
+2.37.3.windows.1
+


=====================================
contrib/src/mingw64/rules.mak
=====================================
@@ -17,7 +17,7 @@ endif # !HAVE_WINSTORE
 PKGS += dxva dxvahd
 
 ifeq ($(call mingw_at_least, 8), true)
-PKGS_FOUND += d3d9 dxvahd
+PKGS_FOUND += d3d9
 endif # MINGW 8
 ifeq ($(call mingw_at_least, 9), true)
 ifdef HAVE_WINSTORE
@@ -30,6 +30,9 @@ endif # MINGW 10
 ifeq ($(call mingw_at_least, 10), true)
 PKGS_FOUND += dcomp
 endif
+ifeq ($(call mingw_at_least, 11), true)
+PKGS_FOUND += dxvahd
+endif # MINGW 11
 endif # !HAVE_VISUALSTUDIO
 
 HAVE_WINPTHREAD := $(shell $(CC) $(CFLAGS) -E -dM -include pthread.h - < /dev/null >/dev/null 2>&1 || echo FAIL)
@@ -53,6 +56,8 @@ $(TARBALLS)/mingw-w64-v$(MINGW64_VERSION).tar.bz2:
 mingw64: mingw-w64-v$(MINGW64_VERSION).tar.bz2 .sum-mingw64
 # mingw64: mingw-w64-$(MINGW64_HASH).tar.xz .sum-mingw64
 	$(UNPACK)
+	$(APPLY) $(SRC)/mingw64/0001-headers-Update-to-Wine-master-and-regenerate-H-from-.patch
+	$(APPLY) $(SRC)/mingw64/0002-headers-dxvahd-Regenerate-H-from-IDL.patch
 	$(MOVE)
 
 .mingw64: mingw64


=====================================
modules/video_output/opengl/interop_dxva2.c
=====================================
@@ -192,7 +192,7 @@ GLConvAllocateTextures(const struct vlc_gl_interop *interop, uint32_t textures[]
 static void
 GLConvClose(vlc_object_t *obj)
 {
-    struct vlc_gl_interop *interop = (void *)obj;
+    struct vlc_gl_interop *interop = container_of(obj, struct vlc_gl_interop, obj);
     struct glpriv *priv = interop->priv;
 
     if (priv->gl_handle_d3d)
@@ -226,10 +226,12 @@ static void SetupProcessorInput(struct vlc_gl_interop *interop, const video_form
     DXVAHD_STREAM_STATE_FRAME_FORMAT_DATA frame_format = { DXVAHD_FRAME_FORMAT_PROGRESSIVE };
     IDXVAHD_VideoProcessor_SetVideoProcessStreamState( sys->processor.proc, 0, DXVAHD_STREAM_STATE_FRAME_FORMAT, sizeof(frame_format), &frame_format );
 
-    DXVAHD_STREAM_STATE_INPUT_COLOR_SPACE_DATA colorspace = { 0 };
-    colorspace.RGB_Range = fmt->color_range == COLOR_RANGE_FULL ? 0 : 1;
-    colorspace.YCbCr_xvYCC = fmt->color_range == COLOR_RANGE_FULL ? 1 : 0;
-    colorspace.YCbCr_Matrix = fmt->space == COLOR_SPACE_BT601 ? 0 : 1;
+    DXVAHD_STREAM_STATE_INPUT_COLOR_SPACE_DATA colorspace = {
+        .Type = 0, // video, not graphics
+        .RGB_Range = fmt->color_range == COLOR_RANGE_FULL ? 0 : 1,
+        .YCbCr_xvYCC = fmt->color_range == COLOR_RANGE_FULL ? 1 : 0,
+        .YCbCr_Matrix = fmt->space == COLOR_SPACE_BT601 ? 0 : 1,
+    };
     IDXVAHD_VideoProcessor_SetVideoProcessStreamState( sys->processor.proc, 0, DXVAHD_STREAM_STATE_INPUT_COLOR_SPACE, sizeof(colorspace), &colorspace );
 
     DXVAHD_STREAM_STATE_SOURCE_RECT_DATA srcRect;
@@ -284,8 +286,11 @@ static int InitRangeProcessor(struct vlc_gl_interop *interop, IDirect3DDevice9Ex
     DXVAHD_VPCAPS *capsList = NULL;
     IDXVAHD_Device *hd_device = NULL;
 
-    HRESULT (WINAPI *CreateDevice)(IDirect3DDevice9Ex *,const DXVAHD_CONTENT_DESC *,DXVAHD_DEVICE_USAGE,PDXVAHDSW_Plugin,IDXVAHD_Device **);
-    CreateDevice = (void *)GetProcAddress(sys->processor.dll, "DXVAHD_CreateDevice");
+#ifdef __MINGW64_VERSION_MAJOR
+    typedef HRESULT (WINAPI* PDXVAHD_CreateDevice)(IDirect3DDevice9Ex *,const DXVAHD_CONTENT_DESC *,DXVAHD_DEVICE_USAGE,PDXVAHDSW_Plugin,IDXVAHD_Device **);
+#endif
+    PDXVAHD_CreateDevice CreateDevice;
+    CreateDevice = (PDXVAHD_CreateDevice)GetProcAddress(sys->processor.dll, "DXVAHD_CreateDevice");
     if (CreateDevice == NULL)
     {
         msg_Err(interop, "Can't create HD device (not Windows 7+)");
@@ -387,11 +392,12 @@ static int InitRangeProcessor(struct vlc_gl_interop *interop, IDirect3DDevice9Ex
 
     SetupProcessorInput(interop, &interop->fmt_in, src_format);
 
-    DXVAHD_BLT_STATE_OUTPUT_COLOR_SPACE_DATA colorspace;
-    colorspace.Usage = 0; // playback
-    colorspace.RGB_Range = true ? 0 : 1;
-    colorspace.YCbCr_xvYCC = true ? 1 : 0;
-    colorspace.YCbCr_Matrix = false ? 0 : 1;
+    DXVAHD_BLT_STATE_OUTPUT_COLOR_SPACE_DATA colorspace = {
+        .Usage = 0, // playback
+        .RGB_Range = /* full range */true ? 0 : 1,
+        .YCbCr_xvYCC = /* full range */true ? 1 : 0,
+        .YCbCr_Matrix = /* BT601 colorspace */ false ? 0 : 1,
+    };
     hr = IDXVAHD_VideoProcessor_SetVideoProcessBltState( sys->processor.proc, DXVAHD_BLT_STATE_OUTPUT_COLOR_SPACE, sizeof(colorspace), &colorspace);
 
     return VLC_SUCCESS;
@@ -408,7 +414,7 @@ error:
 static int
 GLConvOpen(vlc_object_t *obj)
 {
-    struct vlc_gl_interop *interop = (void *) obj;
+    struct vlc_gl_interop *interop = container_of(obj, struct vlc_gl_interop, obj);
 
     if (interop->fmt_in.i_chroma != VLC_CODEC_D3D9_OPAQUE
      && interop->fmt_in.i_chroma != VLC_CODEC_D3D9_OPAQUE_10B)


=====================================
modules/video_output/win32/direct3d9.c
=====================================
@@ -1420,10 +1420,12 @@ static void SetupProcessorInput(vout_display_t *vd, const video_format_t *fmt, c
     DXVAHD_STREAM_STATE_FRAME_FORMAT_DATA frame_format = { DXVAHD_FRAME_FORMAT_PROGRESSIVE };
     IDXVAHD_VideoProcessor_SetVideoProcessStreamState( sys->processor.proc, 0, DXVAHD_STREAM_STATE_FRAME_FORMAT, sizeof(frame_format), &frame_format );
 
-    DXVAHD_STREAM_STATE_INPUT_COLOR_SPACE_DATA colorspace = { 0 };
-    colorspace.RGB_Range = fmt->color_range == COLOR_RANGE_FULL ? 0 : 1;
-    colorspace.YCbCr_xvYCC = fmt->color_range == COLOR_RANGE_FULL ? 1 : 0;
-    colorspace.YCbCr_Matrix = fmt->space == COLOR_SPACE_BT601 ? 0 : 1;
+    DXVAHD_STREAM_STATE_INPUT_COLOR_SPACE_DATA colorspace = {
+        .Type = 0, // video, not graphics
+        .RGB_Range = fmt->color_range == COLOR_RANGE_FULL ? 0 : 1,
+        .YCbCr_xvYCC = fmt->color_range == COLOR_RANGE_FULL ? 1 : 0,
+        .YCbCr_Matrix = fmt->space == COLOR_SPACE_BT601 ? 0 : 1,
+    };
     IDXVAHD_VideoProcessor_SetVideoProcessStreamState( sys->processor.proc, 0, DXVAHD_STREAM_STATE_INPUT_COLOR_SPACE, sizeof(colorspace), &colorspace );
 
     DXVAHD_STREAM_STATE_SOURCE_RECT_DATA srcRect;
@@ -1479,8 +1481,11 @@ static int InitRangeProcessor(vout_display_t *vd, const d3d9_format_t *d3dfmt,
     DXVAHD_VPCAPS *capsList = NULL;
     IDXVAHD_Device *hd_device = NULL;
 
-    HRESULT (WINAPI *CreateDevice)(IDirect3DDevice9Ex *,const DXVAHD_CONTENT_DESC *,DXVAHD_DEVICE_USAGE,PDXVAHDSW_Plugin,IDXVAHD_Device **);
-    CreateDevice = (void *)GetProcAddress(sys->processor.dll, "DXVAHD_CreateDevice");
+#ifdef __MINGW64_VERSION_MAJOR
+    typedef HRESULT (WINAPI* PDXVAHD_CreateDevice)(IDirect3DDevice9Ex *,const DXVAHD_CONTENT_DESC *,DXVAHD_DEVICE_USAGE,PDXVAHDSW_Plugin,IDXVAHD_Device **);
+#endif
+    PDXVAHD_CreateDevice CreateDevice;
+    CreateDevice = (PDXVAHD_CreateDevice)GetProcAddress(sys->processor.dll, "DXVAHD_CreateDevice");
     if (CreateDevice == NULL)
     {
         msg_Err(vd, "Can't create HD device (not Windows 7+)");
@@ -1582,11 +1587,12 @@ static int InitRangeProcessor(vout_display_t *vd, const d3d9_format_t *d3dfmt,
 
     SetupProcessorInput(vd, vd->source, d3dfmt);
 
-    DXVAHD_BLT_STATE_OUTPUT_COLOR_SPACE_DATA colorspace;
-    colorspace.Usage = 0; // playback
-    colorspace.RGB_Range = render_out->full_range ? 0 : 1;
-    colorspace.YCbCr_xvYCC = render_out->full_range ? 1 : 0;
-    colorspace.YCbCr_Matrix = render_out->colorspace == libvlc_video_colorspace_BT601 ? 0 : 1;
+    DXVAHD_BLT_STATE_OUTPUT_COLOR_SPACE_DATA colorspace = {
+        .Usage = 0, // playback
+        .RGB_Range = render_out->full_range ? 0 : 1,
+        .YCbCr_xvYCC = render_out->full_range ? 1 : 0,
+        .YCbCr_Matrix = render_out->colorspace == libvlc_video_colorspace_BT601 ? 0 : 1,
+    };
     hr = IDXVAHD_VideoProcessor_SetVideoProcessBltState( sys->processor.proc, DXVAHD_BLT_STATE_OUTPUT_COLOR_SPACE, sizeof(colorspace), &colorspace);
 
     return VLC_SUCCESS;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f9b271e02b56aec3c0d4c9fb691f06bad6d47e21...3e838637aef8b4254f03d2a203bf9767c1de673a

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f9b271e02b56aec3c0d4c9fb691f06bad6d47e21...3e838637aef8b4254f03d2a203bf9767c1de673a
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list