blob: 428afd08fb9e823600bd514646d8782a491244df [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
James Zerne1cbb132018-08-22 14:10:36 -070012#ifndef AOM_AOM_DSP_VARIANCE_H_
13#define AOM_AOM_DSP_VARIANCE_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
Tom Finegan60e653d2018-05-22 11:34:58 -070015#include "config/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_d_fn_t)(const uint8_t *a, int a_stride,
Yaowu Xuc27fc142016-08-22 16:08:15 -070037 const uint8_t *const b_array[],
38 int b_stride, unsigned int *sad_array);
39
Yaowu Xuf883b422016-08-30 14:01:10 -070040typedef unsigned int (*aom_variance_fn_t)(const uint8_t *a, int a_stride,
Yaowu Xuc27fc142016-08-22 16:08:15 -070041 const uint8_t *b, int b_stride,
42 unsigned int *sse);
43
Yaowu Xuf883b422016-08-30 14:01:10 -070044typedef unsigned int (*aom_subpixvariance_fn_t)(const uint8_t *a, int a_stride,
Yaowu Xuc27fc142016-08-22 16:08:15 -070045 int xoffset, int yoffset,
46 const uint8_t *b, int b_stride,
47 unsigned int *sse);
48
Yaowu Xuf883b422016-08-30 14:01:10 -070049typedef unsigned int (*aom_subp_avg_variance_fn_t)(
Yaowu Xuc27fc142016-08-22 16:08:15 -070050 const uint8_t *a, int a_stride, int xoffset, int yoffset, const uint8_t *b,
51 int b_stride, unsigned int *sse, const uint8_t *second_pred);
52
Debargha Mukherjee0c96c112018-12-20 16:04:18 -080053typedef unsigned int (*aom_dist_wtd_sad_avg_fn_t)(
Debargha Mukherjeef90004a2018-12-20 13:35:06 -080054 const uint8_t *a, int a_stride, const uint8_t *b, int b_stride,
55 const uint8_t *second_pred, const DIST_WTD_COMP_PARAMS *jcp_param);
Cheng Chenf78632e2017-10-20 15:30:51 -070056
Debargha Mukherjee0c96c112018-12-20 16:04:18 -080057typedef unsigned int (*aom_dist_wtd_subp_avg_variance_fn_t)(
Cheng Chenf78632e2017-10-20 15:30:51 -070058 const uint8_t *a, int a_stride, int xoffset, int yoffset, const uint8_t *b,
59 int b_stride, unsigned int *sse, const uint8_t *second_pred,
Debargha Mukherjeef90004a2018-12-20 13:35:06 -080060 const DIST_WTD_COMP_PARAMS *jcp_param);
Cheng Chenf78632e2017-10-20 15:30:51 -070061
David Barkerf19f35f2017-05-22 16:33:22 +010062typedef unsigned int (*aom_masked_sad_fn_t)(const uint8_t *src, int src_stride,
63 const uint8_t *ref, int ref_stride,
64 const uint8_t *second_pred,
65 const uint8_t *msk, int msk_stride,
66 int invert_mask);
67typedef unsigned int (*aom_masked_subpixvariance_fn_t)(
David Barkerc155e012017-05-11 13:54:54 +010068 const uint8_t *src, int src_stride, int xoffset, int yoffset,
69 const uint8_t *ref, int ref_stride, const uint8_t *second_pred,
70 const uint8_t *msk, int msk_stride, int invert_mask, unsigned int *sse);
Peng Binf8daa922018-01-31 16:22:27 +080071
Ravi Chaudhary85ad0112018-07-09 18:50:56 +053072void aom_highbd_comp_mask_upsampled_pred(
73 MACROBLOCKD *xd, const struct AV1Common *const cm, int mi_row, int mi_col,
Peng Bin3ab3a7b2018-07-23 09:52:42 +080074 const MV *const mv, uint8_t *comp_pred8, const uint8_t *pred8, int width,
Ravi Chaudhary85ad0112018-07-09 18:50:56 +053075 int height, int subpel_x_q3, int subpel_y_q3, const uint8_t *ref8,
76 int ref_stride, const uint8_t *mask, int mask_stride, int invert_mask,
Yunqing Wang901ecab2018-08-06 12:27:24 -070077 int bd, int subpel_search);
Ravi Chaudhary85ad0112018-07-09 18:50:56 +053078
Yaowu Xuf883b422016-08-30 14:01:10 -070079typedef unsigned int (*aom_obmc_sad_fn_t)(const uint8_t *pred, int pred_stride,
Yaowu Xuc27fc142016-08-22 16:08:15 -070080 const int32_t *wsrc,
81 const int32_t *msk);
Yaowu Xuf883b422016-08-30 14:01:10 -070082typedef unsigned int (*aom_obmc_variance_fn_t)(const uint8_t *pred,
Yaowu Xuc27fc142016-08-22 16:08:15 -070083 int pred_stride,
84 const int32_t *wsrc,
85 const int32_t *msk,
86 unsigned int *sse);
Yaowu Xuf883b422016-08-30 14:01:10 -070087typedef unsigned int (*aom_obmc_subpixvariance_fn_t)(
Yaowu Xuc27fc142016-08-22 16:08:15 -070088 const uint8_t *pred, int pred_stride, int xoffset, int yoffset,
89 const int32_t *wsrc, const int32_t *msk, unsigned int *sse);
Yaowu Xuc27fc142016-08-22 16:08:15 -070090
Yaowu Xuf883b422016-08-30 14:01:10 -070091typedef struct aom_variance_vtable {
92 aom_sad_fn_t sdf;
chiyotsaic814afb2020-08-04 13:12:35 -070093 // Same as normal sad, but downsample the rows by a factor of 2.
94 aom_sad_fn_t sdsf;
Yaowu Xuf883b422016-08-30 14:01:10 -070095 aom_sad_avg_fn_t sdaf;
96 aom_variance_fn_t vf;
97 aom_subpixvariance_fn_t svf;
98 aom_subp_avg_variance_fn_t svaf;
Yaowu Xuf883b422016-08-30 14:01:10 -070099 aom_sad_multi_d_fn_t sdx4df;
chiyotsaic814afb2020-08-04 13:12:35 -0700100 // Same as sadx4, but downsample the rows by a factor of 2.
101 aom_sad_multi_d_fn_t sdsx4df;
David Barkerf19f35f2017-05-22 16:33:22 +0100102 aom_masked_sad_fn_t msdf;
103 aom_masked_subpixvariance_fn_t msvf;
Yaowu Xuf883b422016-08-30 14:01:10 -0700104 aom_obmc_sad_fn_t osdf;
105 aom_obmc_variance_fn_t ovf;
106 aom_obmc_subpixvariance_fn_t osvf;
Debargha Mukherjee0c96c112018-12-20 16:04:18 -0800107 aom_dist_wtd_sad_avg_fn_t jsdaf;
108 aom_dist_wtd_subp_avg_variance_fn_t jsvaf;
Yaowu Xuf883b422016-08-30 14:01:10 -0700109} aom_variance_fn_ptr_t;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700110
Yaowu Xuf883b422016-08-30 14:01:10 -0700111void aom_highbd_var_filter_block2d_bil_first_pass(
Yaowu Xuc27fc142016-08-22 16:08:15 -0700112 const uint8_t *src_ptr8, uint16_t *output_ptr,
113 unsigned int src_pixels_per_line, int pixel_step,
114 unsigned int output_height, unsigned int output_width,
115 const uint8_t *filter);
116
Yaowu Xuf883b422016-08-30 14:01:10 -0700117void aom_highbd_var_filter_block2d_bil_second_pass(
Yaowu Xuc27fc142016-08-22 16:08:15 -0700118 const uint16_t *src_ptr, uint16_t *output_ptr,
119 unsigned int src_pixels_per_line, unsigned int pixel_step,
120 unsigned int output_height, unsigned int output_width,
121 const uint8_t *filter);
122
Alex Converse29608d82017-03-30 09:36:58 -0700123uint32_t aom_sse_odd_size(const uint8_t *a, int a_stride, const uint8_t *b,
124 int b_stride, int w, int h);
125
Alex Converse29608d82017-03-30 09:36:58 -0700126uint64_t aom_highbd_sse_odd_size(const uint8_t *a, int a_stride,
127 const uint8_t *b, int b_stride, int w, int h);
Alex Converse29608d82017-03-30 09:36:58 -0700128
Yaowu Xuc27fc142016-08-22 16:08:15 -0700129#ifdef __cplusplus
130} // extern "C"
131#endif
132
James Zerne1cbb132018-08-22 14:10:36 -0700133#endif // AOM_AOM_DSP_VARIANCE_H_