demux:mkv: fix wrong value reset after clean of an array
[vlc.git] / modules / video_chroma / d3d9_fmt.h
blob36231b27e5be44cf88a65df891f807aef52c8c6f
1 /*****************************************************************************
2 * d3d9_fmt.h : D3D9 helper calls
3 *****************************************************************************
4 * Copyright © 2017 VLC authors, VideoLAN and VideoLabs
6 * Authors: Steve Lhomme <robux4@gmail.com>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 #ifndef VLC_VIDEOCHROMA_D3D9_FMT_H_
24 #define VLC_VIDEOCHROMA_D3D9_FMT_H_
26 #include <vlc_picture.h>
28 #define COBJMACROS
29 #include <d3d9.h>
30 #include <dxva2api.h>
32 #include "dxgi_fmt.h"
34 /* owned by the vout for VLC_CODEC_D3D9_OPAQUE */
35 typedef struct
37 IDirect3DSurface9 *surface;
38 /* decoder only */
39 IDirectXVideoDecoder *decoder; /* keep a reference while the surface exist */
40 HINSTANCE dxva2_dll;
41 } picture_sys_t;
43 typedef struct
45 HINSTANCE hdll; /* handle of the opened d3d9 dll */
46 union {
47 IDirect3D9 *obj;
48 IDirect3D9Ex *objex;
50 bool use_ex;
51 } d3d9_handle_t;
53 typedef struct
55 /* d3d9_handle_t hd3d; TODO */
56 union
58 IDirect3DDevice9 *dev;
59 IDirect3DDevice9Ex *devex;
61 bool owner;
63 /* creation parameters */
64 D3DPRESENT_PARAMETERS pp;
65 UINT adapterId;
66 HWND hwnd;
67 D3DCAPS9 caps;
68 } d3d9_device_t;
70 #include "../codec/avcodec/va_surface.h"
72 static inline picture_sys_t *ActivePictureSys(picture_t *p_pic)
74 struct va_pic_context *pic_ctx = (struct va_pic_context*)p_pic->context;
75 return pic_ctx ? &pic_ctx->picsys : p_pic->p_sys;
78 static inline void AcquirePictureSys(picture_sys_t *p_sys)
80 IDirect3DSurface9_AddRef(p_sys->surface);
81 if (p_sys->decoder)
82 IDirectXVideoDecoder_AddRef(p_sys->decoder);
83 p_sys->dxva2_dll = LoadLibrary(TEXT("DXVA2.DLL"));
86 static inline void ReleasePictureSys(picture_sys_t *p_sys)
88 IDirect3DSurface9_Release(p_sys->surface);
89 if (p_sys->decoder)
90 IDirectXVideoDecoder_Release(p_sys->decoder);
91 FreeLibrary(p_sys->dxva2_dll);
94 HRESULT D3D9_CreateDevice(vlc_object_t *, d3d9_handle_t *, HWND,
95 const video_format_t *, d3d9_device_t *out);
96 #define D3D9_CreateDevice(a,b,c,d,e) D3D9_CreateDevice( VLC_OBJECT(a), b, c, d, e )
97 HRESULT D3D9_CreateDeviceExternal(IDirect3DDevice9 *, d3d9_handle_t *, HWND,
98 const video_format_t *, d3d9_device_t *out);
100 void D3D9_ReleaseDevice(d3d9_device_t *);
101 int D3D9_Create(vlc_object_t *, d3d9_handle_t *);
102 #define D3D9_Create(a,b) D3D9_Create( VLC_OBJECT(a), b )
103 int D3D9_CreateExternal(vlc_object_t *, d3d9_handle_t *, IDirect3DDevice9 *);
104 #define D3D9_CreateExternal(a,b,c) D3D9_CreateExternal( VLC_OBJECT(a), b, c )
106 void D3D9_Destroy(d3d9_handle_t *);
108 int D3D9_FillPresentationParameters(d3d9_handle_t *, const video_format_t *, d3d9_device_t *);
110 #endif /* VLC_VIDEOCHROMA_D3D9_FMT_H_ */