Line data Source code
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 :
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 :
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 :
26 : typedef int32_t CONV_BUF_TYPE;
27 :
28 : typedef struct ConvolveParams {
29 : int ref;
30 : CONVOLVE_OPT round;
31 : CONV_BUF_TYPE *dst;
32 : int dst_stride;
33 : int round_0;
34 : int round_1;
35 : int plane;
36 : int do_post_rounding;
37 : } ConvolveParams;
38 :
39 0 : static INLINE ConvolveParams get_conv_params(int ref, int plane) {
40 : ConvolveParams conv_params;
41 0 : conv_params.ref = ref;
42 0 : conv_params.round = CONVOLVE_OPT_ROUND;
43 0 : conv_params.plane = plane;
44 0 : conv_params.do_post_rounding = 0;
45 0 : return conv_params;
46 : }
47 : struct AV1Common;
48 : void av1_convolve_init(struct AV1Common *cm);
49 : #if CONFIG_CONVOLVE_ROUND
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 :
63 : static INLINE ConvolveParams get_conv_params_no_round(int ref, int plane,
64 : int32_t *dst,
65 : int dst_stride) {
66 : ConvolveParams conv_params;
67 : conv_params.ref = ref;
68 : conv_params.round = CONVOLVE_OPT_NO_ROUND;
69 : #if CONFIG_COMPOUND_ROUND
70 : conv_params.round_0 = FILTER_BITS;
71 : #else
72 : conv_params.round_0 = 5;
73 : #endif
74 : conv_params.round_1 = 0;
75 : conv_params.dst = dst;
76 : conv_params.dst_stride = dst_stride;
77 : conv_params.plane = plane;
78 : conv_params.do_post_rounding = 0;
79 : return conv_params;
80 : }
81 :
82 : void av1_convolve_rounding(const int32_t *src, int src_stride, uint8_t *dst,
83 : int dst_stride, int w, int h, int bits);
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
104 : #endif // CONFIG_CONVOLVE_ROUND
105 :
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
109 : const InterpFilter *interp_filter,
110 : #else
111 : const InterpFilter interp_filter,
112 : #endif
113 : const int subpel_x, int xstep, const int subpel_y, int ystep,
114 : ConvolveParams *conv_params);
115 :
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 :
126 : #if CONFIG_HIGHBITDEPTH
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
130 : const InterpFilter *interp_filter,
131 : #else
132 : const InterpFilter interp_filter,
133 : #endif
134 : const int subpel_x, int xstep, const int subpel_y,
135 : int ystep, int avg, int bd);
136 : #endif // CONFIG_HIGHBITDEPTH
137 :
138 : #ifdef __cplusplus
139 : } // extern "C"
140 : #endif
141 :
142 : #endif // AV1_COMMON_AV1_CONVOLVE_H_
|