• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_me_instr_set_router.h
23 *
24 * \brief
25 *    This file contains declarations related to me utilities used in encoder
26 *
27 * \date
28 *    15/07/2013
29 *
30 * \author
31 *    Ittiam
32 *
33 * List of Functions
34 *
35 *
36 ******************************************************************************
37 */
38 
39 #ifndef __IHEVCE_ME_INSTR_SET_ROUTER_H_
40 #define __IHEVCE_ME_INSTR_SET_ROUTER_H_
41 
42 /*****************************************************************************/
43 /* Typedefs                                                                  */
44 /*****************************************************************************/
45 typedef void FT_SAD_EVALUATOR(err_prms_t *);
46 
47 typedef void FT_PART_SADS_EVALUATOR(
48     grid_ctxt_t *, UWORD8 *, WORD32, WORD32 **, cand_t *, WORD32 *, CU_SIZE_T);
49 
50 typedef void
51     FT_PART_SADS_EVALUATOR_16X16CU(grid_ctxt_t *, UWORD8 *, WORD32, UWORD16 **, cand_t *, WORD32 *);
52 
53 typedef void FT_CALC_SAD_AND_RESULT(
54     hme_search_prms_t *, wgt_pred_ctxt_t *, err_prms_t *, result_upd_prms_t *, U08 **, S32);
55 
56 typedef void FT_CALC_SAD_AND_RESULT_SUBPEL(err_prms_t *, result_upd_prms_t *);
57 
58 typedef void FT_QPEL_INTERP_AVG(interp_prms_t *, S32, S32, S32);
59 
60 typedef void FT_QPEL_INTERP_AVG_1PT(interp_prms_t *, S32, S32, S32, U08 **, S32 *);
61 
62 typedef void FT_QPEL_INTERP_AVG_2PT(interp_prms_t *, S32, S32, U08 **, S32 *);
63 
64 typedef void FT_GET_WT_INP(layer_ctxt_t *, wgt_pred_ctxt_t *, S32, S32, S32, S32, S32, U08);
65 
66 typedef void
67     FT_STORE_4X4_SADS(hme_search_prms_t *, layer_ctxt_t *, range_prms_t *, wgt_pred_ctxt_t *, S16 *);
68 
69 typedef void FT_COMBINE_4X4_SADS_AND_COMPUTE_COST(
70     S08,
71     range_prms_t *,
72     range_prms_t *,
73     hme_mv_t *,
74     hme_mv_t *,
75     pred_ctxt_t *,
76     PF_MV_COST_FXN,
77     S16 *,
78     S16 *,
79     S16 *);
80 
81 typedef void FT_MV_CLIPPER(hme_search_prms_t *, S32, S08, U08, U08, U08);
82 
83 typedef void FT_COMPUTE_VARIANCE(U08 *, S32, S32 *, U32 *, S32, U08);
84 
85 typedef void FT_COMPUTE_DISTORTION(
86     U08 *, S32, S32 *, ULWORD64 *, ULWORD64 *, S32 *, S32, S32, S32, S32, S32, U08);
87 
88 /*****************************************************************************/
89 /* Structure                                                                 */
90 /*****************************************************************************/
91 
92 // clang-format off
93 typedef struct
94 {
95     FT_SAD_EVALUATOR *pf_evalsad_pt_npu_mxn_8bit;
96     FT_SAD_EVALUATOR *pf_evalsad_grid_npu_MxN;
97     FT_SAD_EVALUATOR *pf_evalsad_pt_npu_8x4_8bit;
98     FT_SAD_EVALUATOR *pf_evalsad_pt_npu_16x4_8bit;
99     FT_SAD_EVALUATOR *pf_evalsad_pt_npu_16x12_8bit;
100     FT_SAD_EVALUATOR *pf_evalsad_pt_npu_24x32_8bit;
101     FT_SAD_EVALUATOR *pf_evalsad_pt_npu_12x16_8bit;
102     FT_SAD_EVALUATOR *pf_evalsad_pt_npu_width_multiple_4_8bit;
103     FT_SAD_EVALUATOR *pf_evalsad_pt_npu_width_multiple_8_8bit;
104     FT_SAD_EVALUATOR *pf_evalsad_pt_npu_width_multiple_16_8bit;
105     FT_PART_SADS_EVALUATOR_16X16CU *pf_compute_4x4_sads_for_16x16_blk;
106     FT_PART_SADS_EVALUATOR *pf_evalsad_grid_pu_MxM;
107     FT_CALC_SAD_AND_RESULT *pf_calc_sad_and_1_best_result_generic;
108     FT_CALC_SAD_AND_RESULT *pf_calc_stim_injected_sad_and_1_best_result_generic;
109     FT_CALC_SAD_AND_RESULT *pf_calc_stim_injected_sad_and_1_best_result_num_part_eq_1;
110     FT_CALC_SAD_AND_RESULT *pf_calc_stim_injected_sad_and_1_best_result_num_square_parts;
111     FT_CALC_SAD_AND_RESULT *pf_calc_stim_injected_sad_and_1_best_result_num_part_lt_9;
112     FT_CALC_SAD_AND_RESULT *pf_calc_stim_injected_sad_and_1_best_result_num_part_lt_17;
113     FT_CALC_SAD_AND_RESULT *pf_calc_sad_and_1_best_result_num_part_eq_1;
114     FT_CALC_SAD_AND_RESULT *pf_calc_sad_and_1_best_result_num_part_1_for_grid;
115     FT_CALC_SAD_AND_RESULT *pf_calc_sad_and_1_best_result_num_square_parts;
116     FT_CALC_SAD_AND_RESULT *pf_calc_sad_and_1_best_result_num_part_lt_9;
117     FT_CALC_SAD_AND_RESULT *pf_calc_sad_and_1_best_result_num_part_lt_17;
118     FT_CALC_SAD_AND_RESULT *pf_calc_pt_sad_and_1_best_result_explicit_generic;
119     FT_CALC_SAD_AND_RESULT *pf_calc_pt_sad_and_1_best_result_explicit_8x8;
120     FT_CALC_SAD_AND_RESULT *pf_calc_pt_sad_and_1_best_result_explicit_8x8_for_grid;
121     FT_CALC_SAD_AND_RESULT *pf_calc_pt_sad_and_1_best_result_explicit_8x8_4x4;
122     FT_CALC_SAD_AND_RESULT *pf_calc_pt_sad_and_2_best_results_explicit_generic;
123     FT_CALC_SAD_AND_RESULT *pf_calc_pt_sad_and_2_best_results_explicit_8x8;
124     FT_CALC_SAD_AND_RESULT *pf_calc_pt_sad_and_2_best_results_explicit_8x8_for_grid;
125     FT_CALC_SAD_AND_RESULT *pf_calc_pt_sad_and_2_best_results_explicit_8x8_4x4;
126     FT_CALC_SAD_AND_RESULT_SUBPEL *pf_calc_sad_and_1_best_result_subpel_generic;
127     FT_CALC_SAD_AND_RESULT_SUBPEL *pf_calc_sad_and_1_best_result_subpel_num_part_eq_1;
128     FT_CALC_SAD_AND_RESULT_SUBPEL *pf_calc_sad_and_1_best_result_subpel_square_parts;
129     FT_CALC_SAD_AND_RESULT_SUBPEL *pf_calc_sad_and_1_best_result_subpel_num_part_lt_9;
130     FT_CALC_SAD_AND_RESULT_SUBPEL *pf_calc_sad_and_1_best_result_subpel_num_part_lt_17;
131     FT_CALC_SAD_AND_RESULT *pf_calc_sad_and_2_best_results_generic;
132     FT_CALC_SAD_AND_RESULT *pf_calc_stim_injected_sad_and_2_best_results_generic;
133     FT_CALC_SAD_AND_RESULT *pf_calc_stim_injected_sad_and_2_best_results_num_part_eq_1;
134     FT_CALC_SAD_AND_RESULT *pf_calc_stim_injected_sad_and_2_best_results_num_square_parts;
135     FT_CALC_SAD_AND_RESULT *pf_calc_stim_injected_sad_and_2_best_results_num_part_lt_9;
136     FT_CALC_SAD_AND_RESULT *pf_calc_stim_injected_sad_and_2_best_results_num_part_lt_17;
137     FT_CALC_SAD_AND_RESULT *pf_calc_sad_and_2_best_results_num_part_eq_1;
138     FT_CALC_SAD_AND_RESULT *pf_calc_sad_and_2_best_results_num_part_1_for_grid;
139     FT_CALC_SAD_AND_RESULT *pf_calc_sad_and_2_best_results_num_square_parts;
140     FT_CALC_SAD_AND_RESULT *pf_calc_sad_and_2_best_results_num_part_lt_9;
141     FT_CALC_SAD_AND_RESULT *pf_calc_sad_and_2_best_results_num_part_lt_17;
142     FT_CALC_SAD_AND_RESULT_SUBPEL *pf_calc_sad_and_2_best_results_subpel_generic;
143     FT_CALC_SAD_AND_RESULT_SUBPEL *pf_calc_sad_and_2_best_results_subpel_num_part_eq_1;
144     FT_CALC_SAD_AND_RESULT_SUBPEL *pf_calc_sad_and_2_best_results_subpel_square_parts;
145     FT_CALC_SAD_AND_RESULT_SUBPEL *pf_calc_sad_and_2_best_results_subpel_num_part_lt_9;
146     FT_CALC_SAD_AND_RESULT_SUBPEL *pf_calc_sad_and_2_best_results_subpel_num_part_lt_17;
147     FT_QPEL_INTERP_AVG *pf_qpel_interp_avg_generic;
148     FT_QPEL_INTERP_AVG_1PT *pf_qpel_interp_avg_1pt;
149     FT_QPEL_INTERP_AVG_2PT *pf_qpel_interp_avg_2pt_vert_with_reuse;
150     FT_QPEL_INTERP_AVG_2PT *pf_qpel_interp_avg_2pt_horz_with_reuse;
151     FT_GET_WT_INP *pf_get_wt_inp_generic;
152     FT_GET_WT_INP *pf_get_wt_inp_8x8;
153     FT_GET_WT_INP *pf_get_wt_inp_ctb;
154     FT_STORE_4X4_SADS *pf_store_4x4_sads_high_speed;
155     FT_STORE_4X4_SADS *pf_store_4x4_sads_high_quality;
156     FT_COMBINE_4X4_SADS_AND_COMPUTE_COST *pf_combine_4x4_sads_and_compute_cost_high_speed;
157     FT_COMBINE_4X4_SADS_AND_COMPUTE_COST *pf_combine_4x4_sads_and_compute_cost_high_quality;
158     FT_MV_CLIPPER *pf_mv_clipper;
159     FT_COMPUTE_VARIANCE *pf_compute_variance_for_all_parts;
160     FT_COMPUTE_DISTORTION *pf_compute_stim_injected_distortion_for_all_parts;
161 } ihevce_me_optimised_function_list_t;
162 
163 /*****************************************************************************/
164 /* Extern Function Declarations                                              */
165 /*****************************************************************************/
166 
167 void ihevce_me_instr_set_router(
168     ihevce_me_optimised_function_list_t *ps_func_list, IV_ARCH_T e_arch);
169 
170 PF_SAD_FXN_T hme_get_sad_fxn(
171     BLK_SIZE_T e_blk_size, S32 i4_grid_mask, S32 i4_part_mask);
172 
173 void ihevce_sifter_sad_fxn_assigner(
174     FT_SAD_EVALUATOR **ppf_evalsad_pt_npu_mxn, IV_ARCH_T e_arch);
175 
176 void hme_evalsad_grid_pu_MxM(err_prms_t *ps_prms);
177 
178 FT_CALC_SAD_AND_RESULT *hme_get_calc_sad_and_result_fxn(S08 i1_grid_flag,
179     U08 u1_is_cu_noisy, S32 i4_part_mask, S32 num_parts, S32 num_results);
180 
181 /* Function List - C */
182 FT_SAD_EVALUATOR hme_evalsad_pt_npu_MxN_8bit;
183 FT_SAD_EVALUATOR hme_evalsad_grid_npu_MxN;
184 FT_PART_SADS_EVALUATOR compute_part_sads_for_MxM_blk;
185 FT_PART_SADS_EVALUATOR_16X16CU compute_4x4_sads_for_16x16_blk;
186 FT_CALC_SAD_AND_RESULT hme_calc_sad_and_1_best_result;
187 FT_CALC_SAD_AND_RESULT hme_calc_stim_injected_sad_and_1_best_result;
188 FT_CALC_SAD_AND_RESULT hme_calc_pt_sad_and_result_explicit;
189 FT_CALC_SAD_AND_RESULT_SUBPEL hme_calc_sad_and_1_best_result_subpel;
190 FT_CALC_SAD_AND_RESULT hme_calc_sad_and_2_best_results;
191 FT_CALC_SAD_AND_RESULT hme_calc_stim_injected_sad_and_2_best_results;
192 FT_CALC_SAD_AND_RESULT_SUBPEL hme_calc_sad_and_2_best_results_subpel;
193 FT_QPEL_INTERP_AVG hme_qpel_interp_avg;
194 FT_QPEL_INTERP_AVG_1PT hme_qpel_interp_avg_1pt;
195 FT_QPEL_INTERP_AVG_2PT hme_qpel_interp_avg_2pt_vert_with_reuse;
196 FT_QPEL_INTERP_AVG_2PT hme_qpel_interp_avg_2pt_horz_with_reuse;
197 FT_GET_WT_INP hme_get_wt_inp;
198 FT_STORE_4X4_SADS hme_store_4x4_sads_high_speed;
199 FT_STORE_4X4_SADS hme_store_4x4_sads_high_quality;
200 FT_COMBINE_4X4_SADS_AND_COMPUTE_COST hme_combine_4x4_sads_and_compute_cost_high_speed;
201 FT_COMBINE_4X4_SADS_AND_COMPUTE_COST hme_combine_4x4_sads_and_compute_cost_high_quality;
202 FT_MV_CLIPPER hme_mv_clipper;
203 FT_COMPUTE_VARIANCE hme_compute_variance_for_all_parts;
204 FT_COMPUTE_DISTORTION hme_compute_stim_injected_distortion_for_all_parts;
205 
206 
207 /* Function List - Neon */
208 #ifdef ENABLE_NEON
209 FT_SAD_EVALUATOR hme_evalsad_pt_npu_MxN_8bit_neon;
210 FT_SAD_EVALUATOR hme_evalsad_grid_npu_MxN_neon;
211 FT_PART_SADS_EVALUATOR compute_part_sads_for_MxM_blk_neon;
212 FT_PART_SADS_EVALUATOR_16X16CU compute_4x4_sads_for_16x16_blk_neon;
213 FT_CALC_SAD_AND_RESULT hme_calc_sad_and_1_best_result_neon;
214 FT_CALC_SAD_AND_RESULT_SUBPEL hme_calc_sad_and_1_best_result_subpel_neon;
215 FT_QPEL_INTERP_AVG hme_qpel_interp_avg_neon;
216 FT_QPEL_INTERP_AVG_1PT hme_qpel_interp_avg_1pt_neon;
217 FT_QPEL_INTERP_AVG_2PT hme_qpel_interp_avg_2pt_vert_with_reuse_neon;
218 FT_QPEL_INTERP_AVG_2PT hme_qpel_interp_avg_2pt_horz_with_reuse_neon;
219 FT_GET_WT_INP hme_get_wt_inp_8x8_neon;
220 FT_GET_WT_INP hme_get_wt_inp_ctb_neon;
221 FT_STORE_4X4_SADS hme_store_4x4_sads_high_speed_neon;
222 FT_STORE_4X4_SADS hme_store_4x4_sads_high_quality_neon;
223 FT_COMBINE_4X4_SADS_AND_COMPUTE_COST hme_combine_4x4_sads_and_compute_cost_high_speed_neon;
224 FT_COMBINE_4X4_SADS_AND_COMPUTE_COST hme_combine_4x4_sads_and_compute_cost_high_quality_neon;
225 #endif
226 
227 // clang-format on
228 
229 #endif
230