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