mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
d3d11: Port to C++
Direct3D11 objects are COM, and most COM C APIs are verbose (C++ is a little better). So, by using C++ APIs, we can make code shorter and more readable. Moreover, "ComPtr" helper class (which is C++ only) can be utilized, that is very helpful for avoiding error-prone COM refcounting issue/leak. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2077>
This commit is contained in:
parent
3c40ffc00f
commit
5b3e316039
33 changed files with 1064 additions and 1186 deletions
|
@ -78,8 +78,8 @@ gst_d3d11_base_filter_class_init (GstD3D11BaseFilterClass * klass)
|
|||
g_param_spec_int ("adapter", "Adapter",
|
||||
"Adapter index for creating device (-1 for default)",
|
||||
-1, G_MAXINT32, DEFAULT_ADAPTER,
|
||||
G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
element_class->set_context =
|
||||
GST_DEBUG_FUNCPTR (gst_d3d11_base_filter_set_context);
|
||||
|
@ -93,7 +93,8 @@ gst_d3d11_base_filter_class_init (GstD3D11BaseFilterClass * klass)
|
|||
GST_DEBUG_FUNCPTR (gst_d3d11_base_filter_get_unit_size);
|
||||
trans_class->query = GST_DEBUG_FUNCPTR (gst_d3d11_base_filter_query);
|
||||
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_D3D11_BASE_FILTER, 0);
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_D3D11_BASE_FILTER,
|
||||
(GstPluginAPIFlags) 0);
|
||||
}
|
||||
|
||||
static void
|
|
@ -1,65 +0,0 @@
|
|||
/* 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_CONVERTER_H__
|
||||
#define __GST_D3D11_COLOR_CONVERTER_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
#include <gst/d3d11/gstd3d11.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GstD3D11ColorConverter GstD3D11ColorConverter;
|
||||
|
||||
GstD3D11ColorConverter * gst_d3d11_color_converter_new (GstD3D11Device * device,
|
||||
GstVideoInfo * in_info,
|
||||
GstVideoInfo * out_info);
|
||||
|
||||
GstD3D11ColorConverter * gst_d3d11_color_converter_new_with_alpha (GstD3D11Device * device,
|
||||
GstVideoInfo * in_info,
|
||||
GstVideoInfo * out_info,
|
||||
gfloat alpha);
|
||||
|
||||
void gst_d3d11_color_converter_free (GstD3D11ColorConverter * converter);
|
||||
|
||||
gboolean gst_d3d11_color_converter_convert (GstD3D11ColorConverter * converter,
|
||||
ID3D11ShaderResourceView *srv[GST_VIDEO_MAX_PLANES],
|
||||
ID3D11RenderTargetView *rtv[GST_VIDEO_MAX_PLANES],
|
||||
ID3D11BlendState *blend,
|
||||
gfloat blend_factor[4]);
|
||||
|
||||
gboolean gst_d3d11_color_converter_convert_unlocked (GstD3D11ColorConverter * converter,
|
||||
ID3D11ShaderResourceView *srv[GST_VIDEO_MAX_PLANES],
|
||||
ID3D11RenderTargetView *rtv[GST_VIDEO_MAX_PLANES],
|
||||
ID3D11BlendState *blend,
|
||||
gfloat blend_factor[4]);
|
||||
|
||||
gboolean gst_d3d11_color_converter_update_viewport (GstD3D11ColorConverter * converter,
|
||||
D3D11_VIEWPORT * viewport);
|
||||
|
||||
gboolean gst_d3d11_color_converter_update_src_rect (GstD3D11ColorConverter * converter,
|
||||
RECT * src_rect);
|
||||
|
||||
gboolean gst_d3d11_color_converter_update_dest_rect (GstD3D11ColorConverter * converter,
|
||||
RECT * dest_rect);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_D3D11_COLOR_CONVERTER_H__ */
|
|
@ -37,14 +37,23 @@
|
|||
#endif
|
||||
|
||||
#include "gstd3d11compositor.h"
|
||||
#include "gstd3d11colorconverter.h"
|
||||
#include "gstd3d11converter.h"
|
||||
#include "gstd3d11shader.h"
|
||||
#include "gstd3d11pluginutils.h"
|
||||
#include <string.h>
|
||||
#include <wrl.h>
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
using namespace Microsoft::WRL;
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_compositor_debug);
|
||||
#define GST_CAT_DEFAULT gst_d3d11_compositor_debug
|
||||
|
||||
G_END_DECLS
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/**
|
||||
* GstD3D11CompositorBlendOperation:
|
||||
* @GST_D3D11_COMPOSITOR_BLEND_OP_ADD:
|
||||
|
@ -389,7 +398,7 @@ struct _GstD3D11CompositorPad
|
|||
{
|
||||
GstVideoAggregatorConvertPad parent;
|
||||
|
||||
GstD3D11ColorConverter *convert;
|
||||
GstD3D11Converter *convert;
|
||||
|
||||
GstBufferPool *fallback_pool;
|
||||
GstBuffer *fallback_buf;
|
||||
|
@ -490,39 +499,46 @@ gst_d3d11_compositor_pad_class_init (GstD3D11CompositorPadClass * klass)
|
|||
g_object_class_install_property (gobject_class, PROP_PAD_XPOS,
|
||||
g_param_spec_int ("xpos", "X Position", "X position of the picture",
|
||||
G_MININT, G_MAXINT, DEFAULT_PAD_XPOS,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_PAD_YPOS,
|
||||
g_param_spec_int ("ypos", "Y Position", "Y position of the picture",
|
||||
G_MININT, G_MAXINT, DEFAULT_PAD_YPOS,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_PAD_WIDTH,
|
||||
g_param_spec_int ("width", "Width", "Width of the picture",
|
||||
G_MININT, G_MAXINT, DEFAULT_PAD_WIDTH,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_PAD_HEIGHT,
|
||||
g_param_spec_int ("height", "Height", "Height of the picture",
|
||||
G_MININT, G_MAXINT, DEFAULT_PAD_HEIGHT,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_PAD_ALPHA,
|
||||
g_param_spec_double ("alpha", "Alpha", "Alpha of the picture", 0.0, 1.0,
|
||||
DEFAULT_PAD_ALPHA,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_PAD_BLEND_OP_RGB,
|
||||
g_param_spec_enum ("blend-op-rgb", "Blend Operation RGB",
|
||||
"Blend equation for RGB", GST_TYPE_D3D11_COMPOSITOR_BLEND_OPERATION,
|
||||
DEFAULT_PAD_BLEND_OP_RGB,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_PAD_BLEND_OP_ALPHA,
|
||||
g_param_spec_enum ("blend-op-alpha", "Blend Operation Alpha",
|
||||
"Blend equation for alpha", GST_TYPE_D3D11_COMPOSITOR_BLEND_OPERATION,
|
||||
DEFAULT_PAD_BLEND_OP_ALPHA,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_PAD_BLEND_SRC_RGB,
|
||||
|
@ -530,7 +546,8 @@ gst_d3d11_compositor_pad_class_init (GstD3D11CompositorPadClass * klass)
|
|||
"Blend factor for source RGB",
|
||||
GST_TYPE_D3D11_COMPOSITOR_BLEND,
|
||||
DEFAULT_PAD_BLEND_SRC_RGB,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_PAD_BLEND_SRC_ALPHA,
|
||||
|
@ -539,7 +556,8 @@ gst_d3d11_compositor_pad_class_init (GstD3D11CompositorPadClass * klass)
|
|||
"Blend factor for source alpha, \"*-color\" values are not allowed",
|
||||
GST_TYPE_D3D11_COMPOSITOR_BLEND,
|
||||
DEFAULT_PAD_BLEND_SRC_ALPHA,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_PAD_BLEND_DEST_RGB,
|
||||
|
@ -548,7 +566,8 @@ gst_d3d11_compositor_pad_class_init (GstD3D11CompositorPadClass * klass)
|
|||
"Blend factor for destination RGB",
|
||||
GST_TYPE_D3D11_COMPOSITOR_BLEND,
|
||||
DEFAULT_PAD_BLEND_DEST_RGB,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_PAD_BLEND_DEST_ALPHA,
|
||||
|
@ -558,43 +577,50 @@ gst_d3d11_compositor_pad_class_init (GstD3D11CompositorPadClass * klass)
|
|||
"\"*-color\" values are not allowed",
|
||||
GST_TYPE_D3D11_COMPOSITOR_BLEND,
|
||||
DEFAULT_PAD_BLEND_DEST_ALPHA,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_PAD_BLEND_FACTOR_RED,
|
||||
g_param_spec_float ("blend-factor-red", "Blend Factor Red",
|
||||
"Blend factor for red component "
|
||||
"when blend type is \"blend-factor\" or \"inv-blend-factor\"",
|
||||
0.0, 1.0, 1.0,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_PAD_BLEND_FACTOR_GREEN,
|
||||
g_param_spec_float ("blend-factor-green", "Blend Factor Green",
|
||||
"Blend factor for green component "
|
||||
"when blend type is \"blend-factor\" or \"inv-blend-factor\"",
|
||||
0.0, 1.0, 1.0,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_PAD_BLEND_FACTOR_BLUE,
|
||||
g_param_spec_float ("blend-factor-blue", "Blend Factor Blue",
|
||||
"Blend factor for blue component "
|
||||
"when blend type is \"blend-factor\" or \"inv-blend-factor\"",
|
||||
0.0, 1.0, 1.0,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_PAD_BLEND_FACTOR_ALPHA,
|
||||
g_param_spec_float ("blend-factor-alpha", "Blend Factor Alpha",
|
||||
"Blend factor for alpha component "
|
||||
"when blend type is \"blend-factor\" or \"inv-blend-factor\"",
|
||||
0.0, 1.0, 1.0,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
vaggpadclass->prepare_frame =
|
||||
GST_DEBUG_FUNCPTR (gst_d3d11_compositor_pad_prepare_frame);
|
||||
vaggpadclass->clean_frame =
|
||||
GST_DEBUG_FUNCPTR (gst_d3d11_compositor_pad_clean_frame);
|
||||
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_D3D11_COMPOSITOR_BLEND, 0);
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_D3D11_COMPOSITOR_BLEND_OPERATION, 0);
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_D3D11_COMPOSITOR_BLEND,
|
||||
(GstPluginAPIFlags) 0);
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_D3D11_COMPOSITOR_BLEND_OPERATION,
|
||||
(GstPluginAPIFlags) 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -624,7 +650,7 @@ gst_d3d11_compositor_pad_update_blend_function (GstD3D11CompositorPad * pad,
|
|||
|
||||
static void
|
||||
gst_d3d11_compositor_pad_update_blend_equation (GstD3D11CompositorPad * pad,
|
||||
D3D11_BLEND_OP * value, GstD3D11CompositorBlend new_value)
|
||||
D3D11_BLEND_OP * value, GstD3D11CompositorBlendOperation new_value)
|
||||
{
|
||||
D3D11_BLEND_OP temp =
|
||||
gst_d3d11_compositor_blend_operation_to_native (new_value);
|
||||
|
@ -670,19 +696,21 @@ gst_d3d11_compositor_pad_set_property (GObject * object, guint prop_id,
|
|||
}
|
||||
case PROP_PAD_BLEND_OP_RGB:
|
||||
gst_d3d11_compositor_pad_update_blend_equation (pad, &pad->desc.BlendOp,
|
||||
g_value_get_enum (value));
|
||||
(GstD3D11CompositorBlendOperation) g_value_get_enum (value));
|
||||
break;
|
||||
case PROP_PAD_BLEND_OP_ALPHA:
|
||||
gst_d3d11_compositor_pad_update_blend_equation (pad,
|
||||
&pad->desc.BlendOpAlpha, g_value_get_enum (value));
|
||||
&pad->desc.BlendOpAlpha,
|
||||
(GstD3D11CompositorBlendOperation) g_value_get_enum (value));
|
||||
break;
|
||||
case PROP_PAD_BLEND_SRC_RGB:
|
||||
gst_d3d11_compositor_pad_update_blend_function (pad, &pad->desc.SrcBlend,
|
||||
g_value_get_enum (value));
|
||||
(GstD3D11CompositorBlend) g_value_get_enum (value));
|
||||
break;
|
||||
case PROP_PAD_BLEND_SRC_ALPHA:
|
||||
{
|
||||
GstD3D11CompositorBlend blend = g_value_get_enum (value);
|
||||
GstD3D11CompositorBlend blend =
|
||||
(GstD3D11CompositorBlend) g_value_get_enum (value);
|
||||
if (blend == GST_D3D11_COMPOSITOR_BLEND_SRC_COLOR ||
|
||||
blend == GST_D3D11_COMPOSITOR_BLEND_INV_SRC_COLOR ||
|
||||
blend == GST_D3D11_COMPOSITOR_BLEND_DEST_COLOR ||
|
||||
|
@ -696,11 +724,12 @@ gst_d3d11_compositor_pad_set_property (GObject * object, guint prop_id,
|
|||
}
|
||||
case PROP_PAD_BLEND_DEST_RGB:
|
||||
gst_d3d11_compositor_pad_update_blend_function (pad, &pad->desc.DestBlend,
|
||||
g_value_get_enum (value));
|
||||
(GstD3D11CompositorBlend) g_value_get_enum (value));
|
||||
break;
|
||||
case PROP_PAD_BLEND_DEST_ALPHA:
|
||||
{
|
||||
GstD3D11CompositorBlend blend = g_value_get_enum (value);
|
||||
GstD3D11CompositorBlend blend =
|
||||
(GstD3D11CompositorBlend) g_value_get_enum (value);
|
||||
if (blend == GST_D3D11_COMPOSITOR_BLEND_SRC_COLOR ||
|
||||
blend == GST_D3D11_COMPOSITOR_BLEND_INV_SRC_COLOR ||
|
||||
blend == GST_D3D11_COMPOSITOR_BLEND_DEST_COLOR ||
|
||||
|
@ -798,7 +827,7 @@ gst_d3d11_compositor_pad_get_property (GObject * object, guint prop_id,
|
|||
static void
|
||||
gst_d3d11_compositor_pad_init_blend_options (GstD3D11CompositorPad * pad)
|
||||
{
|
||||
gint i;
|
||||
guint i;
|
||||
|
||||
pad->desc.BlendEnable = TRUE;
|
||||
pad->desc.SrcBlend =
|
||||
|
@ -840,7 +869,7 @@ gst_d3d11_compositor_configure_fallback_pool (GstD3D11Compositor * self,
|
|||
}
|
||||
|
||||
d3d11_params = gst_d3d11_allocation_params_new (self->device,
|
||||
info, 0, bind_flags);
|
||||
info, (GstD3D11AllocationFlags) 0, bind_flags);
|
||||
|
||||
new_pool = gst_d3d11_buffer_pool_new_with_options (self->device,
|
||||
caps, d3d11_params, 0, 0);
|
||||
|
@ -865,7 +894,7 @@ gst_d3d11_compsitor_prepare_fallback_buffer (GstD3D11Compositor * self,
|
|||
{
|
||||
GstBuffer *new_buf = NULL;
|
||||
gint bind_flags = D3D11_BIND_SHADER_RESOURCE;
|
||||
gint i;
|
||||
guint i;
|
||||
|
||||
gst_clear_buffer (fallback_buffer);
|
||||
|
||||
|
@ -911,7 +940,7 @@ gst_d3d11_compositor_copy_buffer (GstD3D11Compositor * self,
|
|||
GstVideoInfo * info, GstBuffer * src_buf, GstBuffer * dest_buf,
|
||||
gboolean do_device_copy)
|
||||
{
|
||||
gint i;
|
||||
guint i;
|
||||
|
||||
if (do_device_copy) {
|
||||
return gst_d3d11_buffer_copy_into (dest_buf, src_buf, info);
|
||||
|
@ -919,13 +948,13 @@ gst_d3d11_compositor_copy_buffer (GstD3D11Compositor * self,
|
|||
GstVideoFrame src_frame, dest_frame;
|
||||
|
||||
if (!gst_video_frame_map (&src_frame, info, src_buf,
|
||||
GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF)) {
|
||||
(GstMapFlags) (GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF))) {
|
||||
GST_ERROR_OBJECT (self, "Couldn't map input buffer");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!gst_video_frame_map (&dest_frame, info, dest_buf,
|
||||
GST_MAP_WRITE | GST_VIDEO_FRAME_MAP_FLAG_NO_REF)) {
|
||||
(GstMapFlags) (GST_MAP_WRITE | GST_VIDEO_FRAME_MAP_FLAG_NO_REF))) {
|
||||
GST_ERROR_OBJECT (self, "Couldn't fallback buffer");
|
||||
gst_video_frame_unmap (&src_frame);
|
||||
return FALSE;
|
||||
|
@ -953,7 +982,7 @@ static gboolean
|
|||
gst_d3d11_compositor_check_d3d11_memory (GstD3D11Compositor * self,
|
||||
GstBuffer * buffer, gboolean is_input, gboolean * view_available)
|
||||
{
|
||||
gint i;
|
||||
guint i;
|
||||
gboolean ret = TRUE;
|
||||
|
||||
*view_available = TRUE;
|
||||
|
@ -1134,7 +1163,7 @@ gst_d3d11_compositor_pad_prepare_frame (GstVideoAggregatorPad * pad,
|
|||
}
|
||||
|
||||
if (!gst_video_frame_map (prepared_frame, &pad->info, target_buf,
|
||||
GST_MAP_READ | GST_MAP_D3D11)) {
|
||||
(GstMapFlags) (GST_MAP_READ | GST_MAP_D3D11))) {
|
||||
GST_WARNING_OBJECT (pad, "Couldn't map input buffer");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1171,9 +1200,9 @@ gst_d3d11_compositor_pad_setup_converter (GstVideoAggregatorPad * pad,
|
|||
|
||||
if (!cpad->convert || cpad->alpha_updated || cpad->caps_updated) {
|
||||
if (cpad->convert)
|
||||
gst_d3d11_color_converter_free (cpad->convert);
|
||||
gst_d3d11_converter_free (cpad->convert);
|
||||
cpad->convert =
|
||||
gst_d3d11_color_converter_new_with_alpha (self->device,
|
||||
gst_d3d11_converter_new_with_alpha (self->device,
|
||||
&pad->info, &vagg->info, cpad->alpha);
|
||||
cpad->alpha_updated = FALSE;
|
||||
cpad->caps_updated = FALSE;
|
||||
|
@ -1192,16 +1221,13 @@ gst_d3d11_compositor_pad_setup_converter (GstVideoAggregatorPad * pad,
|
|||
ID3D11Device *device_handle =
|
||||
gst_d3d11_device_get_device_handle (self->device);
|
||||
|
||||
if (cpad->blend) {
|
||||
ID3D11BlendState_Release (cpad->blend);
|
||||
cpad->blend = NULL;
|
||||
}
|
||||
GST_D3D11_CLEAR_COM (cpad->blend);
|
||||
|
||||
desc.AlphaToCoverageEnable = FALSE;
|
||||
desc.IndependentBlendEnable = FALSE;
|
||||
desc.RenderTarget[0] = cpad->desc;
|
||||
|
||||
hr = ID3D11Device_CreateBlendState (device_handle, &desc, &blend);
|
||||
hr = device_handle->CreateBlendState (&desc, &blend);
|
||||
if (!gst_d3d11_result (hr, self->device)) {
|
||||
GST_ERROR_OBJECT (pad, "Couldn't create blend staten, hr: 0x%x",
|
||||
(guint) hr);
|
||||
|
@ -1239,7 +1265,7 @@ gst_d3d11_compositor_pad_setup_converter (GstVideoAggregatorPad * pad,
|
|||
|
||||
cpad->position_updated = FALSE;
|
||||
|
||||
return gst_d3d11_color_converter_update_dest_rect (cpad->convert, &rect);
|
||||
return gst_d3d11_converter_update_dest_rect (cpad->convert, &rect);
|
||||
}
|
||||
|
||||
static GstStaticCaps pad_template_caps =
|
||||
|
@ -1313,13 +1339,14 @@ gst_d3d11_compositor_class_init (GstD3D11CompositorClass * klass)
|
|||
g_param_spec_int ("adapter", "Adapter",
|
||||
"Adapter index for creating device (-1 for default)",
|
||||
-1, G_MAXINT32, DEFAULT_ADAPTER,
|
||||
G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_BACKGROUND,
|
||||
g_param_spec_enum ("background", "Background", "Background type",
|
||||
GST_TYPE_COMPOSITOR_BACKGROUND,
|
||||
DEFAULT_BACKGROUND, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
DEFAULT_BACKGROUND,
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
element_class->request_new_pad =
|
||||
GST_DEBUG_FUNCPTR (gst_d3d11_compositor_request_new_pad);
|
||||
|
@ -1360,8 +1387,10 @@ gst_d3d11_compositor_class_init (GstD3D11CompositorClass * klass)
|
|||
"Filter/Editor/Video/Compositor",
|
||||
"A Direct3D11 compositor", "Seungha Yang <seungha@centricular.com>");
|
||||
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_COMPOSITOR_BACKGROUND, 0);
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_D3D11_COMPOSITOR_PAD, 0);
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_COMPOSITOR_BACKGROUND,
|
||||
(GstPluginAPIFlags) 0);
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_D3D11_COMPOSITOR_PAD,
|
||||
(GstPluginAPIFlags) 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1395,7 +1424,8 @@ gst_d3d11_compositor_set_property (GObject * object,
|
|||
self->adapter = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_BACKGROUND:
|
||||
self->background = g_value_get_enum (value);
|
||||
self->background =
|
||||
(GstD3D11CompositorBackground) g_value_get_enum (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
@ -1430,7 +1460,7 @@ gst_d3d11_compositor_child_proxy_get_child_by_index (GstChildProxy * proxy,
|
|||
GObject *obj = NULL;
|
||||
|
||||
GST_OBJECT_LOCK (self);
|
||||
obj = g_list_nth_data (GST_ELEMENT_CAST (self)->sinkpads, index);
|
||||
obj = (GObject *) g_list_nth_data (GST_ELEMENT_CAST (self)->sinkpads, index);
|
||||
if (obj)
|
||||
gst_object_ref (obj);
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
|
@ -1455,7 +1485,7 @@ gst_d3d11_compositor_child_proxy_get_children_count (GstChildProxy * proxy)
|
|||
static void
|
||||
gst_d3d11_compositor_child_proxy_init (gpointer g_iface, gpointer iface_data)
|
||||
{
|
||||
GstChildProxyInterface *iface = g_iface;
|
||||
GstChildProxyInterface *iface = (GstChildProxyInterface *) g_iface;
|
||||
|
||||
iface->get_child_by_index =
|
||||
gst_d3d11_compositor_child_proxy_get_child_by_index;
|
||||
|
@ -1502,11 +1532,8 @@ gst_d3d11_compositor_release_pad (GstElement * element, GstPad * pad)
|
|||
|
||||
gst_clear_buffer (&cpad->fallback_buf);
|
||||
gst_clear_object (&cpad->fallback_pool);
|
||||
g_clear_pointer (&cpad->convert, gst_d3d11_color_converter_free);
|
||||
if (cpad->blend) {
|
||||
ID3D11BlendState_Release (cpad->blend);
|
||||
cpad->blend = NULL;
|
||||
}
|
||||
g_clear_pointer (&cpad->convert, gst_d3d11_converter_free);
|
||||
GST_D3D11_CLEAR_COM (cpad->blend);
|
||||
|
||||
GST_ELEMENT_CLASS (parent_class)->release_pad (element, pad);
|
||||
}
|
||||
|
@ -1691,7 +1718,7 @@ gst_d3d11_compositor_fixate_src_caps (GstAggregator * aggregator,
|
|||
|
||||
GST_OBJECT_LOCK (vagg);
|
||||
for (l = GST_ELEMENT (vagg)->sinkpads; l; l = l->next) {
|
||||
GstVideoAggregatorPad *vaggpad = l->data;
|
||||
GstVideoAggregatorPad *vaggpad = GST_VIDEO_AGGREGATOR_PAD (l->data);
|
||||
GstD3D11CompositorPad *cpad = GST_D3D11_COMPOSITOR_PAD (vaggpad);
|
||||
gint this_width, this_height;
|
||||
gint width, height;
|
||||
|
@ -1765,8 +1792,8 @@ gst_d3d11_compositor_propose_allocation (GstAggregator * aggregator,
|
|||
if (gst_query_get_n_allocation_pools (query) == 0) {
|
||||
GstD3D11AllocationParams *d3d11_params;
|
||||
|
||||
d3d11_params = gst_d3d11_allocation_params_new (self->device, &info, 0,
|
||||
D3D11_BIND_SHADER_RESOURCE);
|
||||
d3d11_params = gst_d3d11_allocation_params_new (self->device, &info,
|
||||
(GstD3D11AllocationFlags) 0, D3D11_BIND_SHADER_RESOURCE);
|
||||
|
||||
pool = gst_d3d11_buffer_pool_new_with_options (self->device,
|
||||
caps, d3d11_params, 0, 0);
|
||||
|
@ -1833,9 +1860,9 @@ gst_d3d11_compositor_decide_allocation (GstAggregator * aggregator,
|
|||
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
|
||||
if (!d3d11_params) {
|
||||
d3d11_params = gst_d3d11_allocation_params_new (self->device,
|
||||
&info, 0, D3D11_BIND_RENDER_TARGET);
|
||||
&info, (GstD3D11AllocationFlags) 0, D3D11_BIND_RENDER_TARGET);
|
||||
} else {
|
||||
gint i;
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&info); i++) {
|
||||
d3d11_params->desc[i].BindFlags |= D3D11_BIND_RENDER_TARGET;
|
||||
|
@ -1894,9 +1921,6 @@ typedef struct
|
|||
static GstD3D11Quad *
|
||||
gst_d3d11_compositor_create_checker_quad (GstD3D11Compositor * self)
|
||||
{
|
||||
ID3D11PixelShader *ps = NULL;
|
||||
ID3D11VertexShader *vs = NULL;
|
||||
ID3D11InputLayout *layout = NULL;
|
||||
GstD3D11Quad *quad = NULL;
|
||||
VertexData *vertex_data;
|
||||
WORD *indices;
|
||||
|
@ -1905,18 +1929,21 @@ gst_d3d11_compositor_create_checker_quad (GstD3D11Compositor * self)
|
|||
D3D11_MAPPED_SUBRESOURCE map;
|
||||
D3D11_INPUT_ELEMENT_DESC input_desc;
|
||||
D3D11_BUFFER_DESC buffer_desc;
|
||||
ID3D11Buffer *vertex_buffer = NULL;
|
||||
ID3D11Buffer *index_buffer = NULL;
|
||||
gboolean ret = FALSE;
|
||||
/* *INDENT-OFF* */
|
||||
ComPtr<ID3D11Buffer> vertex_buffer;
|
||||
ComPtr<ID3D11Buffer> index_buffer;
|
||||
ComPtr<ID3D11PixelShader> ps;
|
||||
ComPtr<ID3D11VertexShader> vs;
|
||||
ComPtr<ID3D11InputLayout> layout;
|
||||
/* *INDENT-ON* */
|
||||
HRESULT hr;
|
||||
|
||||
device_handle = gst_d3d11_device_get_device_handle (self->device);
|
||||
context_handle = gst_d3d11_device_get_device_context_handle (self->device);
|
||||
|
||||
ret = gst_d3d11_create_pixel_shader (self->device, checker_ps_src, &ps);
|
||||
if (!ret) {
|
||||
if (!gst_d3d11_create_pixel_shader (self->device, checker_ps_src, &ps)) {
|
||||
GST_ERROR_OBJECT (self, "Couldn't setup pixel shader");
|
||||
goto done;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset (&input_desc, 0, sizeof (D3D11_INPUT_ELEMENT_DESC));
|
||||
|
@ -1931,7 +1958,7 @@ gst_d3d11_compositor_create_checker_quad (GstD3D11Compositor * self)
|
|||
if (!gst_d3d11_create_vertex_shader (self->device, checker_vs_src,
|
||||
&input_desc, 1, &vs, &layout)) {
|
||||
GST_ERROR_OBJECT (self, "Couldn't setup vertex shader");
|
||||
goto done;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset (&buffer_desc, 0, sizeof (D3D11_BUFFER_DESC));
|
||||
|
@ -1940,21 +1967,19 @@ gst_d3d11_compositor_create_checker_quad (GstD3D11Compositor * self)
|
|||
buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
|
||||
hr = ID3D11Device_CreateBuffer (device_handle, &buffer_desc, NULL,
|
||||
&vertex_buffer);
|
||||
|
||||
hr = device_handle->CreateBuffer (&buffer_desc, NULL, &vertex_buffer);
|
||||
if (!gst_d3d11_result (hr, self->device)) {
|
||||
GST_ERROR_OBJECT (self,
|
||||
"Couldn't create vertex buffer, hr: 0x%x", (guint) hr);
|
||||
goto done;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hr = ID3D11DeviceContext_Map (context_handle,
|
||||
(ID3D11Resource *) vertex_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
||||
hr = context_handle->Map (vertex_buffer.Get (),
|
||||
0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
||||
|
||||
if (!gst_d3d11_result (hr, self->device)) {
|
||||
GST_ERROR_OBJECT (self, "Couldn't map vertex buffer, hr: 0x%x", (guint) hr);
|
||||
goto done;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vertex_data = (VertexData *) map.pData;
|
||||
|
@ -1987,29 +2012,26 @@ gst_d3d11_compositor_create_checker_quad (GstD3D11Compositor * self)
|
|||
vertex_data[3].texture.u = 1.0f;
|
||||
vertex_data[3].texture.v = 1.0f;
|
||||
|
||||
ID3D11DeviceContext_Unmap (context_handle,
|
||||
(ID3D11Resource *) vertex_buffer, 0);
|
||||
context_handle->Unmap (vertex_buffer.Get (), 0);
|
||||
|
||||
buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
buffer_desc.ByteWidth = sizeof (WORD) * 6;
|
||||
buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||
buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
|
||||
hr = ID3D11Device_CreateBuffer (device_handle, &buffer_desc, NULL,
|
||||
&index_buffer);
|
||||
|
||||
hr = device_handle->CreateBuffer (&buffer_desc, NULL, &index_buffer);
|
||||
if (!gst_d3d11_result (hr, self->device)) {
|
||||
GST_ERROR_OBJECT (self,
|
||||
"Couldn't create index buffer, hr: 0x%x", (guint) hr);
|
||||
goto done;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hr = ID3D11DeviceContext_Map (context_handle,
|
||||
(ID3D11Resource *) index_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
||||
hr = context_handle->Map (index_buffer.Get (),
|
||||
0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
||||
|
||||
if (!gst_d3d11_result (hr, self->device)) {
|
||||
GST_ERROR_OBJECT (self, "Couldn't map index buffer, hr: 0x%x", (guint) hr);
|
||||
goto done;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
indices = (WORD *) map.pData;
|
||||
|
@ -2023,29 +2045,17 @@ gst_d3d11_compositor_create_checker_quad (GstD3D11Compositor * self)
|
|||
indices[4] = 0; /* bottom left */
|
||||
indices[5] = 2; /* top right */
|
||||
|
||||
ID3D11DeviceContext_Unmap (context_handle,
|
||||
(ID3D11Resource *) index_buffer, 0);
|
||||
context_handle->Unmap (index_buffer.Get (), 0);
|
||||
|
||||
quad = gst_d3d11_quad_new (self->device,
|
||||
ps, vs, layout, NULL, NULL, NULL, NULL, vertex_buffer,
|
||||
sizeof (VertexData), index_buffer, DXGI_FORMAT_R16_UINT, 6);
|
||||
ps.Get (), vs.Get (), layout.Get (), NULL, NULL, NULL, NULL,
|
||||
vertex_buffer.Get (), sizeof (VertexData), index_buffer.Get (),
|
||||
DXGI_FORMAT_R16_UINT, 6);
|
||||
if (!quad) {
|
||||
GST_ERROR_OBJECT (self, "Couldn't setup quad");
|
||||
goto done;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
done:
|
||||
if (ps)
|
||||
ID3D11PixelShader_Release (ps);
|
||||
if (vs)
|
||||
ID3D11VertexShader_Release (vs);
|
||||
if (layout)
|
||||
ID3D11InputLayout_Release (layout);
|
||||
if (vertex_buffer)
|
||||
ID3D11Buffer_Release (vertex_buffer);
|
||||
if (index_buffer)
|
||||
ID3D11Buffer_Release (index_buffer);
|
||||
|
||||
return quad;
|
||||
}
|
||||
|
||||
|
@ -2101,7 +2111,7 @@ gst_d3d11_compositor_draw_background (GstD3D11Compositor * self,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
ID3D11DeviceContext_ClearRenderTargetView (device_context, rtv, rgba);
|
||||
device_context->ClearRenderTargetView (rtv, rgba);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -2117,7 +2127,7 @@ gst_d3d11_compositor_aggregate_frames (GstVideoAggregator * vagg,
|
|||
gboolean do_device_copy = FALSE;
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
ID3D11RenderTargetView *rtv[GST_VIDEO_MAX_PLANES] = { NULL, };
|
||||
gint i, j;
|
||||
guint i, j;
|
||||
gint view_idx;
|
||||
|
||||
/* Use fallback buffer when output buffer is:
|
||||
|
@ -2181,7 +2191,7 @@ gst_d3d11_compositor_aggregate_frames (GstVideoAggregator * vagg,
|
|||
GST_OBJECT_LOCK (self);
|
||||
|
||||
for (iter = GST_ELEMENT (vagg)->sinkpads; iter; iter = g_list_next (iter)) {
|
||||
GstVideoAggregatorPad *pad = iter->data;
|
||||
GstVideoAggregatorPad *pad = GST_VIDEO_AGGREGATOR_PAD (iter->data);
|
||||
GstD3D11CompositorPad *cpad = GST_D3D11_COMPOSITOR_PAD (pad);
|
||||
GstVideoFrame *prepared_frame =
|
||||
gst_video_aggregator_pad_get_prepared_frame (pad);
|
||||
|
@ -2213,7 +2223,7 @@ gst_d3d11_compositor_aggregate_frames (GstVideoAggregator * vagg,
|
|||
}
|
||||
}
|
||||
|
||||
if (!gst_d3d11_color_converter_convert_unlocked (cpad->convert, srv, rtv,
|
||||
if (!gst_d3d11_converter_convert_unlocked (cpad->convert, srv, rtv,
|
||||
cpad->blend, cpad->blend_factor)) {
|
||||
GST_ERROR_OBJECT (self, "Couldn't convert frame");
|
||||
ret = GST_FLOW_ERROR;
|
|
@ -47,9 +47,15 @@
|
|||
#include "gstd3d11compositor.h"
|
||||
#include "gstd3d11pluginutils.h"
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_compositor_debug);
|
||||
#define GST_CAT_DEFAULT gst_d3d11_compositor_debug
|
||||
|
||||
G_END_DECLS
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/****************************
|
||||
* GstD3D11CompositorBinPad *
|
||||
****************************/
|
||||
|
@ -113,7 +119,7 @@ gst_d3d11_compositor_bin_pad_class_init (GstD3D11CompositorBinPadClass * klass)
|
|||
g_param_spec_boolean ("emit-signals", "Emit signals",
|
||||
"Send signals to signal data consumption",
|
||||
DEFAULT_PAD_EMIT_SIGNALS,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
gst_d3d11_compositor_bin_pad_signals[SIGNAL_PAD_BUFFER_CONSUMED] =
|
||||
g_signal_new ("buffer-consumed", G_TYPE_FROM_CLASS (klass),
|
||||
|
@ -286,13 +292,15 @@ gst_d3d11_compositor_bin_input_class_init (GstD3D11CompositorBinInputClass *
|
|||
g_object_class_install_property (gobject_class, PROP_INPUT_ZORDER,
|
||||
g_param_spec_uint ("zorder", "Z-Order", "Z Order of the picture",
|
||||
0, G_MAXUINT, DEFAULT_INPUT_ZORDER,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INPUT_REPEAT_AFTER_EOS,
|
||||
g_param_spec_boolean ("repeat-after-eos", "Repeat After EOS",
|
||||
"Repeat the " "last frame after EOS until all pads are EOS",
|
||||
DEFAULT_INPUT_REPEAT_AFTER_EOS,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_INPUT_MAX_LAST_BUFFER_REPEAT,
|
||||
|
@ -300,46 +308,53 @@ gst_d3d11_compositor_bin_input_class_init (GstD3D11CompositorBinInputClass *
|
|||
"Repeat last buffer for time (in ns, -1=until EOS), "
|
||||
"behaviour on EOS is not affected", 0, G_MAXUINT64,
|
||||
DEFAULT_INPUT_MAX_LAST_BUFFER_REPEAT,
|
||||
G_PARAM_READWRITE | GST_PARAM_MUTABLE_PLAYING |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_MUTABLE_PLAYING |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
/* GstD3D11CompositorPad */
|
||||
g_object_class_install_property (gobject_class, PROP_INPUT_XPOS,
|
||||
g_param_spec_int ("xpos", "X Position", "X position of the picture",
|
||||
G_MININT, G_MAXINT, DEFAULT_INPUT_XPOS,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INPUT_YPOS,
|
||||
g_param_spec_int ("ypos", "Y Position", "Y position of the picture",
|
||||
G_MININT, G_MAXINT, DEFAULT_INPUT_YPOS,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INPUT_WIDTH,
|
||||
g_param_spec_int ("width", "Width", "Width of the picture",
|
||||
G_MININT, G_MAXINT, DEFAULT_INPUT_WIDTH,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INPUT_HEIGHT,
|
||||
g_param_spec_int ("height", "Height", "Height of the picture",
|
||||
G_MININT, G_MAXINT, DEFAULT_INPUT_HEIGHT,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INPUT_ALPHA,
|
||||
g_param_spec_double ("alpha", "Alpha", "Alpha of the picture", 0.0, 1.0,
|
||||
DEFAULT_INPUT_ALPHA,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INPUT_BLEND_OP_RGB,
|
||||
g_param_spec_enum ("blend-op-rgb", "Blend Operation RGB",
|
||||
"Blend equation for RGB", GST_TYPE_D3D11_COMPOSITOR_BLEND_OPERATION,
|
||||
DEFAULT_INPUT_BLEND_OP_RGB,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INPUT_BLEND_OP_ALPHA,
|
||||
g_param_spec_enum ("blend-op-alpha", "Blend Operation Alpha",
|
||||
"Blend equation for alpha", GST_TYPE_D3D11_COMPOSITOR_BLEND_OPERATION,
|
||||
DEFAULT_INPUT_BLEND_OP_ALPHA,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_INPUT_BLEND_SRC_RGB,
|
||||
|
@ -347,7 +362,8 @@ gst_d3d11_compositor_bin_input_class_init (GstD3D11CompositorBinInputClass *
|
|||
"Blend factor for source RGB",
|
||||
GST_TYPE_D3D11_COMPOSITOR_BLEND,
|
||||
DEFAULT_INPUT_BLEND_SRC_RGB,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_INPUT_BLEND_SRC_ALPHA,
|
||||
|
@ -356,7 +372,8 @@ gst_d3d11_compositor_bin_input_class_init (GstD3D11CompositorBinInputClass *
|
|||
"Blend factor for source alpha, \"*-color\" values are not allowed",
|
||||
GST_TYPE_D3D11_COMPOSITOR_BLEND,
|
||||
DEFAULT_INPUT_BLEND_SRC_ALPHA,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_INPUT_BLEND_DEST_RGB,
|
||||
|
@ -365,7 +382,8 @@ gst_d3d11_compositor_bin_input_class_init (GstD3D11CompositorBinInputClass *
|
|||
"Blend factor for destination RGB",
|
||||
GST_TYPE_D3D11_COMPOSITOR_BLEND,
|
||||
DEFAULT_INPUT_BLEND_DEST_RGB,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_INPUT_BLEND_DEST_ALPHA,
|
||||
|
@ -375,35 +393,40 @@ gst_d3d11_compositor_bin_input_class_init (GstD3D11CompositorBinInputClass *
|
|||
"\"*-color\" values are not allowed",
|
||||
GST_TYPE_D3D11_COMPOSITOR_BLEND,
|
||||
DEFAULT_INPUT_BLEND_DEST_ALPHA,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INPUT_BLEND_FACTOR_RED,
|
||||
g_param_spec_float ("blend-factor-red", "Blend Factor Red",
|
||||
"Blend factor for red component "
|
||||
"when blend type is \"blend-factor\" or \"inv-blend-factor\"",
|
||||
0.0, 1.0, 1.0,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INPUT_BLEND_FACTOR_GREEN,
|
||||
g_param_spec_float ("blend-factor-green", "Blend Factor Green",
|
||||
"Blend factor for green component "
|
||||
"when blend type is \"blend-factor\" or \"inv-blend-factor\"",
|
||||
0.0, 1.0, 1.0,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INPUT_BLEND_FACTOR_BLUE,
|
||||
g_param_spec_float ("blend-factor-blue", "Blend Factor Blue",
|
||||
"Blend factor for blue component "
|
||||
"when blend type is \"blend-factor\" or \"inv-blend-factor\"",
|
||||
0.0, 1.0, 1.0,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INPUT_BLEND_FACTOR_ALPHA,
|
||||
g_param_spec_float ("blend-factor-alpha", "Blend Factor Alpha",
|
||||
"Blend factor for alpha component "
|
||||
"when blend type is \"blend-factor\" or \"inv-blend-factor\"",
|
||||
0.0, 1.0, 1.0,
|
||||
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
pad_class->set_target =
|
||||
GST_DEBUG_FUNCPTR (gst_d3d11_compositor_bin_input_set_target);
|
||||
|
@ -590,7 +613,8 @@ gst_d3d11_compositor_bin_class_init (GstD3D11CompositorBinClass * klass)
|
|||
g_object_class_install_property (gobject_class, PROP_MIXER,
|
||||
g_param_spec_object ("mixer", "D3D11 mixer element",
|
||||
"The d3d11 mixer chain to use",
|
||||
GST_TYPE_ELEMENT, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
GST_TYPE_ELEMENT,
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
/*GstAggregator */
|
||||
g_object_class_install_property (gobject_class, PROP_LATENCY,
|
||||
|
@ -598,7 +622,8 @@ gst_d3d11_compositor_bin_class_init (GstD3D11CompositorBinClass * klass)
|
|||
"Additional latency in live mode to allow upstream "
|
||||
"to take longer to produce buffers for the current "
|
||||
"position (in nanoseconds)", 0, G_MAXUINT64,
|
||||
DEFAULT_LATENCY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
DEFAULT_LATENCY,
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_MIN_UPSTREAM_LATENCY,
|
||||
g_param_spec_uint64 ("min-upstream-latency", "Buffer latency",
|
||||
|
@ -608,41 +633,46 @@ gst_d3d11_compositor_bin_class_init (GstD3D11CompositorBinClass * klass)
|
|||
"initial source(s). This is only taken into account when larger "
|
||||
"than the actually reported minimum latency. (nanoseconds)",
|
||||
0, G_MAXUINT64,
|
||||
DEFAULT_LATENCY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
DEFAULT_LATENCY,
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_START_TIME_SELECTION,
|
||||
g_param_spec_enum ("start-time-selection", "Start Time Selection",
|
||||
"Decides which start time is output",
|
||||
gst_aggregator_start_time_selection_get_type (),
|
||||
DEFAULT_START_TIME_SELECTION,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_START_TIME,
|
||||
g_param_spec_uint64 ("start-time", "Start Time",
|
||||
"Start time to use if start-time-selection=set", 0,
|
||||
G_MAXUINT64,
|
||||
DEFAULT_START_TIME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
DEFAULT_START_TIME,
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_EMIT_SIGNALS,
|
||||
g_param_spec_boolean ("emit-signals", "Emit signals",
|
||||
"Send signals", DEFAULT_EMIT_SIGNALS,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
/* GstD3D11Compositor */
|
||||
g_object_class_install_property (gobject_class, PROP_ADAPTER,
|
||||
g_param_spec_int ("adapter", "Adapter",
|
||||
"Adapter index for creating device (-1 for default)",
|
||||
-1, G_MAXINT32, DEFAULT_ADAPTER,
|
||||
G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_BACKGROUND,
|
||||
g_param_spec_enum ("background", "Background", "Background type",
|
||||
GST_TYPE_COMPOSITOR_BACKGROUND,
|
||||
DEFAULT_BACKGROUND, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
DEFAULT_BACKGROUND,
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_D3D11_COMPOSITOR_BIN_PAD, 0);
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_D3D11_COMPOSITOR_BIN_INPUT, 0);
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_D3D11_COMPOSITOR_BIN_PAD,
|
||||
(GstPluginAPIFlags) 0);
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_D3D11_COMPOSITOR_BIN_INPUT,
|
||||
(GstPluginAPIFlags) 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -934,14 +964,15 @@ gst_d3d11_compositor_bin_child_proxy_get_child_by_index (GstChildProxy * proxy,
|
|||
|
||||
GST_OBJECT_LOCK (self);
|
||||
/* XXX: not exactly thread safe with ordering */
|
||||
if (index < bin->numchildren) {
|
||||
if ((res = g_list_nth_data (bin->children, index)))
|
||||
if (index < (guint) bin->numchildren) {
|
||||
if ((res = (GObject *) g_list_nth_data (bin->children, index)))
|
||||
gst_object_ref (res);
|
||||
} else {
|
||||
GstD3D11CompositorBinChain *chain;
|
||||
if ((chain =
|
||||
g_list_nth_data (self->input_chains, index - bin->numchildren))) {
|
||||
res = gst_object_ref (chain->ghost_pad);
|
||||
(GstD3D11CompositorBinChain *) g_list_nth_data (self->input_chains,
|
||||
index - bin->numchildren))) {
|
||||
res = (GObject *) gst_object_ref (chain->ghost_pad);
|
||||
}
|
||||
}
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
|
@ -967,7 +998,7 @@ static void
|
|||
gst_d3d11_compositor_bin_child_proxy_init (gpointer g_iface,
|
||||
gpointer iface_data)
|
||||
{
|
||||
GstChildProxyInterface *iface = g_iface;
|
||||
GstChildProxyInterface *iface = (GstChildProxyInterface *) g_iface;
|
||||
|
||||
iface->get_child_by_index =
|
||||
gst_d3d11_compositor_bin_child_proxy_get_child_by_index;
|
|
@ -26,9 +26,10 @@
|
|||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "gstd3d11colorconvert.h"
|
||||
#include "gstd3d11colorconverter.h"
|
||||
#include "gstd3d11convert.h"
|
||||
#include "gstd3d11converter.h"
|
||||
#include "gstd3d11videoprocessor.h"
|
||||
#include "gstd3d11pluginutils.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (gst_d3d11_convert_debug);
|
||||
#define GST_CAT_DEFAULT gst_d3d11_convert_debug
|
||||
|
@ -64,7 +65,7 @@ struct _GstD3D11BaseConvert
|
|||
ID3D11RenderTargetView *render_target_view[GST_VIDEO_MAX_PLANES];
|
||||
guint num_output_view;
|
||||
|
||||
GstD3D11ColorConverter *converter;
|
||||
GstD3D11Converter *converter;
|
||||
GstD3D11VideoProcessor *processor;
|
||||
gboolean processor_in_use;
|
||||
|
||||
|
@ -271,7 +272,8 @@ gst_d3d11_base_convert_class_init (GstD3D11BaseConvertClass * klass)
|
|||
|
||||
bfilter_class->set_info = GST_DEBUG_FUNCPTR (gst_d3d11_base_convert_set_info);
|
||||
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_D3D11_BASE_CONVERT, 0);
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_D3D11_BASE_CONVERT,
|
||||
(GstPluginAPIFlags) 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -285,33 +287,19 @@ gst_d3d11_base_convert_clear_shader_resource (GstD3D11BaseConvert * self)
|
|||
gint i;
|
||||
|
||||
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
|
||||
if (self->shader_resource_view[i]) {
|
||||
ID3D11ShaderResourceView_Release (self->shader_resource_view[i]);
|
||||
self->shader_resource_view[i] = NULL;
|
||||
}
|
||||
|
||||
if (self->render_target_view[i]) {
|
||||
ID3D11RenderTargetView_Release (self->render_target_view[i]);
|
||||
self->render_target_view[i] = NULL;
|
||||
}
|
||||
GST_D3D11_CLEAR_COM (self->shader_resource_view[i]);
|
||||
GST_D3D11_CLEAR_COM (self->render_target_view[i]);
|
||||
}
|
||||
|
||||
self->num_input_view = 0;
|
||||
self->num_output_view = 0;
|
||||
|
||||
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
|
||||
if (self->in_texture[i]) {
|
||||
ID3D11Texture2D_Release (self->in_texture[i]);
|
||||
self->in_texture[i] = NULL;
|
||||
GST_D3D11_CLEAR_COM (self->in_texture[i]);
|
||||
GST_D3D11_CLEAR_COM (self->out_texture[i]);
|
||||
}
|
||||
|
||||
if (self->out_texture[i]) {
|
||||
ID3D11Texture2D_Release (self->out_texture[i]);
|
||||
self->out_texture[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
g_clear_pointer (&self->converter, gst_d3d11_color_converter_free);
|
||||
g_clear_pointer (&self->converter, gst_d3d11_converter_free);
|
||||
g_clear_pointer (&self->processor, gst_d3d11_video_processor_free);
|
||||
|
||||
self->processor_in_use = FALSE;
|
||||
|
@ -402,7 +390,7 @@ score_value (GstBaseTransform * base, const GstVideoFormatInfo * in_info,
|
|||
{
|
||||
const gchar *fname;
|
||||
const GstVideoFormatInfo *t_info;
|
||||
GstVideoFormatFlags in_flags, t_flags;
|
||||
guint in_flags, t_flags;
|
||||
gint loss;
|
||||
|
||||
fname = g_value_get_string (val);
|
||||
|
@ -540,7 +528,7 @@ gst_d3d11_base_convert_fixate_format (GstBaseTransform * trans,
|
|||
static gboolean
|
||||
subsampling_unchanged (GstVideoInfo * in_info, GstVideoInfo * out_info)
|
||||
{
|
||||
gint i;
|
||||
guint i;
|
||||
const GstVideoFormatInfo *in_format, *out_format;
|
||||
|
||||
if (GST_VIDEO_INFO_N_COMPONENTS (in_info) !=
|
||||
|
@ -1124,7 +1112,7 @@ gst_d3d11_base_convert_fixate_caps (GstBaseTransform * base,
|
|||
gst_d3d11_base_convert_fixate_size (base, direction, caps, othercaps);
|
||||
|
||||
if (gst_caps_get_size (othercaps) == 1) {
|
||||
gint i;
|
||||
guint i;
|
||||
const gchar *format_fields[] = { "format", "colorimetry", "chroma-site" };
|
||||
GstStructure *format_struct = gst_caps_get_structure (format, 0);
|
||||
GstStructure *fixated_struct;
|
||||
|
@ -1208,8 +1196,8 @@ gst_d3d11_base_convert_propose_allocation (GstBaseTransform * trans,
|
|||
|
||||
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
|
||||
if (!d3d11_params) {
|
||||
d3d11_params = gst_d3d11_allocation_params_new (filter->device, &info, 0,
|
||||
D3D11_BIND_SHADER_RESOURCE);
|
||||
d3d11_params = gst_d3d11_allocation_params_new (filter->device, &info,
|
||||
(GstD3D11AllocationFlags) 0, D3D11_BIND_SHADER_RESOURCE);
|
||||
} else {
|
||||
/* Set bind flag */
|
||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&info); i++) {
|
||||
|
@ -1258,7 +1246,7 @@ gst_d3d11_base_convert_decide_allocation (GstBaseTransform * trans,
|
|||
GstD3D11AllocationParams *d3d11_params;
|
||||
gboolean update_pool = FALSE;
|
||||
GstVideoInfo info;
|
||||
gint i;
|
||||
guint i;
|
||||
|
||||
gst_query_parse_allocation (query, &outcaps, NULL);
|
||||
|
||||
|
@ -1288,7 +1276,8 @@ gst_d3d11_base_convert_decide_allocation (GstBaseTransform * trans,
|
|||
|
||||
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
|
||||
if (!d3d11_params) {
|
||||
d3d11_params = gst_d3d11_allocation_params_new (filter->device, &info, 0,
|
||||
d3d11_params = gst_d3d11_allocation_params_new (filter->device, &info,
|
||||
(GstD3D11AllocationFlags) 0,
|
||||
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET);
|
||||
} else {
|
||||
/* Set bind flag */
|
||||
|
@ -1321,8 +1310,8 @@ static gboolean
|
|||
create_shader_input_resource (GstD3D11BaseConvert * self,
|
||||
GstD3D11Device * device, const GstD3D11Format * format, GstVideoInfo * info)
|
||||
{
|
||||
D3D11_TEXTURE2D_DESC texture_desc = { 0, };
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC view_desc = { 0 };
|
||||
D3D11_TEXTURE2D_DESC texture_desc;
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC view_desc;
|
||||
HRESULT hr;
|
||||
ID3D11Device *device_handle;
|
||||
ID3D11Texture2D *tex[GST_VIDEO_MAX_PLANES] = { NULL, };
|
||||
|
@ -1332,6 +1321,9 @@ create_shader_input_resource (GstD3D11BaseConvert * self,
|
|||
if (self->num_input_view)
|
||||
return TRUE;
|
||||
|
||||
memset (&texture_desc, 0, sizeof (texture_desc));
|
||||
memset (&view_desc, 0, sizeof (view_desc));
|
||||
|
||||
device_handle = gst_d3d11_device_get_device_handle (device);
|
||||
|
||||
texture_desc.MipLevels = 1;
|
||||
|
@ -1350,8 +1342,7 @@ create_shader_input_resource (GstD3D11BaseConvert * self,
|
|||
texture_desc.Height = GST_VIDEO_INFO_COMP_HEIGHT (info, i);
|
||||
texture_desc.Format = format->resource_format[i];
|
||||
|
||||
hr = ID3D11Device_CreateTexture2D (device_handle,
|
||||
&texture_desc, NULL, &tex[i]);
|
||||
hr = device_handle->CreateTexture2D (&texture_desc, NULL, &tex[i]);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR_OBJECT (self, "Failed to create texture (0x%x)", (guint) hr);
|
||||
goto error;
|
||||
|
@ -1375,15 +1366,14 @@ create_shader_input_resource (GstD3D11BaseConvert * self,
|
|||
texture_desc.Height = GST_ROUND_UP_2 (texture_desc.Height);
|
||||
}
|
||||
|
||||
hr = ID3D11Device_CreateTexture2D (device_handle,
|
||||
&texture_desc, NULL, &tex[0]);
|
||||
hr = device_handle->CreateTexture2D (&texture_desc, NULL, &tex[0]);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR_OBJECT (self, "Failed to create texture (0x%x)", (guint) hr);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (is_semiplanar) {
|
||||
ID3D11Resource_AddRef (tex[0]);
|
||||
tex[0]->AddRef ();
|
||||
tex[1] = tex[0];
|
||||
}
|
||||
}
|
||||
|
@ -1396,8 +1386,7 @@ create_shader_input_resource (GstD3D11BaseConvert * self,
|
|||
break;
|
||||
|
||||
view_desc.Format = format->resource_format[i];
|
||||
hr = ID3D11Device_CreateShaderResourceView (device_handle,
|
||||
(ID3D11Resource *) tex[i], &view_desc, &view[i]);
|
||||
hr = device_handle->CreateShaderResourceView (tex[i], &view_desc, &view[i]);
|
||||
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR_OBJECT (self,
|
||||
|
@ -1420,13 +1409,11 @@ create_shader_input_resource (GstD3D11BaseConvert * self,
|
|||
|
||||
error:
|
||||
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
|
||||
if (view[i])
|
||||
ID3D11ShaderResourceView_Release (view[i]);
|
||||
GST_D3D11_CLEAR_COM (view[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
|
||||
if (tex[i])
|
||||
ID3D11Texture2D_Release (tex[i]);
|
||||
GST_D3D11_CLEAR_COM (tex[i]);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@ -1452,7 +1439,7 @@ clear_rtv_color_rgb (GstD3D11BaseConvert * self,
|
|||
else
|
||||
target = clear_color_limited;
|
||||
|
||||
ID3D11DeviceContext_ClearRenderTargetView (context_handle, rtv, target);
|
||||
context_handle->ClearRenderTargetView (rtv, target);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -1470,7 +1457,7 @@ clear_rtv_color_vuya (GstD3D11BaseConvert * self,
|
|||
else
|
||||
target = clear_color_limited;
|
||||
|
||||
ID3D11DeviceContext_ClearRenderTargetView (context_handle, rtv, target);
|
||||
context_handle->ClearRenderTargetView (rtv, target);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -1490,7 +1477,7 @@ clear_rtv_color_luma (GstD3D11BaseConvert * self,
|
|||
else
|
||||
target = clear_color_limited;
|
||||
|
||||
ID3D11DeviceContext_ClearRenderTargetView (context_handle, rtv, target);
|
||||
context_handle->ClearRenderTargetView (rtv, target);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -1499,7 +1486,7 @@ clear_rtv_color_chroma (GstD3D11BaseConvert * self,
|
|||
{
|
||||
const FLOAT clear_color[4] = { 0.5f, 0.5f, 0.5f, 1.0f };
|
||||
|
||||
ID3D11DeviceContext_ClearRenderTargetView (context_handle, rtv, clear_color);
|
||||
context_handle->ClearRenderTargetView (rtv, clear_color);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1533,8 +1520,8 @@ static gboolean
|
|||
create_shader_output_resource (GstD3D11BaseConvert * self,
|
||||
GstD3D11Device * device, const GstD3D11Format * format, GstVideoInfo * info)
|
||||
{
|
||||
D3D11_TEXTURE2D_DESC texture_desc = { 0, };
|
||||
D3D11_RENDER_TARGET_VIEW_DESC view_desc = { 0, };
|
||||
D3D11_TEXTURE2D_DESC texture_desc;
|
||||
D3D11_RENDER_TARGET_VIEW_DESC view_desc;
|
||||
HRESULT hr;
|
||||
ID3D11Device *device_handle;
|
||||
ID3D11DeviceContext *context_handle;
|
||||
|
@ -1545,6 +1532,9 @@ create_shader_output_resource (GstD3D11BaseConvert * self,
|
|||
if (self->num_output_view)
|
||||
return TRUE;
|
||||
|
||||
memset (&texture_desc, 0, sizeof (texture_desc));
|
||||
memset (&view_desc, 0, sizeof (view_desc));
|
||||
|
||||
device_handle = gst_d3d11_device_get_device_handle (device);
|
||||
context_handle = gst_d3d11_device_get_device_context_handle (device);
|
||||
|
||||
|
@ -1565,8 +1555,7 @@ create_shader_output_resource (GstD3D11BaseConvert * self,
|
|||
texture_desc.Height = GST_VIDEO_INFO_COMP_HEIGHT (info, i);
|
||||
texture_desc.Format = format->resource_format[i];
|
||||
|
||||
hr = ID3D11Device_CreateTexture2D (device_handle,
|
||||
&texture_desc, NULL, &tex[i]);
|
||||
hr = device_handle->CreateTexture2D (&texture_desc, NULL, &tex[i]);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR_OBJECT (self, "Failed to create texture (0x%x)", (guint) hr);
|
||||
goto error;
|
||||
|
@ -1590,15 +1579,14 @@ create_shader_output_resource (GstD3D11BaseConvert * self,
|
|||
texture_desc.Height = GST_ROUND_UP_2 (texture_desc.Height);
|
||||
}
|
||||
|
||||
hr = ID3D11Device_CreateTexture2D (device_handle,
|
||||
&texture_desc, NULL, &tex[0]);
|
||||
hr = device_handle->CreateTexture2D (&texture_desc, NULL, &tex[0]);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR_OBJECT (self, "Failed to create texture (0x%x)", (guint) hr);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (is_semiplanar) {
|
||||
ID3D11Resource_AddRef (tex[0]);
|
||||
tex[0]->AddRef ();
|
||||
tex[1] = tex[0];
|
||||
}
|
||||
}
|
||||
|
@ -1610,8 +1598,7 @@ create_shader_output_resource (GstD3D11BaseConvert * self,
|
|||
break;
|
||||
|
||||
view_desc.Format = format->resource_format[i];
|
||||
hr = ID3D11Device_CreateRenderTargetView (device_handle,
|
||||
(ID3D11Resource *) tex[i], &view_desc, &view[i]);
|
||||
hr = device_handle->CreateRenderTargetView (tex[i], &view_desc, &view[i]);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR_OBJECT (self,
|
||||
"Failed to create %dth render target view (0x%x)", i, (guint) hr);
|
||||
|
@ -1636,13 +1623,11 @@ create_shader_output_resource (GstD3D11BaseConvert * self,
|
|||
|
||||
error:
|
||||
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
|
||||
if (view[i])
|
||||
ID3D11RenderTargetView_Release (view[i]);
|
||||
GST_D3D11_CLEAR_COM (view[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
|
||||
if (tex[i])
|
||||
ID3D11Texture2D_Release (tex[i]);
|
||||
GST_D3D11_CLEAR_COM (tex[i]);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@ -1732,8 +1717,7 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter,
|
|||
goto format_unknown;
|
||||
}
|
||||
|
||||
self->converter = gst_d3d11_color_converter_new (filter->device,
|
||||
in_info, out_info);
|
||||
self->converter = gst_d3d11_converter_new (filter->device, in_info, out_info);
|
||||
|
||||
if (!self->converter) {
|
||||
GST_ERROR_OBJECT (self, "couldn't set converter");
|
||||
|
@ -1832,7 +1816,7 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter,
|
|||
view_port.MinDepth = 0.0f;
|
||||
view_port.MaxDepth = 1.0f;
|
||||
|
||||
gst_d3d11_color_converter_update_viewport (self->converter, &view_port);
|
||||
gst_d3d11_converter_update_viewport (self->converter, &view_port);
|
||||
|
||||
return TRUE;
|
||||
|
||||
|
@ -1967,7 +1951,7 @@ gst_d3d11_base_convert_transform (GstBaseTransform * trans,
|
|||
ID3D11ShaderResourceView *resource_view[GST_VIDEO_MAX_PLANES] = { NULL, };
|
||||
ID3D11RenderTargetView *render_view[GST_VIDEO_MAX_PLANES] = { NULL, };
|
||||
ID3D11RenderTargetView **target_rtv;
|
||||
gint i;
|
||||
guint i;
|
||||
gboolean copy_input = FALSE;
|
||||
gboolean copy_output = FALSE;
|
||||
GstMapInfo in_map[GST_VIDEO_MAX_PLANES];
|
||||
|
@ -2027,7 +2011,7 @@ gst_d3d11_base_convert_transform (GstBaseTransform * trans,
|
|||
subidx = gst_d3d11_memory_get_subresource_index (mem);
|
||||
gst_d3d11_memory_get_texture_desc (mem, &src_desc);
|
||||
|
||||
ID3D11Texture2D_GetDesc (self->in_texture[i], &dst_desc);
|
||||
self->in_texture[i]->GetDesc (&dst_desc);
|
||||
|
||||
src_box.left = 0;
|
||||
src_box.top = 0;
|
||||
|
@ -2036,8 +2020,7 @@ gst_d3d11_base_convert_transform (GstBaseTransform * trans,
|
|||
src_box.right = MIN (src_desc.Width, dst_desc.Width);
|
||||
src_box.bottom = MIN (src_desc.Height, dst_desc.Height);
|
||||
|
||||
ID3D11DeviceContext_CopySubresourceRegion (context_handle,
|
||||
(ID3D11Resource *) self->in_texture[i], 0, 0, 0, 0,
|
||||
context_handle->CopySubresourceRegion (self->in_texture[i], 0, 0, 0, 0,
|
||||
(ID3D11Resource *) in_map[i].data, subidx, &src_box);
|
||||
}
|
||||
gst_d3d11_device_unlock (device);
|
||||
|
@ -2070,7 +2053,7 @@ gst_d3d11_base_convert_transform (GstBaseTransform * trans,
|
|||
gst_d3d11_device_unlock (device);
|
||||
}
|
||||
|
||||
if (!gst_d3d11_color_converter_convert (self->converter,
|
||||
if (!gst_d3d11_converter_convert (self->converter,
|
||||
copy_input ? self->shader_resource_view : resource_view,
|
||||
target_rtv, NULL, NULL)) {
|
||||
goto conversion_failed;
|
||||
|
@ -2086,7 +2069,7 @@ gst_d3d11_base_convert_transform (GstBaseTransform * trans,
|
|||
D3D11_TEXTURE2D_DESC src_desc;
|
||||
D3D11_TEXTURE2D_DESC dst_desc;
|
||||
|
||||
ID3D11Texture2D_GetDesc (self->out_texture[i], &src_desc);
|
||||
self->out_texture[i]->GetDesc (&src_desc);
|
||||
subidx = gst_d3d11_memory_get_subresource_index (mem);
|
||||
gst_d3d11_memory_get_texture_desc (mem, &dst_desc);
|
||||
|
||||
|
@ -2097,9 +2080,8 @@ gst_d3d11_base_convert_transform (GstBaseTransform * trans,
|
|||
src_box.right = MIN (src_desc.Width, dst_desc.Width);
|
||||
src_box.bottom = MIN (src_desc.Height, dst_desc.Height);
|
||||
|
||||
ID3D11DeviceContext_CopySubresourceRegion (context_handle,
|
||||
(ID3D11Resource *) out_map[i].data, subidx, 0, 0, 0,
|
||||
(ID3D11Resource *) self->out_texture[i], 0, &src_box);
|
||||
context_handle->CopySubresourceRegion ((ID3D11Resource *) out_map[i].data,
|
||||
subidx, 0, 0, 0, self->out_texture[i], 0, &src_box);
|
||||
}
|
||||
gst_d3d11_device_unlock (device);
|
||||
}
|
|
@ -22,13 +22,22 @@
|
|||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "gstd3d11colorconverter.h"
|
||||
#include "gstd3d11converter.h"
|
||||
#include "gstd3d11shader.h"
|
||||
|
||||
#include "gstd3d11pluginutils.h"
|
||||
#include <wrl.h>
|
||||
#include <string.h>
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_colorconverter_debug);
|
||||
#define GST_CAT_DEFAULT gst_d3d11_colorconverter_debug
|
||||
/* *INDENT-OFF* */
|
||||
using namespace Microsoft::WRL;
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_converter_debug);
|
||||
#define GST_CAT_DEFAULT gst_d3d11_converter_debug
|
||||
|
||||
G_END_DECLS
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#define CONVERTER_MAX_QUADS 2
|
||||
|
||||
|
@ -317,7 +326,7 @@ typedef struct
|
|||
PixelShaderColorTransform transform;
|
||||
} ConvertInfo;
|
||||
|
||||
struct _GstD3D11ColorConverter
|
||||
struct _GstD3D11Converter
|
||||
{
|
||||
GstD3D11Device *device;
|
||||
GstVideoInfo in_info;
|
||||
|
@ -419,7 +428,7 @@ color_matrix_scale_components (MatrixData * m, gfloat a1, gfloat a2, gfloat a3)
|
|||
}
|
||||
|
||||
static void
|
||||
color_matrix_debug (GstD3D11ColorConverter * self, const MatrixData * s)
|
||||
color_matrix_debug (GstD3D11Converter * self, const MatrixData * s)
|
||||
{
|
||||
GST_DEBUG ("[%f %f %f %f]",
|
||||
s->dm[0][0], s->dm[0][1], s->dm[0][2], s->dm[0][3]);
|
||||
|
@ -480,7 +489,7 @@ color_matrix_RGB_to_YCbCr (MatrixData * m, gfloat Kr, gfloat Kb)
|
|||
}
|
||||
|
||||
static void
|
||||
compute_matrix_to_RGB (GstD3D11ColorConverter * self, MatrixData * data,
|
||||
compute_matrix_to_RGB (GstD3D11Converter * self, MatrixData * data,
|
||||
GstVideoInfo * info)
|
||||
{
|
||||
gdouble Kr = 0, Kb = 0;
|
||||
|
@ -503,7 +512,7 @@ compute_matrix_to_RGB (GstD3D11ColorConverter * self, MatrixData * data,
|
|||
}
|
||||
|
||||
static void
|
||||
compute_matrix_to_YUV (GstD3D11ColorConverter * self, MatrixData * data,
|
||||
compute_matrix_to_YUV (GstD3D11Converter * self, MatrixData * data,
|
||||
GstVideoInfo * info)
|
||||
{
|
||||
gdouble Kr = 0, Kb = 0;
|
||||
|
@ -527,7 +536,7 @@ compute_matrix_to_YUV (GstD3D11ColorConverter * self, MatrixData * data,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
converter_get_matrix (GstD3D11ColorConverter * self, MatrixData * matrix,
|
||||
converter_get_matrix (GstD3D11Converter * self, MatrixData * matrix,
|
||||
GstVideoInfo * in_info, GstVideoInfo * out_info)
|
||||
{
|
||||
gboolean same_matrix;
|
||||
|
@ -577,7 +586,7 @@ converter_get_matrix (GstD3D11ColorConverter * self, MatrixData * matrix,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
setup_convert_info_rgb_to_rgb (GstD3D11ColorConverter * self,
|
||||
setup_convert_info_rgb_to_rgb (GstD3D11Converter * self,
|
||||
const GstVideoInfo * in_info, const GstVideoInfo * out_info)
|
||||
{
|
||||
ConvertInfo *convert_info = &self->convert_info;
|
||||
|
@ -590,7 +599,7 @@ setup_convert_info_rgb_to_rgb (GstD3D11ColorConverter * self,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
get_packed_yuv_components (GstD3D11ColorConverter * self, GstVideoFormat
|
||||
get_packed_yuv_components (GstD3D11Converter * self, GstVideoFormat
|
||||
format, gchar * y, gchar * u, gchar * v)
|
||||
{
|
||||
switch (format) {
|
||||
|
@ -646,7 +655,7 @@ get_packed_yuv_components (GstD3D11ColorConverter * self, GstVideoFormat
|
|||
}
|
||||
|
||||
static gboolean
|
||||
setup_convert_info_yuv_to_rgb (GstD3D11ColorConverter * self,
|
||||
setup_convert_info_yuv_to_rgb (GstD3D11Converter * self,
|
||||
const GstVideoInfo * in_info, const GstVideoInfo * out_info)
|
||||
{
|
||||
ConvertInfo *info = &self->convert_info;
|
||||
|
@ -698,7 +707,7 @@ setup_convert_info_yuv_to_rgb (GstD3D11ColorConverter * self,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
setup_convert_info_rgb_to_yuv (GstD3D11ColorConverter * self,
|
||||
setup_convert_info_rgb_to_yuv (GstD3D11Converter * self,
|
||||
const GstVideoInfo * in_info, const GstVideoInfo * out_info)
|
||||
{
|
||||
ConvertInfo *info = &self->convert_info;
|
||||
|
@ -740,7 +749,7 @@ setup_convert_info_rgb_to_yuv (GstD3D11ColorConverter * self,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
setup_convert_info_planar_to_planar (GstD3D11ColorConverter * self,
|
||||
setup_convert_info_planar_to_planar (GstD3D11Converter * self,
|
||||
const GstVideoInfo * in_info, const GstVideoInfo * out_info)
|
||||
{
|
||||
ConvertInfo *info = &self->convert_info;
|
||||
|
@ -765,7 +774,7 @@ setup_convert_info_planar_to_planar (GstD3D11ColorConverter * self,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
setup_convert_info_planar_to_semi_planar (GstD3D11ColorConverter * self,
|
||||
setup_convert_info_planar_to_semi_planar (GstD3D11Converter * self,
|
||||
const GstVideoInfo * in_info, const GstVideoInfo * out_info)
|
||||
{
|
||||
ConvertInfo *info = &self->convert_info;
|
||||
|
@ -787,7 +796,7 @@ setup_convert_info_planar_to_semi_planar (GstD3D11ColorConverter * self,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
setup_convert_info_semi_planar_to_planar (GstD3D11ColorConverter * self,
|
||||
setup_convert_info_semi_planar_to_planar (GstD3D11Converter * self,
|
||||
const GstVideoInfo * in_info, const GstVideoInfo * out_info)
|
||||
{
|
||||
ConvertInfo *info = &self->convert_info;
|
||||
|
@ -809,7 +818,7 @@ setup_convert_info_semi_planar_to_planar (GstD3D11ColorConverter * self,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
setup_convert_info_semi_planar_to_semi_planar (GstD3D11ColorConverter * self,
|
||||
setup_convert_info_semi_planar_to_semi_planar (GstD3D11Converter * self,
|
||||
const GstVideoInfo * in_info, const GstVideoInfo * out_info)
|
||||
{
|
||||
ConvertInfo *info = &self->convert_info;
|
||||
|
@ -828,7 +837,7 @@ setup_convert_info_semi_planar_to_semi_planar (GstD3D11ColorConverter * self,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
setup_convert_info_vuya_to_vuya (GstD3D11ColorConverter * self,
|
||||
setup_convert_info_vuya_to_vuya (GstD3D11Converter * self,
|
||||
const GstVideoInfo * in_info, const GstVideoInfo * out_info)
|
||||
{
|
||||
ConvertInfo *info = &self->convert_info;
|
||||
|
@ -842,7 +851,7 @@ setup_convert_info_vuya_to_vuya (GstD3D11ColorConverter * self,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
setup_convert_info_vuya_to_planar (GstD3D11ColorConverter * self,
|
||||
setup_convert_info_vuya_to_planar (GstD3D11Converter * self,
|
||||
const GstVideoInfo * in_info, const GstVideoInfo * out_info)
|
||||
{
|
||||
ConvertInfo *info = &self->convert_info;
|
||||
|
@ -863,7 +872,7 @@ setup_convert_info_vuya_to_planar (GstD3D11ColorConverter * self,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
setup_convert_info_vuya_to_semi_planar (GstD3D11ColorConverter * self,
|
||||
setup_convert_info_vuya_to_semi_planar (GstD3D11Converter * self,
|
||||
const GstVideoInfo * in_info, const GstVideoInfo * out_info)
|
||||
{
|
||||
ConvertInfo *info = &self->convert_info;
|
||||
|
@ -880,7 +889,7 @@ setup_convert_info_vuya_to_semi_planar (GstD3D11ColorConverter * self,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
setup_convert_info_planar_to_vuya (GstD3D11ColorConverter * self,
|
||||
setup_convert_info_planar_to_vuya (GstD3D11Converter * self,
|
||||
const GstVideoInfo * in_info, const GstVideoInfo * out_info)
|
||||
{
|
||||
ConvertInfo *info = &self->convert_info;
|
||||
|
@ -898,7 +907,7 @@ setup_convert_info_planar_to_vuya (GstD3D11ColorConverter * self,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
setup_convert_info_packed_yuv_to_vuya (GstD3D11ColorConverter * self,
|
||||
setup_convert_info_packed_yuv_to_vuya (GstD3D11Converter * self,
|
||||
const GstVideoInfo * in_info, const GstVideoInfo * out_info)
|
||||
{
|
||||
ConvertInfo *info = &self->convert_info;
|
||||
|
@ -918,7 +927,7 @@ setup_convert_info_packed_yuv_to_vuya (GstD3D11ColorConverter * self,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
setup_convert_info_semi_planar_to_vuya (GstD3D11ColorConverter * self,
|
||||
setup_convert_info_semi_planar_to_vuya (GstD3D11Converter * self,
|
||||
const GstVideoInfo * in_info, const GstVideoInfo * out_info)
|
||||
{
|
||||
ConvertInfo *info = &self->convert_info;
|
||||
|
@ -932,7 +941,7 @@ setup_convert_info_semi_planar_to_vuya (GstD3D11ColorConverter * self,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
setup_convert_info_packed_yuv_to_planar (GstD3D11ColorConverter * self,
|
||||
setup_convert_info_packed_yuv_to_planar (GstD3D11Converter * self,
|
||||
const GstVideoInfo * in_info, const GstVideoInfo * out_info)
|
||||
{
|
||||
ConvertInfo *info = &self->convert_info;
|
||||
|
@ -959,7 +968,7 @@ setup_convert_info_packed_yuv_to_planar (GstD3D11ColorConverter * self,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
setup_convert_info_packed_yuv_to_semi_planar (GstD3D11ColorConverter * self,
|
||||
setup_convert_info_packed_yuv_to_semi_planar (GstD3D11Converter * self,
|
||||
const GstVideoInfo * in_info, const GstVideoInfo * out_info)
|
||||
{
|
||||
ConvertInfo *info = &self->convert_info;
|
||||
|
@ -983,7 +992,7 @@ setup_convert_info_packed_yuv_to_semi_planar (GstD3D11ColorConverter * self,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
setup_convert_info_yuv_to_yuv (GstD3D11ColorConverter * self,
|
||||
setup_convert_info_yuv_to_yuv (GstD3D11Converter * self,
|
||||
const GstVideoInfo * in_info, const GstVideoInfo * out_info)
|
||||
{
|
||||
gboolean in_planar, out_planar;
|
||||
|
@ -1042,29 +1051,35 @@ setup_convert_info_yuv_to_yuv (GstD3D11ColorConverter * self,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_d3d11_color_convert_setup_shader (GstD3D11ColorConverter * self,
|
||||
gst_d3d11_color_convert_setup_shader (GstD3D11Converter * self,
|
||||
GstD3D11Device * device, GstVideoInfo * in_info, GstVideoInfo * out_info)
|
||||
{
|
||||
HRESULT hr;
|
||||
D3D11_SAMPLER_DESC sampler_desc = { 0, };
|
||||
D3D11_INPUT_ELEMENT_DESC input_desc[2] = { 0, };
|
||||
D3D11_BUFFER_DESC buffer_desc = { 0, };
|
||||
D3D11_SAMPLER_DESC sampler_desc;
|
||||
D3D11_INPUT_ELEMENT_DESC input_desc[2];
|
||||
D3D11_BUFFER_DESC buffer_desc;
|
||||
D3D11_MAPPED_SUBRESOURCE map;
|
||||
VertexData *vertex_data;
|
||||
WORD *indices;
|
||||
ID3D11Device *device_handle;
|
||||
ID3D11DeviceContext *context_handle;
|
||||
ConvertInfo *convert_info = &self->convert_info;
|
||||
ID3D11PixelShader *ps[CONVERTER_MAX_QUADS] = { NULL, NULL };
|
||||
ID3D11VertexShader *vs = NULL;
|
||||
ID3D11InputLayout *layout = NULL;
|
||||
ID3D11SamplerState *sampler = NULL;
|
||||
ID3D11Buffer *const_buffer = NULL;
|
||||
ID3D11Buffer *vertex_buffer = NULL;
|
||||
ID3D11Buffer *index_buffer = NULL;
|
||||
/* *INDENT-OFF* */
|
||||
ComPtr<ID3D11PixelShader> ps[CONVERTER_MAX_QUADS];
|
||||
ComPtr<ID3D11VertexShader> vs;
|
||||
ComPtr<ID3D11InputLayout> layout;
|
||||
ComPtr<ID3D11SamplerState> sampler;
|
||||
ComPtr<ID3D11Buffer> const_buffer;
|
||||
ComPtr<ID3D11Buffer> vertex_buffer;
|
||||
ComPtr<ID3D11Buffer> index_buffer;
|
||||
/* *INDENT-ON* */
|
||||
const guint index_count = 2 * 3;
|
||||
gboolean ret = TRUE;
|
||||
gint i;
|
||||
gboolean ret;
|
||||
|
||||
memset (&sampler_desc, 0, sizeof (sampler_desc));
|
||||
memset (input_desc, 0, sizeof (input_desc));
|
||||
memset (&buffer_desc, 0, sizeof (buffer_desc));
|
||||
|
||||
device_handle = gst_d3d11_device_get_device_handle (device);
|
||||
context_handle = gst_d3d11_device_get_device_context_handle (device);
|
||||
|
@ -1078,11 +1093,10 @@ gst_d3d11_color_convert_setup_shader (GstD3D11ColorConverter * self,
|
|||
sampler_desc.MinLOD = 0;
|
||||
sampler_desc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
|
||||
hr = ID3D11Device_CreateSamplerState (device_handle, &sampler_desc, &sampler);
|
||||
hr = device_handle->CreateSamplerState (&sampler_desc, &sampler);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("Couldn't create sampler state, hr: 0x%x", (guint) hr);
|
||||
ret = FALSE;
|
||||
goto clear;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; i < CONVERTER_MAX_QUADS; i++) {
|
||||
|
@ -1101,8 +1115,7 @@ gst_d3d11_color_convert_setup_shader (GstD3D11ColorConverter * self,
|
|||
ret = gst_d3d11_create_pixel_shader (device, shader_code, &ps[i]);
|
||||
g_free (shader_code);
|
||||
if (!ret) {
|
||||
GST_ERROR ("Couldn't create pixel shader");
|
||||
goto clear;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1117,31 +1130,26 @@ gst_d3d11_color_convert_setup_shader (GstD3D11ColorConverter * self,
|
|||
const_buffer_desc.MiscFlags = 0;
|
||||
const_buffer_desc.StructureByteStride = 0;
|
||||
|
||||
hr = ID3D11Device_CreateBuffer (device_handle, &const_buffer_desc, NULL,
|
||||
&const_buffer);
|
||||
|
||||
hr = device_handle->CreateBuffer (&const_buffer_desc, NULL, &const_buffer);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("Couldn't create constant buffer, hr: 0x%x", (guint) hr);
|
||||
ret = FALSE;
|
||||
goto clear;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gst_d3d11_device_lock (device);
|
||||
hr = ID3D11DeviceContext_Map (context_handle,
|
||||
(ID3D11Resource *) const_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
||||
hr = context_handle->Map (const_buffer.Get (),
|
||||
0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
||||
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("Couldn't map constant buffer, hr: 0x%x", (guint) hr);
|
||||
gst_d3d11_device_unlock (device);
|
||||
ret = FALSE;
|
||||
goto clear;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
memcpy (map.pData, &convert_info->transform,
|
||||
sizeof (PixelShaderColorTransform));
|
||||
|
||||
ID3D11DeviceContext_Unmap (context_handle,
|
||||
(ID3D11Resource *) const_buffer, 0);
|
||||
context_handle->Unmap (const_buffer.Get (), 0);
|
||||
gst_d3d11_device_unlock (device);
|
||||
}
|
||||
|
||||
|
@ -1164,8 +1172,7 @@ gst_d3d11_color_convert_setup_shader (GstD3D11ColorConverter * self,
|
|||
if (!gst_d3d11_create_vertex_shader (device, templ_vertex_shader,
|
||||
input_desc, G_N_ELEMENTS (input_desc), &vs, &layout)) {
|
||||
GST_ERROR ("Couldn't vertex pixel shader");
|
||||
ret = FALSE;
|
||||
goto clear;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* setup vertext buffer and index buffer */
|
||||
|
@ -1174,13 +1181,10 @@ gst_d3d11_color_convert_setup_shader (GstD3D11ColorConverter * self,
|
|||
buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
|
||||
hr = ID3D11Device_CreateBuffer (device_handle, &buffer_desc, NULL,
|
||||
&vertex_buffer);
|
||||
|
||||
hr = device_handle->CreateBuffer (&buffer_desc, NULL, &vertex_buffer);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("Couldn't create vertex buffer, hr: 0x%x", (guint) hr);
|
||||
ret = FALSE;
|
||||
goto clear;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
|
@ -1188,38 +1192,30 @@ gst_d3d11_color_convert_setup_shader (GstD3D11ColorConverter * self,
|
|||
buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||
buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
|
||||
hr = ID3D11Device_CreateBuffer (device_handle, &buffer_desc, NULL,
|
||||
&index_buffer);
|
||||
|
||||
hr = device_handle->CreateBuffer (&buffer_desc, NULL, &index_buffer);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("Couldn't create index buffer, hr: 0x%x", (guint) hr);
|
||||
ret = FALSE;
|
||||
goto clear;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gst_d3d11_device_lock (device);
|
||||
hr = ID3D11DeviceContext_Map (context_handle,
|
||||
(ID3D11Resource *) vertex_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
||||
|
||||
hr = context_handle->Map (vertex_buffer.Get (), 0, D3D11_MAP_WRITE_DISCARD, 0,
|
||||
&map);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("Couldn't map vertex buffer, hr: 0x%x", (guint) hr);
|
||||
gst_d3d11_device_unlock (device);
|
||||
ret = FALSE;
|
||||
goto clear;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
vertex_data = (VertexData *) map.pData;
|
||||
|
||||
hr = ID3D11DeviceContext_Map (context_handle,
|
||||
(ID3D11Resource *) index_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
||||
|
||||
hr = context_handle->Map (index_buffer.Get (), 0, D3D11_MAP_WRITE_DISCARD, 0,
|
||||
&map);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("Couldn't map index buffer, hr: 0x%x", (guint) hr);
|
||||
ID3D11DeviceContext_Unmap (context_handle,
|
||||
(ID3D11Resource *) vertex_buffer, 0);
|
||||
context_handle->Unmap (vertex_buffer.Get (), 0);
|
||||
gst_d3d11_device_unlock (device);
|
||||
ret = FALSE;
|
||||
goto clear;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
indices = (WORD *) map.pData;
|
||||
|
@ -1261,28 +1257,27 @@ gst_d3d11_color_convert_setup_shader (GstD3D11ColorConverter * self,
|
|||
indices[4] = 0; /* bottom left */
|
||||
indices[5] = 2; /* top right */
|
||||
|
||||
ID3D11DeviceContext_Unmap (context_handle,
|
||||
(ID3D11Resource *) vertex_buffer, 0);
|
||||
ID3D11DeviceContext_Unmap (context_handle,
|
||||
(ID3D11Resource *) index_buffer, 0);
|
||||
context_handle->Unmap (vertex_buffer.Get (), 0);
|
||||
context_handle->Unmap (index_buffer.Get (), 0);
|
||||
gst_d3d11_device_unlock (device);
|
||||
|
||||
self->quad[0] = gst_d3d11_quad_new (device,
|
||||
ps[0], vs, layout, sampler, NULL, NULL, const_buffer, vertex_buffer,
|
||||
sizeof (VertexData), index_buffer, DXGI_FORMAT_R16_UINT, index_count);
|
||||
ps[0].Get (), vs.Get (), layout.Get (), sampler.Get (), NULL, NULL,
|
||||
const_buffer.Get (), vertex_buffer.Get (), sizeof (VertexData),
|
||||
index_buffer.Get (), DXGI_FORMAT_R16_UINT, index_count);
|
||||
|
||||
if (ps[1]) {
|
||||
self->quad[1] = gst_d3d11_quad_new (device,
|
||||
ps[1], vs, layout, sampler, NULL, NULL, const_buffer, vertex_buffer,
|
||||
sizeof (VertexData), index_buffer, DXGI_FORMAT_R16_UINT, index_count);
|
||||
ps[1].Get (), vs.Get (), layout.Get (), sampler.Get (), NULL, NULL,
|
||||
const_buffer.Get (), vertex_buffer.Get (), sizeof (VertexData),
|
||||
index_buffer.Get (), DXGI_FORMAT_R16_UINT, index_count);
|
||||
}
|
||||
|
||||
self->num_input_view = GST_VIDEO_INFO_N_PLANES (in_info);
|
||||
self->num_output_view = GST_VIDEO_INFO_N_PLANES (out_info);
|
||||
|
||||
/* holds vertex buffer for crop rect update */
|
||||
self->vertex_buffer = vertex_buffer;
|
||||
ID3D11Buffer_AddRef (vertex_buffer);
|
||||
self->vertex_buffer = vertex_buffer.Detach ();
|
||||
|
||||
self->src_rect.left = 0;
|
||||
self->src_rect.top = 0;
|
||||
|
@ -1297,29 +1292,11 @@ gst_d3d11_color_convert_setup_shader (GstD3D11ColorConverter * self,
|
|||
self->input_texture_width = GST_VIDEO_INFO_WIDTH (in_info);
|
||||
self->input_texture_height = GST_VIDEO_INFO_HEIGHT (in_info);
|
||||
|
||||
clear:
|
||||
for (i = 0; i < CONVERTER_MAX_QUADS; i++) {
|
||||
if (ps[i])
|
||||
ID3D11PixelShader_Release (ps[i]);
|
||||
}
|
||||
if (vs)
|
||||
ID3D11VertexShader_Release (vs);
|
||||
if (layout)
|
||||
ID3D11InputLayout_Release (layout);
|
||||
if (sampler)
|
||||
ID3D11SamplerState_Release (sampler);
|
||||
if (const_buffer)
|
||||
ID3D11Buffer_Release (const_buffer);
|
||||
if (vertex_buffer)
|
||||
ID3D11Buffer_Release (vertex_buffer);
|
||||
if (index_buffer)
|
||||
ID3D11Buffer_Release (index_buffer);
|
||||
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GstD3D11ColorConverter *
|
||||
gst_d3d11_color_converter_new_internal (GstD3D11Device * device,
|
||||
static GstD3D11Converter *
|
||||
gst_d3d11_converter_new_internal (GstD3D11Device * device,
|
||||
GstVideoInfo * in_info, GstVideoInfo * out_info, gfloat alpha)
|
||||
{
|
||||
const GstVideoInfo *unknown_info;
|
||||
|
@ -1327,9 +1304,9 @@ gst_d3d11_color_converter_new_internal (GstD3D11Device * device,
|
|||
const GstD3D11Format *out_d3d11_format;
|
||||
gboolean is_supported = FALSE;
|
||||
MatrixData matrix;
|
||||
GstD3D11ColorConverter *converter = NULL;
|
||||
GstD3D11Converter *converter = NULL;
|
||||
gboolean ret;
|
||||
gint i;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
|
||||
g_return_val_if_fail (in_info != NULL, NULL);
|
||||
|
@ -1355,8 +1332,8 @@ gst_d3d11_color_converter_new_internal (GstD3D11Device * device,
|
|||
goto format_unknown;
|
||||
}
|
||||
|
||||
converter = g_new0 (GstD3D11ColorConverter, 1);
|
||||
converter->device = gst_object_ref (device);
|
||||
converter = g_new0 (GstD3D11Converter, 1);
|
||||
converter->device = (GstD3D11Device *) gst_object_ref (device);
|
||||
converter->alpha = alpha;
|
||||
|
||||
if (GST_VIDEO_INFO_IS_RGB (in_info)) {
|
||||
|
@ -1413,7 +1390,7 @@ gst_d3d11_color_converter_new_internal (GstD3D11Device * device,
|
|||
|
||||
if (!ret) {
|
||||
GST_ERROR ("Couldn't setup shader");
|
||||
gst_d3d11_color_converter_free (converter);
|
||||
gst_d3d11_converter_free (converter);
|
||||
converter = NULL;
|
||||
} else {
|
||||
converter->in_info = *in_info;
|
||||
|
@ -1434,32 +1411,30 @@ conversion_not_supported:
|
|||
GST_ERROR ("Conversion %s to %s not supported",
|
||||
gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (in_info)),
|
||||
gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (out_info)));
|
||||
gst_d3d11_color_converter_free (converter);
|
||||
gst_d3d11_converter_free (converter);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
GstD3D11ColorConverter *
|
||||
gst_d3d11_color_converter_new (GstD3D11Device * device,
|
||||
GstD3D11Converter *
|
||||
gst_d3d11_converter_new (GstD3D11Device * device,
|
||||
GstVideoInfo * in_info, GstVideoInfo * out_info)
|
||||
{
|
||||
return gst_d3d11_color_converter_new_internal (device, in_info, out_info,
|
||||
1.0f);
|
||||
return gst_d3d11_converter_new_internal (device, in_info, out_info, 1.0f);
|
||||
}
|
||||
|
||||
GstD3D11ColorConverter *
|
||||
gst_d3d11_color_converter_new_with_alpha (GstD3D11Device * device,
|
||||
GstD3D11Converter *
|
||||
gst_d3d11_converter_new_with_alpha (GstD3D11Device * device,
|
||||
GstVideoInfo * in_info, GstVideoInfo * out_info, gfloat alpha)
|
||||
{
|
||||
g_return_val_if_fail (alpha >= 0.0f, NULL);
|
||||
g_return_val_if_fail (alpha <= 1.0f, NULL);
|
||||
|
||||
return gst_d3d11_color_converter_new_internal (device, in_info, out_info,
|
||||
alpha);
|
||||
return gst_d3d11_converter_new_internal (device, in_info, out_info, alpha);
|
||||
}
|
||||
|
||||
void
|
||||
gst_d3d11_color_converter_free (GstD3D11ColorConverter * converter)
|
||||
gst_d3d11_converter_free (GstD3D11Converter * converter)
|
||||
{
|
||||
gint i;
|
||||
|
||||
|
@ -1472,8 +1447,7 @@ gst_d3d11_color_converter_free (GstD3D11ColorConverter * converter)
|
|||
g_free (converter->convert_info.ps_body[i]);
|
||||
}
|
||||
|
||||
if (converter->vertex_buffer)
|
||||
ID3D11Buffer_Release (converter->vertex_buffer);
|
||||
GST_D3D11_CLEAR_COM (converter->vertex_buffer);
|
||||
|
||||
gst_clear_object (&converter->device);
|
||||
g_free (converter);
|
||||
|
@ -1482,7 +1456,7 @@ gst_d3d11_color_converter_free (GstD3D11ColorConverter * converter)
|
|||
/* must be called with gst_d3d11_device_lock since ID3D11DeviceContext is not
|
||||
* thread-safe */
|
||||
static gboolean
|
||||
gst_d3d11_color_converter_update_vertex_buffer (GstD3D11ColorConverter * self)
|
||||
gst_d3d11_converter_update_vertex_buffer (GstD3D11Converter * self)
|
||||
{
|
||||
D3D11_MAPPED_SUBRESOURCE map;
|
||||
VertexData *vertex_data;
|
||||
|
@ -1498,8 +1472,7 @@ gst_d3d11_color_converter_update_vertex_buffer (GstD3D11ColorConverter * self)
|
|||
|
||||
context_handle = gst_d3d11_device_get_device_context_handle (self->device);
|
||||
|
||||
hr = ID3D11DeviceContext_Map (context_handle,
|
||||
(ID3D11Resource *) self->vertex_buffer, 0, D3D11_MAP_WRITE_DISCARD,
|
||||
hr = context_handle->Map (self->vertex_buffer, 0, D3D11_MAP_WRITE_DISCARD,
|
||||
0, &map);
|
||||
|
||||
if (!gst_d3d11_result (hr, self->device)) {
|
||||
|
@ -1566,8 +1539,7 @@ gst_d3d11_color_converter_update_vertex_buffer (GstD3D11ColorConverter * self)
|
|||
vertex_data[3].texture.x = u;
|
||||
vertex_data[3].texture.y = v;
|
||||
|
||||
ID3D11DeviceContext_Unmap (context_handle,
|
||||
(ID3D11Resource *) self->vertex_buffer, 0);
|
||||
context_handle->Unmap (self->vertex_buffer, 0);
|
||||
|
||||
self->update_vertex = FALSE;
|
||||
|
||||
|
@ -1575,7 +1547,7 @@ gst_d3d11_color_converter_update_vertex_buffer (GstD3D11ColorConverter * self)
|
|||
}
|
||||
|
||||
gboolean
|
||||
gst_d3d11_color_converter_convert (GstD3D11ColorConverter * converter,
|
||||
gst_d3d11_converter_convert (GstD3D11Converter * converter,
|
||||
ID3D11ShaderResourceView * srv[GST_VIDEO_MAX_PLANES],
|
||||
ID3D11RenderTargetView * rtv[GST_VIDEO_MAX_PLANES],
|
||||
ID3D11BlendState * blend, gfloat blend_factor[4])
|
||||
|
@ -1587,7 +1559,7 @@ gst_d3d11_color_converter_convert (GstD3D11ColorConverter * converter,
|
|||
g_return_val_if_fail (rtv != NULL, FALSE);
|
||||
|
||||
gst_d3d11_device_lock (converter->device);
|
||||
ret = gst_d3d11_color_converter_convert_unlocked (converter,
|
||||
ret = gst_d3d11_converter_convert_unlocked (converter,
|
||||
srv, rtv, blend, blend_factor);
|
||||
gst_d3d11_device_unlock (converter->device);
|
||||
|
||||
|
@ -1595,13 +1567,16 @@ gst_d3d11_color_converter_convert (GstD3D11ColorConverter * converter,
|
|||
}
|
||||
|
||||
gboolean
|
||||
gst_d3d11_color_converter_convert_unlocked (GstD3D11ColorConverter * converter,
|
||||
gst_d3d11_converter_convert_unlocked (GstD3D11Converter * converter,
|
||||
ID3D11ShaderResourceView * srv[GST_VIDEO_MAX_PLANES],
|
||||
ID3D11RenderTargetView * rtv[GST_VIDEO_MAX_PLANES],
|
||||
ID3D11BlendState * blend, gfloat blend_factor[4])
|
||||
{
|
||||
gboolean ret;
|
||||
ID3D11Resource *resource;
|
||||
/* *INDENT-OFF* */
|
||||
ComPtr<ID3D11Resource> resource;
|
||||
ComPtr<ID3D11Texture2D> texture;
|
||||
/* *INDENT-ON* */
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
|
||||
g_return_val_if_fail (converter != NULL, FALSE);
|
||||
|
@ -1609,20 +1584,20 @@ gst_d3d11_color_converter_convert_unlocked (GstD3D11ColorConverter * converter,
|
|||
g_return_val_if_fail (rtv != NULL, FALSE);
|
||||
|
||||
/* check texture resolution and update crop area */
|
||||
ID3D11ShaderResourceView_GetResource (srv[0], &resource);
|
||||
ID3D11Texture2D_GetDesc ((ID3D11Texture2D *) resource, &desc);
|
||||
ID3D11Resource_Release (resource);
|
||||
srv[0]->GetResource (&resource);
|
||||
resource.As (&texture);
|
||||
texture->GetDesc (&desc);
|
||||
|
||||
if (converter->update_vertex ||
|
||||
desc.Width != converter->input_texture_width ||
|
||||
desc.Height != converter->input_texture_height) {
|
||||
desc.Width != (guint) converter->input_texture_width ||
|
||||
desc.Height != (guint) converter->input_texture_height) {
|
||||
GST_DEBUG ("Update vertext buffer, texture resolution: %dx%d",
|
||||
desc.Width, desc.Height);
|
||||
|
||||
converter->input_texture_width = desc.Width;
|
||||
converter->input_texture_height = desc.Height;
|
||||
|
||||
if (!gst_d3d11_color_converter_update_vertex_buffer (converter)) {
|
||||
if (!gst_d3d11_converter_update_vertex_buffer (converter)) {
|
||||
GST_ERROR ("Cannot update vertex buffer");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1648,7 +1623,7 @@ gst_d3d11_color_converter_convert_unlocked (GstD3D11ColorConverter * converter,
|
|||
}
|
||||
|
||||
gboolean
|
||||
gst_d3d11_color_converter_update_viewport (GstD3D11ColorConverter * converter,
|
||||
gst_d3d11_converter_update_viewport (GstD3D11Converter * converter,
|
||||
D3D11_VIEWPORT * viewport)
|
||||
{
|
||||
g_return_val_if_fail (converter != NULL, FALSE);
|
||||
|
@ -1662,7 +1637,7 @@ gst_d3d11_color_converter_update_viewport (GstD3D11ColorConverter * converter,
|
|||
case GST_VIDEO_FORMAT_P016_LE:
|
||||
case GST_VIDEO_FORMAT_I420:
|
||||
case GST_VIDEO_FORMAT_I420_10LE:{
|
||||
gint i;
|
||||
guint i;
|
||||
converter->viewport[1].TopLeftX = converter->viewport[0].TopLeftX / 2;
|
||||
converter->viewport[1].TopLeftY = converter->viewport[0].TopLeftY / 2;
|
||||
converter->viewport[1].Width = converter->viewport[0].Width / 2;
|
||||
|
@ -1683,7 +1658,7 @@ gst_d3d11_color_converter_update_viewport (GstD3D11ColorConverter * converter,
|
|||
}
|
||||
|
||||
gboolean
|
||||
gst_d3d11_color_converter_update_src_rect (GstD3D11ColorConverter * converter,
|
||||
gst_d3d11_converter_update_src_rect (GstD3D11Converter * converter,
|
||||
RECT * src_rect)
|
||||
{
|
||||
g_return_val_if_fail (converter != NULL, FALSE);
|
||||
|
@ -1703,7 +1678,7 @@ gst_d3d11_color_converter_update_src_rect (GstD3D11ColorConverter * converter,
|
|||
}
|
||||
|
||||
gboolean
|
||||
gst_d3d11_color_converter_update_dest_rect (GstD3D11ColorConverter * converter,
|
||||
gst_d3d11_converter_update_dest_rect (GstD3D11Converter * converter,
|
||||
RECT * dest_rect)
|
||||
{
|
||||
g_return_val_if_fail (converter != NULL, FALSE);
|
65
sys/d3d11/gstd3d11converter.h
Normal file
65
sys/d3d11/gstd3d11converter.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* 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_CONVERTER_H__
|
||||
#define __GST_D3D11_COLOR_CONVERTER_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
#include <gst/d3d11/gstd3d11.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GstD3D11Converter GstD3D11Converter;
|
||||
|
||||
GstD3D11Converter * gst_d3d11_converter_new (GstD3D11Device * device,
|
||||
GstVideoInfo * in_info,
|
||||
GstVideoInfo * out_info);
|
||||
|
||||
GstD3D11Converter * gst_d3d11_converter_new_with_alpha (GstD3D11Device * device,
|
||||
GstVideoInfo * in_info,
|
||||
GstVideoInfo * out_info,
|
||||
gfloat alpha);
|
||||
|
||||
void gst_d3d11_converter_free (GstD3D11Converter * converter);
|
||||
|
||||
gboolean gst_d3d11_converter_convert (GstD3D11Converter * converter,
|
||||
ID3D11ShaderResourceView *srv[GST_VIDEO_MAX_PLANES],
|
||||
ID3D11RenderTargetView *rtv[GST_VIDEO_MAX_PLANES],
|
||||
ID3D11BlendState *blend,
|
||||
gfloat blend_factor[4]);
|
||||
|
||||
gboolean gst_d3d11_converter_convert_unlocked (GstD3D11Converter * converter,
|
||||
ID3D11ShaderResourceView *srv[GST_VIDEO_MAX_PLANES],
|
||||
ID3D11RenderTargetView *rtv[GST_VIDEO_MAX_PLANES],
|
||||
ID3D11BlendState *blend,
|
||||
gfloat blend_factor[4]);
|
||||
|
||||
gboolean gst_d3d11_converter_update_viewport (GstD3D11Converter * converter,
|
||||
D3D11_VIEWPORT * viewport);
|
||||
|
||||
gboolean gst_d3d11_converter_update_src_rect (GstD3D11Converter * converter,
|
||||
RECT * src_rect);
|
||||
|
||||
gboolean gst_d3d11_converter_update_dest_rect (GstD3D11Converter * converter,
|
||||
RECT * dest_rect);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_D3D11_COLOR_CONVERTER_H__ */
|
|
@ -52,7 +52,7 @@
|
|||
#endif
|
||||
|
||||
#include "gstd3d11decoder.h"
|
||||
#include "gstd3d11colorconverter.h"
|
||||
#include "gstd3d11converter.h"
|
||||
#include "gstd3d11pluginutils.h"
|
||||
#include <string.h>
|
||||
|
||||
|
@ -81,8 +81,8 @@ struct _GstD3D11DecoderPrivate
|
|||
|
||||
GstBufferPool *internal_pool;
|
||||
/* Internal pool params */
|
||||
guint aligned_width;
|
||||
guint aligned_height;
|
||||
gint aligned_width;
|
||||
gint aligned_height;
|
||||
gboolean use_array_of_texture;
|
||||
guint dpb_size;
|
||||
guint downstream_min_buffers;
|
||||
|
@ -98,7 +98,7 @@ struct _GstD3D11DecoderPrivate
|
|||
gboolean can_direct_rendering;
|
||||
|
||||
/* for internal shader */
|
||||
GstD3D11ColorConverter *converter;
|
||||
GstD3D11Converter *converter;
|
||||
ID3D11Texture2D *shader_resource_texture;
|
||||
ID3D11ShaderResourceView *shader_resource_view[GST_VIDEO_MAX_PLANES];
|
||||
ID3D11Texture2D *fallback_shader_output_texture;
|
||||
|
@ -131,7 +131,8 @@ gst_d3d11_decoder_class_init (GstD3D11DecoderClass * klass)
|
|||
g_object_class_install_property (gobject_class, PROP_DEVICE,
|
||||
g_param_spec_object ("device", "Device",
|
||||
"D3D11 Devicd to use", GST_TYPE_D3D11_DEVICE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (d3d11_decoder_debug,
|
||||
"d3d11decoder", 0, "Direct3D11 Base Video Decoder object");
|
||||
|
@ -140,7 +141,8 @@ gst_d3d11_decoder_class_init (GstD3D11DecoderClass * klass)
|
|||
static void
|
||||
gst_d3d11_decoder_init (GstD3D11Decoder * self)
|
||||
{
|
||||
self->priv = gst_d3d11_decoder_get_instance_private (self);
|
||||
self->priv =
|
||||
(GstD3D11DecoderPrivate *) gst_d3d11_decoder_get_instance_private (self);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -161,9 +163,7 @@ gst_d3d11_decoder_constructed (GObject * object)
|
|||
device_context_handle =
|
||||
gst_d3d11_device_get_device_context_handle (priv->device);
|
||||
|
||||
hr = ID3D11Device_QueryInterface (device_handle, &IID_ID3D11VideoDevice,
|
||||
(void **) &priv->video_device);
|
||||
|
||||
hr = device_handle->QueryInterface (IID_PPV_ARGS (&priv->video_device));
|
||||
if (!gst_d3d11_result (hr, priv->device) || !priv->video_device) {
|
||||
GST_WARNING_OBJECT (self, "Cannot create VideoDevice Object: 0x%x",
|
||||
(guint) hr);
|
||||
|
@ -172,9 +172,8 @@ gst_d3d11_decoder_constructed (GObject * object)
|
|||
return;
|
||||
}
|
||||
|
||||
hr = ID3D11DeviceContext_QueryInterface (device_context_handle,
|
||||
&IID_ID3D11VideoContext, (void **) &priv->video_context);
|
||||
|
||||
hr = device_context_handle->
|
||||
QueryInterface (IID_PPV_ARGS (&priv->video_context));
|
||||
if (!gst_d3d11_result (hr, priv->device) || !priv->video_context) {
|
||||
GST_WARNING_OBJECT (self, "Cannot create VideoContext Object: 0x%x",
|
||||
(guint) hr);
|
||||
|
@ -186,15 +185,8 @@ gst_d3d11_decoder_constructed (GObject * object)
|
|||
return;
|
||||
|
||||
fail:
|
||||
if (priv->video_device) {
|
||||
ID3D11VideoDevice_Release (priv->video_device);
|
||||
priv->video_device = NULL;
|
||||
}
|
||||
|
||||
if (priv->video_context) {
|
||||
ID3D11VideoContext_Release (priv->video_context);
|
||||
priv->video_context = NULL;
|
||||
}
|
||||
GST_D3D11_CLEAR_COM (priv->video_device);
|
||||
GST_D3D11_CLEAR_COM (priv->video_context);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -208,7 +200,7 @@ gst_d3d11_decoder_set_property (GObject * object, guint prop_id,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_DEVICE:
|
||||
priv->device = g_value_dup_object (value);
|
||||
priv->device = (GstD3D11Device *) g_value_dup_object (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
@ -240,15 +232,8 @@ gst_d3d11_decoder_close (GstD3D11Decoder * self)
|
|||
|
||||
gst_d3d11_decoder_reset (self);
|
||||
|
||||
if (priv->video_device) {
|
||||
ID3D11VideoDevice_Release (priv->video_device);
|
||||
priv->video_device = NULL;
|
||||
}
|
||||
|
||||
if (priv->video_context) {
|
||||
ID3D11VideoContext_Release (priv->video_context);
|
||||
priv->video_context = NULL;
|
||||
}
|
||||
GST_D3D11_CLEAR_COM (priv->video_device);
|
||||
GST_D3D11_CLEAR_COM (priv->video_context);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -262,42 +247,18 @@ gst_d3d11_decoder_reset_unlocked (GstD3D11Decoder * decoder)
|
|||
priv = decoder->priv;
|
||||
gst_clear_object (&priv->internal_pool);
|
||||
|
||||
if (priv->decoder) {
|
||||
ID3D11VideoDecoder_Release (priv->decoder);
|
||||
priv->decoder = NULL;
|
||||
}
|
||||
GST_D3D11_CLEAR_COM (priv->decoder);
|
||||
GST_D3D11_CLEAR_COM (priv->staging);
|
||||
|
||||
if (priv->staging) {
|
||||
ID3D11Texture2D_Release (priv->staging);
|
||||
priv->staging = NULL;
|
||||
}
|
||||
|
||||
if (priv->converter) {
|
||||
gst_d3d11_color_converter_free (priv->converter);
|
||||
priv->converter = NULL;
|
||||
}
|
||||
g_clear_pointer (&priv->converter, gst_d3d11_converter_free);
|
||||
|
||||
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
|
||||
if (priv->shader_resource_view[i]) {
|
||||
ID3D11ShaderResourceView_Release (priv->shader_resource_view[i]);
|
||||
priv->shader_resource_view[i] = NULL;
|
||||
GST_D3D11_CLEAR_COM (priv->shader_resource_view[i]);
|
||||
GST_D3D11_CLEAR_COM (priv->fallback_render_target_view[i]);
|
||||
}
|
||||
|
||||
if (priv->fallback_render_target_view[i]) {
|
||||
ID3D11RenderTargetView_Release (priv->fallback_render_target_view[i]);
|
||||
priv->fallback_render_target_view[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (priv->shader_resource_texture) {
|
||||
ID3D11Texture2D_Release (priv->shader_resource_texture);
|
||||
priv->shader_resource_texture = NULL;
|
||||
}
|
||||
|
||||
if (priv->fallback_shader_output_texture) {
|
||||
ID3D11Texture2D_Release (priv->fallback_shader_output_texture);
|
||||
priv->fallback_shader_output_texture = NULL;
|
||||
}
|
||||
GST_D3D11_CLEAR_COM (priv->shader_resource_texture);
|
||||
GST_D3D11_CLEAR_COM (priv->fallback_shader_output_texture);
|
||||
|
||||
priv->dpb_size = 0;
|
||||
priv->downstream_min_buffers = 0;
|
||||
|
@ -341,7 +302,8 @@ gst_d3d11_decoder_new (GstD3D11Device * device)
|
|||
|
||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
|
||||
|
||||
decoder = g_object_new (GST_TYPE_D3D11_DECODER, "device", device, NULL);
|
||||
decoder = (GstD3D11Decoder *)
|
||||
g_object_new (GST_TYPE_D3D11_DECODER, "device", device, NULL);
|
||||
priv = decoder->priv;
|
||||
|
||||
if (!priv->video_device || !priv->video_context) {
|
||||
|
@ -379,7 +341,7 @@ gst_d3d11_decoder_prepare_output_view_pool (GstD3D11Decoder * self)
|
|||
GstBufferPool *pool = NULL;
|
||||
GstCaps *caps = NULL;
|
||||
GstVideoAlignment align;
|
||||
GstD3D11AllocationFlags alloc_flags = 0;
|
||||
GstD3D11AllocationFlags alloc_flags = (GstD3D11AllocationFlags) 0;
|
||||
gint bind_flags = D3D11_BIND_DECODER;
|
||||
GstVideoInfo *info = &priv->info;
|
||||
guint pool_size;
|
||||
|
@ -462,8 +424,9 @@ gst_d3d11_decoder_get_supported_decoder_profile (GstD3D11Decoder * decoder,
|
|||
GUID *guid_list = NULL;
|
||||
const GUID *profile = NULL;
|
||||
guint available_profile_count;
|
||||
gint i, j;
|
||||
guint i, j;
|
||||
HRESULT hr;
|
||||
ID3D11VideoDevice *video_device;
|
||||
|
||||
g_return_val_if_fail (GST_IS_D3D11_DECODER (decoder), FALSE);
|
||||
g_return_val_if_fail (decoder_profiles != NULL, FALSE);
|
||||
|
@ -471,9 +434,9 @@ gst_d3d11_decoder_get_supported_decoder_profile (GstD3D11Decoder * decoder,
|
|||
g_return_val_if_fail (selected_profile != NULL, FALSE);
|
||||
|
||||
priv = decoder->priv;
|
||||
video_device = priv->video_device;
|
||||
|
||||
available_profile_count =
|
||||
ID3D11VideoDevice_GetVideoDecoderProfileCount (priv->video_device);
|
||||
available_profile_count = video_device->GetVideoDecoderProfileCount ();
|
||||
|
||||
if (available_profile_count == 0) {
|
||||
GST_WARNING_OBJECT (decoder, "No available decoder profile");
|
||||
|
@ -482,11 +445,10 @@ gst_d3d11_decoder_get_supported_decoder_profile (GstD3D11Decoder * decoder,
|
|||
|
||||
GST_DEBUG_OBJECT (decoder,
|
||||
"Have %u available decoder profiles", available_profile_count);
|
||||
guid_list = g_alloca (sizeof (GUID) * available_profile_count);
|
||||
guid_list = (GUID *) g_alloca (sizeof (GUID) * available_profile_count);
|
||||
|
||||
for (i = 0; i < available_profile_count; i++) {
|
||||
hr = ID3D11VideoDevice_GetVideoDecoderProfile (priv->video_device,
|
||||
i, &guid_list[i]);
|
||||
hr = video_device->GetVideoDecoderProfile (i, &guid_list[i]);
|
||||
if (!gst_d3d11_result (hr, priv->device)) {
|
||||
GST_WARNING_OBJECT (decoder, "Failed to get %d th decoder profile", i);
|
||||
return FALSE;
|
||||
|
@ -519,7 +481,7 @@ gst_d3d11_decoder_get_supported_decoder_profile (GstD3D11Decoder * decoder,
|
|||
|
||||
for (i = 0; i < profile_size; i++) {
|
||||
for (j = 0; j < available_profile_count; j++) {
|
||||
if (IsEqualGUID (decoder_profiles[i], &guid_list[j])) {
|
||||
if (IsEqualGUID (*decoder_profiles[i], guid_list[j])) {
|
||||
profile = decoder_profiles[i];
|
||||
break;
|
||||
}
|
||||
|
@ -548,7 +510,7 @@ gst_d3d11_decoder_get_supported_decoder_profile (GstD3D11Decoder * decoder,
|
|||
|
||||
gboolean
|
||||
gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
||||
GstVideoInfo * info, guint coded_width, guint coded_height,
|
||||
GstVideoInfo * info, gint coded_width, gint coded_height,
|
||||
guint dpb_size, const GUID ** decoder_profiles, guint profile_size)
|
||||
{
|
||||
GstD3D11DecoderPrivate *priv;
|
||||
|
@ -561,11 +523,12 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
D3D11_VIDEO_DECODER_DESC decoder_desc = { 0, };
|
||||
D3D11_TEXTURE2D_DESC staging_desc = { 0, };
|
||||
GUID selected_profile;
|
||||
gint i;
|
||||
guint aligned_width, aligned_height;
|
||||
guint i;
|
||||
gint aligned_width, aligned_height;
|
||||
guint alignment;
|
||||
GstD3D11DeviceVendor vendor;
|
||||
ID3D11Device *device_handle;
|
||||
ID3D11VideoDevice *video_device;
|
||||
|
||||
g_return_val_if_fail (GST_IS_D3D11_DECODER (decoder), FALSE);
|
||||
g_return_val_if_fail (codec > GST_D3D11_CODEC_NONE, FALSE);
|
||||
|
@ -582,6 +545,7 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
priv->use_array_of_texture = FALSE;
|
||||
|
||||
device_handle = gst_d3d11_device_get_device_handle (priv->device);
|
||||
video_device = priv->video_device;
|
||||
|
||||
d3d11_format = gst_d3d11_device_format_from_gst (priv->device,
|
||||
GST_VIDEO_INFO_FORMAT (info));
|
||||
|
@ -597,8 +561,8 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
goto error;
|
||||
}
|
||||
|
||||
hr = ID3D11VideoDevice_CheckVideoDecoderFormat (priv->video_device,
|
||||
&selected_profile, d3d11_format->dxgi_format, &can_support);
|
||||
hr = video_device->CheckVideoDecoderFormat (&selected_profile,
|
||||
d3d11_format->dxgi_format, &can_support);
|
||||
if (!gst_d3d11_result (hr, priv->device) || !can_support) {
|
||||
GST_ERROR_OBJECT (decoder,
|
||||
"VideoDevice could not support dxgi format %d, hr: 0x%x",
|
||||
|
@ -660,8 +624,7 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
decoder_desc.OutputFormat = d3d11_format->dxgi_format;
|
||||
decoder_desc.Guid = selected_profile;
|
||||
|
||||
hr = ID3D11VideoDevice_GetVideoDecoderConfigCount (priv->video_device,
|
||||
&decoder_desc, &config_count);
|
||||
hr = video_device->GetVideoDecoderConfigCount (&decoder_desc, &config_count);
|
||||
if (!gst_d3d11_result (hr, priv->device) || config_count == 0) {
|
||||
GST_ERROR_OBJECT (decoder, "Could not get decoder config count, hr: 0x%x",
|
||||
(guint) hr);
|
||||
|
@ -670,11 +633,12 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
|
||||
GST_DEBUG_OBJECT (decoder, "Total %d config available", config_count);
|
||||
|
||||
config_list = g_alloca (sizeof (D3D11_VIDEO_DECODER_CONFIG) * config_count);
|
||||
config_list = (D3D11_VIDEO_DECODER_CONFIG *)
|
||||
g_alloca (sizeof (D3D11_VIDEO_DECODER_CONFIG) * config_count);
|
||||
|
||||
for (i = 0; i < config_count; i++) {
|
||||
hr = ID3D11VideoDevice_GetVideoDecoderConfig (priv->video_device,
|
||||
&decoder_desc, i, &config_list[i]);
|
||||
hr = video_device->GetVideoDecoderConfig (&decoder_desc, i,
|
||||
&config_list[i]);
|
||||
if (!gst_d3d11_result (hr, priv->device)) {
|
||||
GST_ERROR_OBJECT (decoder, "Could not get decoder %dth config, hr: 0x%x",
|
||||
i, (guint) hr);
|
||||
|
@ -725,8 +689,8 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
}
|
||||
#endif
|
||||
|
||||
hr = ID3D11VideoDevice_CreateVideoDecoder (priv->video_device,
|
||||
&decoder_desc, best_config, &priv->decoder);
|
||||
hr = video_device->CreateVideoDecoder (&decoder_desc,
|
||||
best_config, &priv->decoder);
|
||||
if (!gst_d3d11_result (hr, priv->device) || !priv->decoder) {
|
||||
GST_ERROR_OBJECT (decoder,
|
||||
"Could not create decoder object, hr: 0x%x", (guint) hr);
|
||||
|
@ -748,8 +712,7 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
staging_desc.Usage = D3D11_USAGE_STAGING;
|
||||
staging_desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
|
||||
|
||||
hr = ID3D11Device_CreateTexture2D (device_handle, &staging_desc, NULL,
|
||||
&priv->staging);
|
||||
hr = device_handle->CreateTexture2D (&staging_desc, NULL, &priv->staging);
|
||||
if (!gst_d3d11_result (hr, priv->device)) {
|
||||
GST_ERROR_OBJECT (decoder, "Couldn't create staging texture");
|
||||
goto error;
|
||||
|
@ -786,13 +749,17 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
* Need to VP8 here when VP8 support is added
|
||||
*/
|
||||
if (codec == GST_D3D11_CODEC_VP9) {
|
||||
D3D11_TEXTURE2D_DESC texture_desc = { 0, };
|
||||
D3D11_RENDER_TARGET_VIEW_DESC render_desc = { 0, };
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC resource_desc = { 0, };
|
||||
D3D11_TEXTURE2D_DESC texture_desc;
|
||||
D3D11_RENDER_TARGET_VIEW_DESC render_desc;
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC resource_desc;
|
||||
ID3D11Device *device_handle;
|
||||
D3D11_VIEWPORT viewport;
|
||||
|
||||
priv->converter = gst_d3d11_color_converter_new (priv->device, info, info);
|
||||
memset (&texture_desc, 0, sizeof (texture_desc));
|
||||
memset (&render_desc, 0, sizeof (render_desc));
|
||||
memset (&resource_desc, 0, sizeof (resource_desc));
|
||||
|
||||
priv->converter = gst_d3d11_converter_new (priv->device, info, info);
|
||||
|
||||
viewport.TopLeftX = 0;
|
||||
viewport.TopLeftY = 0;
|
||||
|
@ -800,7 +767,7 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
viewport.Height = priv->display_height;
|
||||
viewport.MinDepth = 0.0f;
|
||||
viewport.MaxDepth = 1.0f;
|
||||
gst_d3d11_color_converter_update_viewport (priv->converter, &viewport);
|
||||
gst_d3d11_converter_update_viewport (priv->converter, &viewport);
|
||||
|
||||
device_handle = gst_d3d11_device_get_device_handle (priv->device);
|
||||
|
||||
|
@ -813,7 +780,7 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
texture_desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
texture_desc.BindFlags = D3D11_BIND_RENDER_TARGET;
|
||||
|
||||
hr = ID3D11Device_CreateTexture2D (device_handle, &texture_desc, NULL,
|
||||
hr = device_handle->CreateTexture2D (&texture_desc, NULL,
|
||||
&priv->fallback_shader_output_texture);
|
||||
if (!gst_d3d11_result (hr, priv->device)) {
|
||||
GST_ERROR_OBJECT (decoder, "Couldn't create shader output texture");
|
||||
|
@ -821,7 +788,7 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
}
|
||||
|
||||
texture_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
hr = ID3D11Device_CreateTexture2D (device_handle, &texture_desc, NULL,
|
||||
hr = device_handle->CreateTexture2D (&texture_desc, NULL,
|
||||
&priv->shader_resource_texture);
|
||||
if (!gst_d3d11_result (hr, priv->device)) {
|
||||
GST_ERROR_OBJECT (decoder, "Couldn't create shader input texture");
|
||||
|
@ -865,9 +832,9 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
for (i = 0; i < priv->num_resource_views; i++) {
|
||||
render_desc.Format = priv->resource_formats[i];
|
||||
|
||||
hr = ID3D11Device_CreateRenderTargetView (device_handle,
|
||||
(ID3D11Resource *) priv->fallback_shader_output_texture, &render_desc,
|
||||
&priv->fallback_render_target_view[i]);
|
||||
hr = device_handle->
|
||||
CreateRenderTargetView (priv->fallback_shader_output_texture,
|
||||
&render_desc, &priv->fallback_render_target_view[i]);
|
||||
if (!gst_d3d11_result (hr, priv->device)) {
|
||||
GST_ERROR_OBJECT (decoder,
|
||||
"Failed to create %dth render target view (0x%x)", i, (guint) hr);
|
||||
|
@ -880,9 +847,9 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
|||
|
||||
for (i = 0; i < priv->num_resource_views; i++) {
|
||||
resource_desc.Format = priv->resource_formats[i];
|
||||
hr = ID3D11Device_CreateShaderResourceView (device_handle,
|
||||
(ID3D11Resource *) priv->shader_resource_texture, &resource_desc,
|
||||
&priv->shader_resource_view[i]);
|
||||
hr = device_handle->
|
||||
CreateShaderResourceView (priv->shader_resource_texture,
|
||||
&resource_desc, &priv->shader_resource_view[i]);
|
||||
|
||||
if (!gst_d3d11_result (hr, priv->device)) {
|
||||
GST_ERROR_OBJECT (decoder,
|
||||
|
@ -920,8 +887,8 @@ gst_d3d11_decoder_begin_frame (GstD3D11Decoder * decoder,
|
|||
do {
|
||||
GST_LOG_OBJECT (decoder, "Try begin frame, retry count %d", retry_count);
|
||||
gst_d3d11_device_lock (priv->device);
|
||||
hr = ID3D11VideoContext_DecoderBeginFrame (priv->video_context,
|
||||
priv->decoder, output_view, content_key_size, content_key);
|
||||
hr = priv->video_context->DecoderBeginFrame (priv->decoder,
|
||||
output_view, content_key_size, content_key);
|
||||
gst_d3d11_device_unlock (priv->device);
|
||||
|
||||
/* HACK: Do 100 times retry with 1ms sleep per failure, since DXVA/D3D11
|
||||
|
@ -962,7 +929,7 @@ gst_d3d11_decoder_end_frame (GstD3D11Decoder * decoder)
|
|||
priv = decoder->priv;
|
||||
|
||||
gst_d3d11_device_lock (priv->device);
|
||||
hr = ID3D11VideoContext_DecoderEndFrame (priv->video_context, priv->decoder);
|
||||
hr = priv->video_context->DecoderEndFrame (priv->decoder);
|
||||
gst_d3d11_device_unlock (priv->device);
|
||||
|
||||
if (!gst_d3d11_result (hr, priv->device)) {
|
||||
|
@ -988,8 +955,8 @@ gst_d3d11_decoder_get_decoder_buffer (GstD3D11Decoder * decoder,
|
|||
priv = decoder->priv;
|
||||
|
||||
gst_d3d11_device_lock (priv->device);
|
||||
hr = ID3D11VideoContext_GetDecoderBuffer (priv->video_context,
|
||||
priv->decoder, type, &size, &decoder_buffer);
|
||||
hr = priv->video_context->GetDecoderBuffer (priv->decoder,
|
||||
type, &size, &decoder_buffer);
|
||||
gst_d3d11_device_unlock (priv->device);
|
||||
|
||||
if (!gst_d3d11_result (hr, priv->device)) {
|
||||
|
@ -1016,8 +983,7 @@ gst_d3d11_decoder_release_decoder_buffer (GstD3D11Decoder * decoder,
|
|||
priv = decoder->priv;
|
||||
|
||||
gst_d3d11_device_lock (priv->device);
|
||||
hr = ID3D11VideoContext_ReleaseDecoderBuffer (priv->video_context,
|
||||
priv->decoder, type);
|
||||
hr = priv->video_context->ReleaseDecoderBuffer (priv->decoder, type);
|
||||
gst_d3d11_device_unlock (priv->device);
|
||||
|
||||
if (!gst_d3d11_result (hr, priv->device)) {
|
||||
|
@ -1041,8 +1007,8 @@ gst_d3d11_decoder_submit_decoder_buffers (GstD3D11Decoder * decoder,
|
|||
priv = decoder->priv;
|
||||
|
||||
gst_d3d11_device_lock (priv->device);
|
||||
hr = ID3D11VideoContext_SubmitDecoderBuffers (priv->video_context,
|
||||
priv->decoder, buffer_count, buffers);
|
||||
hr = priv->video_context->SubmitDecoderBuffers (priv->decoder, buffer_count,
|
||||
buffers);
|
||||
gst_d3d11_device_unlock (priv->device);
|
||||
|
||||
if (!gst_d3d11_result (hr, priv->device)) {
|
||||
|
@ -1142,7 +1108,7 @@ gst_d3d11_decoder_get_output_view_index (ID3D11VideoDecoderOutputView *
|
|||
|
||||
g_return_val_if_fail (view_handle != NULL, 0xff);
|
||||
|
||||
ID3D11VideoDecoderOutputView_GetDesc (view_handle, &view_desc);
|
||||
view_handle->GetDesc (&view_desc);
|
||||
|
||||
return view_desc.Texture2D.ArraySlice;
|
||||
}
|
||||
|
@ -1154,7 +1120,7 @@ copy_to_system (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
|
|||
{
|
||||
GstD3D11DecoderPrivate *priv = self->priv;
|
||||
GstVideoFrame out_frame;
|
||||
gint i;
|
||||
guint i;
|
||||
GstD3D11Memory *in_mem;
|
||||
D3D11_MAPPED_SUBRESOURCE map;
|
||||
HRESULT hr;
|
||||
|
@ -1206,9 +1172,8 @@ copy_to_system (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
|
|||
/* copy decoded texture into shader resource texture */
|
||||
GST_TRACE_OBJECT (self,
|
||||
"Copy decoded texture to internal shader texture");
|
||||
ID3D11DeviceContext_CopySubresourceRegion (device_context,
|
||||
(ID3D11Resource *) priv->shader_resource_texture, 0, 0, 0, 0,
|
||||
(ID3D11Resource *) in_texture, in_subresource_index, &src_box);
|
||||
device_context->CopySubresourceRegion (priv->shader_resource_texture,
|
||||
0, 0, 0, 0, in_texture, in_subresource_index, &src_box);
|
||||
|
||||
for (i = 0; i < priv->num_resource_views; i++)
|
||||
srv[i] = priv->shader_resource_view[i];
|
||||
|
@ -1219,9 +1184,9 @@ copy_to_system (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
|
|||
rect.right = display_width;
|
||||
rect.bottom = display_height;
|
||||
|
||||
gst_d3d11_color_converter_update_src_rect (priv->converter, &rect);
|
||||
gst_d3d11_converter_update_src_rect (priv->converter, &rect);
|
||||
|
||||
if (!gst_d3d11_color_converter_convert_unlocked (priv->converter,
|
||||
if (!gst_d3d11_converter_convert_unlocked (priv->converter,
|
||||
srv, priv->fallback_render_target_view, NULL, NULL)) {
|
||||
GST_ERROR_OBJECT (self, "Failed to convert");
|
||||
goto error;
|
||||
|
@ -1231,12 +1196,10 @@ copy_to_system (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
|
|||
in_subresource_index = 0;
|
||||
}
|
||||
|
||||
ID3D11DeviceContext_CopySubresourceRegion (device_context,
|
||||
(ID3D11Resource *) priv->staging, 0, 0, 0, 0,
|
||||
(ID3D11Resource *) in_texture, in_subresource_index, NULL);
|
||||
device_context->CopySubresourceRegion (priv->staging, 0, 0, 0, 0,
|
||||
in_texture, in_subresource_index, NULL);
|
||||
|
||||
hr = ID3D11DeviceContext_Map (device_context,
|
||||
(ID3D11Resource *) priv->staging, 0, D3D11_MAP_READ, 0, &map);
|
||||
hr = device_context->Map (priv->staging, 0, D3D11_MAP_READ, 0, &map);
|
||||
|
||||
if (!gst_d3d11_result (hr, priv->device)) {
|
||||
GST_ERROR_OBJECT (self, "Failed to map, hr: 0x%x", (guint) hr);
|
||||
|
@ -1248,7 +1211,7 @@ copy_to_system (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
|
|||
D3D11_TEXTURE2D_DESC desc;
|
||||
gsize dummy;
|
||||
|
||||
ID3D11Texture2D_GetDesc (priv->staging, &desc);
|
||||
priv->staging->GetDesc (&desc);
|
||||
|
||||
gst_d3d11_dxgi_format_get_size (desc.Format, desc.Width, desc.Height,
|
||||
map.RowPitch, priv->staging_texture_offset,
|
||||
|
@ -1261,7 +1224,7 @@ copy_to_system (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
|
|||
gint width;
|
||||
|
||||
src = (guint8 *) map.pData + priv->staging_texture_offset[i];
|
||||
dst = GST_VIDEO_FRAME_PLANE_DATA (&out_frame, i);
|
||||
dst = (guint8 *) GST_VIDEO_FRAME_PLANE_DATA (&out_frame, i);
|
||||
width = GST_VIDEO_FRAME_COMP_WIDTH (&out_frame, i) *
|
||||
GST_VIDEO_FRAME_COMP_PSTRIDE (&out_frame, i);
|
||||
|
||||
|
@ -1273,8 +1236,7 @@ copy_to_system (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
|
|||
}
|
||||
|
||||
gst_video_frame_unmap (&out_frame);
|
||||
ID3D11DeviceContext_Unmap (device_context, (ID3D11Resource *) priv->staging,
|
||||
0);
|
||||
device_context->Unmap (priv->staging, 0);
|
||||
gst_d3d11_device_unlock (priv->device);
|
||||
|
||||
return TRUE;
|
||||
|
@ -1304,7 +1266,7 @@ copy_to_d3d11 (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
|
|||
out_mem = (GstD3D11Memory *) gst_buffer_peek_memory (output, 0);
|
||||
|
||||
if (!gst_memory_map (GST_MEMORY_CAST (out_mem),
|
||||
&out_map, GST_MAP_WRITE | GST_MAP_D3D11)) {
|
||||
&out_map, (GstMapFlags) (GST_MAP_WRITE | GST_MAP_D3D11))) {
|
||||
GST_ERROR_OBJECT (self, "Couldn't map output d3d11 memory");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1358,9 +1320,8 @@ copy_to_d3d11 (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
|
|||
/* copy decoded texture into shader resource texture */
|
||||
GST_TRACE_OBJECT (self,
|
||||
"Copy decoded texture to internal shader texture");
|
||||
ID3D11DeviceContext_CopySubresourceRegion (device_context,
|
||||
(ID3D11Resource *) priv->shader_resource_texture, 0, 0, 0, 0,
|
||||
(ID3D11Resource *) in_texture, in_subresource_index, &src_box);
|
||||
device_context->CopySubresourceRegion (priv->shader_resource_texture,
|
||||
0, 0, 0, 0, in_texture, in_subresource_index, &src_box);
|
||||
|
||||
for (i = 0; i < priv->num_resource_views; i++)
|
||||
srv[i] = priv->shader_resource_view[i];
|
||||
|
@ -1371,9 +1332,9 @@ copy_to_d3d11 (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
|
|||
rect.right = display_width;
|
||||
rect.bottom = display_height;
|
||||
|
||||
gst_d3d11_color_converter_update_src_rect (priv->converter, &rect);
|
||||
gst_d3d11_converter_update_src_rect (priv->converter, &rect);
|
||||
|
||||
if (!gst_d3d11_color_converter_convert_unlocked (priv->converter,
|
||||
if (!gst_d3d11_converter_convert_unlocked (priv->converter,
|
||||
srv, rtv, NULL, NULL)) {
|
||||
GST_ERROR_OBJECT (self, "Failed to convert");
|
||||
ret = FALSE;
|
||||
|
@ -1393,9 +1354,9 @@ copy_to_d3d11 (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
|
|||
src_box.bottom = GST_ROUND_UP_2 (priv->display_height);
|
||||
|
||||
out_subresource_index = gst_d3d11_memory_get_subresource_index (out_mem);
|
||||
ID3D11DeviceContext_CopySubresourceRegion (device_context,
|
||||
(ID3D11Resource *) out_map.data, out_subresource_index, 0, 0, 0,
|
||||
(ID3D11Resource *) in_texture, in_subresource_index, &src_box);
|
||||
device_context->CopySubresourceRegion ((ID3D11Resource *) out_map.data,
|
||||
out_subresource_index, 0, 0, 0, in_texture, in_subresource_index,
|
||||
&src_box);
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
|
@ -1628,7 +1589,8 @@ gst_d3d11_decoder_decide_allocation (GstVideoDecoder * decoder,
|
|||
|
||||
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
|
||||
if (!d3d11_params)
|
||||
d3d11_params = gst_d3d11_allocation_params_new (device, &vinfo, 0, 0);
|
||||
d3d11_params = gst_d3d11_allocation_params_new (device, &vinfo,
|
||||
(GstD3D11AllocationFlags) 0, 0);
|
||||
|
||||
width = GST_VIDEO_INFO_WIDTH (&vinfo);
|
||||
height = GST_VIDEO_INFO_HEIGHT (&vinfo);
|
||||
|
@ -1824,8 +1786,8 @@ gst_d3d11_decoder_supports_format (GstD3D11Decoder * decoder,
|
|||
|
||||
priv = decoder->priv;
|
||||
|
||||
hr = ID3D11VideoDevice_CheckVideoDecoderFormat (priv->video_device,
|
||||
decoder_profile, format, &can_support);
|
||||
hr = priv->video_device->CheckVideoDecoderFormat (decoder_profile, format,
|
||||
&can_support);
|
||||
if (!gst_d3d11_result (hr, priv->device) || !can_support) {
|
||||
GST_DEBUG_OBJECT (decoder,
|
||||
"VideoDevice could not support dxgi format %d, hr: 0x%x",
|
||||
|
@ -1858,8 +1820,7 @@ gst_d3d11_decoder_supports_resolution (GstD3D11Decoder * decoder,
|
|||
desc.OutputFormat = format;
|
||||
desc.Guid = *decoder_profile;
|
||||
|
||||
hr = ID3D11VideoDevice_GetVideoDecoderConfigCount (priv->video_device,
|
||||
&desc, &config_count);
|
||||
hr = priv->video_device->GetVideoDecoderConfigCount (&desc, &config_count);
|
||||
if (!gst_d3d11_result (hr, priv->device) || config_count == 0) {
|
||||
GST_DEBUG_OBJECT (decoder, "Could not get decoder config count, hr: 0x%x",
|
||||
(guint) hr);
|
|
@ -72,8 +72,8 @@ GstD3D11Decoder * gst_d3d11_decoder_new (GstD3D11Device * device);
|
|||
gboolean gst_d3d11_decoder_open (GstD3D11Decoder * decoder,
|
||||
GstD3D11Codec codec,
|
||||
GstVideoInfo * info,
|
||||
guint codec_width,
|
||||
guint codec_height,
|
||||
gint codec_width,
|
||||
gint codec_height,
|
||||
guint dpb_size,
|
||||
const GUID ** decoder_profiles,
|
||||
guint profile_size);
|
||||
|
|
|
@ -660,15 +660,8 @@ gst_d3d11_deinterlace_reset (GstD3D11Deinterlace * self)
|
|||
self->fallback_out_pool = NULL;
|
||||
}
|
||||
|
||||
if (self->video_enum) {
|
||||
self->video_enum->Release ();
|
||||
self->video_enum = NULL;
|
||||
}
|
||||
|
||||
if (self->video_proc) {
|
||||
self->video_proc->Release ();
|
||||
self->video_proc = NULL;
|
||||
}
|
||||
GST_D3D11_CLEAR_COM (self->video_enum);
|
||||
GST_D3D11_CLEAR_COM (self->video_proc);
|
||||
|
||||
gst_d3d11_deinterlace_reset_history (self);
|
||||
self->default_buffer_duration = GST_CLOCK_TIME_NONE;
|
||||
|
@ -681,15 +674,8 @@ gst_d3d11_deinterlace_close (GstD3D11Deinterlace * self)
|
|||
{
|
||||
gst_d3d11_deinterlace_reset (self);
|
||||
|
||||
if (self->video_device) {
|
||||
self->video_device->Release ();
|
||||
self->video_device = NULL;
|
||||
}
|
||||
|
||||
if (self->video_context) {
|
||||
self->video_context->Release ();
|
||||
self->video_context = NULL;
|
||||
}
|
||||
GST_D3D11_CLEAR_COM (self->video_device);
|
||||
GST_D3D11_CLEAR_COM (self->video_context);
|
||||
|
||||
gst_clear_object (&self->device);
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
|
||||
#include "gstd3d11desktopdup.h"
|
||||
#include "gstd3d11shader.h"
|
||||
#include "gstd3d11pluginutils.h"
|
||||
#include <string.h>
|
||||
|
||||
#include <wrl.h>
|
||||
|
@ -1620,10 +1621,7 @@ gst_d3d11_desktop_dup_dispose (GObject * object)
|
|||
{
|
||||
GstD3D11DesktopDup *self = GST_D3D11_DESKTOP_DUP (object);
|
||||
|
||||
if (self->texture) {
|
||||
self->texture->Release ();
|
||||
self->texture = nullptr;
|
||||
}
|
||||
GST_D3D11_CLEAR_COM (self->texture);
|
||||
|
||||
if (self->dupl_obj) {
|
||||
delete self->dupl_obj;
|
||||
|
|
|
@ -42,9 +42,15 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_desktop_dup_debug);
|
||||
#define GST_CAT_DEFAULT gst_d3d11_desktop_dup_debug
|
||||
|
||||
G_END_DECLS
|
||||
/* *INDENT-ON* */
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
@ -131,12 +137,14 @@ gst_d3d11_desktop_dup_src_class_init (GstD3D11DesktopDupSrcClass * klass)
|
|||
g_param_spec_int ("monitor-index", "Monitor Index",
|
||||
"Zero-based index for monitor to capture (-1 = primary monitor)",
|
||||
-1, G_MAXINT, DEFAULT_MONITOR_INDEX,
|
||||
G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY | G_PARAM_STATIC_STRINGS);
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
properties[PROP_SHOW_CURSOR] =
|
||||
g_param_spec_boolean ("show-cursor",
|
||||
"Show Mouse Cursor", "Whether to show mouse cursor",
|
||||
DEFAULT_SHOW_CURSOR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
DEFAULT_SHOW_CURSOR,
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_properties (gobject_class, PROP_LAST, properties);
|
||||
|
||||
|
@ -356,8 +364,8 @@ gst_d3d11_desktop_dup_src_decide_allocation (GstBaseSrc * bsrc,
|
|||
|
||||
d3d11_params = gst_buffer_pool_config_get_d3d11_allocation_params (config);
|
||||
if (!d3d11_params) {
|
||||
d3d11_params = gst_d3d11_allocation_params_new (self->device, &vinfo, 0,
|
||||
D3D11_BIND_RENDER_TARGET);
|
||||
d3d11_params = gst_d3d11_allocation_params_new (self->device, &vinfo,
|
||||
(GstD3D11AllocationFlags) 0, D3D11_BIND_RENDER_TARGET);
|
||||
} else {
|
||||
d3d11_params->desc[0].BindFlags |= D3D11_BIND_RENDER_TARGET;
|
||||
}
|
||||
|
@ -497,7 +505,7 @@ gst_d3d11_desktop_dup_src_fill (GstPushSrc * pushsrc, GstBuffer * buffer)
|
|||
GstClockTime latency;
|
||||
GstClockTime dur;
|
||||
gboolean update_latency = FALSE;
|
||||
gint64 next_frame_no;
|
||||
guint64 next_frame_no;
|
||||
gboolean draw_mouse;
|
||||
|
||||
if (!self->dupl) {
|
||||
|
@ -538,7 +546,7 @@ again:
|
|||
|
||||
if (next_frame_no == self->last_frame_no) {
|
||||
GstClockID id;
|
||||
GstClockReturn ret;
|
||||
GstClockReturn clock_ret;
|
||||
|
||||
/* Need to wait for the next frame */
|
||||
next_frame_no += 1;
|
||||
|
@ -556,13 +564,13 @@ again:
|
|||
|
||||
GST_LOG_OBJECT (self, "Waiting for next frame time %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (next_capture_ts));
|
||||
ret = gst_clock_id_wait (id, NULL);
|
||||
clock_ret = gst_clock_id_wait (id, NULL);
|
||||
GST_OBJECT_LOCK (self);
|
||||
|
||||
gst_clock_id_unref (id);
|
||||
self->clock_id = NULL;
|
||||
|
||||
if (ret == GST_CLOCK_UNSCHEDULED) {
|
||||
if (clock_ret == GST_CLOCK_UNSCHEDULED) {
|
||||
/* Got woken up by the unlock function */
|
||||
ret = GST_FLOW_FLUSHING;
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
|
@ -599,7 +607,8 @@ again:
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (!gst_memory_map (mem, &info, GST_MAP_WRITE | GST_MAP_D3D11)) {
|
||||
if (!gst_memory_map (mem, &info,
|
||||
(GstMapFlags) (GST_MAP_WRITE | GST_MAP_D3D11))) {
|
||||
GST_ERROR_OBJECT (self, "Failed to map d3d11 memory");
|
||||
ret = GST_FLOW_ERROR;
|
||||
goto out;
|
|
@ -398,7 +398,7 @@ gst_d3d11_download_transform (GstBaseTransform * trans, GstBuffer * inbuf,
|
|||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
gboolean use_staging_buf;
|
||||
GstBuffer *target_inbuf = inbuf;
|
||||
gint i;
|
||||
guint i;
|
||||
|
||||
use_staging_buf = gst_d3d11_download_can_use_staging_buffer (self, inbuf);
|
||||
|
||||
|
@ -417,11 +417,11 @@ gst_d3d11_download_transform (GstBaseTransform * trans, GstBuffer * inbuf,
|
|||
}
|
||||
|
||||
if (!gst_video_frame_map (&in_frame, &filter->in_info, target_inbuf,
|
||||
GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF))
|
||||
(GstMapFlags) (GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF)))
|
||||
goto invalid_buffer;
|
||||
|
||||
if (!gst_video_frame_map (&out_frame, &filter->out_info, outbuf,
|
||||
GST_MAP_WRITE | GST_VIDEO_FRAME_MAP_FLAG_NO_REF)) {
|
||||
(GstMapFlags) (GST_MAP_WRITE | GST_VIDEO_FRAME_MAP_FLAG_NO_REF))) {
|
||||
gst_video_frame_unmap (&in_frame);
|
||||
goto invalid_buffer;
|
||||
}
|
|
@ -79,9 +79,15 @@
|
|||
#include <d3d9.h>
|
||||
#include <dxva.h>
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_h264_dec_debug);
|
||||
#define GST_CAT_DEFAULT gst_d3d11_h264_dec_debug
|
||||
|
||||
G_END_DECLS
|
||||
/* *INDENT-ON* */
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
@ -106,10 +112,10 @@ typedef struct _GstD3D11H264Dec
|
|||
|
||||
GstD3D11Device *device;
|
||||
|
||||
guint width, height;
|
||||
guint coded_width, coded_height;
|
||||
guint bitdepth;
|
||||
guint chroma_format_idc;
|
||||
gint width, height;
|
||||
gint coded_width, coded_height;
|
||||
gint bitdepth;
|
||||
guint8 chroma_format_idc;
|
||||
GstVideoFormat out_format;
|
||||
gboolean interlaced;
|
||||
gint max_dpb_size;
|
||||
|
@ -198,17 +204,17 @@ gst_d3d11_h264_dec_class_init (GstD3D11H264DecClass * klass, gpointer data)
|
|||
g_param_spec_uint ("adapter", "Adapter",
|
||||
"DXGI Adapter index for creating device",
|
||||
0, G_MAXUINT32, cdata->adapter,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_DEVICE_ID,
|
||||
g_param_spec_uint ("device-id", "Device Id",
|
||||
"DXGI Device ID", 0, G_MAXUINT32, 0,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_VENDOR_ID,
|
||||
g_param_spec_uint ("vendor-id", "Vendor Id",
|
||||
"DXGI Vendor ID", 0, G_MAXUINT32, 0,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
|
||||
|
||||
klass->adapter = cdata->adapter;
|
||||
klass->device_id = cdata->device_id;
|
||||
|
@ -450,7 +456,7 @@ gst_d3d11_h264_dec_new_sequence (GstH264Decoder * decoder,
|
|||
|
||||
if (self->bitdepth != sps->bit_depth_luma_minus8 + 8) {
|
||||
GST_INFO_OBJECT (self, "bitdepth changed");
|
||||
self->bitdepth = sps->bit_depth_luma_minus8 + 8;
|
||||
self->bitdepth = (guint) sps->bit_depth_luma_minus8 + 8;
|
||||
modified = TRUE;
|
||||
}
|
||||
|
||||
|
@ -809,7 +815,8 @@ gst_d3d11_h264_dec_new_field_picture (GstH264Decoder * decoder,
|
|||
GstD3D11H264Dec *self = GST_D3D11_H264_DEC (decoder);
|
||||
GstBuffer *view_buffer;
|
||||
|
||||
view_buffer = gst_h264_picture_get_user_data ((GstH264Picture *) first_field);
|
||||
view_buffer = (GstBuffer *) gst_h264_picture_get_user_data ((GstH264Picture *)
|
||||
first_field);
|
||||
|
||||
if (!view_buffer) {
|
||||
GST_WARNING_OBJECT (self, "First picture does not have output view buffer");
|
||||
|
@ -910,8 +917,8 @@ gst_d3d11_h264_dec_submit_slice_data (GstD3D11H264Dec * self)
|
|||
gpointer buffer;
|
||||
guint8 *data;
|
||||
gsize offset = 0;
|
||||
gint i;
|
||||
D3D11_VIDEO_DECODER_BUFFER_DESC buffer_desc[4] = { 0, };
|
||||
guint i;
|
||||
D3D11_VIDEO_DECODER_BUFFER_DESC buffer_desc[4];
|
||||
gboolean ret;
|
||||
DXVA_Slice_H264_Short *slice_data;
|
||||
|
||||
|
@ -920,6 +927,8 @@ gst_d3d11_h264_dec_submit_slice_data (GstD3D11H264Dec * self)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
memset (buffer_desc, 0, sizeof (buffer_desc));
|
||||
|
||||
slice_data = &g_array_index (self->slice_list, DXVA_Slice_H264_Short,
|
||||
self->slice_list->len - 1);
|
||||
|
||||
|
@ -949,7 +958,7 @@ gst_d3d11_h264_dec_submit_slice_data (GstD3D11H264Dec * self)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
data = buffer;
|
||||
data = (guint8 *) buffer;
|
||||
for (i = 0; i < self->slice_list->len; i++) {
|
||||
DXVA_Slice_H264_Short *slice_data =
|
||||
&g_array_index (self->slice_list, DXVA_Slice_H264_Short, i);
|
||||
|
@ -1037,9 +1046,12 @@ gst_d3d11_h264_dec_picture_params_from_sps (GstD3D11H264Dec * self,
|
|||
(params)->f = (sps)->f
|
||||
|
||||
params->wFrameWidthInMbsMinus1 = sps->pic_width_in_mbs_minus1;
|
||||
if (!sps->frame_mbs_only_flag) {
|
||||
params->wFrameHeightInMbsMinus1 =
|
||||
((sps->pic_height_in_map_units_minus1 + 1) << !sps->frame_mbs_only_flag)
|
||||
- 1;
|
||||
((sps->pic_height_in_map_units_minus1 + 1) << 1) - 1;
|
||||
} else {
|
||||
params->wFrameHeightInMbsMinus1 = sps->pic_height_in_map_units_minus1;
|
||||
}
|
||||
params->residual_colour_transform_flag = sps->separate_colour_plane_flag;
|
||||
params->MbaffFrameFlag = (sps->mb_adaptive_frame_field_flag && !field_pic);
|
||||
params->field_pic_flag = field_pic;
|
||||
|
@ -1356,7 +1368,7 @@ gst_d3d11_h264_dec_register (GstPlugin * plugin, GstD3D11Device * device,
|
|||
}
|
||||
|
||||
type = g_type_register_static (GST_TYPE_H264_DECODER,
|
||||
type_name, &type_info, 0);
|
||||
type_name, &type_info, (GTypeFlags) 0);
|
||||
|
||||
/* make lower rank than default device */
|
||||
if (rank > 0 && index != 0)
|
|
@ -49,9 +49,15 @@
|
|||
#include <d3d9.h>
|
||||
#include <dxva.h>
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_h265_dec_debug);
|
||||
#define GST_CAT_DEFAULT gst_d3d11_h265_dec_debug
|
||||
|
||||
G_END_DECLS
|
||||
/* *INDENT-ON* */
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
@ -74,10 +80,10 @@ typedef struct _GstD3D11H265Dec
|
|||
|
||||
GstD3D11Device *device;
|
||||
|
||||
guint width, height;
|
||||
guint coded_width, coded_height;
|
||||
gint width, height;
|
||||
gint coded_width, coded_height;
|
||||
guint bitdepth;
|
||||
guint chroma_format_idc;
|
||||
guint8 chroma_format_idc;
|
||||
GstVideoFormat out_format;
|
||||
GstVideoInterlaceMode interlace_mode;
|
||||
|
||||
|
@ -170,17 +176,17 @@ gst_d3d11_h265_dec_class_init (GstD3D11H265DecClass * klass, gpointer data)
|
|||
g_param_spec_uint ("adapter", "Adapter",
|
||||
"DXGI Adapter index for creating device",
|
||||
0, G_MAXUINT32, cdata->adapter,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_DEVICE_ID,
|
||||
g_param_spec_uint ("device-id", "Device Id",
|
||||
"DXGI Device ID", 0, G_MAXUINT32, 0,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_VENDOR_ID,
|
||||
g_param_spec_uint ("vendor-id", "Vendor Id",
|
||||
"DXGI Vendor ID", 0, G_MAXUINT32, 0,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
|
||||
|
||||
klass->adapter = cdata->adapter;
|
||||
klass->device_id = cdata->device_id;
|
||||
|
@ -398,7 +404,7 @@ gst_d3d11_h265_dec_new_sequence (GstH265Decoder * decoder,
|
|||
modified = TRUE;
|
||||
}
|
||||
|
||||
if (self->bitdepth != sps->bit_depth_luma_minus8 + 8) {
|
||||
if (self->bitdepth != (guint) sps->bit_depth_luma_minus8 + 8) {
|
||||
GST_INFO_OBJECT (self, "bitdepth changed");
|
||||
self->bitdepth = sps->bit_depth_luma_minus8 + 8;
|
||||
modified = TRUE;
|
||||
|
@ -528,7 +534,7 @@ gst_d3d11_h265_dec_get_output_view_from_picture (GstD3D11H265Dec * self,
|
|||
static gint
|
||||
gst_d3d11_h265_dec_get_ref_index (GstD3D11H265Dec * self, gint view_id)
|
||||
{
|
||||
gint i;
|
||||
guint i;
|
||||
for (i = 0; i < G_N_ELEMENTS (self->ref_pic_list); i++) {
|
||||
if (self->ref_pic_list[i].Index7Bits == view_id)
|
||||
return i;
|
||||
|
@ -543,7 +549,7 @@ gst_d3d11_h265_dec_start_picture (GstH265Decoder * decoder,
|
|||
{
|
||||
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder);
|
||||
ID3D11VideoDecoderOutputView *view;
|
||||
gint i, j;
|
||||
guint i, j;
|
||||
GArray *dpb_array;
|
||||
GstH265SPS *sps;
|
||||
GstH265PPS *pps;
|
||||
|
@ -881,8 +887,8 @@ gst_d3d11_h265_dec_submit_slice_data (GstD3D11H265Dec * self)
|
|||
gpointer buffer;
|
||||
guint8 *data;
|
||||
gsize offset = 0;
|
||||
gint i;
|
||||
D3D11_VIDEO_DECODER_BUFFER_DESC buffer_desc[4] = { 0, };
|
||||
guint i;
|
||||
D3D11_VIDEO_DECODER_BUFFER_DESC buffer_desc[4];
|
||||
gboolean ret;
|
||||
guint buffer_count = 0;
|
||||
DXVA_Slice_HEVC_Short *slice_data;
|
||||
|
@ -892,6 +898,8 @@ gst_d3d11_h265_dec_submit_slice_data (GstD3D11H265Dec * self)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
memset (buffer_desc, 0, sizeof (buffer_desc));
|
||||
|
||||
slice_data = &g_array_index (self->slice_list, DXVA_Slice_HEVC_Short,
|
||||
self->slice_list->len - 1);
|
||||
|
||||
|
@ -921,7 +929,7 @@ gst_d3d11_h265_dec_submit_slice_data (GstD3D11H265Dec * self)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
data = buffer;
|
||||
data = (guint8 *) buffer;
|
||||
for (i = 0; i < self->slice_list->len; i++) {
|
||||
slice_data = &g_array_index (self->slice_list, DXVA_Slice_HEVC_Short, i);
|
||||
|
||||
|
@ -1062,7 +1070,7 @@ static void
|
|||
gst_d3d11_h265_dec_picture_params_from_pps (GstD3D11H265Dec * self,
|
||||
const GstH265PPS * pps, DXVA_PicParams_HEVC * params)
|
||||
{
|
||||
gint i;
|
||||
guint i;
|
||||
|
||||
#define COPY_FIELD(f) \
|
||||
(params)->f = (pps)->f
|
||||
|
@ -1168,7 +1176,7 @@ static void
|
|||
gst_d3d11_h265_dec_dump_pic_params (GstD3D11H265Dec * self,
|
||||
DXVA_PicParams_HEVC * params)
|
||||
{
|
||||
gint i;
|
||||
guint i;
|
||||
|
||||
GST_TRACE_OBJECT (self, "Dump current DXVA_PicParams_HEVC");
|
||||
|
||||
|
@ -1587,7 +1595,7 @@ gst_d3d11_h265_dec_register (GstPlugin * plugin, GstD3D11Device * device,
|
|||
}
|
||||
|
||||
type = g_type_register_static (GST_TYPE_H265_DECODER,
|
||||
type_name, &type_info, 0);
|
||||
type_name, &type_info, (GTypeFlags) 0);
|
||||
|
||||
/* make lower rank than default device */
|
||||
if (rank > 0 && index != 0)
|
|
@ -49,9 +49,15 @@
|
|||
#include <d3d9.h>
|
||||
#include <dxva.h>
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_mpeg2_dec_debug);
|
||||
#define GST_CAT_DEFAULT gst_d3d11_mpeg2_dec_debug
|
||||
|
||||
G_END_DECLS
|
||||
/* *INDENT-ON* */
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
@ -77,7 +83,7 @@ typedef struct _GstD3D11Mpeg2Dec
|
|||
GstD3D11Device *device;
|
||||
GstD3D11Decoder *d3d11_decoder;
|
||||
|
||||
guint width, height;
|
||||
gint width, height;
|
||||
guint width_in_mb, height_in_mb;
|
||||
GstVideoFormat out_format;
|
||||
GstMpegVideoSequenceHdr seq;
|
||||
|
@ -162,17 +168,17 @@ gst_d3d11_mpeg2_dec_class_init (GstD3D11Mpeg2DecClass * klass, gpointer data)
|
|||
g_param_spec_uint ("adapter", "Adapter",
|
||||
"DXGI Adapter index for creating device",
|
||||
0, G_MAXUINT32, cdata->adapter,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_DEVICE_ID,
|
||||
g_param_spec_uint ("device-id", "Device Id",
|
||||
"DXGI Device ID", 0, G_MAXUINT32, 0,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_VENDOR_ID,
|
||||
g_param_spec_uint ("vendor-id", "Vendor Id",
|
||||
"DXGI Vendor ID", 0, G_MAXUINT32, 0,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
|
||||
|
||||
klass->adapter = cdata->adapter;
|
||||
klass->device_id = cdata->device_id;
|
||||
|
@ -398,7 +404,7 @@ gst_d3d11_mpeg2_dec_new_sequence (GstMpeg2Decoder * decoder,
|
|||
|
||||
mpeg_profile = GST_MPEG_VIDEO_PROFILE_MAIN;
|
||||
if (seq_ext)
|
||||
mpeg_profile = seq_ext->profile;
|
||||
mpeg_profile = (GstMpegVideoProfile) seq_ext->profile;
|
||||
|
||||
if (mpeg_profile != GST_MPEG_VIDEO_PROFILE_MAIN &&
|
||||
mpeg_profile != GST_MPEG_VIDEO_PROFILE_SIMPLE) {
|
||||
|
@ -470,7 +476,7 @@ gst_d3d11_mpeg2_dec_new_field_picture (GstMpeg2Decoder * decoder,
|
|||
GstD3D11Mpeg2Dec *self = GST_D3D11_MPEG2_DEC (decoder);
|
||||
GstBuffer *view_buffer;
|
||||
|
||||
view_buffer =
|
||||
view_buffer = (GstBuffer *)
|
||||
gst_mpeg2_picture_get_user_data ((GstMpeg2Picture *) first_field);
|
||||
|
||||
if (!view_buffer) {
|
||||
|
@ -729,8 +735,8 @@ gst_d3d11_mpeg2_dec_submit_slice_data (GstD3D11Mpeg2Dec * self,
|
|||
gpointer buffer;
|
||||
guint8 *data;
|
||||
gsize offset = 0;
|
||||
gint i;
|
||||
D3D11_VIDEO_DECODER_BUFFER_DESC buffer_desc[4] = { 0, };
|
||||
guint i;
|
||||
D3D11_VIDEO_DECODER_BUFFER_DESC buffer_desc[4];
|
||||
gboolean ret;
|
||||
guint buffer_count = 0;
|
||||
DXVA_SliceInfo *slice_data;
|
||||
|
@ -743,6 +749,8 @@ gst_d3d11_mpeg2_dec_submit_slice_data (GstD3D11Mpeg2Dec * self,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
memset (buffer_desc, 0, sizeof (buffer_desc));
|
||||
|
||||
GST_TRACE_OBJECT (self, "Getting slice control buffer");
|
||||
|
||||
if (!gst_d3d11_decoder_get_decoder_buffer (self->d3d11_decoder,
|
||||
|
@ -751,7 +759,7 @@ gst_d3d11_mpeg2_dec_submit_slice_data (GstD3D11Mpeg2Dec * self,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
data = buffer;
|
||||
data = (guint8 *) buffer;
|
||||
for (i = 0; i < self->slice_list->len; i++) {
|
||||
slice_data = &g_array_index (self->slice_list, DXVA_SliceInfo, i);
|
||||
|
||||
|
@ -1038,7 +1046,7 @@ gst_d3d11_mpeg2_dec_register (GstPlugin * plugin, GstD3D11Device * device,
|
|||
}
|
||||
|
||||
type = g_type_register_static (GST_TYPE_MPEG2_DECODER,
|
||||
type_name, &type_info, 0);
|
||||
type_name, &type_info, (GTypeFlags) 0);
|
||||
|
||||
/* make lower rank than default device */
|
||||
if (rank > 0 && index != 0)
|
|
@ -23,11 +23,18 @@
|
|||
|
||||
#include "gstd3d11overlaycompositor.h"
|
||||
#include "gstd3d11shader.h"
|
||||
#include "gstd3d11pluginutils.h"
|
||||
#include <wrl.h>
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
using namespace Microsoft::WRL;
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_overlay_compositor_debug);
|
||||
#define GST_CAT_DEFAULT gst_d3d11_overlay_compositor_debug
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
G_END_DECLS
|
||||
typedef struct
|
||||
{
|
||||
struct {
|
||||
|
@ -108,11 +115,10 @@ gst_d3d11_composition_overlay_new (GstD3D11OverlayCompositor * self,
|
|||
GstD3D11CompositionOverlay *overlay = NULL;
|
||||
gint x, y;
|
||||
guint width, height;
|
||||
D3D11_SUBRESOURCE_DATA subresource_data = { 0, };
|
||||
D3D11_TEXTURE2D_DESC texture_desc = { 0, };
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc = { 0, };
|
||||
D3D11_BUFFER_DESC buffer_desc = { 0, };
|
||||
ID3D11Buffer *vertex_buffer = NULL;
|
||||
D3D11_SUBRESOURCE_DATA subresource_data;
|
||||
D3D11_TEXTURE2D_DESC texture_desc;
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc;
|
||||
D3D11_BUFFER_DESC buffer_desc;
|
||||
D3D11_MAPPED_SUBRESOURCE map;
|
||||
VertexData *vertex_data;
|
||||
GstBuffer *buf;
|
||||
|
@ -120,8 +126,6 @@ gst_d3d11_composition_overlay_new (GstD3D11OverlayCompositor * self,
|
|||
GstMapInfo info;
|
||||
guint8 *data;
|
||||
gint stride;
|
||||
ID3D11Texture2D *texture = NULL;
|
||||
ID3D11ShaderResourceView *srv = NULL;
|
||||
HRESULT hr;
|
||||
ID3D11Device *device_handle;
|
||||
ID3D11DeviceContext *context_handle;
|
||||
|
@ -129,9 +133,19 @@ gst_d3d11_composition_overlay_new (GstD3D11OverlayCompositor * self,
|
|||
const guint index_count = 2 * 3;
|
||||
FLOAT x1, y1, x2, y2;
|
||||
gdouble val;
|
||||
/* *INDENT-OFF* */
|
||||
ComPtr<ID3D11Texture2D> texture;
|
||||
ComPtr<ID3D11ShaderResourceView> srv;
|
||||
ComPtr<ID3D11Buffer> vertex_buffer;
|
||||
/* *INDENT-ON* */
|
||||
|
||||
g_return_val_if_fail (overlay_rect != NULL, NULL);
|
||||
|
||||
memset (&subresource_data, 0, sizeof (subresource_data));
|
||||
memset (&texture_desc, 0, sizeof (texture_desc));
|
||||
memset (&srv_desc, 0, sizeof (srv_desc));
|
||||
memset (&buffer_desc, 0, sizeof (buffer_desc));
|
||||
|
||||
device_handle = gst_d3d11_device_get_device_handle (device);
|
||||
context_handle = gst_d3d11_device_get_device_context_handle (device);
|
||||
|
||||
|
@ -177,7 +191,7 @@ gst_d3d11_composition_overlay_new (GstD3D11OverlayCompositor * self,
|
|||
texture_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
texture_desc.CPUAccessFlags = 0;
|
||||
|
||||
hr = ID3D11Device_CreateTexture2D (device_handle, &texture_desc,
|
||||
hr = device_handle->CreateTexture2D (&texture_desc,
|
||||
&subresource_data, &texture);
|
||||
gst_video_meta_unmap (vmeta, 0, &info);
|
||||
|
||||
|
@ -189,11 +203,11 @@ gst_d3d11_composition_overlay_new (GstD3D11OverlayCompositor * self,
|
|||
srv_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||
srv_desc.Texture2D.MipLevels = 1;
|
||||
|
||||
hr = ID3D11Device_CreateShaderResourceView (device_handle,
|
||||
(ID3D11Resource *) texture, &srv_desc, &srv);
|
||||
hr = device_handle->CreateShaderResourceView (texture.Get (), &srv_desc,
|
||||
&srv);
|
||||
if (!gst_d3d11_result (hr, device) || !srv) {
|
||||
GST_ERROR ("Failed to create shader resource view");
|
||||
goto clear;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
|
@ -201,21 +215,20 @@ gst_d3d11_composition_overlay_new (GstD3D11OverlayCompositor * self,
|
|||
buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
|
||||
hr = ID3D11Device_CreateBuffer (device_handle, &buffer_desc, NULL,
|
||||
&vertex_buffer);
|
||||
hr = device_handle->CreateBuffer (&buffer_desc, NULL, &vertex_buffer);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("Couldn't create vertex buffer, hr: 0x%x", (guint) hr);
|
||||
goto clear;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_d3d11_device_lock (device);
|
||||
hr = ID3D11DeviceContext_Map (context_handle,
|
||||
(ID3D11Resource *) vertex_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
||||
hr = context_handle->Map (vertex_buffer.Get (),
|
||||
0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
||||
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("Couldn't map vertex buffer, hr: 0x%x", (guint) hr);
|
||||
gst_d3d11_device_unlock (device);
|
||||
goto clear;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vertex_data = (VertexData *) map.pData;
|
||||
|
@ -264,30 +277,18 @@ gst_d3d11_composition_overlay_new (GstD3D11OverlayCompositor * self,
|
|||
vertex_data[3].texture.x = 1.0f;
|
||||
vertex_data[3].texture.y = 1.0f;
|
||||
|
||||
ID3D11DeviceContext_Unmap (context_handle,
|
||||
(ID3D11Resource *) vertex_buffer, 0);
|
||||
context_handle->Unmap (vertex_buffer.Get (), 0);
|
||||
gst_d3d11_device_unlock (device);
|
||||
|
||||
overlay = g_new0 (GstD3D11CompositionOverlay, 1);
|
||||
overlay->overlay_rect = gst_video_overlay_rectangle_ref (overlay_rect);
|
||||
overlay->texture = texture;
|
||||
overlay->srv = srv;
|
||||
overlay->texture = texture.Detach ();
|
||||
overlay->srv = srv.Detach ();
|
||||
overlay->quad = gst_d3d11_quad_new (device,
|
||||
self->ps, self->vs, self->layout, self->sampler, self->blend, NULL, NULL,
|
||||
vertex_buffer, sizeof (VertexData),
|
||||
vertex_buffer.Get (), sizeof (VertexData),
|
||||
self->index_buffer, DXGI_FORMAT_R16_UINT, index_count);
|
||||
|
||||
clear:
|
||||
if (!overlay) {
|
||||
if (srv)
|
||||
ID3D11ShaderResourceView_Release (srv);
|
||||
if (texture)
|
||||
ID3D11Texture2D_Release (texture);
|
||||
}
|
||||
|
||||
if (vertex_buffer)
|
||||
ID3D11Buffer_Release (vertex_buffer);
|
||||
|
||||
return overlay;
|
||||
}
|
||||
|
||||
|
@ -300,11 +301,8 @@ gst_d3d11_composition_overlay_free (GstD3D11CompositionOverlay * overlay)
|
|||
if (overlay->overlay_rect)
|
||||
gst_video_overlay_rectangle_unref (overlay->overlay_rect);
|
||||
|
||||
if (overlay->srv)
|
||||
ID3D11ShaderResourceView_Release (overlay->srv);
|
||||
|
||||
if (overlay->texture)
|
||||
ID3D11Texture2D_Release (overlay->texture);
|
||||
GST_D3D11_CLEAR_COM (overlay->srv);
|
||||
GST_D3D11_CLEAR_COM (overlay->texture);
|
||||
|
||||
if (overlay->quad)
|
||||
gst_d3d11_quad_free (overlay->quad);
|
||||
|
@ -317,22 +315,28 @@ gst_d3d11_overlay_compositor_setup_shader (GstD3D11OverlayCompositor * self,
|
|||
GstD3D11Device * device)
|
||||
{
|
||||
HRESULT hr;
|
||||
D3D11_SAMPLER_DESC sampler_desc = { 0, };
|
||||
D3D11_INPUT_ELEMENT_DESC input_desc[2] = { 0, };
|
||||
D3D11_BUFFER_DESC buffer_desc = { 0, };
|
||||
D3D11_BLEND_DESC blend_desc = { 0, };
|
||||
D3D11_SAMPLER_DESC sampler_desc;
|
||||
D3D11_INPUT_ELEMENT_DESC input_desc[2];
|
||||
D3D11_BUFFER_DESC buffer_desc;
|
||||
D3D11_BLEND_DESC blend_desc;
|
||||
D3D11_MAPPED_SUBRESOURCE map;
|
||||
WORD *indices;
|
||||
ID3D11Device *device_handle;
|
||||
ID3D11DeviceContext *context_handle;
|
||||
ID3D11PixelShader *ps = NULL;
|
||||
ID3D11VertexShader *vs = NULL;
|
||||
ID3D11InputLayout *layout = NULL;
|
||||
ID3D11SamplerState *sampler = NULL;
|
||||
ID3D11BlendState *blend = NULL;
|
||||
ID3D11Buffer *index_buffer = NULL;
|
||||
/* *INDENT-OFF* */
|
||||
ComPtr<ID3D11PixelShader> ps;
|
||||
ComPtr<ID3D11VertexShader> vs;
|
||||
ComPtr<ID3D11InputLayout> layout;
|
||||
ComPtr<ID3D11SamplerState> sampler;
|
||||
ComPtr<ID3D11BlendState> blend;
|
||||
ComPtr<ID3D11Buffer> index_buffer;
|
||||
/* *INDENT-ON* */
|
||||
const guint index_count = 2 * 3;
|
||||
gboolean ret = TRUE;
|
||||
|
||||
memset (&sampler_desc, 0, sizeof (sampler_desc));
|
||||
memset (input_desc, 0, sizeof (input_desc));
|
||||
memset (&buffer_desc, 0, sizeof (buffer_desc));
|
||||
memset (&blend_desc, 0, sizeof (blend_desc));
|
||||
|
||||
device_handle = gst_d3d11_device_get_device_handle (device);
|
||||
context_handle = gst_d3d11_device_get_device_context_handle (device);
|
||||
|
@ -346,19 +350,17 @@ gst_d3d11_overlay_compositor_setup_shader (GstD3D11OverlayCompositor * self,
|
|||
sampler_desc.MinLOD = 0;
|
||||
sampler_desc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
|
||||
hr = ID3D11Device_CreateSamplerState (device_handle, &sampler_desc, &sampler);
|
||||
hr = device_handle->CreateSamplerState (&sampler_desc, &sampler);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("Couldn't create sampler state, hr: 0x%x", (guint) hr);
|
||||
ret = FALSE;
|
||||
goto clear;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GST_LOG ("Create Pixel Shader \n%s", templ_pixel_shader);
|
||||
|
||||
if (!gst_d3d11_create_pixel_shader (device, templ_pixel_shader, &ps)) {
|
||||
GST_ERROR ("Couldn't create pixel shader");
|
||||
ret = FALSE;
|
||||
goto clear;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
input_desc[0].SemanticName = "POSITION";
|
||||
|
@ -380,8 +382,7 @@ gst_d3d11_overlay_compositor_setup_shader (GstD3D11OverlayCompositor * self,
|
|||
if (!gst_d3d11_create_vertex_shader (device, templ_vertex_shader,
|
||||
input_desc, G_N_ELEMENTS (input_desc), &vs, &layout)) {
|
||||
GST_ERROR ("Couldn't vertex pixel shader");
|
||||
ret = FALSE;
|
||||
goto clear;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
blend_desc.AlphaToCoverageEnable = FALSE;
|
||||
|
@ -396,11 +397,10 @@ gst_d3d11_overlay_compositor_setup_shader (GstD3D11OverlayCompositor * self,
|
|||
blend_desc.RenderTarget[0].RenderTargetWriteMask =
|
||||
D3D11_COLOR_WRITE_ENABLE_ALL;
|
||||
|
||||
hr = ID3D11Device_CreateBlendState (device_handle, &blend_desc, &blend);
|
||||
hr = device_handle->CreateBlendState (&blend_desc, &blend);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("Couldn't create blend staten, hr: 0x%x", (guint) hr);
|
||||
ret = FALSE;
|
||||
goto clear;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
|
@ -408,23 +408,20 @@ gst_d3d11_overlay_compositor_setup_shader (GstD3D11OverlayCompositor * self,
|
|||
buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||
buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
|
||||
hr = ID3D11Device_CreateBuffer (device_handle, &buffer_desc, NULL,
|
||||
&index_buffer);
|
||||
hr = device_handle->CreateBuffer (&buffer_desc, NULL, &index_buffer);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("Couldn't create index buffer, hr: 0x%x", (guint) hr);
|
||||
ret = FALSE;
|
||||
goto clear;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gst_d3d11_device_lock (device);
|
||||
hr = ID3D11DeviceContext_Map (context_handle,
|
||||
(ID3D11Resource *) index_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
||||
hr = context_handle->Map (index_buffer.Get (),
|
||||
0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
||||
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("Couldn't map index buffer, hr: 0x%x", (guint) hr);
|
||||
gst_d3d11_device_unlock (device);
|
||||
ret = FALSE;
|
||||
goto clear;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
indices = (WORD *) map.pData;
|
||||
|
@ -438,35 +435,17 @@ gst_d3d11_overlay_compositor_setup_shader (GstD3D11OverlayCompositor * self,
|
|||
indices[4] = 0; /* bottom left */
|
||||
indices[5] = 2; /* top right */
|
||||
|
||||
ID3D11DeviceContext_Unmap (context_handle,
|
||||
(ID3D11Resource *) index_buffer, 0);
|
||||
context_handle->Unmap (index_buffer.Get (), 0);
|
||||
gst_d3d11_device_unlock (device);
|
||||
|
||||
self->ps = ps;
|
||||
self->vs = vs;
|
||||
self->layout = layout;
|
||||
self->sampler = sampler;
|
||||
self->blend = blend;
|
||||
self->index_buffer = index_buffer;
|
||||
self->ps = ps.Detach ();
|
||||
self->vs = vs.Detach ();
|
||||
self->layout = layout.Detach ();
|
||||
self->sampler = sampler.Detach ();
|
||||
self->blend = blend.Detach ();
|
||||
self->index_buffer = index_buffer.Detach ();
|
||||
|
||||
clear:
|
||||
if (ret)
|
||||
return TRUE;
|
||||
|
||||
if (ps)
|
||||
ID3D11PixelShader_Release (ps);
|
||||
if (vs)
|
||||
ID3D11VertexShader_Release (vs);
|
||||
if (layout)
|
||||
ID3D11InputLayout_Release (layout);
|
||||
if (sampler)
|
||||
ID3D11SamplerState_Release (sampler);
|
||||
if (blend)
|
||||
ID3D11BlendState_Release (blend);
|
||||
if (index_buffer)
|
||||
ID3D11Buffer_Release (index_buffer);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -486,7 +465,7 @@ gst_d3d11_overlay_compositor_new (GstD3D11Device * device,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
compositor->device = gst_object_ref (device);
|
||||
compositor->device = (GstD3D11Device *) gst_object_ref (device);
|
||||
compositor->out_info = *out_info;
|
||||
|
||||
compositor->viewport.TopLeftX = 0;
|
||||
|
@ -506,18 +485,12 @@ gst_d3d11_overlay_compositor_free (GstD3D11OverlayCompositor * compositor)
|
|||
|
||||
gst_d3d11_overlay_compositor_free_overlays (compositor);
|
||||
|
||||
if (compositor->ps)
|
||||
ID3D11PixelShader_Release (compositor->ps);
|
||||
if (compositor->vs)
|
||||
ID3D11VertexShader_Release (compositor->vs);
|
||||
if (compositor->layout)
|
||||
ID3D11InputLayout_Release (compositor->layout);
|
||||
if (compositor->sampler)
|
||||
ID3D11SamplerState_Release (compositor->sampler);
|
||||
if (compositor->blend)
|
||||
ID3D11BlendState_Release (compositor->blend);
|
||||
if (compositor->index_buffer)
|
||||
ID3D11Buffer_Release (compositor->index_buffer);
|
||||
GST_D3D11_CLEAR_COM (compositor->ps);
|
||||
GST_D3D11_CLEAR_COM (compositor->vs);
|
||||
GST_D3D11_CLEAR_COM (compositor->layout);
|
||||
GST_D3D11_CLEAR_COM (compositor->sampler);
|
||||
GST_D3D11_CLEAR_COM (compositor->blend);
|
||||
GST_D3D11_CLEAR_COM (compositor->index_buffer);
|
||||
|
||||
gst_clear_object (&compositor->device);
|
||||
g_free (compositor);
|
|
@ -27,9 +27,15 @@
|
|||
#include <windows.h>
|
||||
#include <versionhelpers.h>
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_plugin_utils_debug);
|
||||
#define GST_CAT_DEFAULT gst_d3d11_plugin_utils_debug
|
||||
|
||||
G_END_DECLS
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* Max Texture Dimension for feature level 11_0 ~ 12_1 */
|
||||
static guint _gst_d3d11_texture_max_dimension = 16384;
|
||||
|
||||
|
@ -100,7 +106,8 @@ gst_d3d11_get_device_vendor (GstD3D11Device * device)
|
|||
gchar *desc = NULL;
|
||||
GstD3D11DeviceVendor vendor = GST_D3D11_DEVICE_VENDOR_UNKNOWN;
|
||||
|
||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), FALSE);
|
||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device),
|
||||
GST_D3D11_DEVICE_VENDOR_UNKNOWN);
|
||||
|
||||
g_object_get (device, "device-id", &device_id, "vendor-id", &vendor_id,
|
||||
"description", &desc, NULL);
|
||||
|
@ -455,7 +462,8 @@ static const GstDxgiColorSpace *
|
|||
gst_d3d11_video_info_to_dxgi_color_space_rgb (GstVideoInfo * info)
|
||||
{
|
||||
gint best_score = G_MAXINT;
|
||||
gint score, i;
|
||||
gint score;
|
||||
guint i;
|
||||
const GstDxgiColorSpace *colorspace = NULL;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (rgb_colorspace_map); i++) {
|
||||
|
@ -477,7 +485,8 @@ static const GstDxgiColorSpace *
|
|||
gst_d3d11_video_info_to_dxgi_color_space_yuv (GstVideoInfo * info)
|
||||
{
|
||||
gint best_score = G_MAXINT;
|
||||
gint score, i;
|
||||
gint score;
|
||||
guint i;
|
||||
const GstDxgiColorSpace *colorspace = NULL;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (yuv_colorspace_map); i++) {
|
||||
|
@ -515,7 +524,7 @@ gst_d3d11_find_swap_chain_color_space (GstVideoInfo * info,
|
|||
{
|
||||
const GstDxgiColorSpace *colorspace = NULL;
|
||||
gint best_score = G_MAXINT;
|
||||
gint i;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (info != NULL, FALSE);
|
||||
g_return_val_if_fail (swapchain != NULL, FALSE);
|
||||
|
@ -529,8 +538,8 @@ gst_d3d11_find_swap_chain_color_space (GstVideoInfo * info,
|
|||
UINT can_support = 0;
|
||||
HRESULT hr;
|
||||
gint score;
|
||||
GST_DXGI_COLOR_SPACE_TYPE cur_type =
|
||||
rgb_colorspace_map[i].dxgi_color_space_type;
|
||||
DXGI_COLOR_SPACE_TYPE cur_type =
|
||||
(DXGI_COLOR_SPACE_TYPE) rgb_colorspace_map[i].dxgi_color_space_type;
|
||||
|
||||
/* FIXME: Non-HDR colorspace with BT2020 primaries will break rendering.
|
||||
* https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1175
|
||||
|
@ -540,8 +549,7 @@ gst_d3d11_find_swap_chain_color_space (GstVideoInfo * info,
|
|||
rgb_colorspace_map[i].primaries == GST_VIDEO_COLOR_PRIMARIES_BT2020)
|
||||
continue;
|
||||
|
||||
hr = IDXGISwapChain3_CheckColorSpaceSupport (swapchain,
|
||||
cur_type, &can_support);
|
||||
hr = swapchain->CheckColorSpaceSupport (cur_type, &can_support);
|
||||
|
||||
if (FAILED (hr))
|
||||
continue;
|
||||
|
@ -570,7 +578,7 @@ gst_d3d11_allocate_staging_buffer (GstD3D11Allocator * allocator,
|
|||
gboolean add_videometa)
|
||||
{
|
||||
GstBuffer *buffer;
|
||||
gint i;
|
||||
guint i;
|
||||
gint stride[GST_VIDEO_MAX_PLANES] = { 0, };
|
||||
gsize offset[GST_VIDEO_MAX_PLANES] = { 0, };
|
||||
GstMemory *mem;
|
||||
|
@ -586,8 +594,9 @@ gst_d3d11_allocate_staging_buffer (GstD3D11Allocator * allocator,
|
|||
gsize size[GST_VIDEO_MAX_PLANES] = { 0, };
|
||||
|
||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (info); i++) {
|
||||
mem = gst_d3d11_allocator_alloc_staging (allocator, &desc[i], 0,
|
||||
&stride[i]);
|
||||
mem =
|
||||
gst_d3d11_allocator_alloc_staging (allocator, &desc[i],
|
||||
(GstD3D11AllocationFlags) 0, &stride[i]);
|
||||
|
||||
if (!mem) {
|
||||
GST_ERROR_OBJECT (allocator, "Couldn't allocate memory for plane %d",
|
||||
|
@ -604,8 +613,8 @@ gst_d3d11_allocate_staging_buffer (GstD3D11Allocator * allocator,
|
|||
/* must be YUV semi-planar or single plane */
|
||||
g_assert (GST_VIDEO_INFO_N_PLANES (info) <= 2);
|
||||
|
||||
mem = gst_d3d11_allocator_alloc_staging (allocator, &desc[0], 0,
|
||||
&stride[0]);
|
||||
mem = gst_d3d11_allocator_alloc_staging (allocator, &desc[0],
|
||||
(GstD3D11AllocationFlags) 0, &stride[0]);
|
||||
|
||||
if (!mem) {
|
||||
GST_ERROR_OBJECT (allocator, "Couldn't allocate memory");
|
||||
|
@ -646,7 +655,7 @@ gst_d3d11_allocate_staging_buffer_for (GstBuffer * buffer,
|
|||
GstD3D11Allocator *alloc = NULL;
|
||||
GstBuffer *staging_buffer = NULL;
|
||||
D3D11_TEXTURE2D_DESC *desc;
|
||||
gint i;
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < gst_buffer_n_memory (buffer); i++) {
|
||||
GstMemory *mem = gst_buffer_peek_memory (buffer, i);
|
||||
|
@ -662,7 +671,7 @@ gst_d3d11_allocate_staging_buffer_for (GstBuffer * buffer,
|
|||
device = dmem->device;
|
||||
|
||||
params = gst_d3d11_allocation_params_new (device, (GstVideoInfo *) info,
|
||||
0, 0);
|
||||
(GstD3D11AllocationFlags) 0, 0);
|
||||
|
||||
if (!params) {
|
||||
GST_WARNING ("Couldn't create alloc params");
|
||||
|
@ -718,11 +727,11 @@ gst_d3d11_buffer_copy_into_fallback (GstBuffer * dst, GstBuffer * src,
|
|||
gboolean ret;
|
||||
|
||||
if (!gst_video_frame_map (&in_frame, (GstVideoInfo *) info, src,
|
||||
GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF))
|
||||
(GstMapFlags) (GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF)))
|
||||
goto invalid_buffer;
|
||||
|
||||
if (!gst_video_frame_map (&out_frame, (GstVideoInfo *) info, dst,
|
||||
GST_MAP_WRITE | GST_VIDEO_FRAME_MAP_FLAG_NO_REF)) {
|
||||
(GstMapFlags) (GST_MAP_WRITE | GST_VIDEO_FRAME_MAP_FLAG_NO_REF))) {
|
||||
gst_video_frame_unmap (&in_frame);
|
||||
goto invalid_buffer;
|
||||
}
|
||||
|
@ -796,12 +805,14 @@ gst_d3d11_buffer_copy_into (GstBuffer * dst, GstBuffer * src,
|
|||
|
||||
device_context = gst_d3d11_device_get_device_context_handle (device);
|
||||
|
||||
if (!gst_memory_map (dst_mem, &dst_info, GST_MAP_WRITE | GST_MAP_D3D11)) {
|
||||
if (!gst_memory_map (dst_mem, &dst_info,
|
||||
(GstMapFlags) (GST_MAP_WRITE | GST_MAP_D3D11))) {
|
||||
GST_ERROR ("Cannot map dst d3d11 memory");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!gst_memory_map (src_mem, &src_info, GST_MAP_READ | GST_MAP_D3D11)) {
|
||||
if (!gst_memory_map (src_mem, &src_info,
|
||||
(GstMapFlags) (GST_MAP_READ | GST_MAP_D3D11))) {
|
||||
GST_ERROR ("Cannot map src d3d11 memory");
|
||||
gst_memory_unmap (dst_mem, &dst_info);
|
||||
return FALSE;
|
||||
|
@ -823,8 +834,8 @@ gst_d3d11_buffer_copy_into (GstBuffer * dst, GstBuffer * src,
|
|||
src_subidx = gst_d3d11_memory_get_subresource_index (src_dmem);
|
||||
|
||||
gst_d3d11_device_lock (device);
|
||||
ID3D11DeviceContext_CopySubresourceRegion (device_context,
|
||||
dst_texture, dst_subidx, 0, 0, 0, src_texture, src_subidx, &src_box);
|
||||
device_context->CopySubresourceRegion (dst_texture, dst_subidx, 0, 0, 0,
|
||||
src_texture, src_subidx, &src_box);
|
||||
gst_d3d11_device_unlock (device);
|
||||
|
||||
gst_memory_unmap (src_mem, &src_info);
|
||||
|
@ -888,7 +899,7 @@ gst_d3d11_buffer_map (GstBuffer * buffer, ID3D11Device * device,
|
|||
GstMapInfo info[GST_VIDEO_MAX_PLANES], GstMapFlags flags)
|
||||
{
|
||||
GstMapFlags map_flags;
|
||||
gint num_mapped = 0;
|
||||
guint num_mapped = 0;
|
||||
|
||||
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
|
||||
g_return_val_if_fail (info != NULL, FALSE);
|
||||
|
@ -896,7 +907,7 @@ gst_d3d11_buffer_map (GstBuffer * buffer, ID3D11Device * device,
|
|||
if (!gst_d3d11_buffer_can_access_device (buffer, device))
|
||||
return FALSE;
|
||||
|
||||
map_flags = flags | GST_MAP_D3D11;
|
||||
map_flags = (GstMapFlags) (flags | GST_MAP_D3D11);
|
||||
|
||||
for (num_mapped = 0; num_mapped < gst_buffer_n_memory (buffer); num_mapped++) {
|
||||
GstMemory *mem = gst_buffer_peek_memory (buffer, num_mapped);
|
||||
|
@ -911,7 +922,7 @@ gst_d3d11_buffer_map (GstBuffer * buffer, ID3D11Device * device,
|
|||
|
||||
error:
|
||||
{
|
||||
gint i;
|
||||
guint i;
|
||||
for (i = 0; i < num_mapped; i++) {
|
||||
GstMemory *mem = gst_buffer_peek_memory (buffer, num_mapped);
|
||||
gst_memory_unmap (mem, &info[i]);
|
||||
|
@ -925,7 +936,7 @@ gboolean
|
|||
gst_d3d11_buffer_unmap (GstBuffer * buffer,
|
||||
GstMapInfo info[GST_VIDEO_MAX_PLANES])
|
||||
{
|
||||
gint i;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
|
||||
g_return_val_if_fail (info != NULL, FALSE);
|
||||
|
@ -943,7 +954,7 @@ guint
|
|||
gst_d3d11_buffer_get_shader_resource_view (GstBuffer * buffer,
|
||||
ID3D11ShaderResourceView * view[GST_VIDEO_MAX_PLANES])
|
||||
{
|
||||
gint i;
|
||||
guint i;
|
||||
guint num_views = 0;
|
||||
|
||||
g_return_val_if_fail (GST_IS_BUFFER (buffer), 0);
|
||||
|
@ -957,7 +968,7 @@ gst_d3d11_buffer_get_shader_resource_view (GstBuffer * buffer,
|
|||
for (i = 0; i < gst_buffer_n_memory (buffer); i++) {
|
||||
GstD3D11Memory *mem = (GstD3D11Memory *) gst_buffer_peek_memory (buffer, i);
|
||||
guint view_size;
|
||||
gint j;
|
||||
guint j;
|
||||
|
||||
view_size = gst_d3d11_memory_get_shader_resource_view_size (mem);
|
||||
if (!view_size) {
|
||||
|
@ -982,7 +993,7 @@ guint
|
|||
gst_d3d11_buffer_get_render_target_view (GstBuffer * buffer,
|
||||
ID3D11RenderTargetView * view[GST_VIDEO_MAX_PLANES])
|
||||
{
|
||||
gint i;
|
||||
guint i;
|
||||
guint num_views = 0;
|
||||
|
||||
g_return_val_if_fail (GST_IS_BUFFER (buffer), 0);
|
||||
|
@ -996,7 +1007,7 @@ gst_d3d11_buffer_get_render_target_view (GstBuffer * buffer,
|
|||
for (i = 0; i < gst_buffer_n_memory (buffer); i++) {
|
||||
GstD3D11Memory *mem = (GstD3D11Memory *) gst_buffer_peek_memory (buffer, i);
|
||||
guint view_size;
|
||||
gint j;
|
||||
guint j;
|
||||
|
||||
view_size = gst_d3d11_memory_get_render_target_view_size (mem);
|
||||
if (!view_size) {
|
|
@ -48,6 +48,13 @@ struct _GstDxgiColorSpace
|
|||
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);
|
||||
|
|
|
@ -22,11 +22,21 @@
|
|||
#endif
|
||||
|
||||
#include "gstd3d11shader.h"
|
||||
#include "gstd3d11pluginutils.h"
|
||||
#include <gmodule.h>
|
||||
#include <wrl.h>
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
using namespace Microsoft::WRL;
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_shader_debug);
|
||||
#define GST_CAT_DEFAULT gst_d3d11_shader_debug
|
||||
|
||||
G_END_DECLS
|
||||
/* *INDENT-ON* */
|
||||
|
||||
static GModule *d3d_compiler_module = NULL;
|
||||
static pD3DCompile GstD3DCompileFunc = NULL;
|
||||
|
||||
|
@ -47,7 +57,7 @@ gst_d3d11_shader_init (void)
|
|||
"d3dcompiler_44.dll",
|
||||
"d3dcompiler_43.dll",
|
||||
};
|
||||
gint i;
|
||||
guint i;
|
||||
for (i = 0; i < G_N_ELEMENTS (d3d_compiler_names); i++) {
|
||||
d3d_compiler_module =
|
||||
g_module_open (d3d_compiler_names[i], G_MODULE_BIND_LAZY);
|
||||
|
@ -74,27 +84,29 @@ gst_d3d11_shader_init (void)
|
|||
g_once_init_leave (&_init, 1);
|
||||
}
|
||||
|
||||
return ! !GstD3DCompileFunc;
|
||||
return !!GstD3DCompileFunc;
|
||||
}
|
||||
|
||||
static ID3DBlob *
|
||||
static gboolean
|
||||
compile_shader (GstD3D11Device * device, const gchar * shader_source,
|
||||
gboolean is_pixel_shader)
|
||||
gboolean is_pixel_shader, ID3DBlob ** blob)
|
||||
{
|
||||
ID3DBlob *ret;
|
||||
ID3DBlob *error = NULL;
|
||||
const gchar *shader_target;
|
||||
D3D_FEATURE_LEVEL feature_level;
|
||||
HRESULT hr;
|
||||
ID3D11Device *device_handle;
|
||||
/* *INDENT-OFF* */
|
||||
ComPtr<ID3DBlob> ret;
|
||||
ComPtr<ID3DBlob> error;
|
||||
/* *INDENT-ON* */
|
||||
|
||||
if (!gst_d3d11_shader_init ()) {
|
||||
GST_ERROR ("D3DCompiler is unavailable");
|
||||
return NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
device_handle = gst_d3d11_device_get_device_handle (device);
|
||||
feature_level = ID3D11Device_GetFeatureLevel (device_handle);
|
||||
feature_level = device_handle->GetFeatureLevel ();
|
||||
|
||||
if (is_pixel_shader) {
|
||||
if (feature_level >= D3D_FEATURE_LEVEL_10_0)
|
||||
|
@ -123,63 +135,52 @@ compile_shader (GstD3D11Device * device, const gchar * shader_source,
|
|||
const gchar *err = NULL;
|
||||
|
||||
if (error)
|
||||
err = ID3D10Blob_GetBufferPointer (error);
|
||||
err = (const gchar *) error->GetBufferPointer ();
|
||||
|
||||
GST_ERROR ("could not compile source, hr: 0x%x, error detail %s",
|
||||
(guint) hr, GST_STR_NULL (err));
|
||||
|
||||
if (error)
|
||||
ID3D10Blob_Release (error);
|
||||
|
||||
return NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
const gchar *err = ID3D10Blob_GetBufferPointer (error);
|
||||
const gchar *err = (const gchar *) error->GetBufferPointer ();
|
||||
|
||||
GST_DEBUG ("HLSL compiler warnings:\n%s\nShader code:\n%s",
|
||||
GST_STR_NULL (err), GST_STR_NULL (shader_source));
|
||||
ID3D10Blob_Release (error);
|
||||
}
|
||||
|
||||
return ret;
|
||||
*blob = ret.Detach ();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_d3d11_create_pixel_shader (GstD3D11Device * device,
|
||||
const gchar * source, ID3D11PixelShader ** shader)
|
||||
{
|
||||
ID3DBlob *ps_blob;
|
||||
ID3D11Device *device_handle;
|
||||
HRESULT hr;
|
||||
/* *INDENT-OFF* */
|
||||
ComPtr<ID3DBlob> ps_blob;
|
||||
/* *INDENT-ON* */
|
||||
|
||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), FALSE);
|
||||
g_return_val_if_fail (source != NULL, FALSE);
|
||||
g_return_val_if_fail (shader != NULL, FALSE);
|
||||
|
||||
gst_d3d11_device_lock (device);
|
||||
ps_blob = compile_shader (device, source, TRUE);
|
||||
|
||||
if (!ps_blob) {
|
||||
if (!compile_shader (device, source, TRUE, &ps_blob)) {
|
||||
GST_ERROR ("Failed to compile pixel shader");
|
||||
gst_d3d11_device_unlock (device);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
device_handle = gst_d3d11_device_get_device_handle (device);
|
||||
hr = ID3D11Device_CreatePixelShader (device_handle,
|
||||
(gpointer) ID3D10Blob_GetBufferPointer (ps_blob),
|
||||
ID3D10Blob_GetBufferSize (ps_blob), NULL, shader);
|
||||
|
||||
hr = device_handle->CreatePixelShader (ps_blob->GetBufferPointer (),
|
||||
ps_blob->GetBufferSize (), NULL, shader);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("could not create pixel shader, hr: 0x%x", (guint) hr);
|
||||
gst_d3d11_device_unlock (device);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ID3D10Blob_Release (ps_blob);
|
||||
gst_d3d11_device_unlock (device);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -188,12 +189,13 @@ gst_d3d11_create_vertex_shader (GstD3D11Device * device, const gchar * source,
|
|||
const D3D11_INPUT_ELEMENT_DESC * input_desc, guint desc_len,
|
||||
ID3D11VertexShader ** shader, ID3D11InputLayout ** layout)
|
||||
{
|
||||
ID3DBlob *vs_blob;
|
||||
ID3D11Device *device_handle;
|
||||
HRESULT hr;
|
||||
ID3D11VertexShader *vshader = NULL;
|
||||
ID3D11InputLayout *in_layout = NULL;
|
||||
gboolean ret = FALSE;
|
||||
/* *INDENT-OFF* */
|
||||
ComPtr<ID3DBlob> vs_blob;
|
||||
ComPtr<ID3D11VertexShader> vs;
|
||||
ComPtr<ID3D11InputLayout> in_layout;
|
||||
/* *INDENT-ON* */
|
||||
|
||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), FALSE);
|
||||
g_return_val_if_fail (source != NULL, FALSE);
|
||||
|
@ -202,47 +204,31 @@ gst_d3d11_create_vertex_shader (GstD3D11Device * device, const gchar * source,
|
|||
g_return_val_if_fail (shader != NULL, FALSE);
|
||||
g_return_val_if_fail (layout != NULL, FALSE);
|
||||
|
||||
gst_d3d11_device_lock (device);
|
||||
vs_blob = compile_shader (device, source, FALSE);
|
||||
if (!vs_blob) {
|
||||
if (!compile_shader (device, source, FALSE, &vs_blob)) {
|
||||
GST_ERROR ("Failed to compile shader code");
|
||||
goto done;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
device_handle = gst_d3d11_device_get_device_handle (device);
|
||||
|
||||
hr = ID3D11Device_CreateVertexShader (device_handle,
|
||||
(gpointer) ID3D10Blob_GetBufferPointer (vs_blob),
|
||||
ID3D10Blob_GetBufferSize (vs_blob), NULL, &vshader);
|
||||
|
||||
hr = device_handle->CreateVertexShader (vs_blob->GetBufferPointer (),
|
||||
vs_blob->GetBufferSize (), NULL, &vs);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("could not create vertex shader, hr: 0x%x", (guint) hr);
|
||||
ID3D10Blob_Release (vs_blob);
|
||||
goto done;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
hr = ID3D11Device_CreateInputLayout (device_handle, input_desc,
|
||||
desc_len, (gpointer) ID3D10Blob_GetBufferPointer (vs_blob),
|
||||
ID3D10Blob_GetBufferSize (vs_blob), &in_layout);
|
||||
|
||||
hr = device_handle->CreateInputLayout (input_desc,
|
||||
desc_len, vs_blob->GetBufferPointer (),
|
||||
vs_blob->GetBufferSize (), &in_layout);
|
||||
if (!gst_d3d11_result (hr, device)) {
|
||||
GST_ERROR ("could not create input layout shader, hr: 0x%x", (guint) hr);
|
||||
ID3D10Blob_Release (vs_blob);
|
||||
ID3D11VertexShader_Release (vshader);
|
||||
goto done;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ID3D10Blob_Release (vs_blob);
|
||||
*shader = vs.Detach ();
|
||||
*layout = in_layout.Detach ();
|
||||
|
||||
*shader = vshader;
|
||||
*layout = in_layout;
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
gst_d3d11_device_unlock (device);
|
||||
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
struct _GstD3D11Quad
|
||||
|
@ -289,7 +275,7 @@ gst_d3d11_quad_new (GstD3D11Device * device, ID3D11PixelShader * pixel_shader,
|
|||
|
||||
quad = g_new0 (GstD3D11Quad, 1);
|
||||
|
||||
quad->device = gst_object_ref (device);
|
||||
quad->device = (GstD3D11Device *) gst_object_ref (device);
|
||||
quad->ps = pixel_shader;
|
||||
quad->vs = vertex_shader;
|
||||
quad->layout = layout;
|
||||
|
@ -302,24 +288,25 @@ gst_d3d11_quad_new (GstD3D11Device * device, ID3D11PixelShader * pixel_shader,
|
|||
quad->index_format = index_format;
|
||||
quad->index_count = index_count;
|
||||
|
||||
ID3D11PixelShader_AddRef (pixel_shader);
|
||||
ID3D11VertexShader_AddRef (vertex_shader);
|
||||
ID3D11InputLayout_AddRef (layout);
|
||||
pixel_shader->AddRef ();
|
||||
vertex_shader->AddRef ();
|
||||
layout->AddRef ();
|
||||
vertex_buffer->AddRef ();
|
||||
index_buffer->AddRef ();
|
||||
|
||||
if (sampler)
|
||||
ID3D11SamplerState_AddRef (sampler);
|
||||
sampler->AddRef ();
|
||||
|
||||
if (blend)
|
||||
ID3D11BlendState_AddRef (blend);
|
||||
blend->AddRef ();
|
||||
|
||||
if (depth_stencil)
|
||||
ID3D11DepthStencilState_AddRef (depth_stencil);
|
||||
depth_stencil->AddRef ();
|
||||
|
||||
if (const_buffer) {
|
||||
quad->const_buffer = const_buffer;
|
||||
ID3D11Buffer_AddRef (const_buffer);
|
||||
const_buffer->AddRef ();
|
||||
}
|
||||
ID3D11Buffer_AddRef (vertex_buffer);
|
||||
ID3D11Buffer_AddRef (index_buffer);
|
||||
|
||||
return quad;
|
||||
}
|
||||
|
@ -329,24 +316,15 @@ gst_d3d11_quad_free (GstD3D11Quad * quad)
|
|||
{
|
||||
g_return_if_fail (quad != NULL);
|
||||
|
||||
if (quad->ps)
|
||||
ID3D11PixelShader_Release (quad->ps);
|
||||
if (quad->vs)
|
||||
ID3D11VertexShader_Release (quad->vs);
|
||||
if (quad->layout)
|
||||
ID3D11InputLayout_Release (quad->layout);
|
||||
if (quad->sampler)
|
||||
ID3D11SamplerState_Release (quad->sampler);
|
||||
if (quad->blend)
|
||||
ID3D11BlendState_Release (quad->blend);
|
||||
if (quad->depth_stencil)
|
||||
ID3D11DepthStencilState_Release (quad->depth_stencil);
|
||||
if (quad->const_buffer)
|
||||
ID3D11Buffer_Release (quad->const_buffer);
|
||||
if (quad->vertex_buffer)
|
||||
ID3D11Buffer_Release (quad->vertex_buffer);
|
||||
if (quad->index_buffer)
|
||||
ID3D11Buffer_Release (quad->index_buffer);
|
||||
GST_D3D11_CLEAR_COM (quad->ps);
|
||||
GST_D3D11_CLEAR_COM (quad->vs);
|
||||
GST_D3D11_CLEAR_COM (quad->layout);
|
||||
GST_D3D11_CLEAR_COM (quad->sampler);
|
||||
GST_D3D11_CLEAR_COM (quad->blend);
|
||||
GST_D3D11_CLEAR_COM (quad->depth_stencil);
|
||||
GST_D3D11_CLEAR_COM (quad->const_buffer);
|
||||
GST_D3D11_CLEAR_COM (quad->vertex_buffer);
|
||||
GST_D3D11_CLEAR_COM (quad->index_buffer);
|
||||
|
||||
gst_clear_object (&quad->device);
|
||||
g_free (quad);
|
||||
|
@ -380,7 +358,7 @@ gst_d3d11_draw_quad_unlocked (GstD3D11Quad * quad,
|
|||
ID3D11DepthStencilView * dsv, ID3D11BlendState * blend,
|
||||
gfloat blend_factor[4])
|
||||
{
|
||||
ID3D11DeviceContext *context_handle;
|
||||
ID3D11DeviceContext *context;
|
||||
UINT offsets = 0;
|
||||
ID3D11ShaderResourceView *clear_view[GST_VIDEO_MAX_PLANES] = { NULL, };
|
||||
ID3D11BlendState *blend_state = blend;
|
||||
|
@ -391,43 +369,36 @@ gst_d3d11_draw_quad_unlocked (GstD3D11Quad * quad,
|
|||
g_return_val_if_fail (rtv != NULL, FALSE);
|
||||
g_return_val_if_fail (num_rtv <= GST_VIDEO_MAX_PLANES, FALSE);
|
||||
|
||||
context_handle = gst_d3d11_device_get_device_context_handle (quad->device);
|
||||
context = gst_d3d11_device_get_device_context_handle (quad->device);
|
||||
|
||||
ID3D11DeviceContext_IASetPrimitiveTopology (context_handle,
|
||||
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
ID3D11DeviceContext_IASetInputLayout (context_handle, quad->layout);
|
||||
ID3D11DeviceContext_IASetVertexBuffers (context_handle,
|
||||
0, 1, &quad->vertex_buffer, &quad->vertex_stride, &offsets);
|
||||
ID3D11DeviceContext_IASetIndexBuffer (context_handle,
|
||||
quad->index_buffer, quad->index_format, 0);
|
||||
context->IASetPrimitiveTopology (D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
context->IASetInputLayout (quad->layout);
|
||||
context->IASetVertexBuffers (0, 1, &quad->vertex_buffer, &quad->vertex_stride,
|
||||
&offsets);
|
||||
context->IASetIndexBuffer (quad->index_buffer, quad->index_format, 0);
|
||||
|
||||
if (quad->sampler)
|
||||
ID3D11DeviceContext_PSSetSamplers (context_handle, 0, 1, &quad->sampler);
|
||||
ID3D11DeviceContext_VSSetShader (context_handle, quad->vs, NULL, 0);
|
||||
ID3D11DeviceContext_PSSetShader (context_handle, quad->ps, NULL, 0);
|
||||
ID3D11DeviceContext_RSSetViewports (context_handle, num_viewport, viewport);
|
||||
context->PSSetSamplers (0, 1, &quad->sampler);
|
||||
context->VSSetShader (quad->vs, NULL, 0);
|
||||
context->PSSetShader (quad->ps, NULL, 0);
|
||||
context->RSSetViewports (num_viewport, viewport);
|
||||
|
||||
if (quad->const_buffer)
|
||||
ID3D11DeviceContext_PSSetConstantBuffers (context_handle,
|
||||
0, 1, &quad->const_buffer);
|
||||
context->PSSetConstantBuffers (0, 1, &quad->const_buffer);
|
||||
|
||||
if (srv)
|
||||
ID3D11DeviceContext_PSSetShaderResources (context_handle, 0, num_srv, srv);
|
||||
ID3D11DeviceContext_OMSetRenderTargets (context_handle, num_rtv, rtv, dsv);
|
||||
context->PSSetShaderResources (0, num_srv, srv);
|
||||
context->OMSetRenderTargets (num_rtv, rtv, dsv);
|
||||
if (!blend_state)
|
||||
blend_state = quad->blend;
|
||||
ID3D11DeviceContext_OMSetBlendState (context_handle,
|
||||
blend_state, blend_factor, 0xffffffff);
|
||||
ID3D11DeviceContext_OMSetDepthStencilState (context_handle,
|
||||
quad->depth_stencil, 1);
|
||||
context->OMSetBlendState (blend_state, blend_factor, 0xffffffff);
|
||||
context->OMSetDepthStencilState (quad->depth_stencil, 1);
|
||||
|
||||
ID3D11DeviceContext_DrawIndexed (context_handle, quad->index_count, 0, 0);
|
||||
context->DrawIndexed (quad->index_count, 0, 0);
|
||||
|
||||
if (srv) {
|
||||
ID3D11DeviceContext_PSSetShaderResources (context_handle,
|
||||
0, num_srv, clear_view);
|
||||
}
|
||||
ID3D11DeviceContext_OMSetRenderTargets (context_handle, 0, NULL, NULL);
|
||||
if (srv)
|
||||
context->PSSetShaderResources (0, num_srv, clear_view);
|
||||
context->OMSetRenderTargets (0, NULL, NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -441,7 +441,7 @@ gst_d3d11_upload_transform (GstBaseTransform * trans, GstBuffer * inbuf,
|
|||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
gboolean use_staging_buf;
|
||||
GstBuffer *target_outbuf = outbuf;
|
||||
gint i;
|
||||
guint i;
|
||||
|
||||
use_staging_buf = gst_d3d11_upload_can_use_staging_buffer (self, outbuf);
|
||||
|
||||
|
@ -451,11 +451,11 @@ gst_d3d11_upload_transform (GstBaseTransform * trans, GstBuffer * inbuf,
|
|||
}
|
||||
|
||||
if (!gst_video_frame_map (&in_frame, &filter->in_info, inbuf,
|
||||
GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF))
|
||||
(GstMapFlags) (GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF)))
|
||||
goto invalid_buffer;
|
||||
|
||||
if (!gst_video_frame_map (&out_frame, &filter->out_info, target_outbuf,
|
||||
GST_MAP_WRITE | GST_VIDEO_FRAME_MAP_FLAG_NO_REF)) {
|
||||
(GstMapFlags) (GST_MAP_WRITE | GST_VIDEO_FRAME_MAP_FLAG_NO_REF))) {
|
||||
gst_video_frame_unmap (&in_frame);
|
||||
goto invalid_buffer;
|
||||
}
|
|
@ -22,12 +22,19 @@
|
|||
#endif
|
||||
|
||||
#include "gstd3d11videoprocessor.h"
|
||||
#include "gstd3d11pluginutils.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_video_processor_debug);
|
||||
#define GST_CAT_DEFAULT gst_d3d11_video_processor_debug
|
||||
|
||||
G_END_DECLS
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#if (GST_D3D11_HEADER_VERSION >= 1 && GST_D3D11_DXGI_HEADER_VERSION >= 4)
|
||||
#define HAVE_VIDEO_CONTEXT_ONE
|
||||
#endif
|
||||
|
@ -64,23 +71,23 @@ gst_d3d11_video_processor_new (GstD3D11Device * device, guint in_width,
|
|||
ID3D11Device *device_handle;
|
||||
ID3D11DeviceContext *context_handle;
|
||||
HRESULT hr;
|
||||
D3D11_VIDEO_PROCESSOR_CONTENT_DESC desc = { 0, };
|
||||
D3D11_VIDEO_PROCESSOR_CONTENT_DESC desc;
|
||||
|
||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), NULL);
|
||||
|
||||
memset (&desc, 0, sizeof (desc));
|
||||
|
||||
device_handle = gst_d3d11_device_get_device_handle (device);
|
||||
context_handle = gst_d3d11_device_get_device_context_handle (device);
|
||||
|
||||
self = g_new0 (GstD3D11VideoProcessor, 1);
|
||||
self->device = gst_object_ref (device);
|
||||
self->device = (GstD3D11Device *) gst_object_ref (device);
|
||||
|
||||
hr = ID3D11Device_QueryInterface (device_handle,
|
||||
&IID_ID3D11VideoDevice, (void **) &self->video_device);
|
||||
hr = device_handle->QueryInterface (IID_PPV_ARGS (&self->video_device));
|
||||
if (!gst_d3d11_result (hr, device))
|
||||
goto fail;
|
||||
|
||||
hr = ID3D11DeviceContext_QueryInterface (context_handle,
|
||||
&IID_ID3D11VideoContext, (void **) &self->video_context);
|
||||
hr = context_handle->QueryInterface (IID_PPV_ARGS (&self->video_context));
|
||||
if (!gst_d3d11_result (hr, device))
|
||||
goto fail;
|
||||
|
||||
|
@ -93,38 +100,36 @@ gst_d3d11_video_processor_new (GstD3D11Device * device, guint in_width,
|
|||
/* TODO: make option for this */
|
||||
desc.Usage = D3D11_VIDEO_USAGE_PLAYBACK_NORMAL;
|
||||
|
||||
hr = ID3D11VideoDevice_CreateVideoProcessorEnumerator (self->video_device,
|
||||
&desc, &self->enumerator);
|
||||
hr = self->video_device->CreateVideoProcessorEnumerator (&desc,
|
||||
&self->enumerator);
|
||||
if (!gst_d3d11_result (hr, device))
|
||||
goto fail;
|
||||
#ifdef HAVE_VIDEO_CONTEXT_ONE
|
||||
hr = ID3D11VideoContext_QueryInterface (self->enumerator,
|
||||
&IID_ID3D11VideoProcessorEnumerator1, (void **) &self->enumerator1);
|
||||
hr = self->enumerator->QueryInterface (IID_PPV_ARGS (&self->enumerator1));
|
||||
if (gst_d3d11_result (hr, device)) {
|
||||
GST_DEBUG ("ID3D11VideoProcessorEnumerator1 interface available");
|
||||
}
|
||||
#endif
|
||||
|
||||
hr = ID3D11VideoProcessorEnumerator_GetVideoProcessorCaps (self->enumerator,
|
||||
&self->processor_caps);
|
||||
hr = self->enumerator->GetVideoProcessorCaps (&self->processor_caps);
|
||||
if (!gst_d3d11_result (hr, device))
|
||||
goto fail;
|
||||
|
||||
hr = ID3D11VideoDevice_CreateVideoProcessor (self->video_device,
|
||||
self->enumerator, 0, &self->processor);
|
||||
hr = self->video_device->CreateVideoProcessor (self->enumerator, 0,
|
||||
&self->processor);
|
||||
if (!gst_d3d11_result (hr, device))
|
||||
goto fail;
|
||||
|
||||
#ifdef HAVE_VIDEO_CONTEXT_ONE
|
||||
hr = ID3D11VideoContext_QueryInterface (self->video_context,
|
||||
&IID_ID3D11VideoContext1, (void **) &self->video_context1);
|
||||
hr = self->video_context->
|
||||
QueryInterface (IID_PPV_ARGS (&self->video_context1));
|
||||
if (gst_d3d11_result (hr, device)) {
|
||||
GST_DEBUG ("ID3D11VideoContext1 interface available");
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_VIDEO_CONTEXT_TWO
|
||||
hr = ID3D11VideoContext_QueryInterface (self->video_context,
|
||||
&IID_ID3D11VideoContext2, (void **) &self->video_context2);
|
||||
hr = self->video_context->
|
||||
QueryInterface (IID_PPV_ARGS (&self->video_context2));
|
||||
if (gst_d3d11_result (hr, device)) {
|
||||
GST_DEBUG ("ID3D11VideoContext2 interface available");
|
||||
}
|
||||
|
@ -133,8 +138,8 @@ gst_d3d11_video_processor_new (GstD3D11Device * device, guint in_width,
|
|||
/* Setting up default options */
|
||||
gst_d3d11_device_lock (self->device);
|
||||
/* We don't want auto processing by driver */
|
||||
ID3D11VideoContext_VideoProcessorSetStreamAutoProcessingMode
|
||||
(self->video_context, self->processor, 0, FALSE);
|
||||
self->video_context->VideoProcessorSetStreamAutoProcessingMode
|
||||
(self->processor, 0, FALSE);
|
||||
gst_d3d11_device_unlock (self->device);
|
||||
|
||||
return self;
|
||||
|
@ -150,25 +155,18 @@ gst_d3d11_video_processor_free (GstD3D11VideoProcessor * processor)
|
|||
{
|
||||
g_return_if_fail (processor != NULL);
|
||||
|
||||
if (processor->video_device)
|
||||
ID3D11VideoDevice_Release (processor->video_device);
|
||||
if (processor->video_context)
|
||||
ID3D11VideoContext_Release (processor->video_context);
|
||||
GST_D3D11_CLEAR_COM (processor->video_device);
|
||||
GST_D3D11_CLEAR_COM (processor->video_context);
|
||||
#ifdef HAVE_VIDEO_CONTEXT_ONE
|
||||
if (processor->video_context1)
|
||||
ID3D11VideoContext1_Release (processor->video_context1);
|
||||
GST_D3D11_CLEAR_COM (processor->video_context1);
|
||||
#endif
|
||||
#ifdef HAVE_VIDEO_CONTEXT_TWO
|
||||
if (processor->video_context2)
|
||||
ID3D11VideoContext2_Release (processor->video_context2);
|
||||
GST_D3D11_CLEAR_COM (processor->video_context2);
|
||||
#endif
|
||||
if (processor->processor)
|
||||
ID3D11VideoProcessor_Release (processor->processor);
|
||||
if (processor->enumerator)
|
||||
ID3D11VideoProcessorEnumerator_Release (processor->enumerator);
|
||||
GST_D3D11_CLEAR_COM (processor->processor);
|
||||
GST_D3D11_CLEAR_COM (processor->enumerator);
|
||||
#ifdef HAVE_VIDEO_CONTEXT_ONE
|
||||
if (processor->enumerator1)
|
||||
ID3D11VideoProcessorEnumerator1_Release (processor->enumerator1);
|
||||
GST_D3D11_CLEAR_COM (processor->enumerator1);
|
||||
#endif
|
||||
|
||||
gst_clear_object (&processor->device);
|
||||
|
@ -182,8 +180,7 @@ gst_d3d11_video_processor_supports_format (GstD3D11VideoProcessor *
|
|||
HRESULT hr;
|
||||
UINT flag = 0;
|
||||
|
||||
hr = ID3D11VideoProcessorEnumerator_CheckVideoProcessorFormat
|
||||
(self->enumerator, format, &flag);
|
||||
hr = self->enumerator->CheckVideoProcessorFormat (format, &flag);
|
||||
|
||||
if (!gst_d3d11_result (hr, self->device))
|
||||
return FALSE;
|
||||
|
@ -281,8 +278,8 @@ gst_d3d11_video_processor_set_input_color_space (GstD3D11VideoProcessor *
|
|||
|
||||
video_processor_color_space_from_gst (processor, color, &color_space);
|
||||
|
||||
ID3D11VideoContext_VideoProcessorSetStreamColorSpace
|
||||
(processor->video_context, processor->processor, 0, &color_space);
|
||||
processor->video_context->VideoProcessorSetStreamColorSpace
|
||||
(processor->processor, 0, &color_space);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -298,8 +295,8 @@ gst_d3d11_video_processor_set_output_color_space (GstD3D11VideoProcessor *
|
|||
|
||||
video_processor_color_space_from_gst (processor, color, &color_space);
|
||||
|
||||
ID3D11VideoContext_VideoProcessorSetOutputColorSpace
|
||||
(processor->video_context, processor->processor, &color_space);
|
||||
processor->video_context->VideoProcessorSetOutputColorSpace
|
||||
(processor->processor, &color_space);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -319,9 +316,8 @@ gst_d3d11_video_processor_check_format_conversion (GstD3D11VideoProcessor *
|
|||
if (!processor->enumerator1)
|
||||
return FALSE;
|
||||
|
||||
hr = ID3D11VideoProcessorEnumerator1_CheckVideoProcessorFormatConversion
|
||||
(processor->enumerator1, in_format, in_color_space, out_format,
|
||||
out_color_space, &supported);
|
||||
hr = processor->enumerator1->CheckVideoProcessorFormatConversion
|
||||
(in_format, in_color_space, out_format, out_color_space, &supported);
|
||||
if (!gst_d3d11_result (hr, processor->device)) {
|
||||
GST_WARNING ("Failed to check conversion support");
|
||||
return FALSE;
|
||||
|
@ -341,8 +337,8 @@ gst_d3d11_video_processor_set_input_dxgi_color_space (GstD3D11VideoProcessor *
|
|||
|
||||
#ifdef HAVE_VIDEO_CONTEXT_ONE
|
||||
if (processor->video_context1) {
|
||||
ID3D11VideoContext1_VideoProcessorSetStreamColorSpace1
|
||||
(processor->video_context1, processor->processor, 0, color_space);
|
||||
processor->video_context1->VideoProcessorSetStreamColorSpace1
|
||||
(processor->processor, 0, color_space);
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
@ -358,8 +354,8 @@ gst_d3d11_video_processor_set_output_dxgi_color_space (GstD3D11VideoProcessor *
|
|||
|
||||
#ifdef HAVE_VIDEO_CONTEXT_ONE
|
||||
if (processor->video_context1) {
|
||||
ID3D11VideoContext1_VideoProcessorSetOutputColorSpace1
|
||||
(processor->video_context1, processor->processor, color_space);
|
||||
processor->video_context1->VideoProcessorSetOutputColorSpace1
|
||||
(processor->processor, color_space);
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
@ -383,14 +379,13 @@ gst_d3d11_video_processor_set_input_hdr10_metadata (GstD3D11VideoProcessor *
|
|||
if (processor->video_context2 && (processor->processor_caps.FeatureCaps &
|
||||
FEATURE_CAPS_METADATA_HDR10)) {
|
||||
if (hdr10_meta) {
|
||||
ID3D11VideoContext2_VideoProcessorSetStreamHDRMetaData
|
||||
(processor->video_context2, processor->processor, 0,
|
||||
processor->video_context2->VideoProcessorSetStreamHDRMetaData
|
||||
(processor->processor, 0,
|
||||
DXGI_HDR_METADATA_TYPE_HDR10, sizeof (DXGI_HDR_METADATA_HDR10),
|
||||
hdr10_meta);
|
||||
} else {
|
||||
ID3D11VideoContext2_VideoProcessorSetStreamHDRMetaData
|
||||
(processor->video_context2, processor->processor, 0,
|
||||
DXGI_HDR_METADATA_TYPE_NONE, 0, NULL);
|
||||
processor->video_context2->VideoProcessorSetStreamHDRMetaData
|
||||
(processor->processor, 0, DXGI_HDR_METADATA_TYPE_NONE, 0, NULL);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -410,14 +405,12 @@ gst_d3d11_video_processor_set_output_hdr10_metadata (GstD3D11VideoProcessor *
|
|||
if (processor->video_context2 && (processor->processor_caps.FeatureCaps &
|
||||
FEATURE_CAPS_METADATA_HDR10)) {
|
||||
if (hdr10_meta) {
|
||||
ID3D11VideoContext2_VideoProcessorSetOutputHDRMetaData
|
||||
(processor->video_context2, processor->processor,
|
||||
DXGI_HDR_METADATA_TYPE_HDR10, sizeof (DXGI_HDR_METADATA_HDR10),
|
||||
hdr10_meta);
|
||||
processor->video_context2->VideoProcessorSetOutputHDRMetaData
|
||||
(processor->processor, DXGI_HDR_METADATA_TYPE_HDR10,
|
||||
sizeof (DXGI_HDR_METADATA_HDR10), hdr10_meta);
|
||||
} else {
|
||||
ID3D11VideoContext2_VideoProcessorSetOutputHDRMetaData
|
||||
(processor->video_context2, processor->processor,
|
||||
DXGI_HDR_METADATA_TYPE_NONE, 0, NULL);
|
||||
processor->video_context2->VideoProcessorSetOutputHDRMetaData
|
||||
(processor->processor, DXGI_HDR_METADATA_TYPE_NONE, 0, NULL);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -440,8 +433,8 @@ gst_d3d11_video_processor_create_input_view (GstD3D11VideoProcessor * processor,
|
|||
g_return_val_if_fail (resource != NULL, FALSE);
|
||||
g_return_val_if_fail (view != NULL, FALSE);
|
||||
|
||||
hr = ID3D11VideoDevice_CreateVideoProcessorInputView (processor->video_device,
|
||||
resource, processor->enumerator, desc, view);
|
||||
hr = processor->video_device->CreateVideoProcessorInputView (resource,
|
||||
processor->enumerator, desc, view);
|
||||
if (!gst_d3d11_result (hr, processor->device))
|
||||
return FALSE;
|
||||
|
||||
|
@ -468,8 +461,8 @@ gst_d3d11_video_processor_create_output_view (GstD3D11VideoProcessor *
|
|||
g_return_val_if_fail (resource != NULL, FALSE);
|
||||
g_return_val_if_fail (view != NULL, FALSE);
|
||||
|
||||
hr = ID3D11VideoDevice_CreateVideoProcessorOutputView
|
||||
(processor->video_device, resource, processor->enumerator, desc, view);
|
||||
hr = processor->video_device->CreateVideoProcessorOutputView
|
||||
(resource, processor->enumerator, desc, view);
|
||||
if (!gst_d3d11_result (hr, processor->device))
|
||||
return FALSE;
|
||||
|
||||
|
@ -484,26 +477,6 @@ gst_d3d11_video_processor_get_output_view (GstD3D11VideoProcessor *
|
|||
processor->video_device, processor->enumerator);
|
||||
}
|
||||
|
||||
void
|
||||
gst_d3d11_video_processor_input_view_release (ID3D11VideoProcessorInputView *
|
||||
view)
|
||||
{
|
||||
if (!view)
|
||||
return;
|
||||
|
||||
ID3D11VideoProcessorInputView_Release (view);
|
||||
}
|
||||
|
||||
void
|
||||
gst_d3d11_video_processor_output_view_release (ID3D11VideoProcessorOutputView *
|
||||
view)
|
||||
{
|
||||
if (!view)
|
||||
return;
|
||||
|
||||
ID3D11VideoProcessorOutputView_Release (view);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_d3d11_video_processor_render (GstD3D11VideoProcessor * processor,
|
||||
RECT * in_rect, ID3D11VideoProcessorInputView * in_view,
|
||||
|
@ -530,6 +503,8 @@ gst_d3d11_video_processor_render_unlocked (GstD3D11VideoProcessor * processor,
|
|||
{
|
||||
HRESULT hr;
|
||||
D3D11_VIDEO_PROCESSOR_STREAM stream = { 0, };
|
||||
ID3D11VideoContext *context;
|
||||
ID3D11VideoProcessor *proc;
|
||||
|
||||
g_return_val_if_fail (processor != NULL, FALSE);
|
||||
g_return_val_if_fail (in_view != NULL, FALSE);
|
||||
|
@ -537,29 +512,24 @@ gst_d3d11_video_processor_render_unlocked (GstD3D11VideoProcessor * processor,
|
|||
|
||||
stream.Enable = TRUE;
|
||||
stream.pInputSurface = in_view;
|
||||
context = processor->video_context;
|
||||
proc = processor->processor;
|
||||
|
||||
if (in_rect) {
|
||||
ID3D11VideoContext_VideoProcessorSetStreamSourceRect
|
||||
(processor->video_context, processor->processor, 0, TRUE, in_rect);
|
||||
context->VideoProcessorSetStreamSourceRect (proc, 0, TRUE, in_rect);
|
||||
} else {
|
||||
ID3D11VideoContext_VideoProcessorSetStreamSourceRect
|
||||
(processor->video_context, processor->processor, 0, FALSE, NULL);
|
||||
context->VideoProcessorSetStreamSourceRect (proc, 0, FALSE, NULL);
|
||||
}
|
||||
|
||||
if (out_rect) {
|
||||
ID3D11VideoContext_VideoProcessorSetStreamDestRect
|
||||
(processor->video_context, processor->processor, 0, TRUE, out_rect);
|
||||
ID3D11VideoContext_VideoProcessorSetOutputTargetRect
|
||||
(processor->video_context, processor->processor, TRUE, out_rect);
|
||||
context->VideoProcessorSetStreamDestRect (proc, 0, TRUE, out_rect);
|
||||
context->VideoProcessorSetOutputTargetRect (proc, TRUE, out_rect);
|
||||
} else {
|
||||
ID3D11VideoContext_VideoProcessorSetStreamDestRect
|
||||
(processor->video_context, processor->processor, 0, FALSE, NULL);
|
||||
ID3D11VideoContext_VideoProcessorSetOutputTargetRect
|
||||
(processor->video_context, processor->processor, FALSE, NULL);
|
||||
context->VideoProcessorSetStreamDestRect (proc, 0, FALSE, NULL);
|
||||
context->VideoProcessorSetOutputTargetRect (proc, FALSE, NULL);
|
||||
}
|
||||
|
||||
hr = ID3D11VideoContext_VideoProcessorBlt (processor->video_context,
|
||||
processor->processor, out_view, 0, 1, &stream);
|
||||
hr = context->VideoProcessorBlt (proc, out_view, 0, 1, &stream);
|
||||
if (!gst_d3d11_result (hr, processor->device))
|
||||
return FALSE;
|
||||
|
|
@ -89,10 +89,6 @@ gboolean gst_d3d11_video_processor_create_output_view (GstD3D11VideoProcessor *
|
|||
ID3D11VideoProcessorOutputView * gst_d3d11_video_processor_get_output_view (GstD3D11VideoProcessor * processor,
|
||||
GstD3D11Memory *mem);
|
||||
|
||||
void gst_d3d11_video_processor_input_view_release (ID3D11VideoProcessorInputView * view);
|
||||
|
||||
void gst_d3d11_video_processor_output_view_release (ID3D11VideoProcessorOutputView * view);
|
||||
|
||||
gboolean gst_d3d11_video_processor_render (GstD3D11VideoProcessor * processor,
|
||||
RECT *in_rect,
|
||||
ID3D11VideoProcessorInputView * in_view,
|
||||
|
|
|
@ -196,35 +196,36 @@ gst_d3d11_video_sink_class_init (GstD3D11VideoSinkClass * klass)
|
|||
g_param_spec_int ("adapter", "Adapter",
|
||||
"Adapter index for creating device (-1 for default)",
|
||||
-1, G_MAXINT32, DEFAULT_ADAPTER,
|
||||
G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_FORCE_ASPECT_RATIO,
|
||||
g_param_spec_boolean ("force-aspect-ratio",
|
||||
"Force aspect ratio",
|
||||
"When enabled, scaling will respect original aspect ratio",
|
||||
DEFAULT_FORCE_ASPECT_RATIO,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_ENABLE_NAVIGATION_EVENTS,
|
||||
g_param_spec_boolean ("enable-navigation-events",
|
||||
"Enable navigation events",
|
||||
"When enabled, navigation events are sent upstream",
|
||||
DEFAULT_ENABLE_NAVIGATION_EVENTS,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_FULLSCREEN_TOGGLE_MODE,
|
||||
g_param_spec_flags ("fullscreen-toggle-mode",
|
||||
"Full screen toggle mode",
|
||||
"Full screen toggle mode used to trigger fullscreen mode change",
|
||||
GST_D3D11_WINDOW_TOGGLE_MODE_GET_TYPE, DEFAULT_FULLSCREEN_TOGGLE_MODE,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_FULLSCREEN,
|
||||
g_param_spec_boolean ("fullscreen",
|
||||
"fullscreen",
|
||||
"Ignored when \"fullscreen-toggle-mode\" does not include \"property\"",
|
||||
DEFAULT_FULLSCREEN, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
DEFAULT_FULLSCREEN,
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
#ifdef HAVE_DIRECT_WRITE
|
||||
g_object_class_install_property (gobject_class, PROP_RENDER_STATS,
|
||||
|
@ -232,8 +233,9 @@ gst_d3d11_video_sink_class_init (GstD3D11VideoSinkClass * klass)
|
|||
"Render Stats",
|
||||
"Render statistics data (e.g., average framerate) on window",
|
||||
DEFAULT_RENDER_STATS,
|
||||
GST_PARAM_CONDITIONALLY_AVAILABLE | GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (GST_PARAM_CONDITIONALLY_AVAILABLE |
|
||||
GST_PARAM_MUTABLE_READY | G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -262,8 +264,8 @@ gst_d3d11_video_sink_class_init (GstD3D11VideoSinkClass * klass)
|
|||
"DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, and "
|
||||
"DXGI_FORMAT_R10G10B10A2_UNORM.",
|
||||
DEFAULT_DRAW_ON_SHARED_TEXTURE,
|
||||
G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
/**
|
||||
* GstD3D11VideoSink::begin-draw:
|
||||
|
@ -301,7 +303,7 @@ gst_d3d11_video_sink_class_init (GstD3D11VideoSinkClass * klass)
|
|||
*/
|
||||
gst_d3d11_video_sink_signals[SIGNAL_DRAW] =
|
||||
g_signal_new ("draw", G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
||||
(GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
|
||||
G_STRUCT_OFFSET (GstD3D11VideoSinkClass, draw), NULL, NULL, NULL,
|
||||
G_TYPE_BOOLEAN, 4, G_TYPE_POINTER, G_TYPE_UINT, G_TYPE_UINT64,
|
||||
G_TYPE_UINT64);
|
||||
|
@ -335,7 +337,8 @@ gst_d3d11_video_sink_class_init (GstD3D11VideoSinkClass * klass)
|
|||
|
||||
klass->draw = gst_d3d11_video_sink_draw_action;
|
||||
|
||||
gst_type_mark_as_plugin_api (GST_D3D11_WINDOW_TOGGLE_MODE_GET_TYPE, 0);
|
||||
gst_type_mark_as_plugin_api (GST_D3D11_WINDOW_TOGGLE_MODE_GET_TYPE,
|
||||
(GstPluginAPIFlags) 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -377,7 +380,8 @@ gst_d3d11_videosink_set_property (GObject * object, guint prop_id,
|
|||
}
|
||||
break;
|
||||
case PROP_FULLSCREEN_TOGGLE_MODE:
|
||||
self->fullscreen_toggle_mode = g_value_get_flags (value);
|
||||
self->fullscreen_toggle_mode =
|
||||
(GstD3D11WindowFullscreenToggleMode) g_value_get_flags (value);
|
||||
if (self->window) {
|
||||
g_object_set (self->window,
|
||||
"fullscreen-toggle-mode", self->fullscreen_toggle_mode, NULL);
|
||||
|
@ -471,7 +475,7 @@ gst_d3d11_video_sink_get_supported_caps (GstD3D11VideoSink * self,
|
|||
GstD3D11Device *device;
|
||||
ID3D11Device *d3d11_device;
|
||||
HRESULT hr;
|
||||
gint i;
|
||||
guint i;
|
||||
GValue v_list = G_VALUE_INIT;
|
||||
GstCaps *supported_caps;
|
||||
static const GstVideoFormat format_list[] = {
|
||||
|
@ -501,8 +505,8 @@ gst_d3d11_video_sink_get_supported_caps (GstD3D11VideoSink * self,
|
|||
continue;
|
||||
|
||||
format = d3d11_format->format;
|
||||
hr = ID3D11Device_CheckFormatSupport (d3d11_device,
|
||||
d3d11_format->dxgi_format, &format_support);
|
||||
hr = d3d11_device->CheckFormatSupport (d3d11_format->dxgi_format,
|
||||
&format_support);
|
||||
|
||||
if (SUCCEEDED (hr) && ((format_support & flags) == flags)) {
|
||||
GValue v_str = G_VALUE_INIT;
|
||||
|
@ -539,7 +543,8 @@ gst_d3d11_video_sink_get_caps (GstBaseSink * sink, GstCaps * filter)
|
|||
GstCapsFeatures *features;
|
||||
|
||||
caps = gst_d3d11_video_sink_get_supported_caps (self,
|
||||
D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_DISPLAY);
|
||||
(D3D11_FORMAT_SUPPORT) (D3D11_FORMAT_SUPPORT_TEXTURE2D |
|
||||
D3D11_FORMAT_SUPPORT_DISPLAY));
|
||||
overlaycaps = gst_caps_copy (caps);
|
||||
features = gst_caps_features_new (GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY,
|
||||
GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION, NULL);
|
||||
|
@ -684,7 +689,7 @@ gst_d3d11_video_sink_set_caps (GstBaseSink * sink, GstCaps * caps)
|
|||
}
|
||||
|
||||
d3d11_params = gst_d3d11_allocation_params_new (self->device,
|
||||
&self->info, 0, bind_flags);
|
||||
&self->info, (GstD3D11AllocationFlags) 0, bind_flags);
|
||||
|
||||
self->fallback_pool = gst_d3d11_buffer_pool_new_with_options (self->device,
|
||||
caps, d3d11_params, 2, 0);
|
||||
|
@ -909,8 +914,8 @@ gst_d3d11_video_sink_propose_allocation (GstBaseSink * sink, GstQuery * query)
|
|||
|
||||
GST_DEBUG_OBJECT (self, "create new pool");
|
||||
|
||||
d3d11_params = gst_d3d11_allocation_params_new (self->device, &info, 0,
|
||||
D3D11_BIND_SHADER_RESOURCE);
|
||||
d3d11_params = gst_d3d11_allocation_params_new (self->device, &info,
|
||||
(GstD3D11AllocationFlags) 0, D3D11_BIND_SHADER_RESOURCE);
|
||||
pool = gst_d3d11_buffer_pool_new_with_options (self->device, caps,
|
||||
d3d11_params, 2, 0);
|
||||
gst_d3d11_allocation_params_free (d3d11_params);
|
||||
|
@ -1001,11 +1006,11 @@ gst_d3d11_video_sink_upload_frame (GstD3D11VideoSink * self, GstBuffer * inbuf,
|
|||
GST_LOG_OBJECT (self, "Copy to fallback buffer");
|
||||
|
||||
if (!gst_video_frame_map (&in_frame, &self->info, inbuf,
|
||||
GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF))
|
||||
(GstMapFlags) (GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF)))
|
||||
goto invalid_buffer;
|
||||
|
||||
if (!gst_video_frame_map (&out_frame, &self->info, outbuf,
|
||||
GST_MAP_WRITE | GST_VIDEO_FRAME_MAP_FLAG_NO_REF)) {
|
||||
(GstMapFlags) (GST_MAP_WRITE | GST_VIDEO_FRAME_MAP_FLAG_NO_REF))) {
|
||||
gst_video_frame_unmap (&in_frame);
|
||||
goto invalid_buffer;
|
||||
}
|
|
@ -180,105 +180,111 @@ gst_d3d11_video_sink_bin_class_init (GstD3D11VideoSinkBinClass * klass)
|
|||
/* basesink */
|
||||
g_object_class_install_property (gobject_class, PROP_SYNC,
|
||||
g_param_spec_boolean ("sync", "Sync", "Sync on the clock", DEFAULT_SYNC,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_MAX_LATENESS,
|
||||
g_param_spec_int64 ("max-lateness", "Max Lateness",
|
||||
"Maximum number of nanoseconds that a buffer can be late before it "
|
||||
"is dropped (-1 unlimited)", -1, G_MAXINT64, DEFAULT_MAX_LATENESS,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_QOS,
|
||||
g_param_spec_boolean ("qos", "Qos",
|
||||
"Generate Quality-of-Service events upstream", DEFAULT_QOS,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_ASYNC,
|
||||
g_param_spec_boolean ("async", "Async",
|
||||
"Go asynchronously to PAUSED", DEFAULT_ASYNC,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_TS_OFFSET,
|
||||
g_param_spec_int64 ("ts-offset", "TS Offset",
|
||||
"Timestamp offset in nanoseconds", G_MININT64, G_MAXINT64,
|
||||
DEFAULT_TS_OFFSET, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
DEFAULT_TS_OFFSET,
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_ENABLE_LAST_SAMPLE,
|
||||
g_param_spec_boolean ("enable-last-sample", "Enable Last Buffer",
|
||||
"Enable the last-sample property", DEFAULT_ENABLE_LAST_SAMPLE,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_LAST_SAMPLE,
|
||||
g_param_spec_boxed ("last-sample", "Last Sample",
|
||||
"The last sample received in the sink", GST_TYPE_SAMPLE,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_BLOCKSIZE,
|
||||
g_param_spec_uint ("blocksize", "Block size",
|
||||
"Size in bytes to pull per buffer (0 = default)", 0, G_MAXUINT,
|
||||
DEFAULT_BLOCKSIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
DEFAULT_BLOCKSIZE,
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_RENDER_DELAY,
|
||||
g_param_spec_uint64 ("render-delay", "Render Delay",
|
||||
"Additional render delay of the sink in nanoseconds", 0, G_MAXUINT64,
|
||||
DEFAULT_RENDER_DELAY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
DEFAULT_RENDER_DELAY,
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_THROTTLE_TIME,
|
||||
g_param_spec_uint64 ("throttle-time", "Throttle time",
|
||||
"The time to keep between rendered buffers (0 = disabled)", 0,
|
||||
G_MAXUINT64, DEFAULT_THROTTLE_TIME,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_MAX_BITRATE,
|
||||
g_param_spec_uint64 ("max-bitrate", "Max Bitrate",
|
||||
"The maximum bits per second to render (0 = disabled)", 0,
|
||||
G_MAXUINT64, DEFAULT_MAX_BITRATE,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_PROCESSING_DEADLINE,
|
||||
g_param_spec_uint64 ("processing-deadline", "Processing deadline",
|
||||
"Maximum processing deadline in nanoseconds", 0, G_MAXUINT64,
|
||||
DEFAULT_PROCESSING_DEADLINE,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_STATS,
|
||||
g_param_spec_boxed ("stats", "Statistics",
|
||||
"Sink Statistics", GST_TYPE_STRUCTURE,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
/* videosink */
|
||||
g_object_class_install_property (gobject_class, PROP_SHOW_PREROLL_FRAME,
|
||||
g_param_spec_boolean ("show-preroll-frame", "Show preroll frame",
|
||||
"Whether to render video frames during preroll",
|
||||
DEFAULT_SHOW_PREROLL_FRAME,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
/* d3d11videosink */
|
||||
g_object_class_install_property (gobject_class, PROP_ADAPTER,
|
||||
g_param_spec_int ("adapter", "Adapter",
|
||||
"Adapter index for creating device (-1 for default)",
|
||||
-1, G_MAXINT32, DEFAULT_ADAPTER,
|
||||
G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_FORCE_ASPECT_RATIO,
|
||||
g_param_spec_boolean ("force-aspect-ratio",
|
||||
"Force aspect ratio",
|
||||
"When enabled, scaling will respect original aspect ratio",
|
||||
DEFAULT_FORCE_ASPECT_RATIO,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_ENABLE_NAVIGATION_EVENTS,
|
||||
g_param_spec_boolean ("enable-navigation-events",
|
||||
"Enable navigation events",
|
||||
"When enabled, navigation events are sent upstream",
|
||||
DEFAULT_ENABLE_NAVIGATION_EVENTS,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_FULLSCREEN_TOGGLE_MODE,
|
||||
g_param_spec_flags ("fullscreen-toggle-mode",
|
||||
"Full screen toggle mode",
|
||||
"Full screen toggle mode used to trigger fullscreen mode change",
|
||||
GST_D3D11_WINDOW_TOGGLE_MODE_GET_TYPE, DEFAULT_FULLSCREEN_TOGGLE_MODE,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_FULLSCREEN,
|
||||
g_param_spec_boolean ("fullscreen",
|
||||
"fullscreen",
|
||||
"Ignored when \"fullscreen-toggle-mode\" does not include \"property\"",
|
||||
DEFAULT_FULLSCREEN, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
DEFAULT_FULLSCREEN,
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
#ifdef HAVE_DIRECT_WRITE
|
||||
g_object_class_install_property (gobject_class, PROP_RENDER_STATS,
|
||||
g_param_spec_boolean ("render-stats",
|
||||
"Render Stats",
|
||||
"Render statistics data (e.g., average framerate) on window",
|
||||
DEFAULT_RENDER_STATS,
|
||||
GST_PARAM_CONDITIONALLY_AVAILABLE | GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (GST_PARAM_CONDITIONALLY_AVAILABLE |
|
||||
GST_PARAM_MUTABLE_READY | G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -307,8 +313,8 @@ gst_d3d11_video_sink_bin_class_init (GstD3D11VideoSinkBinClass * klass)
|
|||
"DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_B8G8R8A8_UNORM, and "
|
||||
"DXGI_FORMAT_R10G10B10A2_UNORM.",
|
||||
DEFAULT_DRAW_ON_SHARED_TEXTURE,
|
||||
G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READWRITE | GST_PARAM_MUTABLE_READY |
|
||||
G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
/**
|
||||
* GstD3D11VideoSinkBin::begin-draw:
|
||||
|
@ -346,7 +352,7 @@ gst_d3d11_video_sink_bin_class_init (GstD3D11VideoSinkBinClass * klass)
|
|||
*/
|
||||
gst_d3d11_video_sink_bin_signals[SIGNAL_DRAW] =
|
||||
g_signal_new ("draw", G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
||||
(GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
|
||||
G_STRUCT_OFFSET (GstD3D11VideoSinkBinClass, draw), NULL, NULL, NULL,
|
||||
G_TYPE_BOOLEAN, 4, G_TYPE_POINTER, G_TYPE_UINT, G_TYPE_UINT64,
|
||||
G_TYPE_UINT64);
|
|
@ -49,9 +49,15 @@
|
|||
#include <d3d9.h>
|
||||
#include <dxva.h>
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_vp8_dec_debug);
|
||||
#define GST_CAT_DEFAULT gst_d3d11_vp8_dec_debug
|
||||
|
||||
G_END_DECLS
|
||||
/* *INDENT-ON* */
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
@ -138,17 +144,17 @@ gst_d3d11_vp8_dec_class_init (GstD3D11Vp8DecClass * klass, gpointer data)
|
|||
g_param_spec_uint ("adapter", "Adapter",
|
||||
"DXGI Adapter index for creating device",
|
||||
0, G_MAXUINT32, cdata->adapter,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_DEVICE_ID,
|
||||
g_param_spec_uint ("device-id", "Device Id",
|
||||
"DXGI Device ID", 0, G_MAXUINT32, 0,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_VENDOR_ID,
|
||||
g_param_spec_uint ("vendor-id", "Vendor Id",
|
||||
"DXGI Vendor ID", 0, G_MAXUINT32, 0,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
|
||||
|
||||
klass->adapter = cdata->adapter;
|
||||
klass->device_id = cdata->device_id;
|
||||
|
@ -660,9 +666,11 @@ gst_d3d11_vp8_dec_submit_picture_data (GstD3D11Vp8Dec * self,
|
|||
gsize written_buffer_size;
|
||||
gboolean is_last = TRUE;
|
||||
DXVA_Slice_VPx_Short slice_short = { 0, };
|
||||
D3D11_VIDEO_DECODER_BUFFER_DESC buffer_desc[3] = { 0, };
|
||||
D3D11_VIDEO_DECODER_BUFFER_DESC buffer_desc[3];
|
||||
gboolean bad_aligned_bitstream_buffer = FALSE;
|
||||
|
||||
memset (buffer_desc, 0, sizeof (buffer_desc));
|
||||
|
||||
GST_TRACE_OBJECT (self, "Getting bitstream buffer");
|
||||
if (!gst_d3d11_decoder_get_decoder_buffer (self->d3d11_decoder,
|
||||
D3D11_VIDEO_DECODER_BUFFER_BITSTREAM, &d3d11_buffer_size,
|
||||
|
@ -929,7 +937,7 @@ gst_d3d11_vp8_dec_register (GstPlugin * plugin, GstD3D11Device * device,
|
|||
}
|
||||
|
||||
type = g_type_register_static (GST_TYPE_VP8_DECODER,
|
||||
type_name, &type_info, 0);
|
||||
type_name, &type_info, (GTypeFlags) 0);
|
||||
|
||||
/* make lower rank than default device */
|
||||
if (rank > 0 && index != 0)
|
|
@ -79,9 +79,15 @@
|
|||
#include <d3d9.h>
|
||||
#include <dxva.h>
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_vp9_dec_debug);
|
||||
#define GST_CAT_DEFAULT gst_d3d11_vp9_dec_debug
|
||||
|
||||
G_END_DECLS
|
||||
/* *INDENT-ON* */
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
@ -176,17 +182,17 @@ gst_d3d11_vp9_dec_class_init (GstD3D11Vp9DecClass * klass, gpointer data)
|
|||
g_param_spec_uint ("adapter", "Adapter",
|
||||
"DXGI Adapter index for creating device",
|
||||
0, G_MAXUINT32, cdata->adapter,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_DEVICE_ID,
|
||||
g_param_spec_uint ("device-id", "Device Id",
|
||||
"DXGI Device ID", 0, G_MAXUINT32, 0,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
g_object_class_install_property (gobject_class, PROP_VENDOR_ID,
|
||||
g_param_spec_uint ("vendor-id", "Vendor Id",
|
||||
"DXGI Vendor ID", 0, G_MAXUINT32, 0,
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
|
||||
|
||||
klass->adapter = cdata->adapter;
|
||||
klass->device_id = cdata->device_id;
|
||||
|
@ -376,7 +382,7 @@ gst_d3d11_vp9_dec_new_sequence (GstVp9Decoder * decoder,
|
|||
}
|
||||
|
||||
if (self->profile != frame_hdr->profile) {
|
||||
self->profile = frame_hdr->profile;
|
||||
self->profile = (GstVP9Profile) frame_hdr->profile;
|
||||
GST_INFO_OBJECT (self, "profile changed %d", self->profile);
|
||||
modified = TRUE;
|
||||
}
|
||||
|
@ -452,7 +458,7 @@ gst_d3d11_vp9_dec_duplicate_picture (GstVp9Decoder * decoder,
|
|||
GstBuffer *view_buffer;
|
||||
GstVp9Picture *new_picture;
|
||||
|
||||
view_buffer = gst_vp9_picture_get_user_data (picture);
|
||||
view_buffer = (GstBuffer *) gst_vp9_picture_get_user_data (picture);
|
||||
|
||||
if (!view_buffer) {
|
||||
GST_ERROR_OBJECT (self, "Parent picture does not have output view buffer");
|
||||
|
@ -499,9 +505,9 @@ gst_d3d11_vp9_dec_output_picture (GstVp9Decoder * decoder,
|
|||
if (self->use_d3d11_output
|
||||
&& GST_VIDEO_DECODER (self)->input_segment.rate > 0
|
||||
&& GST_VIDEO_INFO_WIDTH (&self->output_state->info) ==
|
||||
picture->frame_hdr.width
|
||||
(gint) picture->frame_hdr.width
|
||||
&& GST_VIDEO_INFO_HEIGHT (&self->output_state->info) ==
|
||||
picture->frame_hdr.height
|
||||
(gint) picture->frame_hdr.height
|
||||
&& gst_d3d11_decoder_can_direct_render (self->d3d11_decoder, view_buffer,
|
||||
GST_MINI_OBJECT_CAST (picture))) {
|
||||
direct_rendering = TRUE;
|
||||
|
@ -895,9 +901,11 @@ gst_d3d11_vp9_dec_submit_picture_data (GstD3D11Vp9Dec * self,
|
|||
gsize written_buffer_size;
|
||||
gboolean is_last = TRUE;
|
||||
DXVA_Slice_VPx_Short slice_short = { 0, };
|
||||
D3D11_VIDEO_DECODER_BUFFER_DESC buffer_desc[3] = { 0, };
|
||||
D3D11_VIDEO_DECODER_BUFFER_DESC buffer_desc[3];
|
||||
gboolean bad_aligned_bitstream_buffer = FALSE;
|
||||
|
||||
memset (buffer_desc, 0, sizeof (buffer_desc));
|
||||
|
||||
GST_TRACE_OBJECT (self, "Getting bitstream buffer");
|
||||
if (!gst_d3d11_decoder_get_decoder_buffer (self->d3d11_decoder,
|
||||
D3D11_VIDEO_DECODER_BUFFER_BITSTREAM, &d3d11_buffer_size,
|
||||
|
@ -1240,7 +1248,7 @@ gst_d3d11_vp9_dec_register (GstPlugin * plugin, GstD3D11Device * device,
|
|||
}
|
||||
|
||||
type = g_type_register_static (GST_TYPE_VP9_DECODER,
|
||||
type_name, &type_info, 0);
|
||||
type_name, &type_info, (GTypeFlags) 0);
|
||||
|
||||
/* make lower rank than default device */
|
||||
if (rank > 0 && index != 0)
|
|
@ -40,16 +40,17 @@
|
|||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#if GST_D3D11_WINAPI_APP || defined(HAVE_DIRECT_WRITE)
|
||||
#include <wrl.h>
|
||||
#include <wrl/wrappers/corewrappers.h>
|
||||
/* *INDENT-OFF* */
|
||||
using namespace Microsoft::WRL;
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_window_debug);
|
||||
#define GST_CAT_DEFAULT gst_d3d11_window_debug
|
||||
}
|
||||
|
||||
G_END_DECLS
|
||||
/* *INDENT-ON* */
|
||||
|
||||
struct _GstD3D11WindowPrivate
|
||||
{
|
||||
|
@ -297,35 +298,12 @@ gst_d3d11_window_release_dwrite_resources (GstD3D11Window * self)
|
|||
{
|
||||
GstD3D11WindowPrivate *priv = self->priv;
|
||||
|
||||
if (priv->d2d_device_context) {
|
||||
priv->d2d_device_context->Release ();
|
||||
priv->d2d_device_context = NULL;
|
||||
}
|
||||
|
||||
if (priv->d2d_factory) {
|
||||
priv->d2d_factory->Release ();
|
||||
priv->d2d_factory = NULL;
|
||||
}
|
||||
|
||||
if (priv->d2d_device) {
|
||||
priv->d2d_device->Release ();
|
||||
priv->d2d_device = NULL;
|
||||
}
|
||||
|
||||
if (priv->d2d_brush) {
|
||||
priv->d2d_brush->Release ();
|
||||
priv->d2d_brush = NULL;
|
||||
}
|
||||
|
||||
if (priv->dwrite_factory) {
|
||||
priv->dwrite_factory->Release ();
|
||||
priv->dwrite_factory = NULL;
|
||||
}
|
||||
|
||||
if (priv->dwrite_format) {
|
||||
priv->dwrite_format->Release ();
|
||||
priv->dwrite_format = NULL;
|
||||
}
|
||||
GST_D3D11_CLEAR_COM (priv->d2d_device_context);
|
||||
GST_D3D11_CLEAR_COM (priv->d2d_factory);
|
||||
GST_D3D11_CLEAR_COM (priv->d2d_device);
|
||||
GST_D3D11_CLEAR_COM (priv->d2d_brush);
|
||||
GST_D3D11_CLEAR_COM (priv->dwrite_factory);
|
||||
GST_D3D11_CLEAR_COM (priv->dwrite_format);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -440,20 +418,9 @@ gst_d3d11_window_release_resources (GstD3D11Device * device,
|
|||
gst_d3d11_window_release_dwrite_resources (window);
|
||||
#endif
|
||||
|
||||
if (window->rtv) {
|
||||
window->rtv->Release ();
|
||||
window->rtv = NULL;
|
||||
}
|
||||
|
||||
if (window->pov) {
|
||||
window->pov->Release ();
|
||||
window->pov = NULL;
|
||||
}
|
||||
|
||||
if (window->swap_chain) {
|
||||
window->swap_chain->Release ();
|
||||
window->swap_chain = NULL;
|
||||
}
|
||||
GST_D3D11_CLEAR_COM (window->rtv);
|
||||
GST_D3D11_CLEAR_COM (window->pov);
|
||||
GST_D3D11_CLEAR_COM (window->swap_chain);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -466,7 +433,7 @@ gst_d3d11_window_dispose (GObject * object)
|
|||
}
|
||||
|
||||
g_clear_pointer (&self->processor, gst_d3d11_video_processor_free);
|
||||
g_clear_pointer (&self->converter, gst_d3d11_color_converter_free);
|
||||
g_clear_pointer (&self->converter, gst_d3d11_converter_free);
|
||||
g_clear_pointer (&self->compositor, gst_d3d11_overlay_compositor_free);
|
||||
|
||||
gst_clear_buffer (&self->cached_buffer);
|
||||
|
@ -497,15 +464,8 @@ gst_d3d11_window_on_resize_default (GstD3D11Window * window, guint width,
|
|||
device_handle = gst_d3d11_device_get_device_handle (window->device);
|
||||
swap_chain = window->swap_chain;
|
||||
|
||||
if (window->rtv) {
|
||||
window->rtv->Release ();
|
||||
window->rtv = NULL;
|
||||
}
|
||||
|
||||
if (window->pov) {
|
||||
window->pov->Release ();
|
||||
window->pov = NULL;
|
||||
}
|
||||
GST_D3D11_CLEAR_COM (window->rtv);
|
||||
GST_D3D11_CLEAR_COM (window->pov);
|
||||
|
||||
#ifdef HAVE_DIRECT_WRITE
|
||||
/* D2D bitmap need to be cleared before resizing swapchain buffer */
|
||||
|
@ -593,8 +553,7 @@ gst_d3d11_window_on_resize_default (GstD3D11Window * window, guint width,
|
|||
}
|
||||
|
||||
done:
|
||||
if (backbuffer)
|
||||
backbuffer->Release ();
|
||||
GST_D3D11_CLEAR_COM (backbuffer);
|
||||
|
||||
gst_d3d11_device_unlock (window->device);
|
||||
}
|
||||
|
@ -683,7 +642,7 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
|
|||
/* Step 1: Clear old resources and objects */
|
||||
gst_clear_buffer (&window->cached_buffer);
|
||||
g_clear_pointer (&window->processor, gst_d3d11_video_processor_free);
|
||||
g_clear_pointer (&window->converter, gst_d3d11_color_converter_free);
|
||||
g_clear_pointer (&window->converter, gst_d3d11_converter_free);
|
||||
g_clear_pointer (&window->compositor, gst_d3d11_overlay_compositor_free);
|
||||
|
||||
/* Step 2: Decide display color format
|
||||
|
@ -958,7 +917,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_color_converter_new (window->device, &window->info,
|
||||
gst_d3d11_converter_new (window->device, &window->info,
|
||||
&window->render_info);
|
||||
|
||||
if (!window->converter) {
|
||||
|
@ -1142,7 +1101,7 @@ gst_d3d111_window_present (GstD3D11Window * self, GstBuffer * buffer,
|
|||
viewport.Height = self->render_rect.bottom - self->render_rect.top;
|
||||
viewport.MinDepth = 0.0f;
|
||||
viewport.MaxDepth = 1.0f;
|
||||
gst_d3d11_color_converter_update_viewport (self->converter,
|
||||
gst_d3d11_converter_update_viewport (self->converter,
|
||||
&viewport);
|
||||
gst_d3d11_overlay_compositor_update_viewport (self->compositor,
|
||||
&viewport);
|
||||
|
@ -1158,7 +1117,7 @@ gst_d3d111_window_present (GstD3D11Window * self, GstBuffer * buffer,
|
|||
GST_TRACE_OBJECT (self, "Rendered using processor");
|
||||
}
|
||||
} else {
|
||||
if (!gst_d3d11_color_converter_convert_unlocked (self->converter,
|
||||
if (!gst_d3d11_converter_convert_unlocked (self->converter,
|
||||
srv, &rtv, NULL, NULL)) {
|
||||
GST_ERROR_OBJECT (self, "Couldn't render to backbuffer using converter");
|
||||
ret = GST_FLOW_ERROR;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
#include <gst/d3d11/gstd3d11.h>
|
||||
#include "gstd3d11colorconverter.h"
|
||||
#include "gstd3d11converter.h"
|
||||
#include "gstd3d11overlaycompositor.h"
|
||||
#include "gstd3d11videoprocessor.h"
|
||||
#include "gstd3d11pluginutils.h"
|
||||
|
@ -99,7 +99,7 @@ struct _GstD3D11Window
|
|||
GstVideoInfo info;
|
||||
GstVideoInfo render_info;
|
||||
GstD3D11VideoProcessor *processor;
|
||||
GstD3D11ColorConverter *converter;
|
||||
GstD3D11Converter *converter;
|
||||
GstD3D11OverlayCompositor *compositor;
|
||||
|
||||
/* calculated rect with aspect ratio and window area */
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#endif
|
||||
|
||||
#include "gstd3d11window_dummy.h"
|
||||
#include "gstd3d11pluginutils.h"
|
||||
#include <wrl.h>
|
||||
|
||||
using namespace Microsoft::WRL;
|
||||
|
@ -88,7 +89,7 @@ gst_d3d11_window_dummy_prepare (GstD3D11Window * window,
|
|||
gboolean * video_processor_available, GError ** error)
|
||||
{
|
||||
g_clear_pointer (&window->processor, gst_d3d11_video_processor_free);
|
||||
g_clear_pointer (&window->converter, gst_d3d11_color_converter_free);
|
||||
g_clear_pointer (&window->converter, gst_d3d11_converter_free);
|
||||
g_clear_pointer (&window->compositor, gst_d3d11_overlay_compositor_free);
|
||||
|
||||
/* We are supporting only RGBA, BGRA or RGB10A2_LE formats but we don't know
|
||||
|
@ -174,7 +175,7 @@ gst_d3d11_window_dummy_prepare (GstD3D11Window * window,
|
|||
*video_processor_available = !!window->processor;
|
||||
|
||||
window->converter =
|
||||
gst_d3d11_color_converter_new (window->device, &window->info,
|
||||
gst_d3d11_converter_new (window->device, &window->info,
|
||||
&window->render_info);
|
||||
|
||||
if (!window->converter) {
|
||||
|
@ -206,20 +207,9 @@ error:
|
|||
static void
|
||||
gst_d3d11_window_dummy_clear_resources (GstD3D11WindowDummy * self)
|
||||
{
|
||||
if (self->fallback_pov) {
|
||||
self->fallback_pov->Release ();
|
||||
self->fallback_pov = nullptr;
|
||||
}
|
||||
|
||||
if (self->fallback_rtv) {
|
||||
self->fallback_rtv->Release ();
|
||||
self->fallback_rtv = nullptr;
|
||||
}
|
||||
|
||||
if (self->fallback_texture) {
|
||||
self->fallback_texture->Release ();
|
||||
self->fallback_texture = nullptr;
|
||||
}
|
||||
GST_D3D11_CLEAR_COM (self->fallback_pov);
|
||||
GST_D3D11_CLEAR_COM (self->fallback_rtv);
|
||||
GST_D3D11_CLEAR_COM (self->fallback_texture);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -450,14 +440,10 @@ gst_d3d11_window_dummy_open_shared_handle (GstD3D11Window * window,
|
|||
return TRUE;
|
||||
|
||||
out:
|
||||
if (texture)
|
||||
texture->Release ();
|
||||
if (keyed_mutex)
|
||||
keyed_mutex->Release ();
|
||||
if (pov)
|
||||
pov->Release ();
|
||||
if (rtv)
|
||||
rtv->Release ();
|
||||
GST_D3D11_CLEAR_COM (texture);
|
||||
GST_D3D11_CLEAR_COM (keyed_mutex);
|
||||
GST_D3D11_CLEAR_COM (pov);
|
||||
GST_D3D11_CLEAR_COM (rtv);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -527,12 +513,9 @@ gst_d3d11_window_dummy_release_shared_handle (GstD3D11Window * window,
|
|||
}
|
||||
}
|
||||
|
||||
if (data->rtv)
|
||||
data->rtv->Release ();
|
||||
if (data->pov)
|
||||
data->pov->Release ();
|
||||
if (data->texture)
|
||||
data->texture->Release ();
|
||||
GST_D3D11_CLEAR_COM (data->rtv);
|
||||
GST_D3D11_CLEAR_COM (data->pov);
|
||||
GST_D3D11_CLEAR_COM (data->texture);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
d3d11_sources = [
|
||||
'gstd3d11basefilter.c',
|
||||
'gstd3d11colorconvert.c',
|
||||
'gstd3d11colorconverter.c',
|
||||
'gstd3d11compositor.c',
|
||||
'gstd3d11compositorbin.c',
|
||||
'gstd3d11download.c',
|
||||
'gstd3d11overlaycompositor.c',
|
||||
'gstd3d11pluginutils.c',
|
||||
'gstd3d11shader.c',
|
||||
'gstd3d11upload.c',
|
||||
'gstd3d11videoprocessor.c',
|
||||
'gstd3d11videosink.c',
|
||||
'gstd3d11videosinkbin.c',
|
||||
'gstd3d11basefilter.cpp',
|
||||
'gstd3d11convert.cpp',
|
||||
'gstd3d11converter.cpp',
|
||||
'gstd3d11compositor.cpp',
|
||||
'gstd3d11compositorbin.cpp',
|
||||
'gstd3d11download.cpp',
|
||||
'gstd3d11overlaycompositor.cpp',
|
||||
'gstd3d11pluginutils.cpp',
|
||||
'gstd3d11shader.cpp',
|
||||
'gstd3d11upload.cpp',
|
||||
'gstd3d11videoprocessor.cpp',
|
||||
'gstd3d11videosink.cpp',
|
||||
'gstd3d11videosinkbin.cpp',
|
||||
'gstd3d11window.cpp',
|
||||
'gstd3d11window_dummy.cpp',
|
||||
'plugin.c',
|
||||
]
|
||||
|
||||
d3d11_dec_sources = [
|
||||
'gstd3d11decoder.c',
|
||||
'gstd3d11h264dec.c',
|
||||
'gstd3d11vp9dec.c',
|
||||
'gstd3d11h265dec.c',
|
||||
'gstd3d11mpeg2dec.c',
|
||||
'gstd3d11vp8dec.c',
|
||||
'gstd3d11decoder.cpp',
|
||||
'gstd3d11h264dec.cpp',
|
||||
'gstd3d11vp9dec.cpp',
|
||||
'gstd3d11h265dec.cpp',
|
||||
'gstd3d11mpeg2dec.cpp',
|
||||
'gstd3d11vp8dec.cpp',
|
||||
]
|
||||
|
||||
extra_c_args = ['-DCOBJMACROS', '-DGST_USE_UNSTABLE_API']
|
||||
|
@ -81,7 +81,7 @@ if d3d11_winapi_desktop
|
|||
# Desktop Duplication API is unavailable for UWP
|
||||
# and MinGW is not supported due to some missing headers
|
||||
extra_c_args += ['-DHAVE_DXGI_DESKTOP_DUP']
|
||||
d3d11_sources += ['gstd3d11desktopdup.cpp', 'gstd3d11desktopdupsrc.c']
|
||||
d3d11_sources += ['gstd3d11desktopdup.cpp', 'gstd3d11desktopdupsrc.cpp']
|
||||
message('Enable D3D11 Desktop Duplication API')
|
||||
endif
|
||||
endif
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "gstd3d11videosink.h"
|
||||
#include "gstd3d11upload.h"
|
||||
#include "gstd3d11download.h"
|
||||
#include "gstd3d11colorconvert.h"
|
||||
#include "gstd3d11convert.h"
|
||||
#include "gstd3d11videosinkbin.h"
|
||||
#include "gstd3d11shader.h"
|
||||
#include "gstd3d11compositor.h"
|
||||
|
@ -47,7 +47,7 @@
|
|||
|
||||
GST_DEBUG_CATEGORY (gst_d3d11_debug);
|
||||
GST_DEBUG_CATEGORY (gst_d3d11_shader_debug);
|
||||
GST_DEBUG_CATEGORY (gst_d3d11_colorconverter_debug);
|
||||
GST_DEBUG_CATEGORY (gst_d3d11_converter_debug);
|
||||
GST_DEBUG_CATEGORY (gst_d3d11_plugin_utils_debug);
|
||||
GST_DEBUG_CATEGORY (gst_d3d11_format_debug);
|
||||
GST_DEBUG_CATEGORY (gst_d3d11_device_debug);
|
||||
|
@ -84,8 +84,8 @@ plugin_init (GstPlugin * plugin)
|
|||
GST_DEBUG_CATEGORY_INIT (gst_d3d11_debug, "d3d11", 0, "direct3d 11 plugin");
|
||||
GST_DEBUG_CATEGORY_INIT (gst_d3d11_shader_debug,
|
||||
"d3d11shader", 0, "d3d11shader");
|
||||
GST_DEBUG_CATEGORY_INIT (gst_d3d11_colorconverter_debug,
|
||||
"d3d11colorconverter", 0, "d3d11colorconverter");
|
||||
GST_DEBUG_CATEGORY_INIT (gst_d3d11_converter_debug,
|
||||
"d3d11converter", 0, "d3d11converter");
|
||||
GST_DEBUG_CATEGORY_INIT (gst_d3d11_plugin_utils_debug,
|
||||
"d3d11pluginutils", 0, "d3d11 plugin utility functions");
|
||||
GST_DEBUG_CATEGORY_INIT (gst_d3d11_overlay_compositor_debug,
|
||||
|
|
Loading…
Reference in a new issue