GstMemory *mem, *mem2;
GstGLMemory *gl_mem, *gl_mem2;
GstAllocator *gl_allocator;
- gint i;
- static GstVideoGLTextureType formats[] = {
- GST_VIDEO_GL_TEXTURE_TYPE_RGBA, GST_VIDEO_GL_TEXTURE_TYPE_RGB,
- GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA,
- GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE
+ 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_ALLOCATOR);
+ fail_if (gl_allocator == NULL);
+
+ /* test allocator creation */
+ ASSERT_WARNING (mem = gst_allocator_alloc (gl_allocator, 0, NULL);
+ );
+
for (i = 0; i < G_N_ELEMENTS (formats); i++) {
- gsize width = 320, height = 240, stride = 324;
-
- gl_allocator = gst_allocator_find (GST_GL_MEMORY_ALLOCATOR);
- fail_if (gl_allocator == NULL);
-
- /* test allocator creation */
- ASSERT_WARNING (mem = gst_allocator_alloc (gl_allocator, 0, NULL););
- mem = gst_gl_memory_alloc (context, formats[i], width, height, stride);
- fail_if (mem == NULL);
- gl_mem = (GstGLMemory *) mem;
-
- /* test init params */
- fail_if (gl_mem->width != width);
- fail_if (gl_mem->height != height);
- fail_if (gl_mem->stride != stride);
- fail_if (gl_mem->context != context);
- fail_if (gl_mem->tex_id == 0);
-
- /* copy the memory */
- mem2 = gst_memory_copy (mem, 0, -1);
- fail_if (mem2 == NULL);
- gl_mem2 = (GstGLMemory *) mem2;
-
- /* test params */
- fail_if (gl_mem->tex_id == gl_mem2->tex_id);
- fail_if (gl_mem->tex_type != gl_mem2->tex_type);
- fail_if (gl_mem->width != gl_mem2->width);
- fail_if (gl_mem->stride != gl_mem2->stride);
- fail_if (gl_mem->context != gl_mem2->context);
-
- if (gst_gl_context_get_error ())
- printf ("%s\n", gst_gl_context_get_error ());
- fail_if (gst_gl_context_get_error () != NULL);
-
- gst_memory_unref (mem);
- gst_memory_unref (mem2);
-
- gst_object_unref (gl_allocator);
+ GstVideoInfo v_info;
+ gsize width = 320, height = 240;
+
+ 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_alloc (context, &v_info, j);
+ fail_if (mem == NULL);
+ gl_mem = (GstGLMemory *) mem;
+
+ /* 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->tex_id == 0);
+
+ /* copy the memory */
+ mem2 = gst_memory_copy (mem, 0, -1);
+ fail_if (mem2 == NULL);
+ gl_mem2 = (GstGLMemory *) mem2;
+
+ /* test params */
+ fail_if (gst_video_info_is_equal (&gl_mem2->info,
+ &gl_mem->info) == FALSE);
+ fail_if (gl_mem->context != gl_mem2->context);
+
+ if (gst_gl_context_get_error ())
+ printf ("%s\n", gst_gl_context_get_error ());
+ fail_if (gst_gl_context_get_error () != NULL);
+
+ gst_memory_unref (mem);
+ gst_memory_unref (mem2);
+ }
}
+
+ gst_object_unref (gl_allocator);
}
GST_END_TEST;
/* create GL buffer */
buffer = gst_buffer_new ();
- gl_mem = gst_gl_memory_wrapped (context, FORMAT, WIDTH, HEIGHT, WIDTH * 4,
- rgba_data, NULL, NULL);
+ gl_mem = gst_gl_memory_wrapped (context, &in_info, 0, rgba_data, NULL, NULL);
gst_buffer_append_memory (buffer, (GstMemory *) gl_mem);
gst_gl_upload_set_format (upload, &in_info);
/* create GL buffer */
buffer = gst_buffer_new ();
- gl_mem = gst_gl_memory_wrapped (context, FORMAT, WIDTH, HEIGHT, WIDTH * 4,
- rgba_data, NULL, NULL);
+ gl_mem = gst_gl_memory_wrapped (context, &in_info, 0, rgba_data, NULL, NULL);
gst_buffer_append_memory (buffer, (GstMemory *) gl_mem);
gst_gl_context_gen_texture (context, &tex_ids[0], GST_VIDEO_FORMAT_RGBA,