Home | History | Annotate | Download | only in encoder
      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 #ifndef VP9_ENCODER_VP9_VARIANCE_H_
     12 #define VP9_ENCODER_VP9_VARIANCE_H_
     13 
     14 #include "vpx/vpx_integer.h"
     15 // #include "./vpx_config.h"
     16 
     17 void variance(const uint8_t *src_ptr,
     18               int  source_stride,
     19               const uint8_t *ref_ptr,
     20               int  recon_stride,
     21               int  w,
     22               int  h,
     23               unsigned int *sse,
     24               int *sum);
     25 
     26 typedef unsigned int(*vp9_sad_fn_t)(const uint8_t *src_ptr,
     27                                     int source_stride,
     28                                     const uint8_t *ref_ptr,
     29                                     int ref_stride,
     30                                     unsigned int max_sad);
     31 
     32 typedef unsigned int(*vp9_sad_avg_fn_t)(const uint8_t *src_ptr,
     33                                         int source_stride,
     34                                         const uint8_t *ref_ptr,
     35                                         int ref_stride,
     36                                         const uint8_t *second_pred,
     37                                         unsigned int max_sad);
     38 
     39 typedef void (*vp9_sad_multi_fn_t)(const uint8_t *src_ptr,
     40                                    int source_stride,
     41                                    const uint8_t *ref_ptr,
     42                                    int  ref_stride,
     43                                    unsigned int *sad_array);
     44 
     45 typedef void (*vp9_sad_multi1_fn_t)(const uint8_t *src_ptr,
     46                                     int source_stride,
     47                                     const uint8_t *ref_ptr,
     48                                     int  ref_stride,
     49                                     unsigned int *sad_array);
     50 
     51 typedef void (*vp9_sad_multi_d_fn_t)(const uint8_t *src_ptr,
     52                                      int source_stride,
     53                                      const uint8_t* const ref_ptr[],
     54                                      int  ref_stride, unsigned int *sad_array);
     55 
     56 typedef unsigned int (*vp9_variance_fn_t)(const uint8_t *src_ptr,
     57                                           int source_stride,
     58                                           const uint8_t *ref_ptr,
     59                                           int ref_stride,
     60                                           unsigned int *sse);
     61 
     62 typedef unsigned int (*vp9_subpixvariance_fn_t)(const uint8_t *src_ptr,
     63                                                 int source_stride,
     64                                                 int xoffset,
     65                                                 int yoffset,
     66                                                 const uint8_t *ref_ptr,
     67                                                 int Refstride,
     68                                                 unsigned int *sse);
     69 
     70 typedef unsigned int (*vp9_subp_avg_variance_fn_t)(const uint8_t *src_ptr,
     71                                                    int source_stride,
     72                                                    int xoffset,
     73                                                    int yoffset,
     74                                                    const uint8_t *ref_ptr,
     75                                                    int Refstride,
     76                                                    unsigned int *sse,
     77                                                    const uint8_t *second_pred);
     78 
     79 typedef unsigned int (*vp9_getmbss_fn_t)(const short *);
     80 
     81 typedef unsigned int (*vp9_get16x16prederror_fn_t)(const uint8_t *src_ptr,
     82                                                    int source_stride,
     83                                                    const uint8_t *ref_ptr,
     84                                                    int  ref_stride);
     85 
     86 typedef struct vp9_variance_vtable {
     87   vp9_sad_fn_t               sdf;
     88   vp9_sad_avg_fn_t           sdaf;
     89   vp9_variance_fn_t          vf;
     90   vp9_subpixvariance_fn_t    svf;
     91   vp9_subp_avg_variance_fn_t svaf;
     92   vp9_variance_fn_t          svf_halfpix_h;
     93   vp9_variance_fn_t          svf_halfpix_v;
     94   vp9_variance_fn_t          svf_halfpix_hv;
     95   vp9_sad_multi_fn_t         sdx3f;
     96   vp9_sad_multi1_fn_t        sdx8f;
     97   vp9_sad_multi_d_fn_t       sdx4df;
     98 } vp9_variance_fn_ptr_t;
     99 
    100 static void comp_avg_pred(uint8_t *comp_pred, const uint8_t *pred, int width,
    101                           int height, const uint8_t *ref, int ref_stride) {
    102   int i, j;
    103 
    104   for (i = 0; i < height; i++) {
    105     for (j = 0; j < width; j++) {
    106       int tmp;
    107       tmp = pred[j] + ref[j];
    108       comp_pred[j] = (tmp + 1) >> 1;
    109     }
    110     comp_pred += width;
    111     pred += width;
    112     ref += ref_stride;
    113   }
    114 }
    115 #endif  // VP9_ENCODER_VP9_VARIANCE_H_
    116