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