From b0e4126e953bada974b312cf99732870fc17418d Mon Sep 17 00:00:00 2001 From: Austin Yuan Date: Fri, 27 Nov 2009 17:54:30 +0800 Subject: re-arrange test programs Signed-off-by: Austin Yuan --- configure.ac | 4 + test/Makefile.am | 53 +----- test/basic/Makefile.am | 66 +++++++ test/basic/test.c | 155 +++++++++++++++ test/basic/test_01.c | 42 +++++ test/basic/test_02.c | 42 +++++ test/basic/test_03.c | 67 +++++++ test/basic/test_04.c | 84 +++++++++ test/basic/test_05.c | 77 ++++++++ test/basic/test_06.c | 123 ++++++++++++ test/basic/test_07.c | 119 ++++++++++++ test/basic/test_08.c | 92 +++++++++ test/basic/test_09.c | 109 +++++++++++ test/basic/test_10.c | 140 ++++++++++++++ test/basic/test_11.c | 179 ++++++++++++++++++ test/basic/test_common.c | 175 +++++++++++++++++ test/basic/testplan.txt | 106 +++++++++++ test/decode/Makefile.am | 36 ++++ test/decode/mpeg2-I.gif | Bin 0 -> 103275 bytes test/decode/mpeg2-I.m2v | Bin 0 -> 197 bytes test/decode/mpeg2vldemo.c | 286 ++++++++++++++++++++++++++++ test/encode/Makefile.am | 36 ++++ test/encode/h264encode.c | 428 ++++++++++++++++++++++++++++++++++++++++++ test/mpeg2-I.jpg | Bin 144089 -> 0 bytes test/mpeg2-I.mpg | Bin 197 -> 0 bytes test/putsurface/Makefile.am | 36 ++++ test/putsurface/loadsurface.h | 97 ++++++++++ test/putsurface/putsurface.c | 343 +++++++++++++++++++++++++++++++++ test/test.c | 155 --------------- test/test_01.c | 42 ----- test/test_02.c | 42 ----- test/test_03.c | 67 ------- test/test_04.c | 84 --------- test/test_05.c | 77 -------- test/test_06.c | 123 ------------ test/test_07.c | 119 ------------ test/test_08.c | 92 --------- test/test_09.c | 109 ----------- test/test_10.c | 140 -------------- test/test_11.c | 179 ------------------ test/test_12.c | 250 ------------------------ test/test_common.c | 175 ----------------- test/testplan.txt | 106 ----------- 43 files changed, 2846 insertions(+), 1809 deletions(-) create mode 100644 test/basic/Makefile.am create mode 100644 test/basic/test.c create mode 100644 test/basic/test_01.c create mode 100644 test/basic/test_02.c create mode 100644 test/basic/test_03.c create mode 100644 test/basic/test_04.c create mode 100644 test/basic/test_05.c create mode 100644 test/basic/test_06.c create mode 100644 test/basic/test_07.c create mode 100644 test/basic/test_08.c create mode 100644 test/basic/test_09.c create mode 100644 test/basic/test_10.c create mode 100644 test/basic/test_11.c create mode 100644 test/basic/test_common.c create mode 100644 test/basic/testplan.txt create mode 100644 test/decode/Makefile.am create mode 100644 test/decode/mpeg2-I.gif create mode 100644 test/decode/mpeg2-I.m2v create mode 100644 test/decode/mpeg2vldemo.c create mode 100644 test/encode/Makefile.am create mode 100644 test/encode/h264encode.c delete mode 100644 test/mpeg2-I.jpg delete mode 100644 test/mpeg2-I.mpg create mode 100644 test/putsurface/Makefile.am create mode 100644 test/putsurface/loadsurface.h create mode 100644 test/putsurface/putsurface.c delete mode 100644 test/test.c delete mode 100644 test/test_01.c delete mode 100644 test/test_02.c delete mode 100644 test/test_03.c delete mode 100644 test/test_04.c delete mode 100644 test/test_05.c delete mode 100644 test/test_06.c delete mode 100644 test/test_07.c delete mode 100644 test/test_08.c delete mode 100644 test/test_09.c delete mode 100644 test/test_10.c delete mode 100644 test/test_11.c delete mode 100644 test/test_12.c delete mode 100644 test/test_common.c delete mode 100644 test/testplan.txt diff --git a/configure.ac b/configure.ac index c3aba90..b99c6b1 100644 --- a/configure.ac +++ b/configure.ac @@ -126,6 +126,10 @@ AC_OUTPUT([ i965_drv_video/shaders/mpeg2/vld/Makefile i965_drv_video/shaders/render/Makefile test/Makefile + test/basic/Makefile + test/decode/Makefile + test/putsurface/Makefile + test/encode/Makefile libva.pc libva-x11.pc ]) diff --git a/test/Makefile.am b/test/Makefile.am index 58e1677..5734226 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -20,62 +20,17 @@ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -check_PROGRAMS = test_01 test_02 test_03 test_04 test_05 test_06 \ - test_07 test_08 test_09 test_10 test_11 test_12 bin_PROGRAMS = vainfo -testdir = $(bindir) +AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/test/basic -I$(top_srcdir)/src/x11 -DIN_LIBVA -AM_CFLAGS = -I$(top_srcdir)/../../include/external/ -I$(top_srcdir)/src -I$(top_srcdir)/src/x11 -DIN_LIBVA - -TESTS = $(check_PROGRAMS) - -TEST_LIBS = $(top_srcdir)/src/$(libvabackendlib) vainfo_LDADD = $(top_srcdir)/src/$(libvabackendlib) vainfo_DEPENDENCIES = $(top_srcdir)/src/$(libvabackendlib) vainfo_SOURCES = vainfo.c -test_01_LDADD = $(TEST_LIBS) -test_01_SOURCES = test_01.c - -test_02_LDADD = $(TEST_LIBS) -test_02_SOURCES = test_02.c - -test_03_LDADD = $(TEST_LIBS) -test_03_SOURCES = test_03.c - -test_04_LDADD = $(TEST_LIBS) -test_04_SOURCES = test_04.c - -test_05_LDADD = $(TEST_LIBS) -test_05_SOURCES = test_05.c - -test_06_LDADD = $(TEST_LIBS) -test_06_SOURCES = test_06.c - -test_07_LDADD = $(TEST_LIBS) -test_07_SOURCES = test_07.c - -test_08_LDADD = $(TEST_LIBS) -test_08_SOURCES = test_08.c - -test_09_LDADD = $(TEST_LIBS) -test_09_SOURCES = test_09.c - -test_10_LDADD = $(TEST_LIBS) -test_10_SOURCES = test_10.c - -test_11_LDADD = $(TEST_LIBS) -test_11_SOURCES = test_11.c - -test_12_LDADD = $(TEST_LIBS) -test_12_SOURCES = test_12.c - -EXTRA_DIST = test_common.c mpeg2-I.jpg mpeg2-I.mpg +SUBDIRS = basic decode encode putsurface -valgrind: $(check_PROGRAMS) - for a in $(check_PROGRAMS); do \ - valgrind --leak-check=full --show-reachable=yes .libs/$$a; \ - done +valgrind: vainfo + valgrind --leak-check=full --show-reachable=yes .libs/vainfo; diff --git a/test/basic/Makefile.am b/test/basic/Makefile.am new file mode 100644 index 0000000..78eabcb --- /dev/null +++ b/test/basic/Makefile.am @@ -0,0 +1,66 @@ +# Copyright (c) 2007 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. + +bin_PROGRAMS = test_01 test_02 test_03 test_04 test_05 test_06 \ + test_07 test_08 test_09 test_10 test_11 + +TEST_LIBS = $(top_srcdir)/src/$(libvabackendlib) + +test_01_LDADD = $(TEST_LIBS) +test_01_SOURCES = test_01.c + +test_02_LDADD = $(TEST_LIBS) +test_02_SOURCES = test_02.c + +test_03_LDADD = $(TEST_LIBS) +test_03_SOURCES = test_03.c + +test_04_LDADD = $(TEST_LIBS) +test_04_SOURCES = test_04.c + +test_05_LDADD = $(TEST_LIBS) +test_05_SOURCES = test_05.c + +test_06_LDADD = $(TEST_LIBS) +test_06_SOURCES = test_06.c + +test_07_LDADD = $(TEST_LIBS) +test_07_SOURCES = test_07.c + +test_08_LDADD = $(TEST_LIBS) +test_08_SOURCES = test_08.c + +test_09_LDADD = $(TEST_LIBS) +test_09_SOURCES = test_09.c + +test_10_LDADD = $(TEST_LIBS) +test_10_SOURCES = test_10.c + +test_11_LDADD = $(TEST_LIBS) +test_11_SOURCES = test_11.c + +EXTRA_DIST = test_common.c + +valgrind: $(bin_PROGRAMS) + for a in $(bin_PROGRAMS); do \ + valgrind --leak-check=full --show-reachable=yes .libs/$$a; \ + done diff --git a/test/basic/test.c b/test/basic/test.c new file mode 100644 index 0000000..2e98b12 --- /dev/null +++ b/test/basic/test.c @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2007 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 IN_LIBVA +#include +#else +#include +#endif + +#include "assert.h" +#include +#include +#include +#include + +#define ASSERT assert + +int main(int argc, const char* argv[]) +{ + Display *dpy; + VADisplay va_dpy; + VAStatus va_status; + int major_version, minor_version; + + dpy = XOpenDisplay(NULL); + ASSERT( dpy ); + printf("XOpenDisplay: dpy = %08x\n", dpy); + + va_dpy = vaGetDisplay(dpy); + ASSERT( va_dpy ); + printf("vaGetDisplay: va_dpy = %08x\n", va_dpy); + + va_status = vaInitialize(va_dpy, &major_version, &minor_version); + ASSERT( VA_STATUS_SUCCESS == va_status ); + printf("vaInitialize: major = %d minor = %d\n", major_version, minor_version); + + { + VASurfaceID surfaces[21]; + int i; + + surfaces[20] = -1; + va_status = vaCreateSurfaces(va_dpy, 720, 480, VA_RT_FORMAT_YUV420, 20, surfaces); + ASSERT( VA_STATUS_SUCCESS == va_status ); + ASSERT( -1 == surfaces[20] ); /* bounds check */ + for(i = 0; i < 20; i++) + { + printf("Surface %d surface_id = %08x\n", i, surfaces[i]); + } + Window win = XCreateSimpleWindow(dpy, RootWindow(dpy, 0), 0, 0, 720, 480, 0, 0, WhitePixel(dpy, 0)); + printf("Window = %08x\n", win); + XMapWindow(dpy, win); + XSync(dpy, False); + + vaPutSurface(va_dpy, surfaces[0], win, 0, 0, 720, 480, 0, 0, 720, 480, 0); + + sleep(10); + va_status = vaDestroySurface(va_dpy, surfaces, 20); + ASSERT( VA_STATUS_SUCCESS == va_status ); + } + + { + int num_profiles; + int i; + VAProfile *profiles = malloc(vaMaxNumProfiles(va_dpy) * sizeof(VAProfile)); + ASSERT(profiles); + printf("vaMaxNumProfiles = %d\n", vaMaxNumProfiles(va_dpy)); + + va_status = vaQueryConfigProfiles(va_dpy, profiles, &num_profiles); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + printf("vaQueryConfigProfiles reports %d profiles\n", num_profiles); + for(i = 0; i < num_profiles; i++) + { + printf("Profile %d\n", profiles[i]); + } + } + + { + VASurfaceID surfaces[20]; + VAContextID context; + VAConfigAttrib attrib; + VAConfigID config_id; + int i; + + attrib.type = VAConfigAttribRTFormat; + va_status = vaGetConfigAttributes(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, + &attrib, 1); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + ASSERT(attrib.value & VA_RT_FORMAT_YUV420); + /* Found desired RT format, keep going */ + + va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, &attrib, 1, + &config_id); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + va_status = vaCreateSurfaces(va_dpy, 720, 480, VA_RT_FORMAT_YUV420, 20, surfaces); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + va_status = vaCreateContext(va_dpy, config_id, 720, 480, 0 /* flag */, surfaces, 20, &context); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + va_status = vaDestroyContext(va_dpy, context); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + va_status = vaDestroySurface(va_dpy, surfaces, 20); + ASSERT( VA_STATUS_SUCCESS == va_status ); + } + + { + VABufferID picture_buf[3]; + va_status = vaCreateBuffer(va_dpy, VAPictureParameterBufferType, &picture_buf[0]); + ASSERT( VA_STATUS_SUCCESS == va_status ); + va_status = vaCreateBuffer(va_dpy, VAPictureParameterBufferType, &picture_buf[1]); + ASSERT( VA_STATUS_SUCCESS == va_status ); + va_status = vaCreateBuffer(va_dpy, VAPictureParameterBufferType, &picture_buf[2]); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + va_status = vaDestroyBuffer(va_dpy, picture_buf[0]); + ASSERT( VA_STATUS_SUCCESS == va_status ); + va_status = vaDestroyBuffer(va_dpy, picture_buf[2]); + ASSERT( VA_STATUS_SUCCESS == va_status ); + va_status = vaDestroyBuffer(va_dpy, picture_buf[1]); + ASSERT( VA_STATUS_SUCCESS == va_status ); + } + + va_status = vaTerminate(va_dpy); + ASSERT( VA_STATUS_SUCCESS == va_status ); + printf("vaTerminate\n"); + + XCloseDisplay(dpy); + + return 0; +} diff --git a/test/basic/test_01.c b/test/basic/test_01.c new file mode 100644 index 0000000..4075655 --- /dev/null +++ b/test/basic/test_01.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2007 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. + */ + +#define TEST_DESCRIPTION "Initialize & Terminate" + +#include "test_common.c" + +void pre() +{ +} + +void post() +{ +} + +void test() +{ + test_init(); + + test_terminate(); +} diff --git a/test/basic/test_02.c b/test/basic/test_02.c new file mode 100644 index 0000000..5622a18 --- /dev/null +++ b/test/basic/test_02.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2007 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. + */ + +#define TEST_DESCRIPTION "Query profiles" + +#include "test_common.c" + +void pre() +{ + test_init(); +} + +void test() +{ + test_profiles(); +} + +void post() +{ + test_terminate(); +} diff --git a/test/basic/test_03.c b/test/basic/test_03.c new file mode 100644 index 0000000..d2af494 --- /dev/null +++ b/test/basic/test_03.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2007 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. + */ + +#define TEST_DESCRIPTION "Query entrypoints for all profiles" + +#include "test_common.c" + +void pre() +{ + test_init(); + test_profiles(); +} + +void test() +{ + int max_entrypoints; + int num_entrypoints; + int i, j; + max_entrypoints = vaMaxNumEntrypoints(va_dpy); + status("vaMaxEntryPoints = %d\n", max_entrypoints); + ASSERT(max_entrypoints > 0); + + VAEntrypoint *entrypoints = malloc(max_entrypoints * sizeof(VAEntrypoint)); + ASSERT(entrypoints); + + for(i = 0; i < num_profiles; i++) + { + memset(entrypoints, 0xff, max_entrypoints * sizeof(VAEntrypoint)); + va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); + ASSERT( VA_STATUS_SUCCESS == va_status ); + status("vaQueryConfigEntryPoints(%s) reports %d entrypoints\n", profile2string(profiles[i]), num_entrypoints); + ASSERT(num_entrypoints <= max_entrypoints); + ASSERT(num_entrypoints > 0); + for(j = 0; j < num_entrypoints; j++) + { + status(" entrypoint %d [%s]\n", entrypoints[j], entrypoint2string(entrypoints[j])); + } + } + + free(entrypoints); +} + +void post() +{ + test_terminate(); +} diff --git a/test/basic/test_04.c b/test/basic/test_04.c new file mode 100644 index 0000000..2e3329c --- /dev/null +++ b/test/basic/test_04.c @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2007 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. + */ + +#define TEST_DESCRIPTION "Get config attributes for all profiles / entrypoints" + +#include "test_common.c" + +void pre() +{ + test_init(); + test_profiles(); +} + +#define DEADVALUE 0xdeaddead + +void test() +{ + VAConfigAttrib attributes[] = { + { type: VAConfigAttribRTFormat, value: DEADVALUE }, + { type: VAConfigAttribSpatialResidual, value: DEADVALUE }, + { type: VAConfigAttribSpatialClipping, value: DEADVALUE }, + { type: VAConfigAttribIntraResidual, value: DEADVALUE }, + { type: VAConfigAttribEncryption, value: DEADVALUE } + }; + int max_entrypoints; + int num_entrypoints; + int num_attribs = sizeof(attributes) / sizeof(VAConfigAttrib); + int i, j, k; + max_entrypoints = vaMaxNumEntrypoints(va_dpy); + ASSERT(max_entrypoints > 0); + VAEntrypoint *entrypoints = malloc(max_entrypoints * sizeof(VAEntrypoint)); + ASSERT(entrypoints); + + VAConfigAttrib *attrib_list = (VAConfigAttrib *) malloc(sizeof(attributes)); + ASSERT(attrib_list); + + for(i = 0; i < num_profiles; i++) + { + va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + for(j = 0; j < num_entrypoints; j++) + { + memcpy(attrib_list, attributes, sizeof(attributes)); + status("vaGetConfigAttributes for %s, %s\n", profile2string(profiles[i]), entrypoint2string(entrypoints[j])); + va_status = vaGetConfigAttributes(va_dpy, profiles[i], entrypoints[j], attrib_list, num_attribs); + ASSERT( VA_STATUS_SUCCESS == va_status ); + for(k = 0; k < num_attribs; k++) + { + status(" %d -> %08x\n", attrib_list[k].type, attrib_list[k].value); + ASSERT(attrib_list[k].value != DEADVALUE); + } + } + } + + free(attrib_list); + free(entrypoints); +} + +void post() +{ + test_terminate(); +} diff --git a/test/basic/test_05.c b/test/basic/test_05.c new file mode 100644 index 0000000..f88dd15 --- /dev/null +++ b/test/basic/test_05.c @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2007 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. + */ + +#define TEST_DESCRIPTION "Create/destroy configs for all profiles / entrypoints" + +#include "test_common.c" + +void pre() +{ + test_init(); + test_profiles(); +} + +void test() +{ + int max_entrypoints; + int num_entrypoints; + int i, j, k; + int config_count = 0; + max_entrypoints = vaMaxNumEntrypoints(va_dpy); + ASSERT(max_entrypoints > 0); + VAEntrypoint *entrypoints = malloc(max_entrypoints * sizeof(VAEntrypoint)); + ASSERT(entrypoints); + + VAConfigID *configs = malloc(max_entrypoints * num_profiles * sizeof(VAConfigID)); + + for(i = 0; i < num_profiles; i++) + { + va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + for(j = 0; j < num_entrypoints; j++) + { + status("vaCreateConfig for %s, %s\n", profile2string(profiles[i]), entrypoint2string(entrypoints[j])); + va_status = vaCreateConfig(va_dpy, profiles[i], entrypoints[j], NULL, 0, &(configs[config_count])); + ASSERT( VA_STATUS_SUCCESS == va_status ); + status("vaCreateConfig returns %08x\n", configs[config_count]); + config_count++; + } + } + + for(i = 0; i < config_count; i++) + { + status("vaDestroyConfig for config %08x\n", configs[i]); + va_status = vaDestroyConfig( va_dpy, configs[i] ); + ASSERT( VA_STATUS_SUCCESS == va_status ); + } + + free(configs); + free(entrypoints); +} + +void post() +{ + test_terminate(); +} diff --git a/test/basic/test_06.c b/test/basic/test_06.c new file mode 100644 index 0000000..ca47e50 --- /dev/null +++ b/test/basic/test_06.c @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2007 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. + */ + +#define TEST_DESCRIPTION "Get config attributes from configs" + +#include "test_common.c" + +int max_entrypoints; +VAEntrypoint *entrypoints; + +VAConfigID *configs; +int config_count = 0; + + + +void pre() +{ + int i, j, k; + + test_init(); + test_profiles(); + + max_entrypoints = vaMaxNumEntrypoints(va_dpy); + ASSERT(max_entrypoints > 0); + entrypoints = malloc(max_entrypoints * sizeof(VAEntrypoint)); + ASSERT(entrypoints); + + configs = malloc(max_entrypoints * num_profiles * sizeof(VAConfigID)); + ASSERT(configs); + + // Create configs + for(i = 0; i < num_profiles; i++) + { + int num_entrypoints; + va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + for(j = 0; j < num_entrypoints; j++) + { + va_status = vaCreateConfig(va_dpy, profiles[i], entrypoints[j], NULL, 0, &(configs[config_count])); + ASSERT( VA_STATUS_SUCCESS == va_status ); + config_count++; + } + } +} + +void test() +{ + int i, j, k; + int max_attribs; + + max_attribs = vaMaxNumConfigAttributes(va_dpy); + ASSERT(max_attribs > 0); + + VAConfigAttrib *attrib_list = malloc(max_attribs * sizeof(VAConfigAttrib)); + + config_count = 0; + for(i = 0; i < num_profiles; i++) + { + int num_entrypoints; + + va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); + ASSERT( VA_STATUS_SUCCESS == va_status ); + for(j = 0; j < num_entrypoints; j++) + { + VAProfile profile= -1; + VAEntrypoint entrypoint = -1; + int num_attribs = -1; + + status("Checking vaQueryConfigAttributes for %s, %s\n", profile2string(profiles[i]), entrypoint2string(entrypoints[j])); + memset(attrib_list, 0xff, max_attribs * sizeof(VAConfigAttrib)); + + va_status = vaQueryConfigAttributes(va_dpy, configs[config_count], &profile, &entrypoint, attrib_list, &num_attribs); + config_count++; + ASSERT( VA_STATUS_SUCCESS == va_status ); + ASSERT( profile == profiles[i] ); + ASSERT( entrypoint == entrypoints[j] ); + ASSERT( num_attribs >= 0 ); + for(k = 0; k < num_attribs; k++) + { + status(" %d -> %08x\n", attrib_list[k].type, attrib_list[k].value); + ASSERT(attrib_list[k].value != VA_ATTRIB_NOT_SUPPORTED); + } + } + } + + free(attrib_list); +} + +void post() +{ + int i; + for(i = 0; i < config_count; i++) + { + va_status = vaDestroyConfig( va_dpy, configs[i] ); + ASSERT( VA_STATUS_SUCCESS == va_status ); + } + + free(configs); + free(entrypoints); + test_terminate(); +} diff --git a/test/basic/test_07.c b/test/basic/test_07.c new file mode 100644 index 0000000..cb1edce --- /dev/null +++ b/test/basic/test_07.c @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2007 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. + */ + +#define TEST_DESCRIPTION "Create and destory surfaces" + +#include "test_common.c" + +void pre() +{ + test_init(); +} + +#define DEAD_SURFACE_ID (VASurfaceID) 0xbeefdead + +void test_unique_surfaces(VASurfaceID *surface_list1, int surface_count1, VASurfaceID *surface_list2, int surface_count2) +{ + int i,j; + + for(i = 0; i < surface_count1; i++) + { + for(j = 0; j < surface_count2; j++) + { + if ((surface_list1 == surface_list2) && (i == j)) continue; + ASSERT(surface_list1[i] != VA_INVALID_SURFACE); + ASSERT(surface_list2[j] != VA_INVALID_SURFACE); + ASSERT(surface_list1[i] != surface_list2[j]); + } + } +} + + +void test() +{ + VASurfaceID surfaces_1[1+1]; + VASurfaceID surfaces_4[4+1]; + VASurfaceID surfaces_16[16+1]; + VASurfaceID surfaces_6[6+1]; + + memset(surfaces_1, 0xff, sizeof(surfaces_1)); + memset(surfaces_4, 0xff, sizeof(surfaces_4)); + memset(surfaces_16, 0xff, sizeof(surfaces_16)); + memset(surfaces_6, 0xff, sizeof(surfaces_6)); + + status("vaCreateSurfaces 1 surface\n"); + surfaces_1[1] = DEAD_SURFACE_ID; + va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 1, surfaces_1); + ASSERT( VA_STATUS_SUCCESS == va_status ); + ASSERT( DEAD_SURFACE_ID == surfaces_1[1] ); /* bounds check */ + + status("vaCreateSurfaces 4 surfaces\n"); + surfaces_4[4] = DEAD_SURFACE_ID; + va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 4, surfaces_4); + ASSERT( VA_STATUS_SUCCESS == va_status ); + ASSERT( DEAD_SURFACE_ID == surfaces_4[4] ); /* bounds check */ + + status("vaCreateSurfaces 16 surfaces\n"); + surfaces_16[16] = DEAD_SURFACE_ID; + va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 16, surfaces_16); + ASSERT( VA_STATUS_SUCCESS == va_status ); + ASSERT( DEAD_SURFACE_ID == surfaces_16[16] ); /* bounds check */ + + test_unique_surfaces(surfaces_1, 1, surfaces_4, 4); + test_unique_surfaces(surfaces_4, 4, surfaces_16, 4); + test_unique_surfaces(surfaces_4, 4, surfaces_16, 16); + test_unique_surfaces(surfaces_4, 1, surfaces_16, 16); + test_unique_surfaces(surfaces_1, 16, surfaces_16, 16); + + status("vaDestroySurface 4 surfaces\n"); + va_status = vaDestroySurfaces(va_dpy, surfaces_4, 4); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + status("vaCreateSurfaces 6 surfaces\n"); + surfaces_6[6] = DEAD_SURFACE_ID; + va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 6, surfaces_6); + ASSERT( VA_STATUS_SUCCESS == va_status ); + ASSERT( DEAD_SURFACE_ID == surfaces_6[6] ); /* bounds check */ + + test_unique_surfaces(surfaces_1, 1, surfaces_6, 6); + test_unique_surfaces(surfaces_6, 6, surfaces_16, 16); + test_unique_surfaces(surfaces_1, 6, surfaces_16, 6); + + status("vaDestroySurface 16 surfaces\n"); + va_status = vaDestroySurfaces(va_dpy, surfaces_16, 16); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + status("vaDestroySurface 1 surface\n"); + va_status = vaDestroySurfaces(va_dpy, surfaces_1, 1); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + status("vaDestroySurface 6 surfaces\n"); + va_status = vaDestroySurfaces(va_dpy, surfaces_6, 6); + ASSERT( VA_STATUS_SUCCESS == va_status ); +} + +void post() +{ + test_terminate(); +} diff --git a/test/basic/test_08.c b/test/basic/test_08.c new file mode 100644 index 0000000..8c743b6 --- /dev/null +++ b/test/basic/test_08.c @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2007 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. + */ + +#define TEST_DESCRIPTION "Create and destory surfaces of different sizes" + +#include "test_common.c" + +void pre() +{ + test_init(); +} + +#define DEAD_SURFACE_ID (VASurfaceID) 0xbeefdead + +void test_unique_surfaces(VASurfaceID *surface_list, int surface_count) +{ + int i,j; + + for(i = 0; i < surface_count; i++) + { + ASSERT(surface_list[i] != VA_INVALID_SURFACE); + for(j = 0; j < i; j++) + { + if (i == j) continue; + ASSERT(surface_list[i] != surface_list[j]); + } + } +} + +typedef struct test_size { int w; int h; } test_size_t; + +test_size_t test_sizes[] = { + { 10, 10 }, + { 128, 128 }, + { 176, 144 }, + { 144, 176 }, + { 352, 288 }, + { 399, 299 }, + { 640, 480 }, + { 1280, 720 } +}; + +#define NUM_SIZES (sizeof(test_sizes) / sizeof(test_size_t)) + +void test() +{ + VASurfaceID surfaces[NUM_SIZES+1]; + int i; + + memset(surfaces, 0xff, sizeof(surfaces)); + + for(i = 0; i < NUM_SIZES; i++) + { + status("vaCreateSurfaces create %dx%d surface\n", test_sizes[i].w, test_sizes[i].h); + surfaces[i+1] = DEAD_SURFACE_ID; + va_status = vaCreateSurfaces(va_dpy, test_sizes[i].w, test_sizes[i].h, VA_RT_FORMAT_YUV420, 1, &surfaces[i]); + ASSERT( VA_STATUS_SUCCESS == va_status ); + ASSERT( DEAD_SURFACE_ID == surfaces[i+1] ); + } + + test_unique_surfaces(surfaces, NUM_SIZES); + + status("vaDestroySurface all surfaces\n"); + va_status = vaDestroySurfaces(va_dpy, surfaces, NUM_SIZES); + ASSERT( VA_STATUS_SUCCESS == va_status ); +} + +void post() +{ + test_terminate(); +} diff --git a/test/basic/test_09.c b/test/basic/test_09.c new file mode 100644 index 0000000..7d6cd4b --- /dev/null +++ b/test/basic/test_09.c @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2007 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. + */ + +#define TEST_DESCRIPTION "Create/destroy contexts for all profiles / entrypoints" + +#include "test_common.c" + +void pre() +{ + test_init(); + test_profiles(); +} + +void test() +{ + int max_entrypoints; + int num_entrypoints; + int i, j, k; + int config_count = 0; + max_entrypoints = vaMaxNumEntrypoints(va_dpy); + ASSERT(max_entrypoints > 0); + VAEntrypoint *entrypoints = malloc(max_entrypoints * sizeof(VAEntrypoint)); + ASSERT(entrypoints); + + VAConfigID *configs = malloc(max_entrypoints * num_profiles * sizeof(VAConfigID)); + VAContextID *contexts = malloc(max_entrypoints * num_profiles * sizeof(VAContextID)); + + for(i = 0; i < num_profiles; i++) + { + va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + for(j = 0; j < num_entrypoints; j++) + { + status("vaCreateConfig for %s, %s\n", profile2string(profiles[i]), entrypoint2string(entrypoints[j])); + va_status = vaCreateConfig(va_dpy, profiles[i], entrypoints[j], NULL, 0, &(configs[config_count])); + ASSERT( VA_STATUS_SUCCESS == va_status ); + status("vaCreateConfig returns %08x\n", configs[config_count]); + config_count++; + } + } + + int width = 352; + int height = 288; + int surface_count = 4; + int total_surfaces = config_count * surface_count; + + VASurfaceID *surfaces = malloc(total_surfaces * sizeof(VASurfaceID)); + + // TODO: Don't assume VA_RT_FORMAT_YUV420 is supported / needed for each config + va_status = vaCreateSurfaces(va_dpy, width, height, VA_RT_FORMAT_YUV420, total_surfaces, surfaces); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + for(i = 0; i < config_count; i++) + { + status("vaCreateContext with config %08x\n", configs[i]); + int flags = 0; + va_status = vaCreateContext( va_dpy, configs[i], width, height, flags, surfaces + i*surface_count, surface_count, &contexts[i] ); + ASSERT( VA_STATUS_SUCCESS == va_status ); + } + + for(i = 0; i < config_count; i++) + { + status("vaDestroyContext for context %08x\n", contexts[i]); + va_status = vaDestroyContext( va_dpy, contexts[i] ); + ASSERT( VA_STATUS_SUCCESS == va_status ); + } + + for(i = 0; i < config_count; i++) + { + status("vaDestroyConfig for config %08x\n", configs[i]); + va_status = vaDestroyConfig( va_dpy, configs[i] ); + ASSERT( VA_STATUS_SUCCESS == va_status ); + } + + va_status = vaDestroySurfaces(va_dpy, surfaces, total_surfaces); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + free(contexts); + free(configs); + free(surfaces); + free(entrypoints); +} + +void post() +{ + test_terminate(); +} diff --git a/test/basic/test_10.c b/test/basic/test_10.c new file mode 100644 index 0000000..6a7b978 --- /dev/null +++ b/test/basic/test_10.c @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2007 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. + */ + +#define TEST_DESCRIPTION "Create and destroy buffers" + +#include "test_common.c" + +VAConfigID config; +VAContextID context; +VASurfaceID *surfaces; +int total_surfaces; + +void pre() +{ + test_init(); + + va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, NULL, 0, &config); + ASSERT( VA_STATUS_SUCCESS == va_status ); + status("vaCreateConfig returns %08x\n", config); + + int width = 352; + int height = 288; + int surface_count = 4; + total_surfaces = surface_count; + + surfaces = malloc(total_surfaces * sizeof(VASurfaceID)); + + // TODO: Don't assume VA_RT_FORMAT_YUV420 is supported / needed for each config + va_status = vaCreateSurfaces(va_dpy, width, height, VA_RT_FORMAT_YUV420, total_surfaces, surfaces); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + status("vaCreateContext with config %08x\n", config); + int flags = 0; + va_status = vaCreateContext( va_dpy, config, width, height, flags, surfaces, surface_count, &context ); + ASSERT( VA_STATUS_SUCCESS == va_status ); +} + +void test_unique_buffers(VABufferID *buffer_list, int buffer_count) +{ + int i,j; + + for(i = 0; i < buffer_count; i++) + { + for(j = 0; j < i; j++) + { + ASSERT(buffer_list[i] != buffer_list[j]); + } + } +} + +VABufferType buffer_types[] = +{ + VAPictureParameterBufferType, + VAIQMatrixBufferType, + VABitPlaneBufferType, + VASliceGroupMapBufferType, + VASliceParameterBufferType, + VASliceDataBufferType, + VAMacroblockParameterBufferType, + VAResidualDataBufferType, + VADeblockingParameterBufferType, +}; + +unsigned int buffer_sizes[] = +{ + sizeof(VAPictureParameterBufferMPEG4), + sizeof(VAIQMatrixBufferH264), + 32*1024, + 48*1024, + sizeof(VASliceParameterBufferMPEG2), + 128*1024, + sizeof(VAMacroblockParameterBufferMPEG2), + 32*1024, + 15*1024, +}; + + +#define NUM_BUFFER_TYPES (sizeof(buffer_types) / sizeof(VABufferType)) + +#define DEAD_BUFFER_ID ((VABufferID) 0x1234ffff) + +void test() +{ + VABufferID buffer_ids[NUM_BUFFER_TYPES+1]; + int i; + memset(buffer_ids, 0xff, sizeof(buffer_ids)); + for(i=0; i < NUM_BUFFER_TYPES; i++) + { + buffer_ids[i+1] = DEAD_BUFFER_ID; + va_status = vaCreateBuffer(va_dpy, context, buffer_types[i], buffer_sizes[i], 1, NULL, &buffer_ids[i]); + ASSERT( VA_STATUS_SUCCESS == va_status ); + ASSERT( DEAD_BUFFER_ID == buffer_ids[i+1] ); /* Bounds check */ + } + test_unique_buffers(buffer_ids, NUM_BUFFER_TYPES); + + for(i=0; i < NUM_BUFFER_TYPES; i++) + { + va_status = vaDestroyBuffer(va_dpy, buffer_ids[i]); + ASSERT( VA_STATUS_SUCCESS == va_status ); + } +} + +void post() +{ + status("vaDestroyContext for context %08x\n", context); + va_status = vaDestroyContext( va_dpy, context ); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + status("vaDestroyConfig for config %08x\n", config); + va_status = vaDestroyConfig( va_dpy, config ); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + va_status = vaDestroySurfaces(va_dpy, surfaces, total_surfaces); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + free(surfaces); + + test_terminate(); +} diff --git a/test/basic/test_11.c b/test/basic/test_11.c new file mode 100644 index 0000000..8f3c4b8 --- /dev/null +++ b/test/basic/test_11.c @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2007 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. + */ + +#define TEST_DESCRIPTION "Map and unmap buffers" + +#include "test_common.c" + +VAConfigID config; +VAContextID context; +VASurfaceID *surfaces; +int total_surfaces; + +void pre() +{ + test_init(); + + va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, NULL, 0, &config); + ASSERT( VA_STATUS_SUCCESS == va_status ); + status("vaCreateConfig returns %08x\n", config); + + int width = 352; + int height = 288; + int surface_count = 4; + total_surfaces = surface_count; + + surfaces = malloc(total_surfaces * sizeof(VASurfaceID)); + + // TODO: Don't assume VA_RT_FORMAT_YUV420 is supported / needed for each config + va_status = vaCreateSurfaces(va_dpy, width, height, VA_RT_FORMAT_YUV420, total_surfaces, surfaces); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + status("vaCreateContext with config %08x\n", config); + int flags = 0; + va_status = vaCreateContext( va_dpy, config, width, height, flags, surfaces, surface_count, &context ); + ASSERT( VA_STATUS_SUCCESS == va_status ); +} + +void test_unique_buffers(VABufferID *buffer_list, int buffer_count) +{ + int i,j; + + for(i = 0; i < buffer_count; i++) + { + for(j = 0; j < i; j++) + { + ASSERT(buffer_list[i] != buffer_list[j]); + } + } +} + +VABufferType buffer_types[] = +{ + VAPictureParameterBufferType, + VAIQMatrixBufferType, + VABitPlaneBufferType, + VASliceGroupMapBufferType, + VASliceParameterBufferType, + VASliceDataBufferType, + VAMacroblockParameterBufferType, + VAResidualDataBufferType, + VADeblockingParameterBufferType, +}; + +unsigned int buffer_sizes[] = +{ + sizeof(VAPictureParameterBufferMPEG4), + sizeof(VAIQMatrixBufferH264), + 32*1024, + 48*1024, + sizeof(VASliceParameterBufferMPEG2), + 128*1024, + sizeof(VAMacroblockParameterBufferMPEG2), + 32*1024, + 15*1024, +}; + + +#define NUM_BUFFER_TYPES (sizeof(buffer_types) / sizeof(VABufferType)) + +#define DEAD_BUFFER_ID ((VABufferID) 0x1234ffff) + +void test() +{ + VABufferID buffer_ids[NUM_BUFFER_TYPES+1]; + uint32_t *input_data[NUM_BUFFER_TYPES]; + int i, j; + memset(buffer_ids, 0xff, sizeof(buffer_ids)); + for(i=0; i < NUM_BUFFER_TYPES; i++) + { + uint32_t *data; + + input_data[i] = malloc(buffer_sizes[i]+4); + ASSERT(input_data[i]); + + /* Generate input data */ + for(j = buffer_sizes[i] / 4; j--;) + { + input_data[i][j] = random(); + } + + /* Copy to secondary buffer */ + data = malloc(buffer_sizes[i]); + ASSERT(data); + memcpy(data, input_data[i], buffer_sizes[i]); + + /* Create buffer and fill with data */ + va_status = vaCreateBuffer(va_dpy, context, buffer_types[i], buffer_sizes[i], 1, data, &buffer_ids[i]); + ASSERT( VA_STATUS_SUCCESS == va_status ); + status("vaCreateBuffer created buffer %08x of type %d\n", buffer_ids[i], buffer_types[i]); + + /* Wipe secondary buffer */ + memset(data, 0, buffer_sizes[i]); + free(data); + } + + for(i=0; i < NUM_BUFFER_TYPES; i++) + { + void *data = NULL; + /* Fetch VA Buffer */ + va_status = vaMapBuffer(va_dpy, buffer_ids[i], &data); + ASSERT( VA_STATUS_SUCCESS == va_status ); + status("vaMapBuffer mapped buffer %08x\n", buffer_ids[i]); + + /* Compare data */ + ASSERT( memcmp(input_data[i], data, buffer_sizes[i]) == 0 ); + } + + for(i=0; i < NUM_BUFFER_TYPES; i++) + { + va_status = vaUnmapBuffer(va_dpy, buffer_ids[i]); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + va_status = vaDestroyBuffer(va_dpy, buffer_ids[i]); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + free(input_data[i]); + } +} + + + +void post() +{ + status("vaDestroyContext for context %08x\n", context); + va_status = vaDestroyContext( va_dpy, context ); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + status("vaDestroyConfig for config %08x\n", config); + va_status = vaDestroyConfig( va_dpy, config ); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + va_status = vaDestroySurfaces(va_dpy, surfaces, total_surfaces); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + free(surfaces); + + test_terminate(); +} diff --git a/test/basic/test_common.c b/test/basic/test_common.c new file mode 100644 index 0000000..91774da --- /dev/null +++ b/test/basic/test_common.c @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2007 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 IN_LIBVA +#include +#else +#include +#endif + +#include "assert.h" +#include +#include +#include +#include +#include +#include + +#define ASSERT assert + +Display *dpy; +VADisplay va_dpy; +VAStatus va_status; +int major_version, minor_version; +int print_status = 0; +int num_profiles; +VAProfile *profiles = NULL; + +void pre(); +void test(); +void post(); + +void status(const char *msg, ...) +{ + if (!print_status) return; + va_list args; + printf("--- "); + va_start(args, msg); + vfprintf(stdout, msg, args); + va_end(args); +} + + +int main(int argc, const char* argv[]) +{ + const char *name = strrchr(argv[0], '/'); + if (name) + name++; + else + name = argv[0]; + printf("*** %s: %s\n", name, TEST_DESCRIPTION); + pre(); + print_status = 1; + test(); + print_status = 0; + post(); + printf("*** %s: Finished\n", name); + return 0; +} + +void test_init() +{ + dpy = XOpenDisplay(NULL); + ASSERT( dpy ); + status("XOpenDisplay: dpy = %08x\n", dpy); + + va_dpy = vaGetDisplay(dpy); + ASSERT( va_dpy ); + status("vaGetDisplay: va_dpy = %08x\n", va_dpy); + + va_status = vaInitialize(va_dpy, &major_version, &minor_version); + ASSERT( VA_STATUS_SUCCESS == va_status ); + status("vaInitialize: major = %d minor = %d\n", major_version, minor_version); +} + +void test_terminate() +{ + va_status = vaTerminate(va_dpy); + ASSERT( VA_STATUS_SUCCESS == va_status ); + status("vaTerminate\n"); + + XCloseDisplay(dpy); + status("XCloseDisplay\n"); + + if (profiles) + { + free(profiles); + profiles = NULL; + } +} + +#define PROFILE(profile) case VAProfile##profile: return("VAProfile" #profile); + +const char *profile2string(VAProfile profile) +{ + switch(profile) + { + PROFILE(MPEG2Simple) + PROFILE(MPEG2Main) + PROFILE(MPEG4Simple) + PROFILE(MPEG4AdvancedSimple) + PROFILE(MPEG4Main) + PROFILE(H264Baseline) + PROFILE(H264Main) + PROFILE(H264High) + PROFILE(VC1Simple) + PROFILE(VC1Main) + PROFILE(VC1Advanced) + } + ASSERT(0); + return "Unknown"; +} + +#define ENTRYPOINT(profile) case VAEntrypoint##profile: return("VAEntrypoint" #profile); + +const char *entrypoint2string(VAEntrypoint entrypoint) +{ + switch(entrypoint) + { + ENTRYPOINT(VLD) + ENTRYPOINT(IZZ) + ENTRYPOINT(IDCT) + ENTRYPOINT(MoComp) + ENTRYPOINT(Deblocking) + } + ASSERT(0); + return "Unknown"; +} + + +void test_profiles() +{ + int max_profiles; + int i; + max_profiles = vaMaxNumProfiles(va_dpy); + status("vaMaxNumProfiles = %d\n", max_profiles); + ASSERT(max_profiles > 0); + profiles = malloc(max_profiles * sizeof(VAProfile)); + ASSERT(profiles); + + va_status = vaQueryConfigProfiles(va_dpy, profiles, &num_profiles); + ASSERT( VA_STATUS_SUCCESS == va_status ); + + status("vaQueryConfigProfiles reports %d profiles\n", num_profiles); + ASSERT(num_profiles <= max_profiles); + ASSERT(num_profiles > 0); + + if (print_status) + { + for(i = 0; i < num_profiles; i++) + { + status(" profile %d [%s]\n", profiles[i], profile2string(profiles[i])); + } + } +} diff --git a/test/basic/testplan.txt b/test/basic/testplan.txt new file mode 100644 index 0000000..1cc573b --- /dev/null +++ b/test/basic/testplan.txt @@ -0,0 +1,106 @@ + +Test 1 +- Initialize & Terminate +- vaGetDisplay, vaInitialize, vaTerminate + +Test 2 +- Query profiles +- vaQueryConfigProfiles, vaMaxNumProfiles + +Test 3 +- Query Entrypoints for all profiles +- vaQueryConfigEntryPoints, vaMaxNumEntryPoints + +Test 4 +- Get Config attributes for all profiles / entrypoints +- vaGetConfigAttributes + +Test 5 +- Create & destroy config for each profile / entrypoint +- vaCreateConfig, vaDestroyConfig + +Test 6 +- Get config attributes of various possible configs +- vaQueryConfigAttributes, vaMaxNumConfigAttributes +- Check if results for vaGetConfigAttributes match with vaQueryConfigAttributes for +a given profile / entrypoint + +Test 7 +- Create and destroy surfaces +- vaCreateSurfaces, vaDestroySurface +- Create surfaces of 352 x 288 pixels +- Create 1, 4 and 16 surfaces, destroy 4, create 6 surfaces, destroy 16, 1 +and 6 surfaces. + +Test 8 +- Create and destroy surfaces of different sizes +- Create surfaces of 10 x 10 pixels, 128 x 128 pixels, 176 x 144 pixels, 144 x 176 +pixels, 352 x 288 pixels, 399 x 299 pixels, 640 x 480 pixels, 1280 x 720 +pixels + +Test 9 +- Create and destroy a context for each profile / entrypoint +- Pass 4 surfaces of 352 x 288 pixels +- vaCreateContext, vaDestroyContext +- See also Test 5 + +Test 10 +- Create and destroy buffers +- vaCreateBuffer, vaDestroyBuffer +- For each different buffertype, create a buffer, then destroy them one by +one. + +Test 11 +- Map & unmap buffers +- vaBufferData, vaMapBuffer, vaUnmapBuffer +- For each different buffertype, copy data to the buffer with vaBufferData. +Then map the buffer and verify the contents of the buffer. + +Test 12 +- Render single MPEG2 I-frame +- vaBeginPicture, vaRenderPicture (num_buffers == 1), vaEndPicture + +Test 13 +- Render single MPEG2 I-frame, multiple buffer submission +- vaRenderPicture (num_buffers > 1) + +Test 14 +- Render single MPEG2 I-frame, split buffers +- Slice split over 2 buffers + +Test 15 +- Render single MPEG2 I-frame, split buffers +- Slice split over 3 buffers + +Test 16 +- Sync Surface +- Render single MPEG2 I-frame, then check vaQuerySurfaceStatus, vaSyncSurface and vaQuerySurfaceStatus + +Test 17 +- Query image formats +- vaMaxNumImageFormats, vaQueryImageFormats + +Test 18 +- Create and destroy vaImage +- vaCreateImage, vaDestroyImage + +Test 19 +- Get image data +- Render single MPEG2 I-frame, copy surface data to image, check resulting +image +- vaGetImage + +Test 20 +- Put image data +- Render single MPEG2 I-frame, copy half of a VAImage to surface, copy +surface back to VAImage, check resulting image +- vaPutImage + +Test 21 +- Query subpicture formats +- vaMaxNumSubpictureFormats, vaQuerySubpictureFromats + +Test 22 +- Create and destory subpictures +- vaCreateSubpicture, vaDestroySubpicture + diff --git a/test/decode/Makefile.am b/test/decode/Makefile.am new file mode 100644 index 0000000..9283671 --- /dev/null +++ b/test/decode/Makefile.am @@ -0,0 +1,36 @@ +# Copyright (c) 2007 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. + +bin_PROGRAMS = mpeg2vldemo + +AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/x11 -DIN_LIBVA + +TEST_LIBS = $(top_srcdir)/src/$(libvabackendlib) + +mpeg2vldemo_LDADD = $(TEST_LIBS) +mpeg2vldemo_SOURCES = mpeg2vldemo.c + + +valgrind: $(bin_PROGRAMS) + for a in $(bin_PROGRAMS); do \ + valgrind --leak-check=full --show-reachable=yes .libs/$$a; \ + done diff --git a/test/decode/mpeg2-I.gif b/test/decode/mpeg2-I.gif new file mode 100644 index 0000000..81a25eb Binary files /dev/null and b/test/decode/mpeg2-I.gif differ diff --git a/test/decode/mpeg2-I.m2v b/test/decode/mpeg2-I.m2v new file mode 100644 index 0000000..f00fa01 Binary files /dev/null and b/test/decode/mpeg2-I.m2v differ diff --git a/test/decode/mpeg2vldemo.c b/test/decode/mpeg2vldemo.c new file mode 100644 index 0000000..945b69d --- /dev/null +++ b/test/decode/mpeg2vldemo.c @@ -0,0 +1,286 @@ +/* + * Copyright (c) 2007-2008 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. + */ + +/* + * it is a real program to show how VAAPI decode work, + * It does VLD decode for a simple MPEG2 clip "mpeg2-I.m2v" + * "mpeg2-I.m2v" and VA parameters are hardcoded into mpeg2vldemo.c, + * See mpeg2-I.jif to know how those VA parameters come from + * + * gcc -o mpeg2vldemo mpeg2vldemo.c -lva -lva-x11 + * ./mpeg2vldemo : only do decode + * ./mpeg2vldemo : decode+display + * + */ +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include +#include + +#define CHECK_VASTATUS(va_status,func) \ +if (va_status != VA_STATUS_SUCCESS) { \ + fprintf(stderr,"%s:%s (%d) failed,exit\n", __func__, func, __LINE__); \ + exit(1); \ +} + +/* Data dump of a 16x16 MPEG2 video clip,it has one I frame + */ +static unsigned char mpeg2_clip[]={ + 0x00,0x00,0x01,0xb3,0x01,0x00,0x10,0x13,0xff,0xff,0xe0,0x18,0x00,0x00,0x01,0xb5, + 0x14,0x8a,0x00,0x01,0x00,0x00,0x00,0x00,0x01,0xb8,0x00,0x08,0x00,0x00,0x00,0x00, + 0x01,0x00,0x00,0x0f,0xff,0xf8,0x00,0x00,0x01,0xb5,0x8f,0xff,0xf3,0x41,0x80,0x00, + 0x00,0x01,0x01,0x13,0xe1,0x00,0x15,0x81,0x54,0xe0,0x2a,0x05,0x43,0x00,0x2d,0x60, + 0x18,0x01,0x4e,0x82,0xb9,0x58,0xb1,0x83,0x49,0xa4,0xa0,0x2e,0x05,0x80,0x4b,0x7a, + 0x00,0x01,0x38,0x20,0x80,0xe8,0x05,0xff,0x60,0x18,0xe0,0x1d,0x80,0x98,0x01,0xf8, + 0x06,0x00,0x54,0x02,0xc0,0x18,0x14,0x03,0xb2,0x92,0x80,0xc0,0x18,0x94,0x42,0x2c, + 0xb2,0x11,0x64,0xa0,0x12,0x5e,0x78,0x03,0x3c,0x01,0x80,0x0e,0x80,0x18,0x80,0x6b, + 0xca,0x4e,0x01,0x0f,0xe4,0x32,0xc9,0xbf,0x01,0x42,0x69,0x43,0x50,0x4b,0x01,0xc9, + 0x45,0x80,0x50,0x01,0x38,0x65,0xe8,0x01,0x03,0xf3,0xc0,0x76,0x00,0xe0,0x03,0x20, + 0x28,0x18,0x01,0xa9,0x34,0x04,0xc5,0xe0,0x0b,0x0b,0x04,0x20,0x06,0xc0,0x89,0xff, + 0x60,0x12,0x12,0x8a,0x2c,0x34,0x11,0xff,0xf6,0xe2,0x40,0xc0,0x30,0x1b,0x7a,0x01, + 0xa9,0x0d,0x00,0xac,0x64 +}; + +/* hardcoded here without a bitstream parser helper + * please see picture mpeg2-I.jpg for bitstream details + */ +static VAPictureParameterBufferMPEG2 pic_param={ + horizontal_size:16, + vertical_size:16, + forward_reference_picture:0xffffffff, + backward_reference_picture:0xffffffff, + picture_coding_type:1, + f_code:0xffff, + { + { + intra_dc_precision:0, + picture_structure:3, + top_field_first:0, + frame_pred_frame_dct:1, + concealment_motion_vectors:0, + q_scale_type:0, + intra_vlc_format:0, + alternate_scan:0, + repeat_first_field:0, + progressive_frame:1 , + is_first_field:1 + }, + } +}; + +/* see MPEG2 spec65 for the defines of matrix */ +static VAIQMatrixBufferMPEG2 iq_matrix = { + load_intra_quantiser_matrix:1, + load_non_intra_quantiser_matrix:1, + load_chroma_intra_quantiser_matrix:0, + load_chroma_non_intra_quantiser_matrix:0, + intra_quantiser_matrix:{ + 8, 16, 16, 19, 16, 19, 22, 22, + 22, 22, 22, 22, 26, 24, 26, 27, + 27, 27, 26, 26, 26, 26, 27, 27, + 27, 29, 29, 29, 34, 34, 34, 29, + 29, 29, 27, 27, 29, 29, 32, 32, + 34, 34, 37, 38, 37, 35, 35, 34, + 35, 38, 38, 40, 40, 40, 48, 48, + 46, 46, 56, 56, 58, 69, 69, 83 + }, + non_intra_quantiser_matrix:{16}, + chroma_intra_quantiser_matrix:{0}, + chroma_non_intra_quantiser_matrix:{0} +}; + +static VASliceParameterBufferMPEG2 slice_param={ + slice_data_size:150, + slice_data_offset:0, + slice_data_flag:0, + macroblock_offset:38,/* 4byte + 6bits=38bits */ + slice_vertical_position:0, + quantiser_scale_code:2, + intra_slice_flag:0 +}; + +#define CLIP_WIDTH 16 +#define CLIP_HEIGHT 16 + +#define WIN_WIDTH (CLIP_WIDTH<<1) +#define WIN_HEIGHT (CLIP_HEIGHT<<1) + +int main(int argc,char **argv) +{ + VAEntrypoint entrypoints[5]; + int num_entrypoints,vld_entrypoint; + VAConfigAttrib attrib; + VAConfigID config_id; + VASurfaceID surface_id; + 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; + + 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_status = vaInitialize(va_dpy, &major_ver, &minor_ver); + assert(va_status == VA_STATUS_SUCCESS); + + va_status = vaQueryConfigEntrypoints(va_dpy, VAProfileMPEG2Main, entrypoints, + &num_entrypoints); + CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints"); + + for (vld_entrypoint = 0; vld_entrypoint < num_entrypoints; vld_entrypoint++) { + if (entrypoints[vld_entrypoint] == VAEntrypointVLD) + break; + } + if (vld_entrypoint == num_entrypoints) { + /* not find VLD entry point */ + assert(0); + } + + /* Assuming finding VLD, find out the format for the render target */ + attrib.type = VAConfigAttribRTFormat; + vaGetConfigAttributes(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, + &attrib, 1); + if ((attrib.value & VA_RT_FORMAT_YUV420) == 0) { + /* not find desired YUV420 RT format */ + assert(0); + } + + va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, + &attrib, 1,&config_id); + CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints"); + + va_status = vaCreateSurfaces(va_dpy,CLIP_WIDTH,CLIP_HEIGHT, + VA_RT_FORMAT_YUV420, 1, &surface_id); + CHECK_VASTATUS(va_status, "vaCreateSurfaces"); + + /* Create a context for this decode pipe */ + va_status = vaCreateContext(va_dpy, config_id, + CLIP_WIDTH, + ((CLIP_HEIGHT+15)/16)*16, + VA_PROGRESSIVE, + &surface_id, + 1, + &context_id); + CHECK_VASTATUS(va_status, "vaCreateContext"); + + va_status = vaCreateBuffer(va_dpy, context_id, + VAPictureParameterBufferType, + sizeof(VAPictureParameterBufferMPEG2), + 1, &pic_param, + &pic_param_buf); + CHECK_VASTATUS(va_status, "vaCreateBuffer"); + + va_status = vaCreateBuffer(va_dpy, context_id, + VAIQMatrixBufferType, + sizeof(VAIQMatrixBufferMPEG2), + 1, &iq_matrix, + &iqmatrix_buf ); + CHECK_VASTATUS(va_status, "vaCreateBuffer"); + + va_status = vaCreateBuffer(va_dpy, context_id, + VASliceParameterBufferType, + sizeof(VASliceParameterBufferMPEG2), + 1, + &slice_param, &slice_param_buf); + CHECK_VASTATUS(va_status, "vaCreateBuffer"); + + va_status = vaCreateBuffer(va_dpy, context_id, + VASliceDataBufferType, + 0xc4-0x2f+1, + 1, + mpeg2_clip+0x2f, + &slice_data_buf); + CHECK_VASTATUS(va_status, "vaCreateBuffer"); + + va_status = vaBeginPicture(va_dpy, context_id, surface_id); + CHECK_VASTATUS(va_status, "vaBeginPicture"); + + va_status = vaRenderPicture(va_dpy,context_id, &pic_param_buf, 1); + CHECK_VASTATUS(va_status, "vaRenderPicture"); + + va_status = vaRenderPicture(va_dpy,context_id, &iqmatrix_buf, 1); + CHECK_VASTATUS(va_status, "vaRenderPicture"); + + va_status = vaRenderPicture(va_dpy,context_id, &slice_param_buf, 1); + CHECK_VASTATUS(va_status, "vaRenderPicture"); + + va_status = vaRenderPicture(va_dpy,context_id, &slice_data_buf, 1); + CHECK_VASTATUS(va_status, "vaRenderPicture"); + + va_status = vaEndPicture(va_dpy,context_id); + CHECK_VASTATUS(va_status, "vaEndPicture"); + + va_status = vaSyncSurface(va_dpy, surface_id); + CHECK_VASTATUS(va_status, "vaSyncSurface"); + + if (putsurface) { + 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); + CHECK_VASTATUS(va_status, "vaPutSurface"); + } + + printf("press any key to exit\n"); + getchar(); + + vaDestroySurfaces(va_dpy,&surface_id,1); + vaDestroyConfig(va_dpy,config_id); + vaDestroyContext(va_dpy,context_id); + + vaTerminate(va_dpy); + XCloseDisplay(x11_display); + + return 0; +} diff --git a/test/encode/Makefile.am b/test/encode/Makefile.am new file mode 100644 index 0000000..6d2d5a9 --- /dev/null +++ b/test/encode/Makefile.am @@ -0,0 +1,36 @@ +# Copyright (c) 2007 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. + +bin_PROGRAMS = h264encode + +AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/x11 -DIN_LIBVA + +TEST_LIBS = $(top_srcdir)/src/$(libvabackendlib) + +h264encode_LDADD = $(TEST_LIBS) +h264encode_SOURCES = h264encode.c + + +valgrind: $(bin_PROGRAMS) + for a in $(bin_PROGRAMS); do \ + valgrind --leak-check=full --show-reachable=yes .libs/$$a; \ + done diff --git a/test/encode/h264encode.c b/test/encode/h264encode.c new file mode 100644 index 0000000..4a4d914 --- /dev/null +++ b/test/encode/h264encode.c @@ -0,0 +1,428 @@ +/* + * Copyright (c) 2007-2008 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. + */ + +/* + * it is a real program to show how VAAPI encoding work, + * It does H264 element stream level encoding on auto-generated YUV data + * + * gcc -o h264encode h264encode -lva -lva-x11 -I /usr/include/va + * ./h264encode -w -h -n + * + */ +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include "va.h" +#include "va_x11.h" + + +#define CHECK_VASTATUS(va_status,func) \ +if (va_status != VA_STATUS_SUCCESS) { \ + fprintf(stderr,"%s:%s (%d) failed,exit\n", __func__, func, __LINE__); \ + exit(1); \ +} + +#define SURFACE_NUM 18 /* 16 surfaces for src, 2 surface for reconstructed/reference */ + +static Display *x11_display; +static VADisplay va_dpy; +static VAContextID context_id; +static VASurfaceID surface_id[SURFACE_NUM]; +static Window display_win = 0; +static int win_width; +static int win_height; + +static int coded_fd; +static char coded_file[256]; + +static int frame_width=352, frame_height=288; +static int frame_rate = 30; +static int frame_count = 1000; +static int intra_count = 30; +static int frame_bitrate = 64000; +static int initial_qp = 15; +static int minimal_qp = 0; + +static int upload_source_YUV_once_for_all() +{ + VAImage surface_image; + void *surface_p=NULL, *U_start,*V_start; + VAStatus va_status; + int box_width=8; + int row_shift=0; + int i; + + for (i=0; i\n"); + printf(" -w -h: resolution\n"); + printf(" -n frame number\n"); + printf(" -p P frame count between two I frames\n"); + printf(" -f frame rate\n"); + printf(" -r bit rate\n"); + printf(" -q initial QP\n"); + printf(" -s maximum QP\n"); + printf(" -s coded file\n"); + exit(0); + } + } + + x11_display = XOpenDisplay(":0.0"); + assert(x11_display); + + va_dpy = vaGetDisplay(x11_display); + va_status = vaInitialize(va_dpy, &major_ver, &minor_ver); + CHECK_VASTATUS(va_status, "vaInitialize"); + + vaQueryConfigEntrypoints(va_dpy, VAProfileH264Baseline, entrypoints, + &num_entrypoints); + for (slice_entrypoint = 0; slice_entrypoint < num_entrypoints; slice_entrypoint++) { + if (entrypoints[slice_entrypoint] == VAEntrypointEncSlice) + break; + } + if (slice_entrypoint == num_entrypoints) { + /* not find Slice entry point */ + assert(0); + } + + /* find out the format for the render target, and rate control mode */ + attrib[0].type = VAConfigAttribRTFormat; + attrib[1].type = VAConfigAttribRateControl; + vaGetConfigAttributes(va_dpy, VAProfileH264Baseline, VAEntrypointEncSlice, + &attrib[0], 2); + if ((attrib[0].value & VA_RT_FORMAT_YUV420) == 0) { + /* not find desired YUV420 RT format */ + assert(0); + } + if ((attrib[1].value & VA_RC_VBR) == 0) { + /* Can't find matched RC mode */ + printf("VBR mode doesn't found, exit\n"); + assert(0); + } + attrib[0].value = VA_RT_FORMAT_YUV420; /* set to desired RT format */ + attrib[1].value = VA_RC_VBR; /* set to desired RC mode */ + + va_status = vaCreateConfig(va_dpy, VAProfileH264Baseline, VAEntrypointEncSlice, + &attrib[0], 2,&config_id); + CHECK_VASTATUS(va_status, "vaCreateConfig"); + + va_status = vaCreateSurfaces(va_dpy,frame_width, frame_height, + VA_RT_FORMAT_YUV420, SURFACE_NUM, &surface_id[0]); + CHECK_VASTATUS(va_status, "vaCreateSurfaces"); + + /* Create a context for this decode pipe */ + va_status = vaCreateContext(va_dpy, config_id, + frame_width, ((frame_height+15)/16)*16, + VA_PROGRESSIVE,&surface_id[0],SURFACE_NUM,&context_id); + CHECK_VASTATUS(va_status, "vaCreateContext"); + + /* store coded data into a file */ + coded_fd = open(coded_file,O_CREAT|O_RDWR, 0); + if (coded_fd == -1) { + printf("Open file %s failed, exit\n", coded_file); + exit(1); + } + + printf("Coded %d frames, %dx%d, save the coded file into %s\n", + frame_count, frame_width, frame_height, coded_file); + do_h264_encoding(); + + vaDestroySurfaces(va_dpy,&surface_id[0],3); + vaDestroyConfig(va_dpy,config_id); + vaDestroyContext(va_dpy,context_id); + + vaTerminate(va_dpy); + + XCloseDisplay(x11_display); + + return 0; +} diff --git a/test/mpeg2-I.jpg b/test/mpeg2-I.jpg deleted file mode 100644 index f5a6c50..0000000 Binary files a/test/mpeg2-I.jpg and /dev/null differ diff --git a/test/mpeg2-I.mpg b/test/mpeg2-I.mpg deleted file mode 100644 index f00fa01..0000000 Binary files a/test/mpeg2-I.mpg and /dev/null differ diff --git a/test/putsurface/Makefile.am b/test/putsurface/Makefile.am new file mode 100644 index 0000000..3e5c864 --- /dev/null +++ b/test/putsurface/Makefile.am @@ -0,0 +1,36 @@ +# Copyright (c) 2007 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. + +bin_PROGRAMS = putsurface + +AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/x11 -DIN_LIBVA + +TEST_LIBS = $(top_srcdir)/src/$(libvabackendlib) + +putsurface_LDADD = $(TEST_LIBS) +putsurface_SOURCES = putsurface.c + + +valgrind: $(bin_PROGRAMS) + for a in $(bin_PROGRAMS); do \ + valgrind --leak-check=full --show-reachable=yes .libs/$$a; \ + done diff --git a/test/putsurface/loadsurface.h b/test/putsurface/loadsurface.h new file mode 100644 index 0000000..4c5da2d --- /dev/null +++ b/test/putsurface/loadsurface.h @@ -0,0 +1,97 @@ + + +static int yuvgen_planar(int width, int height, + unsigned char *Y_start, int Y_pitch, + unsigned char *U_start, int U_pitch, + unsigned char *V_start, int V_pitch, + int UV_interleave, int box_width, int row_shift, + int field) +{ + int row; + + /* copy Y plane */ + for (row=0;row +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include + +#include + +#include + +/*currently, if XCheckWindowEvent was called in more than one thread, it would cause + * XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0" + * after 87 requests (83 known processed) with 0 events remaining. + * + * X Error of failed request: BadGC (invalid GC parameter) + * Major opcode of failed request: 60 (X_FreeGC) + * Resource id in failed request: 0x600034 + * Serial number of failed request: 398 + * Current serial number in output stream: 399 + * The root cause is unknown. */ + +#define CHECK_VASTATUS(va_status,func) \ +if (va_status != VA_STATUS_SUCCESS) { \ + fprintf(stderr,"%s:%s (%d) failed,exit\n", __func__, func, __LINE__); \ + exit(1); \ +} + +#include "loadsurface.h" + + +#define SURFACE_NUM 5 +static VASurfaceID surface_id[SURFACE_NUM]; +static int surface_width=352, surface_height=288; +static int win_width=352, win_height=288; +static Window win_thread0, win_thread1; +static Pixmap pixmap_thread0, pixmap_thread1; +static GC context_thread0, context_thread1; +static Display *x11_display; +static VADisplay *va_dpy; +static int multi_thread=0; +static int put_pixmap = 0; +static int test_clip = 1; +static int display_field = VA_FRAME_PICTURE; +static int check_event = 1; +static int verbose=0; +static pthread_mutex_t surface_mutex[SURFACE_NUM]; + +static pthread_mutex_t gmutex; + +static int box_width=32; + +static Pixmap create_pixmap(int width, int height) +{ + int screen = DefaultScreen(x11_display); + Window root; + Pixmap pixmap; + XWindowAttributes attr; + + root = RootWindow(x11_display, screen); + + XGetWindowAttributes (x11_display, root, &attr); + + printf("Create a pixmap from ROOT window %dx%d\n\n", attr.width, attr.height); + pixmap = XCreatePixmap(x11_display, root, attr.width, attr.height, + DefaultDepth(x11_display, DefaultScreen(x11_display))); + + return pixmap; +} + +static int create_window(int width, int height) +{ + int screen = DefaultScreen(x11_display); + Window root, win; + + root = RootWindow(x11_display, screen); + + printf("Create window0 for thread0\n"); + win_thread0 = win = XCreateSimpleWindow(x11_display, root, 0, 0, width, height, + 0, 0, WhitePixel(x11_display, 0)); + if (win) { + XSizeHints sizehints; + sizehints.width = width; + sizehints.height = height; + sizehints.flags = USSize; + XSetNormalHints(x11_display, win, &sizehints); + XSetStandardProperties(x11_display, win, "Thread 0", "Thread 0", + None, (char **)NULL, 0, &sizehints); + + XMapWindow(x11_display, win); + } + context_thread0 = XCreateGC(x11_display, win, 0, 0); + XSelectInput(x11_display, win, KeyPressMask | StructureNotifyMask); + XSync(x11_display, False); + + if (put_pixmap) + pixmap_thread0 = create_pixmap(width, height); + + if (multi_thread == 0) + return 0; + + printf("Create window1 for thread1\n"); + + win_thread1 = win = XCreateSimpleWindow(x11_display, root, width, 0, width, height, + 0, 0, WhitePixel(x11_display, 0)); + if (win) { + XSizeHints sizehints; + sizehints.width = width; + sizehints.height = height; + sizehints.flags = USSize; + XSetNormalHints(x11_display, win, &sizehints); + XSetStandardProperties(x11_display, win, "Thread 1", "Thread 1", + None, (char **)NULL, 0, &sizehints); + + XMapWindow(x11_display, win); + } + if (put_pixmap) + pixmap_thread1 = create_pixmap(width, height); + + context_thread1 = XCreateGC(x11_display, win, 0, 0); + XSelectInput(x11_display, win, KeyPressMask | StructureNotifyMask); + XSync(x11_display, False); + + return 0; +} + +static VASurfaceID get_next_free_surface(int *index) +{ + VASurfaceStatus surface_status; + int i; + + assert(index); + + for (i=0; i\n"); + printf(" -p output to pixmap\n"); + printf(" -d the dimension of black/write square box, default is 32\n"); + printf(" -t multi-threads\n"); + printf(" -e don't check X11 event\n"); + printf(" -c test clipbox\n"); + printf(" -f <1/2> top field, or bottom field\n"); + printf(" -v verbose output\n"); + exit(0); + break; + case 'w': + win_width = atoi(optarg); + break; + case 'h': + win_height = atoi(optarg); + break; + case 'd': + box_width = atoi(optarg); + break; + case 't': + multi_thread = 1; + printf("Two threads to do vaPutSurface\n"); + break; + case 'e': + check_event = 0; + break; + case 'p': + put_pixmap = 1; + break; + case 'c': + test_clip = 1; + break; + case 'f': + if (atoi(optarg) == 1) { + printf("Display TOP field\n"); + display_field = VA_TOP_FIELD; + } else if (atoi(optarg) == 2) { + printf("Display BOTTOM field\n"); + display_field = VA_BOTTOM_FIELD; + } else + printf("The validate input for -f is: 1(top field)/2(bottom field)\n"); + break; + case 'v': + verbose = 1; + printf("Enable verbose output\n"); + break; + } + } + + x11_display = XOpenDisplay(":0.0"); + if (x11_display == NULL) { + fprintf(stderr, "Can't connect X server!\n"); + exit(-1); + } + + create_window(win_width, win_height); + + va_dpy = vaGetDisplay(x11_display); + va_status = vaInitialize(va_dpy, &major_ver, &minor_ver); + CHECK_VASTATUS(va_status, "vaInitialize"); + + surface_width = win_width; + surface_height = win_height; + va_status = vaCreateSurfaces(va_dpy,surface_width, surface_height, + VA_RT_FORMAT_YUV420, SURFACE_NUM, &surface_id[0]); + CHECK_VASTATUS(va_status, "vaCreateSurfaces"); + + if (check_event) + pthread_mutex_init(&gmutex, NULL); + + for(i = 0; i< SURFACE_NUM; i++) + pthread_mutex_init(&surface_mutex[i], NULL); + + if (multi_thread == 1) + ret = pthread_create(&thread1, NULL, (void *)putsurface_thread, (void*)win_thread1); + + putsurface_thread((void *)win_thread0); + + if (multi_thread == 1) + pthread_join(thread1, (void **)&ret); + + vaDestroySurfaces(va_dpy,&surface_id[0],SURFACE_NUM); + vaTerminate(va_dpy); + + return 0; +} diff --git a/test/test.c b/test/test.c deleted file mode 100644 index 2e98b12..0000000 --- a/test/test.c +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2007 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 IN_LIBVA -#include -#else -#include -#endif - -#include "assert.h" -#include -#include -#include -#include - -#define ASSERT assert - -int main(int argc, const char* argv[]) -{ - Display *dpy; - VADisplay va_dpy; - VAStatus va_status; - int major_version, minor_version; - - dpy = XOpenDisplay(NULL); - ASSERT( dpy ); - printf("XOpenDisplay: dpy = %08x\n", dpy); - - va_dpy = vaGetDisplay(dpy); - ASSERT( va_dpy ); - printf("vaGetDisplay: va_dpy = %08x\n", va_dpy); - - va_status = vaInitialize(va_dpy, &major_version, &minor_version); - ASSERT( VA_STATUS_SUCCESS == va_status ); - printf("vaInitialize: major = %d minor = %d\n", major_version, minor_version); - - { - VASurfaceID surfaces[21]; - int i; - - surfaces[20] = -1; - va_status = vaCreateSurfaces(va_dpy, 720, 480, VA_RT_FORMAT_YUV420, 20, surfaces); - ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( -1 == surfaces[20] ); /* bounds check */ - for(i = 0; i < 20; i++) - { - printf("Surface %d surface_id = %08x\n", i, surfaces[i]); - } - Window win = XCreateSimpleWindow(dpy, RootWindow(dpy, 0), 0, 0, 720, 480, 0, 0, WhitePixel(dpy, 0)); - printf("Window = %08x\n", win); - XMapWindow(dpy, win); - XSync(dpy, False); - - vaPutSurface(va_dpy, surfaces[0], win, 0, 0, 720, 480, 0, 0, 720, 480, 0); - - sleep(10); - va_status = vaDestroySurface(va_dpy, surfaces, 20); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } - - { - int num_profiles; - int i; - VAProfile *profiles = malloc(vaMaxNumProfiles(va_dpy) * sizeof(VAProfile)); - ASSERT(profiles); - printf("vaMaxNumProfiles = %d\n", vaMaxNumProfiles(va_dpy)); - - va_status = vaQueryConfigProfiles(va_dpy, profiles, &num_profiles); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - printf("vaQueryConfigProfiles reports %d profiles\n", num_profiles); - for(i = 0; i < num_profiles; i++) - { - printf("Profile %d\n", profiles[i]); - } - } - - { - VASurfaceID surfaces[20]; - VAContextID context; - VAConfigAttrib attrib; - VAConfigID config_id; - int i; - - attrib.type = VAConfigAttribRTFormat; - va_status = vaGetConfigAttributes(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, - &attrib, 1); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - ASSERT(attrib.value & VA_RT_FORMAT_YUV420); - /* Found desired RT format, keep going */ - - va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, &attrib, 1, - &config_id); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaCreateSurfaces(va_dpy, 720, 480, VA_RT_FORMAT_YUV420, 20, surfaces); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaCreateContext(va_dpy, config_id, 720, 480, 0 /* flag */, surfaces, 20, &context); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaDestroyContext(va_dpy, context); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaDestroySurface(va_dpy, surfaces, 20); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } - - { - VABufferID picture_buf[3]; - va_status = vaCreateBuffer(va_dpy, VAPictureParameterBufferType, &picture_buf[0]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - va_status = vaCreateBuffer(va_dpy, VAPictureParameterBufferType, &picture_buf[1]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - va_status = vaCreateBuffer(va_dpy, VAPictureParameterBufferType, &picture_buf[2]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaDestroyBuffer(va_dpy, picture_buf[0]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - va_status = vaDestroyBuffer(va_dpy, picture_buf[2]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - va_status = vaDestroyBuffer(va_dpy, picture_buf[1]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } - - va_status = vaTerminate(va_dpy); - ASSERT( VA_STATUS_SUCCESS == va_status ); - printf("vaTerminate\n"); - - XCloseDisplay(dpy); - - return 0; -} diff --git a/test/test_01.c b/test/test_01.c deleted file mode 100644 index 4075655..0000000 --- a/test/test_01.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2007 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. - */ - -#define TEST_DESCRIPTION "Initialize & Terminate" - -#include "test_common.c" - -void pre() -{ -} - -void post() -{ -} - -void test() -{ - test_init(); - - test_terminate(); -} diff --git a/test/test_02.c b/test/test_02.c deleted file mode 100644 index 5622a18..0000000 --- a/test/test_02.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2007 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. - */ - -#define TEST_DESCRIPTION "Query profiles" - -#include "test_common.c" - -void pre() -{ - test_init(); -} - -void test() -{ - test_profiles(); -} - -void post() -{ - test_terminate(); -} diff --git a/test/test_03.c b/test/test_03.c deleted file mode 100644 index d2af494..0000000 --- a/test/test_03.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2007 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. - */ - -#define TEST_DESCRIPTION "Query entrypoints for all profiles" - -#include "test_common.c" - -void pre() -{ - test_init(); - test_profiles(); -} - -void test() -{ - int max_entrypoints; - int num_entrypoints; - int i, j; - max_entrypoints = vaMaxNumEntrypoints(va_dpy); - status("vaMaxEntryPoints = %d\n", max_entrypoints); - ASSERT(max_entrypoints > 0); - - VAEntrypoint *entrypoints = malloc(max_entrypoints * sizeof(VAEntrypoint)); - ASSERT(entrypoints); - - for(i = 0; i < num_profiles; i++) - { - memset(entrypoints, 0xff, max_entrypoints * sizeof(VAEntrypoint)); - va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaQueryConfigEntryPoints(%s) reports %d entrypoints\n", profile2string(profiles[i]), num_entrypoints); - ASSERT(num_entrypoints <= max_entrypoints); - ASSERT(num_entrypoints > 0); - for(j = 0; j < num_entrypoints; j++) - { - status(" entrypoint %d [%s]\n", entrypoints[j], entrypoint2string(entrypoints[j])); - } - } - - free(entrypoints); -} - -void post() -{ - test_terminate(); -} diff --git a/test/test_04.c b/test/test_04.c deleted file mode 100644 index 2e3329c..0000000 --- a/test/test_04.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2007 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. - */ - -#define TEST_DESCRIPTION "Get config attributes for all profiles / entrypoints" - -#include "test_common.c" - -void pre() -{ - test_init(); - test_profiles(); -} - -#define DEADVALUE 0xdeaddead - -void test() -{ - VAConfigAttrib attributes[] = { - { type: VAConfigAttribRTFormat, value: DEADVALUE }, - { type: VAConfigAttribSpatialResidual, value: DEADVALUE }, - { type: VAConfigAttribSpatialClipping, value: DEADVALUE }, - { type: VAConfigAttribIntraResidual, value: DEADVALUE }, - { type: VAConfigAttribEncryption, value: DEADVALUE } - }; - int max_entrypoints; - int num_entrypoints; - int num_attribs = sizeof(attributes) / sizeof(VAConfigAttrib); - int i, j, k; - max_entrypoints = vaMaxNumEntrypoints(va_dpy); - ASSERT(max_entrypoints > 0); - VAEntrypoint *entrypoints = malloc(max_entrypoints * sizeof(VAEntrypoint)); - ASSERT(entrypoints); - - VAConfigAttrib *attrib_list = (VAConfigAttrib *) malloc(sizeof(attributes)); - ASSERT(attrib_list); - - for(i = 0; i < num_profiles; i++) - { - va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - for(j = 0; j < num_entrypoints; j++) - { - memcpy(attrib_list, attributes, sizeof(attributes)); - status("vaGetConfigAttributes for %s, %s\n", profile2string(profiles[i]), entrypoint2string(entrypoints[j])); - va_status = vaGetConfigAttributes(va_dpy, profiles[i], entrypoints[j], attrib_list, num_attribs); - ASSERT( VA_STATUS_SUCCESS == va_status ); - for(k = 0; k < num_attribs; k++) - { - status(" %d -> %08x\n", attrib_list[k].type, attrib_list[k].value); - ASSERT(attrib_list[k].value != DEADVALUE); - } - } - } - - free(attrib_list); - free(entrypoints); -} - -void post() -{ - test_terminate(); -} diff --git a/test/test_05.c b/test/test_05.c deleted file mode 100644 index f88dd15..0000000 --- a/test/test_05.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2007 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. - */ - -#define TEST_DESCRIPTION "Create/destroy configs for all profiles / entrypoints" - -#include "test_common.c" - -void pre() -{ - test_init(); - test_profiles(); -} - -void test() -{ - int max_entrypoints; - int num_entrypoints; - int i, j, k; - int config_count = 0; - max_entrypoints = vaMaxNumEntrypoints(va_dpy); - ASSERT(max_entrypoints > 0); - VAEntrypoint *entrypoints = malloc(max_entrypoints * sizeof(VAEntrypoint)); - ASSERT(entrypoints); - - VAConfigID *configs = malloc(max_entrypoints * num_profiles * sizeof(VAConfigID)); - - for(i = 0; i < num_profiles; i++) - { - va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - for(j = 0; j < num_entrypoints; j++) - { - status("vaCreateConfig for %s, %s\n", profile2string(profiles[i]), entrypoint2string(entrypoints[j])); - va_status = vaCreateConfig(va_dpy, profiles[i], entrypoints[j], NULL, 0, &(configs[config_count])); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaCreateConfig returns %08x\n", configs[config_count]); - config_count++; - } - } - - for(i = 0; i < config_count; i++) - { - status("vaDestroyConfig for config %08x\n", configs[i]); - va_status = vaDestroyConfig( va_dpy, configs[i] ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } - - free(configs); - free(entrypoints); -} - -void post() -{ - test_terminate(); -} diff --git a/test/test_06.c b/test/test_06.c deleted file mode 100644 index ca47e50..0000000 --- a/test/test_06.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2007 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. - */ - -#define TEST_DESCRIPTION "Get config attributes from configs" - -#include "test_common.c" - -int max_entrypoints; -VAEntrypoint *entrypoints; - -VAConfigID *configs; -int config_count = 0; - - - -void pre() -{ - int i, j, k; - - test_init(); - test_profiles(); - - max_entrypoints = vaMaxNumEntrypoints(va_dpy); - ASSERT(max_entrypoints > 0); - entrypoints = malloc(max_entrypoints * sizeof(VAEntrypoint)); - ASSERT(entrypoints); - - configs = malloc(max_entrypoints * num_profiles * sizeof(VAConfigID)); - ASSERT(configs); - - // Create configs - for(i = 0; i < num_profiles; i++) - { - int num_entrypoints; - va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - for(j = 0; j < num_entrypoints; j++) - { - va_status = vaCreateConfig(va_dpy, profiles[i], entrypoints[j], NULL, 0, &(configs[config_count])); - ASSERT( VA_STATUS_SUCCESS == va_status ); - config_count++; - } - } -} - -void test() -{ - int i, j, k; - int max_attribs; - - max_attribs = vaMaxNumConfigAttributes(va_dpy); - ASSERT(max_attribs > 0); - - VAConfigAttrib *attrib_list = malloc(max_attribs * sizeof(VAConfigAttrib)); - - config_count = 0; - for(i = 0; i < num_profiles; i++) - { - int num_entrypoints; - - va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); - ASSERT( VA_STATUS_SUCCESS == va_status ); - for(j = 0; j < num_entrypoints; j++) - { - VAProfile profile= -1; - VAEntrypoint entrypoint = -1; - int num_attribs = -1; - - status("Checking vaQueryConfigAttributes for %s, %s\n", profile2string(profiles[i]), entrypoint2string(entrypoints[j])); - memset(attrib_list, 0xff, max_attribs * sizeof(VAConfigAttrib)); - - va_status = vaQueryConfigAttributes(va_dpy, configs[config_count], &profile, &entrypoint, attrib_list, &num_attribs); - config_count++; - ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( profile == profiles[i] ); - ASSERT( entrypoint == entrypoints[j] ); - ASSERT( num_attribs >= 0 ); - for(k = 0; k < num_attribs; k++) - { - status(" %d -> %08x\n", attrib_list[k].type, attrib_list[k].value); - ASSERT(attrib_list[k].value != VA_ATTRIB_NOT_SUPPORTED); - } - } - } - - free(attrib_list); -} - -void post() -{ - int i; - for(i = 0; i < config_count; i++) - { - va_status = vaDestroyConfig( va_dpy, configs[i] ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } - - free(configs); - free(entrypoints); - test_terminate(); -} diff --git a/test/test_07.c b/test/test_07.c deleted file mode 100644 index cb1edce..0000000 --- a/test/test_07.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2007 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. - */ - -#define TEST_DESCRIPTION "Create and destory surfaces" - -#include "test_common.c" - -void pre() -{ - test_init(); -} - -#define DEAD_SURFACE_ID (VASurfaceID) 0xbeefdead - -void test_unique_surfaces(VASurfaceID *surface_list1, int surface_count1, VASurfaceID *surface_list2, int surface_count2) -{ - int i,j; - - for(i = 0; i < surface_count1; i++) - { - for(j = 0; j < surface_count2; j++) - { - if ((surface_list1 == surface_list2) && (i == j)) continue; - ASSERT(surface_list1[i] != VA_INVALID_SURFACE); - ASSERT(surface_list2[j] != VA_INVALID_SURFACE); - ASSERT(surface_list1[i] != surface_list2[j]); - } - } -} - - -void test() -{ - VASurfaceID surfaces_1[1+1]; - VASurfaceID surfaces_4[4+1]; - VASurfaceID surfaces_16[16+1]; - VASurfaceID surfaces_6[6+1]; - - memset(surfaces_1, 0xff, sizeof(surfaces_1)); - memset(surfaces_4, 0xff, sizeof(surfaces_4)); - memset(surfaces_16, 0xff, sizeof(surfaces_16)); - memset(surfaces_6, 0xff, sizeof(surfaces_6)); - - status("vaCreateSurfaces 1 surface\n"); - surfaces_1[1] = DEAD_SURFACE_ID; - va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 1, surfaces_1); - ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( DEAD_SURFACE_ID == surfaces_1[1] ); /* bounds check */ - - status("vaCreateSurfaces 4 surfaces\n"); - surfaces_4[4] = DEAD_SURFACE_ID; - va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 4, surfaces_4); - ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( DEAD_SURFACE_ID == surfaces_4[4] ); /* bounds check */ - - status("vaCreateSurfaces 16 surfaces\n"); - surfaces_16[16] = DEAD_SURFACE_ID; - va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 16, surfaces_16); - ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( DEAD_SURFACE_ID == surfaces_16[16] ); /* bounds check */ - - test_unique_surfaces(surfaces_1, 1, surfaces_4, 4); - test_unique_surfaces(surfaces_4, 4, surfaces_16, 4); - test_unique_surfaces(surfaces_4, 4, surfaces_16, 16); - test_unique_surfaces(surfaces_4, 1, surfaces_16, 16); - test_unique_surfaces(surfaces_1, 16, surfaces_16, 16); - - status("vaDestroySurface 4 surfaces\n"); - va_status = vaDestroySurfaces(va_dpy, surfaces_4, 4); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - status("vaCreateSurfaces 6 surfaces\n"); - surfaces_6[6] = DEAD_SURFACE_ID; - va_status = vaCreateSurfaces(va_dpy, 352, 288, VA_RT_FORMAT_YUV420, 6, surfaces_6); - ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( DEAD_SURFACE_ID == surfaces_6[6] ); /* bounds check */ - - test_unique_surfaces(surfaces_1, 1, surfaces_6, 6); - test_unique_surfaces(surfaces_6, 6, surfaces_16, 16); - test_unique_surfaces(surfaces_1, 6, surfaces_16, 6); - - status("vaDestroySurface 16 surfaces\n"); - va_status = vaDestroySurfaces(va_dpy, surfaces_16, 16); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - status("vaDestroySurface 1 surface\n"); - va_status = vaDestroySurfaces(va_dpy, surfaces_1, 1); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - status("vaDestroySurface 6 surfaces\n"); - va_status = vaDestroySurfaces(va_dpy, surfaces_6, 6); - ASSERT( VA_STATUS_SUCCESS == va_status ); -} - -void post() -{ - test_terminate(); -} diff --git a/test/test_08.c b/test/test_08.c deleted file mode 100644 index 8c743b6..0000000 --- a/test/test_08.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2007 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. - */ - -#define TEST_DESCRIPTION "Create and destory surfaces of different sizes" - -#include "test_common.c" - -void pre() -{ - test_init(); -} - -#define DEAD_SURFACE_ID (VASurfaceID) 0xbeefdead - -void test_unique_surfaces(VASurfaceID *surface_list, int surface_count) -{ - int i,j; - - for(i = 0; i < surface_count; i++) - { - ASSERT(surface_list[i] != VA_INVALID_SURFACE); - for(j = 0; j < i; j++) - { - if (i == j) continue; - ASSERT(surface_list[i] != surface_list[j]); - } - } -} - -typedef struct test_size { int w; int h; } test_size_t; - -test_size_t test_sizes[] = { - { 10, 10 }, - { 128, 128 }, - { 176, 144 }, - { 144, 176 }, - { 352, 288 }, - { 399, 299 }, - { 640, 480 }, - { 1280, 720 } -}; - -#define NUM_SIZES (sizeof(test_sizes) / sizeof(test_size_t)) - -void test() -{ - VASurfaceID surfaces[NUM_SIZES+1]; - int i; - - memset(surfaces, 0xff, sizeof(surfaces)); - - for(i = 0; i < NUM_SIZES; i++) - { - status("vaCreateSurfaces create %dx%d surface\n", test_sizes[i].w, test_sizes[i].h); - surfaces[i+1] = DEAD_SURFACE_ID; - va_status = vaCreateSurfaces(va_dpy, test_sizes[i].w, test_sizes[i].h, VA_RT_FORMAT_YUV420, 1, &surfaces[i]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( DEAD_SURFACE_ID == surfaces[i+1] ); - } - - test_unique_surfaces(surfaces, NUM_SIZES); - - status("vaDestroySurface all surfaces\n"); - va_status = vaDestroySurfaces(va_dpy, surfaces, NUM_SIZES); - ASSERT( VA_STATUS_SUCCESS == va_status ); -} - -void post() -{ - test_terminate(); -} diff --git a/test/test_09.c b/test/test_09.c deleted file mode 100644 index 7d6cd4b..0000000 --- a/test/test_09.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2007 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. - */ - -#define TEST_DESCRIPTION "Create/destroy contexts for all profiles / entrypoints" - -#include "test_common.c" - -void pre() -{ - test_init(); - test_profiles(); -} - -void test() -{ - int max_entrypoints; - int num_entrypoints; - int i, j, k; - int config_count = 0; - max_entrypoints = vaMaxNumEntrypoints(va_dpy); - ASSERT(max_entrypoints > 0); - VAEntrypoint *entrypoints = malloc(max_entrypoints * sizeof(VAEntrypoint)); - ASSERT(entrypoints); - - VAConfigID *configs = malloc(max_entrypoints * num_profiles * sizeof(VAConfigID)); - VAContextID *contexts = malloc(max_entrypoints * num_profiles * sizeof(VAContextID)); - - for(i = 0; i < num_profiles; i++) - { - va_status = vaQueryConfigEntrypoints(va_dpy, profiles[i], entrypoints, &num_entrypoints); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - for(j = 0; j < num_entrypoints; j++) - { - status("vaCreateConfig for %s, %s\n", profile2string(profiles[i]), entrypoint2string(entrypoints[j])); - va_status = vaCreateConfig(va_dpy, profiles[i], entrypoints[j], NULL, 0, &(configs[config_count])); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaCreateConfig returns %08x\n", configs[config_count]); - config_count++; - } - } - - int width = 352; - int height = 288; - int surface_count = 4; - int total_surfaces = config_count * surface_count; - - VASurfaceID *surfaces = malloc(total_surfaces * sizeof(VASurfaceID)); - - // TODO: Don't assume VA_RT_FORMAT_YUV420 is supported / needed for each config - va_status = vaCreateSurfaces(va_dpy, width, height, VA_RT_FORMAT_YUV420, total_surfaces, surfaces); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - for(i = 0; i < config_count; i++) - { - status("vaCreateContext with config %08x\n", configs[i]); - int flags = 0; - va_status = vaCreateContext( va_dpy, configs[i], width, height, flags, surfaces + i*surface_count, surface_count, &contexts[i] ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } - - for(i = 0; i < config_count; i++) - { - status("vaDestroyContext for context %08x\n", contexts[i]); - va_status = vaDestroyContext( va_dpy, contexts[i] ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } - - for(i = 0; i < config_count; i++) - { - status("vaDestroyConfig for config %08x\n", configs[i]); - va_status = vaDestroyConfig( va_dpy, configs[i] ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } - - va_status = vaDestroySurfaces(va_dpy, surfaces, total_surfaces); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - free(contexts); - free(configs); - free(surfaces); - free(entrypoints); -} - -void post() -{ - test_terminate(); -} diff --git a/test/test_10.c b/test/test_10.c deleted file mode 100644 index 6a7b978..0000000 --- a/test/test_10.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2007 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. - */ - -#define TEST_DESCRIPTION "Create and destroy buffers" - -#include "test_common.c" - -VAConfigID config; -VAContextID context; -VASurfaceID *surfaces; -int total_surfaces; - -void pre() -{ - test_init(); - - va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, NULL, 0, &config); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaCreateConfig returns %08x\n", config); - - int width = 352; - int height = 288; - int surface_count = 4; - total_surfaces = surface_count; - - surfaces = malloc(total_surfaces * sizeof(VASurfaceID)); - - // TODO: Don't assume VA_RT_FORMAT_YUV420 is supported / needed for each config - va_status = vaCreateSurfaces(va_dpy, width, height, VA_RT_FORMAT_YUV420, total_surfaces, surfaces); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - status("vaCreateContext with config %08x\n", config); - int flags = 0; - va_status = vaCreateContext( va_dpy, config, width, height, flags, surfaces, surface_count, &context ); - ASSERT( VA_STATUS_SUCCESS == va_status ); -} - -void test_unique_buffers(VABufferID *buffer_list, int buffer_count) -{ - int i,j; - - for(i = 0; i < buffer_count; i++) - { - for(j = 0; j < i; j++) - { - ASSERT(buffer_list[i] != buffer_list[j]); - } - } -} - -VABufferType buffer_types[] = -{ - VAPictureParameterBufferType, - VAIQMatrixBufferType, - VABitPlaneBufferType, - VASliceGroupMapBufferType, - VASliceParameterBufferType, - VASliceDataBufferType, - VAMacroblockParameterBufferType, - VAResidualDataBufferType, - VADeblockingParameterBufferType, -}; - -unsigned int buffer_sizes[] = -{ - sizeof(VAPictureParameterBufferMPEG4), - sizeof(VAIQMatrixBufferH264), - 32*1024, - 48*1024, - sizeof(VASliceParameterBufferMPEG2), - 128*1024, - sizeof(VAMacroblockParameterBufferMPEG2), - 32*1024, - 15*1024, -}; - - -#define NUM_BUFFER_TYPES (sizeof(buffer_types) / sizeof(VABufferType)) - -#define DEAD_BUFFER_ID ((VABufferID) 0x1234ffff) - -void test() -{ - VABufferID buffer_ids[NUM_BUFFER_TYPES+1]; - int i; - memset(buffer_ids, 0xff, sizeof(buffer_ids)); - for(i=0; i < NUM_BUFFER_TYPES; i++) - { - buffer_ids[i+1] = DEAD_BUFFER_ID; - va_status = vaCreateBuffer(va_dpy, context, buffer_types[i], buffer_sizes[i], 1, NULL, &buffer_ids[i]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - ASSERT( DEAD_BUFFER_ID == buffer_ids[i+1] ); /* Bounds check */ - } - test_unique_buffers(buffer_ids, NUM_BUFFER_TYPES); - - for(i=0; i < NUM_BUFFER_TYPES; i++) - { - va_status = vaDestroyBuffer(va_dpy, buffer_ids[i]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - } -} - -void post() -{ - status("vaDestroyContext for context %08x\n", context); - va_status = vaDestroyContext( va_dpy, context ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - status("vaDestroyConfig for config %08x\n", config); - va_status = vaDestroyConfig( va_dpy, config ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaDestroySurfaces(va_dpy, surfaces, total_surfaces); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - free(surfaces); - - test_terminate(); -} diff --git a/test/test_11.c b/test/test_11.c deleted file mode 100644 index 8f3c4b8..0000000 --- a/test/test_11.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2007 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. - */ - -#define TEST_DESCRIPTION "Map and unmap buffers" - -#include "test_common.c" - -VAConfigID config; -VAContextID context; -VASurfaceID *surfaces; -int total_surfaces; - -void pre() -{ - test_init(); - - va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, NULL, 0, &config); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaCreateConfig returns %08x\n", config); - - int width = 352; - int height = 288; - int surface_count = 4; - total_surfaces = surface_count; - - surfaces = malloc(total_surfaces * sizeof(VASurfaceID)); - - // TODO: Don't assume VA_RT_FORMAT_YUV420 is supported / needed for each config - va_status = vaCreateSurfaces(va_dpy, width, height, VA_RT_FORMAT_YUV420, total_surfaces, surfaces); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - status("vaCreateContext with config %08x\n", config); - int flags = 0; - va_status = vaCreateContext( va_dpy, config, width, height, flags, surfaces, surface_count, &context ); - ASSERT( VA_STATUS_SUCCESS == va_status ); -} - -void test_unique_buffers(VABufferID *buffer_list, int buffer_count) -{ - int i,j; - - for(i = 0; i < buffer_count; i++) - { - for(j = 0; j < i; j++) - { - ASSERT(buffer_list[i] != buffer_list[j]); - } - } -} - -VABufferType buffer_types[] = -{ - VAPictureParameterBufferType, - VAIQMatrixBufferType, - VABitPlaneBufferType, - VASliceGroupMapBufferType, - VASliceParameterBufferType, - VASliceDataBufferType, - VAMacroblockParameterBufferType, - VAResidualDataBufferType, - VADeblockingParameterBufferType, -}; - -unsigned int buffer_sizes[] = -{ - sizeof(VAPictureParameterBufferMPEG4), - sizeof(VAIQMatrixBufferH264), - 32*1024, - 48*1024, - sizeof(VASliceParameterBufferMPEG2), - 128*1024, - sizeof(VAMacroblockParameterBufferMPEG2), - 32*1024, - 15*1024, -}; - - -#define NUM_BUFFER_TYPES (sizeof(buffer_types) / sizeof(VABufferType)) - -#define DEAD_BUFFER_ID ((VABufferID) 0x1234ffff) - -void test() -{ - VABufferID buffer_ids[NUM_BUFFER_TYPES+1]; - uint32_t *input_data[NUM_BUFFER_TYPES]; - int i, j; - memset(buffer_ids, 0xff, sizeof(buffer_ids)); - for(i=0; i < NUM_BUFFER_TYPES; i++) - { - uint32_t *data; - - input_data[i] = malloc(buffer_sizes[i]+4); - ASSERT(input_data[i]); - - /* Generate input data */ - for(j = buffer_sizes[i] / 4; j--;) - { - input_data[i][j] = random(); - } - - /* Copy to secondary buffer */ - data = malloc(buffer_sizes[i]); - ASSERT(data); - memcpy(data, input_data[i], buffer_sizes[i]); - - /* Create buffer and fill with data */ - va_status = vaCreateBuffer(va_dpy, context, buffer_types[i], buffer_sizes[i], 1, data, &buffer_ids[i]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaCreateBuffer created buffer %08x of type %d\n", buffer_ids[i], buffer_types[i]); - - /* Wipe secondary buffer */ - memset(data, 0, buffer_sizes[i]); - free(data); - } - - for(i=0; i < NUM_BUFFER_TYPES; i++) - { - void *data = NULL; - /* Fetch VA Buffer */ - va_status = vaMapBuffer(va_dpy, buffer_ids[i], &data); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaMapBuffer mapped buffer %08x\n", buffer_ids[i]); - - /* Compare data */ - ASSERT( memcmp(input_data[i], data, buffer_sizes[i]) == 0 ); - } - - for(i=0; i < NUM_BUFFER_TYPES; i++) - { - va_status = vaUnmapBuffer(va_dpy, buffer_ids[i]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaDestroyBuffer(va_dpy, buffer_ids[i]); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - free(input_data[i]); - } -} - - - -void post() -{ - status("vaDestroyContext for context %08x\n", context); - va_status = vaDestroyContext( va_dpy, context ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - status("vaDestroyConfig for config %08x\n", config); - va_status = vaDestroyConfig( va_dpy, config ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaDestroySurfaces(va_dpy, surfaces, total_surfaces); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - free(surfaces); - - test_terminate(); -} diff --git a/test/test_12.c b/test/test_12.c deleted file mode 100644 index c9e4db9..0000000 --- a/test/test_12.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (c) 2007 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. - */ - -#define TEST_DESCRIPTION "Sample MPEG2 VLD Decoding" - -#ifdef IN_LIBVA -#include -#else -#include -#endif - -#include "test_common.c" - -#include -#include -#include - -void pre() -{ - test_init(); -} - -/* Data dump of a 16x16 MPEG2 video clip,it has one I frame - */ -static unsigned char mpeg2_clip[]={ - 0x00,0x00,0x01,0xb3,0x01,0x00,0x10,0x13,0xff,0xff,0xe0,0x18,0x00,0x00,0x01,0xb5, - 0x14,0x8a,0x00,0x01,0x00,0x00,0x00,0x00,0x01,0xb8,0x00,0x08,0x00,0x00,0x00,0x00, - 0x01,0x00,0x00,0x0f,0xff,0xf8,0x00,0x00,0x01,0xb5,0x8f,0xff,0xf3,0x41,0x80,0x00, - 0x00,0x01,0x01,0x13,0xe1,0x00,0x15,0x81,0x54,0xe0,0x2a,0x05,0x43,0x00,0x2d,0x60, - 0x18,0x01,0x4e,0x82,0xb9,0x58,0xb1,0x83,0x49,0xa4,0xa0,0x2e,0x05,0x80,0x4b,0x7a, - 0x00,0x01,0x38,0x20,0x80,0xe8,0x05,0xff,0x60,0x18,0xe0,0x1d,0x80,0x98,0x01,0xf8, - 0x06,0x00,0x54,0x02,0xc0,0x18,0x14,0x03,0xb2,0x92,0x80,0xc0,0x18,0x94,0x42,0x2c, - 0xb2,0x11,0x64,0xa0,0x12,0x5e,0x78,0x03,0x3c,0x01,0x80,0x0e,0x80,0x18,0x80,0x6b, - 0xca,0x4e,0x01,0x0f,0xe4,0x32,0xc9,0xbf,0x01,0x42,0x69,0x43,0x50,0x4b,0x01,0xc9, - 0x45,0x80,0x50,0x01,0x38,0x65,0xe8,0x01,0x03,0xf3,0xc0,0x76,0x00,0xe0,0x03,0x20, - 0x28,0x18,0x01,0xa9,0x34,0x04,0xc5,0xe0,0x0b,0x0b,0x04,0x20,0x06,0xc0,0x89,0xff, - 0x60,0x12,0x12,0x8a,0x2c,0x34,0x11,0xff,0xf6,0xe2,0x40,0xc0,0x30,0x1b,0x7a,0x01, - 0xa9,0x0d,0x00,0xac,0x64 -}; - -/* hardcoded here without a bitstream parser helper - * please see picture mpeg2-I.jpg for bitstream details - */ -static VAPictureParameterBufferMPEG2 pic_param={ - horizontal_size:16, - vertical_size:16, - forward_reference_picture:0xffffffff, - backward_reference_picture:0xffffffff, - picture_coding_type:1, - f_code:0xffff, - { - { - intra_dc_precision:0, - picture_structure:3, - top_field_first:0, - frame_pred_frame_dct:1, - concealment_motion_vectors:0, - q_scale_type:0, - intra_vlc_format:0, - alternate_scan:0, - repeat_first_field:0, - progressive_frame:1 , - is_first_field:1 - }, - } -}; - -/* see MPEG2 spec65 for the defines of matrix */ -static VAIQMatrixBufferMPEG2 iq_matrix = { - load_intra_quantiser_matrix:1, - load_non_intra_quantiser_matrix:1, - load_chroma_intra_quantiser_matrix:0, - load_chroma_non_intra_quantiser_matrix:0, - intra_quantiser_matrix:{ - 8, 16, 16, 19, 16, 19, 22, 22, - 22, 22, 22, 22, 26, 24, 26, 27, - 27, 27, 26, 26, 26, 26, 27, 27, - 27, 29, 29, 29, 34, 34, 34, 29, - 29, 29, 27, 27, 29, 29, 32, 32, - 34, 34, 37, 38, 37, 35, 35, 34, - 35, 38, 38, 40, 40, 40, 48, 48, - 46, 46, 56, 56, 58, 69, 69, 83 - }, - non_intra_quantiser_matrix:{16}, - chroma_intra_quantiser_matrix:{0}, - chroma_non_intra_quantiser_matrix:{0} -}; - -static VASliceParameterBufferMPEG2 slice_param={ - slice_data_size:150, - slice_data_offset:0, - slice_data_flag:0, - macroblock_offset:38,/* 4byte + 6bits=38bits */ - slice_vertical_position:0, - quantiser_scale_code:2, - intra_slice_flag:0 -}; - -#define CLIP_WIDTH 16 -#define CLIP_HEIGHT 16 - -int surf_width=CLIP_WIDTH,surf_height=CLIP_HEIGHT; -int win_width=CLIP_WIDTH<<1,win_height=CLIP_HEIGHT<<1; - -void test() -{ - VAEntrypoint entrypoints[5]; - int num_entrypoints,vld_entrypoint; - VAConfigAttrib attrib; - VAConfigID config_id; - VASurfaceID vaSurface; - VAContextID vaContext; - VABufferID vaPicParamBuf,vaIQMatrixBuf,vaSliceParamBuf,vaSliceDataBuf; - Window win = 0; - - va_status = vaQueryConfigEntrypoints(va_dpy, VAProfileMPEG2Main, entrypoints, - &num_entrypoints); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - for (vld_entrypoint = 0; vld_entrypoint < num_entrypoints; vld_entrypoint++) { - if (entrypoints[vld_entrypoint] == VAEntrypointVLD) - break; - } - if (vld_entrypoint == num_entrypoints) { - /* not find VLD entry point */ - ASSERT(0); - } - - /* Assuming finding VLD, find out the format for the render target */ - attrib.type = VAConfigAttribRTFormat; - va_status = vaGetConfigAttributes(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, - &attrib, 1); - ASSERT( VA_STATUS_SUCCESS == va_status ); - if ((attrib.value & VA_RT_FORMAT_YUV420) == 0) { - /* not find desired YUV420 RT format */ - ASSERT(0); - } - - va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD, - &attrib, 1,&config_id); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaCreateSurfaces(va_dpy,surf_width,surf_height, - VA_RT_FORMAT_YUV420, 1, &vaSurface); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - /* Create a context for this decode pipe */ - va_status = vaCreateContext(va_dpy, config_id, - CLIP_WIDTH, - ((CLIP_HEIGHT+15)/16)*16, - VA_PROGRESSIVE, - &vaSurface, - 1, - &vaContext); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaCreateBuffer(va_dpy, vaContext, - VAPictureParameterBufferType, - sizeof(VAPictureParameterBufferMPEG2), - 1, &pic_param, - &vaPicParamBuf); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaCreateBuffer(va_dpy, vaContext, - VAIQMatrixBufferType, - sizeof(VAIQMatrixBufferMPEG2), - 1, &iq_matrix, - &vaIQMatrixBuf ); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaCreateBuffer(va_dpy, vaContext, - VASliceParameterBufferType, - sizeof(VASliceParameterBufferMPEG2), - 1, - &slice_param, &vaSliceParamBuf); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaCreateBuffer(va_dpy, vaContext, - VASliceDataBufferType, - 0xc4-0x2f+1, - 1, - mpeg2_clip+0x2f, - &vaSliceDataBuf); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaBeginPicture(va_dpy, vaContext, vaSurface); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaRenderPicture(va_dpy,vaContext, &vaPicParamBuf, 1); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaRenderPicture(va_dpy,vaContext, &vaIQMatrixBuf, 1); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaRenderPicture(va_dpy,vaContext, &vaSliceParamBuf, 1); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaRenderPicture(va_dpy,vaContext, &vaSliceDataBuf, 1); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaEndPicture(va_dpy,vaContext); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - va_status = vaSyncSurface(va_dpy, vaSurface); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - win = XCreateSimpleWindow(dpy, RootWindow(dpy, 0), 0, 0, - win_width,win_height, 0, 0, WhitePixel(dpy, 0)); - XMapWindow(dpy, win); - XSync(dpy, False); - - va_status = vaPutSurface(va_dpy, vaSurface, win, - 0,0,surf_width,surf_height, - 0,0,win_width,win_height, - NULL,0,0); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - printf("press any key to exit\n"); - getchar(); - - vaDestroySurfaces(va_dpy,&vaSurface,1); - vaDestroyConfig(va_dpy,config_id); - vaDestroyContext(va_dpy,vaContext); -} - -void post() -{ - test_terminate(); -} diff --git a/test/test_common.c b/test/test_common.c deleted file mode 100644 index 91774da..0000000 --- a/test/test_common.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2007 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 IN_LIBVA -#include -#else -#include -#endif - -#include "assert.h" -#include -#include -#include -#include -#include -#include - -#define ASSERT assert - -Display *dpy; -VADisplay va_dpy; -VAStatus va_status; -int major_version, minor_version; -int print_status = 0; -int num_profiles; -VAProfile *profiles = NULL; - -void pre(); -void test(); -void post(); - -void status(const char *msg, ...) -{ - if (!print_status) return; - va_list args; - printf("--- "); - va_start(args, msg); - vfprintf(stdout, msg, args); - va_end(args); -} - - -int main(int argc, const char* argv[]) -{ - const char *name = strrchr(argv[0], '/'); - if (name) - name++; - else - name = argv[0]; - printf("*** %s: %s\n", name, TEST_DESCRIPTION); - pre(); - print_status = 1; - test(); - print_status = 0; - post(); - printf("*** %s: Finished\n", name); - return 0; -} - -void test_init() -{ - dpy = XOpenDisplay(NULL); - ASSERT( dpy ); - status("XOpenDisplay: dpy = %08x\n", dpy); - - va_dpy = vaGetDisplay(dpy); - ASSERT( va_dpy ); - status("vaGetDisplay: va_dpy = %08x\n", va_dpy); - - va_status = vaInitialize(va_dpy, &major_version, &minor_version); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaInitialize: major = %d minor = %d\n", major_version, minor_version); -} - -void test_terminate() -{ - va_status = vaTerminate(va_dpy); - ASSERT( VA_STATUS_SUCCESS == va_status ); - status("vaTerminate\n"); - - XCloseDisplay(dpy); - status("XCloseDisplay\n"); - - if (profiles) - { - free(profiles); - profiles = NULL; - } -} - -#define PROFILE(profile) case VAProfile##profile: return("VAProfile" #profile); - -const char *profile2string(VAProfile profile) -{ - switch(profile) - { - PROFILE(MPEG2Simple) - PROFILE(MPEG2Main) - PROFILE(MPEG4Simple) - PROFILE(MPEG4AdvancedSimple) - PROFILE(MPEG4Main) - PROFILE(H264Baseline) - PROFILE(H264Main) - PROFILE(H264High) - PROFILE(VC1Simple) - PROFILE(VC1Main) - PROFILE(VC1Advanced) - } - ASSERT(0); - return "Unknown"; -} - -#define ENTRYPOINT(profile) case VAEntrypoint##profile: return("VAEntrypoint" #profile); - -const char *entrypoint2string(VAEntrypoint entrypoint) -{ - switch(entrypoint) - { - ENTRYPOINT(VLD) - ENTRYPOINT(IZZ) - ENTRYPOINT(IDCT) - ENTRYPOINT(MoComp) - ENTRYPOINT(Deblocking) - } - ASSERT(0); - return "Unknown"; -} - - -void test_profiles() -{ - int max_profiles; - int i; - max_profiles = vaMaxNumProfiles(va_dpy); - status("vaMaxNumProfiles = %d\n", max_profiles); - ASSERT(max_profiles > 0); - profiles = malloc(max_profiles * sizeof(VAProfile)); - ASSERT(profiles); - - va_status = vaQueryConfigProfiles(va_dpy, profiles, &num_profiles); - ASSERT( VA_STATUS_SUCCESS == va_status ); - - status("vaQueryConfigProfiles reports %d profiles\n", num_profiles); - ASSERT(num_profiles <= max_profiles); - ASSERT(num_profiles > 0); - - if (print_status) - { - for(i = 0; i < num_profiles; i++) - { - status(" profile %d [%s]\n", profiles[i], profile2string(profiles[i])); - } - } -} diff --git a/test/testplan.txt b/test/testplan.txt deleted file mode 100644 index 1cc573b..0000000 --- a/test/testplan.txt +++ /dev/null @@ -1,106 +0,0 @@ - -Test 1 -- Initialize & Terminate -- vaGetDisplay, vaInitialize, vaTerminate - -Test 2 -- Query profiles -- vaQueryConfigProfiles, vaMaxNumProfiles - -Test 3 -- Query Entrypoints for all profiles -- vaQueryConfigEntryPoints, vaMaxNumEntryPoints - -Test 4 -- Get Config attributes for all profiles / entrypoints -- vaGetConfigAttributes - -Test 5 -- Create & destroy config for each profile / entrypoint -- vaCreateConfig, vaDestroyConfig - -Test 6 -- Get config attributes of various possible configs -- vaQueryConfigAttributes, vaMaxNumConfigAttributes -- Check if results for vaGetConfigAttributes match with vaQueryConfigAttributes for -a given profile / entrypoint - -Test 7 -- Create and destroy surfaces -- vaCreateSurfaces, vaDestroySurface -- Create surfaces of 352 x 288 pixels -- Create 1, 4 and 16 surfaces, destroy 4, create 6 surfaces, destroy 16, 1 -and 6 surfaces. - -Test 8 -- Create and destroy surfaces of different sizes -- Create surfaces of 10 x 10 pixels, 128 x 128 pixels, 176 x 144 pixels, 144 x 176 -pixels, 352 x 288 pixels, 399 x 299 pixels, 640 x 480 pixels, 1280 x 720 -pixels - -Test 9 -- Create and destroy a context for each profile / entrypoint -- Pass 4 surfaces of 352 x 288 pixels -- vaCreateContext, vaDestroyContext -- See also Test 5 - -Test 10 -- Create and destroy buffers -- vaCreateBuffer, vaDestroyBuffer -- For each different buffertype, create a buffer, then destroy them one by -one. - -Test 11 -- Map & unmap buffers -- vaBufferData, vaMapBuffer, vaUnmapBuffer -- For each different buffertype, copy data to the buffer with vaBufferData. -Then map the buffer and verify the contents of the buffer. - -Test 12 -- Render single MPEG2 I-frame -- vaBeginPicture, vaRenderPicture (num_buffers == 1), vaEndPicture - -Test 13 -- Render single MPEG2 I-frame, multiple buffer submission -- vaRenderPicture (num_buffers > 1) - -Test 14 -- Render single MPEG2 I-frame, split buffers -- Slice split over 2 buffers - -Test 15 -- Render single MPEG2 I-frame, split buffers -- Slice split over 3 buffers - -Test 16 -- Sync Surface -- Render single MPEG2 I-frame, then check vaQuerySurfaceStatus, vaSyncSurface and vaQuerySurfaceStatus - -Test 17 -- Query image formats -- vaMaxNumImageFormats, vaQueryImageFormats - -Test 18 -- Create and destroy vaImage -- vaCreateImage, vaDestroyImage - -Test 19 -- Get image data -- Render single MPEG2 I-frame, copy surface data to image, check resulting -image -- vaGetImage - -Test 20 -- Put image data -- Render single MPEG2 I-frame, copy half of a VAImage to surface, copy -surface back to VAImage, check resulting image -- vaPutImage - -Test 21 -- Query subpicture formats -- vaMaxNumSubpictureFormats, vaQuerySubpictureFromats - -Test 22 -- Create and destory subpictures -- vaCreateSubpicture, vaDestroySubpicture - -- cgit v1.2.3