From: Gwenole Beauchesne Date: Mon, 22 Jul 2013 07:03:30 +0000 (+0200) Subject: tests: add support for render-to-pixmap. X-Git-Tag: 1.19.3~503^2~2500 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=155af03491557edc8bc3a94b47ea63c36cca47aa;p=platform%2Fupstream%2Fgstreamer.git tests: add support for render-to-pixmap. Add --pixmap option to test-decode so that to allow copies of VA surface to an intermediate pixmap and rendering from that pixmap. Only X11 backends are supported for now. --- diff --git a/tests/output.c b/tests/output.c index 5fa7e5a..6a54f3b 100644 --- a/tests/output.c +++ b/tests/output.c @@ -29,6 +29,7 @@ #if USE_X11 # include # include +# include #endif #if USE_GLX # include @@ -52,13 +53,15 @@ static const VideoOutputInfo g_video_outputs[] = { #if USE_X11 { "x11", gst_vaapi_display_x11_new, - gst_vaapi_window_x11_new + gst_vaapi_window_x11_new, + gst_vaapi_pixmap_x11_new }, #endif #if USE_GLX { "glx", gst_vaapi_display_glx_new, - gst_vaapi_window_glx_new + gst_vaapi_window_glx_new, + gst_vaapi_pixmap_x11_new }, #endif #if USE_DRM @@ -200,3 +203,12 @@ video_output_create_window(GstVaapiDisplay *display, guint width, guint height) gst_vaapi_window_set_fullscreen(window, TRUE); return window; } + +GstVaapiPixmap * +video_output_create_pixmap(GstVaapiDisplay *display, GstVideoFormat format, + guint width, guint height) +{ + if (!g_video_output || !g_video_output->create_pixmap) + return NULL; + return g_video_output->create_pixmap(display, format, width, height); +} diff --git a/tests/output.h b/tests/output.h index 3377915..29339c5 100644 --- a/tests/output.h +++ b/tests/output.h @@ -25,16 +25,21 @@ #include #include #include +#include typedef GstVaapiDisplay *(*CreateDisplayFunc)(const gchar *display_name); typedef GstVaapiWindow *(*CreateWindowFunc)(GstVaapiDisplay *display, guint width, guint height); +typedef GstVaapiPixmap *(*CreatePixmapFunc)(GstVaapiDisplay *display, + GstVideoFormat format, guint width, guint height); + typedef struct _VideoOutputInfo VideoOutputInfo; struct _VideoOutputInfo { const gchar *name; CreateDisplayFunc create_display; CreateWindowFunc create_window; + CreatePixmapFunc create_pixmap; }; gboolean @@ -52,4 +57,8 @@ video_output_create_display(const gchar *display_name); GstVaapiWindow * video_output_create_window(GstVaapiDisplay *display, guint width, guint height); +GstVaapiPixmap * +video_output_create_pixmap(GstVaapiDisplay *display, GstVideoFormat format, + guint width, guint height); + #endif /* OUTPUT_H */ diff --git a/tests/test-decode.c b/tests/test-decode.c index cff7612..8790a6e 100644 --- a/tests/test-decode.c +++ b/tests/test-decode.c @@ -36,12 +36,17 @@ static inline void pause(void) } static gchar *g_codec_str; +static gboolean g_use_pixmap; static GOptionEntry g_options[] = { { "codec", 'c', 0, G_OPTION_ARG_STRING, &g_codec_str, "codec to test", NULL }, + { "pixmap", 0, + 0, + G_OPTION_ARG_NONE, &g_use_pixmap, + "use render-to-pixmap", NULL }, { NULL, } }; @@ -50,6 +55,7 @@ main(int argc, char *argv[]) { GstVaapiDisplay *display, *display2; GstVaapiWindow *window; + GstVaapiPixmap *pixmap = NULL; GstVaapiDecoder *decoder; GstVaapiSurfaceProxy *proxy; GstVaapiSurface *surface; @@ -96,12 +102,36 @@ main(int argc, char *argv[]) gst_vaapi_window_show(window); - if (!gst_vaapi_window_put_surface(window, surface, crop_rect, NULL, + if (g_use_pixmap) { + guint width, height; + + if (crop_rect) { + width = crop_rect->width; + height = crop_rect->height; + } + else + gst_vaapi_surface_get_size(surface, &width, &height); + + pixmap = video_output_create_pixmap(display, GST_VIDEO_FORMAT_xRGB, + width, height); + if (!pixmap) + g_error("could not create pixmap"); + + if (!gst_vaapi_pixmap_put_surface(pixmap, surface, crop_rect, + GST_VAAPI_PICTURE_STRUCTURE_FRAME)) + g_error("could not render to pixmap"); + + if (!gst_vaapi_window_put_pixmap(window, pixmap, NULL, NULL)) + g_error("could not render pixmap"); + } + else if (!gst_vaapi_window_put_surface(window, surface, crop_rect, NULL, GST_VAAPI_PICTURE_STRUCTURE_FRAME)) g_error("could not render surface"); pause(); + if (pixmap) + gst_vaapi_pixmap_unref(pixmap); gst_vaapi_surface_proxy_unref(proxy); gst_vaapi_decoder_unref(decoder); gst_vaapi_window_unref(window);