| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 114 |
| 115 ASM_REGISTER_STATE_CHECK(GET_PARAM(4)(source_data_+ GET_PARAM(2), | 115 ASM_REGISTER_STATE_CHECK(GET_PARAM(4)(source_data_+ GET_PARAM(2), |
| 116 source_stride_)); | 116 source_stride_)); |
| 117 unsigned int actual = GET_PARAM(4)(source_data_+ GET_PARAM(2), | 117 unsigned int actual = GET_PARAM(4)(source_data_+ GET_PARAM(2), |
| 118 source_stride_); | 118 source_stride_); |
| 119 | 119 |
| 120 EXPECT_EQ(expected, actual); | 120 EXPECT_EQ(expected, actual); |
| 121 } | 121 } |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 typedef void (*IntProRowFunc)(int16_t hbuf[16], uint8_t const *ref, |
| 125 const int ref_stride, const int height); |
| 126 |
| 127 typedef std::tr1::tuple<int, IntProRowFunc, IntProRowFunc> IntProRowParam; |
| 128 |
| 129 class IntProRowTest |
| 130 : public AverageTestBase, |
| 131 public ::testing::WithParamInterface<IntProRowParam> { |
| 132 public: |
| 133 IntProRowTest() |
| 134 : AverageTestBase(16, GET_PARAM(0)), |
| 135 hbuf_asm_(NULL), |
| 136 hbuf_c_(NULL) { |
| 137 asm_func_ = GET_PARAM(1); |
| 138 c_func_ = GET_PARAM(2); |
| 139 } |
| 140 |
| 141 protected: |
| 142 virtual void SetUp() { |
| 143 hbuf_asm_ = reinterpret_cast<int16_t*>( |
| 144 vpx_memalign(kDataAlignment, sizeof(*hbuf_asm_) * 16)); |
| 145 hbuf_c_ = reinterpret_cast<int16_t*>( |
| 146 vpx_memalign(kDataAlignment, sizeof(*hbuf_c_) * 16)); |
| 147 } |
| 148 |
| 149 virtual void TearDown() { |
| 150 vpx_free(hbuf_c_); |
| 151 hbuf_c_ = NULL; |
| 152 vpx_free(hbuf_asm_); |
| 153 hbuf_asm_ = NULL; |
| 154 } |
| 155 |
| 156 void RunComparison() { |
| 157 ASM_REGISTER_STATE_CHECK(c_func_(hbuf_c_, source_data_, 0, height_)); |
| 158 ASM_REGISTER_STATE_CHECK(asm_func_(hbuf_asm_, source_data_, 0, height_)); |
| 159 EXPECT_EQ(0, memcmp(hbuf_c_, hbuf_asm_, sizeof(*hbuf_c_) * 16)) |
| 160 << "Output mismatch"; |
| 161 } |
| 162 |
| 163 private: |
| 164 IntProRowFunc asm_func_; |
| 165 IntProRowFunc c_func_; |
| 166 int16_t *hbuf_asm_; |
| 167 int16_t *hbuf_c_; |
| 168 }; |
| 169 |
| 170 typedef int16_t (*IntProColFunc)(uint8_t const *ref, const int width); |
| 171 |
| 172 typedef std::tr1::tuple<int, IntProColFunc, IntProColFunc> IntProColParam; |
| 173 |
| 174 class IntProColTest |
| 175 : public AverageTestBase, |
| 176 public ::testing::WithParamInterface<IntProColParam> { |
| 177 public: |
| 178 IntProColTest() : AverageTestBase(GET_PARAM(0), 1), sum_asm_(0), sum_c_(0) { |
| 179 asm_func_ = GET_PARAM(1); |
| 180 c_func_ = GET_PARAM(2); |
| 181 } |
| 182 |
| 183 protected: |
| 184 void RunComparison() { |
| 185 ASM_REGISTER_STATE_CHECK(sum_c_ = c_func_(source_data_, width_)); |
| 186 ASM_REGISTER_STATE_CHECK(sum_asm_ = asm_func_(source_data_, width_)); |
| 187 EXPECT_EQ(sum_c_, sum_asm_) << "Output mismatch"; |
| 188 } |
| 189 |
| 190 private: |
| 191 IntProColFunc asm_func_; |
| 192 IntProColFunc c_func_; |
| 193 int16_t sum_asm_; |
| 194 int16_t sum_c_; |
| 195 }; |
| 196 |
| 124 | 197 |
| 125 uint8_t* AverageTestBase::source_data_ = NULL; | 198 uint8_t* AverageTestBase::source_data_ = NULL; |
| 126 | 199 |
| 127 TEST_P(AverageTest, MinValue) { | 200 TEST_P(AverageTest, MinValue) { |
| 128 FillConstant(0); | 201 FillConstant(0); |
| 129 CheckAverages(); | 202 CheckAverages(); |
| 130 } | 203 } |
| 131 | 204 |
| 132 TEST_P(AverageTest, MaxValue) { | 205 TEST_P(AverageTest, MaxValue) { |
| 133 FillConstant(255); | 206 FillConstant(255); |
| 134 CheckAverages(); | 207 CheckAverages(); |
| 135 } | 208 } |
| 136 | 209 |
| 137 TEST_P(AverageTest, Random) { | 210 TEST_P(AverageTest, Random) { |
| 138 // The reference frame, but not the source frame, may be unaligned for | 211 // The reference frame, but not the source frame, may be unaligned for |
| 139 // certain types of searches. | 212 // certain types of searches. |
| 140 for (int i = 0; i < 1000; i++) { | 213 for (int i = 0; i < 1000; i++) { |
| 141 FillRandom(); | 214 FillRandom(); |
| 142 CheckAverages(); | 215 CheckAverages(); |
| 143 } | 216 } |
| 144 } | 217 } |
| 145 | 218 |
| 219 TEST_P(IntProRowTest, MinValue) { |
| 220 FillConstant(0); |
| 221 RunComparison(); |
| 222 } |
| 223 |
| 224 TEST_P(IntProRowTest, MaxValue) { |
| 225 FillConstant(255); |
| 226 RunComparison(); |
| 227 } |
| 228 |
| 229 TEST_P(IntProRowTest, Random) { |
| 230 FillRandom(); |
| 231 RunComparison(); |
| 232 } |
| 233 |
| 234 TEST_P(IntProColTest, MinValue) { |
| 235 FillConstant(0); |
| 236 RunComparison(); |
| 237 } |
| 238 |
| 239 TEST_P(IntProColTest, MaxValue) { |
| 240 FillConstant(255); |
| 241 RunComparison(); |
| 242 } |
| 243 |
| 244 TEST_P(IntProColTest, Random) { |
| 245 FillRandom(); |
| 246 RunComparison(); |
| 247 } |
| 248 |
| 146 using std::tr1::make_tuple; | 249 using std::tr1::make_tuple; |
| 147 | 250 |
| 148 INSTANTIATE_TEST_CASE_P( | 251 INSTANTIATE_TEST_CASE_P( |
| 149 C, AverageTest, | 252 C, AverageTest, |
| 150 ::testing::Values( | 253 ::testing::Values( |
| 151 make_tuple(16, 16, 1, 8, &vp9_avg_8x8_c), | 254 make_tuple(16, 16, 1, 8, &vp9_avg_8x8_c), |
| 152 make_tuple(16, 16, 1, 4, &vp9_avg_4x4_c))); | 255 make_tuple(16, 16, 1, 4, &vp9_avg_4x4_c))); |
| 153 | 256 |
| 154 | |
| 155 #if HAVE_SSE2 | 257 #if HAVE_SSE2 |
| 156 INSTANTIATE_TEST_CASE_P( | 258 INSTANTIATE_TEST_CASE_P( |
| 157 SSE2, AverageTest, | 259 SSE2, AverageTest, |
| 158 ::testing::Values( | 260 ::testing::Values( |
| 159 make_tuple(16, 16, 0, 8, &vp9_avg_8x8_sse2), | 261 make_tuple(16, 16, 0, 8, &vp9_avg_8x8_sse2), |
| 160 make_tuple(16, 16, 5, 8, &vp9_avg_8x8_sse2), | 262 make_tuple(16, 16, 5, 8, &vp9_avg_8x8_sse2), |
| 161 make_tuple(32, 32, 15, 8, &vp9_avg_8x8_sse2), | 263 make_tuple(32, 32, 15, 8, &vp9_avg_8x8_sse2), |
| 162 make_tuple(16, 16, 0, 4, &vp9_avg_4x4_sse2), | 264 make_tuple(16, 16, 0, 4, &vp9_avg_4x4_sse2), |
| 163 make_tuple(16, 16, 5, 4, &vp9_avg_4x4_sse2), | 265 make_tuple(16, 16, 5, 4, &vp9_avg_4x4_sse2), |
| 164 make_tuple(32, 32, 15, 4, &vp9_avg_4x4_sse2))); | 266 make_tuple(32, 32, 15, 4, &vp9_avg_4x4_sse2))); |
| 165 | 267 |
| 268 INSTANTIATE_TEST_CASE_P( |
| 269 SSE2, IntProRowTest, ::testing::Values( |
| 270 make_tuple(16, &vp9_int_pro_row_sse2, &vp9_int_pro_row_c), |
| 271 make_tuple(32, &vp9_int_pro_row_sse2, &vp9_int_pro_row_c), |
| 272 make_tuple(64, &vp9_int_pro_row_sse2, &vp9_int_pro_row_c))); |
| 273 |
| 274 INSTANTIATE_TEST_CASE_P( |
| 275 SSE2, IntProColTest, ::testing::Values( |
| 276 make_tuple(16, &vp9_int_pro_col_sse2, &vp9_int_pro_col_c), |
| 277 make_tuple(32, &vp9_int_pro_col_sse2, &vp9_int_pro_col_c), |
| 278 make_tuple(64, &vp9_int_pro_col_sse2, &vp9_int_pro_col_c))); |
| 166 #endif | 279 #endif |
| 167 | 280 |
| 168 #if HAVE_NEON | 281 #if HAVE_NEON |
| 169 INSTANTIATE_TEST_CASE_P( | 282 INSTANTIATE_TEST_CASE_P( |
| 170 NEON, AverageTest, | 283 NEON, AverageTest, |
| 171 ::testing::Values( | 284 ::testing::Values( |
| 172 make_tuple(16, 16, 0, 8, &vp9_avg_8x8_neon), | 285 make_tuple(16, 16, 0, 8, &vp9_avg_8x8_neon), |
| 173 make_tuple(16, 16, 5, 8, &vp9_avg_8x8_neon), | 286 make_tuple(16, 16, 5, 8, &vp9_avg_8x8_neon), |
| 174 make_tuple(32, 32, 15, 8, &vp9_avg_8x8_neon))); | 287 make_tuple(32, 32, 15, 8, &vp9_avg_8x8_neon))); |
| 175 | 288 |
| 176 #endif | 289 #endif |
| 177 | 290 |
| 291 #if HAVE_MSA |
| 292 INSTANTIATE_TEST_CASE_P( |
| 293 MSA, AverageTest, |
| 294 ::testing::Values( |
| 295 make_tuple(16, 16, 0, 8, &vp9_avg_8x8_msa), |
| 296 make_tuple(16, 16, 5, 8, &vp9_avg_8x8_msa), |
| 297 make_tuple(32, 32, 15, 8, &vp9_avg_8x8_msa), |
| 298 make_tuple(16, 16, 0, 4, &vp9_avg_4x4_msa), |
| 299 make_tuple(16, 16, 5, 4, &vp9_avg_4x4_msa), |
| 300 make_tuple(32, 32, 15, 4, &vp9_avg_4x4_msa))); |
| 301 #endif |
| 302 |
| 178 } // namespace | 303 } // namespace |
| OLD | NEW |