~misterc/libva/Trunk

« back to all changes in this revision

Viewing changes to test/basic/test_common.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 <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
 
 
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
 
 
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
 
 
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
 
        PROFILE(HEVCMain)
113
 
        PROFILE(HEVCMain10)
114
 
        PROFILE(VP9Profile0)
115
 
        PROFILE(VP9Profile1)
116
 
        PROFILE(VP9Profile2)
117
 
        PROFILE(VP9Profile3)
118
 
    }
119
 
    ASSERT(0);
120
 
    return "Unknown";
121
 
}
122
 
 
123
 
#define ENTRYPOINT(profile)     case VAEntrypoint##profile:     return("VAEntrypoint" #profile);
124
 
 
125
 
const char *entrypoint2string(VAEntrypoint entrypoint)
126
 
{
127
 
    switch(entrypoint)
128
 
    {
129
 
        ENTRYPOINT(VLD)
130
 
        ENTRYPOINT(IZZ)
131
 
        ENTRYPOINT(IDCT)
132
 
        ENTRYPOINT(MoComp)
133
 
        ENTRYPOINT(Deblocking)
134
 
        ENTRYPOINT(EncSlice)
135
 
        ENTRYPOINT(EncPicture)
136
 
        ENTRYPOINT(EncSliceLP)
137
 
        ENTRYPOINT(VideoProc)
138
 
    }
139
 
    ASSERT(0);
140
 
    return "Unknown";
141
 
}
142
 
 
143
 
 
144
 
void test_profiles()
145
 
{
146
 
    int max_profiles;
147
 
    int i;
148
 
    max_profiles = vaMaxNumProfiles(va_dpy);
149
 
    status("vaMaxNumProfiles = %d\n", max_profiles);
150
 
    ASSERT(max_profiles > 0);
151
 
    profiles = malloc(max_profiles * sizeof(VAProfile));
152
 
    ASSERT(profiles);
153
 
      
154
 
    va_status = vaQueryConfigProfiles(va_dpy, profiles, &num_profiles);
155
 
    ASSERT( VA_STATUS_SUCCESS == va_status );
156
 
      
157
 
    status("vaQueryConfigProfiles reports %d profiles\n", num_profiles);
158
 
    ASSERT(num_profiles <= max_profiles);
159
 
    ASSERT(num_profiles > 0);
160
 
    
161
 
    if (print_status)
162
 
    {
163
 
        for(i = 0; i < num_profiles; i++)
164
 
        {
165
 
            status("  profile %d [%s]\n", profiles[i], profile2string(profiles[i]));
166
 
        }
167
 
    }
168
 
}