Commit ebc2d34c authored by Geza Lore's avatar Geza Lore Committed by skal

Add SSE4.1 vpx_obmc_variance* implementations and cosmetics

Speedup for these functions: 4x
Also include some cosmetic changes to SAD functions

Change-Id: I344c32c795492507ae08742f52d035a13f583799
parent 6de0e97d
/*
* Copyright (c) 2016 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 "third_party/googletest/src/include/gtest/gtest.h"
#include "test/acm_random.h"
#include "test/function_equivalence_test.h"
#include "test/register_state_check.h"
#include "./vpx_config.h"
#include "./vpx_dsp_rtcd.h"
#include "vpx/vpx_integer.h"
#define MAX_SB_SQUARE (MAX_SB_SIZE * MAX_SB_SIZE)
using libvpx_test::ACMRandom;
using libvpx_test::FunctionEquivalenceTest;
namespace {
static const int kIterations = 1000;
static const int kMaskMax = 64;
typedef unsigned int (*ObmcVarF)(const uint8_t *pre, int pre_stride,
const int32_t *wsrc, const int32_t *mask,
unsigned int *sse);
typedef libvpx_test::FuncParam<ObmcVarF> TestFuncs;
////////////////////////////////////////////////////////////////////////////////
// 8 bit
////////////////////////////////////////////////////////////////////////////////
class ObmcVarianceTest : public FunctionEquivalenceTest<ObmcVarF> {};
TEST_P(ObmcVarianceTest, RandomValues) {
DECLARE_ALIGNED(32, uint8_t, pre[MAX_SB_SQUARE]);
DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
for (int iter = 0 ; iter < kIterations && !HasFatalFailure() ; ++iter) {
const int pre_stride = this->rng_(MAX_SB_SIZE + 1);
for (int i = 0 ; i < MAX_SB_SQUARE ; ++i) {
pre[i] = this->rng_.Rand8();
wsrc[i] = this->rng_.Rand8() * this->rng_(kMaskMax * kMaskMax + 1);
mask[i] = this->rng_(kMaskMax * kMaskMax + 1);
}
unsigned int ref_sse, tst_sse;
const unsigned int ref_res = params_.ref_func(pre, pre_stride, wsrc, mask,
&ref_sse);
unsigned int tst_res;
ASM_REGISTER_STATE_CHECK(
tst_res = params_.tst_func(pre, pre_stride, wsrc, mask, &tst_sse));
ASSERT_EQ(ref_res, tst_res);
ASSERT_EQ(ref_sse, tst_sse);
}
}
TEST_P(ObmcVarianceTest, ExtremeValues) {
DECLARE_ALIGNED(32, uint8_t, pre[MAX_SB_SQUARE]);
DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
for (int iter = 0 ; iter < MAX_SB_SIZE && !HasFatalFailure() ; ++iter) {
const int pre_stride = iter;
for (int i = 0 ; i < MAX_SB_SQUARE ; ++i) {
pre[i] = UINT8_MAX;
wsrc[i] = UINT8_MAX * kMaskMax * kMaskMax;
mask[i] = kMaskMax * kMaskMax;
}
unsigned int ref_sse, tst_sse;
const unsigned int ref_res = params_.ref_func(pre, pre_stride, wsrc, mask,
&ref_sse);
unsigned int tst_res;
ASM_REGISTER_STATE_CHECK(
tst_res = params_.tst_func(pre, pre_stride, wsrc, mask, &tst_sse));
ASSERT_EQ(ref_res, tst_res);
ASSERT_EQ(ref_sse, tst_sse);
}
}
#if HAVE_SSE4_1
const ObmcVarianceTest::ParamType sse4_functions[] = {
#if CONFIG_EXT_PARTITION
TestFuncs(vpx_obmc_variance128x128_c, vpx_obmc_variance128x128_sse4_1),
TestFuncs(vpx_obmc_variance128x64_c, vpx_obmc_variance128x64_sse4_1),
TestFuncs(vpx_obmc_variance64x128_c, vpx_obmc_variance64x128_sse4_1),
#endif // CONFIG_EXT_PARTITION
TestFuncs(vpx_obmc_variance64x64_c, vpx_obmc_variance64x64_sse4_1),
TestFuncs(vpx_obmc_variance64x32_c, vpx_obmc_variance64x32_sse4_1),
TestFuncs(vpx_obmc_variance32x64_c, vpx_obmc_variance32x64_sse4_1),
TestFuncs(vpx_obmc_variance32x32_c, vpx_obmc_variance32x32_sse4_1),
TestFuncs(vpx_obmc_variance32x16_c, vpx_obmc_variance32x16_sse4_1),
TestFuncs(vpx_obmc_variance16x32_c, vpx_obmc_variance16x32_sse4_1),
TestFuncs(vpx_obmc_variance16x16_c, vpx_obmc_variance16x16_sse4_1),
TestFuncs(vpx_obmc_variance16x8_c, vpx_obmc_variance16x8_sse4_1),
TestFuncs(vpx_obmc_variance8x16_c, vpx_obmc_variance8x16_sse4_1),
TestFuncs(vpx_obmc_variance8x8_c, vpx_obmc_variance8x8_sse4_1),
TestFuncs(vpx_obmc_variance8x4_c, vpx_obmc_variance8x4_sse4_1),
TestFuncs(vpx_obmc_variance4x8_c, vpx_obmc_variance4x8_sse4_1),
TestFuncs(vpx_obmc_variance4x4_c, vpx_obmc_variance4x4_sse4_1)
};
INSTANTIATE_TEST_CASE_P(SSE4_1_C_COMPARE, ObmcVarianceTest,
::testing::ValuesIn(sse4_functions));
#endif // HAVE_SSE4_1
////////////////////////////////////////////////////////////////////////////////
// High bit-depth
////////////////////////////////////////////////////////////////////////////////
#if CONFIG_VP9_HIGHBITDEPTH
class ObmcVarianceHBDTest : public FunctionEquivalenceTest<ObmcVarF> {}
TEST_P(ObmcVarianceHBDTest, RandomValues) {
DECLARE_ALIGNED(32, uint16_t, pre[MAX_SB_SQUARE]);
DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
for (int iter = 0 ; iter < kIterations && !HasFatalFailure() ; ++iter) {
const int pre_stride = this->rng_(MAX_SB_SIZE + 1);
for (int i = 0 ; i < MAX_SB_SQUARE ; ++i) {
pre[i] = this->rng_(1 << this->bit_depth);
wsrc[i] = this->rng_(1 << this->bit_depth) *
this->rng_(kMaskMax * kMaskMax + 1);
mask[i] = this->rng_(kMaskMax * kMaskMax + 1);
}
unsigned int ref_sse, tst_sse;
const unsigned int ref_res = ref_func_(CONVERT_TO_BYTEPTR(pre), pre_stride,
wsrc, mask, &ref_sse);
unsigned int tst_res;
ASM_REGISTER_STATE_CHECK(
tst_res = tst_func_(CONVERT_TO_BYTEPTR(pre),
pre_stride, wsrc, mask, &tst_sse));
ASSERT_EQ(ref_res, tst_res);
ASSERT_EQ(ref_sse, tst_sse);
}
}
TEST_P(ObmcVarianceHBDTest, ExtremeValues) {
DECLARE_ALIGNED(32, uint16_t, pre[MAX_SB_SQUARE]);
DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
for (int iter = 0 ; iter < MAX_SB_SIZE && !HasFatalFailure() ; ++iter) {
const int pre_stride = iter;
for (int i = 0 ; i < MAX_SB_SQUARE ; ++i) {
pre[i] = (1 << this->bit_depth) - 1;
wsrc[i] = ((1 << this->bit_depth) - 1) * kMaskMax * kMaskMax;
mask[i] = kMaskMax * kMaskMax;
}
unsigned int ref_sse, tst_sse;
const unsigned int ref_res = ref_func_(CONVERT_TO_BYTEPTR(pre), pre_stride,
wsrc, mask, &ref_sse);
unsigned int tst_res;
ASM_REGISTER_STATE_CHECK(
tst_res = tst_func_(CONVERT_TO_BYTEPTR(pre), pre_stride,
wsrc, mask, &tst_sse));
ASSERT_EQ(ref_res, tst_res);
ASSERT_EQ(ref_sse, tst_sse);
}
}
#if HAVE_SSE4_1
ObmcVarianceHBDTest::ParamType sse4_functions_hbd[] = {
#if CONFIG_EXT_PARTITION
TestFuncs(vpx_highbd_obmc_variance128x128_c,
vpx_highbd_obmc_variance128x128_sse4_1, 8),
TestFuncs(vpx_highbd_obmc_variance128x64_c,
vpx_highbd_obmc_variance128x64_sse4_1, 8),
TestFuncs(vpx_highbd_obmc_variance64x128_c,
vpx_highbd_obmc_variance64x128_sse4_1, 8),
#endif // CONFIG_EXT_PARTITION
TestFuncs(vpx_highbd_obmc_variance64x64_c,
vpx_highbd_obmc_variance64x64_sse4_1, 8),
TestFuncs(vpx_highbd_obmc_variance64x32_c,
vpx_highbd_obmc_variance64x32_sse4_1, 8),
TestFuncs(vpx_highbd_obmc_variance32x64_c,
vpx_highbd_obmc_variance32x64_sse4_1, 8),
TestFuncs(vpx_highbd_obmc_variance32x32_c,
vpx_highbd_obmc_variance32x32_sse4_1, 8),
TestFuncs(vpx_highbd_obmc_variance32x16_c,
vpx_highbd_obmc_variance32x16_sse4_1, 8),
TestFuncs(vpx_highbd_obmc_variance16x32_c,
vpx_highbd_obmc_variance16x32_sse4_1, 8),
TestFuncs(vpx_highbd_obmc_variance16x16_c,
vpx_highbd_obmc_variance16x16_sse4_1, 8),
TestFuncs(vpx_highbd_obmc_variance16x8_c,
vpx_highbd_obmc_variance16x8_sse4_1, 8),
TestFuncs(vpx_highbd_obmc_variance8x16_c,
vpx_highbd_obmc_variance8x16_sse4_1, 8),
TestFuncs(vpx_highbd_obmc_variance8x8_c,
vpx_highbd_obmc_variance8x8_sse4_1, 8),
TestFuncs(vpx_highbd_obmc_variance8x4_c,
vpx_highbd_obmc_variance8x4_sse4_1, 8),
TestFuncs(vpx_highbd_obmc_variance4x8_c,
vpx_highbd_obmc_variance4x8_sse4_1, 8),
TestFuncs(vpx_highbd_obmc_variance4x4_c,
vpx_highbd_obmc_variance4x4_sse4_1, 8),
#if CONFIG_EXT_PARTITION
TestFuncs(vpx_highbd_10_obmc_variance128x128_c,
vpx_highbd_10_obmc_variance128x128_sse4_1, 10),
TestFuncs(vpx_highbd_10_obmc_variance128x64_c,
vpx_highbd_10_obmc_variance128x64_sse4_1, 10),
TestFuncs(vpx_highbd_10_obmc_variance64x128_c,
vpx_highbd_10_obmc_variance64x128_sse4_1, 10),
#endif // CONFIG_EXT_PARTITION
TestFuncs(vpx_highbd_10_obmc_variance64x64_c,
vpx_highbd_10_obmc_variance64x64_sse4_1, 10),
TestFuncs(vpx_highbd_10_obmc_variance64x32_c,
vpx_highbd_10_obmc_variance64x32_sse4_1, 10),
TestFuncs(vpx_highbd_10_obmc_variance32x64_c,
vpx_highbd_10_obmc_variance32x64_sse4_1, 10),
TestFuncs(vpx_highbd_10_obmc_variance32x32_c,
vpx_highbd_10_obmc_variance32x32_sse4_1, 10),
TestFuncs(vpx_highbd_10_obmc_variance32x16_c,
vpx_highbd_10_obmc_variance32x16_sse4_1, 10),
TestFuncs(vpx_highbd_10_obmc_variance16x32_c,
vpx_highbd_10_obmc_variance16x32_sse4_1, 10),
TestFuncs(vpx_highbd_10_obmc_variance16x16_c,
vpx_highbd_10_obmc_variance16x16_sse4_1, 10),
TestFuncs(vpx_highbd_10_obmc_variance16x8_c,
vpx_highbd_10_obmc_variance16x8_sse4_1, 10),
TestFuncs(vpx_highbd_10_obmc_variance8x16_c,
vpx_highbd_10_obmc_variance8x16_sse4_1, 10),
TestFuncs(vpx_highbd_10_obmc_variance8x8_c,
vpx_highbd_10_obmc_variance8x8_sse4_1, 10),
TestFuncs(vpx_highbd_10_obmc_variance8x4_c,
vpx_highbd_10_obmc_variance8x4_sse4_1, 10),
TestFuncs(vpx_highbd_10_obmc_variance4x8_c,
vpx_highbd_10_obmc_variance4x8_sse4_1, 10),
TestFuncs(vpx_highbd_10_obmc_variance4x4_c,
vpx_highbd_10_obmc_variance4x4_sse4_1, 10),
#if CONFIG_EXT_PARTITION
TestFuncs(vpx_highbd_12_obmc_variance128x128_c,
vpx_highbd_12_obmc_variance128x128_sse4_1, 12),
TestFuncs(vpx_highbd_12_obmc_variance128x64_c,
vpx_highbd_12_obmc_variance128x64_sse4_1, 12),
TestFuncs(vpx_highbd_12_obmc_variance64x128_c,
vpx_highbd_12_obmc_variance64x128_sse4_1, 12),
#endif // CONFIG_EXT_PARTITION
TestFuncs(vpx_highbd_12_obmc_variance64x64_c,
vpx_highbd_12_obmc_variance64x64_sse4_1, 12),
TestFuncs(vpx_highbd_12_obmc_variance64x32_c,
vpx_highbd_12_obmc_variance64x32_sse4_1, 12),
TestFuncs(vpx_highbd_12_obmc_variance32x64_c,
vpx_highbd_12_obmc_variance32x64_sse4_1, 12),
TestFuncs(vpx_highbd_12_obmc_variance32x32_c,
vpx_highbd_12_obmc_variance32x32_sse4_1, 12),
TestFuncs(vpx_highbd_12_obmc_variance32x16_c,
vpx_highbd_12_obmc_variance32x16_sse4_1, 12),
TestFuncs(vpx_highbd_12_obmc_variance16x32_c,
vpx_highbd_12_obmc_variance16x32_sse4_1, 12),
TestFuncs(vpx_highbd_12_obmc_variance16x16_c,
vpx_highbd_12_obmc_variance16x16_sse4_1, 12),
TestFuncs(vpx_highbd_12_obmc_variance16x8_c,
vpx_highbd_12_obmc_variance16x8_sse4_1, 12),
TestFuncs(vpx_highbd_12_obmc_variance8x16_c,
vpx_highbd_12_obmc_variance8x16_sse4_1, 12),
TestFuncs(vpx_highbd_12_obmc_variance8x8_c,
vpx_highbd_12_obmc_variance8x8_sse4_1, 12),
TestFuncs(vpx_highbd_12_obmc_variance8x4_c,
vpx_highbd_12_obmc_variance8x4_sse4_1, 12),
TestFuncs(vpx_highbd_12_obmc_variance4x8_c,
vpx_highbd_12_obmc_variance4x8_sse4_1, 12),
TestFuncs(vpx_highbd_12_obmc_variance4x4_c,
vpx_highbd_12_obmc_variance4x4_sse4_1, 12)
};
INSTANTIATE_TEST_CASE_P(SSE4_1_C_COMPARE, ObmcVarianceHBDTest,
::testing::ValuesIn(sse4_functions_hbd));
#endif // HAVE_SSE4_1
#endif // CONFIG_VP9_HIGHBITDEPTH
} // namespace
......@@ -189,6 +189,7 @@ endif
ifeq ($(CONFIG_OBMC),yes)
LIBVPX_TEST_SRCS-$(CONFIG_VP10_ENCODER) += obmc_sad_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP10_ENCODER) += obmc_variance_test.cc
endif
ifeq ($(CONFIG_VP9_HIGHBITDEPTH),yes)
......
......@@ -1025,10 +1025,9 @@ HIGHBD_MASK_SUBPIX_VAR(128, 128)
#endif // CONFIG_VP10 && CONFIG_EXT_INTER
#if CONFIG_VP10 && CONFIG_OBMC
void obmc_variance(const uint8_t *a, int a_stride,
const int32_t *b,
const int32_t *m,
int w, int h, unsigned int *sse, int *sum) {
static INLINE void obmc_variance(const uint8_t *pre, int pre_stride,
const int32_t *wsrc, const int32_t *mask,
int w, int h, unsigned int *sse, int *sum) {
int i, j;
*sse = 0;
......@@ -1036,34 +1035,36 @@ void obmc_variance(const uint8_t *a, int a_stride,
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
int diff = ROUND_POWER_OF_TWO_SIGNED(b[j] - a[j] * m[j], 12);
int diff = ROUND_POWER_OF_TWO_SIGNED(wsrc[j] - pre[j] * mask[j], 12);
*sum += diff;
*sse += diff * diff;
}
a += a_stride;
b += w;
m += w;
pre += pre_stride;
wsrc += w;
mask += w;
}
}
#define OBMC_VAR(W, H) \
unsigned int vpx_obmc_variance##W##x##H##_c(const uint8_t *a, int a_stride, \
const int32_t *b, \
const int32_t *m, \
unsigned int *sse) { \
int sum; \
obmc_variance(a, a_stride, b, m, W, H, sse, &sum); \
return *sse - (((int64_t)sum * sum) / (W * H)); \
unsigned int vpx_obmc_variance##W##x##H##_c(const uint8_t *pre, \
int pre_stride, \
const int32_t *wsrc, \
const int32_t *mask, \
unsigned int *sse) { \
int sum; \
obmc_variance(pre, pre_stride, wsrc, mask, W, H, sse, &sum); \
return *sse - (((int64_t)sum * sum) / (W * H)); \
}
#define OBMC_SUBPIX_VAR(W, H) \
unsigned int vpx_obmc_sub_pixel_variance##W##x##H##_c( \
const uint8_t *pre, int pre_stride, \
int xoffset, int yoffset, \
const int32_t *wsrc, \
const int32_t *msk, \
unsigned int *sse) { \
unsigned int vpx_obmc_sub_pixel_variance##W##x##H##_c(const uint8_t *pre, \
int pre_stride, \
int xoffset, \
int yoffset, \
const int32_t *wsrc, \
const int32_t *mask, \
unsigned int *sse) { \
uint16_t fdata3[(H + 1) * W]; \
uint8_t temp2[H * W]; \
\
......@@ -1072,7 +1073,7 @@ unsigned int vpx_obmc_sub_pixel_variance##W##x##H##_c( \
var_filter_block2d_bil_second_pass(fdata3, temp2, W, W, H, W, \
bilinear_filters_2t[yoffset]); \
\
return vpx_obmc_variance##W##x##H##_c(temp2, W, wsrc, msk, sse); \
return vpx_obmc_variance##W##x##H##_c(temp2, W, wsrc, mask, sse); \
}
OBMC_VAR(4, 4)
......@@ -1126,86 +1127,94 @@ OBMC_SUBPIX_VAR(128, 128)
#endif // CONFIG_EXT_PARTITION
#if CONFIG_VP9_HIGHBITDEPTH
void highbd_obmc_variance64(const uint8_t *a8, int a_stride,
const int32_t *b, const int32_t *m,
int w, int h, uint64_t *sse, int64_t *sum) {
static INLINE void highbd_obmc_variance64(const uint8_t *pre8, int pre_stride,
const int32_t *wsrc,
const int32_t *mask,
int w, int h,
uint64_t *sse, int64_t *sum) {
int i, j;
uint16_t *a = CONVERT_TO_SHORTPTR(a8);
uint16_t *pre = CONVERT_TO_SHORTPTR(pre8);
*sse = 0;
*sum = 0;
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
int diff = ROUND_POWER_OF_TWO_SIGNED(b[j] - a[j] * m[j], 12);
int diff = ROUND_POWER_OF_TWO_SIGNED(wsrc[j] - pre[j] * mask[j], 12);
*sum += diff;
*sse += diff * diff;
}
a += a_stride;
b += w;
m += w;
pre += pre_stride;
wsrc += w;
mask += w;
}
}
void highbd_obmc_variance(const uint8_t *a8, int a_stride,
const int32_t *b, const int32_t *m,
int w, int h, unsigned int *sse, int *sum) {
static INLINE void highbd_obmc_variance(const uint8_t *pre8, int pre_stride,
const int32_t *wsrc,
const int32_t *mask,
int w, int h,
unsigned int *sse, int *sum) {
int64_t sum64;
uint64_t sse64;
highbd_obmc_variance64(a8, a_stride, b, m, w, h, &sse64, &sum64);
highbd_obmc_variance64(pre8, pre_stride, wsrc, mask, w, h, &sse64, &sum64);
*sum = (int)sum64;
*sse = (unsigned int)sse64;
}
void highbd_10_obmc_variance(const uint8_t *a8, int a_stride,
const int32_t *b, const int32_t *m,
int w, int h, unsigned int *sse, int *sum) {
static INLINE void highbd_10_obmc_variance(const uint8_t *pre8, int pre_stride,
const int32_t *wsrc,
const int32_t *mask,
int w, int h,
unsigned int *sse, int *sum) {
int64_t sum64;
uint64_t sse64;
highbd_obmc_variance64(a8, a_stride, b, m, w, h, &sse64, &sum64);
highbd_obmc_variance64(pre8, pre_stride, wsrc, mask, w, h, &sse64, &sum64);
*sum = (int)ROUND_POWER_OF_TWO(sum64, 2);
*sse = (unsigned int)ROUND_POWER_OF_TWO(sse64, 4);
}
void highbd_12_obmc_variance(const uint8_t *a8, int a_stride,
const int32_t *b, const int32_t *m,
int w, int h, unsigned int *sse, int *sum) {
static INLINE void highbd_12_obmc_variance(const uint8_t *pre8, int pre_stride,
const int32_t *wsrc,
const int32_t *mask,
int w, int h,
unsigned int *sse, int *sum) {
int64_t sum64;
uint64_t sse64;
highbd_obmc_variance64(a8, a_stride, b, m, w, h, &sse64, &sum64);
highbd_obmc_variance64(pre8, pre_stride, wsrc, mask, w, h, &sse64, &sum64);
*sum = (int)ROUND_POWER_OF_TWO(sum64, 4);
*sse = (unsigned int)ROUND_POWER_OF_TWO(sse64, 8);
}
#define HIGHBD_OBMC_VAR(W, H) \
unsigned int vpx_highbd_obmc_variance##W##x##H##_c(const uint8_t *a, \
int a_stride, \
const int32_t *b, \
const int32_t *m, \
unsigned int vpx_highbd_obmc_variance##W##x##H##_c(const uint8_t *pre, \
int pre_stride, \
const int32_t *wsrc, \
const int32_t *mask, \
unsigned int *sse) { \
int sum; \
highbd_obmc_variance(a, a_stride, b, m, W, H, sse, &sum); \
highbd_obmc_variance(pre, pre_stride, wsrc, mask, W, H, sse, &sum); \
return *sse - (((int64_t)sum * sum) / (W * H)); \
} \
\
unsigned int vpx_highbd_10_obmc_variance##W##x##H##_c(const uint8_t *a, \
int a_stride, \
const int32_t *b, \
const int32_t *m, \
unsigned int vpx_highbd_10_obmc_variance##W##x##H##_c(const uint8_t *pre, \
int pre_stride, \
const int32_t *wsrc, \
const int32_t *mask, \
unsigned int *sse) { \
int sum; \
highbd_10_obmc_variance(a, a_stride, b, m, W, H, sse, &sum); \
highbd_10_obmc_variance(pre, pre_stride, wsrc, mask, W, H, sse, &sum); \
return *sse - (((int64_t)sum * sum) / (W * H)); \
} \
\
unsigned int vpx_highbd_12_obmc_variance##W##x##H##_c(const uint8_t *a, \
int a_stride, \
const int32_t *b, \
const int32_t *m, \
unsigned int vpx_highbd_12_obmc_variance##W##x##H##_c(const uint8_t *pre, \
int pre_stride, \
const int32_t *wsrc, \
const int32_t *mask, \
unsigned int *sse) { \
int sum; \
highbd_12_obmc_variance(a, a_stride, b, m, W, H, sse, &sum); \
highbd_12_obmc_variance(pre, pre_stride, wsrc, mask, W, H, sse, &sum); \
return *sse - (((int64_t)sum * sum) / (W * H)); \
}
......@@ -1214,7 +1223,7 @@ unsigned int vpx_highbd_obmc_sub_pixel_variance##W##x##H##_c( \
const uint8_t *pre, int pre_stride, \
int xoffset, int yoffset, \
const int32_t *wsrc, \
const int32_t *msk, \
const int32_t *mask, \
unsigned int *sse) { \
uint16_t fdata3[(H + 1) * W]; \
uint16_t temp2[H * W]; \
......@@ -1226,14 +1235,14 @@ unsigned int vpx_highbd_obmc_sub_pixel_variance##W##x##H##_c( \
bilinear_filters_2t[yoffset]); \
\
return vpx_highbd_obmc_variance##W##x##H##_c(CONVERT_TO_BYTEPTR(temp2), \
W, wsrc, msk, sse); \
W, wsrc, mask, sse); \
} \
\
unsigned int vpx_highbd_10_obmc_sub_pixel_variance##W##x##H##_c( \
const uint8_t *pre, int pre_stride, \
int xoffset, int yoffset, \
const int32_t *wsrc, \
const int32_t *msk, \
const int32_t *mask, \
unsigned int *sse) { \
uint16_t fdata3[(H + 1) * W]; \
uint16_t temp2[H * W]; \
......@@ -1245,14 +1254,14 @@ unsigned int vpx_highbd_10_obmc_sub_pixel_variance##W##x##H##_c( \
bilinear_filters_2t[yoffset]); \
\
return vpx_highbd_10_obmc_variance##W##x##H##_c(CONVERT_TO_BYTEPTR(temp2), \
W, wsrc, msk, sse); \
W, wsrc, mask, sse); \
} \
\
unsigned int vpx_highbd_12_obmc_sub_pixel_variance##W##x##H##_c( \
const uint8_t *pre, int pre_stride, \
int xoffset, int yoffset, \
const int32_t *wsrc, \
const int32_t *msk, \
const int32_t *mask, \
unsigned int *sse) { \
uint16_t fdata3[(H + 1) * W]; \
uint16_t temp2[H * W]; \
......@@ -1264,7 +1273,7 @@ unsigned int vpx_highbd_12_obmc_sub_pixel_variance##W##x##H##_c( \
bilinear_filters_2t[yoffset]); \
\
return vpx_highbd_12_obmc_variance##W##x##H##_c(CONVERT_TO_BYTEPTR(temp2), \
W, wsrc, msk, sse); \
W, wsrc, mask, sse); \
}
HIGHBD_OBMC_VAR(4, 4)
......
......@@ -320,6 +320,7 @@ DSP_SRCS-$(HAVE_SSSE3) += x86/masked_variance_intrin_ssse3.c
endif #CONFIG_EXT_INTER
ifeq ($(CONFIG_OBMC),yes)
DSP_SRCS-$(HAVE_SSE4_1) += x86/obmc_sad_sse4.c
DSP_SRCS-$(HAVE_SSE4_1) += x86/obmc_variance_sse4.c
endif #CONFIG_OBMC
endif #CONFIG_VP10_ENCODER
......
......@@ -1413,9 +1413,9 @@ if (vpx_config("CONFIG_EXT_INTER") eq "yes") {
if (vpx_config("CONFIG_OBMC") eq "yes") {
foreach (@block_sizes) {
($w, $h) = @$_;
add_proto qw/unsigned int/, "vpx_obmc_variance${w}x${h}", "const uint8_t *pre_ptr, int pre_stride, const int32_t *wsrc_ptr, const int32_t *mask, unsigned int *sse";
add_proto qw/unsigned int/, "vpx_obmc_sub_pixel_variance${w}x${h}", "const uint8_t *pre_ptr, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc_ptr, const int32_t *mask, unsigned int *sse";
specialize "vpx_obmc_variance${w}x${h}";
add_proto qw/unsigned int/, "vpx_obmc_variance${w}x${h}", "const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse";
add_proto qw/unsigned int/, "vpx_obmc_sub_pixel_variance${w}x${h}", "const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse";
specialize "vpx_obmc_variance${w}x${h}", q/sse4_1/;
specialize "vpx_obmc_sub_pixel_variance${w}x${h}";
}
......@@ -1423,9 +1423,9 @@ if (vpx_config("CONFIG_OBMC") eq "yes") {
foreach $bd ("_", "_10_", "_12_") {
foreach (@block_sizes) {
($w, $h) = @$_;
add_proto qw/unsigned int/, "vpx_highbd${bd}obmc_variance${w}x${h}", "const uint8_t *pre_ptr, int pre_stride, const int32_t *wsrc_ptr, const int32_t *mask, unsigned int *sse";
add_proto qw/unsigned int/, "vpx_highbd${bd}obmc_sub_pixel_variance${w}x${h}", "const uint8_t *pre_ptr, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc_ptr, const int32_t *mask, unsigned int *sse";
specialize "vpx_highbd${bd}obmc_variance${w}x${h}";
add_proto qw/unsigned int/, "vpx_highbd${bd}obmc_variance${w}x${h}", "const uint8_t *pre, int pre_stride, const int32_t *wsrc, const int32_t *mask, unsigned int *sse";
add_proto qw/unsigned int/, "vpx_highbd${bd}obmc_sub_pixel_variance${w}x${h}", "const uint8_t *pre, int pre_stride, int xoffset, int yoffset, const int32_t *wsrc, const int32_t *mask, unsigned int *sse";
specialize "vpx_highbd${bd}obmc_variance${w}x${h}", qw/sse4_1/;
specialize "vpx_highbd${bd}obmc_sub_pixel_variance${w}x${h}";
}
}
......
......@@ -15,6 +15,7 @@
#include "vpx_ports/mem.h"
#include "vpx/vpx_integer.h"
#include "vpx_dsp/vpx_dsp_common.h"
#include "vpx_dsp/x86/synonyms.h"
////////////////////////////////////////////////////////////////////////////////
......@@ -52,8 +53,7 @@ static INLINE unsigned int obmc_sad_w4(const uint8_t *pre,
n += 4;
if (n % 4 == 0)
pre += pre_step;