diff options
author | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2013-07-22 09:03:30 +0200 |
---|---|---|
committer | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2013-07-22 15:45:10 +0200 |
commit | 155af03491557edc8bc3a94b47ea63c36cca47aa (patch) | |
tree | bfbd82e5c727c289487b437e34e72380390b8029 /tests | |
parent | 0af0849a92cf0a9db2fe92038c8466f5f3e636fe (diff) | |
download | gstreamer-vaapi-155af03491557edc8bc3a94b47ea63c36cca47aa.tar.gz |
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.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/output.c | 16 | ||||
-rw-r--r-- | tests/output.h | 9 | ||||
-rw-r--r-- | tests/test-decode.c | 32 |
3 files changed, 54 insertions, 3 deletions
diff --git a/tests/output.c b/tests/output.c index 5fa7e5a1..6a54f3b5 100644 --- a/tests/output.c +++ b/tests/output.c @@ -29,6 +29,7 @@ #if USE_X11 # include <gst/vaapi/gstvaapidisplay_x11.h> # include <gst/vaapi/gstvaapiwindow_x11.h> +# include <gst/vaapi/gstvaapipixmap_x11.h> #endif #if USE_GLX # include <gst/vaapi/gstvaapidisplay_glx.h> @@ -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 33779154..29339c5a 100644 --- a/tests/output.h +++ b/tests/output.h @@ -25,16 +25,21 @@ #include <glib.h> #include <gst/vaapi/gstvaapidisplay.h> #include <gst/vaapi/gstvaapiwindow.h> +#include <gst/vaapi/gstvaapipixmap.h> 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 cff76122..8790a6e4 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); |