[vlc-devel] [PATCH 2/7] direct3d9: add a shared header to describe the VLC_CODEC_D3D9_OPAQUE chroma

Steve Lhomme robux4 at videolabs.io
Thu May 11 09:36:04 CEST 2017


---
 modules/codec/Makefile.am                      |  3 ++-
 modules/codec/avcodec/dxva2.c                  |  6 +----
 modules/video_chroma/Makefile.am               |  2 +-
 modules/video_chroma/d3d9_fmt.h                | 37 ++++++++++++++++++++++++++
 modules/video_chroma/dxa9.c                    |  6 +----
 modules/video_output/Makefile.am               |  6 +++--
 modules/video_output/win32/direct3d9.c         | 10 ++-----
 modules/video_output/win32/dxva2_deinterlace.c |  6 +----
 8 files changed, 49 insertions(+), 27 deletions(-)
 create mode 100644 modules/video_chroma/d3d9_fmt.h

diff --git a/modules/codec/Makefile.am b/modules/codec/Makefile.am
index 8b580324f6..4bfaa80106 100644
--- a/modules/codec/Makefile.am
+++ b/modules/codec/Makefile.am
@@ -398,7 +398,8 @@ endif
 libdxva2_plugin_la_SOURCES = \
 	codec/avcodec/dxva2.c codec/avcodec/directx_va.c codec/avcodec/directx_va.h \
 	packetizer/h264_nal.c packetizer/h264_nal.h \
-	packetizer/hevc_nal.c packetizer/hevc_nal.h
+	packetizer/hevc_nal.c packetizer/hevc_nal.h \
+	video_chroma/d3d9_fmt.h
 libdxva2_plugin_la_LIBADD = $(LIBCOM) -lshlwapi -luuid
 if HAVE_AVCODEC_DXVA2
 codec_LTLIBRARIES += libdxva2_plugin.la
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 7e2b07405e..fc2427c269 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -40,6 +40,7 @@
 #define DXVA2API_USE_BITFIELDS
 #define COBJMACROS
 #include <libavcodec/dxva2.h>
+#include "../../video_chroma/d3d9_fmt.h"
 
 static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,
                 const es_format_t *, picture_sys_t *p_sys);
@@ -136,11 +137,6 @@ struct vlc_va_sys_t
 #define VIDEO_DEVICE(x)  ((IDirectXVideoDecoderService*) (x)->d3ddec)
 #define D3D_DEVICE(x)    ((IDirect3DDevice9*)            (x)->d3ddev)
 
-struct picture_sys_t
-{
-    LPDIRECT3DSURFACE9 surface;
-};
-
 static picture_t *DxAllocPicture(vlc_va_t *, const video_format_t *, unsigned index);
 
 
diff --git a/modules/video_chroma/Makefile.am b/modules/video_chroma/Makefile.am
index b2e97d9667..cf11b3b81e 100644
--- a/modules/video_chroma/Makefile.am
+++ b/modules/video_chroma/Makefile.am
@@ -115,7 +115,7 @@ endif
 
 # DXVA2
 libdxa9_plugin_la_SOURCES = video_chroma/dxa9.c \
-	video_chroma/copy.c video_chroma/copy.h
+	video_chroma/d3d9_fmt.h video_chroma/copy.c video_chroma/copy.h
 
 if HAVE_AVCODEC_DXVA2
 chroma_LTLIBRARIES += \
diff --git a/modules/video_chroma/d3d9_fmt.h b/modules/video_chroma/d3d9_fmt.h
new file mode 100644
index 0000000000..4694acbf31
--- /dev/null
+++ b/modules/video_chroma/d3d9_fmt.h
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * d3d9_fmt.h : D3D9 helper calls
+ *****************************************************************************
+ * Copyright © 2017 VLC authors, VideoLAN and VideoLabs
+ *
+ * Authors: Steve Lhomme <robux4 at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef VLC_VIDEOCHROMA_D3D9_FMT_H_
+#define VLC_VIDEOCHROMA_D3D9_FMT_H_
+
+/* VLC_CODEC_D3D9_OPAQUE */
+struct picture_sys_t
+{
+    LPDIRECT3DSURFACE9 surface;
+};
+
+static inline void ReleasePictureSys(picture_sys_t *p_sys)
+{
+    IDirect3DSurface9_Release(p_sys->surface);
+}
+
+#endif /* VLC_VIDEOCHROMA_D3D9_FMT_H_ */
diff --git a/modules/video_chroma/dxa9.c b/modules/video_chroma/dxa9.c
index 6a415455c6..11eac913b1 100644
--- a/modules/video_chroma/dxa9.c
+++ b/modules/video_chroma/dxa9.c
@@ -50,11 +50,7 @@ vlc_module_end ()
 
 #include <windows.h>
 #include <d3d9.h>
