2019-12-26 05:28:03 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
|
2021-02-21 08:38:38 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-d3d11h265dec
|
|
|
|
* @title: d3d11h265dec
|
|
|
|
*
|
|
|
|
* A Direct3D11/DXVA based H.265 video decoder
|
|
|
|
*
|
|
|
|
* ## Example launch line
|
|
|
|
* ```
|
|
|
|
* gst-launch-1.0 filesrc location=/path/to/hevc/file ! parsebin ! d3d11h265dec ! d3d11videosink
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* Since: 1.18
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-12-26 05:28:03 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "gstd3d11h265dec.h"
|
2023-09-16 14:57:18 +00:00
|
|
|
#include <gst/dxva/gstdxvah265decoder.h>
|
2019-12-31 04:36:59 +00:00
|
|
|
|
2019-12-26 05:28:03 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_h265_dec_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_d3d11_h265_dec_debug
|
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
GST_D3D11_DECODER_DEFINE_TYPE (GstD3D11H265Dec, gst_d3d11_h265_dec,
|
|
|
|
GST, D3D11_H265_DEC, GstDxvaH265Decoder);
|
2019-12-26 05:28:03 +00:00
|
|
|
|
|
|
|
static void
|
2020-02-14 16:23:32 +00:00
|
|
|
gst_d3d11_h265_dec_class_init (GstD3D11H265DecClass * klass, gpointer data)
|
2019-12-26 05:28:03 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
GstVideoDecoderClass *decoder_class = GST_VIDEO_DECODER_CLASS (klass);
|
2023-09-16 14:57:18 +00:00
|
|
|
GstDxvaH265DecoderClass *dxva_class = GST_DXVA_H265_DECODER_CLASS (klass);
|
2020-02-14 16:23:32 +00:00
|
|
|
GstD3D11DecoderClassData *cdata = (GstD3D11DecoderClassData *) data;
|
2019-12-26 05:28:03 +00:00
|
|
|
|
|
|
|
gobject_class->get_property = gst_d3d11_h265_dec_get_property;
|
|
|
|
|
|
|
|
element_class->set_context =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_d3d11_h265_dec_set_context);
|
|
|
|
|
2021-09-15 14:41:39 +00:00
|
|
|
parent_class = (GstElementClass *) g_type_class_peek_parent (klass);
|
|
|
|
gst_d3d11_decoder_class_data_fill_subclass_data (cdata, &klass->class_data);
|
2021-10-21 10:41:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GstD3D11H265Dec:adapter-luid:
|
|
|
|
*
|
2022-01-28 19:46:24 +00:00
|
|
|
* DXGI Adapter LUID for this element
|
2021-10-21 10:41:15 +00:00
|
|
|
*
|
|
|
|
* Since: 1.20
|
|
|
|
*/
|
2021-09-15 14:41:39 +00:00
|
|
|
gst_d3d11_decoder_proxy_class_init (element_class, cdata,
|
2019-12-26 05:28:03 +00:00
|
|
|
"Seungha Yang <seungha.yang@navercorp.com>");
|
|
|
|
|
|
|
|
decoder_class->open = GST_DEBUG_FUNCPTR (gst_d3d11_h265_dec_open);
|
|
|
|
decoder_class->close = GST_DEBUG_FUNCPTR (gst_d3d11_h265_dec_close);
|
|
|
|
decoder_class->negotiate = GST_DEBUG_FUNCPTR (gst_d3d11_h265_dec_negotiate);
|
|
|
|
decoder_class->decide_allocation =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_d3d11_h265_dec_decide_allocation);
|
2023-09-16 14:57:18 +00:00
|
|
|
decoder_class->sink_query = GST_DEBUG_FUNCPTR (gst_d3d11_h265_dec_sink_query);
|
2019-12-26 05:28:03 +00:00
|
|
|
decoder_class->src_query = GST_DEBUG_FUNCPTR (gst_d3d11_h265_dec_src_query);
|
2021-04-23 14:20:54 +00:00
|
|
|
decoder_class->sink_event = GST_DEBUG_FUNCPTR (gst_d3d11_h265_dec_sink_event);
|
2019-12-26 05:28:03 +00:00
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
dxva_class->configure = GST_DEBUG_FUNCPTR (gst_d3d11_h265_dec_configure);
|
|
|
|
dxva_class->new_picture = GST_DEBUG_FUNCPTR (gst_d3d11_h265_dec_new_picture);
|
|
|
|
dxva_class->get_picture_id =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_d3d11_h265_dec_get_picture_id);
|
|
|
|
dxva_class->start_picture =
|
2019-12-26 05:28:03 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_d3d11_h265_dec_start_picture);
|
2023-09-16 14:57:18 +00:00
|
|
|
dxva_class->end_picture = GST_DEBUG_FUNCPTR (gst_d3d11_h265_dec_end_picture);
|
|
|
|
dxva_class->output_picture =
|
2021-09-20 15:23:13 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_d3d11_h265_dec_output_picture);
|
2019-12-26 05:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_d3d11_h265_dec_init (GstD3D11H265Dec * self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_d3d11_h265_dec_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2020-02-14 16:23:32 +00:00
|
|
|
GstD3D11H265DecClass *klass = GST_D3D11_H265_DEC_GET_CLASS (object);
|
2021-09-15 14:41:39 +00:00
|
|
|
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
|
2019-12-26 05:28:03 +00:00
|
|
|
|
2021-09-15 14:41:39 +00:00
|
|
|
gst_d3d11_decoder_proxy_get_property (object, prop_id, value, pspec, cdata);
|
2019-12-26 05:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_d3d11_h265_dec_set_context (GstElement * element, GstContext * context)
|
|
|
|
{
|
|
|
|
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (element);
|
2020-02-14 16:23:32 +00:00
|
|
|
GstD3D11H265DecClass *klass = GST_D3D11_H265_DEC_GET_CLASS (self);
|
2021-09-15 14:41:39 +00:00
|
|
|
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
|
2019-12-26 05:28:03 +00:00
|
|
|
|
2021-10-08 13:37:20 +00:00
|
|
|
gst_d3d11_handle_set_context_for_adapter_luid (element,
|
2023-09-16 14:57:18 +00:00
|
|
|
context, cdata->adapter_luid, &self->device);
|
2019-12-26 05:28:03 +00:00
|
|
|
|
|
|
|
GST_ELEMENT_CLASS (parent_class)->set_context (element, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_d3d11_h265_dec_open (GstVideoDecoder * decoder)
|
|
|
|
{
|
|
|
|
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder);
|
2020-02-14 16:23:32 +00:00
|
|
|
GstD3D11H265DecClass *klass = GST_D3D11_H265_DEC_GET_CLASS (self);
|
2021-09-15 14:41:39 +00:00
|
|
|
GstD3D11DecoderSubClassData *cdata = &klass->class_data;
|
2019-12-26 05:28:03 +00:00
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
return gst_d3d11_decoder_proxy_open (decoder,
|
|
|
|
cdata, &self->device, &self->decoder);
|
2019-12-26 05:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_d3d11_h265_dec_close (GstVideoDecoder * decoder)
|
|
|
|
{
|
|
|
|
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder);
|
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
gst_clear_object (&self->decoder);
|
|
|
|
gst_clear_object (&self->device);
|
2019-12-26 05:28:03 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_d3d11_h265_dec_negotiate (GstVideoDecoder * decoder)
|
|
|
|
{
|
|
|
|
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder);
|
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
if (!gst_d3d11_decoder_negotiate (self->decoder, decoder))
|
2020-03-29 14:31:13 +00:00
|
|
|
return FALSE;
|
2019-12-26 05:28:03 +00:00
|
|
|
|
|
|
|
return GST_VIDEO_DECODER_CLASS (parent_class)->negotiate (decoder);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_d3d11_h265_dec_decide_allocation (GstVideoDecoder * decoder,
|
|
|
|
GstQuery * query)
|
|
|
|
{
|
|
|
|
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder);
|
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
if (!gst_d3d11_decoder_decide_allocation (self->decoder, decoder, query))
|
2019-12-26 05:28:03 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return GST_VIDEO_DECODER_CLASS (parent_class)->decide_allocation
|
|
|
|
(decoder, query);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2023-09-16 14:57:18 +00:00
|
|
|
gst_d3d11_h265_dec_sink_query (GstVideoDecoder * decoder, GstQuery * query)
|
2019-12-26 05:28:03 +00:00
|
|
|
{
|
|
|
|
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder);
|
|
|
|
|
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_CONTEXT:
|
|
|
|
if (gst_d3d11_handle_context_query (GST_ELEMENT (decoder),
|
2023-09-16 14:57:18 +00:00
|
|
|
query, self->device)) {
|
2019-12-26 05:28:03 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
return GST_VIDEO_DECODER_CLASS (parent_class)->sink_query (decoder, query);
|
2019-12-26 05:28:03 +00:00
|
|
|
}
|
|
|
|
|
2021-03-15 09:26:03 +00:00
|
|
|
static gboolean
|
2023-09-16 14:57:18 +00:00
|
|
|
gst_d3d11_h265_dec_src_query (GstVideoDecoder * decoder, GstQuery * query)
|
2021-03-15 09:26:03 +00:00
|
|
|
{
|
|
|
|
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder);
|
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_CONTEXT:
|
|
|
|
if (gst_d3d11_handle_context_query (GST_ELEMENT (decoder),
|
|
|
|
query, self->device)) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
2021-04-23 14:20:54 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2021-03-15 09:26:03 +00:00
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
return GST_VIDEO_DECODER_CLASS (parent_class)->src_query (decoder, query);
|
2021-03-15 09:26:03 +00:00
|
|
|
}
|
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
static gboolean
|
|
|
|
gst_d3d11_h265_dec_sink_event (GstVideoDecoder * decoder, GstEvent * event)
|
2019-12-26 05:28:03 +00:00
|
|
|
{
|
|
|
|
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder);
|
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
if (self->decoder)
|
|
|
|
gst_d3d11_decoder_sink_event (self->decoder, event);
|
2019-12-26 05:28:03 +00:00
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
return GST_VIDEO_DECODER_CLASS (parent_class)->sink_event (decoder, event);
|
2019-12-26 05:28:03 +00:00
|
|
|
}
|
|
|
|
|
2021-09-20 15:23:13 +00:00
|
|
|
static GstFlowReturn
|
2023-09-16 14:57:18 +00:00
|
|
|
gst_d3d11_h265_dec_configure (GstDxvaH265Decoder * decoder,
|
|
|
|
GstVideoCodecState * input_state, const GstVideoInfo * info,
|
|
|
|
gint crop_x, gint crop_y, gint coded_width, gint coded_height,
|
|
|
|
gint max_dpb_size)
|
2019-12-26 05:28:03 +00:00
|
|
|
{
|
|
|
|
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder);
|
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
return gst_d3d11_decoder_configure (self->decoder, input_state,
|
|
|
|
info, crop_x, crop_y, coded_width, coded_height, max_dpb_size);
|
2019-12-26 05:28:03 +00:00
|
|
|
}
|
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_d3d11_h265_dec_new_picture (GstDxvaH265Decoder * decoder,
|
|
|
|
GstCodecPicture * picture)
|
2021-09-15 15:59:37 +00:00
|
|
|
{
|
2023-09-16 14:57:18 +00:00
|
|
|
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder);
|
2021-09-15 15:59:37 +00:00
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
return gst_d3d11_decoder_new_picture (self->decoder,
|
|
|
|
GST_VIDEO_DECODER (decoder), picture);
|
2021-09-15 15:59:37 +00:00
|
|
|
}
|
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
static guint8
|
|
|
|
gst_d3d11_h265_dec_get_picture_id (GstDxvaH265Decoder * decoder,
|
|
|
|
GstCodecPicture * picture)
|
2021-09-15 15:59:37 +00:00
|
|
|
{
|
|
|
|
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder);
|
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
return gst_d3d11_decoder_get_picture_id (self->decoder, picture);
|
2019-12-26 05:28:03 +00:00
|
|
|
}
|
|
|
|
|
2021-09-20 15:23:13 +00:00
|
|
|
static GstFlowReturn
|
2023-09-16 14:57:18 +00:00
|
|
|
gst_d3d11_h265_dec_start_picture (GstDxvaH265Decoder * decoder,
|
|
|
|
GstCodecPicture * picture, guint8 * picture_id)
|
2019-12-26 05:28:03 +00:00
|
|
|
{
|
|
|
|
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder);
|
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
return gst_d3d11_decoder_start_picture (self->decoder, picture, picture_id);
|
2019-12-26 05:28:03 +00:00
|
|
|
}
|
2020-01-10 15:01:55 +00:00
|
|
|
|
2021-09-20 15:23:13 +00:00
|
|
|
static GstFlowReturn
|
2023-09-16 14:57:18 +00:00
|
|
|
gst_d3d11_h265_dec_end_picture (GstDxvaH265Decoder * decoder,
|
|
|
|
GstCodecPicture * picture, GPtrArray * ref_pics,
|
|
|
|
const GstDxvaDecodingArgs * args)
|
2020-02-14 16:23:32 +00:00
|
|
|
{
|
2021-09-15 15:59:37 +00:00
|
|
|
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder);
|
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
return gst_d3d11_decoder_end_picture (self->decoder, picture, args);
|
2021-09-15 15:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2023-09-16 14:57:18 +00:00
|
|
|
gst_d3d11_h265_dec_output_picture (GstDxvaH265Decoder * decoder,
|
|
|
|
GstVideoCodecFrame * frame, GstCodecPicture * picture,
|
|
|
|
GstVideoBufferFlags buffer_flags, gint display_width, gint display_height)
|
2021-09-15 15:59:37 +00:00
|
|
|
{
|
|
|
|
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder);
|
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
return gst_d3d11_decoder_output_picture (self->decoder,
|
|
|
|
GST_VIDEO_DECODER (decoder), frame, picture,
|
|
|
|
buffer_flags, display_width, display_height);
|
2021-09-15 15:59:37 +00:00
|
|
|
}
|
2020-02-14 16:23:32 +00:00
|
|
|
|
2020-01-10 15:01:55 +00:00
|
|
|
void
|
|
|
|
gst_d3d11_h265_dec_register (GstPlugin * plugin, GstD3D11Device * device,
|
2021-09-15 15:59:37 +00:00
|
|
|
guint rank)
|
2020-01-10 15:01:55 +00:00
|
|
|
{
|
2020-02-14 16:23:32 +00:00
|
|
|
GType type;
|
|
|
|
gchar *type_name;
|
|
|
|
gchar *feature_name;
|
|
|
|
guint index = 0;
|
|
|
|
guint i;
|
2023-09-16 14:57:18 +00:00
|
|
|
const GUID *profile = nullptr;
|
2020-02-14 16:23:32 +00:00
|
|
|
GTypeInfo type_info = {
|
|
|
|
sizeof (GstD3D11H265DecClass),
|
2023-09-16 14:57:18 +00:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2020-02-14 16:23:32 +00:00
|
|
|
(GClassInitFunc) gst_d3d11_h265_dec_class_init,
|
2023-09-16 14:57:18 +00:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2020-02-14 16:23:32 +00:00
|
|
|
sizeof (GstD3D11H265Dec),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) gst_d3d11_h265_dec_init,
|
2020-01-10 15:01:55 +00:00
|
|
|
};
|
2023-09-16 14:57:18 +00:00
|
|
|
const GUID *main_10_guid = nullptr;
|
|
|
|
const GUID *main_guid = nullptr;
|
|
|
|
GstCaps *sink_caps = nullptr;
|
|
|
|
GstCaps *src_caps = nullptr;
|
2021-02-06 17:26:02 +00:00
|
|
|
GstCaps *src_caps_copy;
|
|
|
|
GstCaps *tmp;
|
|
|
|
GstCapsFeatures *caps_features;
|
2020-02-14 16:23:32 +00:00
|
|
|
guint max_width = 0;
|
|
|
|
guint max_height = 0;
|
|
|
|
guint resolution;
|
|
|
|
gboolean have_main10 = FALSE;
|
|
|
|
gboolean have_main = FALSE;
|
|
|
|
DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN;
|
|
|
|
|
2021-09-15 15:59:37 +00:00
|
|
|
have_main10 = gst_d3d11_decoder_get_supported_decoder_profile (device,
|
|
|
|
GST_DXVA_CODEC_H265, GST_VIDEO_FORMAT_P010_10LE, &main_10_guid);
|
2020-02-14 16:23:32 +00:00
|
|
|
if (!have_main10) {
|
|
|
|
GST_DEBUG_OBJECT (device, "decoder does not support HEVC_VLD_MAIN10");
|
|
|
|
} else {
|
|
|
|
have_main10 &=
|
2021-09-15 15:59:37 +00:00
|
|
|
gst_d3d11_decoder_supports_format (device, main_10_guid,
|
2021-03-14 06:08:01 +00:00
|
|
|
DXGI_FORMAT_P010);
|
2020-02-14 16:23:32 +00:00
|
|
|
if (!have_main10) {
|
2020-10-30 15:37:48 +00:00
|
|
|
GST_FIXME_OBJECT (device, "device does not support P010 format");
|
2020-02-14 16:23:32 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-10 15:01:55 +00:00
|
|
|
|
2021-09-15 15:59:37 +00:00
|
|
|
have_main = gst_d3d11_decoder_get_supported_decoder_profile (device,
|
|
|
|
GST_DXVA_CODEC_H265, GST_VIDEO_FORMAT_NV12, &main_guid);
|
2020-02-14 16:23:32 +00:00
|
|
|
if (!have_main) {
|
|
|
|
GST_DEBUG_OBJECT (device, "decoder does not support HEVC_VLD_MAIN");
|
|
|
|
} else {
|
|
|
|
have_main =
|
2021-09-15 15:59:37 +00:00
|
|
|
gst_d3d11_decoder_supports_format (device, main_guid, DXGI_FORMAT_NV12);
|
2020-02-14 16:23:32 +00:00
|
|
|
if (!have_main) {
|
|
|
|
GST_FIXME_OBJECT (device, "device does not support NV12 format");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!have_main10 && !have_main) {
|
|
|
|
GST_INFO_OBJECT (device, "device does not support h.265 decoding");
|
2020-01-10 15:01:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-14 16:23:32 +00:00
|
|
|
if (have_main) {
|
2021-03-14 06:08:01 +00:00
|
|
|
profile = main_guid;
|
2020-02-14 16:23:32 +00:00
|
|
|
format = DXGI_FORMAT_NV12;
|
|
|
|
} else {
|
2021-03-14 06:08:01 +00:00
|
|
|
profile = main_10_guid;
|
2020-02-14 16:23:32 +00:00
|
|
|
format = DXGI_FORMAT_P010;
|
|
|
|
}
|
|
|
|
|
2021-09-15 15:59:37 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (gst_dxva_resolutions); i++) {
|
|
|
|
if (gst_d3d11_decoder_supports_resolution (device, profile,
|
|
|
|
format, gst_dxva_resolutions[i].width,
|
|
|
|
gst_dxva_resolutions[i].height)) {
|
|
|
|
max_width = gst_dxva_resolutions[i].width;
|
|
|
|
max_height = gst_dxva_resolutions[i].height;
|
2020-01-10 15:01:55 +00:00
|
|
|
|
2020-02-14 16:23:32 +00:00
|
|
|
GST_DEBUG_OBJECT (device,
|
|
|
|
"device support resolution %dx%d", max_width, max_height);
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-01-10 15:01:55 +00:00
|
|
|
|
2020-02-14 16:23:32 +00:00
|
|
|
if (max_width == 0 || max_height == 0) {
|
|
|
|
GST_WARNING_OBJECT (device, "Couldn't query supported resolution");
|
2020-01-10 15:01:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-14 16:23:32 +00:00
|
|
|
sink_caps = gst_caps_from_string ("video/x-h265, "
|
|
|
|
"stream-format=(string) { hev1, hvc1, byte-stream }, "
|
2020-10-31 11:31:51 +00:00
|
|
|
"alignment= (string) au");
|
2021-02-06 17:26:02 +00:00
|
|
|
src_caps = gst_caps_new_empty_simple ("video/x-raw");
|
2020-02-14 16:23:32 +00:00
|
|
|
|
|
|
|
if (have_main10) {
|
|
|
|
/* main10 profile covers main and main10 */
|
|
|
|
GValue profile_list = G_VALUE_INIT;
|
|
|
|
GValue profile_value = G_VALUE_INIT;
|
|
|
|
GValue format_list = G_VALUE_INIT;
|
|
|
|
GValue format_value = G_VALUE_INIT;
|
|
|
|
|
|
|
|
g_value_init (&profile_list, GST_TYPE_LIST);
|
|
|
|
|
|
|
|
g_value_init (&profile_value, G_TYPE_STRING);
|
|
|
|
g_value_set_string (&profile_value, "main");
|
|
|
|
gst_value_list_append_and_take_value (&profile_list, &profile_value);
|
|
|
|
|
|
|
|
g_value_init (&profile_value, G_TYPE_STRING);
|
|
|
|
g_value_set_string (&profile_value, "main-10");
|
|
|
|
gst_value_list_append_and_take_value (&profile_list, &profile_value);
|
|
|
|
|
|
|
|
|
|
|
|
g_value_init (&format_list, GST_TYPE_LIST);
|
|
|
|
|
|
|
|
g_value_init (&format_value, G_TYPE_STRING);
|
|
|
|
g_value_set_string (&format_value, "NV12");
|
|
|
|
gst_value_list_append_and_take_value (&format_list, &format_value);
|
|
|
|
|
|
|
|
g_value_init (&format_value, G_TYPE_STRING);
|
|
|
|
g_value_set_string (&format_value, "P010_10LE");
|
|
|
|
gst_value_list_append_and_take_value (&format_list, &format_value);
|
|
|
|
|
|
|
|
gst_caps_set_value (sink_caps, "profile", &profile_list);
|
|
|
|
gst_caps_set_value (src_caps, "format", &format_list);
|
|
|
|
g_value_unset (&profile_list);
|
|
|
|
g_value_unset (&format_list);
|
|
|
|
} else {
|
2023-09-16 14:57:18 +00:00
|
|
|
gst_caps_set_simple (sink_caps, "profile", G_TYPE_STRING, "main", nullptr);
|
|
|
|
gst_caps_set_simple (src_caps, "format", G_TYPE_STRING, "NV12", nullptr);
|
2020-02-14 16:23:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* To cover both landscape and portrait, select max value */
|
|
|
|
resolution = MAX (max_width, max_height);
|
|
|
|
|
2021-02-06 17:26:02 +00:00
|
|
|
/* Copy src caps to append other capsfeatures */
|
|
|
|
src_caps_copy = gst_caps_copy (src_caps);
|
|
|
|
|
|
|
|
/* System memory with alternate interlace-mode */
|
|
|
|
tmp = gst_caps_copy (src_caps_copy);
|
2024-09-03 09:16:19 +00:00
|
|
|
caps_features =
|
|
|
|
gst_caps_features_new_static_str (GST_CAPS_FEATURE_FORMAT_INTERLACED,
|
2023-09-16 14:57:18 +00:00
|
|
|
nullptr);
|
2021-02-06 17:26:02 +00:00
|
|
|
gst_caps_set_features_simple (tmp, caps_features);
|
2023-09-16 14:57:18 +00:00
|
|
|
gst_caps_set_simple (tmp, "interlace-mode", G_TYPE_STRING, "alternate",
|
|
|
|
nullptr);
|
2021-02-06 17:26:02 +00:00
|
|
|
gst_caps_append (src_caps, tmp);
|
|
|
|
|
|
|
|
/* D3D11 memory feature */
|
|
|
|
tmp = gst_caps_copy (src_caps_copy);
|
2024-09-03 09:16:19 +00:00
|
|
|
caps_features =
|
|
|
|
gst_caps_features_new_static_str (GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY,
|
2023-09-16 14:57:18 +00:00
|
|
|
nullptr);
|
2021-02-06 17:26:02 +00:00
|
|
|
gst_caps_set_features_simple (tmp, caps_features);
|
|
|
|
gst_caps_append (src_caps, tmp);
|
|
|
|
|
|
|
|
/* FIXME: D3D11 deinterlace element is not prepared, so this D3D11 with
|
|
|
|
* interlaced caps feature is pointless at the moment */
|
|
|
|
#if 0
|
|
|
|
/* D3D11 memory with alternate interlace-mode */
|
|
|
|
tmp = gst_caps_copy (src_caps_copy);
|
2024-09-03 09:16:19 +00:00
|
|
|
caps_features =
|
|
|
|
gst_caps_features_new_static_str (GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY,
|
2023-09-16 14:57:18 +00:00
|
|
|
GST_CAPS_FEATURE_FORMAT_INTERLACED, nullptr);
|
2021-02-06 17:26:02 +00:00
|
|
|
gst_caps_set_features_simple (tmp, caps_features);
|
2023-09-16 14:57:18 +00:00
|
|
|
gst_caps_set_simple (tmp, "interlace-mode", G_TYPE_STRING, "alternate",
|
|
|
|
nullptr);
|
2021-02-06 17:26:02 +00:00
|
|
|
gst_caps_append (src_caps, tmp);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
gst_caps_unref (src_caps_copy);
|
|
|
|
|
2020-02-14 16:23:32 +00:00
|
|
|
type_info.class_data =
|
2021-09-15 15:59:37 +00:00
|
|
|
gst_d3d11_decoder_class_data_new (device, GST_DXVA_CODEC_H265,
|
2022-05-11 20:13:08 +00:00
|
|
|
sink_caps, src_caps, resolution);
|
2020-02-14 16:23:32 +00:00
|
|
|
|
|
|
|
type_name = g_strdup ("GstD3D11H265Dec");
|
|
|
|
feature_name = g_strdup ("d3d11h265dec");
|
|
|
|
|
|
|
|
while (g_type_from_name (type_name)) {
|
|
|
|
index++;
|
|
|
|
g_free (type_name);
|
|
|
|
g_free (feature_name);
|
|
|
|
type_name = g_strdup_printf ("GstD3D11H265Device%dDec", index);
|
|
|
|
feature_name = g_strdup_printf ("d3d11h265device%ddec", index);
|
|
|
|
}
|
|
|
|
|
2023-09-16 14:57:18 +00:00
|
|
|
type = g_type_register_static (GST_TYPE_DXVA_H265_DECODER,
|
2021-03-13 08:40:57 +00:00
|
|
|
type_name, &type_info, (GTypeFlags) 0);
|
2020-02-14 16:23:32 +00:00
|
|
|
|
|
|
|
/* make lower rank than default device */
|
|
|
|
if (rank > 0 && index != 0)
|
|
|
|
rank--;
|
|
|
|
|
2021-10-21 10:41:15 +00:00
|
|
|
if (index != 0)
|
|
|
|
gst_element_type_set_skip_documentation (type);
|
|
|
|
|
2020-02-14 16:23:32 +00:00
|
|
|
if (!gst_element_register (plugin, feature_name, rank, type))
|
|
|
|
GST_WARNING ("Failed to register plugin '%s'", type_name);
|
|
|
|
|
|
|
|
g_free (type_name);
|
|
|
|
g_free (feature_name);
|
2020-01-10 15:01:55 +00:00
|
|
|
}
|