blob: 471152e528f7290a7c9b1d54161a31bb8ec52f8a [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 Chiang674bffd2017-01-11 16:15:55 -080036} ConvolveParams;
37
Angie Chiange3a4c1c2017-02-10 16:26:49 -080038static INLINE ConvolveParams get_conv_params(int ref, int plane) {
Angie Chiang9f45bc42017-01-13 16:27:54 -080039 ConvolveParams conv_params;
40 conv_params.ref = ref;
41 conv_params.round = CONVOLVE_OPT_ROUND;
Angie Chiange3a4c1c2017-02-10 16:26:49 -080042 conv_params.plane = plane;
Angie Chiang9f45bc42017-01-13 16:27:54 -080043 return conv_params;
44}
Angie Chiang0a2c0cb2017-02-23 14:19:15 -080045struct AV1Common;
46void av1_convolve_init(struct AV1Common *cm);
Angie Chiangdbfec2a2017-02-01 15:04:59 -080047#if CONFIG_CONVOLVE_ROUND
Angie Chiang7927a972017-02-02 18:13:04 -080048void 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
54void 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 Chiange3a4c1c2017-02-10 16:26:49 -080061static INLINE ConvolveParams get_conv_params_no_round(int ref, int plane,
62 int32_t *dst,
Angie Chiang117aa0d2017-01-18 15:27:03 -080063 int dst_stride) {
64 ConvolveParams conv_params;
65 conv_params.ref = ref;
66 conv_params.round = CONVOLVE_OPT_NO_ROUND;
Angie Chiang7927a972017-02-02 18:13:04 -080067 conv_params.round_0 = 5;
Angie Chianga3a30c42017-02-21 10:36:01 -080068 conv_params.round_1 = 0;
Angie Chiang117aa0d2017-01-18 15:27:03 -080069 conv_params.dst = dst;
70 conv_params.dst_stride = dst_stride;
Angie Chiange3a4c1c2017-02-10 16:26:49 -080071 conv_params.plane = plane;
Angie Chiang117aa0d2017-01-18 15:27:03 -080072 return conv_params;
73}
74
75void av1_convolve_rounding(const int32_t *src, int src_stride, uint8_t *dst,
Angie Chiang7927a972017-02-02 18:13:04 -080076 int dst_stride, int w, int h, int bits);
Angie Chiangdbfec2a2017-02-01 15:04:59 -080077#endif // CONFIG_CONVOLVE_ROUND
Angie Chiang117aa0d2017-01-18 15:27:03 -080078
Yaowu Xuf883b422016-08-30 14:01:10 -070079void 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 Zern7b9407a2016-05-18 23:48:05 -070082 const InterpFilter *interp_filter,
Yaowu Xuf883b422016-08-30 14:01:10 -070083#else
James Zern7b9407a2016-05-18 23:48:05 -070084 const InterpFilter interp_filter,
Yaowu Xuf883b422016-08-30 14:01:10 -070085#endif
86 const int subpel_x, int xstep, const int subpel_y, int ystep,
Angie Chiang674bffd2017-01-11 16:15:55 -080087 ConvolveParams *conv_params);
Yaowu Xuf883b422016-08-30 14:01:10 -070088
89#if CONFIG_AOM_HIGHBITDEPTH
90void 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 Zern7b9407a2016-05-18 23:48:05 -070093 const InterpFilter *interp_filter,
Yaowu Xuf883b422016-08-30 14:01:10 -070094#else
James Zern7b9407a2016-05-18 23:48:05 -070095 const InterpFilter interp_filter,
Yaowu Xuf883b422016-08-30 14:01:10 -070096#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_