From 9b66ed12339ac8b47f7e936cad2a997367c3d309 Mon Sep 17 00:00:00 2001 From: gb Date: Fri, 26 Mar 2010 17:00:45 +0000 Subject: [PATCH] Move code around. --- tests/image.c | 39 +++++++++++++++++++++++++++++++++++++++ tests/image.h | 4 ++++ tests/test-windows.c | 41 +---------------------------------------- 3 files changed, 44 insertions(+), 40 deletions(-) diff --git a/tests/image.c b/tests/image.c index 478ed77c39..be628c3d05 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; +} diff --git a/tests/image.h b/tests/image.h index eb914de873..c0558a681d 100644 --- a/tests/image.h +++ b/tests/image.h @@ -22,6 +22,7 @@ #define IMAGE_H #include +#include GstVaapiImage * image_generate( @@ -41,4 +42,7 @@ image_draw_rectangle( guint32 color ); +gboolean +image_upload(GstVaapiImage *image, GstVaapiSurface *surface); + #endif /* IMAGE_H */ diff --git a/tests/test-windows.c b/tests/test-windows.c index 7292bbaeab..d381191035 100644 --- a/tests/test-windows.c +++ b/tests/test-windows.c @@ -30,45 +30,6 @@ static inline void pause(void) getchar(); } -static gboolean -upload_image(GstVaapiSurface *surface, GstVaapiImage *image) -{ - 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 Gst/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; -} - int main(int argc, char *argv[]) { @@ -112,7 +73,7 @@ main(int argc, char *argv[]) image = image_generate(display, format, width, height); if (image) { - if (upload_image(surface, image)) + if (image_upload(image, surface)) break; g_object_unref(image); }