1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
/*
* Copyright (C) 2016 Intel Corporation. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef TEST_H
#define TEST_H
#include <gtest/gtest.h>
#include <iostream>
#include <string>
#include <va/va.h>
#define EXPECT_STATUS(status) \
EXPECT_EQ(VaapiStatus(VA_STATUS_SUCCESS), VaapiStatus(status))
#define ASSERT_STATUS(status) \
ASSERT_EQ(VaapiStatus(VA_STATUS_SUCCESS), VaapiStatus(status))
#define EXPECT_STATUS_EQ(expect, status) \
EXPECT_EQ(VaapiStatus(expect), VaapiStatus(status))
#define ASSERT_STATUS_EQ(expect, status) \
ASSERT_EQ(VaapiStatus(expect), VaapiStatus(status))
#define EXPECT_ID(id) \
EXPECT_NE(VA_INVALID_ID, (id))
#define ASSERT_ID(id) \
ASSERT_NE(VA_INVALID_ID, (id))
#define EXPECT_INVALID_ID(id) \
EXPECT_EQ(VA_INVALID_ID, (id))
#define ASSERT_INVALID_ID(id) \
ASSERT_EQ(VA_INVALID_ID, (id))
#define EXPECT_PTR(ptr) \
EXPECT_FALSE(NULL == (ptr))
#define ASSERT_PTR(ptr) \
ASSERT_FALSE(NULL == (ptr))
#define EXPECT_PTR_NULL(ptr) \
EXPECT_TRUE(NULL == (ptr))
#define ASSERT_PTR_NULL(ptr) \
ASSERT_TRUE(NULL == (ptr))
class VaapiStatus
{
public:
explicit VaapiStatus(VAStatus status)
: m_status(status)
{ }
bool operator ==(const VaapiStatus& other) const
{
return m_status == other.m_status;
}
friend std::ostream& operator <<(std::ostream& os, const VaapiStatus& t)
{
std::string status;
switch(t.m_status) {
case VA_STATUS_SUCCESS:
status = "VA_STATUS_SUCCESS"; break;
case VA_STATUS_ERROR_OPERATION_FAILED:
status = "VA_STATUS_ERROR_OPERATION_FAILED"; break;
case VA_STATUS_ERROR_ALLOCATION_FAILED:
status = "VA_STATUS_ERROR_ALLOCATION_FAILED"; break;
case VA_STATUS_ERROR_INVALID_DISPLAY:
status = "VA_STATUS_ERROR_INVALID_DISPLAY"; break;
case VA_STATUS_ERROR_INVALID_CONFIG:
status = "VA_STATUS_ERROR_INVALID_CONFIG"; break;
case VA_STATUS_ERROR_INVALID_CONTEXT:
status = "VA_STATUS_ERROR_INVALID_CONTEXT"; break;
case VA_STATUS_ERROR_INVALID_SURFACE:
status = "VA_STATUS_ERROR_INVALID_SURFACE"; break;
case VA_STATUS_ERROR_INVALID_BUFFER:
status = "VA_STATUS_ERROR_INVALID_BUFFER"; break;
case VA_STATUS_ERROR_INVALID_IMAGE:
status = "VA_STATUS_ERROR_INVALID_IMAGE"; break;
case VA_STATUS_ERROR_INVALID_SUBPICTURE:
status = "VA_STATUS_ERROR_INVALID_SUBPICTURE"; break;
case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED:
status = "VA_STATUS_ERROR_ATTR_NOT_SUPPORTED"; break;
case VA_STATUS_ERROR_MAX_NUM_EXCEEDED:
status = "VA_STATUS_ERROR_MAX_NUM_EXCEEDED"; break;
case VA_STATUS_ERROR_UNSUPPORTED_PROFILE:
status = "VA_STATUS_ERROR_UNSUPPORTED_PROFILE"; break;
case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT:
status = "VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT"; break;
case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT:
status = "VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT"; break;
case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE:
status = "VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE"; break;
case VA_STATUS_ERROR_SURFACE_BUSY:
status = "VA_STATUS_ERROR_SURFACE_BUSY"; break;
case VA_STATUS_ERROR_FLAG_NOT_SUPPORTED:
status = "VA_STATUS_ERROR_FLAG_NOT_SUPPORTED"; break;
case VA_STATUS_ERROR_INVALID_PARAMETER:
status = "VA_STATUS_ERROR_INVALID_PARAMETER"; break;
case VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED:
status = "VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED"; break;
case VA_STATUS_ERROR_UNIMPLEMENTED:
status = "VA_STATUS_ERROR_UNIMPLEMENTED"; break;
case VA_STATUS_ERROR_SURFACE_IN_DISPLAYING:
status = "VA_STATUS_ERROR_SURFACE_IN_DISPLAYING"; break;
case VA_STATUS_ERROR_INVALID_IMAGE_FORMAT:
status = "VA_STATUS_ERROR_INVALID_IMAGE_FORMAT"; break;
case VA_STATUS_ERROR_DECODING_ERROR:
status = "VA_STATUS_ERROR_DECODING_ERROR"; break;
case VA_STATUS_ERROR_ENCODING_ERROR:
status = "VA_STATUS_ERROR_ENCODING_ERROR"; break;
case VA_STATUS_ERROR_INVALID_VALUE:
status = "VA_STATUS_ERROR_INVALID_VALUE"; break;
case VA_STATUS_ERROR_UNSUPPORTED_FILTER:
status = "VA_STATUS_ERROR_UNSUPPORTED_FILTER"; break;
case VA_STATUS_ERROR_INVALID_FILTER_CHAIN:
status = "VA_STATUS_ERROR_INVALID_FILTER_CHAIN"; break;
case VA_STATUS_ERROR_HW_BUSY:
status = "VA_STATUS_ERROR_HW_BUSY"; break;
case VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE:
status = "VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE"; break;
case VA_STATUS_ERROR_UNKNOWN:
status = "VA_STATUS_ERROR_UNKNOWN"; break;
default:
status = "Unknown VAStatus";
}
os << status;
return os;
}
VAStatus m_status;
};
#endif // TEST_H
|