OSDN Git Service

ENC/VP8: set value to VA_ATTRIB_NOT_SUPPORTED when querying VAConfigAttribEncPackedHe...
[android-x86/hardware-intel-common-vaapi.git] / test / i965_avce_config_test.cpp
1 /*
2  * Copyright (C) 2016 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 "i965_config_test.h"
26
27 namespace AVC {
28 namespace Encode {
29
30 VAStatus ProfileNotSupported()
31 {
32     return VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
33 }
34
35 VAStatus EntrypointNotSupported()
36 {
37     return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
38 }
39
40 //H264*NotSupported functions report properly if profile is not supported or
41 //only entrypoint is not supported
42 VAStatus H264NotSupported()
43 {
44     I965TestEnvironment *env(I965TestEnvironment::instance());
45     EXPECT_PTR(env);
46
47     struct i965_driver_data *i965(*env);
48     EXPECT_PTR(i965);
49
50     if (!HAS_H264_DECODING(i965)
51         && !HAS_LP_H264_ENCODING(i965)
52         && !HAS_FEI_H264_ENCODING(i965)
53         && !HAS_H264_PREENC(i965))
54         return ProfileNotSupported();
55
56     return EntrypointNotSupported();
57 }
58
59 VAStatus H264LPNotSupported()
60 {
61     I965TestEnvironment *env(I965TestEnvironment::instance());
62     EXPECT_PTR(env);
63
64     struct i965_driver_data *i965(*env);
65     EXPECT_PTR(i965);
66
67     if (!HAS_H264_DECODING(i965)
68         && !HAS_H264_ENCODING(i965)
69         && !HAS_FEI_H264_ENCODING(i965)
70         && !HAS_H264_PREENC(i965))
71         return ProfileNotSupported();
72
73     return EntrypointNotSupported();
74 }
75
76 VAStatus H264FEINotSupported()
77 {
78     I965TestEnvironment *env(I965TestEnvironment::instance());
79     EXPECT_PTR(env);
80
81     struct i965_driver_data *i965(*env);
82     EXPECT_PTR(i965);
83
84     if (!HAS_H264_DECODING(i965)
85         && !HAS_H264_ENCODING(i965)
86         && !HAS_LP_H264_ENCODING(i965)
87         && !HAS_H264_PREENC(i965))
88         return ProfileNotSupported();
89
90     return EntrypointNotSupported();
91 }
92
93 VAStatus H264PreEncodeNotSupported()
94 {
95     I965TestEnvironment *env(I965TestEnvironment::instance());
96     EXPECT_PTR(env);
97
98     struct i965_driver_data *i965(*env);
99     EXPECT_PTR(i965);
100
101     if (!HAS_H264_DECODING(i965)
102         && !HAS_H264_ENCODING(i965)
103         && !HAS_LP_H264_ENCODING(i965)
104         && !HAS_FEI_H264_ENCODING(i965))
105          return ProfileNotSupported();
106
107     return EntrypointNotSupported();
108 }
109
110 VAStatus H264MVCNotSupported()
111 {
112     I965TestEnvironment *env(I965TestEnvironment::instance());
113     EXPECT_PTR(env);
114
115     struct i965_driver_data *i965(*env);
116     EXPECT_PTR(i965);
117
118     if (!HAS_H264_MVC_DECODING_PROFILE(i965, VAProfileH264MultiviewHigh))
119         return ProfileNotSupported();
120
121     return EntrypointNotSupported();
122 }
123
124 VAStatus H264StereoNotSupported()
125 {
126     I965TestEnvironment *env(I965TestEnvironment::instance());
127     EXPECT_PTR(env);
128
129     struct i965_driver_data *i965(*env);
130     EXPECT_PTR(i965);
131
132     if (!HAS_H264_MVC_DECODING_PROFILE(i965, VAProfileH264StereoHigh))
133         return ProfileNotSupported();
134
135     return EntrypointNotSupported();
136 }
137
138 VAStatus HasEncodeSupport()
139 {
140     I965TestEnvironment *env(I965TestEnvironment::instance());
141     EXPECT_PTR(env);
142
143     struct i965_driver_data *i965(*env);
144     EXPECT_PTR(i965);
145
146     if (HAS_H264_ENCODING(i965))
147         return VA_STATUS_SUCCESS;
148
149     return H264NotSupported();
150 }
151
152 VAStatus HasLPEncodeSupport()
153 {
154     I965TestEnvironment *env(I965TestEnvironment::instance());
155     EXPECT_PTR(env);
156
157     struct i965_driver_data *i965(*env);
158     EXPECT_PTR(i965);
159
160     if (IS_SKL(i965->intel.device_info))
161         return VA_STATUS_SUCCESS;
162
163     if (HAS_LP_H264_ENCODING(i965))
164         return VA_STATUS_SUCCESS;
165
166     return H264LPNotSupported();
167 }
168
169
170 VAStatus HasFEIEncodeSupport()
171 {
172     I965TestEnvironment *env(I965TestEnvironment::instance());
173     EXPECT_PTR(env);
174
175     struct i965_driver_data *i965(*env);
176     EXPECT_PTR(i965);
177
178     if (IS_SKL(i965->intel.device_info))
179         return VA_STATUS_SUCCESS;
180
181     if (HAS_FEI_H264_ENCODING(i965))
182         return VA_STATUS_SUCCESS;
183
184     return H264FEINotSupported();
185 }
186
187 VAStatus HasPreEncodeSupport()
188 {
189     I965TestEnvironment *env(I965TestEnvironment::instance());
190     EXPECT_PTR(env);
191
192     struct i965_driver_data *i965(*env);
193     EXPECT_PTR(i965);
194
195     if (IS_SKL(i965->intel.device_info))
196         return VA_STATUS_SUCCESS;
197
198     if (HAS_H264_PREENC(i965))
199         return VA_STATUS_SUCCESS;
200
201     return H264PreEncodeNotSupported();
202 }
203
204 VAStatus HasMVCEncodeSupport()
205 {
206     I965TestEnvironment *env(I965TestEnvironment::instance());
207     EXPECT_PTR(env);
208
209     struct i965_driver_data *i965(*env);
210     EXPECT_PTR(i965);
211
212     if (HAS_H264_MVC_ENCODING(i965))
213         return VA_STATUS_SUCCESS;
214
215     return H264MVCNotSupported();
216 }
217
218 VAStatus HasStereoEncodeSupport()
219 {
220     I965TestEnvironment *env(I965TestEnvironment::instance());
221     EXPECT_PTR(env);
222
223     struct i965_driver_data *i965(*env);
224     EXPECT_PTR(i965);
225
226     if (HAS_H264_MVC_ENCODING(i965))
227         return VA_STATUS_SUCCESS;
228
229     return H264StereoNotSupported();
230 }
231
232 static const std::vector<ConfigTestInput> inputs = {
233     {VAProfileH264ConstrainedBaseline, VAEntrypointEncSlice, &HasEncodeSupport},
234     {VAProfileH264ConstrainedBaseline, VAEntrypointEncSliceLP, &HasLPEncodeSupport},
235     {VAProfileH264ConstrainedBaseline, VAEntrypointEncPicture, &H264NotSupported},
236     {VAProfileH264ConstrainedBaseline, VAEntrypointFEI, &HasFEIEncodeSupport},
237     {VAProfileH264ConstrainedBaseline, VAEntrypointStats, &HasPreEncodeSupport},
238
239     {VAProfileH264Main, VAEntrypointEncSlice, &HasEncodeSupport},
240     {VAProfileH264Main, VAEntrypointEncSliceLP, &HasLPEncodeSupport},
241     {VAProfileH264Main, VAEntrypointEncPicture, &H264NotSupported},
242     {VAProfileH264Main, VAEntrypointFEI, &HasFEIEncodeSupport},
243     {VAProfileH264Main, VAEntrypointStats, &HasPreEncodeSupport},
244
245     {VAProfileH264High, VAEntrypointEncSlice, &HasEncodeSupport},
246     {VAProfileH264High, VAEntrypointEncSliceLP, &HasLPEncodeSupport},
247     {VAProfileH264High, VAEntrypointEncPicture, &H264NotSupported},
248     {VAProfileH264High, VAEntrypointFEI, &HasFEIEncodeSupport},
249     {VAProfileH264High, VAEntrypointStats, &HasPreEncodeSupport},
250
251     {VAProfileH264MultiviewHigh, VAEntrypointEncSlice, &HasMVCEncodeSupport},
252     {VAProfileH264MultiviewHigh, VAEntrypointEncSliceLP, &H264MVCNotSupported},
253     {VAProfileH264MultiviewHigh, VAEntrypointEncPicture, &H264MVCNotSupported},
254     {VAProfileH264MultiviewHigh, VAEntrypointFEI, &H264MVCNotSupported},
255     {VAProfileH264MultiviewHigh, VAEntrypointStats, &H264MVCNotSupported},
256
257     {VAProfileH264StereoHigh, VAEntrypointEncSlice, &HasStereoEncodeSupport},
258     {VAProfileH264StereoHigh, VAEntrypointEncSliceLP, &H264StereoNotSupported},
259     {VAProfileH264StereoHigh, VAEntrypointEncPicture, &H264StereoNotSupported},
260     {VAProfileH264StereoHigh, VAEntrypointFEI, &H264StereoNotSupported},
261     {VAProfileH264StereoHigh, VAEntrypointStats, &H264MVCNotSupported},
262 };
263
264 INSTANTIATE_TEST_CASE_P(
265     AVCEncode, I965ConfigTest, ::testing::ValuesIn(inputs));
266
267 } // namespace Encode
268 } // namespace AVC