diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/check/libs/gstglcolorconvert.c | 36 | ||||
-rw-r--r-- | tests/check/libs/gstglmemory.c | 64 | ||||
-rw-r--r-- | tests/check/libs/gstglupload.c | 15 |
3 files changed, 83 insertions, 32 deletions
diff --git a/tests/check/libs/gstglcolorconvert.c b/tests/check/libs/gstglcolorconvert.c index 669cdd401..4577df968 100644 --- a/tests/check/libs/gstglcolorconvert.c +++ b/tests/check/libs/gstglcolorconvert.c @@ -116,17 +116,20 @@ _frame_unref (gpointer user_data) 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; @@ -135,19 +138,22 @@ check_conversion (TestFrame * frames, guint size) 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, @@ -156,8 +162,8 @@ check_conversion (TestFrame * frames, guint size) /* 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]); } } @@ -215,6 +221,8 @@ check_conversion (TestFrame * frames, guint size) fail_unless_equals_int (ref_count, 0); } + + gst_object_unref (base_mem_alloc); } GST_START_TEST (test_reorder_buffer) diff --git a/tests/check/libs/gstglmemory.c b/tests/check/libs/gstglmemory.c index f9796b100..7387e25dd 100644 --- a/tests/check/libs/gstglmemory.c +++ b/tests/check/libs/gstglmemory.c @@ -54,14 +54,16 @@ GST_START_TEST (test_basic) 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)); @@ -73,9 +75,13 @@ GST_START_TEST (test_basic) 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; @@ -98,6 +104,7 @@ GST_START_TEST (test_basic) 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); } @@ -113,31 +120,41 @@ static gchar rgba_pixel[] = { 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, @@ -146,9 +163,13 @@ GST_START_TEST (test_transfer) 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, @@ -251,10 +272,19 @@ GST_START_TEST (test_transfer) 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; @@ -262,12 +292,16 @@ GST_START_TEST (test_separate_transfer) 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)); diff --git a/tests/check/libs/gstglupload.c b/tests/check/libs/gstglupload.c index 61a6a9e96..64d7a332e 100644 --- a/tests/check/libs/gstglupload.c +++ b/tests/check/libs/gstglupload.c @@ -195,6 +195,8 @@ GST_END_TEST; GST_START_TEST (test_upload_buffer) { + GstGLBaseMemoryAllocator *base_mem_alloc; + GstGLVideoAllocationParams *params; GstBuffer *buffer, *outbuf; GstGLMemory *gl_mem; GstCaps *in_caps, *out_caps; @@ -203,14 +205,20 @@ GST_START_TEST (test_upload_buffer) 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, @@ -245,6 +253,7 @@ GST_START_TEST (test_upload_buffer) gst_caps_unref (out_caps); gst_buffer_unref (buffer); gst_buffer_unref (outbuf); + gst_object_unref (base_mem_alloc); } GST_END_TEST; |