Angie Chiang | 6421191 | 2016-10-25 15:09:56 -0700 | [diff] [blame] | 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 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 12 | #ifndef AV1_COMMON_AV1_CONVOLVE_H_ |
| 13 | #define AV1_COMMON_AV1_CONVOLVE_H_ |
| 14 | #include "av1/common/filter.h" |
| 15 | |
| 16 | #ifdef __cplusplus |
| 17 | extern "C" { |
| 18 | #endif |
| 19 | |
Angie Chiang | 9f45bc4 | 2017-01-13 16:27:54 -0800 | [diff] [blame] | 20 | typedef enum CONVOLVE_OPT { |
| 21 | // indicate the results in dst buf is rounded by FILTER_BITS or not |
| 22 | CONVOLVE_OPT_ROUND, |
| 23 | CONVOLVE_OPT_NO_ROUND, |
| 24 | } CONVOLVE_OPT; |
| 25 | |
Angie Chiang | 7927a97 | 2017-02-02 18:13:04 -0800 | [diff] [blame] | 26 | typedef int32_t CONV_BUF_TYPE; |
| 27 | |
Angie Chiang | 674bffd | 2017-01-11 16:15:55 -0800 | [diff] [blame] | 28 | typedef struct ConvolveParams { |
| 29 | int ref; |
Angie Chiang | 9f45bc4 | 2017-01-13 16:27:54 -0800 | [diff] [blame] | 30 | CONVOLVE_OPT round; |
Angie Chiang | 7927a97 | 2017-02-02 18:13:04 -0800 | [diff] [blame] | 31 | CONV_BUF_TYPE *dst; |
Angie Chiang | f715922 | 2017-01-18 12:51:12 -0800 | [diff] [blame] | 32 | int dst_stride; |
Angie Chiang | 7927a97 | 2017-02-02 18:13:04 -0800 | [diff] [blame] | 33 | int round_0; |
| 34 | int round_1; |
Angie Chiang | e3a4c1c | 2017-02-10 16:26:49 -0800 | [diff] [blame] | 35 | int plane; |
Angie Chiang | 05685e9 | 2017-05-08 12:55:39 -0700 | [diff] [blame] | 36 | int do_post_rounding; |
Angie Chiang | 674bffd | 2017-01-11 16:15:55 -0800 | [diff] [blame] | 37 | } ConvolveParams; |
| 38 | |
Angie Chiang | e3a4c1c | 2017-02-10 16:26:49 -0800 | [diff] [blame] | 39 | static INLINE ConvolveParams get_conv_params(int ref, int plane) { |
Angie Chiang | 9f45bc4 | 2017-01-13 16:27:54 -0800 | [diff] [blame] | 40 | ConvolveParams conv_params; |
| 41 | conv_params.ref = ref; |
| 42 | conv_params.round = CONVOLVE_OPT_ROUND; |
Angie Chiang | e3a4c1c | 2017-02-10 16:26:49 -0800 | [diff] [blame] | 43 | conv_params.plane = plane; |
Angie Chiang | 05685e9 | 2017-05-08 12:55:39 -0700 | [diff] [blame] | 44 | conv_params.do_post_rounding = 0; |
Angie Chiang | 9f45bc4 | 2017-01-13 16:27:54 -0800 | [diff] [blame] | 45 | return conv_params; |
| 46 | } |
Angie Chiang | 0a2c0cb | 2017-02-23 14:19:15 -0800 | [diff] [blame] | 47 | struct AV1Common; |
| 48 | void av1_convolve_init(struct AV1Common *cm); |
Angie Chiang | dbfec2a | 2017-02-01 15:04:59 -0800 | [diff] [blame] | 49 | #if CONFIG_CONVOLVE_ROUND |
Angie Chiang | 7927a97 | 2017-02-02 18:13:04 -0800 | [diff] [blame] | 50 | void av1_convolve_2d(const uint8_t *src, int src_stride, CONV_BUF_TYPE *dst, |
| 51 | int dst_stride, int w, int h, |
| 52 | InterpFilterParams *filter_params_x, |
| 53 | InterpFilterParams *filter_params_y, const int subpel_x_q4, |
| 54 | const int subpel_y_q4, ConvolveParams *conv_params); |
| 55 | |
| 56 | void av1_convolve_2d_facade(const uint8_t *src, int src_stride, uint8_t *dst, |
| 57 | int dst_stride, int w, int h, |
| 58 | const InterpFilter *interp_filter, |
| 59 | const int subpel_x_q4, int x_step_q4, |
| 60 | const int subpel_y_q4, int y_step_q4, |
| 61 | ConvolveParams *conv_params); |
| 62 | |
Angie Chiang | e3a4c1c | 2017-02-10 16:26:49 -0800 | [diff] [blame] | 63 | static INLINE ConvolveParams get_conv_params_no_round(int ref, int plane, |
| 64 | int32_t *dst, |
Angie Chiang | 117aa0d | 2017-01-18 15:27:03 -0800 | [diff] [blame] | 65 | int dst_stride) { |
| 66 | ConvolveParams conv_params; |
| 67 | conv_params.ref = ref; |
| 68 | conv_params.round = CONVOLVE_OPT_NO_ROUND; |
Angie Chiang | f87d837 | 2017-04-21 11:23:56 -0700 | [diff] [blame] | 69 | #if CONFIG_COMPOUND_ROUND |
| 70 | conv_params.round_0 = FILTER_BITS; |
| 71 | #else |
Angie Chiang | 7927a97 | 2017-02-02 18:13:04 -0800 | [diff] [blame] | 72 | conv_params.round_0 = 5; |
Angie Chiang | f87d837 | 2017-04-21 11:23:56 -0700 | [diff] [blame] | 73 | #endif |
Angie Chiang | a3a30c4 | 2017-02-21 10:36:01 -0800 | [diff] [blame] | 74 | conv_params.round_1 = 0; |
Angie Chiang | 117aa0d | 2017-01-18 15:27:03 -0800 | [diff] [blame] | 75 | conv_params.dst = dst; |
| 76 | conv_params.dst_stride = dst_stride; |
Angie Chiang | e3a4c1c | 2017-02-10 16:26:49 -0800 | [diff] [blame] | 77 | conv_params.plane = plane; |
Angie Chiang | 05685e9 | 2017-05-08 12:55:39 -0700 | [diff] [blame] | 78 | conv_params.do_post_rounding = 0; |
Angie Chiang | 117aa0d | 2017-01-18 15:27:03 -0800 | [diff] [blame] | 79 | return conv_params; |
| 80 | } |
| 81 | |
| 82 | void av1_convolve_rounding(const int32_t *src, int src_stride, uint8_t *dst, |
Angie Chiang | 7927a97 | 2017-02-02 18:13:04 -0800 | [diff] [blame] | 83 | int dst_stride, int w, int h, int bits); |
Angie Chiang | b03545b | 2017-05-05 12:07:30 -0700 | [diff] [blame] | 84 | |
| 85 | #if CONFIG_HIGHBITDEPTH |
| 86 | void av1_highbd_convolve_rounding(const int32_t *src, int src_stride, |
| 87 | uint8_t *dst8, int dst_stride, int w, int h, |
| 88 | int bits, int bd); |
| 89 | |
| 90 | void av1_highbd_convolve_2d(const uint16_t *src, int src_stride, |
| 91 | CONV_BUF_TYPE *dst, int dst_stride, int w, int h, |
| 92 | InterpFilterParams *filter_params_x, |
| 93 | InterpFilterParams *filter_params_y, |
| 94 | const int subpel_x_q4, const int subpel_y_q4, |
| 95 | ConvolveParams *conv_params, int bd); |
| 96 | |
| 97 | void av1_highbd_convolve_2d_facade(const uint8_t *src8, int src_stride, |
| 98 | uint8_t *dst, int dst_stride, int w, int h, |
| 99 | const InterpFilter *interp_filter, |
| 100 | const int subpel_x_q4, int x_step_q4, |
| 101 | const int subpel_y_q4, int y_step_q4, |
| 102 | ConvolveParams *conv_params, int bd); |
| 103 | #endif |
Angie Chiang | dbfec2a | 2017-02-01 15:04:59 -0800 | [diff] [blame] | 104 | #endif // CONFIG_CONVOLVE_ROUND |
Angie Chiang | 117aa0d | 2017-01-18 15:27:03 -0800 | [diff] [blame] | 105 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 106 | void av1_convolve(const uint8_t *src, int src_stride, uint8_t *dst, |
| 107 | int dst_stride, int w, int h, |
| 108 | #if CONFIG_DUAL_FILTER |
James Zern | 7b9407a | 2016-05-18 23:48:05 -0700 | [diff] [blame] | 109 | const InterpFilter *interp_filter, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 110 | #else |
James Zern | 7b9407a | 2016-05-18 23:48:05 -0700 | [diff] [blame] | 111 | const InterpFilter interp_filter, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 112 | #endif |
| 113 | const int subpel_x, int xstep, const int subpel_y, int ystep, |
Angie Chiang | 674bffd | 2017-01-11 16:15:55 -0800 | [diff] [blame] | 114 | ConvolveParams *conv_params); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 115 | |
Fergus Simpson | fc59389 | 2017-04-06 12:19:06 -0700 | [diff] [blame] | 116 | void av1_convolve_c(const uint8_t *src, int src_stride, uint8_t *dst, |
| 117 | int dst_stride, int w, int h, |
| 118 | #if CONFIG_DUAL_FILTER |
| 119 | const InterpFilter *interp_filter, |
| 120 | #else |
| 121 | const InterpFilter interp_filter, |
| 122 | #endif |
| 123 | const int subpel_x, int xstep, const int subpel_y, |
| 124 | int ystep, ConvolveParams *conv_params); |
| 125 | |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 126 | #if CONFIG_HIGHBITDEPTH |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 127 | void av1_highbd_convolve(const uint8_t *src, int src_stride, uint8_t *dst, |
| 128 | int dst_stride, int w, int h, |
| 129 | #if CONFIG_DUAL_FILTER |
James Zern | 7b9407a | 2016-05-18 23:48:05 -0700 | [diff] [blame] | 130 | const InterpFilter *interp_filter, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 131 | #else |
James Zern | 7b9407a | 2016-05-18 23:48:05 -0700 | [diff] [blame] | 132 | const InterpFilter interp_filter, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 133 | #endif |
| 134 | const int subpel_x, int xstep, const int subpel_y, |
| 135 | int ystep, int avg, int bd); |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 136 | #endif // CONFIG_HIGHBITDEPTH |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 137 | |
| 138 | #ifdef __cplusplus |
| 139 | } // extern "C" |
| 140 | #endif |
| 141 | |
| 142 | #endif // AV1_COMMON_AV1_CONVOLVE_H_ |