Commit f4fcfe30 authored by Yunqing Wang's avatar Yunqing Wang

Optimize variance functions

Added SSE2 version of variance functions for super blocks.

Change-Id: Ibeaae8771ca21c99d41dd74067574a51e97b412d
parent 90a7723f
...@@ -188,11 +188,11 @@ INSTANTIATE_TEST_CASE_P( ...@@ -188,11 +188,11 @@ INSTANTIATE_TEST_CASE_P(
#endif #endif
#if HAVE_SSE2 #if HAVE_SSE2
const vp9_variance_fn_t variance4x4_wmt = vp9_variance4x4_wmt; const vp9_variance_fn_t variance4x4_wmt = vp9_variance4x4_sse2;
const vp9_variance_fn_t variance8x8_wmt = vp9_variance8x8_wmt; const vp9_variance_fn_t variance8x8_wmt = vp9_variance8x8_sse2;
const vp9_variance_fn_t variance8x16_wmt = vp9_variance8x16_wmt; const vp9_variance_fn_t variance8x16_wmt = vp9_variance8x16_sse2;
const vp9_variance_fn_t variance16x8_wmt = vp9_variance16x8_wmt; const vp9_variance_fn_t variance16x8_wmt = vp9_variance16x8_sse2;
const vp9_variance_fn_t variance16x16_wmt = vp9_variance16x16_wmt; const vp9_variance_fn_t variance16x16_wmt = vp9_variance16x16_sse2;
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
SSE2, VP9VarianceTest, SSE2, VP9VarianceTest,
::testing::Values(make_tuple(4, 4, variance4x4_wmt), ::testing::Values(make_tuple(4, 4, variance4x4_wmt),
......
...@@ -236,53 +236,43 @@ if [ "$CONFIG_VP9_ENCODER" = "yes" ]; then ...@@ -236,53 +236,43 @@ if [ "$CONFIG_VP9_ENCODER" = "yes" ]; then
[ $arch = "x86_64" ] && mmx_x86_64=mmx && sse2_x86_64=sse2 [ $arch = "x86_64" ] && mmx_x86_64=mmx && sse2_x86_64=sse2
prototype unsigned int vp9_variance32x16 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse" prototype unsigned int vp9_variance32x16 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"
specialize vp9_variance32x16 specialize vp9_variance32x16 sse2
prototype unsigned int vp9_variance16x32 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse" prototype unsigned int vp9_variance16x32 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"
specialize vp9_variance16x32 specialize vp9_variance16x32 sse2
prototype unsigned int vp9_variance64x32 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse" prototype unsigned int vp9_variance64x32 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"
specialize vp9_variance64x32 specialize vp9_variance64x32 sse2
prototype unsigned int vp9_variance32x64 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse" prototype unsigned int vp9_variance32x64 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"
specialize vp9_variance32x64 specialize vp9_variance32x64 sse2
prototype unsigned int vp9_variance32x32 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse" prototype unsigned int vp9_variance32x32 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"
specialize vp9_variance32x32 specialize vp9_variance32x32 sse2
prototype unsigned int vp9_variance64x64 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse" prototype unsigned int vp9_variance64x64 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"
specialize vp9_variance64x64 specialize vp9_variance64x64 sse2
prototype unsigned int vp9_variance16x16 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse" prototype unsigned int vp9_variance16x16 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"
specialize vp9_variance16x16 mmx sse2 specialize vp9_variance16x16 mmx sse2
vp9_variance16x16_sse2=vp9_variance16x16_wmt
vp9_variance16x16_mmx=vp9_variance16x16_mmx
prototype unsigned int vp9_variance16x8 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse" prototype unsigned int vp9_variance16x8 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"
specialize vp9_variance16x8 mmx sse2 specialize vp9_variance16x8 mmx sse2
vp9_variance16x8_sse2=vp9_variance16x8_wmt
vp9_variance16x8_mmx=vp9_variance16x8_mmx
prototype unsigned int vp9_variance8x16 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse" prototype unsigned int vp9_variance8x16 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"
specialize vp9_variance8x16 mmx sse2 specialize vp9_variance8x16 mmx sse2
vp9_variance8x16_sse2=vp9_variance8x16_wmt
vp9_variance8x16_mmx=vp9_variance8x16_mmx
prototype unsigned int vp9_variance8x8 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse" prototype unsigned int vp9_variance8x8 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"
specialize vp9_variance8x8 mmx sse2 specialize vp9_variance8x8 mmx sse2
vp9_variance8x8_sse2=vp9_variance8x8_wmt
vp9_variance8x8_mmx=vp9_variance8x8_mmx
prototype unsigned int vp9_variance8x4 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse" prototype unsigned int vp9_variance8x4 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"
specialize vp9_variance8x4 specialize vp9_variance8x4 sse2
prototype unsigned int vp9_variance4x8 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse" prototype unsigned int vp9_variance4x8 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"
specialize vp9_variance4x8 specialize vp9_variance4x8 sse2
prototype unsigned int vp9_variance4x4 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse" prototype unsigned int vp9_variance4x4 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"
specialize vp9_variance4x4 mmx sse2 specialize vp9_variance4x4 mmx sse2
vp9_variance4x4_sse2=vp9_variance4x4_wmt
vp9_variance4x4_mmx=vp9_variance4x4_mmx
prototype unsigned int vp9_sub_pixel_variance64x64 "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse" prototype unsigned int vp9_sub_pixel_variance64x64 "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"
specialize vp9_sub_pixel_variance64x64 sse2 specialize vp9_sub_pixel_variance64x64 sse2
......
...@@ -139,7 +139,37 @@ void vp9_half_vert_variance16x_h_sse2 ...@@ -139,7 +139,37 @@ void vp9_half_vert_variance16x_h_sse2
DECLARE_ALIGNED(16, extern const short, vp9_bilinear_filters_mmx[16][8]); DECLARE_ALIGNED(16, extern const short, vp9_bilinear_filters_mmx[16][8]);
unsigned int vp9_variance4x4_wmt( typedef unsigned int (*get_var_sse2) (
const unsigned char *src_ptr,
int source_stride,
const unsigned char *ref_ptr,
int recon_stride,
unsigned int *SSE,
int *Sum
);
static void variance_sse2(const unsigned char *src_ptr, int source_stride,
const unsigned char *ref_ptr, int recon_stride,
int w, int h, unsigned int *sse, int *sum,
get_var_sse2 var_fn, int block_size) {
unsigned int sse0;
int sum0;
int i, j;
*sse = 0;
*sum = 0;
for (i = 0; i < h; i += block_size) {
for (j = 0; j < w; j += block_size) {
var_fn(src_ptr + source_stride * i + j, source_stride,
ref_ptr + recon_stride * i + j, recon_stride, &sse0, &sum0);
*sse += sse0;
*sum += sum0;
}
}
}
unsigned int vp9_variance4x4_sse2(
const unsigned char *src_ptr, const unsigned char *src_ptr,
int source_stride, int source_stride,
const unsigned char *ref_ptr, const unsigned char *ref_ptr,
...@@ -148,13 +178,41 @@ unsigned int vp9_variance4x4_wmt( ...@@ -148,13 +178,41 @@ unsigned int vp9_variance4x4_wmt(
unsigned int var; unsigned int var;
int avg; int avg;
vp9_get4x4var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg); variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 4, 4,
&var, &avg, vp9_get4x4var_mmx, 4);
*sse = var; *sse = var;
return (var - (((unsigned int)avg * avg) >> 4)); return (var - (((unsigned int)avg * avg) >> 4));
}
unsigned int vp9_variance8x4_sse2(const uint8_t *src_ptr,
int source_stride,
const uint8_t *ref_ptr,
int recon_stride,
unsigned int *sse) {
unsigned int var;
int avg;
variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 8, 4,
&var, &avg, vp9_get4x4var_mmx, 4);
*sse = var;
return (var - (((unsigned int)avg * avg) >> 5));
}
unsigned int vp9_variance4x8_sse2(const uint8_t *src_ptr,
int source_stride,
const uint8_t *ref_ptr,
int recon_stride,
unsigned int *sse) {
unsigned int var;
int avg;
variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 4, 8,
&var, &avg, vp9_get4x4var_mmx, 4);
*sse = var;
return (var - (((unsigned int)avg * avg) >> 5));
} }
unsigned int vp9_variance8x8_wmt unsigned int vp9_variance8x8_sse2
( (
const unsigned char *src_ptr, const unsigned char *src_ptr,
int source_stride, int source_stride,
...@@ -164,83 +222,157 @@ unsigned int vp9_variance8x8_wmt ...@@ -164,83 +222,157 @@ unsigned int vp9_variance8x8_wmt
unsigned int var; unsigned int var;
int avg; int avg;
vp9_get8x8var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg); variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 8, 8,
&var, &avg, vp9_get8x8var_sse2, 8);
*sse = var; *sse = var;
return (var - (((unsigned int)avg * avg) >> 6)); return (var - (((unsigned int)avg * avg) >> 6));
} }
unsigned int vp9_variance16x8_sse2
unsigned int vp9_variance16x16_wmt
( (
const unsigned char *src_ptr, const unsigned char *src_ptr,
int source_stride, int source_stride,
const unsigned char *ref_ptr, const unsigned char *ref_ptr,
int recon_stride, int recon_stride,
unsigned int *sse) { unsigned int *sse) {
unsigned int sse0; unsigned int var;
int sum0; int avg;
vp9_get16x16var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0); variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 16, 8,
*sse = sse0; &var, &avg, vp9_get8x8var_sse2, 8);
return (sse0 - (((unsigned int)sum0 * sum0) >> 8)); *sse = var;
return (var - (((unsigned int)avg * avg) >> 7));
} }
unsigned int vp9_mse16x16_wmt( unsigned int vp9_variance8x16_sse2
(
const unsigned char *src_ptr, const unsigned char *src_ptr,
int source_stride, int source_stride,
const unsigned char *ref_ptr, const unsigned char *ref_ptr,
int recon_stride, int recon_stride,
unsigned int *sse) { unsigned int *sse) {
unsigned int var;
int avg;
unsigned int sse0; variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 8, 16,
int sum0; &var, &avg, vp9_get8x8var_sse2, 8);
vp9_get16x16var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0); *sse = var;
*sse = sse0; return (var - (((unsigned int)avg * avg) >> 7));
return sse0;
} }
unsigned int vp9_variance16x16_sse2
unsigned int vp9_variance16x8_wmt
( (
const unsigned char *src_ptr, const unsigned char *src_ptr,
int source_stride, int source_stride,
const unsigned char *ref_ptr, const unsigned char *ref_ptr,
int recon_stride, int recon_stride,
unsigned int *sse) { unsigned int *sse) {
unsigned int sse0, sse1, var; unsigned int var;
int sum0, sum1, avg; int avg;
vp9_get8x8var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0);
vp9_get8x8var_sse2(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &sse1, &sum1);
var = sse0 + sse1; variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 16, 16,
avg = sum0 + sum1; &var, &avg, vp9_get16x16var_sse2, 16);
*sse = var; *sse = var;
return (var - (((unsigned int)avg * avg) >> 7)); return (var - (((unsigned int)avg * avg) >> 8));
} }
unsigned int vp9_variance8x16_wmt unsigned int vp9_mse16x16_wmt(
(
const unsigned char *src_ptr, const unsigned char *src_ptr,
int source_stride, int source_stride,
const unsigned char *ref_ptr, const unsigned char *ref_ptr,
int recon_stride, int recon_stride,
unsigned int *sse) { unsigned int *sse) {
unsigned int sse0, sse1, var;
int sum0, sum1, avg;
vp9_get8x8var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0); unsigned int sse0;
vp9_get8x8var_sse2(src_ptr + 8 * source_stride, source_stride, ref_ptr + 8 * recon_stride, recon_stride, &sse1, &sum1); int sum0;
vp9_get16x16var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &sse0,
&sum0);
*sse = sse0;
return sse0;
}
var = sse0 + sse1; unsigned int vp9_variance32x32_sse2(const uint8_t *src_ptr,
avg = sum0 + sum1; int source_stride,
const uint8_t *ref_ptr,
int recon_stride,
unsigned int *sse) {
unsigned int var;
int avg;
variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 32, 32,
&var, &avg, vp9_get16x16var_sse2, 16);
*sse = var; *sse = var;
return (var - (((unsigned int)avg * avg) >> 7)); return (var - (((int64_t)avg * avg) >> 10));
}
unsigned int vp9_variance32x16_sse2(const uint8_t *src_ptr,
int source_stride,
const uint8_t *ref_ptr,
int recon_stride,
unsigned int *sse) {
unsigned int var;
int avg;
variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 32, 16,
&var, &avg, vp9_get16x16var_sse2, 16);
*sse = var;
return (var - (((int64_t)avg * avg) >> 9));
}
unsigned int vp9_variance16x32_sse2(const uint8_t *src_ptr,
int source_stride,
const uint8_t *ref_ptr,
int recon_stride,
unsigned int *sse) {
unsigned int var;
int avg;
variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 16, 32,
&var, &avg, vp9_get16x16var_sse2, 16);
*sse = var;
return (var - (((int64_t)avg * avg) >> 9));
}
unsigned int vp9_variance64x64_sse2(const uint8_t *src_ptr,
int source_stride,
const uint8_t *ref_ptr,
int recon_stride,
unsigned int *sse) {
unsigned int var;
int avg;
variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 64, 64,
&var, &avg, vp9_get16x16var_sse2, 16);
*sse = var;
return (var - (((int64_t)avg * avg) >> 12));
}
unsigned int vp9_variance64x32_sse2(const uint8_t *src_ptr,
int source_stride,
const uint8_t *ref_ptr,
int recon_stride,
unsigned int *sse) {
unsigned int var;
int avg;
variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 64, 32,
&var, &avg, vp9_get16x16var_sse2, 16);
*sse = var;
return (var - (((int64_t)avg * avg) >> 11));
}
unsigned int vp9_variance32x64_sse2(const uint8_t *src_ptr,
int source_stride,
const uint8_t *ref_ptr,
int recon_stride,
unsigned int *sse) {
unsigned int var;
int avg;
variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 32, 64,
&var, &avg, vp9_get16x16var_sse2, 16);
*sse = var;
return (var - (((int64_t)avg * avg) >> 11));
} }
unsigned int vp9_sub_pixel_variance4x4_wmt unsigned int vp9_sub_pixel_variance4x4_wmt
......
...@@ -15,15 +15,6 @@ ...@@ -15,15 +15,6 @@
#define HALFNDX 8 #define HALFNDX 8
extern unsigned int vp9_get16x16var_sse2
(
const unsigned char *src_ptr,
int source_stride,
const unsigned char *ref_ptr,
int recon_stride,
unsigned int *SSE,
int *Sum
);
extern void vp9_half_horiz_vert_variance16x_h_sse2 extern void vp9_half_horiz_vert_variance16x_h_sse2
( (
const unsigned char *ref_ptr, const unsigned char *ref_ptr,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment