1 /*
2  * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sub license, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial portions
14  * of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #include <va/va.h>
26 #ifdef ANDROID
27 #include <va/va_android.h>
28 #else
29 #include <va/va_x11.h>
30 #endif
31 #include "assert.h"
32 #include <stdarg.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <stdint.h>
37 #include <dlfcn.h>
38 
39 #define ASSERT	assert
40 
41 void status(const char *msg, ...);
42 #ifdef ANDROID
43 #include "test_android.c"
44 #else
45 #include "test_x11.c"
46 #endif
47 
48 Display *dpy;
49 VADisplay va_dpy;
50 VAStatus va_status;
51 int major_version, minor_version;
52 int print_status = 0;
53 int num_profiles;
54 VAProfile *profiles = NULL;
55 
56 void pre();
57 void test();
58 void post();
59 
status(const char * msg,...)60 void status(const char *msg, ...)
61 {
62   if (!print_status) return;
63   va_list args;
64   printf("--- ");
65   va_start(args, msg);
66   vfprintf(stdout, msg, args);
67   va_end(args);
68 }
69 
70 
main(int argc,const char * argv[])71 int main(int argc, const char* argv[])
72 {
73   const char *name = strrchr(argv[0], '/');
74   if (name)
75       name++;
76   else
77       name = argv[0];
78   printf("*** %s: %s\n", name, TEST_DESCRIPTION);
79   pre();
80   print_status = 1;
81   test();
82   print_status = 0;
83   post();
84   printf("*** %s: Finished\n", name);
85   return 0;
86 }
87 
88 #define PROFILE(profile)	case VAProfile##profile:	return("VAProfile" #profile);
89 
profile2string(VAProfile profile)90 const char *profile2string(VAProfile profile)
91 {
92     switch(profile)
93     {
94         PROFILE(None)
95         PROFILE(MPEG2Simple)
96         PROFILE(MPEG2Main)
97         PROFILE(MPEG4Simple)
98         PROFILE(MPEG4AdvancedSimple)
99         PROFILE(MPEG4Main)
100         PROFILE(H263Baseline)
101         PROFILE(H264Baseline)
102         PROFILE(H264Main)
103         PROFILE(H264High)
104         PROFILE(H264ConstrainedBaseline)
105         PROFILE(H264MultiviewHigh)
106         PROFILE(H264StereoHigh)
107         PROFILE(VC1Simple)
108         PROFILE(VC1Main)
109         PROFILE(VC1Advanced)
110         PROFILE(JPEGBaseline)
111         PROFILE(VP8Version0_3)
112         default:return "Unknow";
113     }
114     ASSERT(0);
115     return "Unknown";
116 }
117 
118 #define ENTRYPOINT(profile)	case VAEntrypoint##profile:	return("VAEntrypoint" #profile);
119 
entrypoint2string(VAEntrypoint entrypoint)120 const char *entrypoint2string(VAEntrypoint entrypoint)
121 {
122     switch(entrypoint)
123     {
124         ENTRYPOINT(VLD)
125         ENTRYPOINT(IZZ)
126         ENTRYPOINT(IDCT)
127         ENTRYPOINT(MoComp)
128         ENTRYPOINT(Deblocking)
129         ENTRYPOINT(EncSlice)
130         ENTRYPOINT(EncPicture)
131         ENTRYPOINT(VideoProc)
132         default:return "Unknow";
133     }
134     ASSERT(0);
135     return "Unknown";
136 }
137 
138 
test_profiles()139 void test_profiles()
140 {
141     int max_profiles;
142     int i;
143     max_profiles = vaMaxNumProfiles(va_dpy);
144     status("vaMaxNumProfiles = %d\n", max_profiles);
145     ASSERT(max_profiles > 0);
146     profiles = malloc(max_profiles * sizeof(VAProfile));
147     ASSERT(profiles);
148 
149     va_status = vaQueryConfigProfiles(va_dpy, profiles, &num_profiles);
150     ASSERT( VA_STATUS_SUCCESS == va_status );
151 
152     status("vaQueryConfigProfiles reports %d profiles\n", num_profiles);
153     ASSERT(num_profiles <= max_profiles);
154     ASSERT(num_profiles > 0);
155 
156     if (print_status)
157     {
158         for(i = 0; i < num_profiles; i++)
159         {
160             status("  profile %d [%s]\n", profiles[i], profile2string(profiles[i]));
161         }
162     }
163 }
164