~misterc/libva/Trunk

« back to all changes in this revision

Viewing changes to test/vainfo/vainfo.c

  • Committer: Sean V Kelley
  • Date: 2017-02-18 23:19:05 UTC
  • Revision ID: git-v1:7b8cc07dc7a9b954b9a8c9bde5091fb2e8d443dc
PROJECT HAS MOVED

See https://github.com/01org/libva

Signed-off-by: Sean V Kelley <seanvk@posteo.de>

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
#include "va/sysdeps.h"
32
 
 
33
 
#define CHECK_VASTATUS(va_status,func, ret)                             \
34
 
if (va_status != VA_STATUS_SUCCESS) {                                   \
35
 
    fprintf(stderr,"%s failed with error code %d (%s),exit\n",func, va_status, vaErrorStr(va_status)); \
36
 
    ret_val = ret;                                                      \
37
 
    goto error;                                                         \
38
 
}
39
 
 
40
 
static char * profile_string(VAProfile profile)
41
 
{
42
 
    switch (profile) {
43
 
            case VAProfileNone: return "VAProfileNone";
44
 
            case VAProfileMPEG2Simple: return "VAProfileMPEG2Simple";
45
 
            case VAProfileMPEG2Main: return "VAProfileMPEG2Main";
46
 
            case VAProfileMPEG4Simple: return "VAProfileMPEG4Simple";
47
 
            case VAProfileMPEG4AdvancedSimple: return "VAProfileMPEG4AdvancedSimple";
48
 
            case VAProfileMPEG4Main: return "VAProfileMPEG4Main";
49
 
            case VAProfileH264Baseline: return "VAProfileH264Baseline";
50
 
            case VAProfileH264Main: return "VAProfileH264Main";
51
 
            case VAProfileH264High: return "VAProfileH264High";
52
 
            case VAProfileVC1Simple: return "VAProfileVC1Simple";
53
 
            case VAProfileVC1Main: return "VAProfileVC1Main";
54
 
            case VAProfileVC1Advanced: return "VAProfileVC1Advanced";
55
 
            case VAProfileH263Baseline: return "VAProfileH263Baseline";
56
 
            case VAProfileH264ConstrainedBaseline: return "VAProfileH264ConstrainedBaseline";
57
 
            case VAProfileJPEGBaseline: return "VAProfileJPEGBaseline";
58
 
            case VAProfileVP8Version0_3: return "VAProfileVP8Version0_3";
59
 
            case VAProfileH264MultiviewHigh: return "VAProfileH264MultiviewHigh";
60
 
            case VAProfileH264StereoHigh: return "VAProfileH264StereoHigh";
61
 
            case VAProfileHEVCMain: return "VAProfileHEVCMain";
62
 
            case VAProfileHEVCMain10: return "VAProfileHEVCMain10";
63
 
            case VAProfileVP9Profile0: return "VAProfileVP9Profile0";
64
 
            case VAProfileVP9Profile1: return "VAProfileVP9Profile1";
65
 
            case VAProfileVP9Profile2: return "VAProfileVP9Profile2";
66
 
            case VAProfileVP9Profile3: return "VAProfileVP9Profile3";
67
 
 
68
 
            default:
69
 
                break;
70
 
    }
71
 
    return "<unknown profile>";
72
 
}
73
 
 
74
 
 
75
 
static char * entrypoint_string(VAEntrypoint entrypoint)
76
 
{
77
 
    switch (entrypoint) {
78
 
            case VAEntrypointVLD:return "VAEntrypointVLD";
79
 
            case VAEntrypointIZZ:return "VAEntrypointIZZ";
80
 
            case VAEntrypointIDCT:return "VAEntrypointIDCT";
81
 
            case VAEntrypointMoComp:return "VAEntrypointMoComp";
82
 
            case VAEntrypointDeblocking:return "VAEntrypointDeblocking";
83
 
            case VAEntrypointEncSlice:return "VAEntrypointEncSlice";
84
 
            case VAEntrypointEncPicture:return "VAEntrypointEncPicture";
85
 
            case VAEntrypointEncSliceLP:return "VAEntrypointEncSliceLP";
86
 
            case VAEntrypointVideoProc:return "VAEntrypointVideoProc";
87
 
            default:
88
 
                break;
89
 
    }
90
 
    return "<unknown entrypoint>";
91
 
}
92
 
 
93
 
int main(int argc, const char* argv[])
94
 
{
95
 
  VADisplay va_dpy;
96
 
  VAStatus va_status;
97
 
  int major_version, minor_version;
98
 
  const char *driver;
99
 
  const char *name = strrchr(argv[0], '/'); 
100
 
  VAProfile profile, *profile_list = NULL;
101
 
  int num_profiles, max_num_profiles, i;
102
 
  VAEntrypoint entrypoint, entrypoints[10];
103
 
  int num_entrypoint;
104
 
  int ret_val = 0;
105
 
  
106
 
  if (name)
107
 
      name++;
108
 
  else
109
 
      name = argv[0];
110
 
 
111
 
  va_init_display_args(&argc, (char **)argv);
112
 
 
113
 
  va_dpy = va_open_display();
114
 
  if (NULL == va_dpy)
115
 
  {
116
 
      fprintf(stderr, "%s: vaGetDisplay() failed\n", name);
117
 
      return 2;
118
 
  }
119
 
  
120
 
  va_status = vaInitialize(va_dpy, &major_version, &minor_version);
121
 
  CHECK_VASTATUS(va_status, "vaInitialize", 3);
122
 
  
123
 
  printf("%s: VA-API version: %d.%d (libva %s)\n",
124
 
         name, major_version, minor_version, LIBVA_VERSION_S);
125
 
 
126
 
  driver = vaQueryVendorString(va_dpy);
127
 
  printf("%s: Driver version: %s\n", name, driver ? driver : "<unknown>");
128
 
 
129
 
  printf("%s: Supported profile and entrypoints\n", name);
130
 
  max_num_profiles = vaMaxNumProfiles(va_dpy);
131
 
  profile_list = malloc(max_num_profiles * sizeof(VAProfile));
132
 
 
133
 
  if (!profile_list) {
134
 
      printf("Failed to allocate memory for profile list\n");
135
 
      ret_val = 5;
136
 
      goto error;
137
 
  }
138
 
 
139
 
  va_status = vaQueryConfigProfiles(va_dpy, profile_list, &num_profiles);
140
 
  CHECK_VASTATUS(va_status, "vaQueryConfigProfiles", 6);
141
 
 
142
 
  for (i = 0; i < num_profiles; i++) {
143
 
      char *profile_str;
144
 
 
145
 
      profile = profile_list[i];
146
 
      va_status = vaQueryConfigEntrypoints(va_dpy, profile, entrypoints, 
147
 
                                           &num_entrypoint);
148
 
      if (va_status == VA_STATUS_ERROR_UNSUPPORTED_PROFILE)
149
 
        continue;
150
 
 
151
 
      CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints", 4);
152
 
 
153
 
      profile_str = profile_string(profile);
154
 
      for (entrypoint = 0; entrypoint < num_entrypoint; entrypoint++)
155
 
          printf("      %-32s:  %s\n", profile_str, entrypoint_string(entrypoints[entrypoint]));
156
 
  }
157
 
  
158
 
error:
159
 
  free(profile_list);
160
 
  vaTerminate(va_dpy);
161
 
  va_close_display(va_dpy);
162
 
  
163
 
  return ret_val;
164
 
}