d3d11decoder: Fix build on non-desktop target

Although the target platform of D3D11 decoding API are both desktop and UWP app,
DXVA header is blocked by "WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)"
which is meaning that that's only for desktop app.
To workaround this inconsistent annoyingness, we need to define WINAPI_PARTITION_DESKTOP
regardless of target WinAPI partition.
This commit is contained in:
Seungha Yang 2019-12-31 13:36:59 +09:00
parent 9064de27f9
commit 43a8eb9e92
6 changed files with 103 additions and 57 deletions

View file

@ -22,9 +22,6 @@
#include <gst/gst.h>
#include <gst/video/video.h>
#include <d3d9.h>
#include <dxva.h>
#include <dxva2api.h>
#include "gstd3d11_fwd.h"
#include "gstd3d11device.h"
#include "gstd3d11utils.h"

View file

@ -56,6 +56,14 @@
#include "gstd3d11bufferpool.h"
#include <string.h>
/* HACK: to expose dxva data structure on UWP */
#ifdef WINAPI_PARTITION_DESKTOP
#undef WINAPI_PARTITION_DESKTOP
#endif
#define WINAPI_PARTITION_DESKTOP 1
#include <d3d9.h>
#include <dxva.h>
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_h264_dec_debug);
#define GST_CAT_DEFAULT gst_d3d11_h264_dec_debug
@ -93,8 +101,19 @@ static GstStaticPadTemplate src_template =
(GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY, "{ NV12, P010_10LE }") "; "
GST_VIDEO_CAPS_MAKE ("{ NV12, P010_10LE }")));
struct _GstD3D11H264DecPrivate
{
/* Need to hide DXVA_PicEntry_H264 structure from header for UWP */
DXVA_PicEntry_H264 ref_frame_list[16];
INT field_order_cnt_list[16][2];
USHORT frame_num_list[16];
UINT used_for_reference_flags;
USHORT non_existing_frame_flags;
};
#define parent_class gst_d3d11_h264_dec_parent_class
G_DEFINE_TYPE (GstD3D11H264Dec, gst_d3d11_h264_dec, GST_TYPE_H264_DECODER);
G_DEFINE_TYPE_WITH_PRIVATE (GstD3D11H264Dec,
gst_d3d11_h264_dec, GST_TYPE_H264_DECODER);
static void gst_d3d11_h264_dec_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
@ -189,6 +208,7 @@ gst_d3d11_h264_dec_class_init (GstD3D11H264DecClass * klass)
static void
gst_d3d11_h264_dec_init (GstD3D11H264Dec * self)
{
self->priv = gst_d3d11_h264_dec_get_instance_private (self);
self->slice_list = g_array_new (FALSE, TRUE, sizeof (DXVA_Slice_H264_Short));
self->adapter = DEFAULT_ADAPTER;
}
@ -610,6 +630,7 @@ gst_d3d11_h264_dec_start_picture (GstH264Decoder * decoder,
GstH264Picture * picture, GstH264Slice * slice, GstH264Dpb * dpb)
{
GstD3D11H264Dec *self = GST_D3D11_H264_DEC (decoder);
GstD3D11H264DecPrivate *priv = self->priv;
GstD3D11DecoderOutputView *view;
gint i;
GArray *dpb_array;
@ -628,13 +649,13 @@ gst_d3d11_h264_dec_start_picture (GstH264Decoder * decoder,
}
for (i = 0; i < 16; i++) {
self->ref_frame_list[i].bPicEntry = 0xFF;
self->field_order_cnt_list[i][0] = 0;
self->field_order_cnt_list[i][1] = 0;
self->frame_num_list[i] = 0;
priv->ref_frame_list[i].bPicEntry = 0xFF;
priv->field_order_cnt_list[i][0] = 0;
priv->field_order_cnt_list[i][1] = 0;
priv->frame_num_list[i] = 0;
}
self->used_for_reference_flags = 0;
self->non_existing_frame_flags = 0;
priv->used_for_reference_flags = 0;
priv->non_existing_frame_flags = 0;
dpb_array = gst_h264_dpb_get_pictures_all (dpb);
@ -652,14 +673,14 @@ gst_d3d11_h264_dec_start_picture (GstH264Decoder * decoder,
if (other_view)
id = other_view->view_id;
self->ref_frame_list[i].Index7Bits = id;
self->ref_frame_list[i].AssociatedFlag = other->long_term;
self->field_order_cnt_list[i][0] = other->top_field_order_cnt;
self->field_order_cnt_list[i][1] = other->bottom_field_order_cnt;
self->frame_num_list[i] = self->ref_frame_list[i].AssociatedFlag
priv->ref_frame_list[i].Index7Bits = id;
priv->ref_frame_list[i].AssociatedFlag = other->long_term;
priv->field_order_cnt_list[i][0] = other->top_field_order_cnt;
priv->field_order_cnt_list[i][1] = other->bottom_field_order_cnt;
priv->frame_num_list[i] = priv->ref_frame_list[i].AssociatedFlag
? other->long_term_pic_num : other->frame_num;
self->used_for_reference_flags |= ref << (2 * i);
self->non_existing_frame_flags |= (other->nonexisting) << i;
priv->used_for_reference_flags |= ref << (2 * i);
priv->non_existing_frame_flags |= (other->nonexisting) << i;
}
g_array_unref (dpb_array);
@ -995,6 +1016,7 @@ gst_d3d11_h264_dec_decode_slice (GstH264Decoder * decoder,
GstH264Picture * picture, GstH264Slice * slice)
{
GstD3D11H264Dec *self = GST_D3D11_H264_DEC (decoder);
GstD3D11H264DecPrivate *priv = self->priv;
GstH264SPS *sps;
GstH264PPS *pps;
DXVA_PicParams_H264 pic_params = { 0, };
@ -1031,15 +1053,15 @@ gst_d3d11_h264_dec_decode_slice (GstH264Decoder * decoder,
pic_params.CurrFieldOrderCnt[1] = picture->bottom_field_order_cnt;
}
memcpy (pic_params.RefFrameList, self->ref_frame_list,
memcpy (pic_params.RefFrameList, priv->ref_frame_list,
sizeof (pic_params.RefFrameList));
memcpy (pic_params.FieldOrderCntList, self->field_order_cnt_list,
memcpy (pic_params.FieldOrderCntList, priv->field_order_cnt_list,
sizeof (pic_params.FieldOrderCntList));
memcpy (pic_params.FrameNumList, self->frame_num_list,
memcpy (pic_params.FrameNumList, priv->frame_num_list,
sizeof (pic_params.FrameNumList));
pic_params.UsedForReferenceFlags = self->used_for_reference_flags;
pic_params.NonExistingFrameFlags = self->non_existing_frame_flags;
pic_params.UsedForReferenceFlags = priv->used_for_reference_flags;
pic_params.NonExistingFrameFlags = priv->non_existing_frame_flags;
GST_TRACE_OBJECT (self, "Getting picture param decoder buffer");

View file

@ -39,6 +39,8 @@ G_BEGIN_DECLS
#define GST_IS_D3D11_H264_DEC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_D3D11_H264_DEC))
typedef struct _GstD3D11H264DecPrivate GstD3D11H264DecPrivate;
struct _GstD3D11H264Dec
{
GstH264Decoder parent;
@ -54,12 +56,6 @@ struct _GstD3D11H264Dec
guint chroma_format_idc;
GstVideoFormat out_format;
DXVA_PicEntry_H264 ref_frame_list[16];
INT field_order_cnt_list[16][2];
USHORT frame_num_list[16];
UINT used_for_reference_flags;
USHORT non_existing_frame_flags;
/* Array of DXVA_Slice_H264_Short */
GArray *slice_list;
@ -73,6 +69,8 @@ struct _GstD3D11H264Dec
guint8 * bitstream_buffer_bytes;
gboolean use_d3d11_output;
GstD3D11H264DecPrivate *priv;
};
struct _GstD3D11H264DecClass

View file

@ -26,6 +26,14 @@
#include "gstd3d11bufferpool.h"
#include <string.h>
/* HACK: to expose dxva data structure on UWP */
#ifdef WINAPI_PARTITION_DESKTOP
#undef WINAPI_PARTITION_DESKTOP
#endif
#define WINAPI_PARTITION_DESKTOP 1
#include <d3d9.h>
#include <dxva.h>
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_h265_dec_debug);
#define GST_CAT_DEFAULT gst_d3d11_h265_dec_debug
@ -61,8 +69,18 @@ static GstStaticPadTemplate src_template =
(GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY, "{ NV12, P010_10LE }") "; "
GST_VIDEO_CAPS_MAKE ("{ NV12, P010_10LE }")));
struct _GstD3D11H265DecPrivate
{
DXVA_PicEntry_HEVC ref_pic_list[15];
INT pic_order_cnt_val_list[15];
UCHAR ref_pic_set_st_curr_before[8];
UCHAR ref_pic_set_st_curr_after[8];
UCHAR ref_pic_set_lt_curr[8];
};
#define parent_class gst_d3d11_h265_dec_parent_class
G_DEFINE_TYPE (GstD3D11H265Dec, gst_d3d11_h265_dec, GST_TYPE_H265_DECODER);
G_DEFINE_TYPE_WITH_PRIVATE (GstD3D11H265Dec,
gst_d3d11_h265_dec, GST_TYPE_H265_DECODER);
static void gst_d3d11_h265_dec_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
@ -157,6 +175,7 @@ gst_d3d11_h265_dec_class_init (GstD3D11H265DecClass * klass)
static void
gst_d3d11_h265_dec_init (GstD3D11H265Dec * self)
{
self->priv = gst_d3d11_h265_dec_get_instance_private (self);
self->slice_list = g_array_new (FALSE, TRUE, sizeof (DXVA_Slice_HEVC_Short));
self->adapter = DEFAULT_ADAPTER;
}
@ -573,9 +592,11 @@ 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)
{
GstD3D11H265DecPrivate *priv = self->priv;
gint i;
for (i = 0; i < G_N_ELEMENTS (self->ref_pic_list); i++) {
if (self->ref_pic_list[i].Index7Bits == view_id)
for (i = 0; i < G_N_ELEMENTS (priv->ref_pic_list); i++) {
if (priv->ref_pic_list[i].Index7Bits == view_id)
return i;
}
@ -587,6 +608,7 @@ gst_d3d11_h265_dec_start_picture (GstH265Decoder * decoder,
GstH265Picture * picture, GstH265Slice * slice, GstH265Dpb * dpb)
{
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder);
GstD3D11H265DecPrivate *priv = self->priv;
GstD3D11DecoderOutputView *view;
gint i, j;
GArray *dpb_array;
@ -605,21 +627,21 @@ gst_d3d11_h265_dec_start_picture (GstH265Decoder * decoder,
}
for (i = 0; i < 15; i++) {
self->ref_pic_list[i].bPicEntry = 0xff;
self->pic_order_cnt_val_list[i] = 0;
priv->ref_pic_list[i].bPicEntry = 0xff;
priv->pic_order_cnt_val_list[i] = 0;
}
for (i = 0; i < 8; i++) {
self->ref_pic_set_st_curr_before[i] = 0xff;
self->ref_pic_set_st_curr_after[i] = 0xff;
self->ref_pic_set_lt_curr[i] = 0xff;
priv->ref_pic_set_st_curr_before[i] = 0xff;
priv->ref_pic_set_st_curr_after[i] = 0xff;
priv->ref_pic_set_lt_curr[i] = 0xff;
}
dpb_array = gst_h265_dpb_get_pictures_all (dpb);
GST_LOG_OBJECT (self, "DPB size %d", dpb_array->len);
for (i = 0; i < dpb_array->len && i < G_N_ELEMENTS (self->ref_pic_list); i++) {
for (i = 0; i < dpb_array->len && i < G_N_ELEMENTS (priv->ref_pic_list); i++) {
GstH265Picture *other = g_array_index (dpb_array, GstH265Picture *, i);
GstD3D11DecoderOutputView *other_view;
gint id = 0xff;
@ -634,12 +656,12 @@ gst_d3d11_h265_dec_start_picture (GstH265Decoder * decoder,
if (other_view)
id = other_view->view_id;
self->ref_pic_list[i].Index7Bits = id;
self->ref_pic_list[i].AssociatedFlag = other->long_term;
self->pic_order_cnt_val_list[i] = other->pic_order_cnt;
priv->ref_pic_list[i].Index7Bits = id;
priv->ref_pic_list[i].AssociatedFlag = other->long_term;
priv->pic_order_cnt_val_list[i] = other->pic_order_cnt;
}
for (i = 0, j = 0; i < G_N_ELEMENTS (self->ref_pic_set_st_curr_before); i++) {
for (i = 0, j = 0; i < G_N_ELEMENTS (priv->ref_pic_set_st_curr_before); i++) {
GstH265Picture *other = NULL;
gint id = 0xff;
@ -656,10 +678,10 @@ gst_d3d11_h265_dec_start_picture (GstH265Decoder * decoder,
id = gst_d3d11_h265_dec_get_ref_index (self, other_view->view_id);
}
self->ref_pic_set_st_curr_before[i] = id;
priv->ref_pic_set_st_curr_before[i] = id;
}
for (i = 0, j = 0; i < G_N_ELEMENTS (self->ref_pic_set_st_curr_after); i++) {
for (i = 0, j = 0; i < G_N_ELEMENTS (priv->ref_pic_set_st_curr_after); i++) {
GstH265Picture *other = NULL;
gint id = 0xff;
@ -676,10 +698,10 @@ gst_d3d11_h265_dec_start_picture (GstH265Decoder * decoder,
id = gst_d3d11_h265_dec_get_ref_index (self, other_view->view_id);
}
self->ref_pic_set_st_curr_after[i] = id;
priv->ref_pic_set_st_curr_after[i] = id;
}
for (i = 0, j = 0; i < G_N_ELEMENTS (self->ref_pic_set_lt_curr); i++) {
for (i = 0, j = 0; i < G_N_ELEMENTS (priv->ref_pic_set_lt_curr); i++) {
GstH265Picture *other = NULL;
gint id = 0xff;
@ -696,7 +718,7 @@ gst_d3d11_h265_dec_start_picture (GstH265Decoder * decoder,
id = gst_d3d11_h265_dec_get_ref_index (self, other_view->view_id);
}
self->ref_pic_set_lt_curr[i] = id;
priv->ref_pic_set_lt_curr[i] = id;
}
g_array_unref (dpb_array);
@ -1206,6 +1228,7 @@ gst_d3d11_h265_dec_decode_slice (GstH265Decoder * decoder,
GstH265Picture * picture, GstH265Slice * slice)
{
GstD3D11H265Dec *self = GST_D3D11_H265_DEC (decoder);
GstD3D11H265DecPrivate *priv = self->priv;
GstH265PPS *pps;
DXVA_PicParams_HEVC pic_params = { 0, };
DXVA_Qmatrix_HEVC iq_matrix = { 0, };
@ -1231,15 +1254,15 @@ gst_d3d11_h265_dec_decode_slice (GstH265Decoder * decoder,
pic_params.IntraPicFlag = IS_IRAP (slice->nalu.type);
pic_params.CurrPicOrderCntVal = picture->pic_order_cnt;
memcpy (pic_params.RefPicList, self->ref_pic_list,
memcpy (pic_params.RefPicList, priv->ref_pic_list,
sizeof (pic_params.RefPicList));
memcpy (pic_params.PicOrderCntValList, self->pic_order_cnt_val_list,
memcpy (pic_params.PicOrderCntValList, priv->pic_order_cnt_val_list,
sizeof (pic_params.PicOrderCntValList));
memcpy (pic_params.RefPicSetStCurrBefore, self->ref_pic_set_st_curr_before,
memcpy (pic_params.RefPicSetStCurrBefore, priv->ref_pic_set_st_curr_before,
sizeof (pic_params.RefPicSetStCurrBefore));
memcpy (pic_params.RefPicSetStCurrAfter, self->ref_pic_set_st_curr_after,
memcpy (pic_params.RefPicSetStCurrAfter, priv->ref_pic_set_st_curr_after,
sizeof (pic_params.RefPicSetStCurrAfter));
memcpy (pic_params.RefPicSetLtCurr, self->ref_pic_set_lt_curr,
memcpy (pic_params.RefPicSetLtCurr, priv->ref_pic_set_lt_curr,
sizeof (pic_params.RefPicSetLtCurr));
#ifndef GST_DISABLE_GST_DEBUG

View file

@ -39,6 +39,8 @@ G_BEGIN_DECLS
#define GST_IS_D3D11_H265_DEC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_D3D11_H265_DEC))
typedef struct _GstD3D11H265DecPrivate GstD3D11H265DecPrivate;
struct _GstD3D11H265Dec
{
GstH265Decoder parent;
@ -54,12 +56,6 @@ struct _GstD3D11H265Dec
guint chroma_format_idc;
GstVideoFormat out_format;
DXVA_PicEntry_HEVC ref_pic_list[15];
INT pic_order_cnt_val_list[15];
UCHAR ref_pic_set_st_curr_before[8];
UCHAR ref_pic_set_st_curr_after[8];
UCHAR ref_pic_set_lt_curr[8];
/* Array of DXVA_Slice_HEVC_Short */
GArray *slice_list;
gboolean submit_iq_data;
@ -74,6 +70,8 @@ struct _GstD3D11H265Dec
guint8 * bitstream_buffer_bytes;
gboolean use_d3d11_output;
GstD3D11H265DecPrivate *priv;
};
struct _GstD3D11H265DecClass

View file

@ -56,6 +56,14 @@
#include "gstd3d11bufferpool.h"
#include <string.h>
/* HACK: to expose dxva data structure on UWP */
#ifdef WINAPI_PARTITION_DESKTOP
#undef WINAPI_PARTITION_DESKTOP
#endif
#define WINAPI_PARTITION_DESKTOP 1
#include <d3d9.h>
#include <dxva.h>
GST_DEBUG_CATEGORY_EXTERN (gst_d3d11_vp9_dec_debug);
#define GST_CAT_DEFAULT gst_d3d11_vp9_dec_debug