GstImxIpuBlitter* gst_imx_ipu_blitter_new(void) { GstAllocator *allocator; GstImxIpuBlitter *ipu_blitter; allocator = gst_imx_ipu_allocator_new(); if (allocator == NULL) return NULL; ipu_blitter = (GstImxIpuBlitter *)g_object_new(gst_imx_ipu_blitter_get_type(), NULL); ipu_blitter->allocator = gst_object_ref_sink(allocator); if (!gst_imx_ipu_blitter_allocate_internal_fill_frame(ipu_blitter)) { gst_object_unref(GST_OBJECT(ipu_blitter)); return NULL; } return ipu_blitter; }
GstBufferPool* gst_imx_ipu_blitter_create_bufferpool(GstImxIpuBlitter *ipu_blitter, GstCaps *caps, guint size, guint min_buffers, guint max_buffers, GstAllocator *allocator, GstAllocationParams *alloc_params) { GstBufferPool *pool; GstStructure *config; pool = gst_imx_phys_mem_buffer_pool_new(FALSE); config = gst_buffer_pool_get_config(pool); gst_buffer_pool_config_set_params(config, caps, size, min_buffers, max_buffers); /* If the allocator value is NULL, create an allocator */ if (allocator == NULL) { allocator = gst_imx_ipu_allocator_new(ipu_blitter->priv->ipu_fd); gst_buffer_pool_config_set_allocator(config, allocator, alloc_params); } gst_buffer_pool_config_add_option(config, GST_BUFFER_POOL_OPTION_IMX_PHYS_MEM); gst_buffer_pool_config_add_option(config, GST_BUFFER_POOL_OPTION_VIDEO_META); gst_buffer_pool_set_config(pool, config); return pool; }
void gst_imx_ipu_blitter_init(GstImxIpuBlitter *ipu_blitter) { ipu_blitter->previous_frame = NULL; ipu_blitter->allocator = NULL; ipu_blitter->dummy_black_buffer = NULL; ipu_blitter->output_region_uptodate = FALSE; ipu_blitter->priv = g_slice_alloc(sizeof(GstImxIpuBlitterPrivate)); memset(&(ipu_blitter->priv->task), 0, sizeof(struct ipu_task)); if (!gst_imx_ipu_open()) { GST_ELEMENT_ERROR(ipu_blitter, RESOURCE, OPEN_READ_WRITE, ("could not open IPU device"), (NULL)); return; } ipu_blitter->allocator = gst_imx_ipu_allocator_new(); gst_imx_ipu_blitter_init_dummy_black_buffer(ipu_blitter); GST_INFO_OBJECT(ipu_blitter, "initialized blitter"); }