1 /* 2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved. 3 * 4 * 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. 10 */ 11 12 #ifndef AOM_AOM_DSP_VARIANCE_H_ 13 #define AOM_AOM_DSP_VARIANCE_H_ 14 15 #include "config/aom_config.h" 16 17 #include "aom/aom_integer.h" 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 #define FILTER_BITS 7 24 #define FILTER_WEIGHT 128 25 26 typedef unsigned int (*aom_sad_fn_t)(const uint8_t *a, int a_stride, 27 const uint8_t *b, int b_stride); 28 29 typedef unsigned int (*aom_sad_avg_fn_t)(const uint8_t *a, int a_stride, 30 const uint8_t *b, int b_stride, 31 const uint8_t *second_pred); 32 33 typedef void (*aom_copy32xn_fn_t)(const uint8_t *a, int a_stride, uint8_t *b, 34 int b_stride, int n); 35 36 typedef void (*aom_sad_multi_d_fn_t)(const uint8_t *a, int a_stride, 37 const uint8_t *const b_array[], 38 int b_stride, unsigned int *sad_array); 39 40 typedef unsigned int (*aom_variance_fn_t)(const uint8_t *a, int a_stride, 41 const uint8_t *b, int b_stride, 42 unsigned int *sse); 43 44 typedef unsigned int (*aom_subpixvariance_fn_t)(const uint8_t *a, int a_stride, 45 int xoffset, int yoffset, 46 const uint8_t *b, int b_stride, 47 unsigned int *sse); 48 49 typedef unsigned int (*aom_subp_avg_variance_fn_t)( 50 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 53 typedef unsigned int (*aom_dist_wtd_sad_avg_fn_t)( 54 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); 56 57 typedef unsigned int (*aom_dist_wtd_subp_avg_variance_fn_t)( 58 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, 60 const DIST_WTD_COMP_PARAMS *jcp_param); 61 62 typedef 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); 67 typedef unsigned int (*aom_masked_subpixvariance_fn_t)( 68 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); 71 72 typedef unsigned int (*aom_obmc_sad_fn_t)(const uint8_t *pred, int pred_stride, 73 const int32_t *wsrc, 74 const int32_t *msk); 75 typedef unsigned int (*aom_obmc_variance_fn_t)(const uint8_t *pred, 76 int pred_stride, 77 const int32_t *wsrc, 78 const int32_t *msk, 79 unsigned int *sse); 80 typedef unsigned int (*aom_obmc_subpixvariance_fn_t)( 81 const uint8_t *pred, int pred_stride, int xoffset, int yoffset, 82 const int32_t *wsrc, const int32_t *msk, unsigned int *sse); 83 84 typedef struct aom_variance_vtable { 85 aom_sad_fn_t sdf; 86 // Same as normal sad, but downsample the rows by a factor of 2. 87 aom_sad_fn_t sdsf; 88 aom_sad_avg_fn_t sdaf; 89 aom_variance_fn_t vf; 90 aom_subpixvariance_fn_t svf; 91 aom_subp_avg_variance_fn_t svaf; 92 aom_sad_multi_d_fn_t sdx4df; 93 aom_sad_multi_d_fn_t sdx3df; 94 // Same as sadx4, but downsample the rows by a factor of 2. 95 aom_sad_multi_d_fn_t sdsx4df; 96 aom_masked_sad_fn_t msdf; 97 aom_masked_subpixvariance_fn_t msvf; 98 aom_obmc_sad_fn_t osdf; 99 aom_obmc_variance_fn_t ovf; 100 aom_obmc_subpixvariance_fn_t osvf; 101 aom_dist_wtd_sad_avg_fn_t jsdaf; 102 aom_dist_wtd_subp_avg_variance_fn_t jsvaf; 103 } aom_variance_fn_ptr_t; 104 105 void aom_highbd_var_filter_block2d_bil_first_pass( 106 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 111 void aom_highbd_var_filter_block2d_bil_second_pass( 112 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 117 uint32_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 120 uint64_t aom_highbd_sse_odd_size(const uint8_t *a, int a_stride, 121 const uint8_t *b, int b_stride, int w, int h); 122 123 #ifdef __cplusplus 124 } // extern "C" 125 #endif 126 127 #endif // AOM_AOM_DSP_VARIANCE_H_ 128