diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11_private.h b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11_private.h index 872b1698e3..3aff9c8598 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11_private.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11_private.h @@ -41,6 +41,16 @@ void gst_d3d11_device_dxgi_debug (GstD3D11Device * device, const gchar * function, gint line); +/* Memory allocated by this method does not hold correct size. + * So this is private method and only plugins in -bad are expected to call + * this method */ +GST_D3D11_API +GstMemory * gst_d3d11_allocator_alloc_wrapped_native_size (GstD3D11Allocator * allocator, + GstD3D11Device * device, + ID3D11Texture2D * texture, + gpointer user_data, + GDestroyNotify notify); + #define GST_D3D11_CLEAR_COM(obj) G_STMT_START { \ if (obj) { \ (obj)->Release (); \ diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.cpp index 9e992f22de..8a1ceb90ef 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.cpp @@ -1692,6 +1692,46 @@ gst_d3d11_allocator_alloc_wrapped (GstD3D11Allocator * allocator, return mem; } +GstMemory * +gst_d3d11_allocator_alloc_wrapped_native_size (GstD3D11Allocator * allocator, + GstD3D11Device * device, ID3D11Texture2D * texture, gpointer user_data, + GDestroyNotify notify) +{ + GstMemory *mem; + GstD3D11Memory *dmem; + D3D11_TEXTURE2D_DESC desc = { 0, }; + ID3D11Texture2D *tex = nullptr; + HRESULT hr; + gsize size; + + g_return_val_if_fail (GST_IS_D3D11_ALLOCATOR (allocator), nullptr); + g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), nullptr); + g_return_val_if_fail (texture != nullptr, nullptr); + + hr = texture->QueryInterface (IID_PPV_ARGS (&tex)); + if (FAILED (hr)) { + GST_WARNING_OBJECT (allocator, "Not a valid texture handle"); + return nullptr; + } + + tex->GetDesc (&desc); + mem = gst_d3d11_allocator_alloc_internal (allocator, device, &desc, tex); + + if (!mem) + return nullptr; + + /* XXX: This is not correct memory size */ + size = desc.Width * desc.Height; + mem->maxsize = mem->size = size; + + dmem = GST_D3D11_MEMORY_CAST (mem); + + dmem->priv->user_data = user_data; + dmem->priv->notify = notify; + + return mem; +} + /** * gst_d3d11_allocator_set_active: * @allocator: a #GstD3D11Allocator