mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 00:01:23 +00:00
glmemory: implement on top of glbasebuffer
Provides convenient access to PBO usage. Currently texture updates are coupled tightly to data transfers.
This commit is contained in:
parent
6e88b07cc5
commit
7d8d1f8206
11 changed files with 480 additions and 574 deletions
|
@ -1034,13 +1034,7 @@ GST_GL_FRAMEBUFFER_GET_CLASS
|
|||
<FILE>gstglmemory</FILE>
|
||||
GstGLAllocator
|
||||
GstGLAllocatorClass
|
||||
GST_MAP_GL
|
||||
GST_GL_MEMORY_ALLOCATOR
|
||||
GstGLMemoryFlags
|
||||
GST_GL_MEMORY_FLAGS
|
||||
GST_GL_MEMORY_FLAG_IS_SET
|
||||
GST_GL_MEMORY_FLAG_SET
|
||||
GST_GL_MEMORY_FLAG_UNSET
|
||||
<TITLE>GstGLMemory</TITLE>
|
||||
GstGLMemory
|
||||
gst_gl_memory_init
|
||||
|
|
|
@ -214,7 +214,7 @@ gst_gl_base_buffer_cpu_access (GstGLBaseBuffer * mem,
|
|||
data = gl->MapBufferRange (mem->target, 0, size, gl_map_flags);
|
||||
|
||||
if (data)
|
||||
memcpy (data, mem->data, size);
|
||||
memcpy (mem->data, data, size);
|
||||
|
||||
gl->UnmapBuffer (mem->target);
|
||||
ret = mem->data;
|
||||
|
|
|
@ -70,13 +70,8 @@ typedef enum
|
|||
* GstGLBaseBuffer:
|
||||
* @mem: the parent object
|
||||
* @context: the #GstGLContext to use for GL operations
|
||||
* @tex_id: the texture id for this memory
|
||||
* @v_format: the video format of this texture
|
||||
* @gl_format: the format of the texture
|
||||
* @width: width of the texture
|
||||
* @height: height of the texture
|
||||
* @download: the object used to download this texture into @v_format
|
||||
* @upload: the object used to upload this texture from @v_format
|
||||
* @id: the buffer id for this memory
|
||||
* @target: the GL target of this texture for binding purposes
|
||||
*
|
||||
* Represents information about a GL buffer
|
||||
*/
|
||||
|
@ -89,16 +84,15 @@ struct _GstGLBaseBuffer
|
|||
guint target;
|
||||
|
||||
/* <protected> */
|
||||
GstMapFlags map_flags; /* cumulative map flags */
|
||||
|
||||
GMutex lock;
|
||||
|
||||
GstMapFlags map_flags; /* cumulative map flags */
|
||||
gint map_count;
|
||||
gint gl_map_count;
|
||||
|
||||
gpointer data;
|
||||
/* <private> */
|
||||
gpointer alloc_data;
|
||||
|
||||
gpointer impl;
|
||||
};
|
||||
|
||||
typedef gboolean (*GstGLBaseBufferAllocatorCreateFunction) (GstGLBaseBuffer * buffer, GError ** error);
|
||||
|
|
|
@ -114,6 +114,7 @@ gst_gl_display_init (GstGLDisplay * display)
|
|||
|
||||
GST_TRACE ("init %p", display);
|
||||
|
||||
gst_gl_base_buffer_init_once ();
|
||||
gst_gl_memory_init ();
|
||||
|
||||
#if GST_GL_HAVE_PLATFORM_EGL
|
||||
|
|
|
@ -413,17 +413,16 @@ _do_download (GstGLDownload * download, GstBuffer * inbuf)
|
|||
|
||||
for (i = 0; i < out_planes; i++) {
|
||||
GstMemory *out_mem = gst_buffer_peek_memory (outbuf, i);
|
||||
gpointer temp_data = ((GstGLMemory *) out_mem)->data;
|
||||
((GstGLMemory *) out_mem)->data = data[i];
|
||||
|
||||
gst_gl_memory_download_transfer ((GstGLMemory *) out_mem);
|
||||
gpointer temp_data = ((GstGLBaseBuffer *) out_mem)->data;
|
||||
((GstGLBaseBuffer *) out_mem)->data = data[i];
|
||||
|
||||
if (!gst_memory_map (out_mem, &map_info, GST_MAP_READ)) {
|
||||
GST_ERROR_OBJECT (download, "Failed to map memory");
|
||||
ret = FALSE;
|
||||
}
|
||||
gst_memory_unmap (out_mem, &map_info);
|
||||
((GstGLMemory *) out_mem)->data = temp_data;
|
||||
((GstGLBaseBuffer *) out_mem)->data = temp_data;
|
||||
GST_MINI_OBJECT_FLAG_SET (out_mem, GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD);
|
||||
}
|
||||
|
||||
gst_buffer_unref (outbuf);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -26,6 +26,7 @@
|
|||
#include <gst/gstmemory.h>
|
||||
#include <gst/video/video.h>
|
||||
|
||||
#include <gst/gl/gstglbasebuffer.h>
|
||||
#include <gst/gl/gl.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@ -40,49 +41,24 @@ GType gst_gl_allocator_get_type(void);
|
|||
#define GST_GL_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GL_ALLOCATOR, GstGLAllocatorClass))
|
||||
#define GST_GL_ALLOCATOR_CAST(obj) ((GstGLAllocator *)(obj))
|
||||
|
||||
/**
|
||||
* GstGLMemoryFlags:
|
||||
*
|
||||
* Flags indicating the current state of a #GstGLMemory
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GST_GL_MEMORY_FLAG_DOWNLOAD_INITTED = (GST_MEMORY_FLAG_LAST << 0),
|
||||
GST_GL_MEMORY_FLAG_UPLOAD_INITTED = (GST_MEMORY_FLAG_LAST << 1),
|
||||
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD = (GST_MEMORY_FLAG_LAST << 2),
|
||||
GST_GL_MEMORY_FLAG_NEED_UPLOAD = (GST_MEMORY_FLAG_LAST << 3)
|
||||
} GstGLMemoryFlags;
|
||||
|
||||
/**
|
||||
* GST_MAP_GL:
|
||||
*
|
||||
* Flag indicating that we should map the GL object instead of to system memory.
|
||||
*
|
||||
* Combining #GST_MAP_GL with #GST_MAP_WRITE has the same semantics as though
|
||||
* you are writing to OpenGL. Conversely, combining #GST_MAP_GL with
|
||||
* #GST_MAP_READ has the same semantics as though you are reading from OpenGL.
|
||||
*/
|
||||
#define GST_MAP_GL GST_MAP_FLAG_LAST << 1
|
||||
|
||||
/**
|
||||
* GstGLMemory:
|
||||
* @mem: the parent object
|
||||
* @context: the #GstGLContext to use for GL operations
|
||||
* @tex_id: the texture id for this memory
|
||||
* @v_format: the video format of this texture
|
||||
* @gl_format: the format of the texture
|
||||
* @width: width of the texture
|
||||
* @height: height of the texture
|
||||
* @download: the object used to download this texture into @v_format
|
||||
* @upload: the object used to upload this texture from @v_format
|
||||
* @tex_id: the GL texture id for this memory
|
||||
* @tex_target: the GL texture target for this memory
|
||||
* @tex_type: the texture type
|
||||
* @info: the texture's #GstVideoInfo
|
||||
* @valign: data alignment for system memory mapping
|
||||
* @plane: data plane in @info
|
||||
* @tex_scaling: GL shader scaling parameters for @valign and/or width/height
|
||||
*
|
||||
* Represents information about a GL texture
|
||||
*/
|
||||
struct _GstGLMemory
|
||||
{
|
||||
GstMemory mem;
|
||||
GstGLBaseBuffer mem;
|
||||
|
||||
GstGLContext *context;
|
||||
guint tex_id;
|
||||
guint tex_target;
|
||||
GstVideoGLTextureType tex_type;
|
||||
|
@ -92,20 +68,11 @@ struct _GstGLMemory
|
|||
gfloat tex_scaling[2];
|
||||
|
||||
/* <private> */
|
||||
gpointer alloc_data;
|
||||
gpointer data;
|
||||
|
||||
gboolean texture_wrapped;
|
||||
GDestroyNotify notify;
|
||||
gpointer user_data;
|
||||
guint pbo;
|
||||
guint unpack_length;
|
||||
guint tex_width;
|
||||
guint transfer_pbo;
|
||||
GstMapFlags map_flags;
|
||||
guint map_count;
|
||||
|
||||
GMutex lock;
|
||||
};
|
||||
|
||||
#define GST_CAPS_FEATURE_MEMORY_GL_MEMORY "memory:GLMemory"
|
||||
|
@ -117,71 +84,57 @@ struct _GstGLMemory
|
|||
/**
|
||||
* GST_GL_MEMORY_ALLOCATOR:
|
||||
*
|
||||
* The name of the GL memore allocator
|
||||
* The name of the GL memory allocator
|
||||
*/
|
||||
#define GST_GL_MEMORY_ALLOCATOR "GLMemory"
|
||||
|
||||
/**
|
||||
* GST_GL_MEMORY_FLAGS:
|
||||
* @mem: a #GstGLMemory
|
||||
*
|
||||
* Get the currently set flags on @mem
|
||||
*/
|
||||
#define GST_GL_MEMORY_FLAGS(mem) GST_MEMORY_FLAGS(mem)
|
||||
|
||||
/**
|
||||
* GST_GL_MEMORY_FLAG_IS_SET:
|
||||
* @mem: a #GstGLMemory
|
||||
* @flag: a flag
|
||||
*
|
||||
* Whether @flag is set on @mem
|
||||
*/
|
||||
#define GST_GL_MEMORY_FLAG_IS_SET(mem,flag) GST_MEMORY_FLAG_IS_SET(mem,flag)
|
||||
|
||||
/**
|
||||
* GST_GL_MEMORY_FLAG_SET:
|
||||
* @mem: a #GstGLMemory
|
||||
* @flag: a flag
|
||||
*
|
||||
* Set @flag on @mem
|
||||
*/
|
||||
#define GST_GL_MEMORY_FLAG_SET(mem,flag) GST_MINI_OBJECT_FLAG_SET(mem,flag)
|
||||
|
||||
/**
|
||||
* GST_GL_MEMORY_FLAG_UNSET:
|
||||
* @mem: a #GstGLMemory
|
||||
* @flag: a flag
|
||||
*
|
||||
* Unset @flag on @mem
|
||||
*/
|
||||
#define GST_GL_MEMORY_FLAG_UNSET(mem,flag) GST_MEMORY_FLAG_UNSET(mem,flag)
|
||||
|
||||
void gst_gl_memory_init (void);
|
||||
gboolean gst_is_gl_memory (GstMemory * mem);
|
||||
|
||||
GstMemory * gst_gl_memory_alloc (GstGLContext * context, GstAllocationParams *params,
|
||||
GstVideoInfo * info, guint plane, GstVideoAlignment *valign);
|
||||
GstGLMemory * gst_gl_memory_wrapped (GstGLContext * context, GstVideoInfo * info, guint plane,
|
||||
GstVideoAlignment *valign, gpointer data,
|
||||
gpointer user_data, GDestroyNotify notify);
|
||||
GstGLMemory * gst_gl_memory_wrapped_texture (GstGLContext * context, guint texture_id, guint texture_target,
|
||||
GstVideoInfo * info, guint plane, GstVideoAlignment *valign,
|
||||
gpointer user_data, GDestroyNotify notify);
|
||||
GstMemory * gst_gl_memory_alloc (GstGLContext * context,
|
||||
GstAllocationParams *params,
|
||||
GstVideoInfo * info,
|
||||
guint plane,
|
||||
GstVideoAlignment *valign);
|
||||
GstGLMemory * gst_gl_memory_wrapped (GstGLContext * context,
|
||||
GstVideoInfo * info,
|
||||
guint plane,
|
||||
GstVideoAlignment *valign,
|
||||
gpointer data,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify);
|
||||
GstGLMemory * gst_gl_memory_wrapped_texture (GstGLContext * context,
|
||||
guint texture_id,
|
||||
guint texture_target,
|
||||
GstVideoInfo * info,
|
||||
guint plane,
|
||||
GstVideoAlignment *valign,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify);
|
||||
|
||||
gboolean gst_gl_memory_copy_into_texture (GstGLMemory *gl_mem, guint tex_id,
|
||||
gboolean gst_gl_memory_copy_into_texture (GstGLMemory *gl_mem,
|
||||
guint tex_id,
|
||||
GstVideoGLTextureType tex_type,
|
||||
gint width, gint height, gint stride,
|
||||
gint width,
|
||||
gint height,
|
||||
gint stride,
|
||||
gboolean respecify);
|
||||
|
||||
gboolean gst_gl_memory_setup_buffer (GstGLContext * context, GstAllocationParams * params,
|
||||
GstVideoInfo * info, GstVideoAlignment *valign, GstBuffer * buffer);
|
||||
gboolean gst_gl_memory_setup_wrapped (GstGLContext * context, GstVideoInfo * info, GstVideoAlignment *valign,
|
||||
gboolean gst_gl_memory_setup_buffer (GstGLContext * context,
|
||||
GstAllocationParams * params,
|
||||
GstVideoInfo * info,
|
||||
GstVideoAlignment *valign,
|
||||
GstBuffer * buffer);
|
||||
gboolean gst_gl_memory_setup_wrapped (GstGLContext * context,
|
||||
GstVideoInfo * info,
|
||||
GstVideoAlignment *valign,
|
||||
gpointer data[GST_VIDEO_MAX_PLANES],
|
||||
GstGLMemory *textures[GST_VIDEO_MAX_PLANES]);
|
||||
|
||||
gint gst_gl_memory_get_texture_width (GstGLMemory * gl_mem);
|
||||
gint gst_gl_memory_get_texture_height (GstGLMemory * gl_mem);
|
||||
|
||||
/* utility functions */
|
||||
GstVideoGLTextureType gst_gl_texture_type_from_format (GstGLContext *context,
|
||||
GstVideoFormat v_format,
|
||||
guint plane);
|
||||
|
@ -190,8 +143,6 @@ guint gst_gl_sized_gl_format_from_gl_format_type (GstGLContext *
|
|||
guint format,
|
||||
guint type);
|
||||
|
||||
void gst_gl_memory_download_transfer (GstGLMemory * gl_mem);
|
||||
|
||||
/**
|
||||
* GstGLAllocator
|
||||
*
|
||||
|
@ -199,7 +150,7 @@ void gst_gl_memory_download_transfer (GstGLMemory * gl_mem);
|
|||
*/
|
||||
struct _GstGLAllocator
|
||||
{
|
||||
GstAllocator parent;
|
||||
GstGLBaseBufferAllocator parent;
|
||||
GstMemoryCopyFunction fallback_mem_copy;
|
||||
};
|
||||
|
||||
|
@ -210,7 +161,7 @@ struct _GstGLAllocator
|
|||
*/
|
||||
struct _GstGLAllocatorClass
|
||||
{
|
||||
GstAllocatorClass parent_class;
|
||||
GstGLBaseBufferAllocatorClass parent_class;
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -266,7 +266,8 @@ _gl_memory_upload_perform (gpointer impl, GstBuffer * buffer,
|
|||
GstMemory *mem = gst_buffer_peek_memory (buffer, i);
|
||||
|
||||
gl_mem = (GstGLMemory *) mem;
|
||||
if (!gst_gl_context_can_share (upload->upload->context, gl_mem->context))
|
||||
if (!gst_gl_context_can_share (upload->upload->context,
|
||||
gl_mem->mem.context))
|
||||
return GST_GL_UPLOAD_UNSHARED_GL_CONTEXT;
|
||||
}
|
||||
|
||||
|
@ -434,8 +435,8 @@ _egl_image_upload_perform_gl_thread (GstGLContext * context,
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -581,11 +582,11 @@ _upload_meta_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
|
|||
gpointer handle;
|
||||
|
||||
gl_apis =
|
||||
gst_gl_api_to_string (gst_gl_context_get_gl_api (upload->
|
||||
upload->context));
|
||||
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));
|
||||
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 =
|
||||
|
@ -791,13 +792,6 @@ _raw_data_upload_perform (gpointer impl, GstBuffer * buffer,
|
|||
gst_gl_memory_setup_wrapped (raw->upload->context,
|
||||
&raw->upload->priv->in_info, NULL, raw->in_frame.data, in_tex);
|
||||
|
||||
for (i = 0; i < GST_GL_UPLOAD_MAX_PLANES; i++) {
|
||||
if (in_tex[i]) {
|
||||
in_tex[i]->data = raw->in_frame.data[i];
|
||||
GST_GL_MEMORY_FLAG_SET (in_tex[i], GST_GL_MEMORY_FLAG_NEED_UPLOAD);
|
||||
}
|
||||
}
|
||||
|
||||
*outbuf = gst_buffer_new ();
|
||||
for (i = 0; i < max_planes; i++) {
|
||||
gst_buffer_append_memory (*outbuf, (GstMemory *) in_tex[i]);
|
||||
|
|
|
@ -205,7 +205,7 @@ _perform_with_gl_memory (GstGLUploadMeta * upload, GstVideoGLTextureUploadMeta *
|
|||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&upload->info); i++) {
|
||||
GstGLMemory *in_mem = upload->priv->in_tex[i];
|
||||
|
||||
if (GST_GL_MEMORY_FLAG_IS_SET (in_mem, GST_GL_MEMORY_FLAG_NEED_UPLOAD)) {
|
||||
if (GST_MEMORY_FLAG_IS_SET (in_mem, GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD)) {
|
||||
GstMapInfo map_info;
|
||||
guint tex_id;
|
||||
|
||||
|
@ -219,7 +219,7 @@ _perform_with_gl_memory (GstGLUploadMeta * upload, GstVideoGLTextureUploadMeta *
|
|||
gst_memory_unmap ((GstMemory *) in_mem, &map_info);
|
||||
|
||||
in_mem->tex_id = tex_id;
|
||||
GST_GL_MEMORY_FLAG_SET (in_mem, GST_GL_MEMORY_FLAG_NEED_UPLOAD);
|
||||
GST_MINI_OBJECT_FLAG_SET (in_mem, GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD);
|
||||
} else {
|
||||
GstGLMemory *out_mem;
|
||||
gint mem_width, mem_height;
|
||||
|
@ -234,7 +234,7 @@ _perform_with_gl_memory (GstGLUploadMeta * upload, GstVideoGLTextureUploadMeta *
|
|||
|
||||
if (out_mem->tex_id != texture_id[i]) {
|
||||
out_mem->tex_id = texture_id[i];
|
||||
GST_GL_MEMORY_FLAG_SET (out_mem, GST_GL_MEMORY_FLAG_NEED_DOWNLOAD);
|
||||
GST_MINI_OBJECT_FLAG_SET (out_mem, GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD);
|
||||
}
|
||||
|
||||
mem_width = gst_gl_memory_get_texture_width (out_mem);
|
||||
|
@ -262,8 +262,6 @@ _perform_with_data_unlocked (GstGLUploadMeta * upload,
|
|||
if (!upload->priv->in_tex[i])
|
||||
upload->priv->in_tex[i] = gst_gl_memory_wrapped (upload->context,
|
||||
&upload->info, i, NULL, data[i], NULL, NULL);
|
||||
|
||||
upload->priv->in_tex[i]->data = data[i];
|
||||
}
|
||||
|
||||
return _perform_with_gl_memory (upload, meta, texture_id);
|
||||
|
|
|
@ -203,6 +203,7 @@ endif
|
|||
|
||||
if USE_GL
|
||||
check_gl=libs/gstglcontext \
|
||||
libs/gstglbuffer \
|
||||
libs/gstglmemory \
|
||||
libs/gstglupload \
|
||||
libs/gstglcolorconvert \
|
||||
|
@ -489,6 +490,16 @@ libs_gstglmemory_CFLAGS = \
|
|||
-DGST_USE_UNSTABLE_API \
|
||||
$(GST_BASE_CFLAGS) $(GST_CFLAGS) $(AM_CFLAGS)
|
||||
|
||||
libs_gstglbuffer_LDADD = \
|
||||
$(top_builddir)/gst-libs/gst/gl/libgstgl-@GST_API_VERSION@.la \
|
||||
$(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_API_VERSION) \
|
||||
$(GST_BASE_LIBS) $(GST_LIBS) $(LDADD)
|
||||
|
||||
libs_gstglbuffer_CFLAGS = \
|
||||
$(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \
|
||||
-DGST_USE_UNSTABLE_API \
|
||||
$(GST_BASE_CFLAGS) $(GST_CFLAGS) $(AM_CFLAGS)
|
||||
|
||||
libs_gstglupload_CFLAGS = \
|
||||
$(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \
|
||||
-DGST_USE_UNSTABLE_API \
|
||||
|
|
|
@ -79,7 +79,7 @@ GST_START_TEST (test_basic)
|
|||
|
||||
/* test init params */
|
||||
fail_if (gst_video_info_is_equal (&v_info, &gl_mem->info) == FALSE);
|
||||
fail_if (gl_mem->context != context);
|
||||
fail_if (gl_mem->mem.context != context);
|
||||
fail_if (gl_mem->tex_id == 0);
|
||||
|
||||
/* copy the memory */
|
||||
|
@ -90,7 +90,7 @@ GST_START_TEST (test_basic)
|
|||
/* test params */
|
||||
fail_if (gst_video_info_is_equal (&gl_mem2->info,
|
||||
&gl_mem->info) == FALSE);
|
||||
fail_if (gl_mem->context != gl_mem2->context);
|
||||
fail_if (gl_mem->mem.context != gl_mem2->mem.context);
|
||||
|
||||
if (gst_gl_context_get_error ())
|
||||
printf ("%s\n", gst_gl_context_get_error ());
|
||||
|
@ -125,10 +125,10 @@ GST_START_TEST (test_transfer)
|
|||
|
||||
/* texture creation */
|
||||
mem = (GstMemory *) gst_gl_memory_alloc (context, NULL, &v_info, 0, NULL);
|
||||
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem,
|
||||
GST_GL_MEMORY_FLAG_NEED_UPLOAD));
|
||||
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem,
|
||||
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD));
|
||||
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
|
||||
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
|
||||
|
||||
/* test wrapping raw data */
|
||||
mem2 =
|
||||
|
@ -136,27 +136,27 @@ GST_START_TEST (test_transfer)
|
|||
rgba_pixel, NULL, NULL);
|
||||
fail_if (mem == NULL);
|
||||
|
||||
fail_unless (GST_GL_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_MEMORY_FLAG_NEED_UPLOAD));
|
||||
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD));
|
||||
fail_unless (GST_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
|
||||
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
|
||||
|
||||
/* wrapped texture creation */
|
||||
mem3 = (GstMemory *) gst_gl_memory_wrapped_texture (context,
|
||||
((GstGLMemory *) mem)->tex_id, GL_TEXTURE_2D, &v_info, 0, NULL, NULL,
|
||||
NULL);
|
||||
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem3,
|
||||
GST_GL_MEMORY_FLAG_NEED_UPLOAD));
|
||||
fail_unless (GST_GL_MEMORY_FLAG_IS_SET (mem3,
|
||||
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD));
|
||||
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem3,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
|
||||
fail_unless (GST_MEMORY_FLAG_IS_SET (mem3,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
|
||||
|
||||
/* check data/flags are correct */
|
||||
fail_unless (gst_memory_map (mem2, &map_info, GST_MAP_READ));
|
||||
|
||||
fail_unless (GST_GL_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_MEMORY_FLAG_NEED_UPLOAD));
|
||||
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD));
|
||||
fail_unless (GST_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
|
||||
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
|
||||
|
||||
fail_unless (((gchar *) map_info.data)[0] == rgba_pixel[0]);
|
||||
fail_unless (((gchar *) map_info.data)[1] == rgba_pixel[1]);
|
||||
|
@ -165,32 +165,32 @@ GST_START_TEST (test_transfer)
|
|||
|
||||
gst_memory_unmap (mem2, &map_info);
|
||||
|
||||
fail_unless (GST_GL_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_MEMORY_FLAG_NEED_UPLOAD));
|
||||
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD));
|
||||
fail_unless (GST_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
|
||||
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
|
||||
|
||||
fail_unless (gst_memory_map (mem2, &map_info, GST_MAP_READ | GST_MAP_GL));
|
||||
|
||||
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_MEMORY_FLAG_NEED_UPLOAD));
|
||||
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD));
|
||||
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
|
||||
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
|
||||
|
||||
/* test texture copy */
|
||||
fail_unless (gst_gl_memory_copy_into_texture ((GstGLMemory *) mem2,
|
||||
((GstGLMemory *) mem)->tex_id, GST_VIDEO_GL_TEXTURE_TYPE_RGBA, 1, 1,
|
||||
4, FALSE));
|
||||
GST_GL_MEMORY_FLAG_SET (mem, GST_GL_MEMORY_FLAG_NEED_DOWNLOAD);
|
||||
GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD);
|
||||
|
||||
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_MEMORY_FLAG_NEED_UPLOAD));
|
||||
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD));
|
||||
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem,
|
||||
GST_GL_MEMORY_FLAG_NEED_UPLOAD));
|
||||
fail_unless (GST_GL_MEMORY_FLAG_IS_SET (mem,
|
||||
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD));
|
||||
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
|
||||
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
|
||||
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
|
||||
fail_unless (GST_MEMORY_FLAG_IS_SET (mem,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
|
||||
|
||||
gst_memory_unmap (mem2, &map_info);
|
||||
|
||||
|
@ -207,10 +207,10 @@ GST_START_TEST (test_transfer)
|
|||
/* test download of wrapped copied texture */
|
||||
fail_unless (gst_memory_map (mem3, &map_info, GST_MAP_READ));
|
||||
|
||||
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem,
|
||||
GST_GL_MEMORY_FLAG_NEED_UPLOAD));
|
||||
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem,
|
||||
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD));
|
||||
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
|
||||
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
|
||||
|
||||
fail_unless (((gchar *) map_info.data)[0] == rgba_pixel[0]);
|
||||
fail_unless (((gchar *) map_info.data)[1] == rgba_pixel[1]);
|
||||
|
@ -223,19 +223,19 @@ GST_START_TEST (test_transfer)
|
|||
fail_unless (gst_memory_map (mem3, &map_info, GST_MAP_WRITE));
|
||||
gst_memory_unmap (mem3, &map_info);
|
||||
|
||||
fail_unless (GST_GL_MEMORY_FLAG_IS_SET (mem3,
|
||||
GST_GL_MEMORY_FLAG_NEED_UPLOAD));
|
||||
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem3,
|
||||
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD));
|
||||
fail_unless (GST_MEMORY_FLAG_IS_SET (mem3,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
|
||||
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem3,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
|
||||
|
||||
/* test download flag */
|
||||
fail_unless (gst_memory_map (mem3, &map_info, GST_MAP_WRITE | GST_MAP_GL));
|
||||
gst_memory_unmap (mem3, &map_info);
|
||||
|
||||
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem3,
|
||||
GST_GL_MEMORY_FLAG_NEED_UPLOAD));
|
||||
fail_unless (GST_GL_MEMORY_FLAG_IS_SET (mem3,
|
||||
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD));
|
||||
fail_unless (!GST_MEMORY_FLAG_IS_SET (mem3,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
|
||||
fail_unless (GST_MEMORY_FLAG_IS_SET (mem3,
|
||||
GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
|
||||
|
||||
if (gst_gl_context_get_error ())
|
||||
printf ("%s\n", gst_gl_context_get_error ());
|
||||
|
|
Loading…
Reference in a new issue