blob: 48b476ed5b7fcb7a12d3992b646bd7bc7f24cba2 [file] [log] [blame]
Angie Chiang64211912016-10-25 15:09:56 -07001/*
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 Xuf883b422016-08-30 14:01:10 -070012#ifndef AV1_COMMON_AV1_CONVOLVE_H_
13#define AV1_COMMON_AV1_CONVOLVE_H_
14#include "av1/common/filter.h"
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
Angie Chiang9f45bc42017-01-13 16:27:54 -080020typedef 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 Chiang7927a972017-02-02 18:13:04 -080026typedef int32_t CONV_BUF_TYPE;
27
Angie Chiang674bffd2017-01-11 16:15:55 -080028typedef struct ConvolveParams {
29 int ref;
Angie Chiang9f45bc42017-01-13 16:27:54 -080030 CONVOLVE_OPT round;
Angie Chiang7927a972017-02-02 18:13:04 -080031 CONV_BUF_TYPE *dst;
Angie Chiangf7159222017-01-18 12:51:12 -080032 int dst_stride;
Angie Chiang7927a972017-02-02 18:13:04 -080033 int round_0;
34 int round_1;
Angie Chiange3a4c1c2017-02-10 16:26:49 -080035 int plane;
Angie Chiang05685e92017-05-08 12:55:39 -070036 int do_post_rounding;
Angie Chiang674bffd2017-01-11 16:15:55 -080037} ConvolveParams;
38
Angie Chiange3a4c1c2017-02-10 16:26:49 -080039static INLINE ConvolveParams get_conv_params(int ref, int plane) {
Angie Chiang9f45bc42017-01-13 16:27:54 -080040 ConvolveParams conv_params;
41 conv_params.ref = ref;
42 conv_params.round = CONVOLVE_OPT_ROUND;
Angie Chiange3a4c1c2017-02-10 16:26:49 -080043 conv_params.plane = plane;
Angie Chiang05685e92017-05-08 12:55:39 -070044 conv_params.do_post_rounding = 0;
Angie Chiang9f45bc42017-01-13 16:27:54 -080045 return conv_params;
46}
Angie Chiang0a2c0cb2017-02-23 14:19:15 -080047struct AV1Common;
48void av1_convolve_init(struct AV1Common *cm);
Angie Chiangdbfec2a2017-02-01 15:04:59 -080049#if CONFIG_CONVOLVE_ROUND
Angie Chiang7927a972017-02-02 18:13:04 -080050void 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
56void 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 Chiange3a4c1c2017-02-10 16:26:49 -080063static INLINE ConvolveParams get_conv_params_no_round(int ref, int plane,
64 int32_t *dst,
Angie Chiang117aa0d2017-01-18 15:27:03 -080065 int dst_stride) {
66 ConvolveParams conv_params;
67 conv_params.ref = ref;
68 conv_params.round = CONVOLVE_OPT_NO_ROUND;
Angie Chiangf87d8372017-04-21 11:23:56 -070069#if CONFIG_COMPOUND_ROUND
70 conv_params.round_0 = FILTER_BITS;
71#else
Angie Chiang7927a972017-02-02 18:13:04 -080072 conv_params.round_0 = 5;
Angie Chiangf87d8372017-04-21 11:23:56 -070073#endif
Angie Chianga3a30c42017-02-21 10:36:01 -080074 conv_params.round_1 = 0;
Angie Chiang117aa0d2017-01-18 15:27:03 -080075 conv_params.dst = dst;
76 conv_params.dst_stride = dst_stride;
Angie Chiange3a4c1c2017-02-10 16:26:49 -080077 conv_params.plane = plane;
Angie Chiang05685e92017-05-08 12:55:39 -070078 conv_params.do_post_rounding = 0;
Angie Chiang117aa0d2017-01-18 15:27:03 -080079 return conv_params;
80}
81
82void av1_convolve_rounding(const int32_t *src, int src_stride, uint8_t *dst,
Angie Chiang7927a972017-02-02 18:13:04 -080083 int dst_stride, int w, int h, int bits);
Angie Chiangb03545b2017-05-05 12:07:30 -070084
85#if CONFIG_HIGHBITDEPTH
86void 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
90void 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
97void 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 Chiangdbfec2a2017-02-01 15:04:59 -0800104#endif // CONFIG_CONVOLVE_ROUND
Angie Chiang117aa0d2017-01-18 15:27:03 -0800105
Yaowu Xuf883b422016-08-30 14:01:10 -0700106void 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 Zern7b9407a2016-05-18 23:48:05 -0700109 const InterpFilter *interp_filter,
Yaowu Xuf883b422016-08-30 14:01:10 -0700110#else
James Zern7b9407a2016-05-18 23:48:05 -0700111 const InterpFilter interp_filter,
Yaowu Xuf883b422016-08-30 14:01:10 -0700112#endif
113 const int subpel_x, int xstep, const int subpel_y, int ystep,
Angie Chiang674bffd2017-01-11 16:15:55 -0800114 ConvolveParams *conv_params);
Yaowu Xuf883b422016-08-30 14:01:10 -0700115
Fergus Simpsonfc593892017-04-06 12:19:06 -0700116void 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 Alaiwan71e87842017-04-12 16:03:28 +0200126#if CONFIG_HIGHBITDEPTH
Yaowu Xuf883b422016-08-30 14:01:10 -0700127void 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 Zern7b9407a2016-05-18 23:48:05 -0700130 const InterpFilter *interp_filter,
Yaowu Xuf883b422016-08-30 14:01:10 -0700131#else
James Zern7b9407a2016-05-18 23:48:05 -0700132 const InterpFilter interp_filter,
Yaowu Xuf883b422016-08-30 14:01:10 -0700133#endif
134 const int subpel_x, int xstep, const int subpel_y,
135 int ystep, int avg, int bd);
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200136#endif // CONFIG_HIGHBITDEPTH
Yaowu Xuf883b422016-08-30 14:01:10 -0700137
138#ifdef __cplusplus
139} // extern "C"
140#endif
141
142#endif // AV1_COMMON_AV1_CONVOLVE_H_