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