1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libvpx/vp9/encoder/x86/vp9_variance_mmx.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,154 @@ 1.4 +/* 1.5 + * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license 1.8 + * that can be found in the LICENSE file in the root of the source 1.9 + * tree. An additional intellectual property rights grant can be found 1.10 + * in the file PATENTS. All contributing project authors may 1.11 + * be found in the AUTHORS file in the root of the source tree. 1.12 + */ 1.13 + 1.14 +#include "./vpx_config.h" 1.15 +#include "vp9/encoder/vp9_variance.h" 1.16 +#include "vp9/common/vp9_pragmas.h" 1.17 +#include "vpx_ports/mem.h" 1.18 + 1.19 +extern unsigned int vp9_get_mb_ss_mmx(const int16_t *src_ptr); 1.20 +extern unsigned int vp9_get8x8var_mmx 1.21 +( 1.22 + const unsigned char *src_ptr, 1.23 + int source_stride, 1.24 + const unsigned char *ref_ptr, 1.25 + int recon_stride, 1.26 + unsigned int *SSE, 1.27 + int *Sum 1.28 +); 1.29 +extern unsigned int vp9_get4x4var_mmx 1.30 +( 1.31 + const unsigned char *src_ptr, 1.32 + int source_stride, 1.33 + const unsigned char *ref_ptr, 1.34 + int recon_stride, 1.35 + unsigned int *SSE, 1.36 + int *Sum 1.37 +); 1.38 + 1.39 +unsigned int vp9_variance4x4_mmx( 1.40 + const unsigned char *src_ptr, 1.41 + int source_stride, 1.42 + const unsigned char *ref_ptr, 1.43 + int recon_stride, 1.44 + unsigned int *sse) { 1.45 + unsigned int var; 1.46 + int avg; 1.47 + 1.48 + vp9_get4x4var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg); 1.49 + *sse = var; 1.50 + return (var - (((unsigned int)avg * avg) >> 4)); 1.51 +} 1.52 + 1.53 +unsigned int vp9_variance8x8_mmx( 1.54 + const unsigned char *src_ptr, 1.55 + int source_stride, 1.56 + const unsigned char *ref_ptr, 1.57 + int recon_stride, 1.58 + unsigned int *sse) { 1.59 + unsigned int var; 1.60 + int avg; 1.61 + 1.62 + vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg); 1.63 + *sse = var; 1.64 + 1.65 + return (var - (((unsigned int)avg * avg) >> 6)); 1.66 +} 1.67 + 1.68 +unsigned int vp9_mse16x16_mmx( 1.69 + const unsigned char *src_ptr, 1.70 + int source_stride, 1.71 + const unsigned char *ref_ptr, 1.72 + int recon_stride, 1.73 + unsigned int *sse) { 1.74 + unsigned int sse0, sse1, sse2, sse3, var; 1.75 + int sum0, sum1, sum2, sum3; 1.76 + 1.77 + 1.78 + vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, 1.79 + &sum0); 1.80 + vp9_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, 1.81 + &sse1, &sum1); 1.82 + vp9_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, 1.83 + ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2); 1.84 + vp9_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride, 1.85 + ref_ptr + 8 * recon_stride + 8, recon_stride, &sse3, &sum3); 1.86 + 1.87 + var = sse0 + sse1 + sse2 + sse3; 1.88 + *sse = var; 1.89 + return var; 1.90 +} 1.91 + 1.92 + 1.93 +unsigned int vp9_variance16x16_mmx( 1.94 + const unsigned char *src_ptr, 1.95 + int source_stride, 1.96 + const unsigned char *ref_ptr, 1.97 + int recon_stride, 1.98 + unsigned int *sse) { 1.99 + unsigned int sse0, sse1, sse2, sse3, var; 1.100 + int sum0, sum1, sum2, sum3, avg; 1.101 + 1.102 + vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, 1.103 + &sum0); 1.104 + vp9_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, 1.105 + &sse1, &sum1); 1.106 + vp9_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, 1.107 + ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2); 1.108 + vp9_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride, 1.109 + ref_ptr + 8 * recon_stride + 8, recon_stride, &sse3, &sum3); 1.110 + 1.111 + var = sse0 + sse1 + sse2 + sse3; 1.112 + avg = sum0 + sum1 + sum2 + sum3; 1.113 + *sse = var; 1.114 + return (var - (((unsigned int)avg * avg) >> 8)); 1.115 +} 1.116 + 1.117 +unsigned int vp9_variance16x8_mmx( 1.118 + const unsigned char *src_ptr, 1.119 + int source_stride, 1.120 + const unsigned char *ref_ptr, 1.121 + int recon_stride, 1.122 + unsigned int *sse) { 1.123 + unsigned int sse0, sse1, var; 1.124 + int sum0, sum1, avg; 1.125 + 1.126 + vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, 1.127 + &sum0); 1.128 + vp9_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, 1.129 + &sse1, &sum1); 1.130 + 1.131 + var = sse0 + sse1; 1.132 + avg = sum0 + sum1; 1.133 + *sse = var; 1.134 + return (var - (((unsigned int)avg * avg) >> 7)); 1.135 +} 1.136 + 1.137 + 1.138 +unsigned int vp9_variance8x16_mmx( 1.139 + const unsigned char *src_ptr, 1.140 + int source_stride, 1.141 + const unsigned char *ref_ptr, 1.142 + int recon_stride, 1.143 + unsigned int *sse) { 1.144 + unsigned int sse0, sse1, var; 1.145 + int sum0, sum1, avg; 1.146 + 1.147 + vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, 1.148 + &sum0); 1.149 + vp9_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, 1.150 + ref_ptr + 8 * recon_stride, recon_stride, &sse1, &sum1); 1.151 + 1.152 + var = sse0 + sse1; 1.153 + avg = sum0 + sum1; 1.154 + *sse = var; 1.155 + 1.156 + return (var - (((unsigned int)avg * avg) >> 7)); 1.157 +}