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 hme_globals.h 23 * 24 * \brief 25 * Contains all the global declarations used by HME 26 * 27 * \date 28 * 18/09/2012 29 * 30 * \author 31 * Ittiam 32 * 33 ****************************************************************************** 34 */ 35 36 #ifndef _HME_GLOBALS_H_ 37 38 /*****************************************************************************/ 39 /* File Includes */ 40 /*****************************************************************************/ 41 42 /*****************************************************************************/ 43 /* Globals */ 44 /*****************************************************************************/ 45 46 /** 47 ****************************************************************************** 48 * @brief Converts an encode order to raster order x coord. Meant for 16x16 49 * CU within 64x64 or within 32x32 50 ****************************************************************************** 51 */ 52 extern U08 gau1_encode_to_raster_x[16]; 53 54 /** 55 ****************************************************************************** 56 * @brief Converts an encode order to raster order y coord. Meant for 16x16 57 * CU within 64x64 or within 32x32 58 ****************************************************************************** 59 */ 60 extern U08 gau1_encode_to_raster_y[16]; 61 62 /** 63 ****************************************************************************** 64 * @brief Given a CU id within the bigger CU (0..3), and the partition type 65 * currently within the small CU, we can figure out candidate 66 * partition types for bigger CU. E.g. IF CU id is 0, and is AMP of 67 * nLx2N, candidate partitions for bigger CU are nLx2N and 2Nx2N 68 ****************************************************************************** 69 */ 70 extern PART_TYPE_T ge_part_type_to_merge_part[4][MAX_PART_TYPES][3]; 71 72 /** 73 ****************************************************************************** 74 * @brief A given partition type has 1,2 or 4 partitions, each corresponding 75 * to a unique partition id PART_ID_T enum type. So, this global converts 76 * partition type to a bitmask of corresponding partition ids. 77 ****************************************************************************** 78 */ 79 extern S32 gai4_part_type_to_part_mask[MAX_PART_TYPES]; 80 81 /** 82 ****************************************************************************** 83 * @brief Reads out the index of function pointer to a sad_compute function 84 * of blk given a blk size enumeration 85 ****************************************************************************** 86 */ 87 extern U08 gau1_blk_size_to_fp[NUM_BLK_SIZES]; 88 89 /** 90 ****************************************************************************** 91 * @brief Reads out the width of blk given a blk size enumeration 92 ****************************************************************************** 93 */ 94 extern U08 gau1_blk_size_to_wd[NUM_BLK_SIZES]; 95 96 extern U08 gau1_blk_size_to_wd_shift[NUM_BLK_SIZES]; 97 98 /** 99 ****************************************************************************** 100 * @brief Reads out the height of blk given a blk size enumeration 101 ****************************************************************************** 102 */ 103 extern U08 gau1_blk_size_to_ht[NUM_BLK_SIZES]; 104 105 /** 106 ****************************************************************************** 107 * @brief Given a minimum pt enum in a 3x3 grid, reads out the list of active 108 * search pts in next iteration as a bit-mask, eliminating need to search 109 * pts that have already been searched in this iteration. 110 ****************************************************************************** 111 */ 112 extern S32 gai4_opt_grid_mask[NUM_GRID_PTS]; 113 114 /** 115 ****************************************************************************** 116 * @brief Given a minimum pt enum in a 3x3 grid, reads out the x offset of 117 * the min pt relative to center assuming step size of 1 118 ****************************************************************************** 119 */ 120 extern S08 gai1_grid_id_to_x[NUM_GRID_PTS]; 121 122 /** 123 ****************************************************************************** 124 * @brief Given a minimum pt enum in a 3x3 grid, reads out the y offset of 125 * the min pt relative to center assuming step size of 1 126 ****************************************************************************** 127 */ 128 extern S08 gai1_grid_id_to_y[NUM_GRID_PTS]; 129 130 /** 131 ****************************************************************************** 132 * @brief Lookup of the blk size enum, given a specific partition and cu size 133 ****************************************************************************** 134 */ 135 extern BLK_SIZE_T ge_part_id_to_blk_size[NUM_CU_SIZES][TOT_NUM_PARTS]; 136 137 /** 138 ****************************************************************************** 139 * @brief For a given partition split, find number of partitions 140 ****************************************************************************** 141 */ 142 extern U08 gau1_num_parts_in_part_type[MAX_PART_TYPES]; 143 144 /** 145 ****************************************************************************** 146 * @brief For a given partition split, returns the enumerations of specific 147 * partitions in raster order. E.g. for PART_2NxN, part id 0 is 148 * PART_ID_2NxN_T and part id 1 is PART_ID_2NxN_B 149 ****************************************************************************** 150 */ 151 extern PART_ID_T ge_part_type_to_part_id[MAX_PART_TYPES][MAX_NUM_PARTS]; 152 153 /** 154 ****************************************************************************** 155 * @brief For a given partition id, returs the rectangular position and size 156 * of partition within cu relative ot cu start. 157 ****************************************************************************** 158 */ 159 extern part_attr_t gas_part_attr_in_cu[TOT_NUM_PARTS]; 160 161 /** 162 ****************************************************************************** 163 * @brief Gives the CU type enumeration given a blk size. 164 ****************************************************************************** 165 */ 166 extern CU_SIZE_T ge_blk_size_to_cu_size[NUM_BLK_SIZES]; 167 168 /** 169 ****************************************************************************** 170 171 * @brief Given a minimum pt enum in a diamond grid, reads out the list 172 * of active search pts in next iteration as a bit-mask, eliminating need 173 * to search pts that have already been searched in this iteration. 174 ****************************************************************************** 175 */ 176 extern S32 gai4_opt_grid_mask_diamond[5]; 177 178 /** 179 ****************************************************************************** 180 * @brief Given a minimum pt enum in a 9 point grid, reads out the list 181 * of active search pts in next iteration as a bit-mask, eliminating need 182 * to search pts that have already been searched in this iteration. 183 ****************************************************************************** 184 */ 185 186 extern S32 gai4_opt_grid_mask_conventional[9]; 187 188 /** 189 ****************************************************************************** 190 * @brief Given a raster coord x, y, this aray returns the CU id in encoding 191 * order. Indexed as [y][x] 192 ****************************************************************************** 193 */ 194 extern U08 gau1_cu_id_raster_to_enc[4][4]; 195 /** 196 ****************************************************************************** 197 * @brief Given a CU size, this array returns blk size enum 198 ****************************************************************************** 199 */ 200 extern BLK_SIZE_T ge_cu_size_to_blk_size[NUM_CU_SIZES]; 201 202 /** 203 ****************************************************************************** 204 * @brief Given a part type, returns whether the part type is vertically 205 * oriented. 206 ****************************************************************************** 207 */ 208 extern U08 gau1_is_vert_part[MAX_PART_TYPES]; 209 210 /** 211 ****************************************************************************** 212 * @brief Given a partition, returns the number of best results to consider 213 * for full pell refinement. 214 ****************************************************************************** 215 */ 216 extern U08 gau1_num_best_results_PQ[TOT_NUM_PARTS]; 217 extern U08 gau1_num_best_results_HQ[TOT_NUM_PARTS]; 218 extern U08 gau1_num_best_results_MS[TOT_NUM_PARTS]; 219 extern U08 gau1_num_best_results_HS[TOT_NUM_PARTS]; 220 extern U08 gau1_num_best_results_XS[TOT_NUM_PARTS]; 221 extern U08 gau1_num_best_results_XS25[TOT_NUM_PARTS]; 222 223 /** 224 ****************************************************************************** 225 * @brief gau1_cu_tr_valid[y][x] returns the validity of a top rt candt for 226 * CU with raster id x, y within CTB. Valid for 16x16 CUs and above 227 ****************************************************************************** 228 */ 229 extern U08 gau1_cu_tr_valid[4][4]; 230 /** 231 ****************************************************************************** 232 * @brief gau1_cu_tr_valid[y][x] returns the validity of a bot lt candt for 233 * CU with raster id x, y within CTB. Valid for 16x16 CUs and above 234 ****************************************************************************** 235 */ 236 extern U08 gau1_cu_bl_valid[4][4]; 237 238 /** 239 ****************************************************************************** 240 * @brief Returns the validity of top rt candt for a given part id, will not 241 * be valid if tr of a part pts to a non causal neighbour like 16x8B 242 ****************************************************************************** 243 */ 244 extern U08 gau1_partid_tr_valid[TOT_NUM_PARTS]; 245 /** 246 ****************************************************************************** 247 * @brief Returns the validity of bottom left cant for given part id, will 248 * not be valid, if bl of a part pts to a non causal neighbour like 8x16R 249 ****************************************************************************** 250 */ 251 extern U08 gau1_partid_bl_valid[TOT_NUM_PARTS]; 252 253 /** 254 ****************************************************************************** 255 * @brief The number of partition id in the CU, e.g. PART_ID_16x8_B is 2nd 256 ****************************************************************************** 257 */ 258 extern U08 gau1_part_id_to_part_num[TOT_NUM_PARTS]; 259 260 /** 261 ****************************************************************************** 262 * @brief Returns partition type for a given partition id, e.g. 263 * PART_ID_16x8_B returns PRT_TYPE_16x8 264 ****************************************************************************** 265 */ 266 extern PART_TYPE_T ge_part_id_to_part_type[TOT_NUM_PARTS]; 267 268 /** 269 ****************************************************************************** 270 * @brief given raster id x, y of 8x8 blk in 64x64 CTB, return the enc order 271 ****************************************************************************** 272 */ 273 extern U08 gau1_8x8_cu_id_raster_to_enc[8][8]; 274 275 /** 276 ****************************************************************************** 277 * @brief Return the bits for a given partition id which gets added to the 278 * cost. Although the bits are for a given partition type, we add off the 279 * bits per partition while computing mv cost. For example, if the bits for 280 * 2NxN part type is 3, we add 1.5 bits for 2NxN_T and 1.5 for 2NxN_B. 281 * Hence this is stored in Q1 format 282 ****************************************************************************** 283 */ 284 extern U08 gau1_bits_for_part_id_q1[TOT_NUM_PARTS]; 285 286 /** 287 ****************************************************************************** 288 * @brief Returns 1 if there are qpel points to the top and bottom of the 289 * current point 290 ****************************************************************************** 291 */ 292 extern S32 gai4_2pt_qpel_interpol_possible_vert[4][4]; 293 294 /** 295 ****************************************************************************** 296 * @brief Returns 1 if there are qpel points to the left and right of the 297 * current point 298 ****************************************************************************** 299 */ 300 extern S32 gai4_2pt_qpel_interpol_possible_horz[4][4]; 301 302 /** 303 ****************************************************************************** 304 * @brief For a given partition split, num bits to encode the partition type 305 * and split cu,tu bits; assuming one bin equal to one bit for now 306 ****************************************************************************** 307 */ 308 extern U08 gau1_num_bits_for_part_type[MAX_PART_TYPES]; 309 310 /** 311 ****************************************************************************** 312 * @brief Used exclusively in the Intrinsics version of the function 313 * 'hme_combine_4x4_sads_and_compute_cost_high_speed' instead 314 * of calling get_range() 315 ****************************************************************************** 316 */ 317 extern S16 gi2_mvy_range[MAX_MVY_SUPPORTED_IN_COARSE_LAYER + 1][8]; 318 319 /** 320 ****************************************************************************** 321 * @brief Used exclusively in the Intrinsics version of the function 322 * 'hme_combine_4x4_sads_and_compute_cost_high_speed' instead 323 * of calling get_range() 324 ****************************************************************************** 325 */ 326 extern S16 gi2_mvx_range[MAX_MVX_SUPPORTED_IN_COARSE_LAYER * 2 + 1][8]; 327 328 extern S32 gai4_select_qpel_function_vert[4][16]; 329 330 extern S32 gai4_select_qpel_function_horz[4][16]; 331 332 extern S32 gai4_partition_area[TOT_NUM_PARTS]; 333 334 extern const U08 gau1_search_cand_priority_in_l1_and_l2_me[2][NUM_SEARCH_CAND_TYPES]; 335 336 /* 12 cases are - */ 337 /* case 0 - P picture, num_refs=1, 4x4 in L1ME = 0 */ 338 /* case 1 - P picture, num_refs=1, 4x4 in L1ME = 1 */ 339 /* case 2 - P picture, num_refs=2, 4x4 in L1ME = 0 */ 340 /* case 3 - P picture, num_refs=2, 4x4 in L1ME = 1 */ 341 /* case 4 - P picture, num_refs=3, 4x4 in L1ME = 0 */ 342 /* case 5 - P picture, num_refs=3, 4x4 in L1ME = 1 */ 343 /* case 6 - P picture, num_refs=3, 4x4 in L1ME = 0 */ 344 /* case 7 - P picture, num_refs=3, 4x4 in L1ME = 1 */ 345 /* case 8 - B picture, num_refs=1, 4x4 in L1ME = 0 */ 346 /* case 9 - B picture, num_refs=1, 4x4 in L1ME = 1 */ 347 /* case 10 - B picture, num_refs=2, 4x4 in L1ME = 0 */ 348 /* case 11 - B picture, num_refs=2, 4x4 in L1ME = 1 */ 349 extern const U08 gau1_search_cand_priority_in_l0_me[12][NUM_SEARCH_CAND_TYPES]; 350 351 extern const SEARCH_CANDIDATE_TYPE_T 352 gae_search_cand_priority_to_search_cand_type_map_in_l0_me[12][NUM_SEARCH_CAND_TYPES]; 353 354 extern const U08 gau1_max_num_search_cands_in_l0_me[12]; 355 356 extern const SEARCH_CAND_LOCATIONS_T gae_search_cand_type_to_location_map[NUM_SEARCH_CAND_TYPES]; 357 358 extern const S08 gai1_search_cand_type_to_result_id_map[NUM_SEARCH_CAND_TYPES]; 359 360 extern const U08 gau1_search_cand_type_to_spatiality_map[NUM_SEARCH_CAND_TYPES]; 361 362 extern const S32 gai4_search_cand_location_to_x_offset_map[NUM_SEARCH_CAND_LOCATIONS]; 363 364 extern const S32 gai4_search_cand_location_to_y_offset_map[NUM_SEARCH_CAND_LOCATIONS]; 365 366 /** 367 ****************************************************************************** 368 * @brief Used exclusively in the Intrinsics version of the function 369 * 'hme_combine_4x4_sads_and_compute_cost_high_quality' instead 370 * of calling get_range() 371 ****************************************************************************** 372 */ 373 extern S16 gi2_mvx_range_high_quality[MAX_MVX_SUPPORTED_IN_COARSE_LAYER * 2 + 1][8]; 374 375 extern const S16 gai2_mvx_range_mapping[8193][8]; 376 377 extern const S16 gai2_mvy_range_mapping[4097][8]; 378 379 extern const S16 gai2_set_best_cost_max[8][8]; 380 381 extern const S08 gai1_mv_adjust[8][2]; 382 383 extern const S08 gai1_mv_offsets_from_center_in_rect_grid[NUM_POINTS_IN_RECTANGULAR_GRID][2]; 384 385 #endif /* #ifndef _HME_GLOBALS_H_*/ 386