aom: update libaom to 0ec86ac7ae1e32a7e70410fa4972a655ec3670a4

This commit is contained in:
Roy Tam 2019-02-22 21:52:01 +08:00
commit eb361970c5
438 changed files with 52661 additions and 21905 deletions

View file

@ -27,6 +27,10 @@
using libaom_test::ACMRandom;
using libaom_test::FunctionEquivalenceTest;
using ::testing::Combine;
using ::testing::Range;
using ::testing::Values;
using ::testing::ValuesIn;
namespace {
const int kNumIterations = 10000;
@ -225,4 +229,170 @@ INSTANTIATE_TEST_CASE_P(SSE2, SumSquares1DTest,
aom_sum_squares_i16_c, aom_sum_squares_i16_sse2)));
#endif // HAVE_SSE2
typedef int64_t (*sse_func)(const uint8_t *a, int a_stride, const uint8_t *b,
int b_stride, int width, int height);
typedef libaom_test::FuncParam<sse_func> TestSSEFuncs;
typedef ::testing::tuple<TestSSEFuncs, int> SSETestParam;
class SSETest : public ::testing::TestWithParam<SSETestParam> {
public:
virtual ~SSETest() {}
virtual void SetUp() {
params_ = GET_PARAM(0);
width_ = GET_PARAM(1);
isHbd_ = params_.ref_func == aom_highbd_sse_c;
rnd_.Reset(ACMRandom::DeterministicSeed());
src_ = reinterpret_cast<uint8_t *>(aom_memalign(32, 256 * 256 * 2));
ref_ = reinterpret_cast<uint8_t *>(aom_memalign(32, 256 * 256 * 2));
ASSERT_TRUE(src_ != NULL);
ASSERT_TRUE(ref_ != NULL);
}
virtual void TearDown() {
libaom_test::ClearSystemState();
aom_free(src_);
aom_free(ref_);
}
void RunTest(int isRandom, int width, int height, int run_times);
void GenRandomData(int width, int height, int stride) {
uint16_t *pSrc = (uint16_t *)src_;
uint16_t *pRef = (uint16_t *)ref_;
const int msb = 11; // Up to 12 bit input
const int limit = 1 << (msb + 1);
for (int ii = 0; ii < height; ii++) {
for (int jj = 0; jj < width; jj++) {
if (!isHbd_) {
src_[ii * stride + jj] = rnd_.Rand8();
ref_[ii * stride + jj] = rnd_.Rand8();
} else {
pSrc[ii * stride + jj] = rnd_(limit);
pRef[ii * stride + jj] = rnd_(limit);
}
}
}
}
void GenExtremeData(int width, int height, int stride, uint8_t *data,
int16_t val) {
uint16_t *pData = (uint16_t *)data;
for (int ii = 0; ii < height; ii++) {
for (int jj = 0; jj < width; jj++) {
if (!isHbd_) {
data[ii * stride + jj] = (uint8_t)val;
} else {
pData[ii * stride + jj] = val;
}
}
}
}
protected:
int isHbd_;
int width_;
TestSSEFuncs params_;
uint8_t *src_;
uint8_t *ref_;
ACMRandom rnd_;
};
void SSETest::RunTest(int isRandom, int width, int height, int run_times) {
int failed = 0;
aom_usec_timer ref_timer, test_timer;
for (int k = 0; k < 3; k++) {
int stride = 4 << rnd_(7); // Up to 256 stride
while (stride < width) { // Make sure it's valid
stride = 4 << rnd_(7);
}
if (isRandom) {
GenRandomData(width, height, stride);
} else {
const int msb = isHbd_ ? 12 : 8; // Up to 12 bit input
const int limit = (1 << msb) - 1;
if (k == 0) {
GenExtremeData(width, height, stride, src_, 0);
GenExtremeData(width, height, stride, ref_, limit);
} else {
GenExtremeData(width, height, stride, src_, limit);
GenExtremeData(width, height, stride, ref_, 0);
}
}
int64_t res_ref, res_tst;
uint8_t *pSrc = src_;
uint8_t *pRef = ref_;
if (isHbd_) {
pSrc = CONVERT_TO_BYTEPTR(src_);
pRef = CONVERT_TO_BYTEPTR(ref_);
}
res_ref = params_.ref_func(pSrc, stride, pRef, stride, width, height);
res_tst = params_.tst_func(pSrc, stride, pRef, stride, width, height);
if (run_times > 1) {
aom_usec_timer_start(&ref_timer);
for (int j = 0; j < run_times; j++) {
params_.ref_func(pSrc, stride, pRef, stride, width, height);
}
aom_usec_timer_mark(&ref_timer);
const int elapsed_time_c =
static_cast<int>(aom_usec_timer_elapsed(&ref_timer));
aom_usec_timer_start(&test_timer);
for (int j = 0; j < run_times; j++) {
params_.tst_func(pSrc, stride, pRef, stride, width, height);
}
aom_usec_timer_mark(&test_timer);
const int elapsed_time_simd =
static_cast<int>(aom_usec_timer_elapsed(&test_timer));
printf(
"c_time=%d \t simd_time=%d \t "
"gain=%d\n",
elapsed_time_c, elapsed_time_simd,
(elapsed_time_c / elapsed_time_simd));
} else {
if (!failed) {
failed = res_ref != res_tst;
EXPECT_EQ(res_ref, res_tst)
<< "Error:" << (isHbd_ ? "hbd " : " ") << k << " SSE Test ["
<< width << "x" << height
<< "] C output does not match optimized output.";
}
}
}
}
TEST_P(SSETest, OperationCheck) {
for (int height = 4; height <= 128; height += 4) {
RunTest(1, width_, height, 1); // GenRandomData
}
}
TEST_P(SSETest, ExtremeValues) {
for (int height = 4; height <= 128; height += 4) {
RunTest(0, width_, height, 1);
}
}
TEST_P(SSETest, DISABLED_Speed) {
for (int height = 4; height <= 128; height += 4) {
RunTest(1, width_, height, 100);
}
}
#if HAVE_SSE4_1
TestSSEFuncs sse_sse4[] = { TestSSEFuncs(&aom_sse_c, &aom_sse_sse4_1),
TestSSEFuncs(&aom_highbd_sse_c,
&aom_highbd_sse_sse4_1) };
INSTANTIATE_TEST_CASE_P(SSE4_1, SSETest,
Combine(ValuesIn(sse_sse4), Range(4, 129, 4)));
#endif // HAVE_SSE4_1
#if HAVE_AVX2
TestSSEFuncs sse_avx2[] = { TestSSEFuncs(&aom_sse_c, &aom_sse_avx2),
TestSSEFuncs(&aom_highbd_sse_c,
&aom_highbd_sse_avx2) };
INSTANTIATE_TEST_CASE_P(AVX2, SSETest,
Combine(ValuesIn(sse_avx2), Range(4, 129, 4)));
#endif // HAVE_AVX2
} // namespace