2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
2013-10-04 23:15:06 +02:00
|
|
|
#include "./vpx_config.h"
|
2013-06-20 18:34:25 +02:00
|
|
|
|
2012-11-27 22:59:17 +01:00
|
|
|
#include "vp9/encoder/vp9_variance.h"
|
|
|
|
#include "vp9/common/vp9_pragmas.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
#include "vpx_ports/mem.h"
|
|
|
|
|
2012-10-30 20:58:42 +01:00
|
|
|
extern unsigned int vp9_get4x4var_mmx
|
2010-05-18 17:58:33 +02:00
|
|
|
(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int source_stride,
|
|
|
|
const unsigned char *ref_ptr,
|
|
|
|
int recon_stride,
|
|
|
|
unsigned int *SSE,
|
|
|
|
int *Sum
|
2010-05-18 17:58:33 +02:00
|
|
|
);
|
|
|
|
|
2012-10-30 20:58:42 +01:00
|
|
|
unsigned int vp9_get16x16var_sse2
|
2010-05-18 17:58:33 +02:00
|
|
|
(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int source_stride,
|
|
|
|
const unsigned char *ref_ptr,
|
|
|
|
int recon_stride,
|
|
|
|
unsigned int *SSE,
|
|
|
|
int *Sum
|
2010-05-18 17:58:33 +02:00
|
|
|
);
|
2012-10-30 20:58:42 +01:00
|
|
|
unsigned int vp9_get8x8var_sse2
|
2010-05-18 17:58:33 +02:00
|
|
|
(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int source_stride,
|
|
|
|
const unsigned char *ref_ptr,
|
|
|
|
int recon_stride,
|
|
|
|
unsigned int *SSE,
|
|
|
|
int *Sum
|
2010-05-18 17:58:33 +02:00
|
|
|
);
|
2012-10-30 20:58:42 +01:00
|
|
|
void vp9_half_horiz_vert_variance8x_h_sse2
|
2011-03-08 22:25:06 +01:00
|
|
|
(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *ref_ptr,
|
|
|
|
int ref_pixels_per_line,
|
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int src_pixels_per_line,
|
|
|
|
unsigned int Height,
|
|
|
|
int *sum,
|
|
|
|
unsigned int *sumsquared
|
2011-03-08 22:25:06 +01:00
|
|
|
);
|
2012-10-30 20:58:42 +01:00
|
|
|
void vp9_half_horiz_vert_variance16x_h_sse2
|
2010-05-18 17:58:33 +02:00
|
|
|
(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *ref_ptr,
|
|
|
|
int ref_pixels_per_line,
|
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int src_pixels_per_line,
|
|
|
|
unsigned int Height,
|
|
|
|
int *sum,
|
|
|
|
unsigned int *sumsquared
|
2010-05-18 17:58:33 +02:00
|
|
|
);
|
2012-10-30 20:58:42 +01:00
|
|
|
void vp9_half_horiz_variance8x_h_sse2
|
2011-03-08 22:25:06 +01:00
|
|
|
(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *ref_ptr,
|
|
|
|
int ref_pixels_per_line,
|
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int src_pixels_per_line,
|
|
|
|
unsigned int Height,
|
|
|
|
int *sum,
|
|
|
|
unsigned int *sumsquared
|
2011-03-08 22:25:06 +01:00
|
|
|
);
|
2012-10-30 20:58:42 +01:00
|
|
|
void vp9_half_horiz_variance16x_h_sse2
|
2010-05-18 17:58:33 +02:00
|
|
|
(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *ref_ptr,
|
|
|
|
int ref_pixels_per_line,
|
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int src_pixels_per_line,
|
|
|
|
unsigned int Height,
|
|
|
|
int *sum,
|
|
|
|
unsigned int *sumsquared
|
2010-05-18 17:58:33 +02:00
|
|
|
);
|
2012-10-30 20:58:42 +01:00
|
|
|
void vp9_half_vert_variance8x_h_sse2
|
2011-03-08 22:25:06 +01:00
|
|
|
(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *ref_ptr,
|
|
|
|
int ref_pixels_per_line,
|
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int src_pixels_per_line,
|
|
|
|
unsigned int Height,
|
|
|
|
int *sum,
|
|
|
|
unsigned int *sumsquared
|
2011-03-08 22:25:06 +01:00
|
|
|
);
|
2012-10-30 20:58:42 +01:00
|
|
|
void vp9_half_vert_variance16x_h_sse2
|
2010-05-18 17:58:33 +02:00
|
|
|
(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *ref_ptr,
|
|
|
|
int ref_pixels_per_line,
|
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int src_pixels_per_line,
|
|
|
|
unsigned int Height,
|
|
|
|
int *sum,
|
|
|
|
unsigned int *sumsquared
|
2010-05-18 17:58:33 +02:00
|
|
|
);
|
|
|
|
|
2013-05-22 18:07:30 +02:00
|
|
|
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(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int source_stride,
|
|
|
|
const unsigned char *ref_ptr,
|
|
|
|
int recon_stride,
|
|
|
|
unsigned int *sse) {
|
|
|
|
unsigned int var;
|
|
|
|
int avg;
|
|
|
|
|
2013-05-22 18:07:30 +02:00
|
|
|
variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 4, 4,
|
|
|
|
&var, &avg, vp9_get4x4var_mmx, 4);
|
2012-07-14 00:21:29 +02:00
|
|
|
*sse = var;
|
2012-11-07 01:58:11 +01:00
|
|
|
return (var - (((unsigned int)avg * avg) >> 4));
|
2013-05-22 18:07:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-05-22 18:07:30 +02:00
|
|
|
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));
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2013-05-22 18:07:30 +02:00
|
|
|
unsigned int vp9_variance8x8_sse2
|
2010-05-18 17:58:33 +02:00
|
|
|
(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int source_stride,
|
|
|
|
const unsigned char *ref_ptr,
|
|
|
|
int recon_stride,
|
|
|
|
unsigned int *sse) {
|
|
|
|
unsigned int var;
|
|
|
|
int avg;
|
|
|
|
|
2013-05-22 18:07:30 +02:00
|
|
|
variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 8, 8,
|
|
|
|
&var, &avg, vp9_get8x8var_sse2, 8);
|
2012-07-14 00:21:29 +02:00
|
|
|
*sse = var;
|
2012-11-07 01:58:11 +01:00
|
|
|
return (var - (((unsigned int)avg * avg) >> 6));
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2013-05-22 18:07:30 +02:00
|
|
|
unsigned int vp9_variance16x8_sse2
|
2010-05-18 17:58:33 +02:00
|
|
|
(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int source_stride,
|
|
|
|
const unsigned char *ref_ptr,
|
|
|
|
int recon_stride,
|
|
|
|
unsigned int *sse) {
|
2013-05-22 18:07:30 +02:00
|
|
|
unsigned int var;
|
|
|
|
int avg;
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2013-05-22 18:07:30 +02:00
|
|
|
variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 16, 8,
|
|
|
|
&var, &avg, vp9_get8x8var_sse2, 8);
|
|
|
|
*sse = var;
|
|
|
|
return (var - (((unsigned int)avg * avg) >> 7));
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2013-02-06 20:20:59 +01:00
|
|
|
|
2013-05-22 18:07:30 +02:00
|
|
|
unsigned int vp9_variance8x16_sse2
|
|
|
|
(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int source_stride,
|
|
|
|
const unsigned char *ref_ptr,
|
|
|
|
int recon_stride,
|
|
|
|
unsigned int *sse) {
|
2013-05-22 18:07:30 +02:00
|
|
|
unsigned int var;
|
|
|
|
int avg;
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2013-05-22 18:07:30 +02:00
|
|
|
variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 8, 16,
|
|
|
|
&var, &avg, vp9_get8x8var_sse2, 8);
|
|
|
|
*sse = var;
|
|
|
|
return (var - (((unsigned int)avg * avg) >> 7));
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2013-05-22 18:07:30 +02:00
|
|
|
unsigned int vp9_variance16x16_sse2
|
2010-05-18 17:58:33 +02:00
|
|
|
(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int source_stride,
|
|
|
|
const unsigned char *ref_ptr,
|
|
|
|
int recon_stride,
|
|
|
|
unsigned int *sse) {
|
2013-05-22 18:07:30 +02:00
|
|
|
unsigned int var;
|
|
|
|
int avg;
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2013-05-22 18:07:30 +02:00
|
|
|
variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 16, 16,
|
|
|
|
&var, &avg, vp9_get16x16var_sse2, 16);
|
2012-07-14 00:21:29 +02:00
|
|
|
*sse = var;
|
2013-05-22 18:07:30 +02:00
|
|
|
return (var - (((unsigned int)avg * avg) >> 8));
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2013-08-06 17:25:10 +02:00
|
|
|
unsigned int vp9_mse16x16_sse2(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int source_stride,
|
|
|
|
const unsigned char *ref_ptr,
|
|
|
|
int recon_stride,
|
|
|
|
unsigned int *sse) {
|
2013-05-22 18:07:30 +02:00
|
|
|
unsigned int sse0;
|
|
|
|
int sum0;
|
|
|
|
vp9_get16x16var_sse2(src_ptr, source_stride, ref_ptr, recon_stride, &sse0,
|
|
|
|
&sum0);
|
|
|
|
*sse = sse0;
|
|
|
|
return sse0;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int vp9_variance32x32_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;
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2013-05-22 18:07:30 +02:00
|
|
|
variance_sse2(src_ptr, source_stride, ref_ptr, recon_stride, 32, 32,
|
|
|
|
&var, &avg, vp9_get16x16var_sse2, 16);
|
2012-07-14 00:21:29 +02:00
|
|
|
*sse = var;
|
2013-05-22 18:07:30 +02:00
|
|
|
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;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-05-22 18:07:30 +02:00
|
|
|
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));
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2013-06-21 00:59:48 +02:00
|
|
|
#define DECL(w, opt) \
|
|
|
|
int vp9_sub_pixel_variance##w##xh_##opt(const uint8_t *src, \
|
|
|
|
ptrdiff_t src_stride, \
|
|
|
|
int x_offset, int y_offset, \
|
|
|
|
const uint8_t *dst, \
|
|
|
|
ptrdiff_t dst_stride, \
|
|
|
|
int height, unsigned int *sse)
|
2013-06-20 18:34:25 +02:00
|
|
|
#define DECLS(opt1, opt2) \
|
2013-06-21 00:59:48 +02:00
|
|
|
DECL(4, opt2); \
|
|
|
|
DECL(8, opt1); \
|
|
|
|
DECL(16, opt1)
|
2013-06-20 18:34:25 +02:00
|
|
|
|
|
|
|
DECLS(sse2, sse);
|
|
|
|
DECLS(ssse3, ssse3);
|
|
|
|
#undef DECLS
|
2013-06-21 00:59:48 +02:00
|
|
|
#undef DECL
|
2013-06-20 18:34:25 +02:00
|
|
|
|
|
|
|
#define FN(w, h, wf, wlog2, hlog2, opt, cast) \
|
|
|
|
unsigned int vp9_sub_pixel_variance##w##x##h##_##opt(const uint8_t *src, \
|
|
|
|
int src_stride, \
|
|
|
|
int x_offset, \
|
|
|
|
int y_offset, \
|
|
|
|
const uint8_t *dst, \
|
|
|
|
int dst_stride, \
|
|
|
|
unsigned int *sse_ptr) { \
|
|
|
|
unsigned int sse; \
|
|
|
|
int se = vp9_sub_pixel_variance##wf##xh_##opt(src, src_stride, x_offset, \
|
|
|
|
y_offset, dst, dst_stride, \
|
|
|
|
h, &sse); \
|
|
|
|
if (w > wf) { \
|
|
|
|
unsigned int sse2; \
|
|
|
|
int se2 = vp9_sub_pixel_variance##wf##xh_##opt(src + 16, src_stride, \
|
|
|
|
x_offset, y_offset, \
|
|
|
|
dst + 16, dst_stride, \
|
|
|
|
h, &sse2); \
|
|
|
|
se += se2; \
|
|
|
|
sse += sse2; \
|
|
|
|
if (w > wf * 2) { \
|
|
|
|
se2 = vp9_sub_pixel_variance##wf##xh_##opt(src + 32, src_stride, \
|
|
|
|
x_offset, y_offset, \
|
|
|
|
dst + 32, dst_stride, \
|
|
|
|
h, &sse2); \
|
|
|
|
se += se2; \
|
|
|
|
sse += sse2; \
|
|
|
|
se2 = vp9_sub_pixel_variance##wf##xh_##opt(src + 48, src_stride, \
|
|
|
|
x_offset, y_offset, \
|
|
|
|
dst + 48, dst_stride, \
|
|
|
|
h, &sse2); \
|
|
|
|
se += se2; \
|
|
|
|
sse += sse2; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
*sse_ptr = sse; \
|
|
|
|
return sse - ((cast se * se) >> (wlog2 + hlog2)); \
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2013-06-20 18:34:25 +02:00
|
|
|
#define FNS(opt1, opt2) \
|
|
|
|
FN(64, 64, 16, 6, 6, opt1, (int64_t)); \
|
|
|
|
FN(64, 32, 16, 6, 5, opt1, (int64_t)); \
|
|
|
|
FN(32, 64, 16, 5, 6, opt1, (int64_t)); \
|
|
|
|
FN(32, 32, 16, 5, 5, opt1, (int64_t)); \
|
|
|
|
FN(32, 16, 16, 5, 4, opt1, (int64_t)); \
|
|
|
|
FN(16, 32, 16, 4, 5, opt1, (int64_t)); \
|
|
|
|
FN(16, 16, 16, 4, 4, opt1, (unsigned int)); \
|
2013-10-04 23:15:06 +02:00
|
|
|
FN(16, 8, 16, 4, 3, opt1, (unsigned int)); \
|
|
|
|
FN(8, 16, 8, 3, 4, opt1, (unsigned int)); \
|
|
|
|
FN(8, 8, 8, 3, 3, opt1, (unsigned int)); \
|
|
|
|
FN(8, 4, 8, 3, 2, opt1, (unsigned int)); \
|
|
|
|
FN(4, 8, 4, 2, 3, opt2, (unsigned int)); \
|
|
|
|
FN(4, 4, 4, 2, 2, opt2, (unsigned int))
|
2013-06-20 18:34:25 +02:00
|
|
|
|
|
|
|
FNS(sse2, sse);
|
|
|
|
FNS(ssse3, ssse3);
|
|
|
|
|
|
|
|
#undef FNS
|
|
|
|
#undef FN
|
2010-10-27 17:28:43 +02:00
|
|
|
|
2013-06-21 00:59:48 +02:00
|
|
|
#define DECL(w, opt) \
|
|
|
|
int vp9_sub_pixel_avg_variance##w##xh_##opt(const uint8_t *src, \
|
|
|
|
ptrdiff_t src_stride, \
|
|
|
|
int x_offset, int y_offset, \
|
|
|
|
const uint8_t *dst, \
|
|
|
|
ptrdiff_t dst_stride, \
|
|
|
|
const uint8_t *sec, \
|
|
|
|
ptrdiff_t sec_stride, \
|
|
|
|
int height, unsigned int *sse)
|
|
|
|
#define DECLS(opt1, opt2) \
|
|
|
|
DECL(4, opt2); \
|
|
|
|
DECL(8, opt1); \
|
|
|
|
DECL(16, opt1)
|
|
|
|
|
|
|
|
DECLS(sse2, sse);
|
|
|
|
DECLS(ssse3, ssse3);
|
|
|
|
#undef DECL
|
|
|
|
#undef DECLS
|
|
|
|
|
|
|
|
#define FN(w, h, wf, wlog2, hlog2, opt, cast) \
|
|
|
|
unsigned int vp9_sub_pixel_avg_variance##w##x##h##_##opt(const uint8_t *src, \
|
|
|
|
int src_stride, \
|
|
|
|
int x_offset, \
|
|
|
|
int y_offset, \
|
|
|
|
const uint8_t *dst, \
|
|
|
|
int dst_stride, \
|
|
|
|
unsigned int *sseptr, \
|
|
|
|
const uint8_t *sec) { \
|
|
|
|
unsigned int sse; \
|
|
|
|
int se = vp9_sub_pixel_avg_variance##wf##xh_##opt(src, src_stride, x_offset, \
|
|
|
|
y_offset, dst, dst_stride, \
|
|
|
|
sec, w, h, &sse); \
|
|
|
|
if (w > wf) { \
|
|
|
|
unsigned int sse2; \
|
|
|
|
int se2 = vp9_sub_pixel_avg_variance##wf##xh_##opt(src + 16, src_stride, \
|
|
|
|
x_offset, y_offset, \
|
|
|
|
dst + 16, dst_stride, \
|
|
|
|
sec + 16, w, h, &sse2); \
|
|
|
|
se += se2; \
|
|
|
|
sse += sse2; \
|
|
|
|
if (w > wf * 2) { \
|
|
|
|
se2 = vp9_sub_pixel_avg_variance##wf##xh_##opt(src + 32, src_stride, \
|
|
|
|
x_offset, y_offset, \
|
|
|
|
dst + 32, dst_stride, \
|
|
|
|
sec + 32, w, h, &sse2); \
|
|
|
|
se += se2; \
|
|
|
|
sse += sse2; \
|
|
|
|
se2 = vp9_sub_pixel_avg_variance##wf##xh_##opt(src + 48, src_stride, \
|
|
|
|
x_offset, y_offset, \
|
|
|
|
dst + 48, dst_stride, \
|
|
|
|
sec + 48, w, h, &sse2); \
|
|
|
|
se += se2; \
|
|
|
|
sse += sse2; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
*sseptr = sse; \
|
|
|
|
return sse - ((cast se * se) >> (wlog2 + hlog2)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define FNS(opt1, opt2) \
|
|
|
|
FN(64, 64, 16, 6, 6, opt1, (int64_t)); \
|
|
|
|
FN(64, 32, 16, 6, 5, opt1, (int64_t)); \
|
|
|
|
FN(32, 64, 16, 5, 6, opt1, (int64_t)); \
|
|
|
|
FN(32, 32, 16, 5, 5, opt1, (int64_t)); \
|
|
|
|
FN(32, 16, 16, 5, 4, opt1, (int64_t)); \
|
|
|
|
FN(16, 32, 16, 4, 5, opt1, (int64_t)); \
|
|
|
|
FN(16, 16, 16, 4, 4, opt1, (unsigned int)); \
|
2013-10-04 23:15:06 +02:00
|
|
|
FN(16, 8, 16, 4, 3, opt1, (unsigned int)); \
|
|
|
|
FN(8, 16, 8, 3, 4, opt1, (unsigned int)); \
|
|
|
|
FN(8, 8, 8, 3, 3, opt1, (unsigned int)); \
|
|
|
|
FN(8, 4, 8, 3, 2, opt1, (unsigned int)); \
|
|
|
|
FN(4, 8, 4, 2, 3, opt2, (unsigned int)); \
|
|
|
|
FN(4, 4, 4, 2, 2, opt2, (unsigned int))
|
2013-06-21 00:59:48 +02:00
|
|
|
|
|
|
|
FNS(sse2, sse);
|
|
|
|
FNS(ssse3, ssse3);
|
|
|
|
|
|
|
|
#undef FNS
|
|
|
|
#undef FN
|
|
|
|
|
2013-08-06 17:25:10 +02:00
|
|
|
unsigned int vp9_variance_halfpixvar16x16_h_sse2(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int src_pixels_per_line,
|
|
|
|
const unsigned char *dst_ptr,
|
|
|
|
int dst_pixels_per_line,
|
|
|
|
unsigned int *sse) {
|
|
|
|
int xsum0;
|
|
|
|
unsigned int xxsum0;
|
|
|
|
|
2012-10-30 20:58:42 +01:00
|
|
|
vp9_half_horiz_variance16x_h_sse2(
|
2012-07-14 00:21:29 +02:00
|
|
|
src_ptr, src_pixels_per_line,
|
|
|
|
dst_ptr, dst_pixels_per_line, 16,
|
|
|
|
&xsum0, &xxsum0);
|
|
|
|
|
|
|
|
*sse = xxsum0;
|
2012-11-07 01:58:11 +01:00
|
|
|
return (xxsum0 - (((unsigned int)xsum0 * xsum0) >> 8));
|
2010-10-27 17:28:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-06 17:25:10 +02:00
|
|
|
unsigned int vp9_variance_halfpixvar16x16_v_sse2(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int src_pixels_per_line,
|
|
|
|
const unsigned char *dst_ptr,
|
|
|
|
int dst_pixels_per_line,
|
|
|
|
unsigned int *sse) {
|
|
|
|
int xsum0;
|
|
|
|
unsigned int xxsum0;
|
2012-10-30 20:58:42 +01:00
|
|
|
vp9_half_vert_variance16x_h_sse2(
|
2012-07-14 00:21:29 +02:00
|
|
|
src_ptr, src_pixels_per_line,
|
|
|
|
dst_ptr, dst_pixels_per_line, 16,
|
|
|
|
&xsum0, &xxsum0);
|
|
|
|
|
|
|
|
*sse = xxsum0;
|
2012-11-07 01:58:11 +01:00
|
|
|
return (xxsum0 - (((unsigned int)xsum0 * xsum0) >> 8));
|
2010-10-27 17:28:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-06 17:25:10 +02:00
|
|
|
unsigned int vp9_variance_halfpixvar16x16_hv_sse2(
|
2012-07-14 00:21:29 +02:00
|
|
|
const unsigned char *src_ptr,
|
|
|
|
int src_pixels_per_line,
|
|
|
|
const unsigned char *dst_ptr,
|
|
|
|
int dst_pixels_per_line,
|
|
|
|
unsigned int *sse) {
|
|
|
|
int xsum0;
|
|
|
|
unsigned int xxsum0;
|
|
|
|
|
2012-10-30 20:58:42 +01:00
|
|
|
vp9_half_horiz_vert_variance16x_h_sse2(
|
2012-07-14 00:21:29 +02:00
|
|
|
src_ptr, src_pixels_per_line,
|
|
|
|
dst_ptr, dst_pixels_per_line, 16,
|
|
|
|
&xsum0, &xxsum0);
|
|
|
|
|
|
|
|
*sse = xxsum0;
|
2012-11-07 01:58:11 +01:00
|
|
|
return (xxsum0 - (((unsigned int)xsum0 * xsum0) >> 8));
|
2010-10-27 17:28:43 +02:00
|
|
|
}
|