mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
d3d11: Add color space conversion element using shader
Add d3d11colorconvert element for color space conversion. Currently {RGB, YUV} to RGB conversion is supported.
This commit is contained in:
parent
01903c47f7
commit
79ac41ec5b
5 changed files with 2026 additions and 2 deletions
|
@ -64,6 +64,10 @@ typedef struct _GstD3D11UploadClass GstD3D11UploadClass;
|
|||
typedef struct _GstD3D11Download GstD3D11Download;
|
||||
typedef struct _GstD3D11DownloadClass GstD3D11DownloadClass;
|
||||
|
||||
typedef struct _GstD3D11ColorConvert GstD3D11ColorConvert;
|
||||
typedef struct _GstD3D11ColorConvertClass GstD3D11ColorConvertClass;
|
||||
typedef struct _GstD3D11ColorConvertPrivate GstD3D11ColorConvertPrivate;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_D3D11_FWD_H__ */
|
||||
|
|
1940
sys/d3d11/gstd3d11colorconvert.c
Normal file
1940
sys/d3d11/gstd3d11colorconvert.c
Normal file
File diff suppressed because it is too large
Load diff
75
sys/d3d11/gstd3d11colorconvert.h
Normal file
75
sys/d3d11/gstd3d11colorconvert.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) <2019> Seungha Yang <seungha.yang@navercorp.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_COLOR_CONVERT_H__
|
||||
#define __GST_D3D11_COLOR_CONVERT_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "gstd3d11basefilter.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_D3D11_COLOR_CONVERT (gst_d3d11_color_convert_get_type())
|
||||
#define GST_D3D11_COLOR_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_D3D11_COLOR_CONVERT,GstD3D11ColorConvert))
|
||||
#define GST_D3D11_COLOR_CONVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_D3D11_COLOR_CONVERT,GstD3D11ColorConvertClass))
|
||||
#define GST_D3D11_COLOR_CONVERT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_D3D11_COLOR_CONVERT,GstD3D11ColorConvertClass))
|
||||
#define GST_IS_D3D11_COLOR_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_D3D11_COLOR_CONVERT))
|
||||
#define GST_IS_D3D11_COLOR_CONVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_D3D11_COLOR_CONVERT))
|
||||
|
||||
struct _GstD3D11ColorConvert
|
||||
{
|
||||
GstD3D11BaseFilter parent;
|
||||
|
||||
const GstD3D11Format *in_d3d11_format;
|
||||
const GstD3D11Format *out_d3d11_format;
|
||||
|
||||
ID3D11PixelShader * pixel_shader;
|
||||
ID3D11VertexShader * vertex_shader;
|
||||
ID3D11InputLayout * layout;
|
||||
ID3D11SamplerState * sampler;
|
||||
|
||||
ID3D11Buffer * const_buffer;
|
||||
ID3D11Buffer * vertex_buffer;
|
||||
ID3D11Buffer * index_buffer;
|
||||
guint index_count;
|
||||
|
||||
ID3D11Texture2D *in_texture[GST_VIDEO_MAX_PLANES];
|
||||
ID3D11ShaderResourceView *shader_resource_view[GST_VIDEO_MAX_PLANES];
|
||||
guint num_input_view;
|
||||
|
||||
ID3D11Texture2D *out_texture[GST_VIDEO_MAX_PLANES];
|
||||
ID3D11RenderTargetView *render_target_view[GST_VIDEO_MAX_PLANES];
|
||||
guint num_output_view;
|
||||
|
||||
D3D11_VIEWPORT viewport;
|
||||
|
||||
GstD3D11ColorConvertPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GstD3D11ColorConvertClass
|
||||
{
|
||||
GstD3D11BaseFilterClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_d3d11_color_convert_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_D3D11_COLOR_CONVERT_H__ */
|
|
@ -10,6 +10,7 @@ d3d11_sources = [
|
|||
'gstd3d11basefilter.c',
|
||||
'gstd3d11upload.c',
|
||||
'gstd3d11download.c',
|
||||
'gstd3d11colorconvert.c',
|
||||
]
|
||||
|
||||
have_d3d11 = false
|
||||
|
@ -23,8 +24,9 @@ endif
|
|||
|
||||
d3d11_lib = cc.find_library('d3d11', required : d3d11_option)
|
||||
dxgi_lib = cc.find_library('dxgi', required : d3d11_option)
|
||||
d3dcompiler_lib = cc.find_library('d3dcompiler', required: d3d11_option)
|
||||
|
||||
have_d3d11 = d3d11_lib.found() and dxgi_lib.found() and cc.has_header('d3d11.h') and cc.has_header('dxgi.h')
|
||||
have_d3d11 = d3d11_lib.found() and dxgi_lib.found() and cc.has_header('d3d11.h') and cc.has_header('dxgi.h') and cc.has_header('d3dcompiler.h')
|
||||
if not have_d3d11
|
||||
if d3d11_option.enabled()
|
||||
error('The d3d11 plugin was enabled explicitly, but required dependencies were not found.')
|
||||
|
@ -47,7 +49,7 @@ gstd3d11 = library('gstd3d11',
|
|||
d3d11_sources,
|
||||
c_args : gst_plugins_bad_args + extra_c_args,
|
||||
include_directories : [configinc],
|
||||
dependencies : [gstbase_dep, gstvideo_dep, d3d11_lib, dxgi_lib] + extra_dep,
|
||||
dependencies : [gstbase_dep, gstvideo_dep, d3d11_lib, dxgi_lib, d3dcompiler_lib] + extra_dep,
|
||||
install : true,
|
||||
install_dir : plugins_install_dir,
|
||||
)
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "gstd3d11videosink.h"
|
||||
#include "gstd3d11upload.h"
|
||||
#include "gstd3d11download.h"
|
||||
#include "gstd3d11colorconvert.h"
|
||||
|
||||
static gboolean
|
||||
plugin_init (GstPlugin * plugin)
|
||||
|
@ -36,6 +37,8 @@ plugin_init (GstPlugin * plugin)
|
|||
"d3d11upload", GST_RANK_NONE, GST_TYPE_D3D11_UPLOAD);
|
||||
gst_element_register (plugin,
|
||||
"d3d11download", GST_RANK_NONE, GST_TYPE_D3D11_DOWNLOAD);
|
||||
gst_element_register (plugin,
|
||||
"d3d11colorconvert", GST_RANK_NONE, GST_TYPE_D3D11_COLOR_CONVERT);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue