blob: 88b413d70f70965da4354efa708938f00f6cef66 [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 Chiang674bffd2017-01-11 16:15:55 -080035} ConvolveParams;
36
Angie Chiang9f45bc42017-01-13 16:27:54 -080037static INLINE ConvolveParams get_conv_params(int ref) {
38 ConvolveParams conv_params;
39 conv_params.ref = ref;
40 conv_params.round = CONVOLVE_OPT_ROUND;
41 return conv_params;
42}
43
Angie Chiangdbfec2a2017-02-01 15:04:59 -080044#if CONFIG_CONVOLVE_ROUND
Angie Chiang7927a972017-02-02 18:13:04 -080045void av1_convolve_2d(const uint8_t *src, int src_stride, CONV_BUF_TYPE *dst,
46 int dst_stride, int w, int h,
47 InterpFilterParams *filter_params_x,
48 InterpFilterParams *filter_params_y, const int subpel_x_q4,
49 const int subpel_y_q4, ConvolveParams *conv_params);
50
51void av1_convolve_2d_facade(const uint8_t *src, int src_stride, uint8_t *dst,
52 int dst_stride, int w, int h,
53 const InterpFilter *interp_filter,
54 const int subpel_x_q4, int x_step_q4,
55 const int subpel_y_q4, int y_step_q4,
56 ConvolveParams *conv_params);
57
Angie Chiang117aa0d2017-01-18 15:27:03 -080058static INLINE ConvolveParams get_conv_params_no_round(int ref, int32_t *dst,
59 int dst_stride) {
60 ConvolveParams conv_params;
61 conv_params.ref = ref;
62 conv_params.round = CONVOLVE_OPT_NO_ROUND;
Angie Chiang7927a972017-02-02 18:13:04 -080063 conv_params.round_0 = 5;
64 conv_params.round_1 = 1;
Angie Chiang117aa0d2017-01-18 15:27:03 -080065 conv_params.dst = dst;
66 conv_params.dst_stride = dst_stride;
67 return conv_params;
68}
69
70void av1_convolve_rounding(const int32_t *src, int src_stride, uint8_t *dst,
Angie Chiang7927a972017-02-02 18:13:04 -080071 int dst_stride, int w, int h, int bits);
Angie Chiangdbfec2a2017-02-01 15:04:59 -080072#endif // CONFIG_CONVOLVE_ROUND
Angie Chiang117aa0d2017-01-18 15:27:03 -080073
Yaowu Xuf883b422016-08-30 14:01:10 -070074void av1_convolve(const uint8_t *src, int src_stride, uint8_t *dst,
75 int dst_stride, int w, int h,
76#if CONFIG_DUAL_FILTER
James Zern7b9407a2016-05-18 23:48:05 -070077 const InterpFilter *interp_filter,
Yaowu Xuf883b422016-08-30 14:01:10 -070078#else
James Zern7b9407a2016-05-18 23:48:05 -070079 const InterpFilter interp_filter,
Yaowu Xuf883b422016-08-30 14:01:10 -070080#endif
81 const int subpel_x, int xstep, const int subpel_y, int ystep,
Angie Chiang674bffd2017-01-11 16:15:55 -080082 ConvolveParams *conv_params);
Yaowu Xuf883b422016-08-30 14:01:10 -070083
84#if CONFIG_AOM_HIGHBITDEPTH
85void av1_highbd_convolve(const uint8_t *src, int src_stride, uint8_t *dst,
86 int dst_stride, int w, int h,
87#if CONFIG_DUAL_FILTER
James Zern7b9407a2016-05-18 23:48:05 -070088 const InterpFilter *interp_filter,
Yaowu Xuf883b422016-08-30 14:01:10 -070089#else
James Zern7b9407a2016-05-18 23:48:05 -070090 const InterpFilter interp_filter,
Yaowu Xuf883b422016-08-30 14:01:10 -070091#endif
92 const int subpel_x, int xstep, const int subpel_y,
93 int ystep, int avg, int bd);
94#endif // CONFIG_AOM_HIGHBITDEPTH
95
96#ifdef __cplusplus
97} // extern "C"
98#endif
99
100#endif // AV1_COMMON_AV1_CONVOLVE_H_