static gboolean
gst_gl_overlay_load_jpeg (GstGLOverlay * overlay, FILE * fp)
{
+ GstGLBaseMemoryAllocator *mem_allocator;
+ GstGLVideoAllocationParams *params;
GstVideoInfo v_info;
GstVideoAlignment v_align;
GstMapInfo map_info;
v_align.stride_align[0] = 32 - 1;
gst_video_info_align (&v_info, &v_align);
+ mem_allocator =
+ GST_GL_BASE_MEMORY_ALLOCATOR (gst_allocator_find
+ (GST_GL_MEMORY_PBO_ALLOCATOR_NAME));
+ params =
+ gst_gl_video_allocation_params_new (GST_GL_BASE_FILTER (overlay)->context,
+ NULL, &v_info, 0, &v_align, GST_GL_TEXTURE_TARGET_2D);
overlay->image_memory = (GstGLMemory *)
- gst_gl_memory_pbo_alloc (GST_GL_BASE_FILTER (overlay)->context,
- GST_GL_TEXTURE_TARGET_2D, NULL, &v_info, 0, &v_align);
+ gst_gl_base_memory_alloc (mem_allocator,
+ (GstGLAllocationParams *) params);
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
+ gst_object_unref (mem_allocator);
if (!gst_memory_map ((GstMemory *) overlay->image_memory, &map_info,
GST_MAP_WRITE)) {
static gboolean
gst_gl_overlay_load_png (GstGLOverlay * overlay, FILE * fp)
{
+ GstGLBaseMemoryAllocator *mem_allocator;
+ GstGLVideoAllocationParams *params;
GstVideoInfo v_info;
GstMapInfo map_info;
overlay->image_height = height;
gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, width, height);
+ mem_allocator =
+ GST_GL_BASE_MEMORY_ALLOCATOR (gst_allocator_find
+ (GST_GL_MEMORY_PBO_ALLOCATOR_NAME));
+ params =
+ gst_gl_video_allocation_params_new (GST_GL_BASE_FILTER (overlay)->context,
+ NULL, &v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D);
overlay->image_memory = (GstGLMemory *)
- gst_gl_memory_pbo_alloc (GST_GL_BASE_FILTER (overlay)->context,
- GST_GL_TEXTURE_TARGET_2D, NULL, &v_info, 0, NULL);
+ gst_gl_base_memory_alloc (mem_allocator,
+ (GstGLAllocationParams *) params);
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
+ gst_object_unref (mem_allocator);
if (!gst_memory_map ((GstMemory *) overlay->image_memory, &map_info,
GST_MAP_WRITE)) {
/* Luminance formats are not color renderable */
/* renderering to a framebuffer only renders the intersection of all
* the attachments i.e. the smallest attachment size */
- GstVideoInfo temp_info;
+ if (!convert->priv->out_tex[j]) {
+ GstGLVideoAllocationParams *params;
+ GstGLBaseMemoryAllocator *base_mem_allocator;
+ GstAllocator *allocator;
+ GstVideoInfo temp_info;
- gst_video_info_set_format (&temp_info, GST_VIDEO_FORMAT_RGBA, out_width,
- out_height);
+ gst_video_info_set_format (&temp_info, GST_VIDEO_FORMAT_RGBA, out_width,
+ out_height);
+
+ allocator = gst_allocator_find (GST_GL_MEMORY_ALLOCATOR_NAME);
+ base_mem_allocator = GST_GL_BASE_MEMORY_ALLOCATOR (allocator);
+ params = gst_gl_video_allocation_params_new (context, NULL, &temp_info,
+ 0, NULL, convert->priv->to_texture_target);
- if (!convert->priv->out_tex[j])
convert->priv->out_tex[j] =
- (GstGLMemory *) gst_gl_memory_pbo_alloc (context,
- convert->priv->to_texture_target, NULL, &temp_info, 0, NULL);
+ (GstGLMemory *) gst_gl_base_memory_alloc (base_mem_allocator,
+ (GstGLAllocationParams *) params);
+
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
+ gst_object_unref (allocator);
+ }
} else {
convert->priv->out_tex[j] = out_tex;
}
gint views, v;
GstVideoOverlayCompositionMeta *composition_meta;
GstGLSyncMeta *sync_meta;
+ GstGLVideoAllocationParams *params;
+ GstGLMemoryAllocator *mem_allocator;
+ GstAllocator *allocator;
convert->outbuf = NULL;
gst_gl_sync_meta_wait (sync_meta, convert->context);
convert->outbuf = gst_buffer_new ();
- if (!gst_gl_memory_pbo_setup_buffer (convert->context,
- convert->priv->to_texture_target, NULL, &convert->out_info, NULL,
- convert->outbuf)) {
+
+ allocator = gst_allocator_find (GST_GL_MEMORY_ALLOCATOR_NAME);
+ mem_allocator = GST_GL_MEMORY_ALLOCATOR (allocator);
+ params =
+ gst_gl_video_allocation_params_new (context, NULL, &convert->out_info, 0,
+ NULL, convert->priv->to_texture_target);
+
+ if (!gst_gl_memory_setup_buffer (mem_allocator, convert->outbuf, params)) {
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
+ gst_object_unref (allocator);
convert->priv->result = FALSE;
return;
}
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
+ gst_object_unref (allocator);
if (GST_VIDEO_INFO_MULTIVIEW_MODE (in_info) ==
GST_VIDEO_MULTIVIEW_MODE_SEPARATED)
return copy_params.result;
}
-/**
- * gst_gl_memory_pbo_wrapped_texture:
- * @context: a #GstGLContext
- * @texture_id: the GL texture handle
- * @texture_target: the GL texture target
- * @info: the #GstVideoInfo of the memory
- * @plane: The plane this memory will represent
- * @user_data: user data
- * @notify: Destroy callback for the user data
- *
- * Wraps a texture handle into a #GstGLMemoryPBO.
- *
- * Returns: a newly allocated #GstGLMemoryPBO
- */
-GstGLMemoryPBO *
-gst_gl_memory_pbo_wrapped_texture (GstGLContext * context,
- guint texture_id, GstGLTextureTarget target,
- GstVideoInfo * info, guint plane, GstVideoAlignment * valign,
- gpointer user_data, GDestroyNotify notify)
-{
- GstGLMemoryPBO *mem;
-
- mem = g_slice_new0 (GstGLMemoryPBO);
-
- mem->mem.tex_id = texture_id;
- mem->mem.texture_wrapped = TRUE;
-
- _gl_mem_init (mem, _gl_allocator, NULL, context, target, NULL, info, valign,
- plane, user_data, notify);
-
- GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD);
-
- return mem;
-}
-
-/**
- * gst_gl_memory_pbo_alloc:
- * @context:a #GstGLContext
- * @params: a #GstAllocationParams
- * @info: the #GstVideoInfo of the memory
- * @plane: the plane this memory will represent
- * @valign: the #GstVideoAlignment applied to @info
- *
- * Allocated a new #GstGlMemory.
- *
- * Returns: a #GstMemory object with a GL texture specified by @vinfo
- * from @context
- */
-GstMemory *
-gst_gl_memory_pbo_alloc (GstGLContext * context, GstGLTextureTarget target,
- GstAllocationParams * params, GstVideoInfo * info, guint plane,
- GstVideoAlignment * valign)
-{
- GstGLMemoryPBO *mem;
-
- mem =
- _gl_mem_new (_gl_allocator, NULL, context, target, params, info, valign,
- plane, NULL, NULL);
-
- return (GstMemory *) mem;
-}
-
-/**
- * gst_gl_memory_pbo_wrapped:
- * @context:a #GstGLContext
- * @info: the #GstVideoInfo of the memory and data
- * @plane: the plane this memory will represent
- * @valign: the #GstVideoAlignment applied to @info
- * @data: the data to wrap
- * @user_data: data called with for @notify
- * @notify: function called with @user_data when @data needs to be freed
- *
- * Wrapped @data into a #GstGLMemoryPBO. This version will account for padding
- * added to the allocation and expressed through @valign.
- *
- * Returns: a #GstGLMemoryPBO object with a GL texture specified by @v_info
- * from @context and contents specified by @data
- */
-GstGLMemoryPBO *
-gst_gl_memory_pbo_wrapped (GstGLContext * context, GstGLTextureTarget target,
- GstVideoInfo * info, guint plane, GstVideoAlignment * valign, gpointer data,
- gpointer user_data, GDestroyNotify notify)
-{
- GstGLMemoryPBO *mem;
-
- mem = _gl_mem_new (_gl_allocator, NULL, context, target, NULL, info, valign,
- plane, user_data, notify);
- if (!mem)
- return NULL;
-
- mem->pbo->mem.data = data;
-
- GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD);
- if (mem->pbo)
- GST_MINI_OBJECT_FLAG_SET (mem->pbo,
- GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD);
-
- return mem;
-}
-
static void
_download_transfer (GstGLContext * context, GstGLMemoryPBO * gl_mem)
{
&& g_type_is_a (G_OBJECT_TYPE (mem->allocator),
GST_TYPE_GL_MEMORY_PBO_ALLOCATOR);
}
-
-/**
- * gst_gl_memory_pbo_setup_buffer:
- * @context: a #GstGLContext
- * @params: a #GstAllocationParams
- * @info: a #GstVideoInfo
- * @valign: the #GstVideoAlignment applied to @info
- * @buffer: a #GstBuffer
- *
- * Adds the required #GstGLMemoryPBO<!-- -->s with the correct configuration to
- * @buffer based on @info. This version handles padding through @valign.
- *
- * Returns: whether the memory's were sucessfully added.
- */
-gboolean
-gst_gl_memory_pbo_setup_buffer (GstGLContext * context,
- GstGLTextureTarget target, GstAllocationParams * params,
- GstVideoInfo * info, GstVideoAlignment * valign, GstBuffer * buffer)
-{
- GstGLMemoryPBO *gl_mem[GST_VIDEO_MAX_PLANES] = { NULL, };
- guint n_mem, i, v, views;
-
- n_mem = GST_VIDEO_INFO_N_PLANES (info);
-
- if (GST_VIDEO_INFO_MULTIVIEW_MODE (info) ==
- GST_VIDEO_MULTIVIEW_MODE_SEPARATED)
- views = info->views;
- else
- views = 1;
-
- for (v = 0; v < views; v++) {
- for (i = 0; i < n_mem; i++) {
- gl_mem[i] =
- (GstGLMemoryPBO *) gst_gl_memory_pbo_alloc (context, target, params,
- info, i, valign);
- if (gl_mem[i] == NULL)
- return FALSE;
-
- gst_buffer_append_memory (buffer, (GstMemory *) gl_mem[i]);
- }
-
- gst_buffer_add_video_meta_full (buffer, v,
- GST_VIDEO_INFO_FORMAT (info), GST_VIDEO_INFO_WIDTH (info),
- GST_VIDEO_INFO_HEIGHT (info), n_mem, info->offset, info->stride);
- }
-
- return TRUE;
-}
-
-/**
- * gst_gl_memory_pbo_setup_wrapped:
- * @context: a #GstGLContext
- * @info: a #GstVideoInfo
- * @valign: a #GstVideoInfo
- * @data: a list of per plane data pointers
- * @textures: (transfer out): a list of #GstGLMemoryPBO
- * @user_data: user data for the destroy function
- * @notify: A function called each time a memory is freed
- *
- * Wraps per plane data pointer in @data into the corresponding entry in
- * @textures based on @info and padding from @valign. Note that the @notify
- * will be called as many time as there is planes.
- *
- * Returns: whether the memory's were sucessfully created.
- */
-gboolean
-gst_gl_memory_pbo_setup_wrapped (GstGLContext * context,
- GstGLTextureTarget target, GstVideoInfo * info, GstVideoAlignment * valign,
- gpointer data[GST_VIDEO_MAX_PLANES],
- GstGLMemoryPBO * textures[GST_VIDEO_MAX_PLANES], gpointer user_data,
- GDestroyNotify notify)
-{
- gint i;
-
- for (i = 0; i < GST_VIDEO_INFO_N_PLANES (info); i++) {
- textures[i] =
- (GstGLMemoryPBO *) gst_gl_memory_pbo_wrapped (context, target, info, i,
- valign, data[i], user_data, notify);
- }
-
- return TRUE;
-}
void gst_gl_memory_pbo_init_once (void);
gboolean gst_is_gl_memory_pbo (GstMemory * mem);
-GstMemory * gst_gl_memory_pbo_alloc (GstGLContext * context,
- GstGLTextureTarget target,
- GstAllocationParams *params,
- GstVideoInfo * info,
- guint plane,
- GstVideoAlignment *valign);
-GstGLMemoryPBO * gst_gl_memory_pbo_wrapped (GstGLContext * context,
- GstGLTextureTarget target,
- GstVideoInfo * info,
- guint plane,
- GstVideoAlignment *valign,
- gpointer data,
- gpointer user_data,
- GDestroyNotify notify);
-GstGLMemoryPBO * gst_gl_memory_pbo_wrapped_texture (GstGLContext * context,
- guint texture_id,
- GstGLTextureTarget target,
- GstVideoInfo * info,
- guint plane,
- GstVideoAlignment *valign,
- gpointer user_data,
- GDestroyNotify notify);
-
void gst_gl_memory_pbo_download_transfer (GstGLMemoryPBO * gl_mem);
void gst_gl_memory_pbo_upload_transfer (GstGLMemoryPBO * gl_mem);
gint stride,
gboolean respecify);
-gboolean gst_gl_memory_pbo_setup_buffer (GstGLContext * context,
- GstGLTextureTarget target,
- GstAllocationParams * params,
- GstVideoInfo * info,
- GstVideoAlignment *valign,
- GstBuffer * buffer);
-gboolean gst_gl_memory_pbo_setup_wrapped (GstGLContext * context,
- GstGLTextureTarget target,
- GstVideoInfo * info,
- GstVideoAlignment *valign,
- gpointer data[GST_VIDEO_MAX_PLANES],
- GstGLMemoryPBO *textures[GST_VIDEO_MAX_PLANES],
- gpointer user_data,
- GDestroyNotify notify);
-
/**
* GstGLAllocator
*
vinfo.stride[0] = vmeta->stride[0];
if (gst_video_frame_map (comp_frame, &vinfo, comp_buffer, GST_MAP_READ)) {
+ GstGLVideoAllocationParams *params;
+ GstGLBaseMemoryAllocator *mem_allocator;
+ GstAllocator *allocator;
+
+ allocator = gst_allocator_find (GST_GL_MEMORY_PBO_ALLOCATOR_NAME);
+ mem_allocator = GST_GL_BASE_MEMORY_ALLOCATOR (allocator);
+
gst_gl_composition_overlay_add_transformation (overlay, buf);
+ params = gst_gl_video_allocation_params_new_wrapped_data (overlay->context,
+ NULL, &comp_frame->info, 0, NULL, GST_GL_TEXTURE_TARGET_2D,
+ comp_frame->data[0], _video_frame_unmap_and_free, comp_frame);
+
comp_gl_memory =
- (GstGLMemory *) gst_gl_memory_pbo_wrapped (overlay->context,
- GST_GL_TEXTURE_TARGET_2D, &comp_frame->info, 0, NULL,
- comp_frame->data[0], comp_frame, _video_frame_unmap_and_free);
+ (GstGLMemory *) gst_gl_base_memory_alloc (mem_allocator,
+ (GstGLAllocationParams *) params);
+
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
+ gst_object_unref (allocator);
overlay_buffer = gst_buffer_new ();
gst_buffer_append_memory (overlay_buffer, (GstMemory *) comp_gl_memory);
GstGLUpload *upload;
GstBuffer *buffer;
GstBuffer **outbuf;
+ GstGLVideoAllocationParams *params;
};
static gpointer
if (!ret)
return FALSE;
+ if (image->params)
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) image->params);
+ if (!(image->params =
+ gst_gl_video_allocation_params_new (image->upload->context, NULL,
+ &image->upload->priv->in_info, -1, NULL,
+ GST_GL_TEXTURE_TARGET_2D)))
+ return FALSE;
+
if (buffer) {
GstVideoInfo *in_info = &image->upload->priv->in_info;
guint expected_memories = GST_VIDEO_INFO_N_PLANES (in_info);
_egl_image_upload_perform_gl_thread (GstGLContext * context,
struct EGLImageUpload *image)
{
+ GstGLMemoryAllocator *allocator;
guint i, n;
+ allocator =
+ GST_GL_MEMORY_ALLOCATOR (gst_allocator_find
+ (GST_GL_MEMORY_PBO_ALLOCATOR_NAME));
+
/* FIXME: buffer pool */
*image->outbuf = gst_buffer_new ();
- gst_gl_memory_pbo_setup_buffer (image->upload->context,
- GST_GL_TEXTURE_TARGET_2D, NULL, &image->upload->priv->out_info, NULL,
- *image->outbuf);
+ gst_gl_memory_setup_buffer (allocator, *image->outbuf, image->params);
+ gst_object_unref (allocator);
n = gst_buffer_n_memory (image->buffer);
for (i = 0; i < n; i++) {
}
if (GST_IS_GL_BUFFER_POOL (image->buffer->pool))
- gst_gl_buffer_pool_replace_last_buffer (GST_GL_BUFFER_POOL (image->
- buffer->pool), image->buffer);
+ gst_gl_buffer_pool_replace_last_buffer (GST_GL_BUFFER_POOL (image->buffer->
+ pool), image->buffer);
}
static GstGLUploadReturn
static void
_egl_image_upload_free (gpointer impl)
{
+ struct EGLImageUpload *image = impl;
+
+ if (image->params)
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) image->params);
+
g_free (impl);
}
gboolean result;
GstVideoGLTextureUploadMeta *meta;
guint texture_ids[GST_GL_UPLOAD_MAX_PLANES];
+ GstGLVideoAllocationParams *params;
};
static gpointer
if (!ret)
return ret;
+ if (upload->params)
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) upload->params);
+ if (!(upload->params =
+ gst_gl_video_allocation_params_new (upload->upload->context, NULL,
+ &upload->upload->priv->in_info, -1, NULL,
+ GST_GL_TEXTURE_TARGET_2D)))
+ return FALSE;
+
if (buffer) {
if ((meta = gst_buffer_get_video_gl_texture_upload_meta (buffer)) == NULL)
return FALSE;
gpointer handle;
gl_apis =
- gst_gl_api_to_string (gst_gl_context_get_gl_api (upload->upload->
- context));
- platform =
- gst_gl_platform_to_string (gst_gl_context_get_gl_platform (upload->
+ gst_gl_api_to_string (gst_gl_context_get_gl_api (upload->
upload->context));
+ platform =
+ gst_gl_platform_to_string (gst_gl_context_get_gl_platform
+ (upload->upload->context));
handle = (gpointer) gst_gl_context_get_gl_context (upload->upload->context);
gl_context =
int i;
GstVideoInfo *in_info = &upload->upload->priv->in_info;
guint max_planes = GST_VIDEO_INFO_N_PLANES (in_info);
+ GstGLMemoryAllocator *allocator;
+
+ allocator =
+ GST_GL_MEMORY_ALLOCATOR (gst_allocator_find
+ (GST_GL_MEMORY_PBO_ALLOCATOR_NAME));
/* Support stereo views for separated multiview mode */
if (GST_VIDEO_INFO_MULTIVIEW_MODE (in_info) ==
/* FIXME: buffer pool */
*outbuf = gst_buffer_new ();
- gst_gl_memory_pbo_setup_buffer (upload->upload->context,
- GST_GL_TEXTURE_TARGET_2D, NULL, &upload->upload->priv->in_info, NULL,
- *outbuf);
+ gst_gl_memory_setup_buffer (allocator, *outbuf, upload->params);
+ gst_object_unref (allocator);
for (i = 0; i < GST_GL_UPLOAD_MAX_PLANES; i++) {
guint tex_id = 0;
gst_gl_context_del_texture (upload->upload->context,
&upload->texture_ids[i]);
}
+
+ if (upload->params)
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) upload->params);
+
g_free (upload);
}
{
GstGLUpload *upload;
struct RawUploadFrame *in_frame;
+ GstGLVideoAllocationParams *params;
};
static struct RawUploadFrame *
_raw_upload_frame_unref (raw->in_frame);
raw->in_frame = _raw_upload_frame_new (raw, buffer);
+ if (raw->params)
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) raw->params);
+ if (!(raw->params =
+ gst_gl_video_allocation_params_new_wrapped_data (raw->upload->context,
+ NULL, &raw->upload->priv->in_info, -1, NULL,
+ GST_GL_TEXTURE_TARGET_2D, NULL,
+ (GDestroyNotify) _raw_upload_frame_unref, raw->in_frame)))
+ return FALSE;
+
return (raw->in_frame != NULL);
}
_raw_data_upload_perform (gpointer impl, GstBuffer * buffer,
GstBuffer ** outbuf)
{
- GstGLMemory *in_tex[GST_GL_UPLOAD_MAX_PLANES] = { 0, };
+ GstGLBaseMemoryAllocator *allocator;
struct RawUpload *raw = impl;
int i;
GstVideoInfo *in_info = &raw->upload->priv->in_info;
- guint max_planes = GST_VIDEO_INFO_N_PLANES (in_info);
-
- /* Support stereo views for separated multiview mode */
- if (GST_VIDEO_INFO_MULTIVIEW_MODE (in_info) ==
- GST_VIDEO_MULTIVIEW_MODE_SEPARATED)
- max_planes *= GST_VIDEO_INFO_VIEWS (in_info);
+ guint n_mem = GST_VIDEO_INFO_N_PLANES (in_info);
- gst_gl_memory_pbo_setup_wrapped (raw->upload->context,
- GST_GL_TEXTURE_TARGET_2D, &raw->upload->priv->in_info, NULL,
- raw->in_frame->frame.data, (GstGLMemoryPBO **) in_tex, raw->in_frame,
- (GDestroyNotify) _raw_upload_frame_unref);
+ allocator =
+ GST_GL_BASE_MEMORY_ALLOCATOR (gst_allocator_find
+ (GST_GL_MEMORY_PBO_ALLOCATOR_NAME));
/* FIXME Use a buffer pool to cache the generated textures */
+ /* FIXME: multiview support with separated left/right frames? */
*outbuf = gst_buffer_new ();
- for (i = 0; i < max_planes; i++) {
+ for (i = 0; i < n_mem; i++) {
+ GstGLBaseMemory *tex;
+
+ raw->params->parent.wrapped_data = raw->in_frame->frame.data[i];
+ raw->params->plane = i;
+
+ tex =
+ gst_gl_base_memory_alloc (allocator,
+ (GstGLAllocationParams *) raw->params);
+ if (!tex) {
+ gst_buffer_unref (*outbuf);
+ *outbuf = NULL;
+ GST_ERROR_OBJECT (raw->upload, "Failed to allocate wrapped texture");
+ return GST_GL_UPLOAD_ERROR;
+ }
+
_raw_upload_frame_ref (raw->in_frame);
- gst_buffer_append_memory (*outbuf, (GstMemory *) in_tex[i]);
+ gst_buffer_append_memory (*outbuf, (GstMemory *) tex);
}
+ gst_object_unref (allocator);
_raw_upload_frame_unref (raw->in_frame);
raw->in_frame = NULL;
{
struct RawUpload *raw = impl;
+ if (raw->params)
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) raw->params);
+
g_free (raw);
}
static gboolean
_gen_buffer (GstGLViewConvert * viewconvert, GstBuffer ** target)
{
+ GstGLVideoAllocationParams *params;
+ GstGLMemoryAllocator *mem_allocator;
+ GstAllocator *allocator;
+
*target = gst_buffer_new ();
- if (!gst_gl_memory_pbo_setup_buffer (viewconvert->context,
- viewconvert->to_texture_target, NULL, &viewconvert->out_info, NULL,
- *target)) {
+
+ allocator = gst_allocator_find (GST_GL_MEMORY_PBO_ALLOCATOR_NAME);
+ mem_allocator = GST_GL_MEMORY_ALLOCATOR (allocator);
+ params = gst_gl_video_allocation_params_new (viewconvert->context, NULL,
+ &viewconvert->out_info, 0, NULL, viewconvert->to_texture_target);
+
+ if (!gst_gl_memory_setup_buffer (mem_allocator, *target, params)) {
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
+ gst_object_unref (allocator);
return FALSE;
}
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
+ gst_object_unref (allocator);
+
gst_buffer_add_video_meta_full (*target, 0,
GST_VIDEO_INFO_FORMAT (&viewconvert->out_info),
GST_VIDEO_INFO_WIDTH (&viewconvert->out_info),
/* Luminance formats are not color renderable */
/* renderering to a framebuffer only renders the intersection of all
* the attachments i.e. the smallest attachment size */
- if (!priv->out_tex[j])
+ if (!priv->out_tex[j]) {
+ GstGLVideoAllocationParams *params;
+ GstGLBaseMemoryAllocator *base_mem_allocator;
+ GstAllocator *allocator;
+ GstVideoInfo temp_info;
+
+ gst_video_info_set_format (&temp_info, GST_VIDEO_FORMAT_RGBA, out_width,
+ out_height);
+
+ allocator = gst_allocator_find (GST_GL_MEMORY_PBO_ALLOCATOR_NAME);
+ base_mem_allocator = GST_GL_BASE_MEMORY_ALLOCATOR (allocator);
+ params = gst_gl_video_allocation_params_new (context, NULL, &temp_info,
+ 0, NULL, viewconvert->to_texture_target);
+
priv->out_tex[j] =
- (GstGLMemory *) gst_gl_memory_pbo_alloc (context,
- viewconvert->to_texture_target, NULL, &temp_info, 0, NULL);
+ (GstGLMemory *) gst_gl_base_memory_alloc (base_mem_allocator,
+ (GstGLAllocationParams *) params);
+
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
+ gst_object_unref (allocator);
+ }
} else {
priv->out_tex[j] = out_tex;
}
static void
check_conversion (TestFrame * frames, guint size)
{
+ GstGLBaseMemoryAllocator *base_mem_alloc;
gint i, j, k, l;
gint ref_count = 0;
+ base_mem_alloc =
+ GST_GL_BASE_MEMORY_ALLOCATOR (gst_allocator_find
+ (GST_GL_MEMORY_ALLOCATOR_NAME));
+
for (i = 0; i < size; i++) {
GstBuffer *inbuf;
GstVideoInfo in_info;
gint in_width = frames[i].width;
gint in_height = frames[i].height;
GstVideoFormat in_v_format = frames[i].v_format;
- gchar *in_data[GST_VIDEO_MAX_PLANES] = { 0 };
- GstGLMemory *in_mem[GST_VIDEO_MAX_PLANES] = { 0 };
GstVideoFrame in_frame;
GstCaps *in_caps;
gst_caps_set_features (in_caps, 0,
gst_caps_features_from_string (GST_CAPS_FEATURE_MEMORY_GL_MEMORY));
- for (j = 0; j < GST_VIDEO_INFO_N_PLANES (&in_info); j++) {
- in_data[j] = frames[i].data[j];
- }
-
/* create GL buffer */
- ref_count += GST_VIDEO_INFO_N_PLANES (&in_info);
inbuf = gst_buffer_new ();
- fail_unless (gst_gl_memory_pbo_setup_wrapped (context,
- GST_GL_TEXTURE_TARGET_2D, &in_info, NULL, (gpointer *) in_data,
- (GstGLMemoryPBO **) in_mem, &ref_count, _frame_unref));
-
for (j = 0; j < GST_VIDEO_INFO_N_PLANES (&in_info); j++) {
- gst_buffer_append_memory (inbuf, (GstMemory *) in_mem[j]);
+ GstGLVideoAllocationParams *params;
+ GstGLBaseMemory *mem;
+
+ ref_count++;
+ params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL,
+ &in_info, j, NULL, GST_GL_TEXTURE_TARGET_2D, frames[i].data[j],
+ _frame_unref, &ref_count);
+
+ mem = gst_gl_base_memory_alloc (base_mem_alloc,
+ (GstGLAllocationParams *) params);
+ gst_buffer_append_memory (inbuf, GST_MEMORY_CAST (mem));
+
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
}
fail_unless (gst_video_frame_map (&in_frame, &in_info, inbuf,
/* sanity check that the correct values were wrapped */
for (j = 0; j < GST_VIDEO_INFO_N_PLANES (&in_info); j++) {
for (k = 0; k < _video_info_plane_size (&in_info, j); k++) {
- if (in_data[j][k] != IGNORE_MAGIC)
- fail_unless (((gchar *) in_frame.data[j])[k] == in_data[j][k]);
+ if (frames[i].data[j][k] != IGNORE_MAGIC)
+ fail_unless (((gchar *) in_frame.data[j])[k] == frames[i].data[j][k]);
}
}
fail_unless_equals_int (ref_count, 0);
}
+
+ gst_object_unref (base_mem_alloc);
}
GST_START_TEST (test_reorder_buffer)
GstMemory *mem, *mem2;
GstGLMemory *gl_mem, *gl_mem2;
GstAllocator *gl_allocator;
+ GstGLBaseMemoryAllocator *base_mem_alloc;
gint i, j;
static GstVideoFormat formats[] = {
GST_VIDEO_FORMAT_RGBA, GST_VIDEO_FORMAT_RGB,
GST_VIDEO_FORMAT_YUY2, GST_VIDEO_FORMAT_I420
};
- gl_allocator = gst_allocator_find (GST_GL_MEMORY_PBO_ALLOCATOR_NAME);
+ gl_allocator = gst_allocator_find (GST_GL_MEMORY_ALLOCATOR_NAME);
fail_if (gl_allocator == NULL);
+ base_mem_alloc = GST_GL_BASE_MEMORY_ALLOCATOR (gl_allocator);
/* test allocator creation */
ASSERT_WARNING (mem = gst_allocator_alloc (gl_allocator, 0, NULL));
gst_video_info_set_format (&v_info, formats[i], width, height);
for (j = 0; j < GST_VIDEO_INFO_N_PLANES (&v_info); j++) {
- mem =
- gst_gl_memory_pbo_alloc (context, GST_GL_TEXTURE_TARGET_2D, NULL,
- &v_info, j, NULL);
+ GstGLVideoAllocationParams *params;
+
+ params = gst_gl_video_allocation_params_new (context, NULL, &v_info, j,
+ NULL, GST_GL_TEXTURE_TARGET_2D);
+
+ mem = (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
+ (GstGLAllocationParams *) params);
fail_if (mem == NULL);
gl_mem = (GstGLMemory *) mem;
printf ("%s\n", gst_gl_context_get_error ());
fail_if (gst_gl_context_get_error () != NULL);
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
gst_memory_unref (mem);
gst_memory_unref (mem2);
}
0xff, 0x00, 0x00, 0xff,
};
-GST_START_TEST (test_transfer)
+static void
+test_transfer_allocator (const gchar * allocator_name)
{
GstAllocator *gl_allocator;
+ GstGLBaseMemoryAllocator *base_mem_alloc;
GstVideoInfo v_info;
GstMemory *mem, *mem2, *mem3;
GstMapInfo map_info;
+ GstGLVideoAllocationParams *params;
- gl_allocator = gst_allocator_find (GST_GL_MEMORY_PBO_ALLOCATOR_NAME);
+ gl_allocator = gst_allocator_find (allocator_name);
fail_if (gl_allocator == NULL);
+ base_mem_alloc = GST_GL_BASE_MEMORY_ALLOCATOR (gl_allocator);
gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, 1, 1);
+ params = gst_gl_video_allocation_params_new (context, NULL, &v_info, 0,
+ NULL, GST_GL_TEXTURE_TARGET_2D);
+
/* texture creation */
- mem =
- (GstMemory *) gst_gl_memory_pbo_alloc (context, GST_GL_TEXTURE_TARGET_2D,
- NULL, &v_info, 0, NULL);
+ mem = (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
+ (GstGLAllocationParams *) params);
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD));
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD));
/* test wrapping raw data */
+ params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL,
+ &v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D, rgba_pixel, NULL, NULL);
mem2 =
- (GstMemory *) gst_gl_memory_pbo_wrapped (context,
- GST_GL_TEXTURE_TARGET_2D, &v_info, 0, NULL, rgba_pixel, NULL, NULL);
+ (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
+ (GstGLAllocationParams *) params);
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
fail_if (mem == NULL);
fail_unless (GST_MEMORY_FLAG_IS_SET (mem2,
GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD));
/* wrapped texture creation */
- mem3 = (GstMemory *) gst_gl_memory_pbo_wrapped_texture (context,
- ((GstGLMemory *) mem)->tex_id, GST_GL_TEXTURE_TARGET_2D, &v_info, 0, NULL,
+ params = gst_gl_video_allocation_params_new_wrapped_texture (context, NULL,
+ &v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D, ((GstGLMemory *) mem)->tex_id,
NULL, NULL);
+ mem3 =
+ (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
+ (GstGLAllocationParams *) params);
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem3,
GST_GL_BASE_MEMORY_TRANSFER_NEED_UPLOAD));
fail_unless (GST_MEMORY_FLAG_IS_SET (mem3,
gst_object_unref (gl_allocator);
}
+
+GST_START_TEST (test_transfer)
+{
+ test_transfer_allocator (GST_GL_MEMORY_ALLOCATOR_NAME);
+ test_transfer_allocator (GST_GL_MEMORY_PBO_ALLOCATOR_NAME);
+}
+
GST_END_TEST;
GST_START_TEST (test_separate_transfer)
{
+ GstGLBaseMemoryAllocator *base_mem_alloc;
+ GstGLVideoAllocationParams *params;
GstAllocator *gl_allocator;
GstVideoInfo v_info;
GstMemory *mem;
gl_allocator = gst_allocator_find (GST_GL_MEMORY_PBO_ALLOCATOR_NAME);
fail_if (gl_allocator == NULL);
+ base_mem_alloc = GST_GL_BASE_MEMORY_ALLOCATOR (gl_allocator);
gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, 1, 1);
+ params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL,
+ &v_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D, rgba_pixel, NULL, NULL);
mem =
- (GstMemory *) gst_gl_memory_pbo_wrapped (context,
- GST_GL_TEXTURE_TARGET_2D, &v_info, 0, NULL, rgba_pixel, NULL, NULL);
+ (GstMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
+ (GstGLAllocationParams *) params);
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
fail_if (mem == NULL);
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
GST_GL_BASE_MEMORY_TRANSFER_NEED_DOWNLOAD));
GST_START_TEST (test_upload_buffer)
{
+ GstGLBaseMemoryAllocator *base_mem_alloc;
+ GstGLVideoAllocationParams *params;
GstBuffer *buffer, *outbuf;
GstGLMemory *gl_mem;
GstCaps *in_caps, *out_caps;
gint i = 0;
gboolean res;
+ base_mem_alloc =
+ GST_GL_BASE_MEMORY_ALLOCATOR (gst_allocator_find
+ (GST_GL_MEMORY_ALLOCATOR_NAME));
+
in_caps = gst_caps_from_string ("video/x-raw,format=RGBA,width=10,height=10");
gst_video_info_from_caps (&in_info, in_caps);
/* create GL buffer */
buffer = gst_buffer_new ();
- gl_mem =
- (GstGLMemory *) gst_gl_memory_pbo_wrapped (context,
- GST_GL_TEXTURE_TARGET_2D, &in_info, 0, NULL, rgba_data, NULL, NULL);
+ params = gst_gl_video_allocation_params_new_wrapped_data (context, NULL,
+ &in_info, 0, NULL, GST_GL_TEXTURE_TARGET_2D, rgba_data, NULL, NULL);
+ gl_mem = (GstGLMemory *) gst_gl_base_memory_alloc (base_mem_alloc,
+ (GstGLAllocationParams *) params);
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
res =
gst_memory_map ((GstMemory *) gl_mem, &map_info,
gst_caps_unref (out_caps);
gst_buffer_unref (buffer);
gst_buffer_unref (outbuf);
+ gst_object_unref (base_mem_alloc);
}
GST_END_TEST;