2 * Copyright (C) 2016 Intel Corporation. All Rights Reserved.
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:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
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.
25 #include "i965_avce_test_common.h"
26 #include "i965_streamable.h"
27 #include "i965_test_fixture.h"
37 : public I965TestFixture
38 , public ::testing::WithParamInterface<
39 std::tuple<VAProfile, VAEntrypoint> >
44 I965TestFixture::SetUp();
45 std::tie(profile, entrypoint) = GetParam();
50 if (context != VA_INVALID_ID)
51 destroyContext(context);
52 if (config != VA_INVALID_ID)
53 destroyConfig(config);
54 I965TestFixture::TearDown();
57 operator struct intel_encoder_context const *()
59 if (config == VA_INVALID_ID) return NULL;
61 struct i965_driver_data *i965(*this);
62 if (not i965) return NULL;
64 if (IS_GEN9(i965->intel.device_info)
65 ||IS_GEN10(i965->intel.device_info))
68 struct object_context const *obj_context = CONTEXT(context);
69 if (not obj_context) return NULL;
71 return reinterpret_cast<struct intel_encoder_context const *>(
72 obj_context->hw_context);
76 VAEntrypoint entrypoint;
77 VAConfigID config = VA_INVALID_ID;
78 VAContextID context = VA_INVALID_ID;
80 int min_resolution_width_height = I965_MIN_CODEC_ENC_RESOLUTION_WIDTH_HEIGHT;
83 TEST_P(AVCEContextTest, RateControl)
85 if (not IsSupported(profile, entrypoint)) {
86 RecordProperty("skipped", true);
87 std::cout << "[ SKIPPED ] " << getFullTestName()
88 << " is unsupported on this hardware" << std::endl;
92 static const std::vector<unsigned> rateControls = {
93 VA_RC_NONE, VA_RC_CBR, VA_RC_VBR, VA_RC_VCM, VA_RC_CQP,
94 VA_RC_VBR_CONSTRAINED, VA_RC_MB,
97 struct i965_driver_data *i965(*this);
100 const std::map<VAEntrypoint, unsigned> supportedBRC = {
101 {VAEntrypointEncSlice, i965->codec_info->h264_brc_mode},
102 {VAEntrypointEncSliceLP, i965->codec_info->lp_h264_brc_mode},
103 {VAEntrypointFEI, VA_RC_CQP},
104 {VAEntrypointStats, VA_ATTRIB_NOT_SUPPORTED},
107 for (auto rc : rateControls) {
108 ConfigAttribs attribs(1, {type:VAConfigAttribRateControl, value:rc});
110 const VAStatus expect =
111 (rc & supportedBRC.at(entrypoint)) ?
112 VA_STATUS_SUCCESS : VA_STATUS_ERROR_INVALID_VALUE;
114 config = createConfig(profile, entrypoint, attribs, expect);
115 if (expect != VA_STATUS_SUCCESS) continue;
117 context = createContext(
119 min_resolution_width_height,
120 min_resolution_width_height);
122 if (HasFailure()) continue;
124 struct intel_encoder_context const *hw_context(*this);
125 EXPECT_PTR(hw_context);
126 if (HasFailure()) continue;
128 EXPECT_EQ(rc, hw_context->rate_control_mode);
130 destroyContext(context);
131 destroyConfig(config);
132 context = VA_INVALID_ID;
133 config = VA_INVALID_ID;
137 TEST_P(AVCEContextTest, Codec)
139 if (not IsSupported(profile, entrypoint)) {
140 RecordProperty("skipped", true);
141 std::cout << "[ SKIPPED ] " << getFullTestName()
142 << " is unsupported on this hardware" << std::endl;
146 static const std::map<VAProfile, int> codecs = {
147 {VAProfileH264ConstrainedBaseline, CODEC_H264},
148 {VAProfileH264Main, CODEC_H264},
149 {VAProfileH264High, CODEC_H264},
150 {VAProfileH264MultiviewHigh, CODEC_H264_MVC},
151 {VAProfileH264StereoHigh, CODEC_H264_MVC},
155 config = createConfig(profile, entrypoint);
156 context = createContext(
158 min_resolution_width_height,
159 min_resolution_width_height);
162 struct intel_encoder_context const *hw_context(*this);
163 ASSERT_PTR(hw_context);
165 EXPECT_EQ(codecs.at(profile), hw_context->codec);
168 TEST_P(AVCEContextTest, LowPowerMode)
170 if (not IsSupported(profile, entrypoint)) {
171 RecordProperty("skipped", true);
172 std::cout << "[ SKIPPED ] " << getFullTestName()
173 << " is unsupported on this hardware" << std::endl;
178 config = createConfig(profile, entrypoint);
179 context = createContext(
181 min_resolution_width_height,
182 min_resolution_width_height);
185 struct intel_encoder_context const *hw_context(*this);
186 ASSERT_PTR(hw_context);
189 (entrypoint == VAEntrypointEncSliceLP ? 1u : 0u),
190 hw_context->low_power_mode
194 TEST_P(AVCEContextTest, ROINotSpecified)
196 if (not IsSupported(profile, entrypoint)) {
197 RecordProperty("skipped", true);
198 std::cout << "[ SKIPPED ] " << getFullTestName()
199 << " is unsupported on this hardware" << std::endl;
203 // The lack of the VAConfigAttribEncROI config attribute
206 config = createConfig(profile, entrypoint);
207 context = createContext(
209 min_resolution_width_height,
210 min_resolution_width_height);
213 struct intel_encoder_context const *hw_context(*this);
214 ASSERT_PTR(hw_context);
216 EXPECT_EQ(0u, hw_context->context_roi);
219 TEST_P(AVCEContextTest, ROISpecified)
221 if (not IsSupported(profile, entrypoint)) {
222 RecordProperty("skipped", true);
223 std::cout << "[ SKIPPED ] " << getFullTestName()
224 << " is unsupported on this hardware" << std::endl;
228 static const std::map<VAProfile, unsigned> roiSupport = {
229 {VAProfileH264ConstrainedBaseline, 1}, {VAProfileH264Main, 1},
230 {VAProfileH264High, 1}, {VAProfileH264MultiviewHigh, 0},
231 {VAProfileH264StereoHigh, 0},
234 // The presence of the VAConfigAttribEncROI config attribute
235 // will enable it for supported profile
236 ConfigAttribs attribs(1, {type:VAConfigAttribEncROI});
238 config = createConfig(profile, entrypoint, attribs);
239 context = createContext(
241 min_resolution_width_height,
242 min_resolution_width_height);
245 struct intel_encoder_context const *hw_context(*this);
246 ASSERT_PTR(hw_context);
248 EXPECT_EQ(roiSupport.at(profile), hw_context->context_roi);
251 TEST_P(AVCEContextTest, QualityRange)
253 if (not IsSupported(profile, entrypoint)) {
254 RecordProperty("skipped", true);
255 std::cout << "[ SKIPPED ] " << getFullTestName()
256 << " is unsupported on this hardware" << std::endl;
261 config = createConfig(profile, entrypoint);
262 context = createContext(
264 min_resolution_width_height,
265 min_resolution_width_height);
268 struct intel_encoder_context const *hw_context(*this);
269 ASSERT_PTR(hw_context);
271 std::map<VAProfile, unsigned> qranges;
274 {VAProfileH264ConstrainedBaseline, entrypoint == VAEntrypointEncSliceLP
275 ? ENCODER_LP_QUALITY_RANGE : ENCODER_QUALITY_RANGE_AVC},
276 {VAProfileH264Main, entrypoint == VAEntrypointEncSliceLP
277 ? ENCODER_LP_QUALITY_RANGE : ENCODER_QUALITY_RANGE_AVC},
278 {VAProfileH264High, entrypoint == VAEntrypointEncSliceLP
279 ? ENCODER_LP_QUALITY_RANGE : ENCODER_QUALITY_RANGE_AVC},
280 {VAProfileH264MultiviewHigh, ENCODER_QUALITY_RANGE_AVC},
281 {VAProfileH264StereoHigh, ENCODER_QUALITY_RANGE_AVC},
285 {VAProfileH264ConstrainedBaseline, entrypoint == VAEntrypointEncSliceLP
286 ? ENCODER_LP_QUALITY_RANGE : ENCODER_QUALITY_RANGE},
287 {VAProfileH264Main, entrypoint == VAEntrypointEncSliceLP
288 ? ENCODER_LP_QUALITY_RANGE : ENCODER_QUALITY_RANGE},
289 {VAProfileH264High, entrypoint == VAEntrypointEncSliceLP
290 ? ENCODER_LP_QUALITY_RANGE : ENCODER_QUALITY_RANGE},
291 {VAProfileH264MultiviewHigh, 1u},
292 {VAProfileH264StereoHigh, 1u},
296 EXPECT_EQ(qranges.at(profile), hw_context->quality_range);
299 INSTANTIATE_TEST_CASE_P(
300 AVCEncode, AVCEContextTest, ::testing::Values(
301 std::make_tuple(VAProfileH264ConstrainedBaseline, VAEntrypointEncSlice),
302 std::make_tuple(VAProfileH264ConstrainedBaseline, VAEntrypointEncSliceLP),
303 std::make_tuple(VAProfileH264ConstrainedBaseline, VAEntrypointFEI),
304 std::make_tuple(VAProfileH264ConstrainedBaseline, VAEntrypointStats),
305 std::make_tuple(VAProfileH264Main, VAEntrypointEncSlice),
306 std::make_tuple(VAProfileH264Main, VAEntrypointEncSliceLP),
307 std::make_tuple(VAProfileH264Main, VAEntrypointFEI),
308 std::make_tuple(VAProfileH264Main, VAEntrypointStats),
309 std::make_tuple(VAProfileH264High, VAEntrypointEncSlice),
310 std::make_tuple(VAProfileH264High, VAEntrypointEncSliceLP),
311 std::make_tuple(VAProfileH264High, VAEntrypointFEI),
312 std::make_tuple(VAProfileH264High, VAEntrypointStats),
313 std::make_tuple(VAProfileH264MultiviewHigh, VAEntrypointEncSlice),
314 std::make_tuple(VAProfileH264StereoHigh, VAEntrypointEncSlice)
318 } // namespace Encode