mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
d3d11converter: Add support conversion using videoprocessor
* Add videoprocessor feature to d3d11converter, in order to unifiy conversion flow. * Add convert_buffer() method to support automatic shader/videoprocessor selection. The method also supports texture upload if input memory cannot be used for conversion (e.g., system memory or so) Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2697>
This commit is contained in:
parent
fdbb9041a2
commit
91a732fe90
7 changed files with 1146 additions and 104 deletions
|
@ -878,8 +878,10 @@ gst_d3d11_compositor_pad_setup_converter (GstVideoAggregatorPad * pad,
|
|||
if (!cpad->convert) {
|
||||
GstD3D11Format in_format, out_format;
|
||||
GstDxgiColorSpace in_space, out_space;
|
||||
GstD3D11ConverterMethod method = GST_D3D11_CONVERTER_METHOD_SHADER;
|
||||
|
||||
cpad->convert = gst_d3d11_converter_new (self->device, &pad->info, info);
|
||||
cpad->convert = gst_d3d11_converter_new (self->device, &pad->info, info,
|
||||
&method);
|
||||
if (!cpad->convert) {
|
||||
GST_ERROR_OBJECT (pad, "Couldn't create converter");
|
||||
return FALSE;
|
||||
|
|
|
@ -1718,6 +1718,7 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter,
|
|||
gint from_dar_n, from_dar_d, to_dar_n, to_dar_d;
|
||||
gint border_offset_x = 0;
|
||||
gint border_offset_y = 0;
|
||||
GstD3D11ConverterMethod method = GST_D3D11_CONVERTER_METHOD_SHADER;
|
||||
|
||||
if (gst_caps_is_equal (incaps, outcaps)) {
|
||||
self->same_caps = TRUE;
|
||||
|
@ -1796,7 +1797,8 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter,
|
|||
goto format_unknown;
|
||||
}
|
||||
|
||||
self->converter = gst_d3d11_converter_new (filter->device, in_info, out_info);
|
||||
self->converter = gst_d3d11_converter_new (filter->device, in_info, out_info,
|
||||
&method);
|
||||
if (!self->converter) {
|
||||
GST_ERROR_OBJECT (self, "couldn't set converter");
|
||||
return FALSE;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -38,6 +38,12 @@ typedef struct _GstD3D11Converter GstD3D11Converter;
|
|||
typedef struct _GstD3D11ConverterClass GstD3D11ConverterClass;
|
||||
typedef struct _GstD3D11ConverterPrivate GstD3D11ConverterPrivate;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GST_D3D11_CONVERTER_METHOD_SHADER = (1 << 0),
|
||||
GST_D3D11_CONVERTER_METHOD_VIDEO_PROCESSOR = (1 << 1),
|
||||
} GstD3D11ConverterMethod;
|
||||
|
||||
struct _GstD3D11Converter
|
||||
{
|
||||
GstObject parent;
|
||||
|
@ -61,7 +67,8 @@ GType gst_d3d11_converter_get_type (void);
|
|||
|
||||
GstD3D11Converter * gst_d3d11_converter_new (GstD3D11Device * device,
|
||||
const GstVideoInfo * in_info,
|
||||
const GstVideoInfo * out_info);
|
||||
const GstVideoInfo * out_info,
|
||||
GstD3D11ConverterMethod * method);
|
||||
|
||||
gboolean gst_d3d11_converter_convert (GstD3D11Converter * converter,
|
||||
ID3D11ShaderResourceView *srv[GST_VIDEO_MAX_PLANES],
|
||||
|
@ -71,6 +78,16 @@ gboolean gst_d3d11_converter_convert_unlocked (GstD3D11Converter * co
|
|||
ID3D11ShaderResourceView *srv[GST_VIDEO_MAX_PLANES],
|
||||
ID3D11RenderTargetView *rtv[GST_VIDEO_MAX_PLANES]);
|
||||
|
||||
gboolean gst_d3d11_converter_convert_buffer (GstD3D11Converter * converter,
|
||||
GstBuffer * in_buf,
|
||||
GstBuffer * out_buf);
|
||||
|
||||
gboolean gst_d3d11_converter_convert_buffer_unlocked (GstD3D11Converter * converter,
|
||||
GstBuffer * in_buf,
|
||||
GstBuffer * out_buf);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS (GstD3D11ConverterMethod);
|
||||
|
||||
#endif /* __GST_D3D11_COLOR_CONVERTER_H__ */
|
||||
|
|
|
@ -1293,11 +1293,12 @@ gst_d3d11_test_src_setup_resource (GstD3D11TestSrc * self, GstCaps * caps)
|
|||
GstCaps *draw_caps;
|
||||
GstD3D11AllocationParams *params;
|
||||
GstD3D11TestSrcRender *render;
|
||||
GstD3D11ConverterMethod method = GST_D3D11_CONVERTER_METHOD_SHADER;
|
||||
|
||||
gst_video_info_set_format (&draw_info, GST_VIDEO_FORMAT_RGBA,
|
||||
self->info.width, self->info.height);
|
||||
self->converter = gst_d3d11_converter_new (self->device,
|
||||
&draw_info, &self->info);
|
||||
&draw_info, &self->info, &method);
|
||||
|
||||
if (!self->converter) {
|
||||
GST_ERROR_OBJECT (self, "Failed to create converter");
|
||||
|
|
|
@ -457,6 +457,7 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
|
|||
DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;
|
||||
DXGI_HDR_METADATA_HDR10 hdr10_metadata = { 0, };
|
||||
GstDxgiColorSpace in_dxgi_colorspace;
|
||||
GstD3D11ConverterMethod method = GST_D3D11_CONVERTER_METHOD_SHADER;
|
||||
|
||||
/* Step 1: Clear old resources and objects */
|
||||
gst_clear_buffer (&window->cached_buffer);
|
||||
|
@ -722,7 +723,7 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
|
|||
/* configure shader even if video processor is available for fallback */
|
||||
window->converter =
|
||||
gst_d3d11_converter_new (window->device, &window->info,
|
||||
&window->render_info);
|
||||
&window->render_info, &method);
|
||||
|
||||
if (!window->converter) {
|
||||
GST_ERROR_OBJECT (window, "Cannot create converter");
|
||||
|
|
|
@ -86,6 +86,7 @@ gst_d3d11_window_dummy_prepare (GstD3D11Window * window,
|
|||
gboolean * video_processor_available, GError ** error)
|
||||
{
|
||||
GstDxgiColorSpace in_space;
|
||||
GstD3D11ConverterMethod method = GST_D3D11_CONVERTER_METHOD_SHADER;
|
||||
|
||||
g_clear_pointer (&window->processor, gst_d3d11_video_processor_free);
|
||||
gst_clear_object (&window->compositor);
|
||||
|
@ -172,7 +173,7 @@ gst_d3d11_window_dummy_prepare (GstD3D11Window * window,
|
|||
|
||||
window->converter =
|
||||
gst_d3d11_converter_new (window->device, &window->info,
|
||||
&window->render_info);
|
||||
&window->render_info, &method);
|
||||
|
||||
if (!window->converter) {
|
||||
GST_ERROR_OBJECT (window, "Cannot create converter");
|
||||
|
|
Loading…
Reference in a new issue