95e853113502c45d1c16ec5eaaf3331d9318a5b4
[profile/ivi/libva.git] / test / vainfo / vainfo.c
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 <stdarg.h>
26 #include <stdio.h>
27 #include <string.h>
28 #include <stdlib.h>
29 #include "va_display.h"
30
31 #define CHECK_VASTATUS(va_status,func, ret)                             \
32 if (va_status != VA_STATUS_SUCCESS) {                                   \
33     fprintf(stderr,"%s failed with error code %d (%s),exit\n",func, va_status, vaErrorStr(va_status)); \
34     exit(ret);                                                          \
35 }
36
37 static char * profile_string(VAProfile profile)
38 {
39     switch (profile) {
40             case VAProfileNone: return "VAProfileNone";
41             case VAProfileMPEG2Simple: return "VAProfileMPEG2Simple";
42             case VAProfileMPEG2Main: return "VAProfileMPEG2Main";
43             case VAProfileMPEG4Simple: return "VAProfileMPEG4Simple";
44             case VAProfileMPEG4AdvancedSimple: return "VAProfileMPEG4AdvancedSimple";
45             case VAProfileMPEG4Main: return "VAProfileMPEG4Main";
46             case VAProfileH264Baseline: return "VAProfileH264Baseline";
47             case VAProfileH264Main: return "VAProfileH264Main";
48             case VAProfileH264High: return "VAProfileH264High";
49             case VAProfileVC1Simple: return "VAProfileVC1Simple";
50             case VAProfileVC1Main: return "VAProfileVC1Main";
51             case VAProfileVC1Advanced: return "VAProfileVC1Advanced";
52             case VAProfileH263Baseline: return "VAProfileH263Baseline";
53             case VAProfileH264ConstrainedBaseline: return "VAProfileH264ConstrainedBaseline";
54             case VAProfileJPEGBaseline: return "VAProfileJPEGBaseline";
55             default:
56                 break;
57     }
58     return "<unknown profile>";
59 }
60
61
62 static char * entrypoint_string(VAEntrypoint entrypoint)
63 {
64     switch (entrypoint) {
65             case VAEntrypointVLD:return "VAEntrypointVLD";
66             case VAEntrypointIZZ:return "VAEntrypointIZZ";
67             case VAEntrypointIDCT:return "VAEntrypointIDCT";
68             case VAEntrypointMoComp:return "VAEntrypointMoComp";
69             case VAEntrypointDeblocking:return "VAEntrypointDeblocking";
70             case VAEntrypointEncSlice:return "VAEntrypointEncSlice";
71             case VAEntrypointEncPicture:return "VAEntrypointEncPicture";
72             case VAEntrypointVideoProc:return "VAEntrypointVideoProc";
73             default:
74                 break;
75     }
76     return "<unknown entrypoint>";
77 }
78
79 int main(int argc, const char* argv[])
80 {
81   VADisplay va_dpy;
82   VAStatus va_status;
83   int major_version, minor_version;
84   const char *driver;
85   const char *name = strrchr(argv[0], '/'); 
86   VAProfile profile;
87   VAEntrypoint entrypoint, entrypoints[10];
88   int num_entrypoint;
89   
90   if (name)
91       name++;
92   else
93       name = argv[0];
94
95   va_dpy = va_open_display();
96   if (NULL == va_dpy)
97   {
98       fprintf(stderr, "%s: vaGetDisplay() failed\n", name);
99       return 2;
100   }
101   
102   va_status = vaInitialize(va_dpy, &major_version, &minor_version);
103   CHECK_VASTATUS(va_status, "vaInitialize", 3);
104   
105   printf("%s: VA-API version: %d.%d (libva %s)\n",
106          name, major_version, minor_version, LIBVA_VERSION_S);
107
108   driver = vaQueryVendorString(va_dpy);
109   printf("%s: Driver version: %s\n", name, driver ? driver : "<unknown>");
110
111   printf("%s: Supported profile and entrypoints\n", name);
112   for   (profile = VAProfileNone; profile <= VAProfileH264ConstrainedBaseline; profile++) {
113       char *profile_str;
114
115       va_status = vaQueryConfigEntrypoints(va_dpy, profile, entrypoints, 
116                                            &num_entrypoint);
117       if (va_status == VA_STATUS_ERROR_UNSUPPORTED_PROFILE)
118         continue;
119
120       CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints", 4);
121
122       profile_str = profile_string(profile);
123       for (entrypoint = 0; entrypoint < num_entrypoint; entrypoint++)
124           printf("      %-32s:  %s\n", profile_str, entrypoint_string(entrypoints[entrypoint]));
125   }
126   
127   vaTerminate(va_dpy);
128   va_close_display(va_dpy);
129   
130   return 0;
131 }