variance_test.cc 32 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 *  Copyright (c) 2012 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */
#include <stdlib.h>
#include <new>

#include "third_party/googletest/src/include/gtest/gtest.h"

15
#include "test/clear_system_state.h"
16
#include "test/register_state_check.h"
17

James Zern's avatar
James Zern committed
18
#include "vpx/vpx_integer.h"
Yaowu Xu's avatar
Yaowu Xu committed
19
#include "./vpx_config.h"
20
#include "vpx_mem/vpx_mem.h"
James Zern's avatar
James Zern committed
21
#if CONFIG_VP8_ENCODER
Yaowu Xu's avatar
Yaowu Xu committed
22
# include "./vp8_rtcd.h"
23
# include "vp8/common/variance.h"
James Zern's avatar
James Zern committed
24 25
#endif
#if CONFIG_VP9_ENCODER
Yaowu Xu's avatar
Yaowu Xu committed
26
# include "./vp9_rtcd.h"
27
# include "vp9/encoder/vp9_variance.h"
James Zern's avatar
James Zern committed
28
#endif
29
#include "test/acm_random.h"
30 31 32 33 34 35

namespace {

using ::std::tr1::get;
using ::std::tr1::make_tuple;
using ::std::tr1::tuple;
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
using libvpx_test::ACMRandom;

static unsigned int variance_ref(const uint8_t *ref, const uint8_t *src,
                                 int l2w, int l2h, unsigned int *sse_ptr) {
  int se = 0;
  unsigned int sse = 0;
  const int w = 1 << l2w, h = 1 << l2h;
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      int diff = ref[w * y + x] - src[w * y + x];
      se += diff;
      sse += diff * diff;
    }
  }
  *sse_ptr = sse;
  return sse - (((int64_t) se * se) >> (l2w + l2h));
}

static unsigned int subpel_variance_ref(const uint8_t *ref, const uint8_t *src,
                                        int l2w, int l2h, int xoff, int yoff,
                                        unsigned int *sse_ptr) {
  int se = 0;
  unsigned int sse = 0;
  const int w = 1 << l2w, h = 1 << l2h;
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      // bilinear interpolation at a 16th pel step
      const int a1 = ref[(w + 1) * (y + 0) + x + 0];
      const int a2 = ref[(w + 1) * (y + 0) + x + 1];
      const int b1 = ref[(w + 1) * (y + 1) + x + 0];
      const int b2 = ref[(w + 1) * (y + 1) + x + 1];
      const int a = a1 + (((a2 - a1) * xoff + 8) >> 4);
      const int b = b1 + (((b2 - b1) * xoff + 8) >> 4);
      const int r = a + (((b - a) * yoff + 8) >> 4);
      int diff = r - src[w * y + x];
      se += diff;
      sse += diff * diff;
    }
  }
  *sse_ptr = sse;
  return sse - (((int64_t) se * se) >> (l2w + l2h));
}
78

James Zern's avatar
James Zern committed
79
template<typename VarianceFunctionType>
Yaowu Xu's avatar
Yaowu Xu committed
80 81
class VarianceTest
    : public ::testing::TestWithParam<tuple<int, int, VarianceFunctionType> > {
82 83
 public:
  virtual void SetUp() {
James Zern's avatar
James Zern committed
84
    const tuple<int, int, VarianceFunctionType>& params = this->GetParam();
85 86 87 88
    log2width_  = get<0>(params);
    width_ = 1 << log2width_;
    log2height_ = get<1>(params);
    height_ = 1 << log2height_;
89 90
    variance_ = get<2>(params);

91
    rnd(ACMRandom::DeterministicSeed());
92
    block_size_ = width_ * height_;
93
    src_ = reinterpret_cast<uint8_t *>(vpx_memalign(16, block_size_));
94 95 96 97 98 99
    ref_ = new uint8_t[block_size_];
    ASSERT_TRUE(src_ != NULL);
    ASSERT_TRUE(ref_ != NULL);
  }

  virtual void TearDown() {
100
    vpx_free(src_);
101
    delete[] ref_;
102
    libvpx_test::ClearSystemState();
103 104 105
  }

 protected:
James Zern's avatar
James Zern committed
106
  void ZeroTest();
107
  void RefTest();
James Zern's avatar
James Zern committed
108 109
  void OneQuarterTest();

110
  ACMRandom rnd;
111 112
  uint8_t* src_;
  uint8_t* ref_;
113 114
  int width_, log2width_;
  int height_, log2height_;
115
  int block_size_;
James Zern's avatar
James Zern committed
116
  VarianceFunctionType variance_;
117 118
};

James Zern's avatar
James Zern committed
119 120
template<typename VarianceFunctionType>
void VarianceTest<VarianceFunctionType>::ZeroTest() {
121 122 123 124 125
  for (int i = 0; i <= 255; ++i) {
    memset(src_, i, block_size_);
    for (int j = 0; j <= 255; ++j) {
      memset(ref_, j, block_size_);
      unsigned int sse;
126
      unsigned int var;
127 128
      ASM_REGISTER_STATE_CHECK(
          var = variance_(src_, width_, ref_, width_, &sse));
129 130 131 132 133
      EXPECT_EQ(0u, var) << "src values: " << i << "ref values: " << j;
    }
  }
}

134 135 136 137 138 139 140 141
template<typename VarianceFunctionType>
void VarianceTest<VarianceFunctionType>::RefTest() {
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < block_size_; j++) {
      src_[j] = rnd.Rand8();
      ref_[j] = rnd.Rand8();
    }
    unsigned int sse1, sse2;
142
    unsigned int var1;
143 144
    ASM_REGISTER_STATE_CHECK(
        var1 = variance_(src_, width_, ref_, width_, &sse1));
145 146 147 148 149 150 151
    const unsigned int var2 = variance_ref(src_, ref_, log2width_,
                                           log2height_, &sse2);
    EXPECT_EQ(sse1, sse2);
    EXPECT_EQ(var1, var2);
  }
}

James Zern's avatar
James Zern committed
152 153
template<typename VarianceFunctionType>
void VarianceTest<VarianceFunctionType>::OneQuarterTest() {
154 155 156 157 158
  memset(src_, 255, block_size_);
  const int half = block_size_ / 2;
  memset(ref_, 255, half);
  memset(ref_ + half, 0, half);
  unsigned int sse;
159
  unsigned int var;
160
  ASM_REGISTER_STATE_CHECK(var = variance_(src_, width_, ref_, width_, &sse));
161 162 163 164
  const unsigned int expected = block_size_ * 255 * 255 / 4;
  EXPECT_EQ(expected, var);
}

James Zern's avatar
James Zern committed
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
#if CONFIG_VP9_ENCODER

unsigned int subpel_avg_variance_ref(const uint8_t *ref,
                                     const uint8_t *src,
                                     const uint8_t *second_pred,
                                     int l2w, int l2h,
                                     int xoff, int yoff,
                                     unsigned int *sse_ptr) {
  int se = 0;
  unsigned int sse = 0;
  const int w = 1 << l2w, h = 1 << l2h;
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      // bilinear interpolation at a 16th pel step
      const int a1 = ref[(w + 1) * (y + 0) + x + 0];
      const int a2 = ref[(w + 1) * (y + 0) + x + 1];
      const int b1 = ref[(w + 1) * (y + 1) + x + 0];
      const int b2 = ref[(w + 1) * (y + 1) + x + 1];
      const int a = a1 + (((a2 - a1) * xoff + 8) >> 4);
      const int b = b1 + (((b2 - b1) * xoff + 8) >> 4);
      const int r = a + (((b - a) * yoff + 8) >> 4);
      int diff = ((r + second_pred[w * y + x] + 1) >> 1) - src[w * y + x];
      se += diff;
      sse += diff * diff;
    }
  }
  *sse_ptr = sse;
  return sse - (((int64_t) se * se) >> (l2w + l2h));
}

195
template<typename SubpelVarianceFunctionType>
Yaowu Xu's avatar
Yaowu Xu committed
196 197 198
class SubpelVarianceTest
    : public ::testing::TestWithParam<tuple<int, int,
                                            SubpelVarianceFunctionType> > {
199 200 201 202 203 204 205 206 207 208 209 210
 public:
  virtual void SetUp() {
    const tuple<int, int, SubpelVarianceFunctionType>& params =
        this->GetParam();
    log2width_  = get<0>(params);
    width_ = 1 << log2width_;
    log2height_ = get<1>(params);
    height_ = 1 << log2height_;
    subpel_variance_ = get<2>(params);

    rnd(ACMRandom::DeterministicSeed());
    block_size_ = width_ * height_;
211 212
    src_ = reinterpret_cast<uint8_t *>(vpx_memalign(16, block_size_));
    sec_ = reinterpret_cast<uint8_t *>(vpx_memalign(16, block_size_));
213 214
    ref_ = new uint8_t[block_size_ + width_ + height_ + 1];
    ASSERT_TRUE(src_ != NULL);
215
    ASSERT_TRUE(sec_ != NULL);
216 217 218 219
    ASSERT_TRUE(ref_ != NULL);
  }

  virtual void TearDown() {
220
    vpx_free(src_);
221
    delete[] ref_;
222
    vpx_free(sec_);
223
    libvpx_test::ClearSystemState();
224 225 226 227 228 229
  }

 protected:
  void RefTest();

  ACMRandom rnd;
230 231 232
  uint8_t *src_;
  uint8_t *ref_;
  uint8_t *sec_;
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
  int width_, log2width_;
  int height_, log2height_;
  int block_size_;
  SubpelVarianceFunctionType subpel_variance_;
};

template<typename SubpelVarianceFunctionType>
void SubpelVarianceTest<SubpelVarianceFunctionType>::RefTest() {
  for (int x = 0; x < 16; ++x) {
    for (int y = 0; y < 16; ++y) {
      for (int j = 0; j < block_size_; j++) {
        src_[j] = rnd.Rand8();
      }
      for (int j = 0; j < block_size_ + width_ + height_ + 1; j++) {
        ref_[j] = rnd.Rand8();
      }
      unsigned int sse1, sse2;
250
      unsigned int var1;
251 252
      ASM_REGISTER_STATE_CHECK(var1 = subpel_variance_(ref_, width_ + 1, x, y,
                                                       src_, width_, &sse1));
253 254 255 256 257 258 259 260
      const unsigned int var2 = subpel_variance_ref(ref_, src_, log2width_,
                                                    log2height_, x, y, &sse2);
      EXPECT_EQ(sse1, sse2) << "at position " << x << ", " << y;
      EXPECT_EQ(var1, var2) << "at position " << x << ", " << y;
    }
  }
}

261 262 263 264 265 266 267 268 269 270 271 272
template<>
void SubpelVarianceTest<vp9_subp_avg_variance_fn_t>::RefTest() {
  for (int x = 0; x < 16; ++x) {
    for (int y = 0; y < 16; ++y) {
      for (int j = 0; j < block_size_; j++) {
        src_[j] = rnd.Rand8();
        sec_[j] = rnd.Rand8();
      }
      for (int j = 0; j < block_size_ + width_ + height_ + 1; j++) {
        ref_[j] = rnd.Rand8();
      }
      unsigned int sse1, sse2;
273
      unsigned int var1;
274 275 276
      ASM_REGISTER_STATE_CHECK(
          var1 = subpel_variance_(ref_, width_ + 1, x, y,
                                  src_, width_, &sse1, sec_));
277 278 279 280 281 282 283 284 285
      const unsigned int var2 = subpel_avg_variance_ref(ref_, src_, sec_,
                                                        log2width_, log2height_,
                                                        x, y, &sse2);
      EXPECT_EQ(sse1, sse2) << "at position " << x << ", " << y;
      EXPECT_EQ(var1, var2) << "at position " << x << ", " << y;
    }
  }
}

James Zern's avatar
James Zern committed
286 287
#endif  // CONFIG_VP9_ENCODER

James Zern's avatar
James Zern committed
288 289 290 291 292 293 294 295 296
// -----------------------------------------------------------------------------
// VP8 test cases.

namespace vp8 {

#if CONFIG_VP8_ENCODER
typedef VarianceTest<vp8_variance_fn_t> VP8VarianceTest;

TEST_P(VP8VarianceTest, Zero) { ZeroTest(); }
297
TEST_P(VP8VarianceTest, Ref) { RefTest(); }
James Zern's avatar
James Zern committed
298 299
TEST_P(VP8VarianceTest, OneQuarter) { OneQuarterTest(); }

300 301 302 303 304
const vp8_variance_fn_t variance4x4_c = vp8_variance4x4_c;
const vp8_variance_fn_t variance8x8_c = vp8_variance8x8_c;
const vp8_variance_fn_t variance8x16_c = vp8_variance8x16_c;
const vp8_variance_fn_t variance16x8_c = vp8_variance16x8_c;
const vp8_variance_fn_t variance16x16_c = vp8_variance16x16_c;
James Zern's avatar
James Zern committed
305 306
INSTANTIATE_TEST_CASE_P(
    C, VP8VarianceTest,
307 308 309 310 311
    ::testing::Values(make_tuple(2, 2, variance4x4_c),
                      make_tuple(3, 3, variance8x8_c),
                      make_tuple(3, 4, variance8x16_c),
                      make_tuple(4, 3, variance16x8_c),
                      make_tuple(4, 4, variance16x16_c)));
James Zern's avatar
James Zern committed
312

313
#if HAVE_NEON
314 315 316 317
const vp8_variance_fn_t variance8x8_neon = vp8_variance8x8_neon;
const vp8_variance_fn_t variance8x16_neon = vp8_variance8x16_neon;
const vp8_variance_fn_t variance16x8_neon = vp8_variance16x8_neon;
const vp8_variance_fn_t variance16x16_neon = vp8_variance16x16_neon;
318 319
INSTANTIATE_TEST_CASE_P(
    NEON, VP8VarianceTest,
320 321 322 323
    ::testing::Values(make_tuple(3, 3, variance8x8_neon),
                      make_tuple(3, 4, variance8x16_neon),
                      make_tuple(4, 3, variance16x8_neon),
                      make_tuple(4, 4, variance16x16_neon)));
324 325
#endif

James Zern's avatar
James Zern committed
326
#if HAVE_MMX
327 328 329 330 331
const vp8_variance_fn_t variance4x4_mmx = vp8_variance4x4_mmx;
const vp8_variance_fn_t variance8x8_mmx = vp8_variance8x8_mmx;
const vp8_variance_fn_t variance8x16_mmx = vp8_variance8x16_mmx;
const vp8_variance_fn_t variance16x8_mmx = vp8_variance16x8_mmx;
const vp8_variance_fn_t variance16x16_mmx = vp8_variance16x16_mmx;
James Zern's avatar
James Zern committed
332 333
INSTANTIATE_TEST_CASE_P(
    MMX, VP8VarianceTest,
334 335 336 337 338
    ::testing::Values(make_tuple(2, 2, variance4x4_mmx),
                      make_tuple(3, 3, variance8x8_mmx),
                      make_tuple(3, 4, variance8x16_mmx),
                      make_tuple(4, 3, variance16x8_mmx),
                      make_tuple(4, 4, variance16x16_mmx)));
James Zern's avatar
James Zern committed
339 340 341
#endif

#if HAVE_SSE2
342 343 344 345 346
const vp8_variance_fn_t variance4x4_wmt = vp8_variance4x4_wmt;
const vp8_variance_fn_t variance8x8_wmt = vp8_variance8x8_wmt;
const vp8_variance_fn_t variance8x16_wmt = vp8_variance8x16_wmt;
const vp8_variance_fn_t variance16x8_wmt = vp8_variance16x8_wmt;
const vp8_variance_fn_t variance16x16_wmt = vp8_variance16x16_wmt;
James Zern's avatar
James Zern committed
347 348
INSTANTIATE_TEST_CASE_P(
    SSE2, VP8VarianceTest,
349 350 351 352 353
    ::testing::Values(make_tuple(2, 2, variance4x4_wmt),
                      make_tuple(3, 3, variance8x8_wmt),
                      make_tuple(3, 4, variance8x16_wmt),
                      make_tuple(4, 3, variance16x8_wmt),
                      make_tuple(4, 4, variance16x16_wmt)));
James Zern's avatar
James Zern committed
354 355 356 357 358 359 360 361 362 363 364 365
#endif
#endif  // CONFIG_VP8_ENCODER

}  // namespace vp8

// -----------------------------------------------------------------------------
// VP9 test cases.

namespace vp9 {

#if CONFIG_VP9_ENCODER
typedef VarianceTest<vp9_variance_fn_t> VP9VarianceTest;
366
typedef SubpelVarianceTest<vp9_subpixvariance_fn_t> VP9SubpelVarianceTest;
367
typedef SubpelVarianceTest<vp9_subp_avg_variance_fn_t> VP9SubpelAvgVarianceTest;
James Zern's avatar
James Zern committed
368 369

TEST_P(VP9VarianceTest, Zero) { ZeroTest(); }
370 371
TEST_P(VP9VarianceTest, Ref) { RefTest(); }
TEST_P(VP9SubpelVarianceTest, Ref) { RefTest(); }
372
TEST_P(VP9SubpelAvgVarianceTest, Ref) { RefTest(); }
James Zern's avatar
James Zern committed
373 374
TEST_P(VP9VarianceTest, OneQuarter) { OneQuarterTest(); }

375 376 377 378 379 380 381 382 383 384 385 386 387
const vp9_variance_fn_t variance4x4_c = vp9_variance4x4_c;
const vp9_variance_fn_t variance4x8_c = vp9_variance4x8_c;
const vp9_variance_fn_t variance8x4_c = vp9_variance8x4_c;
const vp9_variance_fn_t variance8x8_c = vp9_variance8x8_c;
const vp9_variance_fn_t variance8x16_c = vp9_variance8x16_c;
const vp9_variance_fn_t variance16x8_c = vp9_variance16x8_c;
const vp9_variance_fn_t variance16x16_c = vp9_variance16x16_c;
const vp9_variance_fn_t variance16x32_c = vp9_variance16x32_c;
const vp9_variance_fn_t variance32x16_c = vp9_variance32x16_c;
const vp9_variance_fn_t variance32x32_c = vp9_variance32x32_c;
const vp9_variance_fn_t variance32x64_c = vp9_variance32x64_c;
const vp9_variance_fn_t variance64x32_c = vp9_variance64x32_c;
const vp9_variance_fn_t variance64x64_c = vp9_variance64x64_c;
388 389
INSTANTIATE_TEST_CASE_P(
    C, VP9VarianceTest,
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
    ::testing::Values(make_tuple(2, 2, variance4x4_c),
                      make_tuple(2, 3, variance4x8_c),
                      make_tuple(3, 2, variance8x4_c),
                      make_tuple(3, 3, variance8x8_c),
                      make_tuple(3, 4, variance8x16_c),
                      make_tuple(4, 3, variance16x8_c),
                      make_tuple(4, 4, variance16x16_c),
                      make_tuple(4, 5, variance16x32_c),
                      make_tuple(5, 4, variance32x16_c),
                      make_tuple(5, 5, variance32x32_c),
                      make_tuple(5, 6, variance32x64_c),
                      make_tuple(6, 5, variance64x32_c),
                      make_tuple(6, 6, variance64x64_c)));

const vp9_subpixvariance_fn_t subpel_variance4x4_c =
    vp9_sub_pixel_variance4x4_c;
const vp9_subpixvariance_fn_t subpel_variance4x8_c =
    vp9_sub_pixel_variance4x8_c;
const vp9_subpixvariance_fn_t subpel_variance8x4_c =
    vp9_sub_pixel_variance8x4_c;
const vp9_subpixvariance_fn_t subpel_variance8x8_c =
    vp9_sub_pixel_variance8x8_c;
const vp9_subpixvariance_fn_t subpel_variance8x16_c =
    vp9_sub_pixel_variance8x16_c;
const vp9_subpixvariance_fn_t subpel_variance16x8_c =
    vp9_sub_pixel_variance16x8_c;
const vp9_subpixvariance_fn_t subpel_variance16x16_c =
    vp9_sub_pixel_variance16x16_c;
const vp9_subpixvariance_fn_t subpel_variance16x32_c =
    vp9_sub_pixel_variance16x32_c;
const vp9_subpixvariance_fn_t subpel_variance32x16_c =
    vp9_sub_pixel_variance32x16_c;
const vp9_subpixvariance_fn_t subpel_variance32x32_c =
    vp9_sub_pixel_variance32x32_c;
const vp9_subpixvariance_fn_t subpel_variance32x64_c =
    vp9_sub_pixel_variance32x64_c;
const vp9_subpixvariance_fn_t subpel_variance64x32_c =
    vp9_sub_pixel_variance64x32_c;
const vp9_subpixvariance_fn_t subpel_variance64x64_c =
    vp9_sub_pixel_variance64x64_c;
430 431
INSTANTIATE_TEST_CASE_P(
    C, VP9SubpelVarianceTest,
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471
    ::testing::Values(make_tuple(2, 2, subpel_variance4x4_c),
                      make_tuple(2, 3, subpel_variance4x8_c),
                      make_tuple(3, 2, subpel_variance8x4_c),
                      make_tuple(3, 3, subpel_variance8x8_c),
                      make_tuple(3, 4, subpel_variance8x16_c),
                      make_tuple(4, 3, subpel_variance16x8_c),
                      make_tuple(4, 4, subpel_variance16x16_c),
                      make_tuple(4, 5, subpel_variance16x32_c),
                      make_tuple(5, 4, subpel_variance32x16_c),
                      make_tuple(5, 5, subpel_variance32x32_c),
                      make_tuple(5, 6, subpel_variance32x64_c),
                      make_tuple(6, 5, subpel_variance64x32_c),
                      make_tuple(6, 6, subpel_variance64x64_c)));

const vp9_subp_avg_variance_fn_t subpel_avg_variance4x4_c =
    vp9_sub_pixel_avg_variance4x4_c;
const vp9_subp_avg_variance_fn_t subpel_avg_variance4x8_c =
    vp9_sub_pixel_avg_variance4x8_c;
const vp9_subp_avg_variance_fn_t subpel_avg_variance8x4_c =
    vp9_sub_pixel_avg_variance8x4_c;
const vp9_subp_avg_variance_fn_t subpel_avg_variance8x8_c =
    vp9_sub_pixel_avg_variance8x8_c;
const vp9_subp_avg_variance_fn_t subpel_avg_variance8x16_c =
    vp9_sub_pixel_avg_variance8x16_c;
const vp9_subp_avg_variance_fn_t subpel_avg_variance16x8_c =
    vp9_sub_pixel_avg_variance16x8_c;
const vp9_subp_avg_variance_fn_t subpel_avg_variance16x16_c =
    vp9_sub_pixel_avg_variance16x16_c;
const vp9_subp_avg_variance_fn_t subpel_avg_variance16x32_c =
    vp9_sub_pixel_avg_variance16x32_c;
const vp9_subp_avg_variance_fn_t subpel_avg_variance32x16_c =
    vp9_sub_pixel_avg_variance32x16_c;
const vp9_subp_avg_variance_fn_t subpel_avg_variance32x32_c =
    vp9_sub_pixel_avg_variance32x32_c;
const vp9_subp_avg_variance_fn_t subpel_avg_variance32x64_c =
    vp9_sub_pixel_avg_variance32x64_c;
const vp9_subp_avg_variance_fn_t subpel_avg_variance64x32_c =
    vp9_sub_pixel_avg_variance64x32_c;
const vp9_subp_avg_variance_fn_t subpel_avg_variance64x64_c =
    vp9_sub_pixel_avg_variance64x64_c;
472 473
INSTANTIATE_TEST_CASE_P(
    C, VP9SubpelAvgVarianceTest,
474 475 476 477 478 479 480 481 482 483 484 485 486
    ::testing::Values(make_tuple(2, 2, subpel_avg_variance4x4_c),
                      make_tuple(2, 3, subpel_avg_variance4x8_c),
                      make_tuple(3, 2, subpel_avg_variance8x4_c),
                      make_tuple(3, 3, subpel_avg_variance8x8_c),
                      make_tuple(3, 4, subpel_avg_variance8x16_c),
                      make_tuple(4, 3, subpel_avg_variance16x8_c),
                      make_tuple(4, 4, subpel_avg_variance16x16_c),
                      make_tuple(4, 5, subpel_avg_variance16x32_c),
                      make_tuple(5, 4, subpel_avg_variance32x16_c),
                      make_tuple(5, 5, subpel_avg_variance32x32_c),
                      make_tuple(5, 6, subpel_avg_variance32x64_c),
                      make_tuple(6, 5, subpel_avg_variance64x32_c),
                      make_tuple(6, 6, subpel_avg_variance64x64_c)));
487

488
#if HAVE_MMX
489 490 491 492 493
const vp9_variance_fn_t variance4x4_mmx = vp9_variance4x4_mmx;
const vp9_variance_fn_t variance8x8_mmx = vp9_variance8x8_mmx;
const vp9_variance_fn_t variance8x16_mmx = vp9_variance8x16_mmx;
const vp9_variance_fn_t variance16x8_mmx = vp9_variance16x8_mmx;
const vp9_variance_fn_t variance16x16_mmx = vp9_variance16x16_mmx;
494 495
INSTANTIATE_TEST_CASE_P(
    MMX, VP9VarianceTest,
496 497 498 499 500
    ::testing::Values(make_tuple(2, 2, variance4x4_mmx),
                      make_tuple(3, 3, variance8x8_mmx),
                      make_tuple(3, 4, variance8x16_mmx),
                      make_tuple(4, 3, variance16x8_mmx),
                      make_tuple(4, 4, variance16x16_mmx)));
501 502 503
#endif

#if HAVE_SSE2
Jim Bankoski's avatar
Jim Bankoski committed
504
#if CONFIG_USE_X86INC
505 506 507 508 509 510 511 512 513 514 515 516 517
const vp9_variance_fn_t variance4x4_sse2 = vp9_variance4x4_sse2;
const vp9_variance_fn_t variance4x8_sse2 = vp9_variance4x8_sse2;
const vp9_variance_fn_t variance8x4_sse2 = vp9_variance8x4_sse2;
const vp9_variance_fn_t variance8x8_sse2 = vp9_variance8x8_sse2;
const vp9_variance_fn_t variance8x16_sse2 = vp9_variance8x16_sse2;
const vp9_variance_fn_t variance16x8_sse2 = vp9_variance16x8_sse2;
const vp9_variance_fn_t variance16x16_sse2 = vp9_variance16x16_sse2;
const vp9_variance_fn_t variance16x32_sse2 = vp9_variance16x32_sse2;
const vp9_variance_fn_t variance32x16_sse2 = vp9_variance32x16_sse2;
const vp9_variance_fn_t variance32x32_sse2 = vp9_variance32x32_sse2;
const vp9_variance_fn_t variance32x64_sse2 = vp9_variance32x64_sse2;
const vp9_variance_fn_t variance64x32_sse2 = vp9_variance64x32_sse2;
const vp9_variance_fn_t variance64x64_sse2 = vp9_variance64x64_sse2;
518 519
INSTANTIATE_TEST_CASE_P(
    SSE2, VP9VarianceTest,
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559
    ::testing::Values(make_tuple(2, 2, variance4x4_sse2),
                      make_tuple(2, 3, variance4x8_sse2),
                      make_tuple(3, 2, variance8x4_sse2),
                      make_tuple(3, 3, variance8x8_sse2),
                      make_tuple(3, 4, variance8x16_sse2),
                      make_tuple(4, 3, variance16x8_sse2),
                      make_tuple(4, 4, variance16x16_sse2),
                      make_tuple(4, 5, variance16x32_sse2),
                      make_tuple(5, 4, variance32x16_sse2),
                      make_tuple(5, 5, variance32x32_sse2),
                      make_tuple(5, 6, variance32x64_sse2),
                      make_tuple(6, 5, variance64x32_sse2),
                      make_tuple(6, 6, variance64x64_sse2)));

const vp9_subpixvariance_fn_t subpel_variance4x4_sse =
    vp9_sub_pixel_variance4x4_sse;
const vp9_subpixvariance_fn_t subpel_variance4x8_sse =
    vp9_sub_pixel_variance4x8_sse;
const vp9_subpixvariance_fn_t subpel_variance8x4_sse2 =
    vp9_sub_pixel_variance8x4_sse2;
const vp9_subpixvariance_fn_t subpel_variance8x8_sse2 =
    vp9_sub_pixel_variance8x8_sse2;
const vp9_subpixvariance_fn_t subpel_variance8x16_sse2 =
    vp9_sub_pixel_variance8x16_sse2;
const vp9_subpixvariance_fn_t subpel_variance16x8_sse2 =
    vp9_sub_pixel_variance16x8_sse2;
const vp9_subpixvariance_fn_t subpel_variance16x16_sse2 =
    vp9_sub_pixel_variance16x16_sse2;
const vp9_subpixvariance_fn_t subpel_variance16x32_sse2 =
    vp9_sub_pixel_variance16x32_sse2;
const vp9_subpixvariance_fn_t subpel_variance32x16_sse2 =
    vp9_sub_pixel_variance32x16_sse2;
const vp9_subpixvariance_fn_t subpel_variance32x32_sse2 =
    vp9_sub_pixel_variance32x32_sse2;
const vp9_subpixvariance_fn_t subpel_variance32x64_sse2 =
    vp9_sub_pixel_variance32x64_sse2;
const vp9_subpixvariance_fn_t subpel_variance64x32_sse2 =
    vp9_sub_pixel_variance64x32_sse2;
const vp9_subpixvariance_fn_t subpel_variance64x64_sse2 =
    vp9_sub_pixel_variance64x64_sse2;
560 561
INSTANTIATE_TEST_CASE_P(
    SSE2, VP9SubpelVarianceTest,
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601
    ::testing::Values(make_tuple(2, 2, subpel_variance4x4_sse),
                      make_tuple(2, 3, subpel_variance4x8_sse),
                      make_tuple(3, 2, subpel_variance8x4_sse2),
                      make_tuple(3, 3, subpel_variance8x8_sse2),
                      make_tuple(3, 4, subpel_variance8x16_sse2),
                      make_tuple(4, 3, subpel_variance16x8_sse2),
                      make_tuple(4, 4, subpel_variance16x16_sse2),
                      make_tuple(4, 5, subpel_variance16x32_sse2),
                      make_tuple(5, 4, subpel_variance32x16_sse2),
                      make_tuple(5, 5, subpel_variance32x32_sse2),
                      make_tuple(5, 6, subpel_variance32x64_sse2),
                      make_tuple(6, 5, subpel_variance64x32_sse2),
                      make_tuple(6, 6, subpel_variance64x64_sse2)));

const vp9_subp_avg_variance_fn_t subpel_avg_variance4x4_sse =
    vp9_sub_pixel_avg_variance4x4_sse;
const vp9_subp_avg_variance_fn_t subpel_avg_variance4x8_sse =
    vp9_sub_pixel_avg_variance4x8_sse;
const vp9_subp_avg_variance_fn_t subpel_avg_variance8x4_sse2 =
    vp9_sub_pixel_avg_variance8x4_sse2;
const vp9_subp_avg_variance_fn_t subpel_avg_variance8x8_sse2 =
    vp9_sub_pixel_avg_variance8x8_sse2;
const vp9_subp_avg_variance_fn_t subpel_avg_variance8x16_sse2 =
    vp9_sub_pixel_avg_variance8x16_sse2;
const vp9_subp_avg_variance_fn_t subpel_avg_variance16x8_sse2 =
    vp9_sub_pixel_avg_variance16x8_sse2;
const vp9_subp_avg_variance_fn_t subpel_avg_variance16x16_sse2 =
    vp9_sub_pixel_avg_variance16x16_sse2;
const vp9_subp_avg_variance_fn_t subpel_avg_variance16x32_sse2 =
    vp9_sub_pixel_avg_variance16x32_sse2;
const vp9_subp_avg_variance_fn_t subpel_avg_variance32x16_sse2 =
    vp9_sub_pixel_avg_variance32x16_sse2;
const vp9_subp_avg_variance_fn_t subpel_avg_variance32x32_sse2 =
    vp9_sub_pixel_avg_variance32x32_sse2;
const vp9_subp_avg_variance_fn_t subpel_avg_variance32x64_sse2 =
    vp9_sub_pixel_avg_variance32x64_sse2;
const vp9_subp_avg_variance_fn_t subpel_avg_variance64x32_sse2 =
    vp9_sub_pixel_avg_variance64x32_sse2;
const vp9_subp_avg_variance_fn_t subpel_avg_variance64x64_sse2 =
    vp9_sub_pixel_avg_variance64x64_sse2;
602 603
INSTANTIATE_TEST_CASE_P(
    SSE2, VP9SubpelAvgVarianceTest,
604 605 606 607 608 609 610 611 612 613 614 615 616
    ::testing::Values(make_tuple(2, 2, subpel_avg_variance4x4_sse),
                      make_tuple(2, 3, subpel_avg_variance4x8_sse),
                      make_tuple(3, 2, subpel_avg_variance8x4_sse2),
                      make_tuple(3, 3, subpel_avg_variance8x8_sse2),
                      make_tuple(3, 4, subpel_avg_variance8x16_sse2),
                      make_tuple(4, 3, subpel_avg_variance16x8_sse2),
                      make_tuple(4, 4, subpel_avg_variance16x16_sse2),
                      make_tuple(4, 5, subpel_avg_variance16x32_sse2),
                      make_tuple(5, 4, subpel_avg_variance32x16_sse2),
                      make_tuple(5, 5, subpel_avg_variance32x32_sse2),
                      make_tuple(5, 6, subpel_avg_variance32x64_sse2),
                      make_tuple(6, 5, subpel_avg_variance64x32_sse2),
                      make_tuple(6, 6, subpel_avg_variance64x64_sse2)));
617
#endif
Jim Bankoski's avatar
Jim Bankoski committed
618
#endif
619 620

#if HAVE_SSSE3
Jim Bankoski's avatar
Jim Bankoski committed
621 622
#if CONFIG_USE_X86INC

623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648
const vp9_subpixvariance_fn_t subpel_variance4x4_ssse3 =
    vp9_sub_pixel_variance4x4_ssse3;
const vp9_subpixvariance_fn_t subpel_variance4x8_ssse3 =
    vp9_sub_pixel_variance4x8_ssse3;
const vp9_subpixvariance_fn_t subpel_variance8x4_ssse3 =
    vp9_sub_pixel_variance8x4_ssse3;
const vp9_subpixvariance_fn_t subpel_variance8x8_ssse3 =
    vp9_sub_pixel_variance8x8_ssse3;
const vp9_subpixvariance_fn_t subpel_variance8x16_ssse3 =
    vp9_sub_pixel_variance8x16_ssse3;
const vp9_subpixvariance_fn_t subpel_variance16x8_ssse3 =
    vp9_sub_pixel_variance16x8_ssse3;
const vp9_subpixvariance_fn_t subpel_variance16x16_ssse3 =
    vp9_sub_pixel_variance16x16_ssse3;
const vp9_subpixvariance_fn_t subpel_variance16x32_ssse3 =
    vp9_sub_pixel_variance16x32_ssse3;
const vp9_subpixvariance_fn_t subpel_variance32x16_ssse3 =
    vp9_sub_pixel_variance32x16_ssse3;
const vp9_subpixvariance_fn_t subpel_variance32x32_ssse3 =
    vp9_sub_pixel_variance32x32_ssse3;
const vp9_subpixvariance_fn_t subpel_variance32x64_ssse3 =
    vp9_sub_pixel_variance32x64_ssse3;
const vp9_subpixvariance_fn_t subpel_variance64x32_ssse3 =
    vp9_sub_pixel_variance64x32_ssse3;
const vp9_subpixvariance_fn_t subpel_variance64x64_ssse3 =
    vp9_sub_pixel_variance64x64_ssse3;
649 650
INSTANTIATE_TEST_CASE_P(
    SSSE3, VP9SubpelVarianceTest,
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690
    ::testing::Values(make_tuple(2, 2, subpel_variance4x4_ssse3),
                      make_tuple(2, 3, subpel_variance4x8_ssse3),
                      make_tuple(3, 2, subpel_variance8x4_ssse3),
                      make_tuple(3, 3, subpel_variance8x8_ssse3),
                      make_tuple(3, 4, subpel_variance8x16_ssse3),
                      make_tuple(4, 3, subpel_variance16x8_ssse3),
                      make_tuple(4, 4, subpel_variance16x16_ssse3),
                      make_tuple(4, 5, subpel_variance16x32_ssse3),
                      make_tuple(5, 4, subpel_variance32x16_ssse3),
                      make_tuple(5, 5, subpel_variance32x32_ssse3),
                      make_tuple(5, 6, subpel_variance32x64_ssse3),
                      make_tuple(6, 5, subpel_variance64x32_ssse3),
                      make_tuple(6, 6, subpel_variance64x64_ssse3)));

const vp9_subp_avg_variance_fn_t subpel_avg_variance4x4_ssse3 =
    vp9_sub_pixel_avg_variance4x4_ssse3;
const vp9_subp_avg_variance_fn_t subpel_avg_variance4x8_ssse3 =
    vp9_sub_pixel_avg_variance4x8_ssse3;
const vp9_subp_avg_variance_fn_t subpel_avg_variance8x4_ssse3 =
    vp9_sub_pixel_avg_variance8x4_ssse3;
const vp9_subp_avg_variance_fn_t subpel_avg_variance8x8_ssse3 =
    vp9_sub_pixel_avg_variance8x8_ssse3;
const vp9_subp_avg_variance_fn_t subpel_avg_variance8x16_ssse3 =
    vp9_sub_pixel_avg_variance8x16_ssse3;
const vp9_subp_avg_variance_fn_t subpel_avg_variance16x8_ssse3 =
    vp9_sub_pixel_avg_variance16x8_ssse3;
const vp9_subp_avg_variance_fn_t subpel_avg_variance16x16_ssse3 =
    vp9_sub_pixel_avg_variance16x16_ssse3;
const vp9_subp_avg_variance_fn_t subpel_avg_variance16x32_ssse3 =
    vp9_sub_pixel_avg_variance16x32_ssse3;
const vp9_subp_avg_variance_fn_t subpel_avg_variance32x16_ssse3 =
    vp9_sub_pixel_avg_variance32x16_ssse3;
const vp9_subp_avg_variance_fn_t subpel_avg_variance32x32_ssse3 =
    vp9_sub_pixel_avg_variance32x32_ssse3;
const vp9_subp_avg_variance_fn_t subpel_avg_variance32x64_ssse3 =
    vp9_sub_pixel_avg_variance32x64_ssse3;
const vp9_subp_avg_variance_fn_t subpel_avg_variance64x32_ssse3 =
    vp9_sub_pixel_avg_variance64x32_ssse3;
const vp9_subp_avg_variance_fn_t subpel_avg_variance64x64_ssse3 =
    vp9_sub_pixel_avg_variance64x64_ssse3;
691 692
INSTANTIATE_TEST_CASE_P(
    SSSE3, VP9SubpelAvgVarianceTest,
693 694 695 696 697 698 699 700 701 702 703 704 705
    ::testing::Values(make_tuple(2, 2, subpel_avg_variance4x4_ssse3),
                      make_tuple(2, 3, subpel_avg_variance4x8_ssse3),
                      make_tuple(3, 2, subpel_avg_variance8x4_ssse3),
                      make_tuple(3, 3, subpel_avg_variance8x8_ssse3),
                      make_tuple(3, 4, subpel_avg_variance8x16_ssse3),
                      make_tuple(4, 3, subpel_avg_variance16x8_ssse3),
                      make_tuple(4, 4, subpel_avg_variance16x16_ssse3),
                      make_tuple(4, 5, subpel_avg_variance16x32_ssse3),
                      make_tuple(5, 4, subpel_avg_variance32x16_ssse3),
                      make_tuple(5, 5, subpel_avg_variance32x32_ssse3),
                      make_tuple(5, 6, subpel_avg_variance32x64_ssse3),
                      make_tuple(6, 5, subpel_avg_variance64x32_ssse3),
                      make_tuple(6, 6, subpel_avg_variance64x64_ssse3)));
706
#endif
Jim Bankoski's avatar
Jim Bankoski committed
707
#endif
708 709

#if HAVE_AVX2
levytamar82's avatar
levytamar82 committed
710

711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728
const vp9_variance_fn_t variance16x16_avx2 = vp9_variance16x16_avx2;
const vp9_variance_fn_t variance32x16_avx2 = vp9_variance32x16_avx2;
const vp9_variance_fn_t variance32x32_avx2 = vp9_variance32x32_avx2;
const vp9_variance_fn_t variance64x32_avx2 = vp9_variance64x32_avx2;
const vp9_variance_fn_t variance64x64_avx2 = vp9_variance64x64_avx2;
INSTANTIATE_TEST_CASE_P(
    AVX2, VP9VarianceTest,
    ::testing::Values(make_tuple(4, 4, variance16x16_avx2),
                      make_tuple(5, 4, variance32x16_avx2),
                      make_tuple(5, 5, variance32x32_avx2),
                      make_tuple(6, 5, variance64x32_avx2),
                      make_tuple(6, 6, variance64x64_avx2)));

const vp9_subpixvariance_fn_t subpel_variance32x32_avx2 =
    vp9_sub_pixel_variance32x32_avx2;
const vp9_subpixvariance_fn_t subpel_variance64x64_avx2 =
    vp9_sub_pixel_variance64x64_avx2;
INSTANTIATE_TEST_CASE_P(
levytamar82's avatar
levytamar82 committed
729
    AVX2, VP9SubpelVarianceTest,
730 731 732 733 734 735 736 737
    ::testing::Values(make_tuple(5, 5, subpel_variance32x32_avx2),
                      make_tuple(6, 6, subpel_variance64x64_avx2)));

const vp9_subp_avg_variance_fn_t subpel_avg_variance32x32_avx2 =
    vp9_sub_pixel_avg_variance32x32_avx2;
const vp9_subp_avg_variance_fn_t subpel_avg_variance64x64_avx2 =
    vp9_sub_pixel_avg_variance64x64_avx2;
INSTANTIATE_TEST_CASE_P(
levytamar82's avatar
levytamar82 committed
738
    AVX2, VP9SubpelAvgVarianceTest,
739 740 741
    ::testing::Values(make_tuple(5, 5, subpel_avg_variance32x32_avx2),
                      make_tuple(6, 6, subpel_avg_variance64x64_avx2)));
#endif  // HAVE_AVX2
742
#if HAVE_NEON
743
const vp9_variance_fn_t variance8x8_neon = vp9_variance8x8_neon;
744
const vp9_variance_fn_t variance16x16_neon = vp9_variance16x16_neon;
745
const vp9_variance_fn_t variance32x32_neon = vp9_variance32x32_neon;
746 747
INSTANTIATE_TEST_CASE_P(
    NEON, VP9VarianceTest,
748 749
    ::testing::Values(make_tuple(3, 3, variance8x8_neon),
                      make_tuple(4, 4, variance16x16_neon),
750
                      make_tuple(5, 5, variance32x32_neon)));
751

752 753
const vp9_subpixvariance_fn_t subpel_variance8x8_neon =
    vp9_sub_pixel_variance8x8_neon;
754 755
const vp9_subpixvariance_fn_t subpel_variance16x16_neon =
    vp9_sub_pixel_variance16x16_neon;
756 757
const vp9_subpixvariance_fn_t subpel_variance32x32_neon =
    vp9_sub_pixel_variance32x32_neon;
758 759
INSTANTIATE_TEST_CASE_P(
    NEON, VP9SubpelVarianceTest,
760 761
    ::testing::Values(make_tuple(3, 3, subpel_variance8x8_neon),
                      make_tuple(4, 4, subpel_variance16x16_neon),
762
                      make_tuple(5, 5, subpel_variance32x32_neon)));
763
#endif  // HAVE_NEON
James Zern's avatar
James Zern committed
764 765 766 767
#endif  // CONFIG_VP9_ENCODER

}  // namespace vp9

768
}  // namespace