1 /******************************************************************************
2  *
3  * Copyright (C) 2018 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *****************************************************************************
18  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20 /*!
21 ******************************************************************************
22 * \file ihevce_had_satd.h
23 *
24 * \brief
25 *    This file contains function prototypes of HAD and SATD functions
26 *
27 * \date
28 *    18/09/2012
29 *
30 * \author
31 *    Ittiam
32 *
33 ******************************************************************************
34 */
35 
36 #ifndef _IHEVCE_HAD_SATD_H_
37 #define _IHEVCE_HAD_SATD_H_
38 
39 /*****************************************************************************/
40 /* Constant Macros                                                           */
41 /*****************************************************************************/
42 
43 /*****************************************************************************/
44 /* Function Macros                                                           */
45 /*****************************************************************************/
46 
47 /*****************************************************************************/
48 /* Typedefs                                                                  */
49 /*****************************************************************************/
50 
51 /*****************************************************************************/
52 /* Enums                                                                     */
53 /*****************************************************************************/
54 
55 /* @breif enum for hadamard transform block sizes supported : 4x4 to 32x32 */
56 typedef enum
57 {
58     HAD_4x4 = 0,
59     HAD_8x8 = 1,
60     HAD_16x16 = 2,
61     HAD_32x32 = 3,
62     HAD_INVALID = 4
63 } HAD_SIZE_T;
64 
65 /*****************************************************************************/
66 /* Structure                                                                 */
67 /*****************************************************************************/
68 
69 /*****************************************************************************/
70 /* Extern Function Declarations                                              */
71 /*****************************************************************************/
72 
73 UWORD32 ihevce_HAD_4x4_8bit(
74     UWORD8 *pu1_origin,
75     WORD32 src_strd,
76     UWORD8 *pu1_pred_buf,
77     WORD32 pred_strd,
78     WORD16 *pi2_dst,
79     WORD32 dst_strd);
80 
81 UWORD32 ihevce_HAD_8x8_8bit(
82     UWORD8 *pu1_origin,
83     WORD32 src_strd,
84     UWORD8 *pu1_pred_buf,
85     WORD32 pred_strd,
86     WORD16 *pi2_dst,
87     WORD32 dst_strd);
88 
89 UWORD32 ihevce_compute_ac_had_8x8_8bit(
90     UWORD8 *pu1_origin,
91     WORD32 src_strd,
92     UWORD8 *pu1_pred_buf,
93     WORD32 pred_strd,
94     WORD16 *pi2_dst,
95     WORD32 dst_strd);
96 
97 UWORD32 ihevce_HAD_16x16_8bit(
98     UWORD8 *pu1_origin,
99     WORD32 src_strd,
100     UWORD8 *pu1_pred_buf,
101     WORD32 pred_strd,
102     WORD16 *pi2_dst,
103     WORD32 dst_strd);
104 
105 UWORD32 ihevce_HAD_32x32_8bit(
106     UWORD8 *pu1_origin,
107     WORD32 src_strd,
108     UWORD8 *pu1_pred_buf,
109     WORD32 pred_strd,
110     WORD16 *pi2_dst,
111     WORD32 dst_strd);
112 
113 typedef WORD32 FT_HAD_16X16_R(
114     UWORD8 *pu1_src,
115     WORD32 src_strd,
116     UWORD8 *pu1_pred,
117     WORD32 pred_strd,
118     WORD16 *pi2_dst,
119     WORD32 dst_strd,
120     WORD32 **ppi4_hsad,
121     WORD32 **ppi4_tu_split,
122     WORD32 **ppi4_tu_early_cbf,
123     WORD32 pos_x_y_4x4,
124     WORD32 num_4x4_in_row,
125     WORD32 lambda,
126     WORD32 lambda_q_shift,
127     WORD32 i4_frm_qstep,
128     WORD32 i4_cur_depth,
129     WORD32 i4_max_depth,
130     WORD32 i4_max_tr_size,
131     WORD32 *pi4_tu_split_cost,
132     void *pv_func_sel);
133 
134 typedef UWORD32 FT_HAD_32X32_USING_16X16(
135     WORD16 *pi2_16x16_had,
136     WORD32 had16_strd,
137     WORD16 *pi2_dst,
138     WORD32 dst_strd,
139     WORD32 i4_frm_qstep,
140     WORD32 *pi4_cbf);
141 
142 typedef UWORD32 ihevce_compute_16x16HAD_using_8x8_ft(
143     WORD16 *pi2_8x8_had,
144     WORD32 had8_strd,
145     WORD16 *pi2_dst,
146     WORD32 dst_strd,
147     WORD32 i4_frm_qstep,
148     WORD32 *pi4_cbf);
149 
150 typedef WORD32 FT_HAD_8X8_USING_4_4X4_R(
151     UWORD8 *pu1_src,
152     WORD32 src_strd,
153     UWORD8 *pu1_pred,
154     WORD32 pred_strd,
155     WORD16 *pi2_dst,
156     WORD32 dst_strd,
157     WORD32 **ppi4_hsad,
158     WORD32 **ppi4_tu_split,
159     WORD32 **ppi4_tu_early_cbf,
160     WORD32 pos_x_y_4x4,
161     WORD32 num_4x4_in_row,
162     WORD32 lambda,
163     WORD32 lambda_q_shift,
164     WORD32 i4_frm_qstep,
165     WORD32 i4_cur_depth,
166     WORD32 i4_max_depth,
167     WORD32 i4_max_tr_size,
168     WORD32 *pi4_tu_split_cost,
169     void *pv_func_sel);
170 
171 WORD32 ihevce_had_16x16_r_noise_detect(
172     UWORD8 *pu1_src,
173     WORD32 src_strd,
174     UWORD8 *pu1_pred,
175     WORD32 pred_strd,
176     WORD16 *pi2_dst,
177     WORD32 dst_strd,
178     WORD32 pos_x_y_4x4,
179     WORD32 num_4x4_in_row,
180     WORD32 scaling_for_pred);
181 
182 UWORD32 ihevce_compute_8x8HAD_using_4x4_noise_detect(
183     WORD16 *pi2_4x4_had,
184     WORD32 had4_strd,
185     WORD16 *pi2_dst,
186     WORD32 dst_strd,
187     WORD32 i4_frm_qstep,
188     WORD32 *pi4_cbf);
189 void ihevce_had4_4x4_noise_detect(
190     UWORD8 *pu1_src,
191     WORD32 src_strd,
192     UWORD8 *pu1_pred,
193     WORD32 pred_strd,
194     WORD16 *pi2_dst4x4,
195     WORD16 *pi2_residue,
196     WORD32 dst_strd,
197     WORD32 scaling_for_pred);
198 
199 void ihevce_had_8x8_using_4_4x4_noise_detect(
200     UWORD8 *pu1_src,
201     WORD32 src_strd,
202     UWORD8 *pu1_pred,
203     WORD32 pred_strd,
204     WORD16 *pi2_dst,
205     WORD32 dst_strd,
206     WORD32 pos_x_y_4x4,
207     WORD32 num_4x4_in_row,
208     WORD32 scaling_for_pred);
209 
210 void ihevce_had_8x8_using_4_4x4(
211     UWORD8 *pu1_src,
212     WORD32 src_strd,
213     UWORD8 *pu1_pred,
214     WORD32 pred_strd,
215     WORD16 *pi2_dst,
216     WORD32 dst_strd,
217     WORD32 **ppi4_hsad,
218     WORD32 pos_x_y_4x4,
219     WORD32 num_4x4_in_row);
220 
221 typedef void ihevce_had_nxn_r_ft(
222     UWORD8 *pu1_src,
223     WORD32 src_strd,
224     UWORD8 *pu1_pred,
225     WORD32 pred_strd,
226     WORD16 *pi2_dst,
227     WORD32 dst_strd,
228     WORD32 **ppi4_hsad,
229     WORD32 **ppi4_tu_split,
230     WORD32 **ppi4_tu_early_cbf,
231     WORD32 pos_x_y_4x4,
232     WORD32 num_4x4_in_row,
233     WORD32 lambda,
234     WORD32 lambda_q_shift,
235     WORD32 i4_frm_qstep,
236     WORD32 i4_cur_depth,
237     WORD32 i4_max_depth,
238     WORD32 i4_max_tr_size,
239     WORD32 *pi4_tu_split_cost,
240     void *pv_func_sel);
241 
242 UWORD32 ihevce_mat_add_shift_satd_16bit(
243     WORD16 *pi2_buf1,
244     WORD32 buf1_strd,
245     WORD16 *pi2_buf2,
246     WORD32 buf2_strd,
247     WORD16 *pi2_dst,
248     WORD32 dst_strd,
249     WORD32 size,
250     WORD32 shift,
251     WORD32 threshold,
252     WORD32 *pi4_cbf);
253 
254 UWORD32 ihevce_mat_sub_shift_satd_16bit(
255     WORD16 *pi2_buf1,
256     WORD32 buf1_strd,
257     WORD16 *pi2_buf2,
258     WORD32 buf2_strd,
259     WORD16 *pi2_dst,
260     WORD32 dst_strd,
261     WORD32 size,
262     WORD32 shift,
263     WORD32 threshold,
264     WORD32 *pi4_cbf);
265 
266 void ihevce_mat_add_16bit(
267     WORD16 *pi2_buf1,
268     WORD32 buf1_strd,
269     WORD16 *pi2_buf2,
270     WORD32 buf2_strd,
271     WORD16 *pi2_dst,
272     WORD32 dst_strd,
273     WORD32 size,
274     WORD32 threshold);
275 
276 void ihevce_mat_sub_16bit(
277     WORD16 *pi2_buf1,
278     WORD32 buf1_strd,
279     WORD16 *pi2_buf2,
280     WORD32 buf2_strd,
281     WORD16 *pi2_dst,
282     WORD32 dst_strd,
283     WORD32 size,
284     WORD32 threshold);
285 
286 UWORD32 ihevce_compute_16x16HAD_using_8x8_noise_detect(
287     WORD16 *pi2_8x8_had,
288     WORD32 had8_strd,
289     WORD16 *pi2_dst,
290     WORD32 dst_strd,
291     WORD32 i4_frm_qstep,
292     WORD32 *pi4_cbf);
293 
294 /******* C declarations ****************/
295 FT_HAD_8X8_USING_4_4X4_R ihevce_had_8x8_using_4_4x4_r;
296 FT_HAD_16X16_R ihevce_had_16x16_r;
297 FT_HAD_32X32_USING_16X16 ihevce_compute_32x32HAD_using_16x16;
298 
299 /******** A9Q declarations **********/
300 FT_HAD_8X8_USING_4_4X4_R ihevce_had_8x8_using_4_4x4_r_neon;
301 FT_HAD_16X16_R ihevce_had_16x16_r_neon;
302 FT_HAD_32X32_USING_16X16 ihevce_compute_32x32HAD_using_16x16_neon;
303 
304 #endif /* _IHEVCE_HAD_SATD_H_ */
305