d3d11decoder: Remove duplicated class_init and property related code

Move them into the decoder helper code to remove duplication

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2525>
This commit is contained in:
Seungha Yang 2021-09-15 23:41:39 +09:00
parent 4f45828641
commit a77f793c8b
8 changed files with 190 additions and 387 deletions

View file

@ -350,14 +350,6 @@ typedef struct _GST_DXVA_Tile_AV1
#pragma pack(pop)
enum
{
PROP_0,
PROP_ADAPTER,
PROP_DEVICE_ID,
PROP_VENDOR_ID,
};
/* reference list 8 + 4 margin */
#define NUM_OUTPUT_VIEW 12
@ -386,9 +378,7 @@ typedef struct _GstD3D11AV1Dec
typedef struct _GstD3D11AV1DecClass
{
GstAV1DecoderClass parent_class;
guint adapter;
guint device_id;
guint vendor_id;
GstD3D11DecoderSubClassData class_data;
} GstD3D11AV1DecClass;
static GstElementClass *parent_class = NULL;
@ -438,48 +428,17 @@ gst_d3d11_av1_dec_class_init (GstD3D11AV1DecClass * klass, gpointer data)
GstVideoDecoderClass *decoder_class = GST_VIDEO_DECODER_CLASS (klass);
GstAV1DecoderClass *av1decoder_class = GST_AV1_DECODER_CLASS (klass);
GstD3D11DecoderClassData *cdata = (GstD3D11DecoderClassData *) data;
gchar *long_name;
gobject_class->get_property = gst_d3d11_av1_dec_get_property;
gobject_class->dispose = gst_d3d11_av1_dec_dispose;
g_object_class_install_property (gobject_class, PROP_ADAPTER,
g_param_spec_uint ("adapter", "Adapter",
"DXGI Adapter index for creating device",
0, G_MAXUINT32, cdata->adapter,
(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,
(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,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
klass->adapter = cdata->adapter;
klass->device_id = cdata->device_id;
klass->vendor_id = cdata->vendor_id;
element_class->set_context =
GST_DEBUG_FUNCPTR (gst_d3d11_av1_dec_set_context);
long_name =
g_strdup_printf ("Direct3D11/DXVA AV1 %s Decoder", cdata->description);
gst_element_class_set_metadata (element_class, long_name,
"Codec/Decoder/Video/Hardware", "A Direct3D11/DXVA AV1 video decoder",
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
gst_d3d11_decoder_class_data_fill_subclass_data (cdata, &klass->class_data);
gst_d3d11_decoder_proxy_class_init (element_class, cdata,
"Seungha Yang <seungha@centricular.com>");
g_free (long_name);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
cdata->sink_caps));
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
cdata->src_caps));
gst_d3d11_decoder_class_data_free (cdata);
decoder_class->open = GST_DEBUG_FUNCPTR (gst_d3d11_av1_dec_open);
decoder_class->close = GST_DEBUG_FUNCPTR (gst_d3d11_av1_dec_close);
@ -516,21 +475,9 @@ gst_d3d11_av1_dec_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstD3D11AV1DecClass *klass = GST_D3D11_AV1_DEC_GET_CLASS (object);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
switch (prop_id) {
case PROP_ADAPTER:
g_value_set_uint (value, klass->adapter);
break;
case PROP_DEVICE_ID:
g_value_set_uint (value, klass->device_id);
break;
case PROP_VENDOR_ID:
g_value_set_uint (value, klass->vendor_id);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
gst_d3d11_decoder_proxy_get_property (object, prop_id, value, pspec, cdata);
}
static void
@ -548,8 +495,9 @@ gst_d3d11_av1_dec_set_context (GstElement * element, GstContext * context)
{
GstD3D11AV1Dec *self = GST_D3D11_AV1_DEC (element);
GstD3D11AV1DecClass *klass = GST_D3D11_AV1_DEC_GET_CLASS (self);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
gst_d3d11_handle_set_context (element, context, klass->adapter,
gst_d3d11_handle_set_context (element, context, cdata->adapter,
&self->device);
GST_ELEMENT_CLASS (parent_class)->set_context (element, context);
@ -560,8 +508,9 @@ gst_d3d11_av1_dec_open (GstVideoDecoder * decoder)
{
GstD3D11AV1Dec *self = GST_D3D11_AV1_DEC (decoder);
GstD3D11AV1DecClass *klass = GST_D3D11_AV1_DEC_GET_CLASS (self);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
if (!gst_d3d11_ensure_element_data (GST_ELEMENT_CAST (self), klass->adapter,
if (!gst_d3d11_ensure_element_data (GST_ELEMENT_CAST (self), cdata->adapter,
&self->device)) {
GST_ERROR_OBJECT (self, "Cannot create d3d11device");
return FALSE;
@ -1470,7 +1419,8 @@ gst_d3d11_av1_dec_register (GstPlugin * plugin, GstD3D11Device * device,
"height", GST_TYPE_INT_RANGE, 1, resolution, NULL);
type_info.class_data =
gst_d3d11_decoder_class_data_new (device, sink_caps, src_caps);
gst_d3d11_decoder_class_data_new (device, GST_D3D11_CODEC_AV1,
sink_caps, src_caps);
type_name = g_strdup ("GstD3D11AV1Dec");
feature_name = g_strdup ("d3d11av1dec");

View file

@ -55,6 +55,7 @@
#include "gstd3d11converter.h"
#include "gstd3d11pluginutils.h"
#include <string.h>
#include <string>
#ifdef HAVE_WINMM
#include <timeapi.h>
@ -1941,6 +1942,22 @@ gst_d3d11_decoder_supports_resolution (GstD3D11Decoder * decoder,
return TRUE;
}
enum
{
PROP_DECODER_ADAPTER = 1,
PROP_DECODER_DEVICE_ID,
PROP_DECODER_VENDOR_ID,
};
struct _GstD3D11DecoderClassData
{
GstD3D11DecoderSubClassData subclass_data;
GstCaps *sink_caps;
GstCaps *src_caps;
gchar *description;
GstD3D11Codec codec;
};
/**
* gst_d3d11_decoder_class_data_new:
* @device: (transfer none): a #GstD3D11Device
@ -1952,7 +1969,7 @@ gst_d3d11_decoder_supports_resolution (GstD3D11Decoder * decoder,
* Returns: (transfer full): the new #GstD3D11DecoderClassData
*/
GstD3D11DecoderClassData *
gst_d3d11_decoder_class_data_new (GstD3D11Device * device,
gst_d3d11_decoder_class_data_new (GstD3D11Device * device, GstD3D11Codec codec,
GstCaps * sink_caps, GstCaps * src_caps)
{
GstD3D11DecoderClassData *ret;
@ -1963,13 +1980,16 @@ gst_d3d11_decoder_class_data_new (GstD3D11Device * device,
ret = g_new0 (GstD3D11DecoderClassData, 1);
ret->codec = codec;
/* class data will be leaked if the element never gets instantiated */
GST_MINI_OBJECT_FLAG_SET (sink_caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
GST_MINI_OBJECT_FLAG_SET (src_caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
g_object_get (device, "adapter", &ret->adapter,
"device-id", &ret->device_id, "vendor-id", &ret->vendor_id,
"description", &ret->description, NULL);
g_object_get (device, "adapter", &ret->subclass_data.adapter,
"device-id", &ret->subclass_data.device_id,
"vendor-id", &ret->subclass_data.vendor_id,
"description", &ret->description, nullptr);
ret->sink_caps = sink_caps;
ret->src_caps = src_caps;
@ -1977,6 +1997,16 @@ gst_d3d11_decoder_class_data_new (GstD3D11Device * device,
}
void
gst_d3d11_decoder_class_data_fill_subclass_data (GstD3D11DecoderClassData *
data, GstD3D11DecoderSubClassData * subclass_data)
{
g_return_if_fail (data != nullptr);
g_return_if_fail (subclass_data != nullptr);
*subclass_data = data->subclass_data;
}
static void
gst_d3d11_decoder_class_data_free (GstD3D11DecoderClassData * data)
{
if (!data)
@ -1987,3 +2017,69 @@ gst_d3d11_decoder_class_data_free (GstD3D11DecoderClassData * data)
g_free (data->description);
g_free (data);
}
void
gst_d3d11_decoder_proxy_class_init (GstElementClass * klass,
GstD3D11DecoderClassData * data, const gchar * author)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstD3D11DecoderSubClassData *cdata = &data->subclass_data;
std::string long_name;
std::string description;
const gchar *codec_name;
g_object_class_install_property (gobject_class, PROP_DECODER_ADAPTER,
g_param_spec_uint ("adapter", "Adapter",
"DXGI Adapter index for creating device",
0, G_MAXUINT32, cdata->adapter,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
g_object_class_install_property (gobject_class, PROP_DECODER_DEVICE_ID,
g_param_spec_uint ("device-id", "Device Id",
"DXGI Device ID", 0, G_MAXUINT32, 0,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
g_object_class_install_property (gobject_class, PROP_DECODER_VENDOR_ID,
g_param_spec_uint ("vendor-id", "Vendor Id",
"DXGI Vendor ID", 0, G_MAXUINT32, 0,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
codec_name = gst_d3d11_codec_to_string (data->codec);
long_name = "Direct3D11/DXVA " + std::string (codec_name) + " " +
std::string (data->description) + " Decoder";
description = "Direct3D11/DXVA based " + std::string (codec_name) +
" video decoder";
gst_element_class_set_metadata (klass, long_name.c_str (),
"Codec/Decoder/Video/Hardware", description.c_str (), author);
gst_element_class_add_pad_template (klass,
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
data->sink_caps));
gst_element_class_add_pad_template (klass,
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
data->src_caps));
gst_d3d11_decoder_class_data_free (data);
}
void
gst_d3d11_decoder_proxy_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec,
GstD3D11DecoderSubClassData * subclass_data)
{
switch (prop_id) {
case PROP_DECODER_ADAPTER:
g_value_set_uint (value, subclass_data->adapter);
break;
case PROP_DECODER_DEVICE_ID:
g_value_set_uint (value, subclass_data->device_id);
break;
case PROP_DECODER_VENDOR_ID:
g_value_set_uint (value, subclass_data->vendor_id);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}

View file

@ -30,7 +30,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GstD3D11Decoder,
gst_d3d11_decoder, GST, D3D11_DECODER, GstObject);
typedef struct _GstD3D11DecoderPrivate GstD3D11DecoderPrivate;
typedef struct _GstD3D11DecoderClassData GstD3D11DecoderClassData;
typedef enum
{
@ -48,13 +48,10 @@ typedef enum
typedef struct
{
GstCaps *sink_caps;
GstCaps *src_caps;
guint adapter;
guint device_id;
guint vendor_id;
gchar *description;
} GstD3D11DecoderClassData;
} GstD3D11DecoderSubClassData;
GstD3D11Decoder * gst_d3d11_decoder_new (GstD3D11Device * device);
@ -130,11 +127,23 @@ gboolean gst_d3d11_decoder_supports_resolution (GstD3D11Decoder * decod
guint width,
guint height);
GstD3D11DecoderClassData * gst_d3d11_decoder_class_data_new (GstD3D11Device * device,
GstCaps * sink_caps,
GstCaps * src_caps);
GstD3D11DecoderClassData * gst_d3d11_decoder_class_data_new (GstD3D11Device * device,
GstD3D11Codec codec,
GstCaps * sink_caps,
GstCaps * src_caps);
void gst_d3d11_decoder_class_data_free (GstD3D11DecoderClassData * data);
void gst_d3d11_decoder_class_data_fill_subclass_data (GstD3D11DecoderClassData * data,
GstD3D11DecoderSubClassData * subclass_data);
void gst_d3d11_decoder_proxy_class_init (GstElementClass * klass,
GstD3D11DecoderClassData * data,
const gchar * author);
void gst_d3d11_decoder_proxy_get_property (GObject * object,
guint prop_id,
GValue * value,
GParamSpec * pspec,
GstD3D11DecoderSubClassData * subclass_data);
G_END_DECLS

View file

@ -82,14 +82,6 @@
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_h264_dec_debug);
#define GST_CAT_DEFAULT gst_d3d11_h264_dec_debug
enum
{
PROP_0,
PROP_ADAPTER,
PROP_DEVICE_ID,
PROP_VENDOR_ID,
};
typedef struct _GstD3D11H264Dec
{
GstH264Decoder parent;
@ -125,9 +117,7 @@ typedef struct _GstD3D11H264Dec
typedef struct _GstD3D11H264DecClass
{
GstH264DecoderClass parent_class;
guint adapter;
guint device_id;
guint vendor_id;
GstD3D11DecoderSubClassData class_data;
} GstD3D11H264DecClass;
static GstElementClass *parent_class = NULL;
@ -179,49 +169,17 @@ gst_d3d11_h264_dec_class_init (GstD3D11H264DecClass * klass, gpointer data)
GstVideoDecoderClass *decoder_class = GST_VIDEO_DECODER_CLASS (klass);
GstH264DecoderClass *h264decoder_class = GST_H264_DECODER_CLASS (klass);
GstD3D11DecoderClassData *cdata = (GstD3D11DecoderClassData *) data;
gchar *long_name;
gobject_class->get_property = gst_d3d11_h264_dec_get_property;
gobject_class->dispose = gst_d3d11_h264_dec_dispose;
g_object_class_install_property (gobject_class, PROP_ADAPTER,
g_param_spec_uint ("adapter", "Adapter",
"DXGI Adapter index for creating device",
0, G_MAXUINT32, cdata->adapter,
(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,
(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,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
klass->adapter = cdata->adapter;
klass->device_id = cdata->device_id;
klass->vendor_id = cdata->vendor_id;
element_class->set_context =
GST_DEBUG_FUNCPTR (gst_d3d11_h264_dec_set_context);
long_name = g_strdup_printf ("Direct3D11/DXVA H.264 %s Decoder",
cdata->description);
gst_element_class_set_metadata (element_class, long_name,
"Codec/Decoder/Video/Hardware",
"A Direct3D11/DXVA H.264 video decoder",
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
gst_d3d11_decoder_class_data_fill_subclass_data (cdata, &klass->class_data);
gst_d3d11_decoder_proxy_class_init (element_class, cdata,
"Seungha Yang <seungha.yang@navercorp.com>");
g_free (long_name);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
cdata->sink_caps));
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
cdata->src_caps));
gst_d3d11_decoder_class_data_free (cdata);
decoder_class->open = GST_DEBUG_FUNCPTR (gst_d3d11_h264_dec_open);
decoder_class->close = GST_DEBUG_FUNCPTR (gst_d3d11_h264_dec_close);
@ -258,21 +216,9 @@ gst_d3d11_h264_dec_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstD3D11H264DecClass *klass = GST_D3D11_H264_DEC_GET_CLASS (object);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
switch (prop_id) {
case PROP_ADAPTER:
g_value_set_uint (value, klass->adapter);
break;
case PROP_DEVICE_ID:
g_value_set_uint (value, klass->device_id);
break;
case PROP_VENDOR_ID:
g_value_set_uint (value, klass->vendor_id);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
gst_d3d11_decoder_proxy_get_property (object, prop_id, value, pspec, cdata);
}
static void
@ -293,8 +239,9 @@ gst_d3d11_h264_dec_set_context (GstElement * element, GstContext * context)
{
GstD3D11H264Dec *self = GST_D3D11_H264_DEC (element);
GstD3D11H264DecClass *klass = GST_D3D11_H264_DEC_GET_CLASS (self);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
gst_d3d11_handle_set_context (element, context, klass->adapter,
gst_d3d11_handle_set_context (element, context, cdata->adapter,
&self->device);
GST_ELEMENT_CLASS (parent_class)->set_context (element, context);
@ -320,8 +267,9 @@ gst_d3d11_h264_dec_open (GstVideoDecoder * decoder)
{
GstD3D11H264Dec *self = GST_D3D11_H264_DEC (decoder);
GstD3D11H264DecClass *klass = GST_D3D11_H264_DEC_GET_CLASS (self);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
if (!gst_d3d11_ensure_element_data (GST_ELEMENT_CAST (self), klass->adapter,
if (!gst_d3d11_ensure_element_data (GST_ELEMENT_CAST (self), cdata->adapter,
&self->device)) {
GST_ERROR_OBJECT (self, "Cannot create d3d11device");
return FALSE;
@ -1301,7 +1249,8 @@ gst_d3d11_h264_dec_register (GstPlugin * plugin, GstD3D11Device * device,
"height", GST_TYPE_INT_RANGE, 1, resolution, NULL);
type_info.class_data =
gst_d3d11_decoder_class_data_new (device, sink_caps, src_caps);
gst_d3d11_decoder_class_data_new (device, GST_D3D11_CODEC_H264,
sink_caps, src_caps);
type_name = g_strdup ("GstD3D11H264Dec");
feature_name = g_strdup ("d3d11h264dec");

View file

@ -52,14 +52,6 @@
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_h265_dec_debug);
#define GST_CAT_DEFAULT gst_d3d11_h265_dec_debug
enum
{
PROP_0,
PROP_ADAPTER,
PROP_DEVICE_ID,
PROP_VENDOR_ID,
};
typedef struct _GstD3D11H265Dec
{
GstH265Decoder parent;
@ -95,9 +87,7 @@ typedef struct _GstD3D11H265Dec
typedef struct _GstD3D11H265DecClass
{
GstH265DecoderClass parent_class;
guint adapter;
guint device_id;
guint vendor_id;
GstD3D11DecoderSubClassData class_data;
} GstD3D11H265DecClass;
static GstElementClass *parent_class = NULL;
@ -153,49 +143,17 @@ gst_d3d11_h265_dec_class_init (GstD3D11H265DecClass * klass, gpointer data)
GstVideoDecoderClass *decoder_class = GST_VIDEO_DECODER_CLASS (klass);
GstH265DecoderClass *h265decoder_class = GST_H265_DECODER_CLASS (klass);
GstD3D11DecoderClassData *cdata = (GstD3D11DecoderClassData *) data;
gchar *long_name;
gobject_class->get_property = gst_d3d11_h265_dec_get_property;
gobject_class->dispose = gst_d3d11_h265_dec_dispose;
g_object_class_install_property (gobject_class, PROP_ADAPTER,
g_param_spec_uint ("adapter", "Adapter",
"DXGI Adapter index for creating device",
0, G_MAXUINT32, cdata->adapter,
(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,
(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,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
klass->adapter = cdata->adapter;
klass->device_id = cdata->device_id;
klass->vendor_id = cdata->vendor_id;
element_class->set_context =
GST_DEBUG_FUNCPTR (gst_d3d11_h265_dec_set_context);
long_name = g_strdup_printf ("Direct3D11/DXVA H.265 %s Decoder",
cdata->description);
gst_element_class_set_metadata (element_class, long_name,
"Codec/Decoder/Video/Hardware",
"A Direct3D11/DXVA H.265 video decoder",
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
gst_d3d11_decoder_class_data_fill_subclass_data (cdata, &klass->class_data);
gst_d3d11_decoder_proxy_class_init (element_class, cdata,
"Seungha Yang <seungha.yang@navercorp.com>");
g_free (long_name);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
cdata->sink_caps));
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
cdata->src_caps));
gst_d3d11_decoder_class_data_free (cdata);
decoder_class->open = GST_DEBUG_FUNCPTR (gst_d3d11_h265_dec_open);
decoder_class->close = GST_DEBUG_FUNCPTR (gst_d3d11_h265_dec_close);
@ -230,21 +188,9 @@ gst_d3d11_h265_dec_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstD3D11H265DecClass *klass = GST_D3D11_H265_DEC_GET_CLASS (object);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
switch (prop_id) {
case PROP_ADAPTER:
g_value_set_uint (value, klass->adapter);
break;
case PROP_DEVICE_ID:
g_value_set_uint (value, klass->device_id);
break;
case PROP_VENDOR_ID:
g_value_set_uint (value, klass->vendor_id);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
gst_d3d11_decoder_proxy_get_property (object, prop_id, value, pspec, cdata);
}
static void
@ -265,8 +211,9 @@ gst_d3d11_h265_dec_set_context (GstElement * element, GstContext * context)
{
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (element);
GstD3D11H265DecClass *klass = GST_D3D11_H265_DEC_GET_CLASS (self);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
gst_d3d11_handle_set_context (element, context, klass->adapter,
gst_d3d11_handle_set_context (element, context, cdata->adapter,
&self->device);
GST_ELEMENT_CLASS (parent_class)->set_context (element, context);
@ -277,8 +224,9 @@ gst_d3d11_h265_dec_open (GstVideoDecoder * decoder)
{
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder);
GstD3D11H265DecClass *klass = GST_D3D11_H265_DEC_GET_CLASS (self);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
if (!gst_d3d11_ensure_element_data (GST_ELEMENT_CAST (self), klass->adapter,
if (!gst_d3d11_ensure_element_data (GST_ELEMENT_CAST (self), cdata->adapter,
&self->device)) {
GST_ERROR_OBJECT (self, "Cannot create d3d11device");
return FALSE;
@ -1527,7 +1475,8 @@ gst_d3d11_h265_dec_register (GstPlugin * plugin, GstD3D11Device * device,
gst_caps_unref (src_caps_copy);
type_info.class_data =
gst_d3d11_decoder_class_data_new (device, sink_caps, src_caps);
gst_d3d11_decoder_class_data_new (device, GST_D3D11_CODEC_H265,
sink_caps, src_caps);
type_name = g_strdup ("GstD3D11H265Dec");
feature_name = g_strdup ("d3d11h265dec");

View file

@ -52,14 +52,6 @@
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_mpeg2_dec_debug);
#define GST_CAT_DEFAULT gst_d3d11_mpeg2_dec_debug
enum
{
PROP_0,
PROP_ADAPTER,
PROP_DEVICE_ID,
PROP_VENDOR_ID,
};
/* reference list 2 + 4 margin */
#define NUM_OUTPUT_VIEW 6
@ -90,9 +82,7 @@ typedef struct _GstD3D11Mpeg2Dec
typedef struct _GstD3D11Mpeg2DecClass
{
GstMpeg2DecoderClass parent_class;
guint adapter;
guint device_id;
guint vendor_id;
GstD3D11DecoderSubClassData class_data;
} GstD3D11Mpeg2DecClass;
static GstElementClass *parent_class = NULL;
@ -146,48 +136,17 @@ gst_d3d11_mpeg2_dec_class_init (GstD3D11Mpeg2DecClass * klass, gpointer data)
GstVideoDecoderClass *decoder_class = GST_VIDEO_DECODER_CLASS (klass);
GstMpeg2DecoderClass *mpeg2decoder_class = GST_MPEG2_DECODER_CLASS (klass);
GstD3D11DecoderClassData *cdata = (GstD3D11DecoderClassData *) data;
gchar *long_name;
gobject_class->get_property = gst_d3d11_mpeg2_dec_get_property;
gobject_class->finalize = gst_d3d11_mpeg2_dec_finalize;
g_object_class_install_property (gobject_class, PROP_ADAPTER,
g_param_spec_uint ("adapter", "Adapter",
"DXGI Adapter index for creating device",
0, G_MAXUINT32, cdata->adapter,
(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,
(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,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
klass->adapter = cdata->adapter;
klass->device_id = cdata->device_id;
klass->vendor_id = cdata->vendor_id;
element_class->set_context =
GST_DEBUG_FUNCPTR (gst_d3d11_mpeg2_dec_set_context);
long_name =
g_strdup_printf ("Direct3D11/DXVA MPEG2 %s Decoder", cdata->description);
gst_element_class_set_metadata (element_class, long_name,
"Codec/Decoder/Video/Hardware", "A Direct3D11/DXVA MPEG2 video decoder",
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
gst_d3d11_decoder_class_data_fill_subclass_data (cdata, &klass->class_data);
gst_d3d11_decoder_proxy_class_init (element_class, cdata,
"Seungha Yang <seungha@centricular.com>");
g_free (long_name);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
cdata->sink_caps));
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
cdata->src_caps));
gst_d3d11_decoder_class_data_free (cdata);
decoder_class->open = GST_DEBUG_FUNCPTR (gst_d3d11_mpeg2_dec_open);
decoder_class->close = GST_DEBUG_FUNCPTR (gst_d3d11_mpeg2_dec_close);
@ -236,21 +195,9 @@ gst_d3d11_mpeg2_dec_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstD3D11Mpeg2DecClass *klass = GST_D3D11_MPEG2_DEC_GET_CLASS (object);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
switch (prop_id) {
case PROP_ADAPTER:
g_value_set_uint (value, klass->adapter);
break;
case PROP_DEVICE_ID:
g_value_set_uint (value, klass->device_id);
break;
case PROP_VENDOR_ID:
g_value_set_uint (value, klass->vendor_id);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
gst_d3d11_decoder_proxy_get_property (object, prop_id, value, pspec, cdata);
}
static void
@ -258,8 +205,9 @@ gst_d3d11_mpeg2_dec_set_context (GstElement * element, GstContext * context)
{
GstD3D11Mpeg2Dec *self = GST_D3D11_MPEG2_DEC (element);
GstD3D11Mpeg2DecClass *klass = GST_D3D11_MPEG2_DEC_GET_CLASS (self);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
gst_d3d11_handle_set_context (element, context, klass->adapter,
gst_d3d11_handle_set_context (element, context, cdata->adapter,
&self->device);
GST_ELEMENT_CLASS (parent_class)->set_context (element, context);
@ -270,8 +218,9 @@ gst_d3d11_mpeg2_dec_open (GstVideoDecoder * decoder)
{
GstD3D11Mpeg2Dec *self = GST_D3D11_MPEG2_DEC (decoder);
GstD3D11Mpeg2DecClass *klass = GST_D3D11_MPEG2_DEC_GET_CLASS (self);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
if (!gst_d3d11_ensure_element_data (GST_ELEMENT_CAST (self), klass->adapter,
if (!gst_d3d11_ensure_element_data (GST_ELEMENT_CAST (self), cdata->adapter,
&self->device)) {
GST_ERROR_OBJECT (self, "Cannot create d3d11device");
return FALSE;
@ -997,7 +946,8 @@ gst_d3d11_mpeg2_dec_register (GstPlugin * plugin, GstD3D11Device * device,
"height", GST_TYPE_INT_RANGE, 1, 1920, NULL);
type_info.class_data =
gst_d3d11_decoder_class_data_new (device, sink_caps, src_caps);
gst_d3d11_decoder_class_data_new (device, GST_D3D11_CODEC_MPEG2,
sink_caps, src_caps);
type_name = g_strdup ("GstD3D11Mpeg2Dec");
feature_name = g_strdup ("d3d11mpeg2dec");

View file

@ -52,14 +52,6 @@
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_vp8_dec_debug);
#define GST_CAT_DEFAULT gst_d3d11_vp8_dec_debug
enum
{
PROP_0,
PROP_ADAPTER,
PROP_DEVICE_ID,
PROP_VENDOR_ID,
};
/* reference list 4 + 4 margin */
#define NUM_OUTPUT_VIEW 8
@ -77,9 +69,7 @@ typedef struct _GstD3D11Vp8Dec
typedef struct _GstD3D11Vp8DecClass
{
GstVp8DecoderClass parent_class;
guint adapter;
guint device_id;
guint vendor_id;
GstD3D11DecoderSubClassData class_data;
} GstD3D11Vp8DecClass;
static GstElementClass *parent_class = NULL;
@ -125,47 +115,16 @@ gst_d3d11_vp8_dec_class_init (GstD3D11Vp8DecClass * klass, gpointer data)
GstVideoDecoderClass *decoder_class = GST_VIDEO_DECODER_CLASS (klass);
GstVp8DecoderClass *vp8decoder_class = GST_VP8_DECODER_CLASS (klass);
GstD3D11DecoderClassData *cdata = (GstD3D11DecoderClassData *) data;
gchar *long_name;
gobject_class->get_property = gst_d3d11_vp8_dec_get_property;
g_object_class_install_property (gobject_class, PROP_ADAPTER,
g_param_spec_uint ("adapter", "Adapter",
"DXGI Adapter index for creating device",
0, G_MAXUINT32, cdata->adapter,
(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,
(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,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
klass->adapter = cdata->adapter;
klass->device_id = cdata->device_id;
klass->vendor_id = cdata->vendor_id;
element_class->set_context =
GST_DEBUG_FUNCPTR (gst_d3d11_vp8_dec_set_context);
long_name =
g_strdup_printf ("Direct3D11/DXVA VP8 %s Decoder", cdata->description);
gst_element_class_set_metadata (element_class, long_name,
"Codec/Decoder/Video/Hardware", "A Direct3D11/DXVA VP8 video decoder",
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
gst_d3d11_decoder_class_data_fill_subclass_data (cdata, &klass->class_data);
gst_d3d11_decoder_proxy_class_init (element_class, cdata,
"Seungha Yang <seungha.yang@navercorp.com>");
g_free (long_name);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
cdata->sink_caps));
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
cdata->src_caps));
gst_d3d11_decoder_class_data_free (cdata);
decoder_class->open = GST_DEBUG_FUNCPTR (gst_d3d11_vp8_dec_open);
decoder_class->close = GST_DEBUG_FUNCPTR (gst_d3d11_vp8_dec_close);
@ -199,21 +158,9 @@ gst_d3d11_vp8_dec_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstD3D11Vp8DecClass *klass = GST_D3D11_VP8_DEC_GET_CLASS (object);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
switch (prop_id) {
case PROP_ADAPTER:
g_value_set_uint (value, klass->adapter);
break;
case PROP_DEVICE_ID:
g_value_set_uint (value, klass->device_id);
break;
case PROP_VENDOR_ID:
g_value_set_uint (value, klass->vendor_id);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
gst_d3d11_decoder_proxy_get_property (object, prop_id, value, pspec, cdata);
}
static void
@ -221,8 +168,9 @@ gst_d3d11_vp8_dec_set_context (GstElement * element, GstContext * context)
{
GstD3D11Vp8Dec *self = GST_D3D11_VP8_DEC (element);
GstD3D11Vp8DecClass *klass = GST_D3D11_VP8_DEC_GET_CLASS (self);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
gst_d3d11_handle_set_context (element, context, klass->adapter,
gst_d3d11_handle_set_context (element, context, cdata->adapter,
&self->device);
GST_ELEMENT_CLASS (parent_class)->set_context (element, context);
@ -233,8 +181,9 @@ gst_d3d11_vp8_dec_open (GstVideoDecoder * decoder)
{
GstD3D11Vp8Dec *self = GST_D3D11_VP8_DEC (decoder);
GstD3D11Vp8DecClass *klass = GST_D3D11_VP8_DEC_GET_CLASS (self);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
if (!gst_d3d11_ensure_element_data (GST_ELEMENT_CAST (self), klass->adapter,
if (!gst_d3d11_ensure_element_data (GST_ELEMENT_CAST (self), cdata->adapter,
&self->device)) {
GST_ERROR_OBJECT (self, "Cannot create d3d11device");
return FALSE;
@ -894,7 +843,8 @@ gst_d3d11_vp8_dec_register (GstPlugin * plugin, GstD3D11Device * device,
"height", GST_TYPE_INT_RANGE, 1, resolution, NULL);
type_info.class_data =
gst_d3d11_decoder_class_data_new (device, sink_caps, src_caps);
gst_d3d11_decoder_class_data_new (device, GST_D3D11_CODEC_VP8,
sink_caps, src_caps);
type_name = g_strdup ("GstD3D11Vp8Dec");
feature_name = g_strdup ("d3d11vp8dec");

View file

@ -82,14 +82,6 @@
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_vp9_dec_debug);
#define GST_CAT_DEFAULT gst_d3d11_vp9_dec_debug
enum
{
PROP_0,
PROP_ADAPTER,
PROP_DEVICE_ID,
PROP_VENDOR_ID,
};
/* reference list 8 + 4 margin */
#define NUM_OUTPUT_VIEW 12
@ -109,9 +101,7 @@ typedef struct _GstD3D11Vp9Dec
typedef struct _GstD3D11Vp9DecClass
{
GstVp9DecoderClass parent_class;
guint adapter;
guint device_id;
guint vendor_id;
GstD3D11DecoderSubClassData class_data;
} GstD3D11Vp9DecClass;
static GstElementClass *parent_class = NULL;
@ -159,47 +149,16 @@ gst_d3d11_vp9_dec_class_init (GstD3D11Vp9DecClass * klass, gpointer data)
GstVideoDecoderClass *decoder_class = GST_VIDEO_DECODER_CLASS (klass);
GstVp9DecoderClass *vp9decoder_class = GST_VP9_DECODER_CLASS (klass);
GstD3D11DecoderClassData *cdata = (GstD3D11DecoderClassData *) data;
gchar *long_name;
gobject_class->get_property = gst_d3d11_vp9_dec_get_property;
g_object_class_install_property (gobject_class, PROP_ADAPTER,
g_param_spec_uint ("adapter", "Adapter",
"DXGI Adapter index for creating device",
0, G_MAXUINT32, cdata->adapter,
(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,
(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,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
klass->adapter = cdata->adapter;
klass->device_id = cdata->device_id;
klass->vendor_id = cdata->vendor_id;
element_class->set_context =
GST_DEBUG_FUNCPTR (gst_d3d11_vp9_dec_set_context);
long_name =
g_strdup_printf ("Direct3D11/DXVA VP9 %s Decoder", cdata->description);
gst_element_class_set_metadata (element_class, long_name,
"Codec/Decoder/Video/Hardware", "A Direct3D11/DXVA VP9 video decoder",
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
gst_d3d11_decoder_class_data_fill_subclass_data (cdata, &klass->class_data);
gst_d3d11_decoder_proxy_class_init (element_class, cdata,
"Seungha Yang <seungha.yang@navercorp.com>");
g_free (long_name);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
cdata->sink_caps));
gst_element_class_add_pad_template (element_class,
gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
cdata->src_caps));
gst_d3d11_decoder_class_data_free (cdata);
decoder_class->open = GST_DEBUG_FUNCPTR (gst_d3d11_vp9_dec_open);
decoder_class->close = GST_DEBUG_FUNCPTR (gst_d3d11_vp9_dec_close);
@ -235,21 +194,9 @@ gst_d3d11_vp9_dec_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstD3D11Vp9DecClass *klass = GST_D3D11_VP9_DEC_GET_CLASS (object);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
switch (prop_id) {
case PROP_ADAPTER:
g_value_set_uint (value, klass->adapter);
break;
case PROP_DEVICE_ID:
g_value_set_uint (value, klass->device_id);
break;
case PROP_VENDOR_ID:
g_value_set_uint (value, klass->vendor_id);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
gst_d3d11_decoder_proxy_get_property (object, prop_id, value, pspec, cdata);
}
static void
@ -257,8 +204,9 @@ gst_d3d11_vp9_dec_set_context (GstElement * element, GstContext * context)
{
GstD3D11Vp9Dec *self = GST_D3D11_VP9_DEC (element);
GstD3D11Vp9DecClass *klass = GST_D3D11_VP9_DEC_GET_CLASS (self);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
gst_d3d11_handle_set_context (element, context, klass->adapter,
gst_d3d11_handle_set_context (element, context, cdata->adapter,
&self->device);
GST_ELEMENT_CLASS (parent_class)->set_context (element, context);
@ -269,8 +217,9 @@ gst_d3d11_vp9_dec_open (GstVideoDecoder * decoder)
{
GstD3D11Vp9Dec *self = GST_D3D11_VP9_DEC (decoder);
GstD3D11Vp9DecClass *klass = GST_D3D11_VP9_DEC_GET_CLASS (self);
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
if (!gst_d3d11_ensure_element_data (GST_ELEMENT_CAST (self), klass->adapter,
if (!gst_d3d11_ensure_element_data (GST_ELEMENT_CAST (self), cdata->adapter,
&self->device)) {
GST_ERROR_OBJECT (self, "Cannot create d3d11device");
return FALSE;
@ -1093,7 +1042,8 @@ gst_d3d11_vp9_dec_register (GstPlugin * plugin, GstD3D11Device * device,
"height", GST_TYPE_INT_RANGE, 1, resolution, NULL);
type_info.class_data =
gst_d3d11_decoder_class_data_new (device, sink_caps, src_caps);
gst_d3d11_decoder_class_data_new (device, GST_D3D11_CODEC_VP9,
sink_caps, src_caps);
type_name = g_strdup ("GstD3D11Vp9Dec");
feature_name = g_strdup ("d3d11vp9dec");