OSDN Git Service

Bump intel-vaapi-driver to 1.8.3.pre1 for development
[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         return ProfileNotSupported();
53
54     return EntrypointNotSupported();
55 }
56
57 VAStatus H264LPNotSupported()
58 {
59     I965TestEnvironment *env(I965TestEnvironment::instance());
60     EXPECT_PTR(env);
61
62     struct i965_driver_data *i965(*env);
63     EXPECT_PTR(i965);
64
65     if (!HAS_H264_DECODING(i965)
66         && !HAS_H264_ENCODING(i965))
67         return ProfileNotSupported();
68
69     return EntrypointNotSupported();
70 }
71
72 VAStatus H264MVCNotSupported()
73 {
74     I965TestEnvironment *env(I965TestEnvironment::instance());
75     EXPECT_PTR(env);
76
77     struct i965_driver_data *i965(*env);
78     EXPECT_PTR(i965);
79
80     if (!HAS_H264_MVC_DECODING(i965))
81         return ProfileNotSupported();
82
83     return EntrypointNotSupported();
84 }
85
86 VAStatus HasEncodeSupport()
87 {
88     I965TestEnvironment *env(I965TestEnvironment::instance());
89     EXPECT_PTR(env);
90
91     struct i965_driver_data *i965(*env);
92     EXPECT_PTR(i965);
93
94     if (HAS_H264_ENCODING(i965))
95         return VA_STATUS_SUCCESS;
96
97     return H264NotSupported();
98 }
99
100 VAStatus HasLPEncodeSupport()
101 {
102     I965TestEnvironment *env(I965TestEnvironment::instance());
103     EXPECT_PTR(env);
104
105     struct i965_driver_data *i965(*env);
106     EXPECT_PTR(i965);
107
108     if (IS_SKL(i965->intel.device_info))
109         return VA_STATUS_SUCCESS;
110
111     if (HAS_LP_H264_ENCODING(i965))
112         return VA_STATUS_SUCCESS;
113
114     return H264LPNotSupported();
115 }
116
117 VAStatus HasMVCEncodeSupport()
118 {
119     I965TestEnvironment *env(I965TestEnvironment::instance());
120     EXPECT_PTR(env);
121
122     struct i965_driver_data *i965(*env);
123     EXPECT_PTR(i965);
124
125     if (HAS_H264_MVC_ENCODING(i965))
126         return VA_STATUS_SUCCESS;
127
128     return H264MVCNotSupported();
129 }
130
131 static const std::vector<ConfigTestInput> inputs = {
132     {VAProfileH264Baseline, VAEntrypointEncSlice, &ProfileNotSupported},
133     {VAProfileH264Baseline, VAEntrypointEncSliceLP, &ProfileNotSupported},
134     {VAProfileH264Baseline, VAEntrypointEncPicture, &ProfileNotSupported},
135
136     {VAProfileH264ConstrainedBaseline, VAEntrypointEncSlice, &HasEncodeSupport},
137     {VAProfileH264ConstrainedBaseline, VAEntrypointEncSliceLP, &HasLPEncodeSupport},
138     {VAProfileH264ConstrainedBaseline, VAEntrypointEncPicture, &H264NotSupported},
139
140     {VAProfileH264Main, VAEntrypointEncSlice, &HasEncodeSupport},
141     {VAProfileH264Main, VAEntrypointEncSliceLP, &HasLPEncodeSupport},
142     {VAProfileH264Main, VAEntrypointEncPicture, &H264NotSupported},
143
144     {VAProfileH264High, VAEntrypointEncSlice, &HasEncodeSupport},
145     {VAProfileH264High, VAEntrypointEncSliceLP, &HasLPEncodeSupport},
146     {VAProfileH264High, VAEntrypointEncPicture, &H264NotSupported},
147
148     {VAProfileH264MultiviewHigh, VAEntrypointEncSlice, &HasMVCEncodeSupport},
149     {VAProfileH264MultiviewHigh, VAEntrypointEncSliceLP, &H264MVCNotSupported},
150     {VAProfileH264MultiviewHigh, VAEntrypointEncPicture, &H264MVCNotSupported},
151
152     {VAProfileH264StereoHigh, VAEntrypointEncSlice, &HasMVCEncodeSupport},
153     {VAProfileH264StereoHigh, VAEntrypointEncSliceLP, &H264MVCNotSupported},
154     {VAProfileH264StereoHigh, VAEntrypointEncPicture, &H264MVCNotSupported},
155 };
156
157 INSTANTIATE_TEST_CASE_P(
158     AVCEncode, I965ConfigTest, ::testing::ValuesIn(inputs));
159
160 } // namespace Encode
161 } // namespace AVC