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))
67 struct object_context const *obj_context = CONTEXT(context);
68 if (not obj_context) return NULL;
70 return reinterpret_cast<struct intel_encoder_context const *>(
71 obj_context->hw_context);
75 VAEntrypoint entrypoint;
76 VAConfigID config = VA_INVALID_ID;
77 VAContextID context = VA_INVALID_ID;
81 TEST_P(AVCEContextTest, RateControl)
83 if (not IsSupported(profile, entrypoint)) {
84 RecordProperty("skipped", true);
85 std::cout << "[ SKIPPED ] " << getFullTestName()
86 << " is unsupported on this hardware" << std::endl;
90 static const std::vector<unsigned> rateControls = {
91 VA_RC_NONE, VA_RC_CBR, VA_RC_VBR, VA_RC_VCM, VA_RC_CQP,
92 VA_RC_VBR_CONSTRAINED, VA_RC_MB,
95 for (auto rc : rateControls) {
96 ConfigAttribs attribs(1, {type:VAConfigAttribRateControl, value:rc});
97 config = createConfig(profile, entrypoint, attribs);
98 context = createContext(config, 1, 1);
99 if (HasFailure()) continue;
101 struct intel_encoder_context const *hw_context(*this);
102 EXPECT_PTR(hw_context);
103 if (HasFailure()) continue;
105 EXPECT_EQ(rc, hw_context->rate_control_mode);
107 destroyContext(context);
108 destroyConfig(config);
109 context = VA_INVALID_ID;
110 config = VA_INVALID_ID;
114 TEST_P(AVCEContextTest, Codec)
116 if (not IsSupported(profile, entrypoint)) {
117 RecordProperty("skipped", true);
118 std::cout << "[ SKIPPED ] " << getFullTestName()
119 << " is unsupported on this hardware" << std::endl;
123 static const std::map<VAProfile, int> codecs = {
124 {VAProfileH264ConstrainedBaseline, CODEC_H264},
125 {VAProfileH264Main, CODEC_H264},
126 {VAProfileH264High, CODEC_H264},
127 {VAProfileH264MultiviewHigh, CODEC_H264_MVC},
128 {VAProfileH264StereoHigh, CODEC_H264_MVC},
132 config = createConfig(profile, entrypoint);
133 context = createContext(config, 1, 1);
136 struct intel_encoder_context const *hw_context(*this);
137 ASSERT_PTR(hw_context);
139 EXPECT_EQ(codecs.at(profile), hw_context->codec);
142 TEST_P(AVCEContextTest, LowPowerMode)
144 if (not IsSupported(profile, entrypoint)) {
145 RecordProperty("skipped", true);
146 std::cout << "[ SKIPPED ] " << getFullTestName()
147 << " is unsupported on this hardware" << std::endl;
152 config = createConfig(profile, entrypoint);
153 context = createContext(config, 1, 1);
156 struct intel_encoder_context const *hw_context(*this);
157 ASSERT_PTR(hw_context);
160 (entrypoint == VAEntrypointEncSliceLP ? 1u : 0u),
161 hw_context->low_power_mode
165 TEST_P(AVCEContextTest, ROINotSpecified)
167 if (not IsSupported(profile, entrypoint)) {
168 RecordProperty("skipped", true);
169 std::cout << "[ SKIPPED ] " << getFullTestName()
170 << " is unsupported on this hardware" << std::endl;
174 // The lack of the VAConfigAttribEncROI config attribute
177 config = createConfig(profile, entrypoint);
178 context = createContext(config, 1, 1);
181 struct intel_encoder_context const *hw_context(*this);
182 ASSERT_PTR(hw_context);
184 EXPECT_EQ(0u, hw_context->context_roi);
187 TEST_P(AVCEContextTest, ROISpecified)
189 if (not IsSupported(profile, entrypoint)) {
190 RecordProperty("skipped", true);
191 std::cout << "[ SKIPPED ] " << getFullTestName()
192 << " is unsupported on this hardware" << std::endl;
196 static const std::map<VAProfile, unsigned> roiSupport = {
197 {VAProfileH264ConstrainedBaseline, 1}, {VAProfileH264Main, 1},
198 {VAProfileH264High, 1}, {VAProfileH264MultiviewHigh, 0},
199 {VAProfileH264StereoHigh, 0},
202 // The presence of the VAConfigAttribEncROI config attribute
203 // will enable it for supported profile
204 ConfigAttribs attribs(1, {type:VAConfigAttribEncROI});
206 config = createConfig(profile, entrypoint, attribs);
207 context = createContext(config, 1, 1);
210 struct intel_encoder_context const *hw_context(*this);
211 ASSERT_PTR(hw_context);
213 EXPECT_EQ(roiSupport.at(profile), hw_context->context_roi);
216 TEST_P(AVCEContextTest, QualityRange)
218 if (not IsSupported(profile, entrypoint)) {
219 RecordProperty("skipped", true);
220 std::cout << "[ SKIPPED ] " << getFullTestName()
221 << " is unsupported on this hardware" << std::endl;
226 config = createConfig(profile, entrypoint);
227 context = createContext(config, 1, 1);
230 struct intel_encoder_context const *hw_context(*this);
231 ASSERT_PTR(hw_context);
233 std::map<VAProfile, unsigned> qranges;
236 {VAProfileH264ConstrainedBaseline, entrypoint == VAEntrypointEncSliceLP
237 ? ENCODER_LP_QUALITY_RANGE : ENCODER_QUALITY_RANGE_AVC},
238 {VAProfileH264Main, entrypoint == VAEntrypointEncSliceLP
239 ? ENCODER_LP_QUALITY_RANGE : ENCODER_QUALITY_RANGE_AVC},
240 {VAProfileH264High, entrypoint == VAEntrypointEncSliceLP
241 ? ENCODER_LP_QUALITY_RANGE : ENCODER_QUALITY_RANGE_AVC},
242 {VAProfileH264MultiviewHigh, ENCODER_QUALITY_RANGE_AVC},
243 {VAProfileH264StereoHigh, ENCODER_QUALITY_RANGE_AVC},
247 {VAProfileH264ConstrainedBaseline, entrypoint == VAEntrypointEncSliceLP
248 ? ENCODER_LP_QUALITY_RANGE : ENCODER_QUALITY_RANGE},
249 {VAProfileH264Main, entrypoint == VAEntrypointEncSliceLP
250 ? ENCODER_LP_QUALITY_RANGE : ENCODER_QUALITY_RANGE},
251 {VAProfileH264High, entrypoint == VAEntrypointEncSliceLP
252 ? ENCODER_LP_QUALITY_RANGE : ENCODER_QUALITY_RANGE},
253 {VAProfileH264MultiviewHigh, 1u},
254 {VAProfileH264StereoHigh, 1u},
258 EXPECT_EQ(qranges.at(profile), hw_context->quality_range);
261 INSTANTIATE_TEST_CASE_P(
262 AVCEncode, AVCEContextTest, ::testing::Values(
263 std::make_tuple(VAProfileH264ConstrainedBaseline, VAEntrypointEncSlice),
264 std::make_tuple(VAProfileH264ConstrainedBaseline, VAEntrypointEncSliceLP),
265 std::make_tuple(VAProfileH264Main, VAEntrypointEncSlice),
266 std::make_tuple(VAProfileH264Main, VAEntrypointEncSliceLP),
267 std::make_tuple(VAProfileH264High, VAEntrypointEncSlice),
268 std::make_tuple(VAProfileH264High, VAEntrypointEncSliceLP),
269 std::make_tuple(VAProfileH264MultiviewHigh, VAEntrypointEncSlice),
270 std::make_tuple(VAProfileH264StereoHigh, VAEntrypointEncSlice)
274 } // namespace Encode