From: Gwenole Beauchesne Date: Fri, 6 Apr 2012 14:45:34 +0000 (+0200) Subject: tests: simplify VA display construction. X-Git-Tag: libva-1.1.0~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=273d245b445092a62de2ba7c73c481a944b78e56;p=platform%2Fupstream%2Flibva.git tests: simplify VA display construction. Signed-off-by: Gwenole Beauchesne --- diff --git a/configure.ac b/configure.ac index 25052ed..9e7437f 100644 --- a/configure.ac +++ b/configure.ac @@ -149,6 +149,7 @@ AC_DISABLE_STATIC AC_PROG_LIBTOOL AC_PROG_CC AC_PROG_CXX +AM_PROG_CC_C_O AC_HEADER_STDC AC_SYS_LARGEFILE @@ -250,6 +251,7 @@ AC_OUTPUT([ pkgconfig/libva.pc test/Makefile test/basic/Makefile + test/common/Makefile test/decode/Makefile test/encode/Makefile test/putsurface/Makefile diff --git a/test/Makefile.am b/test/Makefile.am index d403ae6..5453061 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -23,6 +23,6 @@ AM_CFLAGS = -I$(top_srcdir)/va -I$(top_srcdir)/test/basic -I$(top_srcdir)/src/x11 -SUBDIRS = basic decode encode putsurface vainfo v4l_h264 +SUBDIRS = common basic decode encode putsurface vainfo v4l_h264 -EXTRA_DIST = loadsurface.h loadsurface_yuv.h \ No newline at end of file +EXTRA_DIST = loadsurface.h loadsurface_yuv.h diff --git a/test/common/Makefile.am b/test/common/Makefile.am new file mode 100644 index 0000000..c348fd7 --- /dev/null +++ b/test/common/Makefile.am @@ -0,0 +1,48 @@ +# Copyright (c) 2012 Intel Corporation. All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sub license, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice (including the +# next paragraph) shall be included in all copies or substantial portions +# of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +noinst_LTLIBRARIES = libva-display.la + +libva_display_cflags = \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + $(NULL) + +libva_display_libs = \ + $(top_builddir)/va/$(libvacorelib) \ + $(top_builddir)/va/$(libvabackendlib) \ + $(NULL) + +source_c = va_display.c +source_h = va_display.h + +source_c += va_display_x11.c +libva_display_cflags += $(X11_CFLAGS) +libva_display_libs += $(X11_LIBS) + +libva_display_la_SOURCES= $(source_c) +noinst_HEADERS = $(source_h) +libva_display_la_CFLAGS = $(libva_display_cflags) +libva_display_la_LIBADD = $(libva_display_libs) + +# Extra clean files so that maintainer-clean removes *everything* +MAINTAINERCLEANFILES = Makefile.in diff --git a/test/common/va_display.c b/test/common/va_display.c new file mode 100644 index 0000000..7a4e563 --- /dev/null +++ b/test/common/va_display.c @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2012 Intel Corporation. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#include +#include +#include "va_display.h" + +extern const VADisplayHooks va_display_hooks_android; +extern const VADisplayHooks va_display_hooks_x11; + +static const VADisplayHooks *g_display_hooks; +static const VADisplayHooks *g_display_hooks_available[] = { +#ifdef ANDROID + &va_display_hooks_android, +#else + &va_display_hooks_x11, +#endif + NULL +}; + +VADisplay +va_open_display(void) +{ + VADisplay va_dpy = NULL; + unsigned int i; + + for (i = 0; !va_dpy && g_display_hooks_available[i]; i++) { + g_display_hooks = g_display_hooks_available[i]; + if (!g_display_hooks->open_display) + continue; + va_dpy = g_display_hooks->open_display(); + } + return va_dpy; +} + +void +va_close_display(VADisplay va_dpy) +{ + if (!va_dpy) + return; + + if (g_display_hooks && g_display_hooks->close_display) + g_display_hooks->close_display(va_dpy); +} + +VAStatus +va_put_surface( + VADisplay va_dpy, + VASurfaceID surface, + const VARectangle *src_rect, + const VARectangle *dst_rect +) +{ + if (!va_dpy) + return VA_STATUS_ERROR_INVALID_DISPLAY; + + if (g_display_hooks && g_display_hooks->put_surface) + return g_display_hooks->put_surface(va_dpy, surface, src_rect, dst_rect); + return VA_STATUS_ERROR_UNIMPLEMENTED; +} diff --git a/test/common/va_display.h b/test/common/va_display.h new file mode 100644 index 0000000..12992f5 --- /dev/null +++ b/test/common/va_display.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2012 Intel Corporation. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef VA_DISPLAY_H +#define VA_DISPLAY_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + VADisplay (*open_display) (void); + void (*close_display) (VADisplay va_dpy); + VAStatus (*put_surface) (VADisplay va_dpy, VASurfaceID surface, + const VARectangle *src_rect, + const VARectangle *dst_rect); +} VADisplayHooks; + +VADisplay +va_open_display(void); + +void +va_close_display(VADisplay va_dpy); + +VAStatus +va_put_surface( + VADisplay va_dpy, + VASurfaceID surface, + const VARectangle *src_rect, + const VARectangle *dst_rect +); + +#ifdef __cplusplus +} +#endif + +#endif /* VA_DISPLAY_H */ diff --git a/test/common/va_display_android.cpp b/test/common/va_display_android.cpp new file mode 100644 index 0000000..77bdc1d --- /dev/null +++ b/test/common/va_display_android.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2012 Intel Corporation. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include "va_display.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static unsigned int fake_display = 0xdeada01d; + +using namespace android; +sp client; +sp android_surface; +sp android_isurface; +sp surface_ctrl; +#include "../android_winsys.cpp" + +static VADisplay +va_open_display_android(void) +{ + return vaGetDisplay(&fake_display); +} + +static void +va_close_display_android(VADisplay va_dpy) +{ +} + +static VAStatus +va_put_surface_android( + VADisplay va_dpy, + VASurfaceID surface, + const VARectangle *src_rect, + const VARectangle *dst_rect +) +{ + sp proc(ProcessState::self()); + ProcessState::self()->startThreadPool(); + + printf("Create window0 for thread0\n"); + SURFACE_CREATE( + client, + surface_ctrl, + android_surface, + android_isurface, + dst_rect->x, dst_rect->y, dst_rect->width, dst_rect->height); + + return vaPutSurface(va_dpy, surface, android_isurface, + src_rect->x, src_rect->y, + src_rect->width, src_rect->height, + dst_rect->x, dst_rect->y, + dst_rect->width, dst_rect->height, + NULL, 0, + VA_FRAME_PICTURE); +} + +extern "C" +const VADisplayHooks va_display_hooks_android = { + va_open_display_android, + va_close_display_android, + va_put_surface_android +}; diff --git a/test/common/va_display_x11.c b/test/common/va_display_x11.c new file mode 100644 index 0000000..de252a7 --- /dev/null +++ b/test/common/va_display_x11.c @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2012 Intel Corporation. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include "va_display.h" + +static Display *x11_display; +static Window x11_window; + +static VADisplay +va_open_display_x11(void) +{ + x11_display = XOpenDisplay(NULL); + if (!x11_display) { + fprintf(stderr, "error: can't connect to X server!\n"); + return NULL; + } + return vaGetDisplay(x11_display); +} + +static void +va_close_display_x11(VADisplay va_dpy) +{ + if (!x11_display) + return; + + if (x11_window) { + XUnmapWindow(x11_display, x11_window); + XDestroyWindow(x11_display, x11_window); + x11_window = None; + } + XCloseDisplay(x11_display); + x11_display = NULL; +} + +static int +ensure_window(unsigned int width, unsigned int height) +{ + Window win, rootwin; + unsigned int black_pixel, white_pixel; + int screen; + + if (!x11_display) + return 0; + + if (x11_window) { + XResizeWindow(x11_display, x11_window, width, height); + return 1; + } + + screen = DefaultScreen(x11_display); + rootwin = RootWindow(x11_display, screen); + black_pixel = BlackPixel(x11_display, screen); + white_pixel = WhitePixel(x11_display, screen); + + win = XCreateSimpleWindow( + x11_display, + rootwin, + 0, 0, width, height, + 1, black_pixel, white_pixel + ); + if (!win) + return 0; + x11_window = win; + + XMapWindow(x11_display, x11_window); + XSync(x11_display, False); + return 1; +} + +static inline bool +validate_rect(const VARectangle *rect) +{ + return (rect && + rect->x >= 0 && + rect->y >= 0 && + rect->width > 0 && + rect->height > 0); +} + +static VAStatus +va_put_surface_x11( + VADisplay va_dpy, + VASurfaceID surface, + const VARectangle *src_rect, + const VARectangle *dst_rect +) +{ + unsigned int win_width, win_height; + + if (!va_dpy) + return VA_STATUS_ERROR_INVALID_DISPLAY; + if (surface == VA_INVALID_SURFACE) + return VA_STATUS_ERROR_INVALID_SURFACE; + if (!validate_rect(src_rect) || !validate_rect(dst_rect)) + return VA_STATUS_ERROR_INVALID_PARAMETER; + + win_width = dst_rect->x + dst_rect->width; + win_height = dst_rect->y + dst_rect->height; + if (!ensure_window(win_width, win_height)) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + return vaPutSurface(va_dpy, surface, x11_window, + src_rect->x, src_rect->y, + src_rect->width, src_rect->height, + dst_rect->x, dst_rect->y, + dst_rect->width, dst_rect->height, + NULL, 0, + VA_FRAME_PICTURE); +} + +const VADisplayHooks va_display_hooks_x11 = { + va_open_display_x11, + va_close_display_x11, + va_put_surface_x11, +}; diff --git a/test/decode/Android.mk b/test/decode/Android.mk index 3fa39c1..e94b5d9 100755 --- a/test/decode/Android.mk +++ b/test/decode/Android.mk @@ -6,12 +6,15 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := \ - mpeg2vldemo.cpp \ + mpeg2vldemo.cpp \ + ../common/va_display.c \ + ../common/va_display_android.cpp LOCAL_CFLAGS += \ -DANDROID LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/../common \ $(TARGET_OUT_HEADERS)/libva \ $(TOPDIR)/hardware/intel/libva/va/ \ $(TARGET_OUT_HEADERS)/X11 diff --git a/test/decode/Makefile.am b/test/decode/Makefile.am index 918c031..477383c 100644 --- a/test/decode/Makefile.am +++ b/test/decode/Makefile.am @@ -22,15 +22,31 @@ bin_PROGRAMS = mpeg2vldemo loadjpeg -INCLUDES = -I$(top_srcdir) +libva_helpers = \ + $(top_builddir)/test/common/libva-display.la \ + $(NULL) + +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/test/common \ + $(NULL) + +TEST_LIBS = \ + $(top_builddir)/va/$(libvabackendlib) \ + $(top_builddir)/va/$(libvacorelib) \ + $(libva_helpers) \ + $(NULL) -TEST_LIBS = $(top_builddir)/va/$(libvabackendlib) $(top_builddir)/va/$(libvacorelib) -lX11 +INCLUDES += $(X11_CFLAGS) +TEST_LIBS += $(X11_LIBS) -mpeg2vldemo_LDADD = $(TEST_LIBS) -mpeg2vldemo_SOURCES = mpeg2vldemo.cpp +mpeg2vldemo_LDADD = $(TEST_LIBS) +mpeg2vldemo_SOURCES = mpeg2vldemo.cpp +mpeg2vldemo_DEPENDENCIES = $(libva_helpers) -loadjpeg_LDADD = $(TEST_LIBS) -loadjpeg_SOURCES = loadjpeg.c tinyjpeg.c +loadjpeg_LDADD = $(TEST_LIBS) +loadjpeg_SOURCES = loadjpeg.c tinyjpeg.c +loadjpeg_DEPENDENCIES = $(libva_helpers) valgrind: $(bin_PROGRAMS) for a in $(bin_PROGRAMS); do \ diff --git a/test/decode/mpeg2vldemo.cpp b/test/decode/mpeg2vldemo.cpp index efdf260..892317e 100644 --- a/test/decode/mpeg2vldemo.cpp +++ b/test/decode/mpeg2vldemo.cpp @@ -43,30 +43,7 @@ #include #include #include - -#ifdef ANDROID -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define Display unsigned int - -using namespace android; -sp client; -sp android_surface; -sp android_isurface; -sp surface_ctrl; -#include "../android_winsys.cpp" -#else -#include -#include -#endif +#include "va_display.h" #define CHECK_VASTATUS(va_status,func) \ if (va_status != VA_STATUS_SUCCESS) { \ @@ -169,28 +146,14 @@ int main(int argc,char **argv) VAContextID context_id; VABufferID pic_param_buf,iqmatrix_buf,slice_param_buf,slice_data_buf; int major_ver, minor_ver; - Display *x11_display; VADisplay va_dpy; VAStatus va_status; int putsurface=0; if (argc > 1) putsurface=1; -#ifdef ANDROID - x11_display = (Display*)malloc(sizeof(Display)); - *(x11_display ) = 0x18c34078; -#else - x11_display = XOpenDisplay(":0.0"); -#endif - - if (x11_display == NULL) { - fprintf(stderr, "Can't connect X server!\n"); - exit(-1); - } - - assert(x11_display); - va_dpy = vaGetDisplay(x11_display); + va_dpy = va_open_display(); va_status = vaInitialize(va_dpy, &major_ver, &minor_ver); assert(va_status == VA_STATUS_SUCCESS); @@ -285,29 +248,20 @@ int main(int argc,char **argv) CHECK_VASTATUS(va_status, "vaSyncSurface"); if (putsurface) { -#ifdef ANDROID - sp proc(ProcessState::self()); - ProcessState::self()->startThreadPool(); + VARectangle src_rect, dst_rect; - printf("Create window0 for thread0\n"); - SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, 0, 0, WIN_WIDTH, WIN_HEIGHT); + src_rect.x = 0; + src_rect.y = 0; + src_rect.width = CLIP_WIDTH; + src_rect.height = CLIP_HEIGHT; - va_status = vaPutSurface(va_dpy, surface_id, android_isurface, - 0,0,CLIP_WIDTH,CLIP_HEIGHT, - 0,0,WIN_WIDTH,WIN_HEIGHT, - NULL,0,0); -#else - Window win; - win = XCreateSimpleWindow(x11_display, RootWindow(x11_display, 0), 0, 0, - WIN_WIDTH,WIN_HEIGHT, 0, 0, WhitePixel(x11_display, 0)); - XMapWindow(x11_display, win); - XSync(x11_display, False); - va_status = vaPutSurface(va_dpy, surface_id, win, - 0,0,CLIP_WIDTH,CLIP_HEIGHT, - 0,0,WIN_WIDTH,WIN_HEIGHT, - NULL,0,0); -#endif - CHECK_VASTATUS(va_status, "vaPutSurface"); + dst_rect.x = 0; + dst_rect.y = 0; + dst_rect.width = WIN_WIDTH; + dst_rect.height = WIN_HEIGHT; + + va_status = va_put_surface(va_dpy, surface_id, &src_rect, &dst_rect); + CHECK_VASTATUS(va_status, "vaPutSurface"); } printf("press any key to exit\n"); getchar(); @@ -317,11 +271,6 @@ int main(int argc,char **argv) vaDestroyContext(va_dpy,context_id); vaTerminate(va_dpy); -#ifdef ANDROID - free(x11_display); -#else - XCloseDisplay(x11_display); -#endif - + va_close_display(va_dpy); return 0; } diff --git a/test/decode/tinyjpeg.c b/test/decode/tinyjpeg.c index 420fc52..111971c 100644 --- a/test/decode/tinyjpeg.c +++ b/test/decode/tinyjpeg.c @@ -48,8 +48,7 @@ #include #include #include -#include -#include +#include "va_display.h" #define cY 0 @@ -543,23 +542,13 @@ int tinyjpeg_decode(struct jdec_private *priv) VAContextID context_id; VABufferID pic_param_buf,iqmatrix_buf,huffmantable_buf,slice_param_buf,slice_data_buf; int major_ver, minor_ver; - Display *x11_display; VADisplay va_dpy; VAStatus va_status; int max_h_factor, max_v_factor; int putsurface=1; unsigned int i, j; - x11_display = XOpenDisplay(":0.0"); - - if (x11_display == NULL) { - fprintf(stderr, "Can't connect X server!\n"); - exit(-1); - } - - assert(x11_display); - - va_dpy = vaGetDisplay(x11_display); + va_dpy = va_open_display(); va_status = vaInitialize(va_dpy, &major_ver, &minor_ver); assert(va_status == VA_STATUS_SUCCESS); @@ -733,16 +722,16 @@ int tinyjpeg_decode(struct jdec_private *priv) CHECK_VASTATUS(va_status, "vaSyncSurface"); if (putsurface) { - Window win; - win = XCreateSimpleWindow(x11_display, RootWindow(x11_display, 0), 0, 0, - priv->width,priv->height, 0, 0, WhitePixel(x11_display, 0)); - XMapWindow(x11_display, win); - XSync(x11_display, False); - va_status = vaPutSurface(va_dpy, surface_id, win, - 0,0,priv->width,priv->height, - 0,0,priv->width,priv->height, - NULL,0,0); - CHECK_VASTATUS(va_status, "vaPutSurface"); + VARectangle src_rect, dst_rect; + + src_rect.x = 0; + src_rect.y = 0; + src_rect.width = priv->width; + src_rect.height = priv->height; + dst_rect = src_rect; + + va_status = va_put_surface(va_dpy, surface_id, &src_rect, &dst_rect); + CHECK_VASTATUS(va_status, "vaPutSurface"); } printf("press any key to exit\n"); getchar(); @@ -752,8 +741,7 @@ int tinyjpeg_decode(struct jdec_private *priv) vaDestroyContext(va_dpy,context_id); vaTerminate(va_dpy); - XCloseDisplay(x11_display); - + va_close_display(va_dpy); return 0; } const char *tinyjpeg_get_errorstring(struct jdec_private *priv) diff --git a/test/vainfo/Android.mk b/test/vainfo/Android.mk index 0aac2cf..91ea526 100644 --- a/test/vainfo/Android.mk +++ b/test/vainfo/Android.mk @@ -6,7 +6,9 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := \ - vainfo.c + vainfo.c \ + ../common/va_display.c \ + ../common/va_display_android.cpp LOCAL_CFLAGS += \ -DANDROID diff --git a/test/vainfo/Makefile.am b/test/vainfo/Makefile.am index 190aa8b..e0db1a3 100644 --- a/test/vainfo/Makefile.am +++ b/test/vainfo/Makefile.am @@ -20,18 +20,30 @@ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - bin_PROGRAMS = vainfo -INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/test/basic \ - -DLIBVA_VERSION_S="\"${LIBVA_VERSION}\"" \ +libva_helpers = \ + $(top_builddir)/test/common/libva-display.la \ + $(NULL) + +vainfo_cflags = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/test/common \ + -I$(top_builddir) \ + -DLIBVA_VERSION_S="\"$(LIBVA_VERSION)\"" \ $(NULL) -vainfo_LDADD = $(top_builddir)/va/$(libvacorelib) $(top_builddir)/va/$(libvabackendlib) -lX11 +vainfo_libs = \ + $(top_builddir)/va/$(libvacorelib) \ + $(top_builddir)/va/$(libvabackendlib) \ + $(libva_helpers) \ + $(NULL) -vainfo_DEPENDENCIES = $(top_builddir)/va/$(libvacorelib) $(top_builddir)/va/$(libvabackendlib) +vainfo_SOURCES = vainfo.c +noinst_HEADERS = $(source_h) +vainfo_CFLAGS = $(vainfo_cflags) +vainfo_LDADD = $(vainfo_libs) +vainfo_DEPENDENCIES = $(libva_helpers) valgrind: vainfo valgrind --leak-check=full --show-reachable=yes .libs/vainfo; diff --git a/test/vainfo/vainfo.c b/test/vainfo/vainfo.c index d98a627..3a49cf6 100644 --- a/test/vainfo/vainfo.c +++ b/test/vainfo/vainfo.c @@ -22,18 +22,11 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef ANDROID -#include -#else -#include "va/va_android.h" -#define Display unsigned int -#endif - #include #include #include #include - +#include "va_display.h" #define CHECK_VASTATUS(va_status,func, ret) \ if (va_status != VA_STATUS_SUCCESS) { \ @@ -79,12 +72,10 @@ static char * entrypoint_string(VAEntrypoint entrypoint) int main(int argc, const char* argv[]) { - Display *dpy; VADisplay va_dpy; VAStatus va_status; int major_version, minor_version; const char *driver; - const char *display = getenv("DISPLAY"); const char *name = strrchr(argv[0], '/'); VAProfile profile; VAEntrypoint entrypoint, entrypoints[10]; @@ -95,18 +86,7 @@ int main(int argc, const char* argv[]) else name = argv[0]; -#ifndef ANDROID - dpy = XOpenDisplay(NULL); -#else - dpy = (Display*)malloc(sizeof(Display)); -#endif - if (NULL == dpy) - { - fprintf(stderr, "%s: Error, can't open display: '%s'\n", name, display ? display : ""); - return 1; - } - - va_dpy = vaGetDisplay(dpy); + va_dpy = va_open_display(); if (NULL == va_dpy) { fprintf(stderr, "%s: vaGetDisplay() failed\n", name); @@ -139,6 +119,7 @@ int main(int argc, const char* argv[]) } vaTerminate(va_dpy); + va_close_display(va_dpy); return 0; }