Home | History | Annotate | Download | only in x86
      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 short *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 
     51 unsigned int vp9_variance8x8_mmx(
     52   const unsigned char *src_ptr,
     53   int  source_stride,
     54   const unsigned char *ref_ptr,
     55   int  recon_stride,
     56   unsigned int *sse) {
     57   unsigned int var;
     58   int avg;
     59 
     60   vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg);
     61   *sse = var;
     62 
     63   return (var - (((unsigned int)avg * avg) >> 6));
     64 
     65 }
     66 
     67 unsigned int vp9_mse16x16_mmx(
     68   const unsigned char *src_ptr,
     69   int  source_stride,
     70   const unsigned char *ref_ptr,
     71   int  recon_stride,
     72   unsigned int *sse) {
     73   unsigned int sse0, sse1, sse2, sse3, var;
     74   int sum0, sum1, sum2, sum3;
     75 
     76 
     77   vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0);
     78   vp9_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &sse1, &sum1);
     79   vp9_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2);
     80   vp9_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride, ref_ptr + 8 * recon_stride + 8, recon_stride, &sse3, &sum3);
     81 
     82   var = sse0 + sse1 + sse2 + sse3;
     83   *sse = var;
     84   return var;
     85 }
     86 
     87 
     88 unsigned int vp9_variance16x16_mmx(
     89   const unsigned char *src_ptr,
     90   int  source_stride,
     91   const unsigned char *ref_ptr,
     92   int  recon_stride,
     93   unsigned int *sse) {
     94   unsigned int sse0, sse1, sse2, sse3, var;
     95   int sum0, sum1, sum2, sum3, avg;
     96 
     97 
     98   vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0);
     99   vp9_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &sse1, &sum1);
    100   vp9_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2);
    101   vp9_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride, ref_ptr + 8 * recon_stride + 8, recon_stride, &sse3, &sum3);
    102 
    103   var = sse0 + sse1 + sse2 + sse3;
    104   avg = sum0 + sum1 + sum2 + sum3;
    105   *sse = var;
    106   return (var - (((unsigned int)avg * avg) >> 8));
    107 }
    108 
    109 unsigned int vp9_variance16x8_mmx(
    110   const unsigned char *src_ptr,
    111   int  source_stride,
    112   const unsigned char *ref_ptr,
    113   int  recon_stride,
    114   unsigned int *sse) {
    115   unsigned int sse0, sse1, var;
    116   int sum0, sum1, avg;
    117 
    118   vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0);
    119   vp9_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &sse1, &sum1);
    120 
    121   var = sse0 + sse1;
    122   avg = sum0 + sum1;
    123   *sse = var;
    124   return (var - (((unsigned int)avg * avg) >> 7));
    125 
    126 }
    127 
    128 
    129 unsigned int vp9_variance8x16_mmx(
    130   const unsigned char *src_ptr,
    131   int  source_stride,
    132   const unsigned char *ref_ptr,
    133   int  recon_stride,
    134   unsigned int *sse) {
    135   unsigned int sse0, sse1, var;
    136   int sum0, sum1, avg;
    137 
    138   vp9_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0);
    139   vp9_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, ref_ptr + 8 * recon_stride, recon_stride, &sse1, &sum1);
    140 
    141   var = sse0 + sse1;
    142   avg = sum0 + sum1;
    143   *sse = var;
    144 
    145   return (var - (((unsigned int)avg * avg) >> 7));
    146 
    147 }
    148