summaryrefslogtreecommitdiff
path: root/tests/image.c
diff options
context:
space:
mode:
authorgb <gb@5584edef-b1fe-4b99-b61b-dd2bab72e969>2010-03-26 17:00:45 +0000
committergb <gb@5584edef-b1fe-4b99-b61b-dd2bab72e969>2010-03-26 17:00:45 +0000
commit9b66ed12339ac8b47f7e936cad2a997367c3d309 (patch)
treea43632d163d6cdadd06d3e0cc5c8bcda8e019aae /tests/image.c
parent10c454e801866feb794ca0ae778e48bd6efeed1e (diff)
Move code around.
Diffstat (limited to 'tests/image.c')
-rw-r--r--tests/image.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/image.c b/tests/image.c
index 478ed77c..be628c3d 100644
--- a/tests/image.c
+++ b/tests/image.c
@@ -318,3 +318,42 @@ image_draw_rectangle(
gst_vaapi_display_unlock(display);
return gst_vaapi_image_unmap(image);
}
+
+gboolean
+image_upload(GstVaapiImage *image, GstVaapiSurface *surface)
+{
+ GstVaapiDisplay *display;
+ GstVaapiImageFormat format;
+ GstVaapiSubpicture *subpicture;
+
+ display = gst_vaapi_object_get_display(GST_VAAPI_OBJECT(surface));
+ if (!display)
+ return FALSE;
+
+ format = gst_vaapi_image_get_format(image);
+ if (!format)
+ return FALSE;
+
+ if (gst_vaapi_surface_put_image(surface, image))
+ return TRUE;
+
+ g_print("could not upload %" GST_FOURCC_FORMAT" image to surface\n",
+ GST_FOURCC_ARGS(format));
+
+ if (!gst_vaapi_display_has_subpicture_format(display, format))
+ return FALSE;
+
+ g_print("trying as a subpicture\n");
+
+ subpicture = gst_vaapi_subpicture_new(image);
+ if (!subpicture)
+ g_error("could not create VA subpicture");
+
+ if (!gst_vaapi_surface_associate_subpicture(surface, subpicture,
+ NULL, NULL))
+ g_error("could not associate subpicture to surface");
+
+ /* The surface holds a reference to the subpicture. This is safe */
+ g_object_unref(subpicture);
+ return TRUE;
+}