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 | 674bffd | 2017-01-11 16:15:55 -0800 | [diff] [blame] | 36 | } ConvolveParams; |
| 37 | |
Angie Chiang | e3a4c1c | 2017-02-10 16:26:49 -0800 | [diff] [blame] | 38 | static INLINE ConvolveParams get_conv_params(int ref, int plane) { |
Angie Chiang | 9f45bc4 | 2017-01-13 16:27:54 -0800 | [diff] [blame] | 39 | ConvolveParams conv_params; |
| 40 | conv_params.ref = ref; |
| 41 | conv_params.round = CONVOLVE_OPT_ROUND; |
Angie Chiang | e3a4c1c | 2017-02-10 16:26:49 -0800 | [diff] [blame] | 42 | conv_params.plane = plane; |
Angie Chiang | 9f45bc4 | 2017-01-13 16:27:54 -0800 | [diff] [blame] | 43 | return conv_params; |
| 44 | } |
Angie Chiang | 0a2c0cb | 2017-02-23 14:19:15 -0800 | [diff] [blame^] | 45 | struct AV1Common; |
| 46 | void av1_convolve_init(struct AV1Common *cm); |
Angie Chiang | dbfec2a | 2017-02-01 15:04:59 -0800 | [diff] [blame] | 47 | #if CONFIG_CONVOLVE_ROUND |
Angie Chiang | 7927a97 | 2017-02-02 18:13:04 -0800 | [diff] [blame] | 48 | void av1_convolve_2d(const uint8_t *src, int src_stride, CONV_BUF_TYPE *dst, |
| 49 | int dst_stride, int w, int h, |
| 50 | InterpFilterParams *filter_params_x, |
| 51 | InterpFilterParams *filter_params_y, const int subpel_x_q4, |
| 52 | const int subpel_y_q4, ConvolveParams *conv_params); |
| 53 | |
| 54 | void av1_convolve_2d_facade(const uint8_t *src, int src_stride, uint8_t *dst, |
| 55 | int dst_stride, int w, int h, |
| 56 | const InterpFilter *interp_filter, |
| 57 | const int subpel_x_q4, int x_step_q4, |
| 58 | const int subpel_y_q4, int y_step_q4, |
| 59 | ConvolveParams *conv_params); |
| 60 | |
Angie Chiang | e3a4c1c | 2017-02-10 16:26:49 -0800 | [diff] [blame] | 61 | static INLINE ConvolveParams get_conv_params_no_round(int ref, int plane, |
| 62 | int32_t *dst, |
Angie Chiang | 117aa0d | 2017-01-18 15:27:03 -0800 | [diff] [blame] | 63 | int dst_stride) { |
| 64 | ConvolveParams conv_params; |
| 65 | conv_params.ref = ref; |
| 66 | conv_params.round = CONVOLVE_OPT_NO_ROUND; |
Angie Chiang | 7927a97 | 2017-02-02 18:13:04 -0800 | [diff] [blame] | 67 | conv_params.round_0 = 5; |
Angie Chiang | a3a30c4 | 2017-02-21 10:36:01 -0800 | [diff] [blame] | 68 | conv_params.round_1 = 0; |
Angie Chiang | 117aa0d | 2017-01-18 15:27:03 -0800 | [diff] [blame] | 69 | conv_params.dst = dst; |
| 70 | conv_params.dst_stride = dst_stride; |
Angie Chiang | e3a4c1c | 2017-02-10 16:26:49 -0800 | [diff] [blame] | 71 | conv_params.plane = plane; |
Angie Chiang | 117aa0d | 2017-01-18 15:27:03 -0800 | [diff] [blame] | 72 | return conv_params; |
| 73 | } |
| 74 | |
| 75 | 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] | 76 | int dst_stride, int w, int h, int bits); |
Angie Chiang | dbfec2a | 2017-02-01 15:04:59 -0800 | [diff] [blame] | 77 | #endif // CONFIG_CONVOLVE_ROUND |
Angie Chiang | 117aa0d | 2017-01-18 15:27:03 -0800 | [diff] [blame] | 78 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 79 | void av1_convolve(const uint8_t *src, int src_stride, uint8_t *dst, |
| 80 | int dst_stride, int w, int h, |
| 81 | #if CONFIG_DUAL_FILTER |
James Zern | 7b9407a | 2016-05-18 23:48:05 -0700 | [diff] [blame] | 82 | const InterpFilter *interp_filter, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 83 | #else |
James Zern | 7b9407a | 2016-05-18 23:48:05 -0700 | [diff] [blame] | 84 | const InterpFilter interp_filter, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 85 | #endif |
| 86 | const int subpel_x, int xstep, const int subpel_y, int ystep, |
Angie Chiang | 674bffd | 2017-01-11 16:15:55 -0800 | [diff] [blame] | 87 | ConvolveParams *conv_params); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 88 | |
| 89 | #if CONFIG_AOM_HIGHBITDEPTH |
| 90 | void av1_highbd_convolve(const uint8_t *src, int src_stride, uint8_t *dst, |
| 91 | int dst_stride, int w, int h, |
| 92 | #if CONFIG_DUAL_FILTER |
James Zern | 7b9407a | 2016-05-18 23:48:05 -0700 | [diff] [blame] | 93 | const InterpFilter *interp_filter, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 94 | #else |
James Zern | 7b9407a | 2016-05-18 23:48:05 -0700 | [diff] [blame] | 95 | const InterpFilter interp_filter, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 96 | #endif |
| 97 | const int subpel_x, int xstep, const int subpel_y, |
| 98 | int ystep, int avg, int bd); |
| 99 | #endif // CONFIG_AOM_HIGHBITDEPTH |
| 100 | |
| 101 | #ifdef __cplusplus |
| 102 | } // extern "C" |
| 103 | #endif |
| 104 | |
| 105 | #endif // AV1_COMMON_AV1_CONVOLVE_H_ |