2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #include "./vpx_config.h"
12 #include "vp9/encoder/vp9_variance.h"
13 #include "vp9/common/vp9_pragmas.h"
14 #include "vpx_ports/mem.h"
16 extern unsigned int vp9_get8x8var_mmx
18 const unsigned char *src_ptr,
20 const unsigned char *ref_ptr,
25 extern unsigned int vp9_get4x4var_mmx
27 const unsigned char *src_ptr,
29 const unsigned char *ref_ptr,
35 unsigned int vp9_variance4x4_mmx(
36 const unsigned char *src_ptr,
38 const unsigned char *ref_ptr,
44 vp9_get4x4var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg);
46 return (var - (((unsigned int)avg * avg) >> 4));
49 unsigned int vp9_variance8x8_mmx(
50 const unsigned char *src_ptr,
52 const unsigned char *ref_ptr,
58 vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg);
61 return (var - (((unsigned int)avg * avg) >> 6));
64 unsigned int vp9_mse16x16_mmx(
65 const unsigned char *src_ptr,
67 const unsigned char *ref_ptr,
70 unsigned int sse0, sse1, sse2, sse3, var;
71 int sum0, sum1, sum2, sum3;
74 vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0,
76 vp9_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride,
78 vp9_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride,
79 ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2);
80 vp9_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride,
81 ref_ptr + 8 * recon_stride + 8, recon_stride, &sse3, &sum3);
83 var = sse0 + sse1 + sse2 + sse3;
89 unsigned int vp9_variance16x16_mmx(
90 const unsigned char *src_ptr,
92 const unsigned char *ref_ptr,
95 unsigned int sse0, sse1, sse2, sse3, var;
96 int sum0, sum1, sum2, sum3, avg;
98 vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0,
100 vp9_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride,
102 vp9_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride,
103 ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2);
104 vp9_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride,
105 ref_ptr + 8 * recon_stride + 8, recon_stride, &sse3, &sum3);
107 var = sse0 + sse1 + sse2 + sse3;
108 avg = sum0 + sum1 + sum2 + sum3;
110 return (var - (((unsigned int)avg * avg) >> 8));
113 unsigned int vp9_variance16x8_mmx(
114 const unsigned char *src_ptr,
116 const unsigned char *ref_ptr,
119 unsigned int sse0, sse1, var;
122 vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0,
124 vp9_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride,
130 return (var - (((unsigned int)avg * avg) >> 7));
134 unsigned int vp9_variance8x16_mmx(
135 const unsigned char *src_ptr,
137 const unsigned char *ref_ptr,
140 unsigned int sse0, sse1, var;
143 vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0,
145 vp9_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride,
146 ref_ptr + 8 * recon_stride, recon_stride, &sse1, &sum1);
152 return (var - (((unsigned int)avg * avg) >> 7));