summaryrefslogtreecommitdiff
path: root/sys/d3d11/gstd3d11pluginutils.h
blob: ab4f6b48f08814ab19b9fe72b10f9ef9078d4941 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/* GStreamer
 * Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.com>
 * Copyright (C) 2020 Seungha Yang <seungha@centricular.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef __GST_D3D11_PLUGIN_UTILS_H__
#define __GST_D3D11_PLUGIN_UTILS_H__

#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/d3d11/gstd3d11.h>

G_BEGIN_DECLS

typedef struct _GstDxgiColorSpace GstDxgiColorSpace;

typedef enum
{
  GST_D3D11_DEVICE_VENDOR_UNKNOWN = 0,
  GST_D3D11_DEVICE_VENDOR_AMD,
  GST_D3D11_DEVICE_VENDOR_INTEL,
  GST_D3D11_DEVICE_VENDOR_NVIDIA,
  GST_D3D11_DEVICE_VENDOR_QUALCOMM,
  GST_D3D11_DEVICE_VENDOR_XBOX,
} GstD3D11DeviceVendor;

struct _GstDxgiColorSpace
{
  guint dxgi_color_space_type;
  GstVideoColorRange range;
  GstVideoColorMatrix matrix;
  GstVideoTransferFunction transfer;
  GstVideoColorPrimaries primaries;
};

#define GST_D3D11_CLEAR_COM(obj) G_STMT_START { \
    if (obj) { \
      (obj)->Release (); \
      (obj) = NULL; \
    } \
  } G_STMT_END

void            gst_d3d11_plugin_utils_init         (D3D_FEATURE_LEVEL feature_level);

GstCaps *       gst_d3d11_get_updated_template_caps (GstStaticCaps * template_caps);

gboolean        gst_d3d11_is_windows_8_or_greater   (void);

GstD3D11DeviceVendor gst_d3d11_get_device_vendor    (GstD3D11Device * device);

#if (GST_D3D11_DXGI_HEADER_VERSION >= 5)
gboolean        gst_d3d11_hdr_meta_data_to_dxgi     (GstVideoMasteringDisplayInfo * minfo,
                                                     GstVideoContentLightLevel * cll,
                                                     DXGI_HDR_METADATA_HDR10 * dxgi_hdr10);
#endif

#if (GST_D3D11_DXGI_HEADER_VERSION >= 4)
const GstDxgiColorSpace * gst_d3d11_video_info_to_dxgi_color_space (GstVideoInfo * info);

const GstDxgiColorSpace * gst_d3d11_find_swap_chain_color_space (GstVideoInfo * info,
                                                                 IDXGISwapChain3 * swapchain,
                                                                 gboolean use_hdr10);
#endif

GstBuffer *     gst_d3d11_allocate_staging_buffer   (GstD3D11Allocator * allocator,
                                                     const GstVideoInfo * info,
                                                     const GstD3D11Format * format,
                                                     const D3D11_TEXTURE2D_DESC desc[GST_VIDEO_MAX_PLANES],
                                                     gboolean add_videometa);

GstBuffer *     gst_d3d11_allocate_staging_buffer_for (GstBuffer * buffer,
                                                       const GstVideoInfo * info,
                                                       gboolean add_videometa);

gboolean        gst_d3d11_buffer_copy_into          (GstBuffer * dst,
                                                     GstBuffer * src,
                                                     const GstVideoInfo * info);

gboolean        gst_is_d3d11_buffer                 (GstBuffer * buffer);

gboolean        gst_d3d11_buffer_can_access_device  (GstBuffer * buffer,
                                                     ID3D11Device * device);

gboolean        gst_d3d11_buffer_map                (GstBuffer * buffer,
                                                     ID3D11Device * device,
                                                     GstMapInfo info[GST_VIDEO_MAX_PLANES],
                                                     GstMapFlags flags);

gboolean        gst_d3d11_buffer_unmap              (GstBuffer * buffer,
                                                     GstMapInfo info[GST_VIDEO_MAX_PLANES]);

guint           gst_d3d11_buffer_get_shader_resource_view (GstBuffer * buffer,
                                                           ID3D11ShaderResourceView * view[GST_VIDEO_MAX_PLANES]);

guint           gst_d3d11_buffer_get_render_target_view   (GstBuffer * buffer,
                                                           ID3D11RenderTargetView * view[GST_VIDEO_MAX_PLANES]);

GstBufferPool * gst_d3d11_buffer_pool_new_with_options  (GstD3D11Device * device,
                                                         GstCaps * caps,
                                                         GstD3D11AllocationParams * alloc_params,
                                                         guint min_buffers,
                                                         guint max_buffers);

G_END_DECLS

#endif /* __GST_D3D11_PLUGIN_UTILS_H__ */