{
GstD3D11Memory *dmem;
GstD3D11Device *device;
- GstD3D11Allocator *alloc = NULL;
GstBuffer *staging_buffer = NULL;
gint stride[GST_VIDEO_MAX_PLANES] = { 0, };
gsize offset[GST_VIDEO_MAX_PLANES] = { 0, };
return NULL;
}
- alloc = (GstD3D11Allocator *) gst_allocator_find (GST_D3D11_MEMORY_NAME);
- if (!alloc) {
- GST_ERROR ("D3D11 allocator is not available");
- return NULL;
- }
-
staging_buffer = gst_buffer_new ();
for (i = 0; i < gst_buffer_n_memory (buffer); i++) {
D3D11_TEXTURE2D_DESC staging_desc;
fill_staging_desc (&desc, &staging_desc);
new_mem = (GstD3D11Memory *)
- gst_d3d11_allocator_alloc (alloc, mem->device, &staging_desc);
+ gst_d3d11_allocator_alloc (nullptr, mem->device, &staging_desc);
if (!new_mem) {
GST_ERROR ("Failed to allocate memory");
goto error;
GST_VIDEO_INFO_HEIGHT (info), GST_VIDEO_INFO_N_PLANES (info),
offset, stride);
- if (alloc)
- gst_object_unref (alloc);
-
return staging_buffer;
error:
gst_clear_buffer (&staging_buffer);
- gst_clear_object (&alloc);
return NULL;
}
gst_clear_buffer (&self->cached_buffer);
gst_clear_object (&self->device);
- gst_clear_object (&self->allocator);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
size *= 4;
}
- mem = gst_d3d11_allocator_alloc_wrapped (self->allocator,
+ mem = gst_d3d11_allocator_alloc_wrapped (nullptr,
self->device, backbuffer.Get (), size, nullptr, nullptr);
if (!mem) {
GST_ERROR_OBJECT (self, "Couldn't allocate wrapped memory");
const gchar *cll_str = nullptr;
const gchar *mdcv_str = nullptr;
- if (!window->allocator) {
- window->allocator =
- (GstD3D11Allocator *) gst_allocator_find (GST_D3D11_MEMORY_NAME);
- if (!window->allocator) {
- GST_ERROR_OBJECT (window, "Allocator is unavailable");
- if (config)
- gst_structure_free (config);
-
- return FALSE;
- }
- }
-
/* Step 1: Clear old resources and objects */
gst_clear_buffer (&window->cached_buffer);
gst_clear_object (&window->compositor);
/*< protected >*/
gboolean initialized;
GstD3D11Device *device;
- GstD3D11Allocator *allocator;
guintptr external_handle;
/* properties */
guint display_width, guint display_height, GstCaps * caps,
GstStructure * config, GError ** error)
{
- if (!window->allocator) {
- window->allocator =
- (GstD3D11Allocator *) gst_allocator_find (GST_D3D11_MEMORY_NAME);
- if (!window->allocator) {
- GST_ERROR_OBJECT (window, "Allocator is unavailable");
- if (config)
- gst_structure_free (config);
-
- return FALSE;
- }
- }
-
gst_clear_object (&window->compositor);
gst_clear_object (&window->converter);
}
}
- mem = gst_d3d11_allocator_alloc_wrapped (window->allocator,
+ mem = gst_d3d11_allocator_alloc_wrapped (nullptr,
device, texture.Get (), desc.Width * desc.Height * 4, nullptr, nullptr);
if (!mem) {
GST_ERROR_OBJECT (window, "Couldn't allocate memory");
}
if (request->Info.FourCC == MFX_FOURCC_P8) {
- GstD3D11Allocator *d3d11_alloc = nullptr;
D3D11_BUFFER_DESC desc;
GstVideoInfo info;
GstMemory *mem;
gint stride[GST_VIDEO_MAX_PLANES] = { 0, };
guint size;
- d3d11_alloc =
- (GstD3D11Allocator *) gst_allocator_find (GST_D3D11_MEMORY_NAME);
- if (!d3d11_alloc) {
- GST_ERROR_OBJECT (self, "D3D11 allocator is unavailable");
-
- return MFX_ERR_MEMORY_ALLOC;
- }
-
memset (&desc, 0, sizeof (D3D11_BUFFER_DESC));
desc.ByteWidth = request->Info.Width * request->Info.Height;
desc.Usage = D3D11_USAGE_STAGING;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
- mem = gst_d3d11_allocator_alloc_buffer (d3d11_alloc, self->device, &desc);
- gst_object_unref (d3d11_alloc);
-
+ mem = gst_d3d11_allocator_alloc_buffer (nullptr, self->device, &desc);
if (!mem) {
GST_ERROR_OBJECT (self, "Failed to allocate buffer");
return MFX_ERR_MEMORY_ALLOC;
GMainLoop *loop;
GstElement *pipeline;
GstD3D11Device *d3d11_device;
- GstD3D11Allocator *d3d11_allocator;
ID3D11Device *device;
ID3D11DeviceContext *context;
backbuffer->GetDesc (&desc);
- mem = gst_d3d11_allocator_alloc_wrapped (app_data->d3d11_allocator,
+ mem = gst_d3d11_allocator_alloc_wrapped (nullptr,
app_data->d3d11_device, backbuffer.Get (),
/* This might not be correct CPU accessible (staging) texture size
* but it's fine since we don't use this memory for CPU access */
exit (1);
}
- /* Gets d3d11 memory allocator which will be used to wrap swapchain
- * backbuffer */
- app_data.d3d11_allocator = (GstD3D11Allocator *)
- gst_allocator_find (GST_D3D11_MEMORY_NAME);
- if (!app_data.d3d11_allocator) {
- gst_printerrln ("D3D11 allocator is unavailable");
- exit (1);
- }
-
/* Creates window and swapchain */
app_data.hwnd = create_window ();
if (!app_data.hwnd) {
if (app_data.hwnd)
DestroyWindow (app_data.hwnd);
- gst_clear_object (&app_data.d3d11_allocator);
gst_clear_object (&app_data.d3d11_device);
gst_clear_object (&app_data.pipeline);
ComPtr < ID3D11RenderTargetView > rtv;
FLOAT clear_color[4] = { 1.0, 1.0, 1.0, 1.0 };
GstMemory *mem;
- GstD3D11Allocator *allocator;
GstD3D11Memory *dmem;
MemoryUserData *memory_data;
GstBuffer *buffer;
app_data->context->ClearRenderTargetView (rtv.Get (), clear_color);
gst_d3d11_device_unlock (app_data->d3d11_device);
- /* Find global default D3D11 allocator */
- allocator = (GstD3D11Allocator *) gst_allocator_find (GST_D3D11_MEMORY_NAME);
- if (!allocator) {
- gst_printerrln ("D3D11 allocator is unavailable");
- exit (1);
- }
-
/* Demonstrating application-side texture pool.
* GstD3D11BufferPool can be used instead */
memory_data = g_new0 (MemoryUserData, 1);
/* gst_d3d11_allocator_alloc_wrapped() method does not take ownership of
* ID3D11Texture2D object, but in this example, we pass ownership via
* user data */
- mem = gst_d3d11_allocator_alloc_wrapped (allocator, app_data->d3d11_device,
+ mem = gst_d3d11_allocator_alloc_wrapped (nullptr, app_data->d3d11_device,
texture, app_data->mem_size, memory_data,
(GDestroyNotify) on_memory_freed);
- gst_object_unref (allocator);
if (!mem) {
gst_printerrln ("Couldn't allocate memory");