
Cherry-Picked the following commits: 0defd8f Changed "WebM" to "AOMedia" & "webm" to "aomedia" 54e6676 Replace "VPx" by "AVx" 5082a36 Change "Vpx" to "Avx" 7df44f1 Replace "Vp9" w/ "Av1" 967f722 Remove kVp9CodecId 828f30c Change "Vp8" to "AOM" 030b5ff AUTHORS regenerated 2524cae Add ref-mv experimental flag 016762b Change copyright notice to AOMedia form 81e5526 Replace vp9 w/ av1 9b94565 Add missing files fa8ca9f Change "vp9" to "av1" ec838b7 Convert "vp8" to "aom" 80edfa0 Change "VP9" to "AV1" d1a11fb Change "vp8" to "aom" 7b58251 Point to WebM test data dd1a5c8 Replace "VP8" with "AOM" ff00fc0 Change "VPX" to "AOM" 01dee0b Change "vp10" to "av1" in source code cebe6f0 Convert "vpx" to "aom" 17b0567 rename vp10*.mk to av1_*.mk fe5f8a8 rename files vp10_* to av1_* Change-Id: I6fc3d18eb11fc171e46140c836ad5339cf6c9419
187 lines
5.4 KiB
C++
187 lines
5.4 KiB
C++
/*
|
|
* Copyright (c) 2014 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 <cmath>
|
|
#include <cstdlib>
|
|
#include <string>
|
|
|
|
#include "third_party/googletest/src/include/gtest/gtest.h"
|
|
|
|
#include "./aom_config.h"
|
|
#include "./aom_dsp_rtcd.h"
|
|
#include "aom_ports/mem.h"
|
|
#include "test/acm_random.h"
|
|
#include "test/clear_system_state.h"
|
|
#include "test/register_state_check.h"
|
|
#include "test/util.h"
|
|
#include "test/function_equivalence_test.h"
|
|
|
|
using libaom_test::ACMRandom;
|
|
using libaom_test::FunctionEquivalenceTest;
|
|
|
|
namespace {
|
|
const int kNumIterations = 10000;
|
|
|
|
static const int16_t kInt13Max = (1 << 12) - 1;
|
|
|
|
typedef uint64_t (*SSI16Func)(const int16_t *src, int stride, int size);
|
|
typedef libaom_test::FuncParam<SSI16Func> TestFuncs;
|
|
|
|
class SumSquaresTest : public ::testing::TestWithParam<TestFuncs> {
|
|
public:
|
|
virtual ~SumSquaresTest() {}
|
|
virtual void SetUp() { params_ = this->GetParam(); }
|
|
|
|
virtual void TearDown() { libaom_test::ClearSystemState(); }
|
|
|
|
protected:
|
|
TestFuncs params_;
|
|
};
|
|
|
|
TEST_P(SumSquaresTest, OperationCheck) {
|
|
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
|
DECLARE_ALIGNED(16, int16_t, src[256 * 256]);
|
|
|
|
int failed = 0;
|
|
|
|
const int msb = 11; // Up to 12 bit input
|
|
const int limit = 1 << (msb + 1);
|
|
|
|
for (int k = 0; k < kNumIterations; k++) {
|
|
int size = 4 << rnd(6); // Up to 128x128
|
|
int stride = 4 << rnd(7); // Up to 256 stride
|
|
while (stride < size) { // Make sure it's valid
|
|
stride = 4 << rnd(7);
|
|
}
|
|
|
|
for (int ii = 0; ii < size; ii++) {
|
|
for (int jj = 0; jj < size; jj++) {
|
|
src[ii * stride + jj] = rnd(2) ? rnd(limit) : -rnd(limit);
|
|
}
|
|
}
|
|
|
|
const uint64_t res_ref = params_.ref_func(src, stride, size);
|
|
uint64_t res_tst;
|
|
ASM_REGISTER_STATE_CHECK(res_tst = params_.tst_func(src, stride, size));
|
|
|
|
if (!failed) {
|
|
failed = res_ref != res_tst;
|
|
EXPECT_EQ(res_ref, res_tst)
|
|
<< "Error: Sum Squares Test"
|
|
<< " C output does not match optimized output.";
|
|
}
|
|
}
|
|
}
|
|
|
|
TEST_P(SumSquaresTest, ExtremeValues) {
|
|
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
|
DECLARE_ALIGNED(16, int16_t, src[256 * 256]);
|
|
|
|
int failed = 0;
|
|
|
|
const int msb = 11; // Up to 12 bit input
|
|
const int limit = 1 << (msb + 1);
|
|
|
|
for (int k = 0; k < kNumIterations; k++) {
|
|
int size = 4 << rnd(6); // Up to 128x128
|
|
int stride = 4 << rnd(7); // Up to 256 stride
|
|
while (stride < size) { // Make sure it's valid
|
|
stride = 4 << rnd(7);
|
|
}
|
|
|
|
int val = rnd(2) ? limit - 1 : -(limit - 1);
|
|
for (int ii = 0; ii < size; ii++) {
|
|
for (int jj = 0; jj < size; jj++) {
|
|
src[ii * stride + jj] = val;
|
|
}
|
|
}
|
|
|
|
const uint64_t res_ref = params_.ref_func(src, stride, size);
|
|
uint64_t res_tst;
|
|
ASM_REGISTER_STATE_CHECK(res_tst = params_.tst_func(src, stride, size));
|
|
|
|
if (!failed) {
|
|
failed = res_ref != res_tst;
|
|
EXPECT_EQ(res_ref, res_tst)
|
|
<< "Error: Sum Squares Test"
|
|
<< " C output does not match optimized output.";
|
|
}
|
|
}
|
|
}
|
|
|
|
#if HAVE_SSE2
|
|
|
|
INSTANTIATE_TEST_CASE_P(
|
|
SSE2, SumSquaresTest,
|
|
::testing::Values(TestFuncs(&aom_sum_squares_2d_i16_c,
|
|
&aom_sum_squares_2d_i16_sse2)));
|
|
|
|
#endif // HAVE_SSE2
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// 1D version
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
typedef uint64_t (*F1D)(const int16_t *src, uint32_t N);
|
|
typedef libaom_test::FuncParam<F1D> TestFuncs1D;
|
|
|
|
class SumSquares1DTest : public FunctionEquivalenceTest<F1D> {
|
|
protected:
|
|
static const int kIterations = 1000;
|
|
static const int kMaxSize = 256;
|
|
};
|
|
|
|
TEST_P(SumSquares1DTest, RandomValues) {
|
|
DECLARE_ALIGNED(16, int16_t, src[kMaxSize * kMaxSize]);
|
|
|
|
for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
|
|
for (int i = 0; i < kMaxSize * kMaxSize; ++i)
|
|
src[i] = rng_(kInt13Max * 2 + 1) - kInt13Max;
|
|
|
|
const int N = rng_(2) ? rng_(kMaxSize * kMaxSize + 1 - kMaxSize) + kMaxSize
|
|
: rng_(kMaxSize) + 1;
|
|
|
|
const uint64_t ref_res = params_.ref_func(src, N);
|
|
uint64_t tst_res;
|
|
ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(src, N));
|
|
|
|
ASSERT_EQ(ref_res, tst_res);
|
|
}
|
|
}
|
|
|
|
TEST_P(SumSquares1DTest, ExtremeValues) {
|
|
DECLARE_ALIGNED(16, int16_t, src[kMaxSize * kMaxSize]);
|
|
|
|
for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
|
|
if (rng_(2)) {
|
|
for (int i = 0; i < kMaxSize * kMaxSize; ++i) src[i] = kInt13Max;
|
|
} else {
|
|
for (int i = 0; i < kMaxSize * kMaxSize; ++i) src[i] = -kInt13Max;
|
|
}
|
|
|
|
const int N = rng_(2) ? rng_(kMaxSize * kMaxSize + 1 - kMaxSize) + kMaxSize
|
|
: rng_(kMaxSize) + 1;
|
|
|
|
const uint64_t ref_res = params_.ref_func(src, N);
|
|
uint64_t tst_res;
|
|
ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(src, N));
|
|
|
|
ASSERT_EQ(ref_res, tst_res);
|
|
}
|
|
}
|
|
|
|
#if HAVE_SSE2
|
|
INSTANTIATE_TEST_CASE_P(SSE2, SumSquares1DTest,
|
|
::testing::Values(TestFuncs1D(
|
|
aom_sum_squares_i16_c, aom_sum_squares_i16_sse2)));
|
|
|
|
#endif // HAVE_SSE2
|
|
} // namespace
|