1 /* 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 * 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. 9 */ 10 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" 15 16 extern unsigned int vp9_get_mb_ss_mmx(const int16_t *src_ptr); 17 extern unsigned int vp9_get8x8var_mmx 18 ( 19 const unsigned char *src_ptr, 20 int source_stride, 21 const unsigned char *ref_ptr, 22 int recon_stride, 23 unsigned int *SSE, 24 int *Sum 25 ); 26 extern unsigned int vp9_get4x4var_mmx 27 ( 28 const unsigned char *src_ptr, 29 int source_stride, 30 const unsigned char *ref_ptr, 31 int recon_stride, 32 unsigned int *SSE, 33 int *Sum 34 ); 35 36 unsigned int vp9_variance4x4_mmx( 37 const unsigned char *src_ptr, 38 int source_stride, 39 const unsigned char *ref_ptr, 40 int recon_stride, 41 unsigned int *sse) { 42 unsigned int var; 43 int avg; 44 45 vp9_get4x4var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg); 46 *sse = var; 47 return (var - (((unsigned int)avg * avg) >> 4)); 48 } 49 50 unsigned int vp9_variance8x8_mmx( 51 const unsigned char *src_ptr, 52 int source_stride, 53 const unsigned char *ref_ptr, 54 int recon_stride, 55 unsigned int *sse) { 56 unsigned int var; 57 int avg; 58 59 vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg); 60 *sse = var; 61 62 return (var - (((unsigned int)avg * avg) >> 6)); 63 } 64 65 unsigned int vp9_mse16x16_mmx( 66 const unsigned char *src_ptr, 67 int source_stride, 68 const unsigned char *ref_ptr, 69 int recon_stride, 70 unsigned int *sse) { 71 unsigned int sse0, sse1, sse2, sse3, var; 72 int sum0, sum1, sum2, sum3; 73 74 75 vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, 76 &sum0); 77 vp9_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, 78 &sse1, &sum1); 79 vp9_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, 80 ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2); 81 vp9_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride, 82 ref_ptr + 8 * recon_stride + 8, recon_stride, &sse3, &sum3); 83 84 var = sse0 + sse1 + sse2 + sse3; 85 *sse = var; 86 return var; 87 } 88 89 90 unsigned int vp9_variance16x16_mmx( 91 const unsigned char *src_ptr, 92 int source_stride, 93 const unsigned char *ref_ptr, 94 int recon_stride, 95 unsigned int *sse) { 96 unsigned int sse0, sse1, sse2, sse3, var; 97 int sum0, sum1, sum2, sum3, avg; 98 99 vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, 100 &sum0); 101 vp9_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, 102 &sse1, &sum1); 103 vp9_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, 104 ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2); 105 vp9_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride, 106 ref_ptr + 8 * recon_stride + 8, recon_stride, &sse3, &sum3); 107 108 var = sse0 + sse1 + sse2 + sse3; 109 avg = sum0 + sum1 + sum2 + sum3; 110 *sse = var; 111 return (var - (((unsigned int)avg * avg) >> 8)); 112 } 113 114 unsigned int vp9_variance16x8_mmx( 115 const unsigned char *src_ptr, 116 int source_stride, 117 const unsigned char *ref_ptr, 118 int recon_stride, 119 unsigned int *sse) { 120 unsigned int sse0, sse1, var; 121 int sum0, sum1, avg; 122 123 vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, 124 &sum0); 125 vp9_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, 126 &sse1, &sum1); 127 128 var = sse0 + sse1; 129 avg = sum0 + sum1; 130 *sse = var; 131 return (var - (((unsigned int)avg * avg) >> 7)); 132 } 133 134 135 unsigned int vp9_variance8x16_mmx( 136 const unsigned char *src_ptr, 137 int source_stride, 138 const unsigned char *ref_ptr, 139 int recon_stride, 140 unsigned int *sse) { 141 unsigned int sse0, sse1, var; 142 int sum0, sum1, avg; 143 144 vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, 145 &sum0); 146 vp9_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, 147 ref_ptr + 8 * recon_stride, recon_stride, &sse1, &sum1); 148 149 var = sse0 + sse1; 150 avg = sum0 + sum1; 151 *sse = var; 152 153 return (var - (((unsigned int)avg * avg) >> 7)); 154 } 155