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