-
-struct picture_sys_t
-{
-    LPDIRECT3DSURFACE9 surface;
-};
+#include "d3d9_fmt.h"
 
 static bool GetLock(filter_t *p_filter, LPDIRECT3DSURFACE9 d3d,
                     D3DLOCKED_RECT *p_lock, D3DSURFACE_DESC *p_desc)
diff --git a/modules/video_output/Makefile.am b/modules/video_output/Makefile.am
index c8206186f8..783c047932 100644
--- a/modules/video_output/Makefile.am
+++ b/modules/video_output/Makefile.am
@@ -209,12 +209,14 @@ libdirect3d9_plugin_la_SOURCES = video_output/win32/direct3d9.c \
 	video_output/win32/common.c video_output/win32/common.h \
 	video_output/win32/events.c video_output/win32/events.h \
 	video_output/win32/builtin_shaders.h \
-	video_output/win32/win32touch.c video_output/win32/win32touch.h
+	video_output/win32/win32touch.c video_output/win32/win32touch.h \
+	video_chroma/d3d9_fmt.h
 libdirect3d9_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) \
 	-DMODULE_NAME_IS_direct3d9
 libdirect3d9_plugin_la_LIBADD = -lgdi32 $(LIBCOM) -luuid
 libdirect3d9_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(voutdir)'
-libdxva2_deinterlace_plugin_la_SOURCES = video_output/win32/dxva2_deinterlace.c
+libdxva2_deinterlace_plugin_la_SOURCES = video_output/win32/dxva2_deinterlace.c \
+	video_chroma/d3d9_fmt.h
 libdxva2_deinterlace_plugin_la_LIBADD = $(LIBCOM)
 libdxva2_deinterlace_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(voutdir)'
 if HAVE_WIN32_DESKTOP
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 514564adcd..09a8537d19 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -48,6 +48,7 @@
 #include <windows.h>
 #include <d3d9.h>
 #include <d3dx9effect.h>
+#include "../../video_chroma/d3d9_fmt.h"
 
 #include "common.h"
 #include "builtin_shaders.h"
@@ -147,8 +148,6 @@ struct vout_display_sys_t
     struct d3d_region_t     *d3dregion;
     const d3d_format_t      *d3dtexture_format;  /* Rendering texture(s) format */
 
-    picture_sys_t           *picsys;
-
     /* */
     bool                    reset_device;
     bool                    reopen_device;
@@ -161,11 +160,6 @@ struct vout_display_sys_t
     bool           desktop_requested;
 };
 
-struct picture_sys_t
-{
-    LPDIRECT3DSURFACE9 surface;
-};
-
 static const d3d_format_t *Direct3DFindFormat(vout_display_t *vd, vlc_fourcc_t chroma, D3DFORMAT target);
 
 static int  Open(vlc_object_t *);
@@ -343,7 +337,7 @@ static void Close(vlc_object_t *object)
 
 static void DestroyPicture(picture_t *picture)
 {
-    IDirect3DSurface9_Release(picture->p_sys->surface);
+    ReleasePictureSys(picture->p_sys);
 
     free(picture->p_sys);
     free(picture);
diff --git a/modules/video_output/win32/dxva2_deinterlace.c b/modules/video_output/win32/dxva2_deinterlace.c
index dcfff72bd9..b01e46b282 100644
--- a/modules/video_output/win32/dxva2_deinterlace.c
+++ b/modules/video_output/win32/dxva2_deinterlace.c
@@ -36,11 +36,7 @@
 #include <initguid.h>
 #include <d3d9.h>
 #include <dxva2api.h>
-
-struct picture_sys_t
-{
-    LPDIRECT3DSURFACE9 surface;
-};
+#include "../../video_chroma/d3d9_fmt.h"
 
 struct filter_sys_t
 {
-- 
2.12.1



More information about the vlc-devel mailing list