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 struct object_context const *obj_context = CONTEXT(context);
65 if (not obj_context) return NULL;
67 return reinterpret_cast<struct intel_encoder_context const *>(
68 obj_context->hw_context);
72 VAEntrypoint entrypoint;
73 VAConfigID config = VA_INVALID_ID;
74 VAContextID context = VA_INVALID_ID;
77 TEST_P(AVCEContextTest, RateControl)
79 if (not IsSupported(profile, entrypoint)) {
80 RecordProperty("skipped", true);
81 std::cout << "[ SKIPPED ] " << getFullTestName()
82 << " is unsupported on this hardware" << std::endl;
86 static const std::vector<unsigned> rateControls = {
87 VA_RC_NONE, VA_RC_CBR, VA_RC_VBR, VA_RC_VCM, VA_RC_CQP,
88 VA_RC_VBR_CONSTRAINED, VA_RC_MB,
91 for (auto rc : rateControls) {
92 ConfigAttribs attribs(1, {type:VAConfigAttribRateControl, value:rc});
93 config = createConfig(profile, entrypoint, attribs);
94 context = createContext(config, 1, 1);
95 if (HasFailure()) continue;
97 struct intel_encoder_context const *hw_context(*this);
98 EXPECT_PTR(hw_context);
99 if (HasFailure()) continue;
101 EXPECT_EQ(rc, hw_context->rate_control_mode);
103 destroyContext(context);
104 destroyConfig(config);
105 context = VA_INVALID_ID;
106 config = VA_INVALID_ID;
110 TEST_P(AVCEContextTest, Codec)
112 if (not IsSupported(profile, entrypoint)) {
113 RecordProperty("skipped", true);
114 std::cout << "[ SKIPPED ] " << getFullTestName()
115 << " is unsupported on this hardware" << std::endl;
119 static const std::map<VAProfile, int> codecs = {
120 {VAProfileH264ConstrainedBaseline, CODEC_H264},
121 {VAProfileH264Main, CODEC_H264},
122 {VAProfileH264High, CODEC_H264},
123 {VAProfileH264MultiviewHigh, CODEC_H264_MVC},
124 {VAProfileH264StereoHigh, CODEC_H264_MVC},
128 config = createConfig(profile, entrypoint);
129 context = createContext(config, 1, 1);
132 struct intel_encoder_context const *hw_context(*this);
133 ASSERT_PTR(hw_context);
135 EXPECT_EQ(codecs.at(profile), hw_context->codec);
138 TEST_P(AVCEContextTest, LowPowerMode)
140 if (not IsSupported(profile, entrypoint)) {
141 RecordProperty("skipped", true);
142 std::cout << "[ SKIPPED ] " << getFullTestName()
143 << " is unsupported on this hardware" << std::endl;
148 config = createConfig(profile, entrypoint);
149 context = createContext(config, 1, 1);
152 struct intel_encoder_context const *hw_context(*this);
153 ASSERT_PTR(hw_context);
156 (entrypoint == VAEntrypointEncSliceLP ? 1u : 0u),
157 hw_context->low_power_mode
161 TEST_P(AVCEContextTest, ROINotSpecified)
163 if (not IsSupported(profile, entrypoint)) {
164 RecordProperty("skipped", true);
165 std::cout << "[ SKIPPED ] " << getFullTestName()
166 << " is unsupported on this hardware" << std::endl;
170 // The lack of the VAConfigAttribEncROI config attribute
173 config = createConfig(profile, entrypoint);
174 context = createContext(config, 1, 1);
177 struct intel_encoder_context const *hw_context(*this);
178 ASSERT_PTR(hw_context);
180 EXPECT_EQ(0u, hw_context->context_roi);
183 TEST_P(AVCEContextTest, ROISpecified)
185 if (not IsSupported(profile, entrypoint)) {
186 RecordProperty("skipped", true);
187 std::cout << "[ SKIPPED ] " << getFullTestName()
188 << " is unsupported on this hardware" << std::endl;
192 static const std::map<VAProfile, unsigned> roiSupport = {
193 {VAProfileH264ConstrainedBaseline, 1}, {VAProfileH264Main, 1},
194 {VAProfileH264High, 1}, {VAProfileH264MultiviewHigh, 0},
195 {VAProfileH264StereoHigh, 0},
198 // The presence of the VAConfigAttribEncROI config attribute
199 // will enable it for supported profile
200 ConfigAttribs attribs(1, {type:VAConfigAttribEncROI});
202 config = createConfig(profile, entrypoint, attribs);
203 context = createContext(config, 1, 1);
206 struct intel_encoder_context const *hw_context(*this);
207 ASSERT_PTR(hw_context);
209 EXPECT_EQ(roiSupport.at(profile), hw_context->context_roi);
212 TEST_P(AVCEContextTest, QualityRange)
214 if (not IsSupported(profile, entrypoint)) {
215 RecordProperty("skipped", true);
216 std::cout << "[ SKIPPED ] " << getFullTestName()
217 << " is unsupported on this hardware" << std::endl;
221 const std::map<VAProfile, unsigned> qranges = {
222 {VAProfileH264ConstrainedBaseline, entrypoint == VAEntrypointEncSliceLP
223 ? ENCODER_LP_QUALITY_RANGE : ENCODER_QUALITY_RANGE},
224 {VAProfileH264Main, entrypoint == VAEntrypointEncSliceLP
225 ? ENCODER_LP_QUALITY_RANGE : ENCODER_QUALITY_RANGE},
226 {VAProfileH264High, entrypoint == VAEntrypointEncSliceLP
227 ? ENCODER_LP_QUALITY_RANGE : ENCODER_QUALITY_RANGE},
228 {VAProfileH264MultiviewHigh, 1u},
229 {VAProfileH264StereoHigh, 1u},
233 config = createConfig(profile, entrypoint);
234 context = createContext(config, 1, 1);
237 struct intel_encoder_context const *hw_context(*this);
238 ASSERT_PTR(hw_context);
240 EXPECT_EQ(qranges.at(profile), hw_context->quality_range);
243 INSTANTIATE_TEST_CASE_P(
244 AVCEncode, AVCEContextTest, ::testing::Values(
245 std::make_tuple(VAProfileH264ConstrainedBaseline, VAEntrypointEncSlice),
246 std::make_tuple(VAProfileH264ConstrainedBaseline, VAEntrypointEncSliceLP),
247 std::make_tuple(VAProfileH264Main, VAEntrypointEncSlice),
248 std::make_tuple(VAProfileH264Main, VAEntrypointEncSliceLP),
249 std::make_tuple(VAProfileH264High, VAEntrypointEncSlice),
250 std::make_tuple(VAProfileH264High, VAEntrypointEncSliceLP),
251 std::make_tuple(VAProfileH264MultiviewHigh, VAEntrypointEncSlice),
252 std::make_tuple(VAProfileH264StereoHigh, VAEntrypointEncSlice)
256 } // namespace Encode