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