variance.h 5.76 KB
Newer Older
Johann's avatar
Johann committed
1
/*
Yaowu Xu's avatar
Yaowu Xu committed
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Johann's avatar
Johann committed
3
 *
Yaowu Xu's avatar
Yaowu Xu committed
4 5 6 7 8 9
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Johann's avatar
Johann committed
10 11
 */

Yaowu Xu's avatar
Yaowu Xu committed
12 13
#ifndef AOM_DSP_VARIANCE_H_
#define AOM_DSP_VARIANCE_H_
Johann's avatar
Johann committed
14

Yaowu Xu's avatar
Yaowu Xu committed
15
#include "./aom_config.h"
Johann's avatar
Johann committed
16

Yaowu Xu's avatar
Yaowu Xu committed
17
#include "aom/aom_integer.h"
Johann's avatar
Johann committed
18 19 20 21 22 23 24 25

#ifdef __cplusplus
extern "C" {
#endif

#define FILTER_BITS 7
#define FILTER_WEIGHT 128

Yaowu Xu's avatar
Yaowu Xu committed
26
typedef unsigned int (*aom_sad_fn_t)(const uint8_t *a, int a_stride,
clang-format's avatar
clang-format committed
27
                                     const uint8_t *b, int b_stride);
Johann's avatar
Johann committed
28

Yaowu Xu's avatar
Yaowu Xu committed
29
typedef unsigned int (*aom_sad_avg_fn_t)(const uint8_t *a, int a_stride,
clang-format's avatar
clang-format committed
30 31
                                         const uint8_t *b, int b_stride,
                                         const uint8_t *second_pred);
Johann's avatar
Johann committed
32

Yaowu Xu's avatar
Yaowu Xu committed
33
typedef void (*aom_copy32xn_fn_t)(const uint8_t *a, int a_stride, uint8_t *b,
clang-format's avatar
clang-format committed
34
                                  int b_stride, int n);
Johann's avatar
Johann committed
35

Yaowu Xu's avatar
Yaowu Xu committed
36
typedef void (*aom_sad_multi_fn_t)(const uint8_t *a, int a_stride,
Johann's avatar
Johann committed
37 38 39
                                   const uint8_t *b, int b_stride,
                                   unsigned int *sad_array);

Yaowu Xu's avatar
Yaowu Xu committed
40
typedef void (*aom_sad_multi_d_fn_t)(const uint8_t *a, int a_stride,
Johann's avatar
Johann committed
41
                                     const uint8_t *const b_array[],
clang-format's avatar
clang-format committed
42
                                     int b_stride, unsigned int *sad_array);
Johann's avatar
Johann committed
43

Yaowu Xu's avatar
Yaowu Xu committed
44
typedef unsigned int (*aom_variance_fn_t)(const uint8_t *a, int a_stride,
Johann's avatar
Johann committed
45 46 47
                                          const uint8_t *b, int b_stride,
                                          unsigned int *sse);

Yaowu Xu's avatar
Yaowu Xu committed
48
typedef unsigned int (*aom_subpixvariance_fn_t)(const uint8_t *a, int a_stride,
Johann's avatar
Johann committed
49 50 51 52
                                                int xoffset, int yoffset,
                                                const uint8_t *b, int b_stride,
                                                unsigned int *sse);

Yaowu Xu's avatar
Yaowu Xu committed
53
typedef unsigned int (*aom_subp_avg_variance_fn_t)(
clang-format's avatar
clang-format committed
54 55
    const uint8_t *a, int a_stride, int xoffset, int yoffset, const uint8_t *b,
    int b_stride, unsigned int *sse, const uint8_t *second_pred);
Johann's avatar
Johann committed
56

Cheng Chen's avatar
Cheng Chen committed
57 58 59 60 61 62 63 64 65 66 67 68
#if CONFIG_JNT_COMP
typedef unsigned int (*aom_jnt_sad_avg_fn_t)(const uint8_t *a, int a_stride,
                                             const uint8_t *b, int b_stride,
                                             const uint8_t *second_pred,
                                             const JNT_COMP_PARAMS *jcp_param);

typedef unsigned int (*aom_jnt_subp_avg_variance_fn_t)(
    const uint8_t *a, int a_stride, int xoffset, int yoffset, const uint8_t *b,
    int b_stride, unsigned int *sse, const uint8_t *second_pred,
    const JNT_COMP_PARAMS *jcp_param);
#endif  // CONFIG_JNT_COMP

69
#if CONFIG_AV1
David Barker's avatar
David Barker committed
70 71 72 73 74 75
typedef unsigned int (*aom_masked_sad_fn_t)(const uint8_t *src, int src_stride,
                                            const uint8_t *ref, int ref_stride,
                                            const uint8_t *second_pred,
                                            const uint8_t *msk, int msk_stride,
                                            int invert_mask);
typedef unsigned int (*aom_masked_subpixvariance_fn_t)(
76 77 78
    const uint8_t *src, int src_stride, int xoffset, int yoffset,
    const uint8_t *ref, int ref_stride, const uint8_t *second_pred,
    const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
79
#endif  // CONFIG_AV1
80

81
#if CONFIG_AV1
Yaowu Xu's avatar
Yaowu Xu committed
82
typedef unsigned int (*aom_obmc_sad_fn_t)(const uint8_t *pred, int pred_stride,
clang-format's avatar
clang-format committed
83 84
                                          const int32_t *wsrc,
                                          const int32_t *msk);
Yaowu Xu's avatar
Yaowu Xu committed
85
typedef unsigned int (*aom_obmc_variance_fn_t)(const uint8_t *pred,
86
                                               int pred_stride,
87 88
                                               const int32_t *wsrc,
                                               const int32_t *msk,
89
                                               unsigned int *sse);
Yaowu Xu's avatar
Yaowu Xu committed
90
typedef unsigned int (*aom_obmc_subpixvariance_fn_t)(
clang-format's avatar
clang-format committed
91 92
    const uint8_t *pred, int pred_stride, int xoffset, int yoffset,
    const int32_t *wsrc, const int32_t *msk, unsigned int *sse);
93
#endif  // CONFIG_AV1
Yaowu Xu's avatar
Yaowu Xu committed
94 95 96 97 98 99 100 101 102 103 104

#if CONFIG_AV1
typedef struct aom_variance_vtable {
  aom_sad_fn_t sdf;
  aom_sad_avg_fn_t sdaf;
  aom_variance_fn_t vf;
  aom_subpixvariance_fn_t svf;
  aom_subp_avg_variance_fn_t svaf;
  aom_sad_multi_fn_t sdx3f;
  aom_sad_multi_fn_t sdx8f;
  aom_sad_multi_d_fn_t sdx4df;
David Barker's avatar
David Barker committed
105 106
  aom_masked_sad_fn_t msdf;
  aom_masked_subpixvariance_fn_t msvf;
Yaowu Xu's avatar
Yaowu Xu committed
107 108 109
  aom_obmc_sad_fn_t osdf;
  aom_obmc_variance_fn_t ovf;
  aom_obmc_subpixvariance_fn_t osvf;
Cheng Chen's avatar
Cheng Chen committed
110 111 112 113
#if CONFIG_JNT_COMP
  aom_jnt_sad_avg_fn_t jsdaf;
  aom_jnt_subp_avg_variance_fn_t jsvaf;
#endif  // CONFIG_JNT_COMP
Yaowu Xu's avatar
Yaowu Xu committed
114 115
} aom_variance_fn_ptr_t;
#endif  // CONFIG_AV1
Johann's avatar
Johann committed
116

Yaowu Xu's avatar
Yaowu Xu committed
117
void aom_highbd_var_filter_block2d_bil_first_pass(
clang-format's avatar
clang-format committed
118 119 120
    const uint8_t *src_ptr8, uint16_t *output_ptr,
    unsigned int src_pixels_per_line, int pixel_step,
    unsigned int output_height, unsigned int output_width,
121 122
    const uint8_t *filter);

Yaowu Xu's avatar
Yaowu Xu committed
123
void aom_highbd_var_filter_block2d_bil_second_pass(
clang-format's avatar
clang-format committed
124 125 126
    const uint16_t *src_ptr, uint16_t *output_ptr,
    unsigned int src_pixels_per_line, unsigned int pixel_step,
    unsigned int output_height, unsigned int output_width,
127 128
    const uint8_t *filter);

129 130 131
uint32_t aom_sse_odd_size(const uint8_t *a, int a_stride, const uint8_t *b,
                          int b_stride, int w, int h);

132
#if CONFIG_HIGHBITDEPTH
133 134
uint64_t aom_highbd_sse_odd_size(const uint8_t *a, int a_stride,
                                 const uint8_t *b, int b_stride, int w, int h);
135
#endif  // CONFIG_HIGHBITDEPTH
136

Johann's avatar
Johann committed
137 138 139 140
#ifdef __cplusplus
}  // extern "C"
#endif

Yaowu Xu's avatar
Yaowu Xu committed
141
#endif  // AOM_DSP_VARIANCE_H_