michael@0: /* michael@0: * Copyright (c) 2010 The WebM project authors. All Rights Reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: #include "./vpx_config.h" michael@0: #include "vp9/encoder/vp9_variance.h" michael@0: #include "vp9/common/vp9_pragmas.h" michael@0: #include "vpx_ports/mem.h" michael@0: michael@0: extern unsigned int vp9_get_mb_ss_mmx(const int16_t *src_ptr); michael@0: extern unsigned int vp9_get8x8var_mmx michael@0: ( michael@0: const unsigned char *src_ptr, michael@0: int source_stride, michael@0: const unsigned char *ref_ptr, michael@0: int recon_stride, michael@0: unsigned int *SSE, michael@0: int *Sum michael@0: ); michael@0: extern unsigned int vp9_get4x4var_mmx michael@0: ( michael@0: const unsigned char *src_ptr, michael@0: int source_stride, michael@0: const unsigned char *ref_ptr, michael@0: int recon_stride, michael@0: unsigned int *SSE, michael@0: int *Sum michael@0: ); michael@0: michael@0: unsigned int vp9_variance4x4_mmx( michael@0: const unsigned char *src_ptr, michael@0: int source_stride, michael@0: const unsigned char *ref_ptr, michael@0: int recon_stride, michael@0: unsigned int *sse) { michael@0: unsigned int var; michael@0: int avg; michael@0: michael@0: vp9_get4x4var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg); michael@0: *sse = var; michael@0: return (var - (((unsigned int)avg * avg) >> 4)); michael@0: } michael@0: michael@0: unsigned int vp9_variance8x8_mmx( michael@0: const unsigned char *src_ptr, michael@0: int source_stride, michael@0: const unsigned char *ref_ptr, michael@0: int recon_stride, michael@0: unsigned int *sse) { michael@0: unsigned int var; michael@0: int avg; michael@0: michael@0: vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg); michael@0: *sse = var; michael@0: michael@0: return (var - (((unsigned int)avg * avg) >> 6)); michael@0: } michael@0: michael@0: unsigned int vp9_mse16x16_mmx( michael@0: const unsigned char *src_ptr, michael@0: int source_stride, michael@0: const unsigned char *ref_ptr, michael@0: int recon_stride, michael@0: unsigned int *sse) { michael@0: unsigned int sse0, sse1, sse2, sse3, var; michael@0: int sum0, sum1, sum2, sum3; michael@0: michael@0: michael@0: vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, michael@0: &sum0); michael@0: vp9_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, michael@0: &sse1, &sum1); michael@0: vp9_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, michael@0: ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2); michael@0: vp9_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride, michael@0: ref_ptr + 8 * recon_stride + 8, recon_stride, &sse3, &sum3); michael@0: michael@0: var = sse0 + sse1 + sse2 + sse3; michael@0: *sse = var; michael@0: return var; michael@0: } michael@0: michael@0: michael@0: unsigned int vp9_variance16x16_mmx( michael@0: const unsigned char *src_ptr, michael@0: int source_stride, michael@0: const unsigned char *ref_ptr, michael@0: int recon_stride, michael@0: unsigned int *sse) { michael@0: unsigned int sse0, sse1, sse2, sse3, var; michael@0: int sum0, sum1, sum2, sum3, avg; michael@0: michael@0: vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, michael@0: &sum0); michael@0: vp9_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, michael@0: &sse1, &sum1); michael@0: vp9_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, michael@0: ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2); michael@0: vp9_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride, michael@0: ref_ptr + 8 * recon_stride + 8, recon_stride, &sse3, &sum3); michael@0: michael@0: var = sse0 + sse1 + sse2 + sse3; michael@0: avg = sum0 + sum1 + sum2 + sum3; michael@0: *sse = var; michael@0: return (var - (((unsigned int)avg * avg) >> 8)); michael@0: } michael@0: michael@0: unsigned int vp9_variance16x8_mmx( michael@0: const unsigned char *src_ptr, michael@0: int source_stride, michael@0: const unsigned char *ref_ptr, michael@0: int recon_stride, michael@0: unsigned int *sse) { michael@0: unsigned int sse0, sse1, var; michael@0: int sum0, sum1, avg; michael@0: michael@0: vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, michael@0: &sum0); michael@0: vp9_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, michael@0: &sse1, &sum1); michael@0: michael@0: var = sse0 + sse1; michael@0: avg = sum0 + sum1; michael@0: *sse = var; michael@0: return (var - (((unsigned int)avg * avg) >> 7)); michael@0: } michael@0: michael@0: michael@0: unsigned int vp9_variance8x16_mmx( michael@0: const unsigned char *src_ptr, michael@0: int source_stride, michael@0: const unsigned char *ref_ptr, michael@0: int recon_stride, michael@0: unsigned int *sse) { michael@0: unsigned int sse0, sse1, var; michael@0: int sum0, sum1, avg; michael@0: michael@0: vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, michael@0: &sum0); michael@0: vp9_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, michael@0: ref_ptr + 8 * recon_stride, recon_stride, &sse1, &sum1); michael@0: michael@0: var = sse0 + sse1; michael@0: avg = sum0 + sum1; michael@0: *sse = var; michael@0: michael@0: return (var - (((unsigned int)avg * avg) >> 7)); michael@0: }