mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 04:56:24 +00:00
d3d11decoder: Use consistent resolution between output caps and video meta
h264/h265 decoded buffer might have crop area then we need to adjust video meta based on the padding space
This commit is contained in:
parent
2f32f30b62
commit
371b181292
5 changed files with 35 additions and 19 deletions
|
@ -347,13 +347,15 @@ gst_d3d11_decoder_ensure_output_view (GstD3D11Decoder * self,
|
||||||
/* Must be called from D3D11Device thread */
|
/* Must be called from D3D11Device thread */
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_d3d11_decoder_prepare_output_view_pool (GstD3D11Decoder * self,
|
gst_d3d11_decoder_prepare_output_view_pool (GstD3D11Decoder * self,
|
||||||
GstVideoInfo * info, guint pool_size, const GUID * decoder_profile)
|
GstVideoInfo * info, guint coded_width, guint coded_height,
|
||||||
|
guint pool_size, const GUID * decoder_profile)
|
||||||
{
|
{
|
||||||
GstD3D11DecoderPrivate *priv = self->priv;
|
GstD3D11DecoderPrivate *priv = self->priv;
|
||||||
GstD3D11AllocationParams *alloc_params = NULL;
|
GstD3D11AllocationParams *alloc_params = NULL;
|
||||||
GstBufferPool *pool = NULL;
|
GstBufferPool *pool = NULL;
|
||||||
GstStructure *config = NULL;
|
GstStructure *config = NULL;
|
||||||
GstCaps *caps = NULL;
|
GstCaps *caps = NULL;
|
||||||
|
GstVideoAlignment align;
|
||||||
|
|
||||||
gst_clear_object (&priv->internal_pool);
|
gst_clear_object (&priv->internal_pool);
|
||||||
|
|
||||||
|
@ -366,6 +368,14 @@ gst_d3d11_decoder_prepare_output_view_pool (GstD3D11Decoder * self,
|
||||||
}
|
}
|
||||||
|
|
||||||
alloc_params->desc[0].ArraySize = pool_size;
|
alloc_params->desc[0].ArraySize = pool_size;
|
||||||
|
gst_video_alignment_reset (&align);
|
||||||
|
|
||||||
|
align.padding_right = coded_width - GST_VIDEO_INFO_WIDTH (info);
|
||||||
|
align.padding_bottom = coded_height - GST_VIDEO_INFO_HEIGHT (info);
|
||||||
|
if (!gst_d3d11_allocation_params_alignment (alloc_params, &align)) {
|
||||||
|
GST_ERROR_OBJECT (self, "Cannot set alignment");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
pool = gst_d3d11_buffer_pool_new (priv->device);
|
pool = gst_d3d11_buffer_pool_new (priv->device);
|
||||||
if (!pool) {
|
if (!pool) {
|
||||||
|
@ -415,8 +425,8 @@ error:
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
||||||
GstVideoInfo * info, guint pool_size, const GUID ** decoder_profiles,
|
GstVideoInfo * info, guint coded_width, guint coded_height,
|
||||||
guint profile_size)
|
guint pool_size, const GUID ** decoder_profiles, guint profile_size)
|
||||||
{
|
{
|
||||||
GstD3D11DecoderPrivate *priv;
|
GstD3D11DecoderPrivate *priv;
|
||||||
const GstD3D11Format *d3d11_format;
|
const GstD3D11Format *d3d11_format;
|
||||||
|
@ -435,6 +445,8 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
||||||
g_return_val_if_fail (codec > GST_D3D11_CODEC_NONE, FALSE);
|
g_return_val_if_fail (codec > GST_D3D11_CODEC_NONE, FALSE);
|
||||||
g_return_val_if_fail (codec < GST_D3D11_CODEC_LAST, FALSE);
|
g_return_val_if_fail (codec < GST_D3D11_CODEC_LAST, FALSE);
|
||||||
g_return_val_if_fail (info != NULL, FALSE);
|
g_return_val_if_fail (info != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (coded_width >= GST_VIDEO_INFO_WIDTH (info), FALSE);
|
||||||
|
g_return_val_if_fail (coded_height >= GST_VIDEO_INFO_HEIGHT (info), FALSE);
|
||||||
g_return_val_if_fail (pool_size > 0, FALSE);
|
g_return_val_if_fail (pool_size > 0, FALSE);
|
||||||
g_return_val_if_fail (decoder_profiles != NULL, FALSE);
|
g_return_val_if_fail (decoder_profiles != NULL, FALSE);
|
||||||
g_return_val_if_fail (profile_size > 0, FALSE);
|
g_return_val_if_fail (profile_size > 0, FALSE);
|
||||||
|
@ -531,8 +543,8 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
||||||
|
|
||||||
gst_d3d11_decoder_reset_unlocked (decoder);
|
gst_d3d11_decoder_reset_unlocked (decoder);
|
||||||
|
|
||||||
decoder_desc.SampleWidth = GST_VIDEO_INFO_WIDTH (info);
|
decoder_desc.SampleWidth = coded_width;
|
||||||
decoder_desc.SampleHeight = GST_VIDEO_INFO_HEIGHT (info);
|
decoder_desc.SampleHeight = coded_height;
|
||||||
decoder_desc.OutputFormat = d3d11_format->dxgi_format;
|
decoder_desc.OutputFormat = d3d11_format->dxgi_format;
|
||||||
decoder_desc.Guid = *selected_profile;
|
decoder_desc.Guid = *selected_profile;
|
||||||
|
|
||||||
|
@ -577,7 +589,7 @@ gst_d3d11_decoder_open (GstD3D11Decoder * decoder, GstD3D11Codec codec,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_d3d11_decoder_prepare_output_view_pool (decoder,
|
if (!gst_d3d11_decoder_prepare_output_view_pool (decoder,
|
||||||
info, pool_size, selected_profile)) {
|
info, coded_width, coded_height, pool_size, selected_profile)) {
|
||||||
GST_ERROR_OBJECT (decoder, "Couldn't prepare output view pool");
|
GST_ERROR_OBJECT (decoder, "Couldn't prepare output view pool");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,8 @@ GstD3D11Decoder * gst_d3d11_decoder_new (GstD3D11Device * device);
|
||||||
gboolean gst_d3d11_decoder_open (GstD3D11Decoder * decoder,
|
gboolean gst_d3d11_decoder_open (GstD3D11Decoder * decoder,
|
||||||
GstD3D11Codec codec,
|
GstD3D11Codec codec,
|
||||||
GstVideoInfo * info,
|
GstVideoInfo * info,
|
||||||
|
guint codec_width,
|
||||||
|
guint codec_height,
|
||||||
guint pool_size,
|
guint pool_size,
|
||||||
const GUID ** decoder_profiles,
|
const GUID ** decoder_profiles,
|
||||||
guint profile_size);
|
guint profile_size);
|
||||||
|
|
|
@ -517,7 +517,8 @@ gst_d3d11_h264_dec_new_sequence (GstH264Decoder * decoder,
|
||||||
|
|
||||||
if (self->width != crop_width || self->height != crop_height ||
|
if (self->width != crop_width || self->height != crop_height ||
|
||||||
self->coded_width != sps->width || self->coded_height != sps->height) {
|
self->coded_width != sps->width || self->coded_height != sps->height) {
|
||||||
GST_INFO_OBJECT (self, "resolution changed %dx%d", crop_width, crop_height);
|
GST_INFO_OBJECT (self, "resolution changed %dx%d (%dx%d)",
|
||||||
|
crop_width, crop_height, sps->width, sps->height);
|
||||||
self->width = crop_width;
|
self->width = crop_width;
|
||||||
self->height = crop_height;
|
self->height = crop_height;
|
||||||
self->coded_width = sps->width;
|
self->coded_width = sps->width;
|
||||||
|
@ -561,14 +562,13 @@ gst_d3d11_h264_dec_new_sequence (GstH264Decoder * decoder,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocated internal pool with coded width/height */
|
|
||||||
gst_video_info_set_format (&info,
|
gst_video_info_set_format (&info,
|
||||||
self->out_format, self->coded_width, self->coded_height);
|
self->out_format, self->width, self->height);
|
||||||
|
|
||||||
gst_d3d11_decoder_reset (self->d3d11_decoder);
|
gst_d3d11_decoder_reset (self->d3d11_decoder);
|
||||||
if (!gst_d3d11_decoder_open (self->d3d11_decoder, GST_D3D11_CODEC_H264,
|
if (!gst_d3d11_decoder_open (self->d3d11_decoder, GST_D3D11_CODEC_H264,
|
||||||
&info, NUM_OUTPUT_VIEW, supported_profiles,
|
&info, self->coded_width, self->coded_height, NUM_OUTPUT_VIEW,
|
||||||
G_N_ELEMENTS (supported_profiles))) {
|
supported_profiles, G_N_ELEMENTS (supported_profiles))) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to create decoder");
|
GST_ERROR_OBJECT (self, "Failed to create decoder");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1237,7 +1237,7 @@ gst_d3d11_h264_dec_register (GstPlugin * plugin, GstD3D11Device * device,
|
||||||
gst_video_info_set_format (&info, GST_VIDEO_FORMAT_NV12, 1280, 720);
|
gst_video_info_set_format (&info, GST_VIDEO_FORMAT_NV12, 1280, 720);
|
||||||
|
|
||||||
ret = gst_d3d11_decoder_open (decoder, GST_D3D11_CODEC_H264,
|
ret = gst_d3d11_decoder_open (decoder, GST_D3D11_CODEC_H264,
|
||||||
&info, NUM_OUTPUT_VIEW, supported_profiles,
|
&info, 1280, 720, NUM_OUTPUT_VIEW, supported_profiles,
|
||||||
G_N_ELEMENTS (supported_profiles));
|
G_N_ELEMENTS (supported_profiles));
|
||||||
gst_object_unref (decoder);
|
gst_object_unref (decoder);
|
||||||
|
|
||||||
|
|
|
@ -479,7 +479,8 @@ gst_d3d11_h265_dec_new_sequence (GstH265Decoder * decoder,
|
||||||
|
|
||||||
if (self->width != crop_width || self->height != crop_height ||
|
if (self->width != crop_width || self->height != crop_height ||
|
||||||
self->coded_width != sps->width || self->coded_height != sps->height) {
|
self->coded_width != sps->width || self->coded_height != sps->height) {
|
||||||
GST_INFO_OBJECT (self, "resolution changed %dx%d", crop_width, crop_height);
|
GST_INFO_OBJECT (self, "resolution changed %dx%d (%dx%d)",
|
||||||
|
crop_width, crop_height, sps->width, sps->height);
|
||||||
self->width = crop_width;
|
self->width = crop_width;
|
||||||
self->height = crop_height;
|
self->height = crop_height;
|
||||||
self->coded_width = sps->width;
|
self->coded_width = sps->width;
|
||||||
|
@ -526,13 +527,13 @@ gst_d3d11_h265_dec_new_sequence (GstH265Decoder * decoder,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocated internal pool with coded width/height */
|
|
||||||
gst_video_info_set_format (&info,
|
gst_video_info_set_format (&info,
|
||||||
self->out_format, self->coded_width, self->coded_height);
|
self->out_format, self->width, self->height);
|
||||||
|
|
||||||
gst_d3d11_decoder_reset (self->d3d11_decoder);
|
gst_d3d11_decoder_reset (self->d3d11_decoder);
|
||||||
if (!gst_d3d11_decoder_open (self->d3d11_decoder, GST_D3D11_CODEC_H265,
|
if (!gst_d3d11_decoder_open (self->d3d11_decoder, GST_D3D11_CODEC_H265,
|
||||||
&info, NUM_OUTPUT_VIEW, &profile_guid, 1)) {
|
&info, self->coded_width, self->coded_height,
|
||||||
|
NUM_OUTPUT_VIEW, &profile_guid, 1)) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to create decoder");
|
GST_ERROR_OBJECT (self, "Failed to create decoder");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1452,7 +1453,7 @@ gst_d3d11_h265_dec_register (GstPlugin * plugin, GstD3D11Device * device,
|
||||||
gst_video_info_set_format (&info, GST_VIDEO_FORMAT_NV12, 1280, 720);
|
gst_video_info_set_format (&info, GST_VIDEO_FORMAT_NV12, 1280, 720);
|
||||||
|
|
||||||
ret = gst_d3d11_decoder_open (decoder, GST_D3D11_CODEC_H265,
|
ret = gst_d3d11_decoder_open (decoder, GST_D3D11_CODEC_H265,
|
||||||
&info, NUM_OUTPUT_VIEW, supported_profiles,
|
&info, 1280, 720, NUM_OUTPUT_VIEW, supported_profiles,
|
||||||
G_N_ELEMENTS (supported_profiles));
|
G_N_ELEMENTS (supported_profiles));
|
||||||
gst_object_unref (decoder);
|
gst_object_unref (decoder);
|
||||||
|
|
||||||
|
|
|
@ -512,7 +512,8 @@ gst_d3d11_vp9_dec_new_sequence (GstVp9Decoder * decoder,
|
||||||
|
|
||||||
gst_d3d11_decoder_reset (self->d3d11_decoder);
|
gst_d3d11_decoder_reset (self->d3d11_decoder);
|
||||||
if (!gst_d3d11_decoder_open (self->d3d11_decoder, GST_D3D11_CODEC_VP9,
|
if (!gst_d3d11_decoder_open (self->d3d11_decoder, GST_D3D11_CODEC_VP9,
|
||||||
&info, NUM_OUTPUT_VIEW, &profile_guid, 1)) {
|
&info, self->width, self->height,
|
||||||
|
NUM_OUTPUT_VIEW, &profile_guid, 1)) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to create decoder");
|
GST_ERROR_OBJECT (self, "Failed to create decoder");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1217,7 +1218,7 @@ gst_d3d11_vp9_dec_register (GstPlugin * plugin, GstD3D11Device * device,
|
||||||
gst_video_info_set_format (&info, GST_VIDEO_FORMAT_NV12, 1280, 720);
|
gst_video_info_set_format (&info, GST_VIDEO_FORMAT_NV12, 1280, 720);
|
||||||
|
|
||||||
ret = gst_d3d11_decoder_open (decoder, GST_D3D11_CODEC_VP9,
|
ret = gst_d3d11_decoder_open (decoder, GST_D3D11_CODEC_VP9,
|
||||||
&info, NUM_OUTPUT_VIEW, supported_profiles,
|
&info, 1280, 720, NUM_OUTPUT_VIEW, supported_profiles,
|
||||||
G_N_ELEMENTS (supported_profiles));
|
G_N_ELEMENTS (supported_profiles));
|
||||||
gst_object_unref (decoder);
|
gst_object_unref (decoder);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue