convolve_test.cc 49.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/*
 *  Copyright (c) 2010 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.
 */

11
#include <string.h>
12

James Zern's avatar
James Zern committed
13
#include "third_party/googletest/src/include/gtest/gtest.h"
14 15 16

#include "./vpx_config.h"
#include "./vp9_rtcd.h"
Zoe Liu's avatar
Zoe Liu committed
17
#include "./vpx_dsp_rtcd.h"
18 19 20 21
#include "test/acm_random.h"
#include "test/clear_system_state.h"
#include "test/register_state_check.h"
#include "test/util.h"
22
#include "vp9/common/vp9_common.h"
23
#include "vp9/common/vp9_filter.h"
Zoe Liu's avatar
Zoe Liu committed
24 25
#include "vpx_dsp/vpx_dsp_common.h"
#include "vpx_dsp/vpx_filter.h"
26
#include "vpx_mem/vpx_mem.h"
27
#include "vpx_ports/mem.h"
28 29

namespace {
30

hkuang's avatar
hkuang committed
31
static const unsigned int kMaxDimension = 64;
32

33 34 35 36 37
typedef void (*ConvolveFunc)(const uint8_t *src, ptrdiff_t src_stride,
                             uint8_t *dst, ptrdiff_t dst_stride,
                             const int16_t *filter_x, int filter_x_stride,
                             const int16_t *filter_y, int filter_y_stride,
                             int w, int h);
38 39

struct ConvolveFunctions {
40 41
  ConvolveFunctions(ConvolveFunc copy, ConvolveFunc avg,
                    ConvolveFunc h8, ConvolveFunc h8_avg,
42
                    ConvolveFunc v8, ConvolveFunc v8_avg,
43
                    ConvolveFunc hv8, ConvolveFunc hv8_avg,
44 45 46
                    ConvolveFunc sh8, ConvolveFunc sh8_avg,
                    ConvolveFunc sv8, ConvolveFunc sv8_avg,
                    ConvolveFunc shv8, ConvolveFunc shv8_avg,
47
                    int bd)
48
      : copy_(copy), avg_(avg), h8_(h8), v8_(v8), hv8_(hv8), h8_avg_(h8_avg),
49 50 51
        v8_avg_(v8_avg), hv8_avg_(hv8_avg), sh8_(sh8), sv8_(sv8), shv8_(shv8),
        sh8_avg_(sh8_avg), sv8_avg_(sv8_avg), shv8_avg_(shv8_avg),
        use_highbd_(bd) {}
52

53 54
  ConvolveFunc copy_;
  ConvolveFunc avg_;
55 56 57 58 59 60
  ConvolveFunc h8_;
  ConvolveFunc v8_;
  ConvolveFunc hv8_;
  ConvolveFunc h8_avg_;
  ConvolveFunc v8_avg_;
  ConvolveFunc hv8_avg_;
61 62 63 64 65 66
  ConvolveFunc sh8_;        // scaled horiz
  ConvolveFunc sv8_;        // scaled vert
  ConvolveFunc shv8_;       // scaled horiz/vert
  ConvolveFunc sh8_avg_;    // scaled avg horiz
  ConvolveFunc sv8_avg_;    // scaled avg vert
  ConvolveFunc shv8_avg_;   // scaled avg horiz/vert
67
  int use_highbd_;  // 0 if high bitdepth not used, else the actual bit depth.
68 69
};

70
typedef std::tr1::tuple<int, int, const ConvolveFunctions *> ConvolveParam;
71

72 73 74
// Reference 8-tap subpixel filter, slightly modified to fit into this test.
#define VP9_FILTER_WEIGHT 128
#define VP9_FILTER_SHIFT 7
James Zern's avatar
James Zern committed
75
uint8_t clip_pixel(int x) {
76 77 78 79 80
  return x < 0 ? 0 :
         x > 255 ? 255 :
         x;
}

James Zern's avatar
James Zern committed
81 82 83 84 85 86 87 88
void filter_block2d_8_c(const uint8_t *src_ptr,
                        const unsigned int src_stride,
                        const int16_t *HFilter,
                        const int16_t *VFilter,
                        uint8_t *dst_ptr,
                        unsigned int dst_stride,
                        unsigned int output_width,
                        unsigned int output_height) {
89 90 91 92 93
  // Between passes, we use an intermediate buffer whose height is extended to
  // have enough horizontally filtered values as input for the vertical pass.
  // This buffer is allocated to be big enough for the largest block type we
  // support.
  const int kInterp_Extend = 4;
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 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
  const unsigned int intermediate_height =
      (kInterp_Extend - 1) + output_height + kInterp_Extend;
  unsigned int i, j;

  // Size of intermediate_buffer is max_intermediate_height * filter_max_width,
  // where max_intermediate_height = (kInterp_Extend - 1) + filter_max_height
  //                                 + kInterp_Extend
  //                               = 3 + 16 + 4
  //                               = 23
  // and filter_max_width          = 16
  //
  uint8_t intermediate_buffer[71 * kMaxDimension];
  const int intermediate_next_stride = 1 - intermediate_height * output_width;

  // Horizontal pass (src -> transposed intermediate).
  uint8_t *output_ptr = intermediate_buffer;
  const int src_next_row_stride = src_stride - output_width;
  src_ptr -= (kInterp_Extend - 1) * src_stride + (kInterp_Extend - 1);
  for (i = 0; i < intermediate_height; ++i) {
    for (j = 0; j < output_width; ++j) {
      // Apply filter...
      const int temp = (src_ptr[0] * HFilter[0]) +
          (src_ptr[1] * HFilter[1]) +
          (src_ptr[2] * HFilter[2]) +
          (src_ptr[3] * HFilter[3]) +
          (src_ptr[4] * HFilter[4]) +
          (src_ptr[5] * HFilter[5]) +
          (src_ptr[6] * HFilter[6]) +
          (src_ptr[7] * HFilter[7]) +
          (VP9_FILTER_WEIGHT >> 1);  // Rounding

      // Normalize back to 0-255...
      *output_ptr = clip_pixel(temp >> VP9_FILTER_SHIFT);
      ++src_ptr;
      output_ptr += intermediate_height;
    }
    src_ptr += src_next_row_stride;
    output_ptr += intermediate_next_stride;
  }

  // Vertical pass (transposed intermediate -> dst).
  src_ptr = intermediate_buffer;
  const int dst_next_row_stride = dst_stride - output_width;
  for (i = 0; i < output_height; ++i) {
    for (j = 0; j < output_width; ++j) {
      // Apply filter...
      const int temp = (src_ptr[0] * VFilter[0]) +
          (src_ptr[1] * VFilter[1]) +
          (src_ptr[2] * VFilter[2]) +
          (src_ptr[3] * VFilter[3]) +
          (src_ptr[4] * VFilter[4]) +
          (src_ptr[5] * VFilter[5]) +
          (src_ptr[6] * VFilter[6]) +
          (src_ptr[7] * VFilter[7]) +
          (VP9_FILTER_WEIGHT >> 1);  // Rounding

      // Normalize back to 0-255...
      *dst_ptr++ = clip_pixel(temp >> VP9_FILTER_SHIFT);
      src_ptr += intermediate_height;
    }
    src_ptr += intermediate_next_stride;
    dst_ptr += dst_next_row_stride;
  }
}

void block2d_average_c(uint8_t *src,
                       unsigned int src_stride,
                       uint8_t *output_ptr,
                       unsigned int output_stride,
                       unsigned int output_width,
                       unsigned int output_height) {
  unsigned int i, j;
  for (i = 0; i < output_height; ++i) {
    for (j = 0; j < output_width; ++j) {
      output_ptr[j] = (output_ptr[j] + src[i * src_stride + j] + 1) >> 1;
    }
    output_ptr += output_stride;
  }
}

void filter_average_block2d_8_c(const uint8_t *src_ptr,
                                const unsigned int src_stride,
                                const int16_t *HFilter,
                                const int16_t *VFilter,
                                uint8_t *dst_ptr,
                                unsigned int dst_stride,
                                unsigned int output_width,
                                unsigned int output_height) {
  uint8_t tmp[kMaxDimension * kMaxDimension];

  assert(output_width <= kMaxDimension);
  assert(output_height <= kMaxDimension);
  filter_block2d_8_c(src_ptr, src_stride, HFilter, VFilter, tmp, 64,
                     output_width, output_height);
  block2d_average_c(tmp, 64, dst_ptr, dst_stride,
                    output_width, output_height);
}

#if CONFIG_VP9_HIGHBITDEPTH
193 194 195 196 197 198 199 200 201
void highbd_filter_block2d_8_c(const uint16_t *src_ptr,
                               const unsigned int src_stride,
                               const int16_t *HFilter,
                               const int16_t *VFilter,
                               uint16_t *dst_ptr,
                               unsigned int dst_stride,
                               unsigned int output_width,
                               unsigned int output_height,
                               int bd) {
202 203 204 205 206
  // Between passes, we use an intermediate buffer whose height is extended to
  // have enough horizontally filtered values as input for the vertical pass.
  // This buffer is allocated to be big enough for the largest block type we
  // support.
  const int kInterp_Extend = 4;
207
  const unsigned int intermediate_height =
James Zern's avatar
James Zern committed
208
      (kInterp_Extend - 1) + output_height + kInterp_Extend;
209 210 211 212 213 214 215 216

  /* Size of intermediate_buffer is max_intermediate_height * filter_max_width,
   * where max_intermediate_height = (kInterp_Extend - 1) + filter_max_height
   *                                 + kInterp_Extend
   *                               = 3 + 16 + 4
   *                               = 23
   * and filter_max_width = 16
   */
217
  uint16_t intermediate_buffer[71 * kMaxDimension];
218 219 220 221
  const int intermediate_next_stride = 1 - intermediate_height * output_width;

  // Horizontal pass (src -> transposed intermediate).
  {
222
    uint16_t *output_ptr = intermediate_buffer;
223 224 225 226 227 228
    const int src_next_row_stride = src_stride - output_width;
    unsigned int i, j;
    src_ptr -= (kInterp_Extend - 1) * src_stride + (kInterp_Extend - 1);
    for (i = 0; i < intermediate_height; ++i) {
      for (j = 0; j < output_width; ++j) {
        // Apply filter...
James Zern's avatar
James Zern committed
229 230 231 232 233 234 235 236 237
        const int temp = (src_ptr[0] * HFilter[0]) +
                         (src_ptr[1] * HFilter[1]) +
                         (src_ptr[2] * HFilter[2]) +
                         (src_ptr[3] * HFilter[3]) +
                         (src_ptr[4] * HFilter[4]) +
                         (src_ptr[5] * HFilter[5]) +
                         (src_ptr[6] * HFilter[6]) +
                         (src_ptr[7] * HFilter[7]) +
                         (VP9_FILTER_WEIGHT >> 1);  // Rounding
238 239

        // Normalize back to 0-255...
240
        *output_ptr = clip_pixel_highbd(temp >> VP9_FILTER_SHIFT, bd);
241 242 243 244 245 246 247 248 249 250
        ++src_ptr;
        output_ptr += intermediate_height;
      }
      src_ptr += src_next_row_stride;
      output_ptr += intermediate_next_stride;
    }
  }

  // Vertical pass (transposed intermediate -> dst).
  {
251
    uint16_t *src_ptr = intermediate_buffer;
252 253 254 255 256
    const int dst_next_row_stride = dst_stride - output_width;
    unsigned int i, j;
    for (i = 0; i < output_height; ++i) {
      for (j = 0; j < output_width; ++j) {
        // Apply filter...
James Zern's avatar
James Zern committed
257 258 259 260 261 262 263 264 265
        const int temp = (src_ptr[0] * VFilter[0]) +
                         (src_ptr[1] * VFilter[1]) +
                         (src_ptr[2] * VFilter[2]) +
                         (src_ptr[3] * VFilter[3]) +
                         (src_ptr[4] * VFilter[4]) +
                         (src_ptr[5] * VFilter[5]) +
                         (src_ptr[6] * VFilter[6]) +
                         (src_ptr[7] * VFilter[7]) +
                         (VP9_FILTER_WEIGHT >> 1);  // Rounding
266 267

        // Normalize back to 0-255...
268
        *dst_ptr++ = clip_pixel_highbd(temp >> VP9_FILTER_SHIFT, bd);
269 270 271 272 273 274 275 276
        src_ptr += intermediate_height;
      }
      src_ptr += intermediate_next_stride;
      dst_ptr += dst_next_row_stride;
    }
  }
}

277 278 279 280 281 282 283
void highbd_block2d_average_c(uint16_t *src,
                              unsigned int src_stride,
                              uint16_t *output_ptr,
                              unsigned int output_stride,
                              unsigned int output_width,
                              unsigned int output_height,
                              int bd) {
284 285 286 287 288 289 290 291 292
  unsigned int i, j;
  for (i = 0; i < output_height; ++i) {
    for (j = 0; j < output_width; ++j) {
      output_ptr[j] = (output_ptr[j] + src[i * src_stride + j] + 1) >> 1;
    }
    output_ptr += output_stride;
  }
}

293 294 295 296 297 298 299 300 301
void highbd_filter_average_block2d_8_c(const uint16_t *src_ptr,
                                       const unsigned int src_stride,
                                       const int16_t *HFilter,
                                       const int16_t *VFilter,
                                       uint16_t *dst_ptr,
                                       unsigned int dst_stride,
                                       unsigned int output_width,
                                       unsigned int output_height,
                                       int bd) {
302 303 304 305
  uint16_t tmp[kMaxDimension * kMaxDimension];

  assert(output_width <= kMaxDimension);
  assert(output_height <= kMaxDimension);
306 307 308 309
  highbd_filter_block2d_8_c(src_ptr, src_stride, HFilter, VFilter, tmp, 64,
                            output_width, output_height, bd);
  highbd_block2d_average_c(tmp, 64, dst_ptr, dst_stride,
                           output_width, output_height, bd);
310
}
311
#endif  // CONFIG_VP9_HIGHBITDEPTH
312

313
class ConvolveTest : public ::testing::TestWithParam<ConvolveParam> {
314 315 316 317
 public:
  static void SetUpTestCase() {
    // Force input_ to be unaligned, output to be 16 byte aligned.
    input_ = reinterpret_cast<uint8_t*>(
318
        vpx_memalign(kDataAlignment, kInputBufferSize + 1)) + 1;
319
    output_ = reinterpret_cast<uint8_t*>(
320
        vpx_memalign(kDataAlignment, kOutputBufferSize));
321 322
    output_ref_ = reinterpret_cast<uint8_t*>(
        vpx_memalign(kDataAlignment, kOutputBufferSize));
323 324 325 326 327 328
#if CONFIG_VP9_HIGHBITDEPTH
    input16_ = reinterpret_cast<uint16_t*>(
        vpx_memalign(kDataAlignment,
                     (kInputBufferSize + 1) * sizeof(uint16_t))) + 1;
    output16_ = reinterpret_cast<uint16_t*>(
        vpx_memalign(kDataAlignment, (kOutputBufferSize) * sizeof(uint16_t)));
329 330
    output16_ref_ = reinterpret_cast<uint16_t*>(
        vpx_memalign(kDataAlignment, (kOutputBufferSize) * sizeof(uint16_t)));
331
#endif
332 333
  }

334 335
  virtual void TearDown() { libvpx_test::ClearSystemState(); }

336 337 338 339 340
  static void TearDownTestCase() {
    vpx_free(input_ - 1);
    input_ = NULL;
    vpx_free(output_);
    output_ = NULL;
341 342
    vpx_free(output_ref_);
    output_ref_ = NULL;
343 344 345 346 347
#if CONFIG_VP9_HIGHBITDEPTH
    vpx_free(input16_ - 1);
    input16_ = NULL;
    vpx_free(output16_);
    output16_ = NULL;
348 349
    vpx_free(output16_ref_);
    output16_ref_ = NULL;
350
#endif
351 352
  }

James Zern's avatar
James Zern committed
353 354
 protected:
  static const int kDataAlignment = 16;
355
  static const int kOuterBlockSize = 256;
James Zern's avatar
James Zern committed
356 357 358 359 360 361 362 363 364 365 366 367
  static const int kInputStride = kOuterBlockSize;
  static const int kOutputStride = kOuterBlockSize;
  static const int kInputBufferSize = kOuterBlockSize * kOuterBlockSize;
  static const int kOutputBufferSize = kOuterBlockSize * kOuterBlockSize;

  int Width() const { return GET_PARAM(0); }
  int Height() const { return GET_PARAM(1); }
  int BorderLeft() const {
    const int center = (kOuterBlockSize - Width()) / 2;
    return (center + (kDataAlignment - 1)) & ~(kDataAlignment - 1);
  }
  int BorderTop() const { return (kOuterBlockSize - Height()) / 2; }
368

James Zern's avatar
James Zern committed
369 370 371 372 373 374
  bool IsIndexInBorder(int i) {
    return (i < BorderTop() * kOuterBlockSize ||
            i >= (BorderTop() + Height()) * kOuterBlockSize ||
            i % kOuterBlockSize < BorderLeft() ||
            i % kOuterBlockSize >= (BorderLeft() + Width()));
  }
375

James Zern's avatar
James Zern committed
376 377
  virtual void SetUp() {
    UUT_ = GET_PARAM(2);
378
#if CONFIG_VP9_HIGHBITDEPTH
379 380
    if (UUT_->use_highbd_ != 0)
      mask_ = (1 << UUT_->use_highbd_) - 1;
381 382 383
    else
      mask_ = 255;
#endif
384
    /* Set up guard blocks for an inner block centered in the outer block */
James Zern's avatar
James Zern committed
385 386 387 388 389
    for (int i = 0; i < kOutputBufferSize; ++i) {
      if (IsIndexInBorder(i))
        output_[i] = 255;
      else
        output_[i] = 0;
390 391
    }

James Zern's avatar
James Zern committed
392
    ::libvpx_test::ACMRandom prng;
393
    for (int i = 0; i < kInputBufferSize; ++i) {
394
      if (i & 1) {
395
        input_[i] = 255;
396 397 398 399
#if CONFIG_VP9_HIGHBITDEPTH
        input16_[i] = mask_;
#endif
      } else {
400
        input_[i] = prng.Rand8Extremes();
401 402 403 404
#if CONFIG_VP9_HIGHBITDEPTH
        input16_[i] = prng.Rand16() & mask_;
#endif
      }
405
    }
James Zern's avatar
James Zern committed
406
  }
407

408 409
  void SetConstantInput(int value) {
    memset(input_, value, kInputBufferSize);
410 411 412
#if CONFIG_VP9_HIGHBITDEPTH
    vpx_memset16(input16_, value, kInputBufferSize);
#endif
413 414
  }

415
  void CopyOutputToRef() {
James Zern's avatar
James Zern committed
416
    memcpy(output_ref_, output_, kOutputBufferSize);
417
#if CONFIG_VP9_HIGHBITDEPTH
James Zern's avatar
James Zern committed
418
    memcpy(output16_ref_, output16_, kOutputBufferSize);
419 420 421
#endif
  }

James Zern's avatar
James Zern committed
422 423 424 425
  void CheckGuardBlocks() {
    for (int i = 0; i < kOutputBufferSize; ++i) {
      if (IsIndexInBorder(i))
        EXPECT_EQ(255, output_[i]);
426
    }
James Zern's avatar
James Zern committed
427
  }
428

429 430
  uint8_t *input() const {
#if CONFIG_VP9_HIGHBITDEPTH
431
    if (UUT_->use_highbd_ == 0) {
432 433 434 435 436 437
      return input_ + BorderTop() * kOuterBlockSize + BorderLeft();
    } else {
      return CONVERT_TO_BYTEPTR(input16_ + BorderTop() * kOuterBlockSize +
                                BorderLeft());
    }
#else
James Zern's avatar
James Zern committed
438
    return input_ + BorderTop() * kOuterBlockSize + BorderLeft();
439
#endif
James Zern's avatar
James Zern committed
440
  }
441

442 443
  uint8_t *output() const {
#if CONFIG_VP9_HIGHBITDEPTH
444
    if (UUT_->use_highbd_ == 0) {
445 446 447 448 449 450
      return output_ + BorderTop() * kOuterBlockSize + BorderLeft();
    } else {
      return CONVERT_TO_BYTEPTR(output16_ + BorderTop() * kOuterBlockSize +
                                BorderLeft());
    }
#else
James Zern's avatar
James Zern committed
451
    return output_ + BorderTop() * kOuterBlockSize + BorderLeft();
452 453 454
#endif
  }

455 456 457 458 459 460 461 462 463 464 465 466 467
  uint8_t *output_ref() const {
#if CONFIG_VP9_HIGHBITDEPTH
    if (UUT_->use_highbd_ == 0) {
      return output_ref_ + BorderTop() * kOuterBlockSize + BorderLeft();
    } else {
      return CONVERT_TO_BYTEPTR(output16_ref_ + BorderTop() * kOuterBlockSize +
                                BorderLeft());
    }
#else
    return output_ref_ + BorderTop() * kOuterBlockSize + BorderLeft();
#endif
  }

468 469
  uint16_t lookup(uint8_t *list, int index) const {
#if CONFIG_VP9_HIGHBITDEPTH
470
    if (UUT_->use_highbd_ == 0) {
471 472 473 474 475 476 477 478 479 480 481
      return list[index];
    } else {
      return CONVERT_TO_SHORTPTR(list)[index];
    }
#else
    return list[index];
#endif
  }

  void assign_val(uint8_t *list, int index, uint16_t val) const {
#if CONFIG_VP9_HIGHBITDEPTH
482
    if (UUT_->use_highbd_ == 0) {
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
      list[index] = (uint8_t) val;
    } else {
      CONVERT_TO_SHORTPTR(list)[index] = val;
    }
#else
    list[index] = (uint8_t) val;
#endif
  }

  void wrapper_filter_average_block2d_8_c(const uint8_t *src_ptr,
                                          const unsigned int src_stride,
                                          const int16_t *HFilter,
                                          const int16_t *VFilter,
                                          uint8_t *dst_ptr,
                                          unsigned int dst_stride,
                                          unsigned int output_width,
                                          unsigned int output_height) {
#if CONFIG_VP9_HIGHBITDEPTH
501
    if (UUT_->use_highbd_ == 0) {
502 503 504 505
      filter_average_block2d_8_c(src_ptr, src_stride, HFilter, VFilter,
                                 dst_ptr, dst_stride, output_width,
                                 output_height);
    } else {
506 507 508 509 510
      highbd_filter_average_block2d_8_c(CONVERT_TO_SHORTPTR(src_ptr),
                                        src_stride, HFilter, VFilter,
                                        CONVERT_TO_SHORTPTR(dst_ptr),
                                        dst_stride, output_width, output_height,
                                        UUT_->use_highbd_);
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527
    }
#else
    filter_average_block2d_8_c(src_ptr, src_stride, HFilter, VFilter,
                               dst_ptr, dst_stride, output_width,
                               output_height);
#endif
  }

  void wrapper_filter_block2d_8_c(const uint8_t *src_ptr,
                                  const unsigned int src_stride,
                                  const int16_t *HFilter,
                                  const int16_t *VFilter,
                                  uint8_t *dst_ptr,
                                  unsigned int dst_stride,
                                  unsigned int output_width,
                                  unsigned int output_height) {
#if CONFIG_VP9_HIGHBITDEPTH
528
    if (UUT_->use_highbd_ == 0) {
529 530 531
      filter_block2d_8_c(src_ptr, src_stride, HFilter, VFilter,
                         dst_ptr, dst_stride, output_width, output_height);
    } else {
532 533 534 535
      highbd_filter_block2d_8_c(CONVERT_TO_SHORTPTR(src_ptr), src_stride,
                                HFilter, VFilter,
                                CONVERT_TO_SHORTPTR(dst_ptr), dst_stride,
                                output_width, output_height, UUT_->use_highbd_);
536 537 538 539 540
    }
#else
    filter_block2d_8_c(src_ptr, src_stride, HFilter, VFilter,
                       dst_ptr, dst_stride, output_width, output_height);
#endif
James Zern's avatar
James Zern committed
541 542 543 544 545
  }

  const ConvolveFunctions* UUT_;
  static uint8_t* input_;
  static uint8_t* output_;
546
  static uint8_t* output_ref_;
547 548 549
#if CONFIG_VP9_HIGHBITDEPTH
  static uint16_t* input16_;
  static uint16_t* output16_;
550
  static uint16_t* output16_ref_;
551 552
  int mask_;
#endif
553
};
554

555 556
uint8_t* ConvolveTest::input_ = NULL;
uint8_t* ConvolveTest::output_ = NULL;
557
uint8_t* ConvolveTest::output_ref_ = NULL;
558 559 560
#if CONFIG_VP9_HIGHBITDEPTH
uint16_t* ConvolveTest::input16_ = NULL;
uint16_t* ConvolveTest::output16_ = NULL;
561
uint16_t* ConvolveTest::output16_ref_ = NULL;
562
#endif
563 564 565 566 567

TEST_P(ConvolveTest, GuardBlocks) {
  CheckGuardBlocks();
}

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 602 603 604
TEST_P(ConvolveTest, Copy) {
  uint8_t* const in = input();
  uint8_t* const out = output();

  ASM_REGISTER_STATE_CHECK(
      UUT_->copy_(in, kInputStride, out, kOutputStride, NULL, 0, NULL, 0,
                  Width(), Height()));

  CheckGuardBlocks();

  for (int y = 0; y < Height(); ++y)
    for (int x = 0; x < Width(); ++x)
      ASSERT_EQ(lookup(out, y * kOutputStride + x),
                lookup(in, y * kInputStride + x))
          << "(" << x << "," << y << ")";
}

TEST_P(ConvolveTest, Avg) {
  uint8_t* const in = input();
  uint8_t* const out = output();
  uint8_t* const out_ref = output_ref();
  CopyOutputToRef();

  ASM_REGISTER_STATE_CHECK(
      UUT_->avg_(in, kInputStride, out, kOutputStride, NULL, 0, NULL, 0,
                Width(), Height()));

  CheckGuardBlocks();

  for (int y = 0; y < Height(); ++y)
    for (int x = 0; x < Width(); ++x)
      ASSERT_EQ(lookup(out, y * kOutputStride + x),
                ROUND_POWER_OF_TWO(lookup(in, y * kInputStride + x) +
                                   lookup(out_ref, y * kOutputStride + x), 1))
          << "(" << x << "," << y << ")";
}

605 606 607
TEST_P(ConvolveTest, CopyHoriz) {
  uint8_t* const in = input();
  uint8_t* const out = output();
608
  DECLARE_ALIGNED(256, const int16_t, filter8[8]) = {0, 0, 0, 128, 0, 0, 0, 0};
609

610
  ASM_REGISTER_STATE_CHECK(
611 612
      UUT_->sh8_(in, kInputStride, out, kOutputStride, filter8, 16, filter8, 16,
                 Width(), Height()));
613 614 615 616 617

  CheckGuardBlocks();

  for (int y = 0; y < Height(); ++y)
    for (int x = 0; x < Width(); ++x)
618 619
      ASSERT_EQ(lookup(out, y * kOutputStride + x),
                lookup(in, y * kInputStride + x))
620 621 622 623 624 625
          << "(" << x << "," << y << ")";
}

TEST_P(ConvolveTest, CopyVert) {
  uint8_t* const in = input();
  uint8_t* const out = output();
626
  DECLARE_ALIGNED(256, const int16_t, filter8[8]) = {0, 0, 0, 128, 0, 0, 0, 0};
627

628
  ASM_REGISTER_STATE_CHECK(
629 630
      UUT_->sv8_(in, kInputStride, out, kOutputStride, filter8, 16, filter8, 16,
                 Width(), Height()));
631 632 633 634 635

  CheckGuardBlocks();

  for (int y = 0; y < Height(); ++y)
    for (int x = 0; x < Width(); ++x)
636 637
      ASSERT_EQ(lookup(out, y * kOutputStride + x),
                lookup(in, y * kInputStride + x))
638 639 640 641 642 643
          << "(" << x << "," << y << ")";
}

TEST_P(ConvolveTest, Copy2D) {
  uint8_t* const in = input();
  uint8_t* const out = output();
644
  DECLARE_ALIGNED(256, const int16_t, filter8[8]) = {0, 0, 0, 128, 0, 0, 0, 0};
645

646
  ASM_REGISTER_STATE_CHECK(
647 648
      UUT_->shv8_(in, kInputStride, out, kOutputStride, filter8, 16, filter8,
                  16, Width(), Height()));
649 650 651 652 653

  CheckGuardBlocks();

  for (int y = 0; y < Height(); ++y)
    for (int x = 0; x < Width(); ++x)
654 655
      ASSERT_EQ(lookup(out, y * kOutputStride + x),
                lookup(in, y * kInputStride + x))
656 657 658
          << "(" << x << "," << y << ")";
}

659
const int kNumFilterBanks = 4;
660 661 662 663
const int kNumFilters = 16;

TEST(ConvolveTest, FiltersWontSaturateWhenAddedPairwise) {
  for (int filter_bank = 0; filter_bank < kNumFilterBanks; ++filter_bank) {
664
    const InterpKernel *filters =
665
        vp9_filter_kernels[static_cast<INTERP_FILTER>(filter_bank)];
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681
    for (int i = 0; i < kNumFilters; i++) {
      const int p0 = filters[i][0] + filters[i][1];
      const int p1 = filters[i][2] + filters[i][3];
      const int p2 = filters[i][4] + filters[i][5];
      const int p3 = filters[i][6] + filters[i][7];
      EXPECT_LE(p0, 128);
      EXPECT_LE(p1, 128);
      EXPECT_LE(p2, 128);
      EXPECT_LE(p3, 128);
      EXPECT_LE(p0 + p3, 128);
      EXPECT_LE(p0 + p3 + p1, 128);
      EXPECT_LE(p0 + p3 + p1 + p2, 128);
      EXPECT_EQ(p0 + p1 + p2 + p3, 128);
    }
  }
}
682

683 684
const int16_t kInvalidFilter[8] = { 0 };

685 686 687
TEST_P(ConvolveTest, MatchesReferenceSubpixelFilter) {
  uint8_t* const in = input();
  uint8_t* const out = output();
688 689 690 691
#if CONFIG_VP9_HIGHBITDEPTH
  uint8_t ref8[kOutputStride * kMaxDimension];
  uint16_t ref16[kOutputStride * kMaxDimension];
  uint8_t* ref;
692
  if (UUT_->use_highbd_ == 0) {
693 694 695 696 697
    ref = ref8;
  } else {
    ref = CONVERT_TO_BYTEPTR(ref16);
  }
#else
698
  uint8_t ref[kOutputStride * kMaxDimension];
699
#endif
700 701

  for (int filter_bank = 0; filter_bank < kNumFilterBanks; ++filter_bank) {
702
    const InterpKernel *filters =
703
        vp9_filter_kernels[static_cast<INTERP_FILTER>(filter_bank)];
704

705 706
    for (int filter_x = 0; filter_x < kNumFilters; ++filter_x) {
      for (int filter_y = 0; filter_y < kNumFilters; ++filter_y) {
707 708 709 710
        wrapper_filter_block2d_8_c(in, kInputStride,
                                   filters[filter_x], filters[filter_y],
                                   ref, kOutputStride,
                                   Width(), Height());
711

712
        if (filter_x && filter_y)
713
          ASM_REGISTER_STATE_CHECK(
714 715 716 717
              UUT_->hv8_(in, kInputStride, out, kOutputStride,
                         filters[filter_x], 16, filters[filter_y], 16,
                         Width(), Height()));
        else if (filter_y)
718
          ASM_REGISTER_STATE_CHECK(
719
              UUT_->v8_(in, kInputStride, out, kOutputStride,
720
                        kInvalidFilter, 16, filters[filter_y], 16,
721
                        Width(), Height()));
722
        else if (filter_x)
723
          ASM_REGISTER_STATE_CHECK(
724
              UUT_->h8_(in, kInputStride, out, kOutputStride,
725
                        filters[filter_x], 16, kInvalidFilter, 16,
726
                        Width(), Height()));
727 728 729 730 731
        else
          ASM_REGISTER_STATE_CHECK(
              UUT_->copy_(in, kInputStride, out, kOutputStride,
                          kInvalidFilter, 0, kInvalidFilter, 0,
                          Width(), Height()));
732 733 734 735 736

        CheckGuardBlocks();

        for (int y = 0; y < Height(); ++y)
          for (int x = 0; x < Width(); ++x)
737 738
            ASSERT_EQ(lookup(ref, y * kOutputStride + x),
                      lookup(out, y * kOutputStride + x))
739 740 741 742
                << "mismatch at (" << x << "," << y << "), "
                << "filters (" << filter_bank << ","
                << filter_x << "," << filter_y << ")";
      }
743 744 745 746 747 748 749
    }
  }
}

TEST_P(ConvolveTest, MatchesReferenceAveragingSubpixelFilter) {
  uint8_t* const in = input();
  uint8_t* const out = output();
750 751 752 753
#if CONFIG_VP9_HIGHBITDEPTH
  uint8_t ref8[kOutputStride * kMaxDimension];
  uint16_t ref16[kOutputStride * kMaxDimension];
  uint8_t* ref;
754
  if (UUT_->use_highbd_ == 0) {
755 756 757 758 759
    ref = ref8;
  } else {
    ref = CONVERT_TO_BYTEPTR(ref16);
  }
#else
760
  uint8_t ref[kOutputStride * kMaxDimension];
761
#endif
762 763 764 765 766

  // Populate ref and out with some random data
  ::libvpx_test::ACMRandom prng;
  for (int y = 0; y < Height(); ++y) {
    for (int x = 0; x < Width(); ++x) {
767 768
      uint16_t r;
#if CONFIG_VP9_HIGHBITDEPTH
769
      if (UUT_->use_highbd_ == 0 || UUT_->use_highbd_ == 8) {
770 771 772 773 774 775 776
        r = prng.Rand8Extremes();
      } else {
        r = prng.Rand16() & mask_;
      }
#else
      r = prng.Rand8Extremes();
#endif
777

778 779
      assign_val(out, y * kOutputStride + x, r);
      assign_val(ref, y * kOutputStride + x, r);
780 781 782
    }
  }

783
  for (int filter_bank = 0; filter_bank < kNumFilterBanks; ++filter_bank) {
784
    const InterpKernel *filters =
785
        vp9_filter_kernels[static_cast<INTERP_FILTER>(filter_bank)];
786 787 788

    for (int filter_x = 0; filter_x < kNumFilters; ++filter_x) {
      for (int filter_y = 0; filter_y < kNumFilters; ++filter_y) {
789 790 791 792
        wrapper_filter_average_block2d_8_c(in, kInputStride,
                                           filters[filter_x], filters[filter_y],
                                           ref, kOutputStride,
                                           Width(), Height());
793

794
        if (filter_x && filter_y)
795
          ASM_REGISTER_STATE_CHECK(
796 797 798 799
              UUT_->hv8_avg_(in, kInputStride, out, kOutputStride,
                             filters[filter_x], 16, filters[filter_y], 16,
                             Width(), Height()));
        else if (filter_y)
800
          ASM_REGISTER_STATE_CHECK(
801
              UUT_->v8_avg_(in, kInputStride, out, kOutputStride,
802
                            kInvalidFilter, 16, filters[filter_y], 16,
803
                            Width(), Height()));
804
        else if (filter_x)
805
          ASM_REGISTER_STATE_CHECK(
806
              UUT_->h8_avg_(in, kInputStride, out, kOutputStride,
807
                            filters[filter_x], 16, kInvalidFilter, 16,
808
                            Width(), Height()));
809 810 811 812 813
        else
          ASM_REGISTER_STATE_CHECK(
              UUT_->avg_(in, kInputStride, out, kOutputStride,
                          kInvalidFilter, 0, kInvalidFilter, 0,
                          Width(), Height()));
814 815 816 817 818

        CheckGuardBlocks();

        for (int y = 0; y < Height(); ++y)
          for (int x = 0; x < Width(); ++x)
819 820
            ASSERT_EQ(lookup(ref, y * kOutputStride + x),
                      lookup(out, y * kOutputStride + x))
821 822 823 824
                << "mismatch at (" << x << "," << y << "), "
                << "filters (" << filter_bank << ","
                << filter_x << "," << filter_y << ")";
      }
825 826 827 828
    }
  }
}

829 830 831 832 833 834 835
TEST_P(ConvolveTest, FilterExtremes) {
  uint8_t *const in = input();
  uint8_t *const out = output();
#if CONFIG_VP9_HIGHBITDEPTH
  uint8_t ref8[kOutputStride * kMaxDimension];
  uint16_t ref16[kOutputStride * kMaxDimension];
  uint8_t *ref;
836
  if (UUT_->use_highbd_ == 0) {
837 838 839 840 841 842 843 844 845 846 847 848 849 850
    ref = ref8;
  } else {
    ref = CONVERT_TO_BYTEPTR(ref16);
  }
#else
  uint8_t ref[kOutputStride * kMaxDimension];
#endif

  // Populate ref and out with some random data
  ::libvpx_test::ACMRandom prng;
  for (int y = 0; y < Height(); ++y) {
    for (int x = 0; x < Width(); ++x) {
      uint16_t r;
#if CONFIG_VP9_HIGHBITDEPTH
851
      if (UUT_->use_highbd_ == 0 || UUT_->use_highbd_ == 8) {
852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886
        r = prng.Rand8Extremes();
      } else {
        r = prng.Rand16() & mask_;
      }
#else
      r = prng.Rand8Extremes();
#endif
      assign_val(out, y * kOutputStride + x, r);
      assign_val(ref, y * kOutputStride + x, r);
    }
  }

  for (int axis = 0; axis < 2; axis++) {
    int seed_val = 0;
    while (seed_val < 256) {
      for (int y = 0; y < 8; ++y) {
        for (int x = 0; x < 8; ++x) {
#if CONFIG_VP9_HIGHBITDEPTH
            assign_val(in, y * kOutputStride + x - SUBPEL_TAPS / 2 + 1,
                       ((seed_val >> (axis ? y : x)) & 1) * mask_);
#else
            assign_val(in, y * kOutputStride + x - SUBPEL_TAPS / 2 + 1,
                       ((seed_val >> (axis ? y : x)) & 1) * 255);
#endif
          if (axis) seed_val++;
        }
        if (axis)
          seed_val-= 8;
        else
          seed_val++;
      }
      if (axis) seed_val += 8;

      for (int filter_bank = 0; filter_bank < kNumFilterBanks; ++filter_bank) {
        const InterpKernel *filters =
887
            vp9_filter_kernels[static_cast<INTERP_FILTER>(filter_bank)];
888 889 890 891 892 893
        for (int filter_x = 0; filter_x < kNumFilters; ++filter_x) {
          for (int filter_y = 0; filter_y < kNumFilters; ++filter_y) {
            wrapper_filter_block2d_8_c(in, kInputStride,
                                       filters[filter_x], filters[filter_y],
                                       ref, kOutputStride,
                                       Width(), Height());
894
            if (filter_x && filter_y)
895 896 897 898 899 900 901 902 903
              ASM_REGISTER_STATE_CHECK(
                  UUT_->hv8_(in, kInputStride, out, kOutputStride,
                             filters[filter_x], 16, filters[filter_y], 16,
                             Width(), Height()));
            else if (filter_y)
              ASM_REGISTER_STATE_CHECK(
                  UUT_->v8_(in, kInputStride, out, kOutputStride,
                            kInvalidFilter, 16, filters[filter_y], 16,
                            Width(), Height()));
904
            else if (filter_x)
905 906 907 908
              ASM_REGISTER_STATE_CHECK(
                  UUT_->h8_(in, kInputStride, out, kOutputStride,
                            filters[filter_x], 16, kInvalidFilter, 16,
                            Width(), Height()));
909 910 911 912 913
            else
              ASM_REGISTER_STATE_CHECK(
                  UUT_->copy_(in, kInputStride, out, kOutputStride,
                              kInvalidFilter, 0, kInvalidFilter, 0,
                              Width(), Height()));
914 915 916 917 918 919 920 921 922 923 924 925 926 927 928

            for (int y = 0; y < Height(); ++y)
              for (int x = 0; x < Width(); ++x)
                ASSERT_EQ(lookup(ref, y * kOutputStride + x),
                          lookup(out, y * kOutputStride + x))
                    << "mismatch at (" << x << "," << y << "), "
                    << "filters (" << filter_bank << ","
                    << filter_x << "," << filter_y << ")";
          }
        }
      }
    }
  }
}

929 930 931 932 933
/* This test exercises that enough rows and columns are filtered with every
   possible initial fractional positions and scaling steps. */
TEST_P(ConvolveTest, CheckScalingFiltering) {
  uint8_t* const in = input();
  uint8_t* const out = output();
934
  const InterpKernel *const eighttap = vp9_filter_kernels[EIGHTTAP];
935 936 937 938 939 940

  SetConstantInput(127);

  for (int frac = 0; frac < 16; ++frac) {
    for (int step = 1; step <= 32; ++step) {
      /* Test the horizontal and vertical filters in combination. */
941 942 943 944
      ASM_REGISTER_STATE_CHECK(UUT_->shv8_(in, kInputStride, out, kOutputStride,
                                           eighttap[frac], step,
                                           eighttap[frac], step,
                                           Width(), Height()));
945 946 947 948 949

      CheckGuardBlocks();

      for (int y = 0; y < Height(); ++y) {
        for (int x = 0; x < Width(); ++x) {
950 951
          ASSERT_EQ(lookup(in, y * kInputStride + x),
                    lookup(out, y * kOutputStride + x))
952 953 954 955 956 957 958 959
              << "x == " << x << ", y == " << y
              << ", frac == " << frac << ", step == " << step;
        }
      }
    }
  }
}

960 961
using std::tr1::make_tuple;

962
#if CONFIG_VP9_HIGHBITDEPTH
963 964 965 966 967 968 969 970 971 972 973
#define WRAP(func, bd) \
void wrap_ ## func ## _ ## bd(const uint8_t *src, ptrdiff_t src_stride, \
                              uint8_t *dst, ptrdiff_t dst_stride, \
                              const int16_t *filter_x, \
                              int filter_x_stride, \
                              const int16_t *filter_y, \
                              int filter_y_stride, \
                              int w, int h) { \
  vpx_highbd_ ## func(src, src_stride, dst, dst_stride, filter_x, \
                      filter_x_stride, filter_y, filter_y_stride, \
                      w, h, bd); \
974
}
975
#if HAVE_SSE2 && ARCH_X86_64
976 977 978 979 980 981 982 983
#if CONFIG_USE_X86INC
WRAP(convolve_copy_sse2, 8)
WRAP(convolve_avg_sse2, 8)
WRAP(convolve_copy_sse2, 10)
WRAP(convolve_avg_sse2, 10)
WRAP(convolve_copy_sse2, 12)
WRAP(convolve_avg_sse2, 12)
#endif  // CONFIG_USE_X86INC
984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001
WRAP(convolve8_horiz_sse2, 8)
WRAP(convolve8_avg_horiz_sse2, 8)
WRAP(convolve8_vert_sse2, 8)
WRAP(convolve8_avg_vert_sse2, 8)
WRAP(convolve8_sse2, 8)
WRAP(convolve8_avg_sse2, 8)
WRAP(convolve8_horiz_sse2, 10)
WRAP(convolve8_avg_horiz_sse2, 10)
WRAP(convolve8_vert_sse2, 10)
WRAP(convolve8_avg_vert_sse2, 10)
WRAP(convolve8_sse2, 10)
WRAP(convolve8_avg_sse2, 10)
WRAP(convolve8_horiz_sse2, 12)
WRAP(convolve8_avg_horiz_sse2, 12)
WRAP(convolve8_vert_sse2, 12)
WRAP(convolve8_avg_vert_sse2, 12)
WRAP(convolve8_sse2, 12)
WRAP(convolve8_avg_sse2, 12)
1002 1003
#endif  // HAVE_SSE2 && ARCH_X86_64

1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028
WRAP(convolve_copy_c, 8)
WRAP(convolve_avg_c, 8)
WRAP(convolve8_horiz_c, 8)
WRAP(convolve8_avg_horiz_c, 8)
WRAP(convolve8_vert_c, 8)
WRAP(convolve8_avg_vert_c, 8)
WRAP(convolve8_c, 8)
WRAP(convolve8_avg_c, 8)
WRAP(convolve_copy_c, 10)
WRAP(convolve_avg_c, 10)
WRAP(convolve8_horiz_c, 10)
WRAP(convolve8_avg_horiz_c, 10)
WRAP(convolve8_vert_c, 10)
WRAP(convolve8_avg_vert_c, 10)
WRAP(convolve8_c, 10)
WRAP(convolve8_avg_c, 10)
WRAP(convolve_copy_c, 12)
WRAP(convolve_avg_c, 12)
WRAP(convolve8_horiz_c, 12)
WRAP(convolve8_avg_horiz_c, 12)
WRAP(convolve8_vert_c, 12)
WRAP(convolve8_avg_vert_c, 12)
WRAP(convolve8_c, 12)
WRAP(convolve8_avg_c, 12)
#undef WRAP
1029 1030

const ConvolveFunctions convolve8_c(
1031
    wrap_convolve_copy_c_8, wrap_convolve_avg_c_8,
1032 1033
    wrap_convolve8_horiz_c_8, wrap_convolve8_avg_horiz_c_8,
    wrap_convolve8_vert_c_8, wrap_convolve8_avg_vert_c_8,
1034 1035 1036
    wrap_convolve8_c_8, wrap_convolve8_avg_c_8,
    wrap_convolve8_horiz_c_8, wrap_convolve8_avg_horiz_c_8,
    wrap_convolve8_vert_c_8, wrap_convolve8_avg_vert_c_8,
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052
    wrap_convolve8_c_8, wrap_convolve8_avg_c_8, 8);
INSTANTIATE_TEST_CASE_P(C_8, ConvolveTest, ::testing::Values(
    make_tuple(4, 4, &convolve8_c),
    make_tuple(8, 4, &convolve8_c),
    make_tuple(4, 8, &convolve8_c),
    make_tuple(8, 8, &convolve8_c),
    make_tuple(16, 8, &convolve8_c),
    make_tuple(8, 16, &convolve8_c),
    make_tuple(16, 16, &convolve8_c),
    make_tuple(32, 16, &convolve8_c),
    make_tuple(16, 32, &convolve8_c),
    make_tuple(32, 32, &convolve8_c),
    make_tuple(64, 32, &convolve8_c),
    make_tuple(32, 64, &convolve8_c),
    make_tuple(64, 64, &convolve8_c)));
const ConvolveFunctions convolve10_c(
1053
    wrap_convolve_copy_c_10, wrap_convolve_avg_c_10,
1054 1055
    wrap_convolve8_horiz_c_10, wrap_convolve8_avg_horiz_c_10,
    wrap_convolve8_vert_c_10, wrap_convolve8_avg_vert_c_10,
1056 1057 1058
    wrap_convolve8_c_10, wrap_convolve8_avg_c_10,
    wrap_convolve8_horiz_c_10, wrap_convolve8_avg_horiz_c_10,
    wrap_convolve8_vert_c_10, wrap_convolve8_avg_vert_c_10,
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074
    wrap_convolve8_c_10, wrap_convolve8_avg_c_10, 10);
INSTANTIATE_TEST_CASE_P(C_10, ConvolveTest, ::testing::Values(
    make_tuple(4, 4, &convolve10_c),
    make_tuple(8, 4, &convolve10_c),
    make_tuple(4, 8, &convolve10_c),
    make_tuple(8, 8, &convolve10_c),
    make_tuple(16, 8, &convolve10_c),
    make_tuple(8, 16, &convolve10_c),
    make_tuple(16, 16, &convolve10_c),
    make_tuple(32, 16, &convolve10_c),
    make_tuple(16, 32, &convolve10_c),
    make_tuple(32, 32, &convolve10_c),
    make_tuple(64, 32, &convolve10_c),
    make_tuple(32, 64, &convolve10_c),
    make_tuple(64, 64, &convolve10_c)));
const ConvolveFunctions convolve12_c(
1075
    wrap_convolve_copy_c_12, wrap_convolve_avg_c_12,
1076 1077
    wrap_convolve8_horiz_c_12, wrap_convolve8_avg_horiz_c_12,
    wrap_convolve8_vert_c_12, wrap_convolve8_avg_vert_c_12,
1078 1079 1080
    wrap_convolve8_c_12, wrap_convolve8_avg_c_12,
    wrap_convolve8_horiz_c_12, wrap_convolve8_avg_horiz_c_12,
    wrap_convolve8_vert_c_12, wrap_convolve8_avg_vert_c_12,
1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096
    wrap_convolve8_c_12, wrap_convolve8_avg_c_12, 12);
INSTANTIATE_TEST_CASE_P(C_12, ConvolveTest, ::testing::Values(
    make_tuple(4, 4, &convolve12_c),
    make_tuple(8, 4, &convolve12_c),
    make_tuple(4, 8, &convolve12_c),
    make_tuple(8, 8, &convolve12_c),
    make_tuple(16, 8, &convolve12_c),
    make_tuple(8, 16, &convolve12_c),
    make_tuple(16, 16, &convolve12_c),
    make_tuple(32, 16, &convolve12_c),
    make_tuple(16, 32, &convolve12_c),
    make_tuple(32, 32, &convolve12_c),
    make_tuple(64, 32, &convolve12_c),
    make_tuple(32, 64, &convolve12_c),
    make_tuple(64, 64, &convolve12_c)));

1097
#else
1098

1099
const ConvolveFunctions convolve8_c(
Zoe Liu's avatar
Zoe Liu committed
1100 1101 1102
    vpx_convolve_copy_c, vpx_convolve_avg_c,
    vpx_convolve8_horiz_c, vpx_convolve8_avg_horiz_c,
    vpx_convolve8_vert_c, vpx_convolve8_avg_vert_c,
1103 1104 1105 1106
    vpx_convolve8_c, vpx_convolve8_avg_c,
    vpx_scaled_horiz_c, vpx_scaled_avg_horiz_c,
    vpx_scaled_vert_c, vpx_scaled_avg_vert_c,
    vpx_scaled_2d_c, vpx_scaled_avg_2d_c, 0);
1107 1108 1109 1110

INSTANTIATE_TEST_CASE_P(C, ConvolveTest, ::testing::Values(
    make_tuple(4, 4, &convolve8_c),
    make_tuple(8, 4, &convolve8_c),
1111
    make_tuple(4, 8, &convolve8_c),
1112
    make_tuple(8, 8, &convolve8_c),
1113
    make_tuple(16, 8, &convolve8_c),
1114 1115 1116 1117 1118 1119 1120 1121
    make_tuple(8, 16, &convolve8_c),
    make_tuple(16, 16, &convolve8_c),
    make_tuple(32, 16, &convolve8_c),
    make_tuple(16, 32, &convolve8_c),
    make_tuple(32, 32, &convolve8_c),
    make_tuple(64, 32, &convolve8_c),
    make_tuple(32, 64, &convolve8_c),
    make_tuple(64, 64, &convolve8_c)));
1122
#endif
1123

1124 1125
#if HAVE_SSE2 && ARCH_X86_64
#if CONFIG_VP9_HIGHBITDEPTH
1126
const ConvolveFunctions convolve8_sse2(
1127 1128 1129
#if CONFIG_USE_X86INC
    wrap_convolve_copy_sse2_8, wrap_convolve_avg_sse2_8,
#else
1130
    wrap_convolve_copy_c_8, wrap_convolve_avg_c_8,
1131
#endif  // CONFIG_USE_X86INC
1132 1133
    wrap_convolve8_horiz_sse2_8, wrap_convolve8_avg_horiz_sse2_8,
    wrap_convolve8_vert_sse2_8, wrap_convolve8_avg_vert_sse2_8,
1134 1135 1136
    wrap_convolve8_sse2_8, wrap_convolve8_avg_sse2_8,
    wrap_convolve8_horiz_sse2_8, wrap_convolve8_avg_horiz_sse2_8,
    wrap_convolve8_vert_sse2_8, wrap_convolve8_avg_vert_sse2_8,
1137
    wrap_convolve8_sse2_8, wrap_convolve8_avg_sse2_8, 8);
1138
const ConvolveFunctions convolve10_sse2(
1139 1140 1141
#if CONFIG_USE_X86INC
    wrap_convolve_copy_sse2_10, wrap_convolve_avg_sse2_10,
#else
1142
    wrap_convolve_copy_c_10, wrap_convolve_avg_c_10,
1143
#endif  // CONFIG_USE_X86INC
1144 1145
    wrap_convolve8_horiz_sse2_10, wrap_convolve8_avg_horiz_sse2_10,
    wrap_convolve8_vert_sse2_10, wrap_convolve8_avg_vert_sse2_10,
1146 1147 1148
    wrap_convolve8_sse2_10, wrap_convolve8_avg_sse2_10,
    wrap_convolve8_horiz_sse2_10, wrap_convolve8_avg_horiz_sse2_10,
    wrap_convolve8_vert_sse2_10, wrap_convolve8_avg_vert_sse2_10,
1149 1150
    wrap_convolve8_sse2_10, wrap_convolve8_avg_sse2_10, 10);
const ConvolveFunctions convolve12_sse2(
1151 1152 1153
#if CONFIG_USE_X86INC
    wrap_convolve_copy_sse2_12, wrap_convolve_avg_sse2_12,
#else
1154
    wrap_convolve_copy_c_12, wrap_convolve_avg_c_12,
1155
#endif  // CONFIG_USE_X86INC
1156 1157
    wrap_convolve8_horiz_sse2_12, wrap_convolve8_avg_horiz_sse2_12,
    wrap_convolve8_vert_sse2_12, wrap_convolve8_avg_vert_sse2_12,
1158 1159 1160
    wrap_convolve8_sse2_12, wrap_convolve8_avg_sse2_12,
    wrap_convolve8_horiz_sse2_12, wrap_convolve8_avg_horiz_sse2_12,
    wrap_convolve8_vert_sse2_12, wrap_convolve8_avg_vert_sse2_12,
1161 1162
    wrap_convolve8_sse2_12, wrap_convolve8_avg_sse2_12, 12);
INSTANTIATE_TEST_CASE_P(SSE2, ConvolveTest, ::testing::Values(
1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174
    make_tuple(4, 4, &convolve8_sse2),
    make_tuple(8, 4, &convolve8_sse2),
    make_tuple(4, 8, &convolve8_sse2),
    make_tuple(8, 8, &convolve8_sse2),
    make_tuple(16, 8, &convolve8_sse2),
    make_tuple(8, 16, &convolve8_sse2),
    make_tuple(16, 16, &convolve8_sse2),
    make_tuple(32, 16, &convolve8_sse2),
    make_tuple(16, 32, &convolve8_sse2),
    make_tuple(32, 32, &convolve8_sse2),
    make_tuple(64, 32, &convolve8_sse2),
    make_tuple(32, 64, &convolve8_sse2),
1175
    make_tuple(64, 64, &convolve8_sse2),
1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187
    make_tuple(4, 4, &convolve10_sse2),
    make_tuple(8, 4, &convolve10_sse2),
    make_tuple(4, 8, &convolve10_sse2),
    make_tuple(8, 8, &convolve10_sse2),
    make_tuple(16, 8, &convolve10_sse2),
    make_tuple(8, 16, &convolve10_sse2),
    make_tuple(16, 16, &convolve10_sse2),
    make_tuple(32, 16, &convolve10_sse2),
    make_tuple(16, 32, &convolve10_sse2),
    make_tuple(32, 32, &convolve10_sse2),
    make_tuple(64, 32, &convolve10_sse2),
    make_tuple(32, 64, &convolve10_sse2),
1188
    make_tuple(64, 64, &convolve10_sse2),
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201
    make_tuple(4, 4, &convolve12_sse2),
    make_tuple(8, 4, &convolve12_sse2),
    make_tuple(4, 8, &convolve12_sse2),
    make_tuple(8, 8, &convolve12_sse2),
    make_tuple(16, 8, &convolve12_sse2),
    make_tuple(8, 16, &convolve12_sse2),
    make_tuple(16, 16, &convolve12_sse2),
    make_tuple(32, 16, &convolve12_sse2),
    make_tuple(16, 32, &convolve12_sse2),
    make_tuple(32, 32, &convolve12_sse2),
    make_tuple(64, 32, &convolve12_sse2),
    make_tuple(32, 64, &convolve12_sse2),
    make_tuple(64, 64, &convolve12_sse2)));
1202
#else
1203
const ConvolveFunctions convolve8_sse2(
Johann's avatar
Johann committed
1204
#if CONFIG_USE_X86INC
Zoe Liu's avatar
Zoe Liu committed
1205
    vpx_convolve_copy_sse2, vpx_convolve_avg_sse2,
Johann's avatar
Johann committed
1206
#else
Zoe Liu's avatar
Zoe Liu committed
1207
    vpx_convolve_copy_c, vpx_convolve_avg_c,
Johann's avatar
Johann committed
1208
#endif  // CONFIG_USE_X86INC
Zoe Liu's avatar
Zoe Liu committed
1209 1210
    vpx_convolve8_horiz_sse2, vpx_convolve8_avg_horiz_sse2,
    vpx_convolve8_vert_sse2, vpx_convolve8_avg_vert_sse2,
1211 1212 1213 1214
    vpx_convolve8_sse2, vpx_convolve8_avg_sse2,
    vpx_scaled_horiz_c, vpx_scaled_avg_horiz_c,
    vpx_scaled_vert_c, vpx_scaled_avg_vert_c,
    vpx_scaled_2d_c, vpx_scaled_avg_2d_c, 0);
1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229

INSTANTIATE_TEST_CASE_P(SSE2, ConvolveTest, ::testing::Values(
    make_tuple(4, 4, &convolve8_sse2),
    make_tuple(8, 4, &convolve8_sse2),
    make_tuple(4, 8, &convolve8_sse2),
    make_tuple(8, 8, &convolve8_sse2),
    make_tuple(16, 8, &convolve8_sse2),
    make_tuple(8, 16, &convolve8_sse2),
    make_tuple(16, 16, &convolve8_sse2),
    make_tuple(32, 16, &convolve8_sse2),
    make_tuple(16, 32, &convolve8_sse2),
    make_tuple(32, 32, &convolve8_sse2),
    make_tuple(64, 32, &convolve8_sse2),
    make_tuple(32, 64, &convolve8_sse2),
    make_tuple(64, 64, &convolve8_sse2)));
1230
#endif  // CONFIG_VP9_HIGHBITDEPTH
1231
#endif
1232

1233 1234
#if HAVE_SSSE3
const ConvolveFunctions convolve8_ssse3(
Zoe Liu's avatar
Zoe Liu committed
1235 1236 1237
    vpx_convolve_copy_c, vpx_convolve_avg_c,
    vpx_convolve8_horiz_ssse3, vpx_convolve8_avg_horiz_ssse3,
    vpx_convolve8_vert_ssse3, vpx_convolve8_avg_vert_ssse3,
1238 1239 1240 1241
    vpx_convolve8_ssse3, vpx_convolve8_avg_ssse3,
    vpx_scaled_horiz_c, vpx_scaled_avg_horiz_c,
    vpx_scaled_vert_c, vpx_scaled_avg_vert_c,
    vpx_scaled_2d_c, vpx_scaled_avg_2d_c, 0);
1242 1243 1244 1245

INSTANTIATE_TEST_CASE_P(SSSE3, ConvolveTest, ::testing::Values(
    make_tuple(4, 4, &convolve8_ssse3),
    make_tuple(8, 4, &convolve8_ssse3),
1246
    make_tuple(4, 8, &convolve8_ssse3),
1247
    make_tuple(8, 8, &convolve8_ssse3),
1248
    make_tuple(16, 8, &convolve8_ssse3),
1249 1250 1251 1252 1253 1254 1255 1256
    make_tuple(8, 16, &convolve8_ssse3),
    make_tuple(16, 16, &convolve8_ssse3),
    make_tuple(32, 16, &convolve8_ssse3),
    make_tuple(16, 32, &convolve8_ssse3),
    make_tuple(32, 32, &convolve8_ssse3),
    make_tuple(64, 32, &convolve8_ssse3),
    make_tuple(32, 64, &convolve8_ssse3),
    make_tuple(64, 64, &convolve8_ssse3)));
1257
#endif
1258

1259
#if HAVE_AVX2 && HAVE_SSSE3
1260
const ConvolveFunctions convolve8_avx2(
Zoe Liu's avatar
Zoe Liu committed
1261 1262 1263
    vpx_convolve_copy_c, vpx_convolve_avg_c,
    vpx_convolve8_horiz_avx2, vpx_convolve8_avg_horiz_ssse3,
    vpx_convolve8_vert_avx2, vpx_convolve8_avg_vert_ssse3,
1264 1265 1266 1267
    vpx_convolve8_avx2, vpx_convolve8_avg_ssse3,
    vpx_scaled_horiz_c, vpx_scaled_avg_horiz_c,
    vpx_scaled_vert_c, vpx_scaled_avg_vert_c,
    vpx_scaled_2d_c, vpx_scaled_avg_2d_c, 0);
1268 1269 1270 1271 1272 1273

INSTANTIATE_TEST_CASE_P(AVX2, ConvolveTest, ::testing::Values(
    make_tuple(4, 4, &convolve8_avx2),
    make_tuple(8, 4, &convolve8_avx2),
    make_tuple(4, 8, &convolve8_avx2),
    make_tuple(8, 8, &convolve8_avx2),
levytamar82's avatar
levytamar82 committed
1274
    make_tuple(8, 16, &convolve8_avx2),
1275 1276 1277 1278 1279 1280 1281 1282
    make_tuple(16, 8, &convolve8_avx2),
    make_tuple(16, 16, &convolve8_avx2),
    make_tuple(32, 16, &convolve8_avx2),
    make_tuple(16, 32, &convolve8_avx2),
    make_tuple(32, 32, &convolve8_avx2),
    make_tuple(64, 32, &convolve8_avx2),
    make_tuple(32, 64, &convolve8_avx2),
    make_tuple(64, 64, &convolve8_avx2)));
1283
#endif  // HAVE_AVX2 && HAVE_SSSE3
1284

1285
#if HAVE_NEON
1286
#if HAVE_NEON_ASM
1287
const ConvolveFunctions convolve8_neon(
Zoe Liu's avatar
Zoe Liu committed
1288 1289 1290
    vpx_convolve_copy_neon, vpx_convolve_avg_neon,
    vpx_convolve8_horiz_neon, vpx_convolve8_avg_horiz_neon,
    vpx_convolve8_vert_neon, vpx_convolve8_avg_vert_neon,
1291 1292 1293 1294
    vpx_convolve8_neon, vpx_convolve8_avg_neon,
    vpx_scaled_horiz_c, vpx_scaled_avg_horiz_c,
    vpx_scaled_vert_c, vpx_scaled_avg_vert_c,
    vpx_scaled_2d_c, vpx_scaled_avg_2d_c, 0);
1295 1296
#else  // HAVE_NEON
const ConvolveFunctions convolve8_neon(
Zoe Liu's avatar
Zoe Liu committed
1297 1298 1299
    vpx_convolve_copy_neon, vpx_convolve_avg_neon,
    vpx_convolve8_horiz_neon, vpx_convolve8_avg_horiz_neon,
    vpx_convolve8_vert_neon, vpx_convolve8_avg_vert_neon,
1300 1301 1302 1303
    vpx_convolve8_neon, vpx_convolve8_avg_neon,
    vpx_scaled_horiz_c, vpx_scaled_avg_horiz_c,
    vpx_scaled_vert_c, vpx_scaled_avg_vert_c,
    vpx_scaled_2d_c, vpx_scaled_avg_2d_c, 0);
1304
#endif  // HAVE_NEON_ASM
1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319

INSTANTIATE_TEST_CASE_P(NEON, ConvolveTest, ::testing::Values(
    make_tuple(4, 4, &convolve8_neon),
    make_tuple(8, 4, &convolve8_neon),
    make_tuple(4, 8, &convolve8_neon),
    make_tuple(8, 8, &convolve8_neon),
    make_tuple(16, 8, &convolve8_neon),
    make_tuple(8, 16, &convolve8_neon),
    make_tuple(16, 16, &convolve8_neon),
    make_tuple(32, 16, &convolve8_neon),
    make_tuple(16, 32, &convolve8_neon),
    make_tuple(32, 32, &convolve8_neon),
    make_tuple(64, 32, &convolve8_neon),
    make_tuple(32, 64, &convolve8_neon),
    make_tuple(64, 64, &convolve8_neon)));
1320
#endif  // HAVE_NEON
1321 1322 1323

#if HAVE_DSPR2
const ConvolveFunctions convolve8_dspr2(
Zoe Liu's avatar
Zoe Liu committed
1324 1325 1326
    vpx_convolve_copy_dspr2, vpx_convolve_avg_dspr2,
    vpx_convolve8_horiz_dspr2, vpx_convolve8_avg_horiz_dspr2,
    vpx_convolve8_vert_dspr2, vpx_convolve8_avg_vert_dspr2,
1327 1328 1329 1330
    vpx_convolve8_dspr2, vpx_convolve8_avg_dspr2,
    vpx_scaled_horiz_c, vpx_scaled_avg_horiz_c,
    vpx_scaled_vert_c, vpx_scaled_avg_vert_c,
    vpx_scaled_2d_c, vpx_scaled_avg_2d_c, 0);
1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346

INSTANTIATE_TEST_CASE_P(DSPR2, ConvolveTest, ::testing::Values(
    make_tuple(4, 4, &convolve8_dspr2),
    make_tuple(8, 4, &convolve8_dspr2),
    make_tuple(4, 8, &convolve8_dspr2),
    make_tuple(8, 8, &convolve8_dspr2),
    make_tuple(16, 8, &convolve8_dspr2),
    make_tuple(8, 16, &convolve8_dspr2),
    make_tuple(16, 16, &convolve8_dspr2),
    make_tuple(32, 16, &convolve8_dspr2),
    make_tuple(16, 32, &convolve8_dspr2),
    make_tuple(32, 32, &convolve8_dspr2),
    make_tuple(64, 32, &convolve8_dspr2),
    make_tuple(32, 64, &convolve8_dspr2),
    make_tuple(64, 64, &convolve8_dspr2)));
#endif
1347

1348
#if HAVE_MSA
1349
const ConvolveFunctions convolve8_msa(
Zoe Liu's avatar
Zoe Liu committed
1350 1351 1352
    vpx_convolve_copy_msa, vpx_convolve_avg_msa,
    vpx_convolve8_horiz_msa, vpx_convolve8_avg_horiz_msa,
    vpx_convolve8_vert_msa, vpx_convolve8_avg_vert_msa,
1353 1354 1355 1356
    vpx_convolve8_msa, vpx_convolve8_avg_msa,
    vpx_scaled_horiz_c, vpx_scaled_avg_horiz_c,
    vpx_scaled_vert_c, vpx_scaled_avg_vert_c,
    vpx_scaled_2d_c, vpx_scaled_avg_2d_c, 0);
1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372

INSTANTIATE_TEST_CASE_P(MSA, ConvolveTest, ::testing::Values(
    make_tuple(4, 4, &convolve8_msa),
    make_tuple(8, 4, &convolve8_msa),
    make_tuple(4, 8, &convolve8_msa),
    make_tuple(8, 8, &convolve8_msa),
    make_tuple(16, 8, &convolve8_msa),
    make_tuple(8, 16, &convolve8_msa),
    make_tuple(16, 16, &convolve8_msa),
    make_tuple(32, 16, &convolve8_msa),
    make_tuple(16, 32, &convolve8_msa),
    make_tuple(32, 32, &convolve8_msa),
    make_tuple(64, 32, &convolve8_msa),
    make_tuple(32, 64, &convolve8_msa),
    make_tuple(64, 64, &convolve8_msa)));
#endif  // HAVE_MSA
James Zern's avatar
James Zern committed
1373
}  // namespace