d3d11memory: Add a method to specify padding space

This commit is contained in:
Seungha Yang 2020-02-03 21:55:55 +09:00 committed by GStreamer Merge Bot
parent f852ce01e4
commit 2f32f30b62
3 changed files with 43 additions and 2 deletions

View file

@ -255,6 +255,7 @@ gst_d3d11_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
GstBuffer *buf;
GstD3D11AllocationParams *d3d11_params = priv->d3d11_params;
GstVideoInfo *info = &d3d11_params->info;
GstVideoInfo *aligned_info = &d3d11_params->aligned_info;
gint n_texture = 0;
gint i;
gsize offset[GST_VIDEO_MAX_PLANES] = { 0, };
@ -292,7 +293,7 @@ gst_d3d11_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
/* calculate offset */
for (i = 0; i < n_texture && i < GST_VIDEO_MAX_PLANES - 1; i++) {
offset[i + 1] = offset[i] +
d3d11_params->stride[i] * GST_VIDEO_INFO_COMP_HEIGHT (info, i);
d3d11_params->stride[i] * GST_VIDEO_INFO_COMP_HEIGHT (aligned_info, i);
}
if (priv->add_videometa) {

View file

@ -49,6 +49,7 @@ gst_d3d11_allocation_params_new (GstD3D11Device * device, GstVideoInfo * info,
ret = g_new0 (GstD3D11AllocationParams, 1);
ret->info = *info;
ret->aligned_info = *info;
ret->d3d11_format = d3d11_format;
/* Usage Flag
@ -96,6 +97,41 @@ gst_d3d11_allocation_params_new (GstD3D11Device * device, GstVideoInfo * info,
return ret;
}
gboolean
gst_d3d11_allocation_params_alignment (GstD3D11AllocationParams * params,
GstVideoAlignment * align)
{
gint i;
guint padding_width, padding_height;
GstVideoInfo *info;
GstVideoInfo new_info;
g_return_val_if_fail (params != NULL, FALSE);
g_return_val_if_fail (align != NULL, FALSE);
/* d3d11 does not support stride align. Consider padding only */
padding_width = align->padding_left + align->padding_right;
padding_height = align->padding_top + align->padding_bottom;
info = &params->info;
if (!gst_video_info_set_format (&new_info, GST_VIDEO_INFO_FORMAT (info),
GST_VIDEO_INFO_WIDTH (info) + padding_width,
GST_VIDEO_INFO_HEIGHT (info) + padding_height)) {
GST_WARNING ("Set format fail");
return FALSE;
}
params->aligned_info = new_info;
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (info); i++) {
params->desc[i].Width = GST_VIDEO_INFO_COMP_WIDTH (&new_info, i);
params->desc[i].Height = GST_VIDEO_INFO_COMP_HEIGHT (&new_info, i);
}
return TRUE;
}
GstD3D11AllocationParams *
gst_d3d11_allocation_params_copy (GstD3D11AllocationParams * src)
{

View file

@ -81,6 +81,7 @@ struct _GstD3D11AllocationParams
D3D11_TEXTURE2D_DESC desc[GST_VIDEO_MAX_PLANES];
GstVideoInfo info;
GstVideoInfo aligned_info;
const GstD3D11Format *d3d11_format;
/* size and stride of staging texture, set by allocator */
@ -162,7 +163,10 @@ GstD3D11AllocationParams * gst_d3d11_allocation_params_new (GstD3D11Device * dev
GstD3D11AllocationParams * gst_d3d11_allocation_params_copy (GstD3D11AllocationParams * src);
void gst_d3d11_allocation_params_free (GstD3D11AllocationParams * parms);
void gst_d3d11_allocation_params_free (GstD3D11AllocationParams * params);
gboolean gst_d3d11_allocation_params_alignment (GstD3D11AllocationParams * parms,
GstVideoAlignment * align);
GType gst_d3d11_allocator_get_type (void);