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 "vp8/common/variance.h" michael@0: #include "vp8/common/pragmas.h" michael@0: #include "vpx_ports/mem.h" michael@0: #include "vp8/common/x86/filter_x86.h" michael@0: michael@0: extern void filter_block1d_h6_mmx michael@0: ( michael@0: const unsigned char *src_ptr, michael@0: unsigned short *output_ptr, michael@0: unsigned int src_pixels_per_line, michael@0: unsigned int pixel_step, michael@0: unsigned int output_height, michael@0: unsigned int output_width, michael@0: short *filter michael@0: ); michael@0: extern void filter_block1d_v6_mmx michael@0: ( michael@0: const short *src_ptr, michael@0: unsigned char *output_ptr, michael@0: unsigned int pixels_per_line, michael@0: unsigned int pixel_step, michael@0: unsigned int output_height, michael@0: unsigned int output_width, michael@0: short *filter michael@0: ); michael@0: michael@0: extern unsigned int vp8_get_mb_ss_mmx(const short *src_ptr); michael@0: extern unsigned int vp8_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 vp8_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: extern void vp8_filter_block2d_bil4x4_var_mmx michael@0: ( michael@0: const unsigned char *ref_ptr, michael@0: int ref_pixels_per_line, michael@0: const unsigned char *src_ptr, michael@0: int src_pixels_per_line, michael@0: const short *HFilter, michael@0: const short *VFilter, michael@0: int *sum, michael@0: unsigned int *sumsquared michael@0: ); michael@0: extern void vp8_filter_block2d_bil_var_mmx michael@0: ( michael@0: const unsigned char *ref_ptr, michael@0: int ref_pixels_per_line, michael@0: const unsigned char *src_ptr, michael@0: int src_pixels_per_line, michael@0: unsigned int Height, michael@0: const short *HFilter, michael@0: const short *VFilter, michael@0: int *sum, michael@0: unsigned int *sumsquared michael@0: ); michael@0: michael@0: michael@0: unsigned int vp8_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: { michael@0: unsigned int var; michael@0: int avg; michael@0: michael@0: vp8_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: michael@0: unsigned int vp8_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: { michael@0: unsigned int var; michael@0: int avg; michael@0: michael@0: vp8_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: michael@0: unsigned int vp8_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: { michael@0: unsigned int sse0, sse1, sse2, sse3, var; michael@0: int sum0, sum1, sum2, sum3; michael@0: michael@0: michael@0: vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0) ; michael@0: vp8_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &sse1, &sum1); michael@0: vp8_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2) ; michael@0: vp8_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride, 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 vp8_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: { michael@0: unsigned int sse0, sse1, sse2, sse3, var; michael@0: int sum0, sum1, sum2, sum3, avg; michael@0: michael@0: michael@0: vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0) ; michael@0: vp8_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &sse1, &sum1); michael@0: vp8_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2) ; michael@0: vp8_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride, 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 vp8_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: { michael@0: unsigned int sse0, sse1, var; michael@0: int sum0, sum1, avg; michael@0: michael@0: vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0) ; michael@0: vp8_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &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: michael@0: unsigned int vp8_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: { michael@0: unsigned int sse0, sse1, var; michael@0: int sum0, sum1, avg; michael@0: michael@0: vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0) ; michael@0: vp8_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, 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: michael@0: } michael@0: michael@0: michael@0: unsigned int vp8_sub_pixel_variance4x4_mmx michael@0: ( michael@0: const unsigned char *src_ptr, michael@0: int src_pixels_per_line, michael@0: int xoffset, michael@0: int yoffset, michael@0: const unsigned char *dst_ptr, michael@0: int dst_pixels_per_line, michael@0: unsigned int *sse) michael@0: michael@0: { michael@0: int xsum; michael@0: unsigned int xxsum; michael@0: vp8_filter_block2d_bil4x4_var_mmx( michael@0: src_ptr, src_pixels_per_line, michael@0: dst_ptr, dst_pixels_per_line, michael@0: vp8_bilinear_filters_x86_4[xoffset], vp8_bilinear_filters_x86_4[yoffset], michael@0: &xsum, &xxsum michael@0: ); michael@0: *sse = xxsum; michael@0: return (xxsum - (((unsigned int)xsum * xsum) >> 4)); michael@0: } michael@0: michael@0: michael@0: unsigned int vp8_sub_pixel_variance8x8_mmx michael@0: ( michael@0: const unsigned char *src_ptr, michael@0: int src_pixels_per_line, michael@0: int xoffset, michael@0: int yoffset, michael@0: const unsigned char *dst_ptr, michael@0: int dst_pixels_per_line, michael@0: unsigned int *sse michael@0: ) michael@0: { michael@0: michael@0: int xsum; michael@0: unsigned int xxsum; michael@0: vp8_filter_block2d_bil_var_mmx( michael@0: src_ptr, src_pixels_per_line, michael@0: dst_ptr, dst_pixels_per_line, 8, michael@0: vp8_bilinear_filters_x86_4[xoffset], vp8_bilinear_filters_x86_4[yoffset], michael@0: &xsum, &xxsum michael@0: ); michael@0: *sse = xxsum; michael@0: return (xxsum - (((unsigned int)xsum * xsum) >> 6)); michael@0: } michael@0: michael@0: unsigned int vp8_sub_pixel_variance16x16_mmx michael@0: ( michael@0: const unsigned char *src_ptr, michael@0: int src_pixels_per_line, michael@0: int xoffset, michael@0: int yoffset, michael@0: const unsigned char *dst_ptr, michael@0: int dst_pixels_per_line, michael@0: unsigned int *sse michael@0: ) michael@0: { michael@0: michael@0: int xsum0, xsum1; michael@0: unsigned int xxsum0, xxsum1; michael@0: michael@0: michael@0: vp8_filter_block2d_bil_var_mmx( michael@0: src_ptr, src_pixels_per_line, michael@0: dst_ptr, dst_pixels_per_line, 16, michael@0: vp8_bilinear_filters_x86_4[xoffset], vp8_bilinear_filters_x86_4[yoffset], michael@0: &xsum0, &xxsum0 michael@0: ); michael@0: michael@0: michael@0: vp8_filter_block2d_bil_var_mmx( michael@0: src_ptr + 8, src_pixels_per_line, michael@0: dst_ptr + 8, dst_pixels_per_line, 16, michael@0: vp8_bilinear_filters_x86_4[xoffset], vp8_bilinear_filters_x86_4[yoffset], michael@0: &xsum1, &xxsum1 michael@0: ); michael@0: michael@0: xsum0 += xsum1; michael@0: xxsum0 += xxsum1; michael@0: michael@0: *sse = xxsum0; michael@0: return (xxsum0 - (((unsigned int)xsum0 * xsum0) >> 8)); michael@0: michael@0: michael@0: } michael@0: michael@0: unsigned int vp8_sub_pixel_mse16x16_mmx( michael@0: const unsigned char *src_ptr, michael@0: int src_pixels_per_line, michael@0: int xoffset, michael@0: int yoffset, michael@0: const unsigned char *dst_ptr, michael@0: int dst_pixels_per_line, michael@0: unsigned int *sse michael@0: ) michael@0: { michael@0: vp8_sub_pixel_variance16x16_mmx(src_ptr, src_pixels_per_line, xoffset, yoffset, dst_ptr, dst_pixels_per_line, sse); michael@0: return *sse; michael@0: } michael@0: michael@0: unsigned int vp8_sub_pixel_variance16x8_mmx michael@0: ( michael@0: const unsigned char *src_ptr, michael@0: int src_pixels_per_line, michael@0: int xoffset, michael@0: int yoffset, michael@0: const unsigned char *dst_ptr, michael@0: int dst_pixels_per_line, michael@0: unsigned int *sse michael@0: ) michael@0: { michael@0: int xsum0, xsum1; michael@0: unsigned int xxsum0, xxsum1; michael@0: michael@0: michael@0: vp8_filter_block2d_bil_var_mmx( michael@0: src_ptr, src_pixels_per_line, michael@0: dst_ptr, dst_pixels_per_line, 8, michael@0: vp8_bilinear_filters_x86_4[xoffset], vp8_bilinear_filters_x86_4[yoffset], michael@0: &xsum0, &xxsum0 michael@0: ); michael@0: michael@0: michael@0: vp8_filter_block2d_bil_var_mmx( michael@0: src_ptr + 8, src_pixels_per_line, michael@0: dst_ptr + 8, dst_pixels_per_line, 8, michael@0: vp8_bilinear_filters_x86_4[xoffset], vp8_bilinear_filters_x86_4[yoffset], michael@0: &xsum1, &xxsum1 michael@0: ); michael@0: michael@0: xsum0 += xsum1; michael@0: xxsum0 += xxsum1; michael@0: michael@0: *sse = xxsum0; michael@0: return (xxsum0 - (((unsigned int)xsum0 * xsum0) >> 7)); michael@0: } michael@0: michael@0: unsigned int vp8_sub_pixel_variance8x16_mmx michael@0: ( michael@0: const unsigned char *src_ptr, michael@0: int src_pixels_per_line, michael@0: int xoffset, michael@0: int yoffset, michael@0: const unsigned char *dst_ptr, michael@0: int dst_pixels_per_line, michael@0: unsigned int *sse michael@0: ) michael@0: { michael@0: int xsum; michael@0: unsigned int xxsum; michael@0: vp8_filter_block2d_bil_var_mmx( michael@0: src_ptr, src_pixels_per_line, michael@0: dst_ptr, dst_pixels_per_line, 16, michael@0: vp8_bilinear_filters_x86_4[xoffset], vp8_bilinear_filters_x86_4[yoffset], michael@0: &xsum, &xxsum michael@0: ); michael@0: *sse = xxsum; michael@0: return (xxsum - (((unsigned int)xsum * xsum) >> 7)); michael@0: } michael@0: michael@0: michael@0: unsigned int vp8_variance_halfpixvar16x16_h_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: { michael@0: return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 4, 0, michael@0: ref_ptr, recon_stride, sse); michael@0: } michael@0: michael@0: michael@0: unsigned int vp8_variance_halfpixvar16x16_v_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: { michael@0: return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 0, 4, michael@0: ref_ptr, recon_stride, sse); michael@0: } michael@0: michael@0: michael@0: unsigned int vp8_variance_halfpixvar16x16_hv_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: { michael@0: return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 4, 4, michael@0: ref_ptr, recon_stride, sse); michael@0: }