blob: 20f0895cbeb1106268023b14489931c484d7eff7 [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Yaowu Xu9c01aa12016-09-01 14:32:49 -07004 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Yaowu Xuc27fc142016-08-22 16:08:15 -070010 */
11
Yaowu Xuf883b422016-08-30 14:01:10 -070012#ifndef AOM_DSP_VARIANCE_H_
13#define AOM_DSP_VARIANCE_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
Yaowu Xuf883b422016-08-30 14:01:10 -070015#include "./aom_config.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070016
Yaowu Xuf883b422016-08-30 14:01:10 -070017#include "aom/aom_integer.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070018
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#define FILTER_BITS 7
24#define FILTER_WEIGHT 128
25
Yaowu Xuf883b422016-08-30 14:01:10 -070026typedef unsigned int (*aom_sad_fn_t)(const uint8_t *a, int a_stride,
Yaowu Xuc27fc142016-08-22 16:08:15 -070027 const uint8_t *b, int b_stride);
28
Yaowu Xuf883b422016-08-30 14:01:10 -070029typedef unsigned int (*aom_sad_avg_fn_t)(const uint8_t *a, int a_stride,
Yaowu Xuc27fc142016-08-22 16:08:15 -070030 const uint8_t *b, int b_stride,
31 const uint8_t *second_pred);
32
Yaowu Xuf883b422016-08-30 14:01:10 -070033typedef void (*aom_copy32xn_fn_t)(const uint8_t *a, int a_stride, uint8_t *b,
Yaowu Xuc27fc142016-08-22 16:08:15 -070034 int b_stride, int n);
35
Yaowu Xuf883b422016-08-30 14:01:10 -070036typedef void (*aom_sad_multi_fn_t)(const uint8_t *a, int a_stride,
Yaowu Xuc27fc142016-08-22 16:08:15 -070037 const uint8_t *b, int b_stride,
38 unsigned int *sad_array);
39
Yaowu Xuf883b422016-08-30 14:01:10 -070040typedef void (*aom_sad_multi_d_fn_t)(const uint8_t *a, int a_stride,
Yaowu Xuc27fc142016-08-22 16:08:15 -070041 const uint8_t *const b_array[],
42 int b_stride, unsigned int *sad_array);
43
Yaowu Xuf883b422016-08-30 14:01:10 -070044typedef unsigned int (*aom_variance_fn_t)(const uint8_t *a, int a_stride,
Yaowu Xuc27fc142016-08-22 16:08:15 -070045 const uint8_t *b, int b_stride,
46 unsigned int *sse);
47
Yaowu Xuf883b422016-08-30 14:01:10 -070048typedef unsigned int (*aom_subpixvariance_fn_t)(const uint8_t *a, int a_stride,
Yaowu Xuc27fc142016-08-22 16:08:15 -070049 int xoffset, int yoffset,
50 const uint8_t *b, int b_stride,
51 unsigned int *sse);
52
Yaowu Xuf883b422016-08-30 14:01:10 -070053typedef unsigned int (*aom_subp_avg_variance_fn_t)(
Yaowu Xuc27fc142016-08-22 16:08:15 -070054 const uint8_t *a, int a_stride, int xoffset, int yoffset, const uint8_t *b,
55 int b_stride, unsigned int *sse, const uint8_t *second_pred);
56
Yaowu Xuf883b422016-08-30 14:01:10 -070057#if CONFIG_AV1 && CONFIG_EXT_INTER
David Barkerf19f35f2017-05-22 16:33:22 +010058typedef unsigned int (*aom_masked_sad_fn_t)(const uint8_t *src, int src_stride,
59 const uint8_t *ref, int ref_stride,
60 const uint8_t *second_pred,
61 const uint8_t *msk, int msk_stride,
62 int invert_mask);
63typedef unsigned int (*aom_masked_subpixvariance_fn_t)(
David Barkerc155e012017-05-11 13:54:54 +010064 const uint8_t *src, int src_stride, int xoffset, int yoffset,
65 const uint8_t *ref, int ref_stride, const uint8_t *second_pred,
66 const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
Yaowu Xuf883b422016-08-30 14:01:10 -070067#endif // CONFIG_AV1 && CONFIG_EXT_INTER
Yaowu Xuc27fc142016-08-22 16:08:15 -070068
Yue Chencb60b182016-10-13 15:18:22 -070069#if CONFIG_AV1 && CONFIG_MOTION_VAR
Yaowu Xuf883b422016-08-30 14:01:10 -070070typedef unsigned int (*aom_obmc_sad_fn_t)(const uint8_t *pred, int pred_stride,
Yaowu Xuc27fc142016-08-22 16:08:15 -070071 const int32_t *wsrc,
72 const int32_t *msk);
Yaowu Xuf883b422016-08-30 14:01:10 -070073typedef unsigned int (*aom_obmc_variance_fn_t)(const uint8_t *pred,
Yaowu Xuc27fc142016-08-22 16:08:15 -070074 int pred_stride,
75 const int32_t *wsrc,
76 const int32_t *msk,
77 unsigned int *sse);
Yaowu Xuf883b422016-08-30 14:01:10 -070078typedef unsigned int (*aom_obmc_subpixvariance_fn_t)(
Yaowu Xuc27fc142016-08-22 16:08:15 -070079 const uint8_t *pred, int pred_stride, int xoffset, int yoffset,
80 const int32_t *wsrc, const int32_t *msk, unsigned int *sse);
Yue Chencb60b182016-10-13 15:18:22 -070081#endif // CONFIG_AV1 && CONFIG_MOTION_VAR
Yaowu Xuc27fc142016-08-22 16:08:15 -070082
Yaowu Xuf883b422016-08-30 14:01:10 -070083#if CONFIG_AV1
84typedef struct aom_variance_vtable {
85 aom_sad_fn_t sdf;
86 aom_sad_avg_fn_t sdaf;
87 aom_variance_fn_t vf;
88 aom_subpixvariance_fn_t svf;
89 aom_subp_avg_variance_fn_t svaf;
90 aom_sad_multi_fn_t sdx3f;
91 aom_sad_multi_fn_t sdx8f;
92 aom_sad_multi_d_fn_t sdx4df;
Yaowu Xuc27fc142016-08-22 16:08:15 -070093#if CONFIG_EXT_INTER
David Barkerf19f35f2017-05-22 16:33:22 +010094 aom_masked_sad_fn_t msdf;
95 aom_masked_subpixvariance_fn_t msvf;
Yaowu Xuc27fc142016-08-22 16:08:15 -070096#endif // CONFIG_EXT_INTER
Yue Chencb60b182016-10-13 15:18:22 -070097#if CONFIG_MOTION_VAR
Yaowu Xuf883b422016-08-30 14:01:10 -070098 aom_obmc_sad_fn_t osdf;
99 aom_obmc_variance_fn_t ovf;
100 aom_obmc_subpixvariance_fn_t osvf;
Yue Chencb60b182016-10-13 15:18:22 -0700101#endif // CONFIG_MOTION_VAR
Yaowu Xuf883b422016-08-30 14:01:10 -0700102} aom_variance_fn_ptr_t;
103#endif // CONFIG_AV1
Yaowu Xuc27fc142016-08-22 16:08:15 -0700104
Yaowu Xuf883b422016-08-30 14:01:10 -0700105void aom_highbd_var_filter_block2d_bil_first_pass(
Yaowu Xuc27fc142016-08-22 16:08:15 -0700106 const uint8_t *src_ptr8, uint16_t *output_ptr,
107 unsigned int src_pixels_per_line, int pixel_step,
108 unsigned int output_height, unsigned int output_width,
109 const uint8_t *filter);
110
Yaowu Xuf883b422016-08-30 14:01:10 -0700111void aom_highbd_var_filter_block2d_bil_second_pass(
Yaowu Xuc27fc142016-08-22 16:08:15 -0700112 const uint16_t *src_ptr, uint16_t *output_ptr,
113 unsigned int src_pixels_per_line, unsigned int pixel_step,
114 unsigned int output_height, unsigned int output_width,
115 const uint8_t *filter);
116
Alex Converse29608d82017-03-30 09:36:58 -0700117uint32_t aom_sse_odd_size(const uint8_t *a, int a_stride, const uint8_t *b,
118 int b_stride, int w, int h);
119
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200120#if CONFIG_HIGHBITDEPTH
Alex Converse29608d82017-03-30 09:36:58 -0700121uint64_t aom_highbd_sse_odd_size(const uint8_t *a, int a_stride,
122 const uint8_t *b, int b_stride, int w, int h);
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200123#endif // CONFIG_HIGHBITDEPTH
Alex Converse29608d82017-03-30 09:36:58 -0700124
Yaowu Xuc27fc142016-08-22 16:08:15 -0700125#ifdef __cplusplus
126} // extern "C"
127#endif
128
Yaowu Xuf883b422016-08-30 14:01:10 -0700129#endif // AOM_DSP_VARIANCE_H_