Line data Source code
1 : /*
2 : * Copyright(c) 2019 Intel Corporation
3 : * SPDX - License - Identifier: BSD - 2 - Clause - Patent
4 : */
5 :
6 : /*
7 : * Copyright (c) 2016, Alliance for Open Media. All rights reserved
8 : *
9 : * This source code is subject to the terms of the BSD 2 Clause License and
10 : * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
11 : * was not distributed with this source code in the LICENSE file, you can
12 : * obtain it at www.aomedia.org/license/software. If the Alliance for Open
13 : * Media Patent License 1.0 was not distributed with this source code in the
14 : * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
15 : */
16 :
17 : #ifndef EbDefinitions_h
18 : #define EbDefinitions_h
19 : #include <stdint.h>
20 : #include <stdlib.h>
21 : #include <string.h>
22 : #include <stddef.h>
23 : #include "EbSvtAv1.h"
24 : #ifdef _WIN32
25 : #define inline __inline
26 : #elif __GNUC__
27 : #define inline __inline__
28 : #else
29 : #define inline
30 : #endif
31 :
32 : #ifdef __cplusplus
33 : extern "C" {
34 : #endif
35 : #define HBD_CLEAN_UP 1
36 :
37 : #define IFS_8BIT_MD 1
38 :
39 :
40 : /* Note: shutting the macro PAL_SUP will not give SS as pcs->palette_mode = 0
41 : rate estimation is changed for I frame + enabled sc for P (rate estimation
42 : is a result changed for P frames)
43 : */
44 : #define PAL_SUP 1 //Palette prediction support.
45 : #if PAL_SUP
46 : #define PAL_CLASS 1
47 : #endif
48 :
49 : #define LESS_RECTANGULAR_CHECK_LEVEL 1 // Shortcut to skip a/b shapes depending on SQ/H/V shape costs
50 :
51 : #define INTER_INTRA_CLASS_PRUNING 1
52 :
53 : #define FIX_ALTREF 1 // Address ALTREF mismatch between rtime-m0-test and master: fixed actual_future_pics derivation, shut padding of the central frame, fixed end past frame index prior to window shrinking
54 : #define FIX_NEAREST_NEW 1 // Address NEAREST_NEW mismatch between rtime-m0-test and master: fixed injection and fixed settings
55 : #define FIX_ESTIMATE_INTRA 1 // Address ESTIMATE_INTRA mismatch between rtime-m0-test and master: fixed settings
56 : #define FIX_SKIP_REDUNDANT_BLOCK 1 // Address SKIP_REDUNDANT_BLOCK mismatch between rtime-m0-test and master: fixed the action to bypass MD
57 : #define FIX_COEF_BASED_ATB_SKIP 1 // Address COEF_BASED_ATB_SKIP mismatch between rtime-m0-test and master: reset coeff_based_skip_atb @ each SB
58 : #define FIX_WM_SETTINGS 1 // Address WM_SETTINGS mismatch between rtime-m0-test and master: fixed settings
59 : #define FIX_ENABLE_CDF_UPDATE 1 // Address ENABLE_CDF_UPDATE mismatch between rtime-m0-test and master: removed useless update
60 : #define FIX_SORTING_METHOD 1 // Address SORTING mismatch between rtime-m0-test and master: used same method
61 : #define FIX_SETTINGS_RESET 1 // Address SEGMENT_RESET mismatch between rtime-m0-test and master: only @ 1st segment
62 : #define FIX_COMPOUND 1 // Address COMPOUND mismatch between rtime-m0-test and master: used block size @ the derivation of compound count
63 :
64 : #define OBMC_FLAG 1 // OBMC motion mode flag
65 : #define OBMC_CONVOLVE 1 // to track convolve kernels changes
66 :
67 : #define INJECT_NEW_NEAR_NEAR_NEW 1 // Inject NEW_NEAR / NEAR_NEW inter prediction
68 : #define FILTER_INTRA_FLAG 1 // Filter intra prediction
69 :
70 :
71 : #define II_COMP_FLAG 1 // InterIntra compound
72 : #define PAETH_HBD 1 // Enbale Intra PAETH for 10bit
73 : #define INTER_INTER_HBD 1 // Upgrade InterInter compound 10bit
74 : #define INTER_INTRA_HBD 1 // Upgrade InterIntra compound 10bit
75 : #define ATB_10_BIT 1 // Upgrade ATB 10bit
76 :
77 : #define PRED_CHANGE 1 // Change the MRP in 4L Pictures 3, 5 , 7 and 9 use 1 as the reference
78 : #define PRED_CHANGE_5L 1 // Change the MRP in 5L Pictures 3, 5 , 7 and 9 use 1 as the reference, 11, 13, 15 and 17 use 9 as the reference
79 : #define PRED_CHANGE_MOD 1 // Reorder the references for MRP
80 : #define SPEED_OPT 1 // Speed optimization(s)
81 : #define GLOBAL_WARPED_MOTION 1 // Global warped motion detection and insertion
82 :
83 : #ifndef NON_AVX512_SUPPORT
84 : #define NON_AVX512_SUPPORT
85 : #endif
86 :
87 : #define MR_MODE 0
88 :
89 : #define WARP_UPDATE 1 // Modified Warp settings: ON for MR mode. ON for ref frames in M0
90 : #define EIGTH_PEL_MV 1
91 : #define EIGHT_PEL_PREDICTIVE_ME 1
92 : #define COMP_INTERINTRA 1 // InterIntra mode support
93 :
94 : #define ENHANCE_ATB 1
95 :
96 : #define RDOQ_CHROMA 1
97 :
98 :
99 : #define TWO_PASS 1 // Two pass encoding. For now, the encoder is called two times and data transfered using file.
100 : // Actions in the second pass: Frame and SB QP assignment and temporal filtering strenght change
101 : #define TWO_PASS_USE_2NDP_ME_IN_1STP 1 // Add a config parameter to the first pass to use the ME settings of the second pass
102 :
103 : #define REMOVE_MD_STAGE_1 1 // Simplified MD Staging; removed md_stage_1
104 : #define NON_KF_INTRA_TF_FIX 0 // Fix temporal filtering for non-key Intra frames
105 :
106 : #define TWO_PASS_IMPROVEMENT 1 // Tune 2 pass for better Luma by adjusting the reference area and the actions
107 : //FOR DEBUGGING - Do not remove
108 : #define NO_ENCDEC 0 // bypass encDec to test cmpliance of MD. complained achieved when skip_flag is OFF. Port sample code from VCI-SW_AV1_Candidate1 branch
109 :
110 : #define ADP_STATS_PER_LAYER 0
111 : #define AOM_INTERP_EXTEND 4
112 : #define OPTIMISED_EX_SUBPEL 1
113 :
114 : #define AOM_LEFT_TOP_MARGIN_PX(subsampling) \
115 : ((AOM_BORDER_IN_PIXELS >> subsampling) - AOM_INTERP_EXTEND)
116 : #define AOM_LEFT_TOP_MARGIN_SCALED(subsampling) \
117 : (AOM_LEFT_TOP_MARGIN_PX(subsampling) << SCALE_SUBPEL_BITS)
118 :
119 : #if OPTIMISED_EX_SUBPEL
120 : #define H_PEL_SEARCH_WIND 3 // 1/2-pel serach window
121 : #else
122 : #define H_PEL_SEARCH_WIND 4 // 1/2-pel serach window
123 : #endif
124 : #define Q_PEL_SEARCH_WIND 2 // 1/4-pel serach window
125 : #define HP_REF_OPT 1 // Remove redundant positions.
126 : typedef enum ME_HP_MODE {
127 : EX_HP_MODE = 0, // Exhaustive 1/2-pel serach mode.
128 : REFINMENT_HP_MODE = 1 // Refinement 1/2-pel serach mode.
129 : } ME_HP_MODE;
130 : typedef enum ME_QP_MODE {
131 : EX_QP_MODE = 0, // Exhaustive 1/4-pel serach mode.
132 : REFINMENT_QP_MODE = 1 // Refinement 1/4-pel serach mode.
133 : } ME_QP_MODE;
134 : struct Buf2D
135 : {
136 : uint8_t *buf;
137 : uint8_t *buf0;
138 : int width;
139 : int height;
140 : int stride;
141 : };
142 : typedef struct MvLimits
143 : {
144 : int col_min;
145 : int col_max;
146 : int row_min;
147 : int row_max;
148 : } MvLimits;
149 : typedef struct {
150 : uint8_t by;
151 : uint8_t bx;
152 : uint8_t skip;
153 : } cdef_list;
154 :
155 : /*!\brief force enum to be unsigned 1 byte*/
156 : #define UENUM1BYTE(enumvar) \
157 : ; \
158 : typedef uint8_t enumvar
159 :
160 : enum {
161 : DIAMOND = 0,
162 : NSTEP = 1,
163 : HEX = 2,
164 : BIGDIA = 3,
165 : SQUARE = 4,
166 : FAST_HEX = 5,
167 : FAST_DIAMOND = 6
168 : } UENUM1BYTE(SEARCH_METHODS);
169 :
170 : /********************************************************/
171 : /****************** Pre-defined Values ******************/
172 : /********************************************************/
173 :
174 : #define ALTREF_MAX_NFRAMES 10 // maximum number of frames allowed for the Alt-ref picture computation
175 : // this number can be increased by increasing the constant
176 : // FUTURE_WINDOW_WIDTH defined in EbPictureDecisionProcess.c
177 : #define ALTREF_MAX_STRENGTH 6
178 :
179 : #define PAD_VALUE (128+32)
180 :
181 : /* Use open-loop data to predict the NSQ partitions. */
182 : #define PREDICT_NSQ_SHAPE 1
183 : #if PREDICT_NSQ_SHAPE
184 : #define NUMBER_OF_DEPTH 6
185 : #define NUMBER_OF_SHAPES 10
186 : #define ADD_SAD_FOR_128X128 1
187 : #define ADJUST_NSQ_RANK_BASED_ON_NEIGH 1
188 : #define COMBINE_MDC_NSQ_TABLE 1
189 : #define ADD_SUPPORT_TO_SKIP_PART_N 1
190 : #define ADD_MDC_REFINEMENT_LOOP 1
191 : #define ADD_MDC_FULL_COST 1
192 : #define NSQ_TAB_SIZE 8
193 : #define MAX_MDC_LEVEL 8
194 : #define MDC_ADAPTIVE_LEVEL 1
195 : #else
196 : #define NSQ_TAB_SIZE 6
197 : #endif
198 :
199 : #define AUTO_MODE -1
200 :
201 : // Delta QP support
202 : #define ADD_DELTA_QP_SUPPORT 1 // Add delta QP support
203 : #define BLOCK_MAX_COUNT_SB_128 4421 // TODO: reduce alloction for 64x64
204 : #define BLOCK_MAX_COUNT_SB_64 1101 // TODO: reduce alloction for 64x64
205 : #define MAX_TXB_COUNT 4 // Maximum number of transform blocks.
206 : #if II_COMP_FLAG
207 : #if OBMC_FLAG
208 : #if FILTER_INTRA_FLAG
209 : #define MAX_NFL 125 // Maximum number of candidates MD can support
210 : #else
211 : #define MAX_NFL 120 // Maximum number of candidates MD can support
212 : #endif
213 : #else
214 : #define MAX_NFL 95
215 : #endif
216 : #else
217 : #define MAX_NFL 80
218 : #endif
219 : #define MAX_NFL_BUFF (MAX_NFL + CAND_CLASS_TOTAL) //need one extra temp buffer for each fast loop call
220 : #define MAX_LAD 120 // max lookahead-distance 2x60fps
221 : #define ROUND_UV(x) (((x)>>3)<<3)
222 : #define AV1_PROB_COST_SHIFT 9
223 : #define AOMINNERBORDERINPIXELS 160
224 : #define SWITCHABLE_FILTER_CONTEXTS ((SWITCHABLE_FILTERS + 1) * 4)
225 : #define MAX_MB_PLANE 3
226 : #define CFL_MAX_BlockSize (BLOCK_32X32)
227 : #define CFL_BUF_LINE (32)
228 : #define CFL_BUF_LINE_I128 (CFL_BUF_LINE >> 3)
229 : #define CFL_BUF_LINE_I256 (CFL_BUF_LINE >> 4)
230 : #define CFL_BUF_SQUARE (CFL_BUF_LINE * CFL_BUF_LINE)
231 : /*********************************** AV1_OBU ********************************/
232 : #define INVALID_NEIGHBOR_DATA 0xFFu
233 : #define CONFIG_BITSTREAM_DEBUG 0
234 : #define CONFIG_BUFFER_MODEL 1
235 : #define CONFIG_COEFFICIENT_RANGE_CHECKING 0
236 : #define CONFIG_ENTROPY_STATS 0
237 : #define CONFIG_FP_MB_STATS 0
238 : #define CONFIG_INTERNAL_STATS 0
239 : #define CONFIG_RD_DEBUG 0
240 :
241 : // Max superblock size
242 : #define MAX_SB_SIZE_LOG2 7
243 : #define MAX_SB_SIZE (1 << MAX_SB_SIZE_LOG2)
244 : #define MAX_SB_SQUARE (MAX_SB_SIZE * MAX_SB_SIZE)
245 : #define SB_STRIDE_Y MAX_SB_SIZE
246 : #define SB_STRIDE_UV (MAX_SB_SIZE>>1)
247 :
248 : // Min superblock size
249 : #define MIN_SB_SIZE_LOG2 6
250 :
251 : // Pixels per Mode Info (MI) unit
252 : #define MI_SIZE_LOG2 2
253 : #define MI_SIZE (1 << MI_SIZE_LOG2)
254 :
255 : // MI-units per max superblock (MI Block - MIB)
256 : #define MAX_MIB_SIZE_LOG2 (MAX_SB_SIZE_LOG2 - MI_SIZE_LOG2)
257 : #define MAX_MIB_SIZE (1 << MAX_MIB_SIZE_LOG2)
258 :
259 : // MI-units per min superblock
260 : #define SB64_MIB_SIZE 16
261 :
262 : // MI-units per min superblock
263 : #define MIN_MIB_SIZE_LOG2 (MIN_SB_SIZE_LOG2 - MI_SIZE_LOG2)
264 :
265 : // Mask to extract MI offset within max MIB
266 : #define MAX_MIB_MASK (MAX_MIB_SIZE - 1)
267 :
268 : // Maximum size of a loop restoration tile
269 : #define RESTORATION_TILESIZE_MAX 256
270 : // Maximum number of tile rows and tile columns
271 : #define MAX_TILE_ROWS 64
272 : #define MAX_TILE_COLS 64
273 : #if ENHANCE_ATB
274 : #define MAX_VARTX_DEPTH 2
275 : #else
276 : #define MAX_VARTX_DEPTH 1
277 : #endif
278 : #define MI_SIZE_64X64 (64 >> MI_SIZE_LOG2)
279 : #define MI_SIZE_128X128 (128 >> MI_SIZE_LOG2)
280 : #define MAX_PALETTE_SQUARE (64 * 64)
281 : // Maximum number of colors in a palette.
282 : #define PALETTE_MAX_SIZE 8
283 : // Minimum number of colors in a palette.
284 : #define PALETTE_MIN_SIZE 2
285 : #define FRAME_OFFSET_BITS 5
286 : #define MAX_FRAME_DISTANCE ((1 << FRAME_OFFSET_BITS) - 1)
287 :
288 : // 4 frame filter levels: y plane vertical, y plane horizontal,
289 : // u plane, and v plane
290 : #define FRAME_LF_COUNT 4
291 : #define DEFAULT_DELTA_LF_MULTI 0
292 : #define MAX_MODE_LF_DELTAS 2
293 : #define LEVEL_MAJOR_BITS 3
294 : #define LEVEL_MINOR_BITS 2
295 : #define LEVEL_BITS (LEVEL_MAJOR_BITS + LEVEL_MINOR_BITS)
296 :
297 : #define LEVEL_MAJOR_MIN 2
298 : #define LEVEL_MAJOR_MAX ((1 << LEVEL_MAJOR_BITS) - 1 + LEVEL_MAJOR_MIN)
299 : #define LEVEL_MINOR_MIN 0
300 : #define LEVEL_MINOR_MAX ((1 << LEVEL_MINOR_BITS) - 1)
301 :
302 : #define OP_POINTS_CNT_MINUS_1_BITS 5
303 : #define OP_POINTS_IDC_BITS 12
304 : #define TX_SIZE_LUMA_MIN (TX_4X4)
305 : /* We don't need to code a transform size unless the allowed size is at least
306 : one more than the minimum. */
307 : #define TX_SIZE_CTX_MIN (TX_SIZE_LUMA_MIN + 1)
308 :
309 : // Maximum tx_size categories
310 : #define MAX_TX_CATS (TX_SIZES - TX_SIZE_CTX_MIN)
311 : #define MAX_TX_DEPTH 2
312 :
313 : #define MAX_TX_SIZE_LOG2 (6)
314 : #define MAX_TX_SIZE (1 << MAX_TX_SIZE_LOG2)
315 : #define MIN_TX_SIZE_LOG2 2
316 : #define MIN_TX_SIZE (1 << MIN_TX_SIZE_LOG2)
317 : #define MAX_TX_SQUARE (MAX_TX_SIZE * MAX_TX_SIZE)
318 :
319 : // Pad 4 extra columns to remove horizontal availability check.
320 : #define TX_PAD_HOR_LOG2 2
321 : #define TX_PAD_HOR 4
322 : // Pad 6 extra rows (2 on top and 4 on bottom) to remove vertical availability
323 : // check.
324 : #define TX_PAD_TOP 2
325 : #define TX_PAD_BOTTOM 4
326 : #define TX_PAD_VER (TX_PAD_TOP + TX_PAD_BOTTOM)
327 : // Pad 16 extra bytes to avoid reading overflow in SIMD optimization.
328 : #define TX_PAD_END 16
329 : #define TX_PAD_2D \
330 : ((MAX_TX_SIZE + TX_PAD_HOR) * (MAX_TX_SIZE + TX_PAD_VER) + TX_PAD_END)
331 : #define COMPOUND_WEIGHT_MODE DIST
332 : #define DIST_PRECISION_BITS 4
333 : #define DIST_PRECISION (1 << DIST_PRECISION_BITS) // 16
334 :
335 : // TODO(chengchen): Temporal flag serve as experimental flag for WIP
336 : // bitmask construction.
337 : // Shall be removed when bitmask code is completely checkedin
338 : #define LOOP_FILTER_BITMASK 0
339 : #define PROFILE_BITS 3
340 :
341 : // AV1 Loop Filter
342 : #define AV1_LF 1 // AV1 Loop Filter
343 : #if AV1_LF
344 : #define LF_SHARPNESS 0
345 : #endif
346 :
347 : #define FILTER_BITS 7
348 : #define SUBPEL_BITS 4
349 : #define SUBPEL_MASK ((1 << SUBPEL_BITS) - 1)
350 : #define SUBPEL_SHIFTS (1 << SUBPEL_BITS)
351 : #define SUBPEL_TAPS 8
352 :
353 : #define SCALE_SUBPEL_BITS 10
354 : #define SCALE_SUBPEL_SHIFTS (1 << SCALE_SUBPEL_BITS)
355 : #define SCALE_SUBPEL_MASK (SCALE_SUBPEL_SHIFTS - 1)
356 : #define SCALE_EXTRA_BITS (SCALE_SUBPEL_BITS - SUBPEL_BITS)
357 : #define SCALE_EXTRA_OFF ((1 << SCALE_EXTRA_BITS) / 2)
358 :
359 : typedef int16_t InterpKernel[SUBPEL_TAPS];
360 :
361 : /***************************************************/
362 : /****************** Helper Macros ******************/
363 : /***************************************************/
364 : void aom_reset_mmx_state(void);
365 : extern void RunEmms();
366 : #define aom_clear_system_state() RunEmms() //aom_reset_mmx_state()
367 :
368 : /* Shift down with rounding for use when n >= 0, value >= 0 */
369 : #define ROUND_POWER_OF_TWO(value, n) (((value)+(((1 << (n)) >> 1))) >> (n))
370 :
371 : /* Shift down with rounding for signed integers, for use when n >= 0 */
372 : #define ROUND_POWER_OF_TWO_SIGNED(value, n) \
373 : (((value) < 0) ? -ROUND_POWER_OF_TWO(-(value), (n)) \
374 : : ROUND_POWER_OF_TWO((value), (n)))
375 :
376 : /* Shift down with rounding for use when n >= 0, value >= 0 for (64 bit) */
377 : #define ROUND_POWER_OF_TWO_64(value, n) \
378 : (((value) + ((((int64_t)1 << (n)) >> 1))) >> (n))
379 :
380 : /* Shift down with rounding for signed integers, for use when n >= 0 (64 bit) */
381 : #define ROUND_POWER_OF_TWO_SIGNED_64(value, n) \
382 : (((value) < 0) ? -ROUND_POWER_OF_TWO_64(-(value), (n)) \
383 : : ROUND_POWER_OF_TWO_64((value), (n)))
384 :
385 : #define IS_POWER_OF_TWO(x) (((x) & ((x)-1)) == 0)
386 :
387 : #ifdef __cplusplus
388 : #define EB_EXTERN extern "C"
389 : #else
390 : #define EB_EXTERN
391 : #endif // __cplusplus
392 :
393 : #define INLINE __inline
394 : #define RESTRICT
395 : #ifdef _WIN32
396 : #define FOPEN(f,s,m) fopen_s(&f,s,m)
397 : #else
398 : #define FOPEN(f,s,m) f=fopen(s,m)
399 : #endif
400 :
401 : #define IMPLIES(a, b) (!(a) || (b)) // Logical 'a implies b' (or 'a -> b')
402 : #if (defined(__GNUC__) && __GNUC__) || defined(__SUNPRO_C)
403 : #define DECLARE_ALIGNED(n, typ, val) typ val __attribute__((aligned(n)))
404 : #elif defined(_WIN32)
405 : #define DECLARE_ALIGNED(n, typ, val) __declspec(align(n)) typ val
406 : #else
407 : #warning No alignment directives known for this compiler.
408 : #define DECLARE_ALIGNED(n, typ, val) typ val
409 : #endif
410 :
411 : #ifdef _MSC_VER
412 : #define EB_ALIGN(n) __declspec(align(n))
413 : #elif defined(__GNUC__)
414 : #define EB_ALIGN(n) __attribute__((__aligned__(n)))
415 : #else
416 : #define EB_ALIGN(n)
417 : #endif
418 :
419 : #ifdef _MSC_VER
420 : #define AOM_FORCE_INLINE __forceinline
421 : #define AOM_INLINE __inline
422 : #else
423 : #define AOM_FORCE_INLINE __inline__ __attribute__((always_inline))
424 : // TODO(jbb): Allow a way to force inline off for older compilers.
425 : #define AOM_INLINE inline
426 : #endif
427 :
428 : #define SIMD_INLINE static AOM_FORCE_INLINE
429 :
430 : //*********************************************************************************************************************//
431 : // mem.h
432 : /* shift right or left depending on sign of n */
433 : #define RIGHT_SIGNED_SHIFT(value, n) \
434 : ((n) < 0 ? ((value) << (-(n))) : ((value) >> (n)))
435 : //*********************************************************************************************************************//
436 : // cpmmom.h
437 : // Only need this for fixed-size arrays, for structs just assign.
438 : #define av1_copy(dest, src) \
439 : { \
440 : assert(sizeof(dest) == sizeof(src)); \
441 : memcpy(dest, src, sizeof(src)); \
442 : }
443 :
444 : // mem_ops.h
445 : #ifndef MAU_T
446 : /* Minimum Access Unit for this target */
447 : #define MAU_T uint8_t
448 : #endif
449 :
450 : #ifndef MEM_VALUE_T
451 : #define MEM_VALUE_T int32_t
452 : #endif
453 :
454 : #undef MEM_VALUE_T_SZ_BITS
455 : #define MEM_VALUE_T_SZ_BITS (sizeof(MEM_VALUE_T) << 3)
456 :
457 : static __inline void mem_put_le16(void *vmem, MEM_VALUE_T val) {
458 : MAU_T *mem = (MAU_T *)vmem;
459 :
460 : mem[0] = (MAU_T)((val >> 0) & 0xff);
461 : mem[1] = (MAU_T)((val >> 8) & 0xff);
462 : }
463 :
464 0 : static __inline void mem_put_le32(void *vmem, MEM_VALUE_T val) {
465 0 : MAU_T *mem = (MAU_T *)vmem;
466 :
467 0 : mem[0] = (MAU_T)((val >> 0) & 0xff);
468 0 : mem[1] = (MAU_T)((val >> 8) & 0xff);
469 0 : mem[2] = (MAU_T)((val >> 16) & 0xff);
470 0 : mem[3] = (MAU_T)((val >> 24) & 0xff);
471 0 : }
472 : /* clang-format on */
473 : //#endif // AOM_PORTS_MEM_OPS_H_
474 :
475 : typedef uint16_t ConvBufType;
476 :
477 : typedef struct ConvolveParams
478 : {
479 : int32_t ref;
480 : int32_t do_average;
481 : ConvBufType *dst;
482 : int32_t dst_stride;
483 : int32_t round_0;
484 : int32_t round_1;
485 : int32_t plane;
486 : int32_t is_compound;
487 : int32_t use_jnt_comp_avg;
488 : int32_t fwd_offset;
489 : int32_t bck_offset;
490 : int32_t use_dist_wtd_comp_avg;
491 : } ConvolveParams;
492 :
493 : // texture component type
494 : typedef enum ATTRIBUTE_PACKED
495 : {
496 : COMPONENT_LUMA = 0, // luma
497 : COMPONENT_CHROMA = 1, // chroma (Cb+Cr)
498 : COMPONENT_CHROMA_CB = 2, // chroma Cb
499 : COMPONENT_CHROMA_CR = 3, // chroma Cr
500 : COMPONENT_ALL = 4, // Y+Cb+Cr
501 : COMPONENT_NONE = 15
502 : }COMPONENT_TYPE;
503 :
504 5788189108 : static INLINE int32_t clamp(int32_t value, int32_t low, int32_t high) {
505 5788189108 : return value < low ? low : (value > high ? high : value);
506 : }
507 :
508 2950930 : static INLINE int64_t clamp64(int64_t value, int64_t low, int64_t high) {
509 2950930 : return value < low ? low : (value > high ? high : value);
510 : }
511 :
512 0 : static INLINE uint8_t clip_pixel(int32_t val) {
513 0 : return (uint8_t)((val > 255) ? 255 : (val < 0) ? 0 : val);
514 : }
515 :
516 0 : static INLINE uint16_t clip_pixel_highbd(int32_t val, int32_t bd) {
517 0 : switch (bd) {
518 0 : case 8:
519 0 : default: return (uint16_t)clamp(val, 0, 255);
520 0 : case 10: return (uint16_t)clamp(val, 0, 1023);
521 0 : case 12: return (uint16_t)clamp(val, 0, 4095);
522 : }
523 : }
524 :
525 0 : static INLINE unsigned int negative_to_zero(int value) {
526 0 : return value & ~(value >> (sizeof(value) * 8 - 1));
527 : }
528 : //*********************************************************************************************************************//
529 : // enums.h
530 : /*!\brief Decorator indicating that given struct/union/enum is packed */
531 : #ifndef ATTRIBUTE_PACKED
532 : #if defined(__GNUC__) && __GNUC__
533 : #define ATTRIBUTE_PACKED __attribute__((packed))
534 : #else
535 : #define ATTRIBUTE_PACKED
536 : #endif
537 : #endif /* ATTRIBUTE_PACKED */
538 :
539 : typedef enum CAND_CLASS {
540 : CAND_CLASS_0,
541 : CAND_CLASS_1,
542 : CAND_CLASS_2,
543 : CAND_CLASS_3,
544 : #if II_COMP_FLAG
545 : CAND_CLASS_4,
546 : #endif
547 : #if OBMC_FLAG
548 : CAND_CLASS_5,
549 : #endif
550 : #if FILTER_INTRA_FLAG
551 : CAND_CLASS_6,
552 : #endif
553 : #if PAL_CLASS
554 : CAND_CLASS_7,
555 : #endif
556 : CAND_CLASS_8,
557 : CAND_CLASS_TOTAL
558 : } CAND_CLASS;
559 :
560 : typedef enum MD_STAGE {
561 : MD_STAGE_0,
562 : MD_STAGE_1,
563 : MD_STAGE_2,
564 : MD_STAGE_3,
565 : MD_STAGE_TOTAL
566 : } MD_STAGE;
567 : #if REMOVE_MD_STAGE_1
568 : #define MD_STAGING_MODE_0 0
569 : #define MD_STAGING_MODE_1 1
570 : #else
571 : #define MD_STAGING_MODE_0 0
572 : #define MD_STAGING_MODE_1 1
573 : #define MD_STAGING_MODE_2 2
574 : #define MD_STAGING_MODE_3 3
575 : #endif
576 : #define INTRA_NFL 16
577 : #define INTER_NEW_NFL 16
578 : #define INTER_PRED_NFL 16
579 :
580 :
581 : #define BEST_CANDIDATE_COUNT 4
582 : #define MAX_REF_TYPE_CAND 30
583 : #define PRUNE_REC_TH 5
584 : #define PRUNE_REF_ME_TH 2
585 : #if !SPEED_OPT
586 : #define MD_EXIT_THSL 0 // MD_EXIT_THSL -->0 is lossless 100 is maximum. Increase with a step of 10-20.
587 : #endif
588 : typedef enum
589 : {
590 : EIGHTTAP_REGULAR,
591 : EIGHTTAP_SMOOTH,
592 : MULTITAP_SHARP,
593 : BILINEAR,
594 : INTERP_FILTERS_ALL,
595 : SWITCHABLE_FILTERS = BILINEAR,
596 : SWITCHABLE = SWITCHABLE_FILTERS + 1, /* the last switchable one */
597 : EXTRA_FILTERS = INTERP_FILTERS_ALL - SWITCHABLE_FILTERS,
598 : }InterpFilter;
599 : #if OBMC_FLAG
600 :
601 : #define AV1_COMMON Av1Common
602 : enum {
603 : USE_2_TAPS_ORIG = 0, // This is used in temporal filtering.
604 : USE_2_TAPS,
605 : USE_4_TAPS,
606 : USE_8_TAPS,
607 : } UENUM1BYTE(SUBPEL_SEARCH_TYPE);
608 : #endif
609 : typedef struct InterpFilterParams
610 : {
611 : const int16_t *filter_ptr;
612 : uint16_t taps;
613 : uint16_t subpel_shifts;
614 : InterpFilter interp_filter;
615 : } InterpFilterParams;
616 :
617 : typedef enum TxSearchLevel
618 : {
619 : TX_SEARCH_OFF,
620 : TX_SEARCH_ENC_DEC,
621 : TX_SEARCH_INTER_DEPTH,
622 : TX_SEARCH_FULL_LOOP
623 : } TxSearchLevel;
624 :
625 : typedef enum InterpolationSearchLevel
626 : {
627 : IT_SEARCH_OFF,
628 : IT_SEARCH_INTER_DEPTH,
629 : IT_SEARCH_FULL_LOOP,
630 : IT_SEARCH_FAST_LOOP_UV_BLIND,
631 : IT_SEARCH_FAST_LOOP,
632 : } InterpolationSearchLevel;
633 :
634 : typedef enum NsqSearchLevel
635 : {
636 : NSQ_SEARCH_OFF,
637 : NSQ_SEARCH_LEVEL1,
638 : NSQ_SEARCH_LEVEL2,
639 : NSQ_SEARCH_LEVEL3,
640 : NSQ_SEARCH_LEVEL4,
641 : NSQ_SEARCH_LEVEL5,
642 : NSQ_SEARCH_LEVEL6,
643 : #if PREDICT_NSQ_SHAPE
644 : NSQ_SEARCH_LEVEL7,
645 : #endif
646 : NSQ_SEARCH_FULL
647 : } NsqSearchLevel;
648 :
649 : #define MAX_PARENT_SQ 6
650 : typedef enum CompoundDistWeightMode {
651 : DIST,
652 : } CompoundDistWeightMode;
653 :
654 : // Profile 0. 8-bit and 10-bit 4:2:0 and 4:0:0 only.
655 : // Profile 1. 8-bit and 10-bit 4:4:4
656 : // Profile 2. 8-bit and 10-bit 4:2:2
657 : // 12 bit 4:0:0, 4:2:2 and 4:4:4
658 : typedef enum BitstreamProfile {
659 : PROFILE_0,
660 : PROFILE_1,
661 : PROFILE_2,
662 : MAX_PROFILES
663 : } BitstreamProfile;
664 : // Note: Some enums use the attribute 'packed' to use smallest possible integer
665 : // type, so that we can save memory when they are used in structs/arrays.
666 :
667 : typedef enum ATTRIBUTE_PACKED {
668 : BLOCK_4X4,
669 : BLOCK_4X8,
670 : BLOCK_8X4,
671 : BLOCK_8X8,
672 : BLOCK_8X16,
673 : BLOCK_16X8,
674 : BLOCK_16X16,
675 : BLOCK_16X32,
676 : BLOCK_32X16,
677 : BLOCK_32X32,
678 : BLOCK_32X64,
679 : BLOCK_64X32,
680 : BLOCK_64X64,
681 : BLOCK_64X128,
682 : BLOCK_128X64,
683 : BLOCK_128X128,
684 : BLOCK_4X16,
685 : BLOCK_16X4,
686 : BLOCK_8X32,
687 : BLOCK_32X8,
688 : BLOCK_16X64,
689 : BLOCK_64X16,
690 : BlockSizeS_ALL,
691 : BlockSizeS = BLOCK_4X16,
692 : BLOCK_INVALID = 255,
693 : BLOCK_LARGEST = (BlockSizeS - 1)
694 : } BlockSize;
695 :
696 : typedef enum ATTRIBUTE_PACKED {
697 : PARTITION_NONE,
698 : PARTITION_HORZ,
699 : PARTITION_VERT,
700 : PARTITION_SPLIT,
701 : PARTITION_HORZ_A, // HORZ split and the top partition is split again
702 : PARTITION_HORZ_B, // HORZ split and the bottom partition is split again
703 : PARTITION_VERT_A, // VERT split and the left partition is split again
704 : PARTITION_VERT_B, // VERT split and the right partition is split again
705 : PARTITION_HORZ_4, // 4:1 horizontal partition
706 : PARTITION_VERT_4, // 4:1 vertical partition
707 : EXT_PARTITION_TYPES,
708 : PARTITION_TYPES = PARTITION_SPLIT + 1,
709 : PARTITION_INVALID = 255
710 : } PartitionType;
711 :
712 : #define MAX_NUM_BLOCKS_ALLOC 7493 //max number of blocks assuming 128x128-4x4 all partitions.
713 :
714 : typedef enum ATTRIBUTE_PACKED {
715 : PART_N,
716 : PART_H,
717 : PART_V,
718 : PART_HA,
719 : PART_HB,
720 : PART_VA,
721 : PART_VB,
722 : PART_H4,
723 : PART_V4,
724 : PART_S
725 : } PART;
726 :
727 : static const uint8_t mi_size_wide[BlockSizeS_ALL] = {
728 : 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 1, 4, 2, 8, 4, 16
729 : };
730 : static const uint8_t mi_size_high[BlockSizeS_ALL] = {
731 : 1, 2, 1, 2, 4, 2, 4, 8, 4, 8, 16, 8, 16, 32, 16, 32, 4, 1, 8, 2, 16, 4
732 : };
733 :
734 : typedef char PartitionContextType;
735 : #define PARTITION_PLOFFSET 4 // number of probability models per block size
736 : #define PARTITION_BlockSizeS 5
737 : #define PARTITION_CONTEXTS (PARTITION_BlockSizeS * PARTITION_PLOFFSET)
738 :
739 : // block transform size
740 : #ifdef _MSC_VER
741 : typedef uint8_t TxSize;
742 : enum ATTRIBUTE_PACKED {
743 : #else
744 : typedef enum ATTRIBUTE_PACKED {
745 : #endif
746 : TX_4X4, // 4x4 transform
747 : TX_8X8, // 8x8 transform
748 : TX_16X16, // 16x16 transform
749 : TX_32X32, // 32x32 transform
750 : TX_64X64, // 64x64 transform
751 : TX_4X8, // 4x8 transform
752 : TX_8X4, // 8x4 transform
753 : TX_8X16, // 8x16 transform
754 : TX_16X8, // 16x8 transform
755 : TX_16X32, // 16x32 transform
756 : TX_32X16, // 32x16 transform
757 : TX_32X64, // 32x64 transform
758 : TX_64X32, // 64x32 transform
759 : TX_4X16, // 4x16 transform
760 : TX_16X4, // 16x4 transform
761 : TX_8X32, // 8x32 transform
762 : TX_32X8, // 32x8 transform
763 : TX_16X64, // 16x64 transform
764 : TX_64X16, // 64x16 transform
765 : TX_SIZES_ALL, // Includes rectangular transforms
766 : TX_SIZES = TX_4X8, // Does NOT include rectangular transforms
767 : TX_SIZES_LARGEST = TX_64X64,
768 : TX_INVALID = 255 // Invalid transform size
769 :
770 : #ifdef _MSC_VER
771 : };
772 : #else
773 : } TxSize;
774 : #endif
775 : static const TxSize tx_depth_to_tx_size[3][BlockSizeS_ALL] = {
776 : // tx_depth 0
777 : {
778 : TX_4X4,
779 : TX_4X8,
780 : TX_8X4,
781 : TX_8X8,
782 : TX_8X16,
783 : TX_16X8,
784 : TX_16X16,
785 : TX_16X32,
786 : TX_32X16,
787 : TX_32X32,
788 : TX_32X64,
789 : TX_64X32,
790 : TX_64X64,
791 : TX_64X64,//TX_64X128,
792 : TX_64X64,//TX_128X64,
793 : TX_64X64,//TX_128X128,
794 : TX_4X16,
795 : TX_16X4,
796 : TX_8X32,
797 : TX_32X8,
798 : TX_16X64,
799 : TX_64X16
800 : },
801 : // tx_depth 1:
802 : {
803 : TX_4X4,
804 : TX_4X8,
805 : TX_8X4,
806 : TX_4X4,
807 : TX_8X8,
808 : TX_8X8,
809 : TX_8X8,
810 : TX_16X16,
811 : TX_16X16,
812 : TX_16X16,
813 : TX_32X32,
814 : TX_32X32,
815 : TX_32X32,
816 : TX_64X64,//TX_64X128,
817 : TX_64X64,//TX_128X64,
818 : TX_64X64,//TX_128X128,
819 : TX_4X4,
820 : TX_4X4,
821 : TX_8X8,
822 : TX_8X8,
823 : TX_16X16,
824 : TX_16X16
825 : },
826 : // tx_depth 2
827 : {
828 : TX_4X4,
829 : TX_4X8,
830 : TX_8X4,
831 : TX_8X8,
832 : TX_4X4,
833 : TX_4X4,
834 : TX_4X4,
835 : TX_8X8,
836 : TX_8X8,
837 : TX_8X8,
838 : TX_16X16,
839 : TX_16X16,
840 : TX_16X16,
841 : TX_64X64,//TX_64X128,
842 : TX_64X64,//TX_128X64,
843 : TX_64X64,//TX_128X128,
844 : TX_4X16, // No depth 2
845 : TX_16X4, // No depth 2
846 : TX_4X4,
847 : TX_4X4,
848 : TX_8X8,
849 : TX_8X8
850 : }
851 : };
852 : static const int32_t tx_size_wide[TX_SIZES_ALL] = {
853 : 4, 8, 16, 32, 64, 4, 8, 8, 16, 16, 32, 32, 64, 4, 16, 8, 32, 16, 64,
854 : };
855 : // Transform block height in pixels
856 : static const int32_t tx_size_high[TX_SIZES_ALL] = {
857 : 4, 8, 16, 32, 64, 8, 4, 16, 8, 32, 16, 64, 32, 16, 4, 32, 8, 64, 16,
858 : };
859 :
860 : // TranLow is the datatype used for final transform coefficients.
861 : typedef int32_t TranLow;
862 : typedef uint8_t QmVal;
863 :
864 : typedef enum TxClass
865 : {
866 : TX_CLASS_2D = 0,
867 : TX_CLASS_HORIZ = 1,
868 : TX_CLASS_VERT = 2,
869 : TX_CLASSES = 3,
870 : } TxClass;
871 :
872 350575003 : static INLINE TxSize av1_get_adjusted_tx_size(TxSize tx_size)
873 : {
874 350575003 : switch (tx_size) {
875 3138068 : case TX_64X64:
876 : case TX_64X32:
877 3138068 : case TX_32X64: return TX_32X32;
878 1293468 : case TX_64X16: return TX_32X16;
879 1716658 : case TX_16X64: return TX_16X32;
880 344425928 : default: return tx_size;
881 : }
882 : }
883 :
884 : // Transform block width in log2
885 : static const int32_t tx_size_wide_log2[TX_SIZES_ALL] = {
886 : 2, 3, 4, 5, 6, 2, 3, 3, 4, 4, 5, 5, 6, 2, 4, 3, 5, 4, 6,
887 : };
888 :
889 : // Transform block height in log2
890 : static const int32_t tx_size_high_log2[TX_SIZES_ALL] = {
891 : 2, 3, 4, 5, 6, 3, 2, 4, 3, 5, 4, 6, 5, 4, 2, 5, 3, 6, 4,
892 : };
893 : #define ALIGN_POWER_OF_TWO(value, n) \
894 : (((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
895 : #define AOM_PLANE_Y 0 /**< Y (Luminance) plane */
896 : #define AOM_PLANE_U 1 /**< U (Chroma) plane */
897 : #define AOM_PLANE_V 2 /**< V (Chroma) plane */
898 :
899 : #define CONVERT_TO_SHORTPTR(x) ((uint16_t *)(((uintptr_t)(x)) << 1))
900 : #define CONVERT_TO_BYTEPTR(x) ((uint8_t *)(((uintptr_t)(x)) >> 1))
901 :
902 : #define AOMMIN(x, y) (((x) < (y)) ? (x) : (y))
903 : #define AOMMAX(x, y) (((x) > (y)) ? (x) : (y))
904 :
905 : // frame transform mode
906 : typedef enum ATTRIBUTE_PACKED
907 : {
908 : ONLY_4X4, // use only 4x4 transform
909 : TX_MODE_LARGEST, // transform size is the largest possible for pu size
910 : TX_MODE_SELECT, // transform specified for each block
911 : TX_MODES,
912 : } TxMode;
913 :
914 : // 1D tx types
915 : typedef enum ATTRIBUTE_PACKED
916 : {
917 : DCT_1D,
918 : ADST_1D,
919 : FLIPADST_1D,
920 : IDTX_1D,
921 : // TODO(sarahparker) need to eventually put something here for the
922 : // mrc experiment to make this work with the ext-tx pruning functions
923 : TX_TYPES_1D,
924 : } TxType1D;
925 :
926 : typedef enum ATTRIBUTE_PACKED
927 : {
928 : DCT_DCT, // DCT in both horizontal and vertical
929 : ADST_DCT, // ADST in vertical, DCT in horizontal
930 : DCT_ADST, // DCT in vertical, ADST in horizontal
931 : ADST_ADST, // ADST in both directions
932 : FLIPADST_DCT,
933 : DCT_FLIPADST,
934 : FLIPADST_FLIPADST,
935 : ADST_FLIPADST,
936 : FLIPADST_ADST,
937 : IDTX,
938 : V_DCT,
939 : H_DCT,
940 : V_ADST,
941 : H_ADST,
942 : V_FLIPADST,
943 : H_FLIPADST,
944 : TX_TYPES,
945 : } TxType;
946 :
947 : typedef enum ATTRIBUTE_PACKED
948 : {
949 : // DCT only
950 : EXT_TX_SET_DCTONLY,
951 : // DCT + Identity only
952 : EXT_TX_SET_DCT_IDTX,
953 : // Discrete Trig transforms w/o flip (4) + Identity (1)
954 : EXT_TX_SET_DTT4_IDTX,
955 : // Discrete Trig transforms w/o flip (4) + Identity (1) + 1D Hor/vert DCT (2)
956 : EXT_TX_SET_DTT4_IDTX_1DDCT,
957 : // Discrete Trig transforms w/ flip (9) + Identity (1) + 1D Hor/Ver DCT (2)
958 : EXT_TX_SET_DTT9_IDTX_1DDCT,
959 : // Discrete Trig transforms w/ flip (9) + Identity (1) + 1D Hor/Ver (6)
960 : EXT_TX_SET_ALL16,
961 : EXT_TX_SET_TYPES
962 : } TxSetType;
963 :
964 : typedef struct TxfmParam
965 : {
966 : // for both forward and inverse transforms
967 : TxType tx_type;
968 : TxSize tx_size;
969 : int32_t lossless;
970 : int32_t bd;
971 : // are the pixel buffers octets or shorts? This should collapse to
972 : // bd==8 implies !is_hbd, but that's not certain right now.
973 : int32_t is_hbd;
974 : TxSetType tx_set_type;
975 : // for inverse transforms only
976 : int32_t eob;
977 : } TxfmParam;
978 :
979 : #define IS_2D_TRANSFORM(tx_type) (tx_type < IDTX)
980 : #define EXT_TX_SIZES 4 // number of sizes that use extended transforms
981 : #define EXT_TX_SETS_INTER 4 // Sets of transform selections for INTER
982 : #define EXT_TX_SETS_INTRA 3 // Sets of transform selections for INTRA
983 :
984 : typedef enum ATTRIBUTE_PACKED
985 : {
986 : UNIDIR_COMP_REFERENCE,
987 : BIDIR_COMP_REFERENCE,
988 : COMP_REFERENCE_TYPES,
989 : } CompReferenceType;
990 :
991 : typedef enum ATTRIBUTE_PACKED
992 : {
993 : PLANE_TYPE_Y,
994 : PLANE_TYPE_UV,
995 : PLANE_TYPES
996 : } PlaneType;
997 :
998 : #define CFL_ALPHABET_SIZE_LOG2 4
999 : #define CFL_ALPHABET_SIZE (1 << CFL_ALPHABET_SIZE_LOG2)
1000 : #define CFL_MAGS_SIZE ((2 << CFL_ALPHABET_SIZE_LOG2) + 1)
1001 : #define CFL_IDX_U(idx) (idx >> CFL_ALPHABET_SIZE_LOG2)
1002 : #define CFL_IDX_V(idx) (idx & (CFL_ALPHABET_SIZE - 1))
1003 :
1004 : typedef enum ATTRIBUTE_PACKED
1005 : {
1006 : CFL_PRED_U,
1007 : CFL_PRED_V,
1008 : CFL_PRED_PLANES
1009 : } CflPredType;
1010 :
1011 : typedef enum ATTRIBUTE_PACKED
1012 : {
1013 : CFL_SIGN_ZERO,
1014 : CFL_SIGN_NEG,
1015 : CFL_SIGN_POS,
1016 : CFL_SIGNS
1017 : } CflSignType;
1018 :
1019 : typedef enum ATTRIBUTE_PACKED
1020 : {
1021 : CFL_DISALLOWED,
1022 : CFL_ALLOWED,
1023 : CFL_ALLOWED_TYPES
1024 : } CflAllowedType;
1025 :
1026 : // CFL_SIGN_ZERO,CFL_SIGN_ZERO is invalid
1027 : #define CFL_JOINT_SIGNS (CFL_SIGNS * CFL_SIGNS - 1)
1028 : // CFL_SIGN_U is equivalent to (js + 1) / 3 for js in 0 to 8
1029 : #define CFL_SIGN_U(js) (((js + 1) * 11) >> 5)
1030 : // CFL_SIGN_V is equivalent to (js + 1) % 3 for js in 0 to 8
1031 : #define CFL_SIGN_V(js) ((js + 1) - CFL_SIGNS * CFL_SIGN_U(js))
1032 :
1033 : // There is no context when the alpha for a given plane is zero.
1034 : // So there are 2 fewer contexts than joint signs.
1035 : #define CFL_ALPHA_CONTEXTS (CFL_JOINT_SIGNS + 1 - CFL_SIGNS)
1036 : #define CFL_CONTEXT_U(js) (js + 1 - CFL_SIGNS)
1037 : // Also, the contexts are symmetric under swapping the planes.
1038 : #define CFL_CONTEXT_V(js) \
1039 : (CFL_SIGN_V(js) * CFL_SIGNS + CFL_SIGN_U(js) - CFL_SIGNS)
1040 :
1041 : typedef enum ATTRIBUTE_PACKED {
1042 : PALETTE_MAP,
1043 : COLOR_MAP_TYPES,
1044 : } COLOR_MAP_TYPE;
1045 :
1046 : typedef enum ATTRIBUTE_PACKED {
1047 : TWO_COLORS,
1048 : THREE_COLORS,
1049 : FOUR_COLORS,
1050 : FIVE_COLORS,
1051 : SIX_COLORS,
1052 : SEVEN_COLORS,
1053 : EIGHT_COLORS,
1054 : PALETTE_SIZES
1055 : } PaletteSize;
1056 :
1057 : typedef enum ATTRIBUTE_PACKED
1058 : {
1059 : PALETTE_COLOR_ONE,
1060 : PALETTE_COLOR_TWO,
1061 : PALETTE_COLOR_THREE,
1062 : PALETTE_COLOR_FOUR,
1063 : PALETTE_COLOR_FIVE,
1064 : PALETTE_COLOR_SIX,
1065 : PALETTE_COLOR_SEVEN,
1066 : PALETTE_COLOR_EIGHT,
1067 : PALETTE_COLORS
1068 : } PaletteColor;
1069 :
1070 : // Note: All directional predictors must be between V_PRED and D67_PRED (both
1071 : // inclusive).
1072 : typedef enum ATTRIBUTE_PACKED
1073 : {
1074 : DC_PRED, // Average of above and left pixels
1075 : V_PRED, // Vertical
1076 : H_PRED, // Horizontal
1077 : D45_PRED, // Directional 45 degree
1078 : D135_PRED, // Directional 135 degree
1079 : D113_PRED, // Directional 113 degree
1080 : D157_PRED, // Directional 157 degree
1081 : D203_PRED, // Directional 203 degree
1082 : D67_PRED, // Directional 67 degree
1083 : SMOOTH_PRED, // Combination of horizontal and vertical interpolation
1084 : SMOOTH_V_PRED, // Vertical interpolation
1085 : SMOOTH_H_PRED, // Horizontal interpolation
1086 : PAETH_PRED, // Predict from the direction of smallest gradient
1087 : NEARESTMV,
1088 : NEARMV,
1089 : GLOBALMV,
1090 : NEWMV,
1091 : // Compound ref compound modes
1092 : NEAREST_NEARESTMV,
1093 : NEAR_NEARMV,
1094 : NEAREST_NEWMV,
1095 : NEW_NEARESTMV,
1096 : NEAR_NEWMV,
1097 : NEW_NEARMV,
1098 : GLOBAL_GLOBALMV,
1099 : NEW_NEWMV,
1100 : MB_MODE_COUNT,
1101 : INTRA_MODE_START = DC_PRED,
1102 : INTRA_MODE_END = NEARESTMV,
1103 : INTRA_MODE_NUM = INTRA_MODE_END - INTRA_MODE_START,
1104 : SINGLE_INTER_MODE_START = NEARESTMV,
1105 : SINGLE_INTER_MODE_END = NEAREST_NEARESTMV,
1106 : SINGLE_INTER_MODE_NUM = SINGLE_INTER_MODE_END - SINGLE_INTER_MODE_START,
1107 : COMP_INTER_MODE_START = NEAREST_NEARESTMV,
1108 : COMP_INTER_MODE_END = MB_MODE_COUNT,
1109 : COMP_INTER_MODE_NUM = COMP_INTER_MODE_END - COMP_INTER_MODE_START,
1110 : INTRA_MODES = PAETH_PRED + 1, // PAETH_PRED has to be the last intra mode.
1111 : INTRA_INVALID = MB_MODE_COUNT, // For uv_mode in inter blocks
1112 : INTRA_MODE_4x4
1113 : } PredictionMode;
1114 :
1115 : // TODO(ltrudeau) Do we really want to pack this?
1116 : // TODO(ltrudeau) Do we match with PredictionMode?
1117 : typedef enum ATTRIBUTE_PACKED
1118 : {
1119 : UV_DC_PRED, // Average of above and left pixels
1120 : UV_V_PRED, // Vertical
1121 : UV_H_PRED, // Horizontal
1122 : UV_D45_PRED, // Directional 45 degree
1123 : UV_D135_PRED, // Directional 135 degree
1124 : UV_D113_PRED, // Directional 113 degree
1125 : UV_D157_PRED, // Directional 157 degree
1126 : UV_D203_PRED, // Directional 203 degree
1127 : UV_D67_PRED, // Directional 67 degree
1128 : UV_SMOOTH_PRED, // Combination of horizontal and vertical interpolation
1129 : UV_SMOOTH_V_PRED, // Vertical interpolation
1130 : UV_SMOOTH_H_PRED, // Horizontal interpolation
1131 : UV_PAETH_PRED, // Predict from the direction of smallest gradient
1132 : UV_CFL_PRED, // Chroma-from-Luma
1133 : UV_INTRA_MODES,
1134 : UV_MODE_INVALID, // For uv_mode in inter blocks
1135 : } UvPredictionMode;
1136 :
1137 : typedef enum ATTRIBUTE_PACKED
1138 : {
1139 : SIMPLE_TRANSLATION,
1140 : OBMC_CAUSAL, // 2-sided OBMC
1141 : WARPED_CAUSAL, // 2-sided WARPED
1142 : MOTION_MODES
1143 : } MotionMode;
1144 :
1145 : typedef enum ATTRIBUTE_PACKED
1146 : {
1147 : II_DC_PRED,
1148 : II_V_PRED,
1149 : II_H_PRED,
1150 : II_SMOOTH_PRED,
1151 : INTERINTRA_MODES
1152 : } InterIntraMode;
1153 :
1154 : typedef enum
1155 : {
1156 : COMPOUND_AVERAGE,
1157 : COMPOUND_DISTWTD,
1158 : COMPOUND_WEDGE,
1159 : COMPOUND_DIFFWTD,
1160 : COMPOUND_TYPES,
1161 : MASKED_COMPOUND_TYPES = 2,
1162 : } CompoundType;
1163 :
1164 : #define COMPOUND_INTRA 4//just for the decoder
1165 : #define AOM_BLEND_A64_ROUND_BITS 6
1166 : #define AOM_BLEND_A64_MAX_ALPHA (1 << AOM_BLEND_A64_ROUND_BITS) // 64
1167 :
1168 : #define AOM_BLEND_A64(a, v0, v1) \
1169 : ROUND_POWER_OF_TWO((a) * (v0) + (AOM_BLEND_A64_MAX_ALPHA - (a)) * (v1), \
1170 : AOM_BLEND_A64_ROUND_BITS)
1171 : #define DIFF_FACTOR_LOG2 4
1172 : #define DIFF_FACTOR (1 << DIFF_FACTOR_LOG2)
1173 : #define AOM_BLEND_AVG(v0, v1) ROUND_POWER_OF_TWO((v0) + (v1), 1)
1174 : typedef uint16_t CONV_BUF_TYPE;
1175 : #define MAX_WEDGE_TYPES (1 << 4)
1176 : #define MAX_WEDGE_SIZE_LOG2 5 // 32x32
1177 : #define MAX_WEDGE_SIZE (1 << MAX_WEDGE_SIZE_LOG2)
1178 : #define MAX_WEDGE_SQUARE (MAX_WEDGE_SIZE * MAX_WEDGE_SIZE)
1179 : #define WEDGE_WEIGHT_BITS 6
1180 : #define WEDGE_NONE -1
1181 : #define MASK_MASTER_SIZE ((MAX_WEDGE_SIZE) << 1)
1182 : #define MASK_MASTER_STRIDE (MASK_MASTER_SIZE)
1183 : typedef struct {
1184 : int enable_order_hint; // 0 - disable order hint, and related tools
1185 : int order_hint_bits_minus_1; // dist_wtd_comp, ref_frame_mvs,
1186 : int enable_dist_wtd_comp; // 0 - disable dist-wtd compound modes
1187 : int enable_ref_frame_mvs; // 0 - disable ref frame mvs
1188 : } OrderHintInfoEnc;
1189 : enum {
1190 : MD_COMP_AVG,
1191 : MD_COMP_DIST,
1192 : MD_COMP_DIFF0,
1193 : MD_COMP_WEDGE,
1194 : MD_COMP_TYPES,
1195 : } UENUM1BYTE(MD_COMP_TYPE);
1196 : #define COMPOUND_TYPE CompoundType
1197 : #define MAX_DIFFWTD_MASK_BITS 1
1198 : enum {
1199 : DIFFWTD_38 = 0,
1200 : DIFFWTD_38_INV,
1201 : DIFFWTD_MASK_TYPES,
1202 : } UENUM1BYTE(DIFFWTD_MASK_TYPE);
1203 : typedef struct {
1204 :
1205 : /*!< Specifies how the two predictions should be blended together. */
1206 : CompoundType type;
1207 :
1208 : /*!< Used to derive the direction and offset of the wedge mask used during blending. */
1209 : uint8_t wedge_index;
1210 :
1211 : /*!< Specifies the sign of the wedge blend. */
1212 : uint8_t wedge_sign;
1213 :
1214 : /*!< Specifies the type of mask to be used during blending. */
1215 : DIFFWTD_MASK_TYPE mask_type;
1216 : } InterInterCompoundData;
1217 :
1218 : #if II_COMP_FLAG
1219 : #define INTERINTRA_MODE InterIntraMode
1220 : #endif
1221 : typedef enum ATTRIBUTE_PACKED
1222 : {
1223 : FILTER_DC_PRED,
1224 : FILTER_V_PRED,
1225 : FILTER_H_PRED,
1226 : FILTER_D157_PRED,
1227 : FILTER_PAETH_PRED,
1228 : FILTER_INTRA_MODES,
1229 : } FilterIntraMode;
1230 :
1231 : #if FILTER_INTRA_FLAG
1232 : static const PredictionMode fimode_to_intramode[FILTER_INTRA_MODES] = {
1233 : DC_PRED, V_PRED, H_PRED, D157_PRED, PAETH_PRED
1234 : };
1235 : #endif
1236 : #define DIRECTIONAL_MODES 8
1237 : #define MAX_ANGLE_DELTA 3
1238 : #define ANGLE_STEP 3
1239 :
1240 : #define INTER_MODES (1 + NEWMV - NEARESTMV)
1241 :
1242 : #define INTER_COMPOUND_MODES (1 + NEW_NEWMV - NEAREST_NEARESTMV)
1243 :
1244 : #define SKIP_CONTEXTS 3
1245 : #define SKIP_MODE_CONTEXTS 3
1246 :
1247 : #define COMP_INDEX_CONTEXTS 6
1248 : #define COMP_GROUP_IDX_CONTEXTS 6
1249 :
1250 : #define NMV_CONTEXTS 3
1251 :
1252 : #define NEWMV_MODE_CONTEXTS 6
1253 : #define GLOBALMV_MODE_CONTEXTS 2
1254 : #define REFMV_MODE_CONTEXTS 6
1255 : #define DRL_MODE_CONTEXTS 3
1256 :
1257 : #define GLOBALMV_OFFSET 3
1258 : #define REFMV_OFFSET 4
1259 :
1260 : #define NEWMV_CTX_MASK ((1 << GLOBALMV_OFFSET) - 1)
1261 : #define GLOBALMV_CTX_MASK ((1 << (REFMV_OFFSET - GLOBALMV_OFFSET)) - 1)
1262 : #define REFMV_CTX_MASK ((1 << (8 - REFMV_OFFSET)) - 1)
1263 :
1264 : #define COMP_NEWMV_CTXS 5
1265 : #define INTER_MODE_CONTEXTS 8
1266 :
1267 : #define DELTA_Q_SMALL 3
1268 : #define DELTA_Q_PROBS (DELTA_Q_SMALL)
1269 : #define DEFAULT_DELTA_Q_RES 1
1270 : #define DELTA_LF_SMALL 3
1271 : #define DELTA_LF_PROBS (DELTA_LF_SMALL)
1272 : #define DEFAULT_DELTA_LF_RES 2
1273 :
1274 : /* Segment Feature Masks */
1275 : #define MAX_MV_REF_CANDIDATES 2
1276 :
1277 : #define MAX_REF_MV_STACK_SIZE 8
1278 : #define REF_CAT_LEVEL 640
1279 :
1280 : #define INTRA_INTER_CONTEXTS 4
1281 : #define COMP_INTER_CONTEXTS 5
1282 : #define REF_CONTEXTS 3
1283 :
1284 : #define COMP_REF_TYPE_CONTEXTS 5
1285 : #define UNI_COMP_REF_CONTEXTS 3
1286 :
1287 : #define TXFM_PARTITION_CONTEXTS ((TX_SIZES - TX_8X8) * 6 - 3)
1288 : typedef uint8_t TXFM_CONTEXT;
1289 :
1290 : // frame types
1291 : #define NONE_FRAME -1
1292 : #define INTRA_FRAME 0
1293 : #define LAST_FRAME 1
1294 : #define LAST2_FRAME 2
1295 : #define LAST3_FRAME 3
1296 : #define GOLDEN_FRAME 4
1297 : #define BWDREF_FRAME 5
1298 : #define ALTREF2_FRAME 6
1299 : #define ALTREF_FRAME 7
1300 : #define LAST_REF_FRAMES (LAST3_FRAME - LAST_FRAME + 1)
1301 :
1302 : #define REFS_PER_FRAME 7
1303 : #define INTER_REFS_PER_FRAME (ALTREF_FRAME - LAST_FRAME + 1)
1304 : #define TOTAL_REFS_PER_FRAME (ALTREF_FRAME - INTRA_FRAME + 1)
1305 :
1306 : #define FWD_REFS (GOLDEN_FRAME - LAST_FRAME + 1)
1307 : #define FWD_RF_OFFSET(ref) (ref - LAST_FRAME)
1308 : #define BWD_REFS (ALTREF_FRAME - BWDREF_FRAME + 1)
1309 : #define BWD_RF_OFFSET(ref) (ref - BWDREF_FRAME)
1310 :
1311 : #define SINGLE_REFS (FWD_REFS + BWD_REFS)
1312 :
1313 : typedef enum ATTRIBUTE_PACKED
1314 : {
1315 : LAST_LAST2_FRAMES, // { LAST_FRAME, LAST2_FRAME }
1316 : LAST_LAST3_FRAMES, // { LAST_FRAME, LAST3_FRAME }
1317 : LAST_GOLDEN_FRAMES, // { LAST_FRAME, GOLDEN_FRAME }
1318 : BWDREF_ALTREF_FRAMES, // { BWDREF_FRAME, ALTREF_FRAME }
1319 : LAST2_LAST3_FRAMES, // { LAST2_FRAME, LAST3_FRAME }
1320 : LAST2_GOLDEN_FRAMES, // { LAST2_FRAME, GOLDEN_FRAME }
1321 : LAST3_GOLDEN_FRAMES, // { LAST3_FRAME, GOLDEN_FRAME }
1322 : BWDREF_ALTREF2_FRAMES, // { BWDREF_FRAME, ALTREF2_FRAME }
1323 : ALTREF2_ALTREF_FRAMES, // { ALTREF2_FRAME, ALTREF_FRAME }
1324 : TOTAL_UNIDIR_COMP_REFS,
1325 : // NOTE: UNIDIR_COMP_REFS is the number of uni-directional reference pairs
1326 : // that are explicitly signaled.
1327 : UNIDIR_COMP_REFS = BWDREF_ALTREF_FRAMES + 1,
1328 : } UniDirCompRef;
1329 :
1330 : #define TOTAL_COMP_REFS (FWD_REFS * BWD_REFS + TOTAL_UNIDIR_COMP_REFS)
1331 :
1332 : #define COMP_REFS (FWD_REFS * BWD_REFS + UNIDIR_COMP_REFS)
1333 :
1334 : // NOTE: A limited number of unidirectional reference pairs can be signalled for
1335 : // compound prediction. The use of skip mode, on the other hand, makes it
1336 : // possible to have a reference pair not listed for explicit signaling.
1337 : #define MODE_CTX_REF_FRAMES (TOTAL_REFS_PER_FRAME + TOTAL_COMP_REFS)
1338 :
1339 : typedef enum ATTRIBUTE_PACKED
1340 : {
1341 : RESTORE_NONE,
1342 : RESTORE_WIENER,
1343 : RESTORE_SGRPROJ,
1344 : RESTORE_SWITCHABLE,
1345 : RESTORE_SWITCHABLE_TYPES = RESTORE_SWITCHABLE,
1346 : RESTORE_TYPES = 4,
1347 : } RestorationType;
1348 :
1349 : #define SCALE_NUMERATOR 8
1350 : #define SUPERRES_SCALE_BITS 3
1351 : #define SUPERRES_SCALE_DENOMINATOR_MIN (SCALE_NUMERATOR + 1)
1352 :
1353 : //*********************************************************************************************************************//
1354 : // assert.h
1355 : #undef assert
1356 :
1357 : #ifdef NDEBUG
1358 :
1359 : #define assert(expression) ((void)0)
1360 :
1361 : #else
1362 : #define assert(expression) ((void)0)
1363 :
1364 : #endif
1365 : //**********************************************************************************************************************//
1366 : // onyxc_int.h
1367 : #define CDEF_MAX_STRENGTHS 16
1368 :
1369 : #define REF_FRAMES_LOG2 3
1370 : #define REF_FRAMES (1 << REF_FRAMES_LOG2)
1371 :
1372 : // 4 scratch frames for the new frames to support a maximum of 4 cores decoding
1373 : // in parallel, 3 for scaled references on the encoder.
1374 : // TODO(hkuang): Add ondemand frame buffers instead of hardcoding the number
1375 : // of framebuffers.
1376 : // TODO(jkoleszar): These 3 extra references could probably come from the
1377 : // normal reference pool.
1378 : #define FRAME_BUFFERS (REF_FRAMES + 7)
1379 :
1380 : /* Constant values while waiting for the sequence header */
1381 : #define FRAME_ID_LENGTH 15
1382 : #define DELTA_FRAME_ID_LENGTH 14
1383 :
1384 : #define FRAME_CONTEXTS (FRAME_BUFFERS + 1)
1385 : // Extra frame context which is always kept at default values
1386 : #define FRAME_CONTEXT_DEFAULTS (FRAME_CONTEXTS - 1)
1387 : #define PRIMARY_REF_BITS 3
1388 : #define PRIMARY_REF_NONE 7
1389 :
1390 : #define NUM_PING_PONG_BUFFERS 2
1391 :
1392 : #define MAX_NUM_TEMPORAL_LAYERS 8
1393 : #define MAX_NUM_SPATIAL_LAYERS 4
1394 : /* clang-format off */
1395 : // clang-format seems to think this is a pointer dereference and not a
1396 : // multiplication.
1397 : #define MAX_NUM_OPERATING_POINTS \
1398 : MAX_NUM_TEMPORAL_LAYERS * MAX_NUM_SPATIAL_LAYERS
1399 :
1400 3 : static INLINE int32_t is_valid_seq_level_idx(uint8_t seq_level_idx) {
1401 3 : return seq_level_idx < 24 || seq_level_idx == 31;
1402 : }
1403 : // TODO(jingning): Turning this on to set up transform coefficient
1404 : // processing timer.
1405 : #define TXCOEFF_TIMER 0
1406 : #define TXCOEFF_COST_TIMER 0
1407 :
1408 : typedef enum
1409 : {
1410 : SINGLE_REFERENCE = 0,
1411 : COMPOUND_REFERENCE = 1,
1412 : REFERENCE_MODE_SELECT = 2,
1413 : REFERENCE_MODES = 3,
1414 : } ReferenceMode;
1415 :
1416 : typedef enum RefreshFrameContextMode
1417 : {
1418 : /**
1419 : * Frame context updates are disabled
1420 : */
1421 : REFRESH_FRAME_CONTEXT_DISABLED,
1422 : /**
1423 : * Update frame context to values resulting from backward probability
1424 : * updates based on entropy/counts in the decoded frame
1425 : */
1426 : REFRESH_FRAME_CONTEXT_BACKWARD,
1427 : } RefreshFrameContextMode;
1428 :
1429 : //**********************************************************************************************************************//
1430 : // aom_codec.h
1431 : /*!\brief Algorithm return codes */
1432 : typedef enum AomCodecErr
1433 : {
1434 : /*!\brief Operation completed without error */
1435 : AOM_CODEC_OK,
1436 : /*!\brief Unspecified error */
1437 : AOM_CODEC_ERROR,
1438 : /*!\brief Memory operation failed */
1439 : AOM_CODEC_MEM_ERROR,
1440 : /*!\brief ABI version mismatch */
1441 : AOM_CODEC_ABI_MISMATCH,
1442 : /*!\brief Algorithm does not have required capability */
1443 : AOM_CODEC_INCAPABLE,
1444 : /*!\brief The given bitstream is not supported.
1445 : *
1446 : * The bitstream was unable to be parsed at the highest level. The decoder
1447 : * is unable to proceed. This error \ref SHOULD be treated as fatal to the
1448 : * stream. */
1449 : AOM_CODEC_UNSUP_BITSTREAM,
1450 : /*!\brief Encoded bitstream uses an unsupported feature
1451 : *
1452 : * The decoder does not implement a feature required by the encoder. This
1453 : * return code should only be used for features that prevent future
1454 : * pictures from being properly decoded. This error \ref MAY be treated as
1455 : * fatal to the stream or \ref MAY be treated as fatal to the current GOP.
1456 : */
1457 : AOM_CODEC_UNSUP_FEATURE,
1458 : /*!\brief The coded data for this stream is corrupt or incomplete
1459 : *
1460 : * There was a problem decoding the current frame. This return code
1461 : * should only be used for failures that prevent future pictures from
1462 : * being properly decoded. This error \ref MAY be treated as fatal to the
1463 : * stream or \ref MAY be treated as fatal to the current GOP. If decoding
1464 : * is continued for the current GOP, artifacts may be present.
1465 : */
1466 : AOM_CODEC_CORRUPT_FRAME,
1467 : /*!\brief An application-supplied parameter is not valid.
1468 : *
1469 : */
1470 : AOM_CODEC_INVALID_PARAM,
1471 : /*!\brief An iterator reached the end of list.
1472 : *
1473 : */
1474 : AOM_CODEC_LIST_END
1475 : } AomCodecErr;
1476 :
1477 : //**********************************************************************************************************************//
1478 : // Common_data.h
1479 : static const int32_t intra_mode_context[INTRA_MODES] = {
1480 : 0, 1, 2, 3, 4, 4, 4, 4, 3, 0, 1, 2, 0,
1481 : };
1482 :
1483 : static const TxSize txsize_sqr_map[TX_SIZES_ALL] = {
1484 : TX_4X4, // TX_4X4
1485 : TX_8X8, // TX_8X8
1486 : TX_16X16, // TX_16X16
1487 : TX_32X32, // TX_32X32
1488 : TX_64X64, // TX_64X64
1489 : TX_4X4, // TX_4X8
1490 : TX_4X4, // TX_8X4
1491 : TX_8X8, // TX_8X16
1492 : TX_8X8, // TX_16X8
1493 : TX_16X16, // TX_16X32
1494 : TX_16X16, // TX_32X16
1495 : TX_32X32, // TX_32X64
1496 : TX_32X32, // TX_64X32
1497 : TX_4X4, // TX_4X16
1498 : TX_4X4, // TX_16X4
1499 : TX_8X8, // TX_8X32
1500 : TX_8X8, // TX_32X8
1501 : TX_16X16, // TX_16X64
1502 : TX_16X16, // TX_64X16
1503 : };
1504 : static const TxSize txsize_sqr_up_map[TX_SIZES_ALL] = {
1505 : TX_4X4, // TX_4X4
1506 : TX_8X8, // TX_8X8
1507 : TX_16X16, // TX_16X16
1508 : TX_32X32, // TX_32X32
1509 : TX_64X64, // TX_64X64
1510 : TX_8X8, // TX_4X8
1511 : TX_8X8, // TX_8X4
1512 : TX_16X16, // TX_8X16
1513 : TX_16X16, // TX_16X8
1514 : TX_32X32, // TX_16X32
1515 : TX_32X32, // TX_32X16
1516 : TX_64X64, // TX_32X64
1517 : TX_64X64, // TX_64X32
1518 : TX_16X16, // TX_4X16
1519 : TX_16X16, // TX_16X4
1520 : TX_32X32, // TX_8X32
1521 : TX_32X32, // TX_32X8
1522 : TX_64X64, // TX_16X64
1523 : TX_64X64, // TX_64X16
1524 : };
1525 :
1526 : // above and left partition
1527 : typedef struct PartitionContext
1528 : {
1529 : PartitionContextType above;
1530 : PartitionContextType left;
1531 : }PartitionContext;
1532 : // Generates 5 bit field in which each bit set to 1 represents
1533 : // a BlockSize partition 11111 means we split 128x128, 64x64, 32x32, 16x16
1534 : // and 8x8. 10000 means we just split the 128x128 to 64x64
1535 : /* clang-format off */
1536 : static const struct
1537 : {
1538 : PartitionContextType above;
1539 : PartitionContextType left;
1540 : } partition_context_lookup[BlockSizeS_ALL] = {
1541 : { 31, 31 }, // 4X4 - {0b11111, 0b11111}
1542 : { 31, 30 }, // 4X8 - {0b11111, 0b11110}
1543 : { 30, 31 }, // 8X4 - {0b11110, 0b11111}
1544 : { 30, 30 }, // 8X8 - {0b11110, 0b11110}
1545 : { 30, 28 }, // 8X16 - {0b11110, 0b11100}
1546 : { 28, 30 }, // 16X8 - {0b11100, 0b11110}
1547 : { 28, 28 }, // 16X16 - {0b11100, 0b11100}
1548 : { 28, 24 }, // 16X32 - {0b11100, 0b11000}
1549 : { 24, 28 }, // 32X16 - {0b11000, 0b11100}
1550 : { 24, 24 }, // 32X32 - {0b11000, 0b11000}
1551 : { 24, 16 }, // 32X64 - {0b11000, 0b10000}
1552 : { 16, 24 }, // 64X32 - {0b10000, 0b11000}
1553 : { 16, 16 }, // 64X64 - {0b10000, 0b10000}
1554 : { 16, 0 }, // 64X128- {0b10000, 0b00000}
1555 : { 0, 16 }, // 128X64- {0b00000, 0b10000}
1556 : { 0, 0 }, // 128X128-{0b00000, 0b00000}
1557 : { 31, 28 }, // 4X16 - {0b11111, 0b11100}
1558 : { 28, 31 }, // 16X4 - {0b11100, 0b11111}
1559 : { 30, 24 }, // 8X32 - {0b11110, 0b11000}
1560 : { 24, 30 }, // 32X8 - {0b11000, 0b11110}
1561 : { 28, 16 }, // 16X64 - {0b11100, 0b10000}
1562 : { 16, 28 }, // 64X16 - {0b10000, 0b11100}
1563 : };
1564 : /* clang-format on */
1565 :
1566 : // Width/height lookup tables in units of various block sizes
1567 : static const uint8_t block_size_wide[BlockSizeS_ALL] = {
1568 : 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32,
1569 : 64, 64, 64, 128, 128, 4, 16, 8, 32, 16, 64
1570 : };
1571 :
1572 : static const uint8_t block_size_high[BlockSizeS_ALL] = {
1573 : 4, 8, 4, 8, 16, 8, 16, 32, 16, 32, 64,
1574 : 32, 64, 128, 64, 128, 16, 4, 32, 8, 64, 16
1575 : };
1576 :
1577 : // AOMMIN(3, AOMMIN(b_width_log2(bsize), b_height_log2(bsize)))
1578 : static const uint8_t size_group_lookup[BlockSizeS_ALL] = {
1579 : 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 0, 0, 1, 1, 2, 2
1580 : };
1581 :
1582 : static const uint8_t num_pels_log2_lookup[BlockSizeS_ALL] = {
1583 : 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12, 13, 13, 14, 6, 6, 8, 8, 10, 10
1584 : };
1585 : static const TxSize max_txsize_lookup[BlockSizeS_ALL] = {
1586 : // 4X4
1587 : TX_4X4,
1588 : // 4X8, 8X4, 8X8
1589 : TX_4X4, TX_4X4, TX_8X8,
1590 : // 8X16, 16X8, 16X16
1591 : TX_8X8, TX_8X8, TX_16X16,
1592 : // 16X32, 32X16, 32X32
1593 : TX_16X16, TX_16X16, TX_32X32,
1594 : // 32X64, 64X32,
1595 : TX_32X32, TX_32X32,
1596 : // 64X64
1597 : TX_64X64,
1598 : // 64x128, 128x64, 128x128
1599 : TX_64X64, TX_64X64, TX_64X64,
1600 : // 4x16, 16x4, 8x32
1601 : TX_4X4, TX_4X4, TX_8X8,
1602 : // 32x8, 16x64 64x16
1603 : TX_8X8, TX_16X16, TX_16X16
1604 : };
1605 :
1606 : static const TxSize max_txsize_rect_lookup[BlockSizeS_ALL] = {
1607 : // 4X4
1608 : TX_4X4,
1609 : // 4X8, 8X4, 8X8
1610 : TX_4X8, TX_8X4, TX_8X8,
1611 : // 8X16, 16X8, 16X16
1612 : TX_8X16, TX_16X8, TX_16X16,
1613 : // 16X32, 32X16, 32X32
1614 : TX_16X32, TX_32X16, TX_32X32,
1615 : // 32X64, 64X32,
1616 : TX_32X64, TX_64X32,
1617 : // 64X64
1618 : TX_64X64,
1619 : // 64x128, 128x64, 128x128
1620 : TX_64X64, TX_64X64, TX_64X64,
1621 : // 4x16, 16x4,
1622 : TX_4X16, TX_16X4,
1623 : // 8x32, 32x8
1624 : TX_8X32, TX_32X8,
1625 : // 16x64, 64x16
1626 : TX_16X64, TX_64X16
1627 : };
1628 :
1629 : // Transform block width in unit
1630 : static const int32_t tx_size_wide_unit[TX_SIZES_ALL] = {
1631 : 1, 2, 4, 8, 16, 1, 2, 2, 4, 4, 8, 8, 16, 1, 4, 2, 8, 4, 16,
1632 : };
1633 : // Transform block height in unit
1634 : static const int32_t tx_size_high_unit[TX_SIZES_ALL] = {
1635 : 1, 2, 4, 8, 16, 2, 1, 4, 2, 8, 4, 16, 8, 4, 1, 8, 2, 16, 4,
1636 : };
1637 :
1638 : static const TxSize sub_tx_size_map[TX_SIZES_ALL] = {
1639 : TX_4X4, // TX_4X4
1640 : TX_4X4, // TX_8X8
1641 : TX_8X8, // TX_16X16
1642 : TX_16X16, // TX_32X32
1643 : TX_32X32, // TX_64X64
1644 : TX_4X4, // TX_4X8
1645 : TX_4X4, // TX_8X4
1646 : TX_8X8, // TX_8X16
1647 : TX_8X8, // TX_16X8
1648 : TX_16X16, // TX_16X32
1649 : TX_16X16, // TX_32X16
1650 : TX_32X32, // TX_32X64
1651 : TX_32X32, // TX_64X32
1652 : TX_4X8, // TX_4X16
1653 : TX_8X4, // TX_16X4
1654 : TX_8X16, // TX_8X32
1655 : TX_16X8, // TX_32X8
1656 : TX_16X32, // TX_16X64
1657 : TX_32X16, // TX_64X16
1658 : };
1659 : static const TxSize txsize_horz_map[TX_SIZES_ALL] = {
1660 : TX_4X4, // TX_4X4
1661 : TX_8X8, // TX_8X8
1662 : TX_16X16, // TX_16X16
1663 : TX_32X32, // TX_32X32
1664 : TX_64X64, // TX_64X64
1665 : TX_4X4, // TX_4X8
1666 : TX_8X8, // TX_8X4
1667 : TX_8X8, // TX_8X16
1668 : TX_16X16, // TX_16X8
1669 : TX_16X16, // TX_16X32
1670 : TX_32X32, // TX_32X16
1671 : TX_32X32, // TX_32X64
1672 : TX_64X64, // TX_64X32
1673 : TX_4X4, // TX_4X16
1674 : TX_16X16, // TX_16X4
1675 : TX_8X8, // TX_8X32
1676 : TX_32X32, // TX_32X8
1677 : TX_16X16, // TX_16X64
1678 : TX_64X64, // TX_64X16
1679 : };
1680 :
1681 : static const TxSize txsize_vert_map[TX_SIZES_ALL] = {
1682 : TX_4X4, // TX_4X4
1683 : TX_8X8, // TX_8X8
1684 : TX_16X16, // TX_16X16
1685 : TX_32X32, // TX_32X32
1686 : TX_64X64, // TX_64X64
1687 : TX_8X8, // TX_4X8
1688 : TX_4X4, // TX_8X4
1689 : TX_16X16, // TX_8X16
1690 : TX_8X8, // TX_16X8
1691 : TX_32X32, // TX_16X32
1692 : TX_16X16, // TX_32X16
1693 : TX_64X64, // TX_32X64
1694 : TX_32X32, // TX_64X32
1695 : TX_16X16, // TX_4X16
1696 : TX_4X4, // TX_16X4
1697 : TX_32X32, // TX_8X32
1698 : TX_8X8, // TX_32X8
1699 : TX_64X64, // TX_16X64
1700 : TX_16X16, // TX_64X16
1701 : };
1702 : static const uint8_t mi_size_wide_log2[BlockSizeS_ALL] = {
1703 : 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 0, 2, 1, 3, 2, 4
1704 : };
1705 : static const uint8_t mi_size_high_log2[BlockSizeS_ALL] = {
1706 : 0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 2, 0, 3, 1, 4, 2
1707 : };
1708 :
1709 : typedef struct SgrParamsType
1710 : {
1711 : int32_t r[2]; // radii
1712 : int32_t s[2]; // sgr parameters for r[0] and r[1], based on GenSgrprojVtable()
1713 : } SgrParamsType;
1714 :
1715 : //**********************************************************************************************************************//
1716 : // blockd.h
1717 : typedef enum FrameType
1718 : {
1719 : KEY_FRAME = 0,
1720 : INTER_FRAME = 1,
1721 : INTRA_ONLY_FRAME = 2, // replaces intra-only
1722 : S_FRAME = 3,
1723 : FRAME_TYPES,
1724 : } FrameType;
1725 :
1726 : typedef int8_t MvReferenceFrame;
1727 :
1728 : // Number of transform types in each set type
1729 :
1730 : static const int32_t av1_num_ext_tx_set[EXT_TX_SET_TYPES] = {
1731 : 1, 2, 5, 7, 12, 16,
1732 : };
1733 :
1734 : static const int32_t av1_ext_tx_used[EXT_TX_SET_TYPES][TX_TYPES] = {
1735 : { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
1736 : { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
1737 : { 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
1738 : { 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0 },
1739 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
1740 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
1741 : };
1742 :
1743 86185673 : static INLINE TxSetType get_ext_tx_set_type(TxSize tx_size, int32_t is_inter,
1744 : int32_t use_reduced_set) {
1745 86185673 : const TxSize tx_size_sqr_up = txsize_sqr_up_map[tx_size];
1746 :
1747 86185673 : if (tx_size_sqr_up > TX_32X32) return EXT_TX_SET_DCTONLY;
1748 84943360 : if (tx_size_sqr_up == TX_32X32)
1749 5716502 : return is_inter ? EXT_TX_SET_DCT_IDTX : EXT_TX_SET_DCTONLY;
1750 79226923 : if (use_reduced_set)
1751 0 : return is_inter ? EXT_TX_SET_DCT_IDTX : EXT_TX_SET_DTT4_IDTX;
1752 79226923 : const TxSize tx_size_sqr = txsize_sqr_map[tx_size];
1753 79226923 : if (is_inter) {
1754 : return (tx_size_sqr == TX_16X16 ? EXT_TX_SET_DTT9_IDTX_1DDCT
1755 30412496 : : EXT_TX_SET_ALL16);
1756 : }
1757 : else {
1758 : return (tx_size_sqr == TX_16X16 ? EXT_TX_SET_DTT4_IDTX
1759 48814427 : : EXT_TX_SET_DTT4_IDTX_1DDCT);
1760 : }
1761 : }
1762 34571910 : static INLINE int32_t get_ext_tx_types(TxSize tx_size, int32_t is_inter,
1763 : int32_t use_reduced_set) {
1764 34571910 : const int32_t set_type = get_ext_tx_set_type(tx_size, is_inter, use_reduced_set);
1765 34575110 : return av1_num_ext_tx_set[set_type];
1766 : }
1767 : // Maps tx set types to the indices.
1768 : static const int32_t ext_tx_set_index[2][EXT_TX_SET_TYPES] = {
1769 : { // Intra
1770 : 0, -1, 2, 1, -1, -1 },
1771 : { // Inter
1772 : 0, 3, -1, -1, 2, 1 },
1773 : };
1774 :
1775 33019798 : static INLINE int32_t get_ext_tx_set(TxSize tx_size, int32_t is_inter,
1776 : int32_t use_reduced_set) {
1777 : const TxSetType set_type =
1778 33019798 : get_ext_tx_set_type(tx_size, is_inter, use_reduced_set);
1779 33016806 : return ext_tx_set_index[is_inter][set_type];
1780 : }
1781 :
1782 161349040 : static INLINE int32_t is_inter_compound_mode(PredictionMode mode) {
1783 161349040 : return mode >= NEAREST_NEARESTMV && mode <= NEW_NEWMV;
1784 : }
1785 12303 : static INLINE int is_inter_singleref_mode(PredictionMode mode) {
1786 12303 : return mode >= SINGLE_INTER_MODE_START && mode < SINGLE_INTER_MODE_END;
1787 : }
1788 :
1789 : //**********************************************************************************************************************//
1790 : // encoder.h
1791 : typedef enum FrameContextIndex
1792 : {
1793 : // regular inter frame
1794 : REGULAR_FRAME = 0,
1795 : // alternate reference frame
1796 : ARF_FRAME = 1,
1797 : // overlay frame
1798 : OVERLAY_FRAME = 2,
1799 : // golden frame
1800 : GLD_FRAME = 3,
1801 : // backward reference frame
1802 : BRF_FRAME = 4,
1803 : // extra alternate reference frame
1804 : EXT_ARF_FRAME = 5,
1805 : FRAME_CONTEXT_INDEXES
1806 : } FrameContextIndex;
1807 :
1808 : //**********************************************************************************************************************//
1809 : // common.h
1810 : #define av1_zero(dest) memset(&(dest), 0, sizeof(dest))
1811 : //**********************************************************************************************************************//
1812 : // alloccommon.h
1813 : #define INVALID_IDX -1 // Invalid buffer index.
1814 :
1815 : //**********************************************************************************************************************//
1816 : // quant_common.h
1817 : #define MINQ 0
1818 : #define MAXQ 255
1819 : #define QINDEX_RANGE (MAXQ - MINQ + 1)
1820 : #define QINDEX_BITS 8
1821 : // Total number of QM sets stored
1822 : #define QM_LEVEL_BITS 4
1823 : #define NUM_QM_LEVELS (1 << QM_LEVEL_BITS)
1824 : /* Range of QMS is between first and last value, with offset applied to inter
1825 : * blocks*/
1826 : #define DEFAULT_QM_Y 10
1827 : #define DEFAULT_QM_U 11
1828 : #define DEFAULT_QM_V 12
1829 : #define DEFAULT_QM_FIRST 5
1830 : #define DEFAULT_QM_LAST 9
1831 :
1832 : //**********************************************************************************************************************//
1833 : // blockd.h
1834 : #define NO_FILTER_FOR_IBC 1 // Disable in-loop filters for frame with intrabc
1835 : //**********************************************************************************************************************//
1836 : // av1_loopfilter.h
1837 : #define MAX_LOOP_FILTER 63
1838 : #define MAX_SHARPNESS 7
1839 : #define SIMD_WIDTH 16
1840 :
1841 : struct LoopFilter {
1842 : int32_t filter_level[2];
1843 : int32_t filter_level_u;
1844 : int32_t filter_level_v;
1845 :
1846 : int32_t sharpness_level;
1847 :
1848 : uint8_t mode_ref_delta_enabled;
1849 : uint8_t mode_ref_delta_update;
1850 :
1851 : // 0 = Intra, Last, Last2+Last3,
1852 : // GF, BRF, ARF2, ARF
1853 : int8_t ref_deltas[REF_FRAMES];
1854 :
1855 : // 0 = ZERO_MV, MV
1856 : int8_t mode_deltas[MAX_MODE_LF_DELTAS];
1857 : int32_t combine_vert_horz_lf;
1858 : };
1859 :
1860 : #define MAX_SEGMENTS 8
1861 : #define MAX_MB_PLANE 3
1862 :
1863 : #define MAX_LOOP_FILTER 63
1864 : #define MAX_SHARPNESS 7
1865 :
1866 : #define SIMD_WIDTH 16
1867 : // Need to align this structure so when it is declared and
1868 : // passed it can be loaded into vector registers.
1869 : typedef struct LoopFilterThresh
1870 : {
1871 : DECLARE_ALIGNED(SIMD_WIDTH, uint8_t, mblim[SIMD_WIDTH]);
1872 : DECLARE_ALIGNED(SIMD_WIDTH, uint8_t, lim[SIMD_WIDTH]);
1873 : DECLARE_ALIGNED(SIMD_WIDTH, uint8_t, hev_thr[SIMD_WIDTH]);
1874 : } LoopFilterThresh;
1875 :
1876 : typedef struct LoopFilterInfoN
1877 : {
1878 : LoopFilterThresh lfthr[MAX_LOOP_FILTER + 1];
1879 : uint8_t lvl[MAX_MB_PLANE][MAX_SEGMENTS][2][REF_FRAMES][MAX_MODE_LF_DELTAS];
1880 : } LoopFilterInfoN;
1881 :
1882 : //**********************************************************************************************************************//
1883 : // cdef.h
1884 : #define CDEF_STRENGTH_BITS 6
1885 :
1886 : #define CDEF_PRI_STRENGTHS 16
1887 : #define CDEF_SEC_STRENGTHS 4
1888 :
1889 : // Bits of precision used for the model
1890 : #define WARPEDMODEL_PREC_BITS 16
1891 : // The following constants describe the various precisions
1892 : // of different parameters in the global motion experiment.
1893 : //
1894 : // Given the general homography:
1895 : // [x' (a b c [x
1896 : // z . y' = d e f * y
1897 : // 1] g h i) 1]
1898 : //
1899 : // Constants using the name ALPHA here are related to parameters
1900 : // a, b, d, e. Constants using the name TRANS are related
1901 : // to parameters c and f.
1902 : //
1903 : // Anything ending in PREC_BITS is the number of bits of precision
1904 : // to maintain when converting from double to integer.
1905 : //
1906 : // The ABS parameters are used to create an upper and lower bound
1907 : // for each parameter. In other words, after a parameter is integerized
1908 : // it is clamped between -(1 << ABS_XXX_BITS) and (1 << ABS_XXX_BITS).
1909 : //
1910 : // XXX_PREC_DIFF and XXX_DECODE_FACTOR
1911 : // are computed once here to prevent repetitive
1912 : // computation on the decoder side. These are
1913 : // to allow the global motion parameters to be encoded in a lower
1914 : // precision than the warped model precision. This means that they
1915 : // need to be changed to warped precision when they are decoded.
1916 : //
1917 : // XX_MIN, XX_MAX are also computed to avoid repeated computation
1918 :
1919 : #define SUBEXPFIN_K 3
1920 : #define GM_TRANS_PREC_BITS 6
1921 : #define GM_ABS_TRANS_BITS 12
1922 : #define GM_ABS_TRANS_ONLY_BITS (GM_ABS_TRANS_BITS - GM_TRANS_PREC_BITS + 3)
1923 : #define GM_TRANS_PREC_DIFF (WARPEDMODEL_PREC_BITS - GM_TRANS_PREC_BITS)
1924 : #define GM_TRANS_ONLY_PREC_DIFF (WARPEDMODEL_PREC_BITS - 3)
1925 : #define GM_TRANS_DECODE_FACTOR (1 << GM_TRANS_PREC_DIFF)
1926 : #define GM_TRANS_ONLY_DECODE_FACTOR (1 << GM_TRANS_ONLY_PREC_DIFF)
1927 : #define GM_TRANS_ONLY_PREC_BITS 3
1928 :
1929 : #define GM_ALPHA_PREC_BITS 15
1930 : #define GM_ABS_ALPHA_BITS 12
1931 : #define GM_ALPHA_PREC_DIFF (WARPEDMODEL_PREC_BITS - GM_ALPHA_PREC_BITS)
1932 : #define GM_ALPHA_DECODE_FACTOR (1 << GM_ALPHA_PREC_DIFF)
1933 :
1934 : #define GM_ROW3HOMO_PREC_BITS 16
1935 : #define GM_ABS_ROW3HOMO_BITS 11
1936 : #define GM_ROW3HOMO_PREC_DIFF \
1937 : (WARPEDMODEL_ROW3HOMO_PREC_BITS - GM_ROW3HOMO_PREC_BITS)
1938 : #define GM_ROW3HOMO_DECODE_FACTOR (1 << GM_ROW3HOMO_PREC_DIFF)
1939 :
1940 : #define GM_TRANS_MAX (1 << GM_ABS_TRANS_BITS)
1941 : #define GM_ALPHA_MAX (1 << GM_ABS_ALPHA_BITS)
1942 : #define GM_ROW3HOMO_MAX (1 << GM_ABS_ROW3HOMO_BITS)
1943 :
1944 : #define GM_TRANS_MIN -GM_TRANS_MAX
1945 : #define GM_ALPHA_MIN -GM_ALPHA_MAX
1946 : #define GM_ROW3HOMO_MIN -GM_ROW3HOMO_MAX
1947 :
1948 : #define USE_CUR_GM_REFMV 1
1949 :
1950 : /* clang-format off */
1951 : typedef enum TransformationType
1952 : {
1953 : IDENTITY = 0, // identity transformation, 0-parameter
1954 : TRANSLATION = 1, // translational motion 2-parameter
1955 : ROTZOOM = 2, // simplified affine with rotation + zoom only, 4-parameter
1956 : AFFINE = 3, // affine, 6-parameter
1957 : TRANS_TYPES,
1958 : } TransformationType;
1959 : // The order of values in the wmmat matrix below is best described
1960 : // by the homography:
1961 : // [x' (m2 m3 m0 [x
1962 : // z . y' = m4 m5 m1 * y
1963 : // 1] m6 m7 1) 1]
1964 : typedef struct EbWarpedMotionParams
1965 : {
1966 : TransformationType wmtype;
1967 : int32_t wmmat[8];
1968 : int16_t alpha, beta, gamma, delta;
1969 : int8_t invalid;
1970 : } EbWarpedMotionParams;
1971 :
1972 : /*! Scale factors and scaling function pointers when reference and current frame dimensions are not equal */
1973 : typedef struct ScaleFactors {
1974 : int32_t x_scale_fp; // horizontal fixed point scale factor
1975 : int32_t y_scale_fp; // vertical fixed point scale factor
1976 : int32_t x_step_q4;
1977 : int32_t y_step_q4;
1978 :
1979 : int32_t(*scale_value_x)(int32_t val, const struct ScaleFactors *sf);
1980 : int32_t(*scale_value_y)(int32_t val, const struct ScaleFactors *sf);
1981 : } ScaleFactors;
1982 :
1983 : /* clang-format off */
1984 : static const EbWarpedMotionParams default_warp_params = {
1985 : IDENTITY,
1986 : { 0, 0, (1 << WARPEDMODEL_PREC_BITS), 0, 0, (1 << WARPEDMODEL_PREC_BITS), 0,
1987 : 0 },
1988 : 0, 0, 0, 0,
1989 : 0,
1990 : };
1991 :
1992 : /*********************************** AV1_OBU ********************************/
1993 :
1994 : //**********************************************************************************************************************//
1995 : //**********************************************************************************************************************//
1996 :
1997 : #define YBITS_THSHLD 50
1998 : #define YDC_THSHLD 5
1999 : #define M6_YBITS_THSHLD 80
2000 : #define M6_YDC_THSHLD 10
2001 :
2002 : #ifdef _WIN32
2003 : #define NOINLINE __declspec ( noinline )
2004 : #define FORCE_INLINE __forceinline
2005 : #else
2006 : #define NOINLINE __attribute__(( noinline ))
2007 : #define FORCE_INLINE __attribute__((always_inline))
2008 : #endif
2009 :
2010 : #define EB_STRINGIZE( L ) #L
2011 : #define EB_MAKESTRING( M, L ) M( L )
2012 : #define $Line EB_MAKESTRING( EB_STRINGIZE, __LINE__ )
2013 : #define EB_SRC_LINE __FILE__ "(" $Line ") : message "
2014 :
2015 : // ***************************** Definitions *****************************
2016 : #define PM_DC_TRSHLD1 10 // The threshold for DC to disable masking for DC
2017 :
2018 : #define MAX_BITS_PER_FRAME 8000000
2019 : #define VAR_BASED_STAT_AREA_THRSLHD (32*32)
2020 :
2021 : #define ANTI_TRAILING_VAR_THRSLD 1000
2022 : #define MAX_VAR_BIAS 100
2023 : #define MEAN_DIFF_THRSHOLD 10
2024 : #define VAR_DIFF_THRSHOLD 10
2025 :
2026 : #define HME_BIAS_X_THRSHLD1 64
2027 : #define HME_BIAS_Y_THRSHLD1 64
2028 : #define HME_BIAS_X_THRSHLD2 32
2029 : #define HME_BIAS_Y_THRSHLD2 32
2030 :
2031 : #define ASPECT_RATIO_4_3 13 // Limit Ration to detect VGA resolutiosn
2032 : #define ASPECT_RATIO_16_9 17 // Limit Ration to detect UHD,1080p,720p ... or similar resolutions
2033 :
2034 : #define ASPECT_RATIO_CLASS_0 0 // 4:3 aspect ratios
2035 : #define ASPECT_RATIO_CLASS_1 1 // 16:9 aspect ratios
2036 : #define ASPECT_RATIO_CLASS_2 2 // Other aspect ratios
2037 :
2038 : #define SC_FRAMES_TO_IGNORE 1000 // The speed control algorith starts after SC_FRAMES_TO_IGNORE number frames.
2039 : #define SC_FRAMES_INTERVAL_SPEED 60 // The speed control Interval To Check the speed
2040 : #define SC_FRAMES_INTERVAL_T1 60 // The speed control Interval Threshold1
2041 : #define SC_FRAMES_INTERVAL_T2 180 // The speed control Interval Threshold2
2042 : #define SC_FRAMES_INTERVAL_T3 120 // The speed control Interval Threshold3
2043 :
2044 : #define SC_SPEED_T2 1250 // speed level thershold. If speed is higher than target speed x SC_SPEED_T2, a slower mode is selected (+25% x 1000 (for precision))
2045 : #define SC_SPEED_T1 750 // speed level thershold. If speed is less than target speed x SC_SPEED_T1, a fast mode is selected (-25% x 1000 (for precision))
2046 : #define EB_CMPLX_CLASS uint8_t
2047 : #define CMPLX_LOW 0
2048 : #define CMPLX_MEDIUM 1
2049 : #define CMPLX_HIGH 2
2050 : #define CMPLX_VHIGH 3
2051 : #define CMPLX_NOISE 4
2052 : #define EB_NORMAL_LATENCY 0
2053 : #define EB_LOW_LATENCY 1
2054 :
2055 : typedef enum EbBitFieldMasks
2056 : {
2057 : BITMASK_0 = 1,
2058 : BITMASK_1 = 2,
2059 : BITMASK_2 = 4,
2060 : BITMASK_3 = 8
2061 : } EbBitFieldMasks;
2062 :
2063 : // CLEAN_BASIS_FUNCTIONS
2064 : #define CLEAN_BASIS_FUNCTIONS_VAR_TRSHLD 10
2065 : #define CLEAN_BASIS_FUNCTIONS_NZCOEF_TRSHLD0 10
2066 : #define CLEAN_BASIS_FUNCTIONS_NZCOEF_TRSHLD1 15
2067 : #define CLEAN_BASIS_FUNCTIONS_NZCOEF_TRSHLD2 20
2068 : // Anti-contouring
2069 : #define C3_TRSHLF_N 45
2070 : #define C3_TRSHLF_D 10
2071 : #define C4_TRSHLF_N 35
2072 : #define C4_TRSHLF_D 10
2073 :
2074 : #define C1_TRSHLF_4K_N 45
2075 : #define C1_TRSHLF_4K_D 10
2076 : #define C2_TRSHLF_4K_N 35
2077 : #define C2_TRSHLF_4K_D 10
2078 :
2079 : #define AC_ENERGY_BASED_4K_ANTI_CONTOURING_QP_DELTA 3
2080 : #define AC_ENERGY_BASED_4K_ANTI_CONTOURING_MIN_QP 22
2081 :
2082 : #define C1_TRSHLF_N 1
2083 : #define C1_TRSHLF_D 1
2084 : #define C2_TRSHLF_N 16
2085 : #define C2_TRSHLF_D 10
2086 :
2087 : #define CHANGE_LAMBDA_FOR_AURA 0x01
2088 : #define RESTRICT_CUS_AND_MODIFY_COST 0x02
2089 :
2090 : #define ANTI_CONTOURING_TH_0 16 * 16
2091 : #define ANTI_CONTOURING_TH_1 32 * 32
2092 : #define ANTI_CONTOURING_TH_2 2 * 32 * 32
2093 :
2094 : #define ANTI_CONTOURING_DELTA_QP_0 -3
2095 : #define ANTI_CONTOURING_DELTA_QP_1 -9
2096 : #define ANTI_CONTOURING_DELTA_QP_2 -11
2097 :
2098 : #define AC_ENERGY_BASED_ANTI_CONTOURING_QP_DELTA 11
2099 : #define AC_ENERGY_BASED_ANTI_CONTOURING_MIN_QP 20
2100 : #define ANTI_CONTOURING_LUMA_T1 40
2101 : #define ANTI_CONTOURING_LUMA_T2 180
2102 :
2103 : #define VAR_BASED_DETAIL_PRESERVATION_SELECTOR_THRSLHD (64*64)
2104 :
2105 : #define LAST_BWD_FRAME 8
2106 : #define LAST_ALT_FRAME 16
2107 :
2108 : #define MAX_NUM_TOKENS 200
2109 :
2110 : #define LAD_DISABLE 0
2111 : #define INIT_RC_OPT_G1 1
2112 : #define INIT_RC_OPT_G2 1
2113 : #define HIST_OPT 2 // 1 is intrinsic, 2 is C
2114 : #define ENABLE_8x8 0
2115 :
2116 : #define Log2f Log2f_SSE2
2117 :
2118 : #define INPUT_SIZE_576p_TH 0x90000 // 0.58 Million
2119 : #define INPUT_SIZE_1080i_TH 0xB71B0 // 0.75 Million
2120 : #define INPUT_SIZE_1080p_TH 0x1AB3F0 // 1.75 Million
2121 : #define INPUT_SIZE_4K_TH 0x29F630 // 2.75 Million
2122 : #define INPUT_SIZE_8K_TH 0xA7D8C0 // 11 Million
2123 :
2124 : /** Redefine ASSERT() to avoid warnings
2125 : */
2126 : #if defined _DEBUG || _DEBUG_
2127 : #include <assert.h>
2128 : #define ASSERT assert
2129 : #elif defined _DEBUG
2130 : #define ASSERT assert
2131 : #else
2132 : #define ASSERT(exp) ((void)sizeof(exp))
2133 : #endif
2134 :
2135 : #define INTERPOLATION_NEED 4
2136 : #define BUFF_PITCH (INTERPOLATION_NEED*2+64)
2137 : #define ME_FILTER_TAP 4
2138 : #define SUB_SAD_SEARCH 0
2139 : #define FULL_SAD_SEARCH 1
2140 : #define SSD_SEARCH 2
2141 : /************************ INPUT CLASS **************************/
2142 :
2143 : #define EbInputResolution uint8_t
2144 : #define INPUT_SIZE_576p_RANGE_OR_LOWER 0
2145 : #define INPUT_SIZE_1080i_RANGE 1
2146 : #define INPUT_SIZE_1080p_RANGE 2
2147 : #define INPUT_SIZE_4K_RANGE 3
2148 : #define INPUT_SIZE_COUNT INPUT_SIZE_4K_RANGE + 1
2149 :
2150 : /** The EbPtr type is intended to be used to pass pointers to and from the eBrisk
2151 : API. This is a 32 bit pointer and is aligned on a 32 bit word boundary.
2152 : */
2153 : typedef void *EbPtr;
2154 :
2155 : /** The EbString type is intended to be used to pass "C" type strings to and
2156 : from the eBrisk API. The EbString type is a 32 bit pointer to a zero terminated
2157 : string. The pointer is word aligned and the string is byte aligned.
2158 : */
2159 : typedef char * EbString;
2160 :
2161 : /** The EbByte type is intended to be used to pass arrays of bytes such as
2162 : buffers to and from the eBrisk API. The EbByte type is a 32 bit pointer.
2163 : The pointer is word aligned and the buffer is byte aligned.
2164 : */
2165 : typedef uint8_t * EbByte;
2166 :
2167 : /** The EB_SAMPLE type is intended to be used to pass arrays of bytes such as
2168 : buffers to and from the eBrisk API. The EbByte type is a 32 bit pointer.
2169 : The pointer is word aligned and the buffer is byte aligned.
2170 : */
2171 :
2172 : /** The EbBitDepthEnum type is used to describe the bitdepth of video data.
2173 : */
2174 : typedef enum EbBitDepthEnum
2175 : {
2176 : EB_8BIT = 8,
2177 : EB_10BIT = 10,
2178 : EB_12BIT = 12,
2179 : EB_14BIT = 14,
2180 : EB_16BIT = 16,
2181 : EB_32BIT = 32
2182 : } EbBitDepthEnum;
2183 : #if HBD_CLEAN_UP
2184 : /** The MD_BIT_DEPTH_MODE type is used to describe the bitdepth of MD path.
2185 : */
2186 :
2187 : typedef enum MD_BIT_DEPTH_MODE
2188 : {
2189 : EB_8_BIT_MD = 0, // 8bit mode decision
2190 : EB_10_BIT_MD = 1, // 10bit mode decision
2191 : EB_DUAL_BIT_MD = 2 // Auto: 8bit & 10bit mode decision
2192 : } MD_BIT_DEPTH_MODE;
2193 : #endif
2194 : /** The EB_GOP type is used to describe the hierarchical coding structure of
2195 : Groups of Pictures (GOP) units.
2196 : */
2197 : #define EbPred uint8_t
2198 : #define EB_PRED_LOW_DELAY_P 0
2199 : #define EB_PRED_LOW_DELAY_B 1
2200 : #define EB_PRED_RANDOM_ACCESS 2
2201 : #define EB_PRED_TOTAL_COUNT 3
2202 : #define EB_PRED_INVALID 0xFF
2203 :
2204 : /** The EB_SLICE type is used to describe the slice prediction type.
2205 : */
2206 :
2207 : #define EB_SLICE uint8_t
2208 : #define B_SLICE 0
2209 : #define P_SLICE 1
2210 : #define I_SLICE 2
2211 : #define IDR_SLICE 3
2212 : #define INVALID_SLICE 0xFF
2213 :
2214 : /** The EbPictStruct type is used to describe the picture structure.
2215 : */
2216 : #define EbPictStruct uint8_t
2217 : #define PROGRESSIVE_PICT_STRUCT 0
2218 : #define TOP_FIELD_PICT_STRUCT 1
2219 : #define BOTTOM_FIELD_PICT_STRUCT 2
2220 :
2221 : /** The EbModeType type is used to describe the PU type.
2222 : */
2223 : typedef uint8_t EbModeType;
2224 : #define INTER_MODE 1
2225 : #define INTRA_MODE 2
2226 :
2227 : #define INVALID_MODE 0xFFu
2228 :
2229 : /** INTRA_4x4 offsets
2230 : */
2231 : static const uint8_t INTRA_4x4_OFFSET_X[4] = { 0, 4, 0, 4 };
2232 : static const uint8_t INTRA_4x4_OFFSET_Y[4] = { 0, 0, 4, 4 };
2233 :
2234 : /** The EbPartMode type is used to describe the CU partition size.
2235 : */
2236 : typedef uint8_t EbPartMode;
2237 : #define SIZE_2Nx2N 0
2238 : #define SIZE_2NxN 1
2239 : #define SIZE_Nx2N 2
2240 : #define SIZE_NxN 3
2241 : #define SIZE_2NxnU 4
2242 : #define SIZE_2NxnD 5
2243 : #define SIZE_nLx2N 6
2244 : #define SIZE_nRx2N 7
2245 : #define SIZE_PART_MODE 8
2246 :
2247 : /** The EbIntraRefreshType is used to describe the intra refresh type.
2248 : */
2249 : typedef enum EbIntraRefreshType
2250 : {
2251 : NO_REFRESH = 0,
2252 : CRA_REFRESH = 1,
2253 : IDR_REFRESH = 2
2254 : }EbIntraRefreshType;
2255 :
2256 : #define SIZE_2Nx2N_PARTITION_MASK (1 << SIZE_2Nx2N)
2257 : #define SIZE_2NxN_PARTITION_MASK (1 << SIZE_2NxN)
2258 : #define SIZE_Nx2N_PARTITION_MASK (1 << SIZE_Nx2N)
2259 : #define SIZE_NxN_PARTITION_MASK (1 << SIZE_NxN)
2260 : #define SIZE_2NxnU_PARTITION_MASK (1 << SIZE_2NxnU)
2261 : #define SIZE_2NxnD_PARTITION_MASK (1 << SIZE_2NxnD)
2262 : #define SIZE_nLx2N_PARTITION_MASK (1 << SIZE_nLx2N)
2263 : #define SIZE_nRx2N_PARTITION_MASK (1 << SIZE_nRx2N)
2264 :
2265 : /** The EbEncMode type is used to describe the encoder mode .
2266 : */
2267 :
2268 : #define EbEncMode uint8_t
2269 : #define ENC_M0 0
2270 : #define ENC_M1 1
2271 : #define ENC_M2 2
2272 : #define ENC_M3 3
2273 : #define ENC_M4 4
2274 : #define ENC_M5 5
2275 : #define ENC_M6 6
2276 : #define ENC_M7 7
2277 : #define ENC_M8 8
2278 : #define ENC_M9 9
2279 : #define ENC_M10 10
2280 : #define ENC_M11 11
2281 : #define ENC_M12 12
2282 :
2283 : #define MAX_SUPPORTED_MODES 13
2284 :
2285 : #define SPEED_CONTROL_INIT_MOD ENC_M4;
2286 : /** The EB_TUID type is used to identify a TU within a CU.
2287 : */
2288 : typedef enum EbTuSize
2289 : {
2290 : TU_2Nx2N = 0,
2291 : TU_NxN_0 = 1,
2292 : TU_NxN_1 = 2,
2293 : TU_NxN_2 = 3,
2294 : TU_NxN_3 = 4,
2295 : TU_N2xN2_0 = 5,
2296 : TU_N2xN2_1 = 6,
2297 : TU_N2xN2_2 = 7,
2298 : TU_N2xN2_3 = 8,
2299 : INVALID_TUSIZE = ~0
2300 : }EbTuSize;
2301 :
2302 : #define TU_2Nx2N_PARTITION_MASK (1 << TU_2Nx2N)
2303 : #define TU_NxN_0_PARTITION_MASK (1 << TU_NxN_0)
2304 : #define TU_NxN_1_PARTITION_MASK (1 << TU_NxN_1)
2305 : #define TU_NxN_2_PARTITION_MASK (1 << TU_NxN_2)
2306 : #define TU_NxN_3_PARTITION_MASK (1 << TU_NxN_3)
2307 : #define TU_N2xN2_0_PARTITION_MASK (1 << TU_N2xN2_0)
2308 : #define TU_N2xN2_1_PARTITION_MASK (1 << TU_N2xN2_1)
2309 : #define TU_N2xN2_2_PARTITION_MASK (1 << TU_N2xN2_2)
2310 : #define TU_N2xN2_3_PARTITION_MASK (1 << TU_N2xN2_3)
2311 :
2312 : #define EbReflist uint8_t
2313 : #define REF_LIST_0 0
2314 : #define REF_LIST_1 1
2315 : #define TOTAL_NUM_OF_REF_LISTS 2
2316 : #define INVALID_LIST 0xFF
2317 :
2318 : #define EbPredDirection uint8_t
2319 : #define UNI_PRED_LIST_0 0
2320 : #define UNI_PRED_LIST_1 1
2321 : #define BI_PRED 2
2322 : #define EB_PREDDIRECTION_TOTAL 3
2323 : #define INVALID_PRED_DIRECTION 0xFF
2324 :
2325 : #define UNI_PRED_LIST_0_MASK (1 << UNI_PRED_LIST_0)
2326 : #define UNI_PRED_LIST_1_MASK (1 << UNI_PRED_LIST_1)
2327 : #define BI_PRED_MASK (1 << BI_PRED)
2328 :
2329 : // The EB_QP_OFFSET_MODE type is used to describe the QP offset
2330 : #define EB_FRAME_CARACTERICTICS uint8_t
2331 : #define EB_FRAME_CARAC_0 0
2332 : #define EB_FRAME_CARAC_1 1
2333 : #define EB_FRAME_CARAC_2 2
2334 : #define EB_FRAME_CARAC_3 3
2335 : #define EB_FRAME_CARAC_4 4
2336 :
2337 : static const uint8_t QP_OFFSET_WEIGHT[3][4] = { // [Slice Type][QP Offset Weight Level]
2338 : { 9, 8, 7, 6 },
2339 : { 9, 8, 7, 6 },
2340 : { 10, 9, 8, 7 }
2341 : };
2342 : /** Assembly Types
2343 : */
2344 : typedef enum EbAsm
2345 : {
2346 : ASM_NON_AVX2,
2347 : ASM_AVX2,
2348 : ASM_TYPE_TOTAL,
2349 : ASM_TYPE_INVALID = ~0
2350 : } EbAsm;
2351 :
2352 : #if PAL_SUP
2353 : #define MAX_PAL_CAND 14
2354 : typedef struct {
2355 : // Value of base colors for Y, U, and V
2356 : uint16_t palette_colors[3 * PALETTE_MAX_SIZE];
2357 : // Number of base colors for Y (0) and UV (1)
2358 : uint8_t palette_size[2];
2359 :
2360 : } PaletteModeInfo;
2361 :
2362 : typedef struct {
2363 : PaletteModeInfo pmi;
2364 : uint8_t *color_idx_map;
2365 : } PaletteInfo;
2366 : #endif
2367 : /** The EB_NULL type is used to define the C style NULL pointer.
2368 : */
2369 : #define EB_NULL ((void*) 0)
2370 :
2371 : /** The EbHandle type is used to define OS object handles for threads,
2372 : semaphores, mutexs, etc.
2373 : */
2374 : typedef void * EbHandle;
2375 :
2376 : /**
2377 : object_ptr is a EbPtr to the object being constructed.
2378 : object_init_data_ptr is a EbPtr to a data structure used to initialize the object.
2379 : */
2380 : typedef EbErrorType(*EbCreator)(
2381 : EbPtr *object_dbl_ptr,
2382 : EbPtr object_init_data_ptr);
2383 :
2384 : #define INVALID_MV 0x80008000 //0xFFFFFFFF //ICOPY They changed this to 0x80008000
2385 : #define BLKSIZE 64
2386 :
2387 : /***************************************
2388 : * Generic linked list data structure for passing data into/out from the library
2389 : ***************************************/
2390 : // Reserved types for lib's internal use. Must be less than EB_EXT_TYPE_BASE
2391 : #define EB_TYPE_PIC_TIMING_SEI 0
2392 : #define EB_TYPE_BUFFERING_PERIOD_SEI 1
2393 : #define EB_TYPE_RECOVERY_POINT_SEI 2
2394 : #define EB_TYPE_UNREG_USER_DATA_SEI 3
2395 : #define EB_TYPE_REG_USER_DATA_SEI 4
2396 : #define EB_TYPE_PIC_STRUCT 5 // It is a requirement (for the application) that if pictureStruct is present for 1 picture it shall be present for every picture
2397 : #define EB_TYPE_INPUT_PICTURE_DEF 6
2398 :
2399 : #define EB_TYPE_HIERARCHICAL_LEVELS 100
2400 : #define EB_TYPE_PRED_STRUCTURE 101
2401 :
2402 : typedef int32_t EbLinkedListType;
2403 :
2404 : typedef struct EbLinkedListNode
2405 : {
2406 : void* app; // points to an application object this node is associated
2407 : // with. this is an opaque pointer to the encoder lib, but
2408 : // release_cb_fnc_ptr may need to access it.
2409 : EbLinkedListType type; // type of data pointed by "data" member variable
2410 : uint32_t size; // size of (data)
2411 : EbBool passthrough; // whether this is passthrough data from application
2412 : void(*release_cb_fnc_ptr)(struct EbLinkedListNode*); // callback to be executed by encoder when picture reaches end of pipeline, or
2413 : // when aborting. However, at end of pipeline encoder shall
2414 : // NOT invoke this callback if passthrough is TRUE (but
2415 : // still needs to do so when aborting)
2416 : void *data; // pointer to application's data
2417 : struct EbLinkedListNode *next; // pointer to next node (null when last)
2418 : } EbLinkedListNode;
2419 :
2420 : typedef enum DistCalcType
2421 : {
2422 : DIST_CALC_RESIDUAL = 0, // SSE(Coefficients - ReconCoefficients)
2423 : DIST_CALC_PREDICTION = 1, // SSE(Coefficients) *Note - useful in modes that don't send residual coeff bits
2424 : DIST_CALC_TOTAL = 2
2425 : } DistCalcType;
2426 :
2427 : typedef enum EbPtrType
2428 : {
2429 : EB_N_PTR = 0, // malloc'd pointer
2430 : EB_C_PTR = 1, // calloc'd pointer
2431 : EB_A_PTR = 2, // malloc'd pointer aligned
2432 : EB_MUTEX = 3, // mutex
2433 : EB_SEMAPHORE = 4, // semaphore
2434 : EB_THREAD = 5, // thread handle
2435 : EB_PTR_TYPE_TOTAL,
2436 : } EbPtrType;
2437 :
2438 : typedef struct EbMemoryMapEntry
2439 : {
2440 : EbPtr ptr; // points to a memory pointer
2441 : EbPtrType ptr_type; // pointer type
2442 : EbPtr prev_entry; // pointer to the prev entry
2443 : } EbMemoryMapEntry;
2444 :
2445 : // Rate Control
2446 : #define THRESHOLD1QPINCREASE 1
2447 : #define THRESHOLD2QPINCREASE 2
2448 : #define EB_IOS_POINT uint8_t
2449 : #define OIS_VERY_FAST_MODE 0
2450 : #define OIS_FAST_MODE 1
2451 : #define OIS_MEDUIM_MODE 2
2452 : #define OIS_COMPLEX_MODE 3
2453 : #define OIS_VERY_COMPLEX_MODE 4
2454 : // Display Total Memory at the end of the memory allocations
2455 : #define DISPLAY_MEMORY 0
2456 :
2457 : extern EbMemoryMapEntry *app_memory_map; // App Memory table
2458 : extern uint32_t *app_memory_map_index; // App Memory index
2459 : extern uint64_t *total_app_memory; // App Memory malloc'd
2460 :
2461 : extern EbMemoryMapEntry *memory_map; // library Memory table
2462 : extern uint32_t *memory_map_index; // library memory index
2463 : extern uint64_t *total_lib_memory; // library Memory malloc'd
2464 :
2465 : extern uint32_t lib_malloc_count;
2466 : extern uint32_t lib_thread_count;
2467 : extern uint32_t lib_semaphore_count;
2468 : extern uint32_t lib_mutex_count;
2469 :
2470 : extern uint32_t app_malloc_count;
2471 :
2472 : #define ALVALUE 64
2473 :
2474 : #define EB_ADD_APP_MEM(pointer, size, pointer_class, count, release, return_type) \
2475 : do { \
2476 : if (!pointer) return return_type; \
2477 : if (*(app_memory_map_index) >= MAX_APP_NUM_PTR) { \
2478 : printf("Malloc has failed due to insuffucient resources"); \
2479 : release(pointer); \
2480 : return return_type; \
2481 : } \
2482 : app_memory_map[*(app_memory_map_index)].ptr_type = pointer_class; \
2483 : app_memory_map[(*(app_memory_map_index))++].ptr = pointer; \
2484 : *total_app_memory += (size + 7) / 8; \
2485 : count++; \
2486 : } while (0)
2487 :
2488 : #define EB_APP_MALLOC(type, pointer, n_elements, pointer_class, return_type) \
2489 : pointer = (type)malloc(n_elements); \
2490 : EB_ADD_APP_MEM(pointer, n_elements, pointer_class, app_malloc_count, return_type);
2491 :
2492 :
2493 : #define EB_APP_MALLOC_NR(type, pointer, n_elements, pointer_class,return_type) \
2494 : pointer = (type)malloc(n_elements); \
2495 : EB_ADD_APP_MEM(pointer, n_elements, pointer_class, app_malloc_count, return_type);
2496 :
2497 : #define ALVALUE 64
2498 :
2499 : #define EB_CREATE_SEMAPHORE(pointer, initial_count, max_count) \
2500 : do { \
2501 : pointer = eb_create_semaphore(initial_count, max_count); \
2502 : EB_ADD_MEM(pointer, 1, EB_SEMAPHORE); \
2503 : }while (0)
2504 :
2505 : #define EB_DESTROY_SEMAPHORE(pointer) \
2506 : do { \
2507 : if (pointer) { \
2508 : eb_destroy_semaphore(pointer); \
2509 : EB_REMOVE_MEM_ENTRY(pointer, EB_SEMAPHORE); \
2510 : pointer = NULL; \
2511 : } \
2512 : }while (0)
2513 :
2514 : #define EB_CREATE_MUTEX(pointer) \
2515 : do { \
2516 : pointer = eb_create_mutex(); \
2517 : EB_ADD_MEM(pointer, 1, EB_MUTEX); \
2518 : } while (0)
2519 :
2520 : #define EB_DESTROY_MUTEX(pointer) \
2521 : do { \
2522 : if (pointer) { \
2523 : eb_destroy_mutex(pointer); \
2524 : EB_REMOVE_MEM_ENTRY(pointer, EB_MUTEX); \
2525 : pointer = NULL; \
2526 : } \
2527 : } while (0)
2528 :
2529 :
2530 : #define EB_MEMORY() \
2531 : printf("Total Number of Mallocs in Library: %d\n", lib_malloc_count); \
2532 : printf("Total Number of Threads in Library: %d\n", lib_thread_count); \
2533 : printf("Total Number of Semaphore in Library: %d\n", lib_semaphore_count); \
2534 : printf("Total Number of Mutex in Library: %d\n", lib_mutex_count); \
2535 : printf("Total Library Memory: %.2lf KB\n\n",*total_lib_memory/(double)1024);
2536 :
2537 : #define EB_APP_MEMORY() \
2538 : printf("Total Number of Mallocs in App: %d\n", app_malloc_count); \
2539 : printf("Total App Memory: %.2lf KB\n\n",*total_app_memory/(double)1024);
2540 :
2541 : #define RSIZE_MAX_MEM ( 256UL << 20 ) /* 256MB */
2542 :
2543 : #define EXPORT_SYMBOL(sym)
2544 :
2545 : #ifndef _ERRNO_T_DEFINED
2546 : #define _ERRNO_T_DEFINED
2547 : typedef int32_t errno_t;
2548 : #endif /* _ERRNO_T_DEFINED */
2549 :
2550 : extern void
2551 : eb_memcpy(void *dst_ptr, void *src_ptr, size_t size);
2552 :
2553 : #define EB_MEMCPY(dst, src, size) \
2554 : eb_memcpy(dst, src, size)
2555 :
2556 : #define EB_MEMSET(dst, val, count) \
2557 : memset(dst, val, count)
2558 :
2559 : //#ifdef __cplusplus
2560 : //}
2561 : //#endif // __cplusplus
2562 :
2563 : /**************************************
2564 : * Callback Functions
2565 : **************************************/
2566 : typedef struct EbCallback
2567 : {
2568 : EbPtr appPrivateData;
2569 : EbPtr handle;
2570 : void(*ErrorHandler)(
2571 : EbPtr handle,
2572 : uint32_t errorCode);
2573 : } EbCallback;
2574 :
2575 : // DEBUG MACROS
2576 : #define LIB_PRINTF_ENABLE 1
2577 :
2578 : #if LIB_PRINTF_ENABLE
2579 : #define SVT_LOG printf
2580 : #else
2581 : #ifdef _MSC_VER
2582 : #define SVT_LOG(s, ...) printf("")
2583 : #else
2584 : #define SVT_LOG(s, ...) printf("",##__VA_ARGS__)
2585 : #endif
2586 : #endif
2587 :
2588 : // Common Macros
2589 : #define UNUSED(x) (void)(x)
2590 :
2591 : //***Profile, tier, level***
2592 : #define TOTAL_LEVEL_COUNT 13
2593 :
2594 : //***Encoding Parameters***
2595 : #define MAX_PICTURE_WIDTH_SIZE 4672u
2596 : #define MAX_PICTURE_HEIGHT_SIZE 2560u
2597 : #define MAX_PICTURE_WIDTH_SIZE_CH 2336u
2598 : #define MAX_PICTURE_HEIGHT_SIZE_CH 1280u
2599 : #define INTERNAL_BIT_DEPTH 8 // to be modified
2600 : #define MAX_SAMPLE_VALUE ((1 << INTERNAL_BIT_DEPTH) - 1)
2601 : #define MAX_SAMPLE_VALUE_10BIT 0x3FF
2602 : #define BLOCK_SIZE_64 64u
2603 : #define LOG2F_MAX_LCU_SIZE 6u
2604 : #define LOG2_64_SIZE 6 // log2(BLOCK_SIZE_64)
2605 : #define MAX_LEVEL_COUNT 5 // log2(BLOCK_SIZE_64) - log2(MIN_BLOCK_SIZE)
2606 : #if !ENHANCE_ATB
2607 : #define MAX_TU_DEPTH 2
2608 : #endif
2609 : #define LOG_MIN_BLOCK_SIZE 3
2610 : #define MIN_BLOCK_SIZE (1 << LOG_MIN_BLOCK_SIZE)
2611 : #define LOG_MIN_PU_SIZE 2
2612 : #define MIN_PU_SIZE (1 << LOG_MIN_PU_SIZE)
2613 : #define MAX_NUM_OF_PU_PER_CU 1
2614 : #define MAX_NUM_OF_REF_PIC_LIST 2
2615 : #define MAX_NUM_OF_PART_SIZE 8
2616 : #define EB_MAX_LCU_DEPTH (((BLOCK_SIZE_64 / MIN_BLOCK_SIZE) == 1) ? 1 : \
2617 : ((BLOCK_SIZE_64 / MIN_BLOCK_SIZE) == 2) ? 2 : \
2618 : ((BLOCK_SIZE_64 / MIN_BLOCK_SIZE) == 4) ? 3 : \
2619 : ((BLOCK_SIZE_64 / MIN_BLOCK_SIZE) == 8) ? 4 : \
2620 : ((BLOCK_SIZE_64 / MIN_BLOCK_SIZE) == 16) ? 5 : \
2621 : ((BLOCK_SIZE_64 / MIN_BLOCK_SIZE) == 32) ? 6 : 7)
2622 : #define MIN_CU_BLK_COUNT ((BLOCK_SIZE_64 / MIN_BLOCK_SIZE) * (BLOCK_SIZE_64 / MIN_BLOCK_SIZE))
2623 : #define MAX_NUM_OF_TU_PER_CU 21
2624 : #define MIN_NUM_OF_TU_PER_CU 5
2625 : #define MAX_LCU_ROWS ((MAX_PICTURE_HEIGHT_SIZE) / (BLOCK_SIZE_64))
2626 :
2627 : #define MAX_NUMBER_OF_TREEBLOCKS_PER_PICTURE ((MAX_PICTURE_WIDTH_SIZE + BLOCK_SIZE_64 - 1) / BLOCK_SIZE_64) * \
2628 : ((MAX_PICTURE_HEIGHT_SIZE + BLOCK_SIZE_64 - 1) / BLOCK_SIZE_64)
2629 :
2630 : //***Prediction Structure***
2631 : #define REF_LIST_MAX_DEPTH 4 // NM - To be specified
2632 : #define MAX_TEMPORAL_LAYERS 6
2633 : #define MAX_HIERARCHICAL_LEVEL 6
2634 : #define MAX_REF_IDX 4
2635 : #define INVALID_POC (((uint32_t) (~0)) - (((uint32_t) (~0)) >> 1))
2636 : #define MAX_ELAPSED_IDR_COUNT 1024
2637 :
2638 : typedef enum DownSamplingMethod
2639 : {
2640 : ME_FILTERED_DOWNSAMPLED = 0,
2641 : ME_DECIMATED_DOWNSAMPLED = 1
2642 : } DownSamplingMethod;
2643 :
2644 : //***Segments***
2645 : #define EB_SEGMENT_MIN_COUNT 1
2646 : #define EB_SEGMENT_MAX_COUNT 64
2647 : #define CU_MAX_COUNT 85
2648 :
2649 : #define EB_EVENT_MAX_COUNT 20
2650 :
2651 : #define MAX_INTRA_REFERENCE_SAMPLES (BLOCK_SIZE_64 << 2) + 1
2652 :
2653 : #define MAX_INTRA_MODES 35
2654 :
2655 : #define _MVXT(mv) ( (int16_t)((mv) & 0xFFFF) )
2656 : #define _MVYT(mv) ( (int16_t)((mv) >> 16 ) )
2657 :
2658 : //***MCP***
2659 : #define MaxChromaFilterTag 4
2660 : #define MaxVerticalLumaFliterTag 8
2661 : #define MaxHorizontalLumaFliterTag 8
2662 :
2663 : #define MCPXPaddingOffset 16 // to be modified
2664 : #define MCPYPaddingOffset 16 // to be modified
2665 :
2666 : #define InternalBitDepth 8 // to be modified
2667 : #define MAX_Sample_Value ((1 << InternalBitDepth) - 1)
2668 : #define IF_Shift 6 // to be modified
2669 : #define IF_Prec 14 // to be modified
2670 : #define IF_Negative_Offset (IF_Prec - 1) // to be modified
2671 : #define InternalBitDepthIncrement (InternalBitDepth - 8)
2672 :
2673 : #define MIN_QP_VALUE 0
2674 : #define MAX_QP_VALUE 63
2675 : #define MAX_CHROMA_MAP_QP_VALUE 63
2676 :
2677 : //***Transforms***
2678 : #define TRANSFORMS_LUMA_FLAG 0
2679 : #define TRANSFORMS_CHROMA_FLAG 1
2680 : #define TRANSFORMS_COLOR_LEN 2
2681 : #define TRANSFORMS_LUMA_MASK (1 << TRANSFORMS_LUMA_FLAG)
2682 : #define TRANSFORMS_CHROMA_MASK (1 << TRANSFORMS_CHROMA_FLAG)
2683 : #define TRANSFORMS_FULL_MASK ((1 << TRANSFORMS_LUMA_FLAG) | (1 << TRANSFORMS_CHROMA_FLAG))
2684 :
2685 : #define TRANSFORMS_SIZE_32_FLAG 0
2686 : #define TRANSFORMS_SIZE_16_FLAG 1
2687 : #define TRANSFORMS_SIZE_8_FLAG 2
2688 : #define TRANSFORMS_SIZE_4_FLAG 3
2689 : #define TRANSFORMS_SIZE_LEN 4
2690 : #define TRANSFORM_MAX_SIZE 64
2691 : #define TRANSFORM_MIN_SIZE 4
2692 :
2693 : #define BIT_INCREMENT_10BIT 2
2694 : #define BIT_INCREMENT_8BIT 0
2695 :
2696 : #define TRANS_BIT_INCREMENT 0
2697 : #define QUANT_IQUANT_SHIFT 20 // Q(QP%6) * IQ(QP%6) = 2^20
2698 : #define QUANT_SHIFT 14 // Q(4) = 2^14
2699 : #define SCALE_BITS 15 // Inherited from TMuC, pressumably for fractional bit estimates in RDOQ
2700 : #define MAX_TR_DYNAMIC_RANGE 15 // Maximum transform dynamic range (excluding sign bit)
2701 : #define MAX_POS_16BIT_NUM 32767
2702 : #define MIN_NEG_16BIT_NUM -32768
2703 : #define QUANT_OFFSET_I 171
2704 : #define QUANT_OFFSET_P 85
2705 : #define LOW_LCU_VARIANCE 10
2706 : #define MEDIUM_LCU_VARIANCE 50
2707 :
2708 : /*********************************************************
2709 : * used for the first time, but not the last time interpolation filter
2710 : *********************************************************/
2711 : #define Shift1 InternalBitDepthIncrement
2712 : #define MinusOffset1 (1 << (IF_Negative_Offset + InternalBitDepthIncrement))
2713 : #if (InternalBitDepthIncrement == 0)
2714 : #define ChromaMinusOffset1 0
2715 : #else
2716 : #define ChromaMinusOffset1 MinusOffset1
2717 : #endif
2718 :
2719 : /*********************************************************
2720 : * used for neither the first time nor the last time interpolation filter
2721 : *********************************************************/
2722 : #define Shift2 IF_Shift
2723 :
2724 : /*********************************************************
2725 : * used for the first time, and also the last time interpolation filter
2726 : *********************************************************/
2727 : #define Shift3 IF_Shift
2728 : #define Offset3 (1<<(Shift3-1))
2729 :
2730 : /*********************************************************
2731 : * used for not the first time, but the last time interpolation filter
2732 : *********************************************************/
2733 : #define Shift4 (IF_Shift + IF_Shift - InternalBitDepthIncrement)
2734 : #define Offset4 ((1 << (IF_Shift + IF_Negative_Offset)) + (1 << (Shift4 - 1)))
2735 : #if (InternalBitDepthIncrement == 0)
2736 : #define ChromaOffset4 (1 << (Shift4 - 1))
2737 : #else
2738 : #define ChromaOffset4 Offset4
2739 : #endif
2740 :
2741 : /*********************************************************
2742 : * used for weighted sample prediction
2743 : *********************************************************/
2744 : #define Shift5 (IF_Shift - InternalBitDepthIncrement + 1)
2745 : #define Offset5 ((1 << (Shift5 - 1)) + (1 << (IF_Negative_Offset + 1)))
2746 : #if (InternalBitDepthIncrement == 0)
2747 : #define ChromaOffset5 (1 << (Shift5 - 1))
2748 : #else
2749 : #define ChromaOffset5 Offset5
2750 : #endif
2751 :
2752 : /*********************************************************
2753 : * used for biPredCopy()
2754 : *********************************************************/
2755 : #define Shift6 (IF_Shift - InternalBitDepthIncrement)
2756 : #define MinusOffset6 (1 << IF_Negative_Offset)
2757 : #if (InternalBitDepthIncrement == 0)
2758 : #define ChromaMinusOffset6 0
2759 : #else
2760 : #define ChromaMinusOffset6 MinusOffset6
2761 : #endif
2762 :
2763 : /*********************************************************
2764 : * 10bit case
2765 : *********************************************************/
2766 :
2767 : #define SHIFT1D_10BIT 6
2768 : #define OFFSET1D_10BIT 32
2769 :
2770 : #define SHIFT2D1_10BIT 2
2771 : #define OFFSET2D1_10BIT (-32768)
2772 :
2773 : #define SHIFT2D2_10BIT 10
2774 : #define OFFSET2D2_10BIT 524800
2775 :
2776 : //BIPRED
2777 : #define BI_SHIFT_10BIT 4
2778 : #define BI_OFFSET_10BIT 8192//2^(14-1)
2779 :
2780 : #define BI_AVG_SHIFT_10BIT 5
2781 : #define BI_AVG_OFFSET_10BIT 16400
2782 :
2783 : #define BI_SHIFT2D2_10BIT 6
2784 : #define BI_OFFSET2D2_10BIT 0
2785 :
2786 : // Noise detection
2787 : #define NOISE_VARIANCE_TH 390
2788 :
2789 : #define EbPicnoiseClass uint8_t
2790 : #define PIC_NOISE_CLASS_INV 0 //not computed
2791 : #define PIC_NOISE_CLASS_1 1 //No Noise
2792 : #define PIC_NOISE_CLASS_2 2
2793 : #define PIC_NOISE_CLASS_3 3
2794 : #define PIC_NOISE_CLASS_3_1 4
2795 : #define PIC_NOISE_CLASS_4 5
2796 : #define PIC_NOISE_CLASS_5 6
2797 : #define PIC_NOISE_CLASS_6 7
2798 : #define PIC_NOISE_CLASS_7 8
2799 : #define PIC_NOISE_CLASS_8 9
2800 : #define PIC_NOISE_CLASS_9 10
2801 : #define PIC_NOISE_CLASS_10 11 //Extreme Noise
2802 :
2803 : // Intrinisc
2804 : #define INTRINSIC_SSE2 1
2805 :
2806 : // Enhance background macros for decimated 64x64
2807 : #define BEA_CLASS_0_0_DEC_TH 16 * 16 // 16x16 block size * 1
2808 : #define BEA_CLASS_0_DEC_TH 16 * 16 * 2 // 16x16 block size * 2
2809 : #define BEA_CLASS_1_DEC_TH 16 * 16 * 4 // 16x16 block size * 4
2810 : #define BEA_CLASS_2_DEC_TH 16 * 16 * 8 // 16x16 block size * 8
2811 :
2812 : // Enhance background macros
2813 : #define BEA_CLASS_0_0_TH 8 * 8 // 8x8 block size * 1
2814 :
2815 : #define BEA_CLASS_0_TH 8 * 8 * 2 // 8x8 block size * 2
2816 : #define BEA_CLASS_1_TH 8 * 8 * 4 // 8x8 block size * 4
2817 : #define BEA_CLASS_2_TH 8 * 8 * 8 // 8x8 block size * 8
2818 :
2819 : #define UNCOVERED_AREA_ZZ_TH 4 * 4 * 14
2820 :
2821 : #define BEA_CLASS_0_ZZ_COST 0
2822 : #define BEA_CLASS_0_1_ZZ_COST 3
2823 :
2824 : #define BEA_CLASS_1_ZZ_COST 10
2825 : #define BEA_CLASS_2_ZZ_COST 20
2826 : #define BEA_CLASS_3_ZZ_COST 30
2827 : #define INVALID_ZZ_COST (uint8_t) ~0
2828 :
2829 : #define PM_NON_MOVING_INDEX_TH 23
2830 :
2831 : #define QP_OFFSET_LCU_SCORE_0 0
2832 : #define QP_OFFSET_LCU_SCORE_1 50
2833 : #define QP_OFFSET_LCU_SCORE_2 100
2834 : #define UNCOVERED_AREA_ZZ_COST_TH 8
2835 : #define BEA_MIN_DELTA_QP_T00 1
2836 : #define BEA_MIN_DELTA_QP_T0 3
2837 : #define BEA_MIN_DELTA_QP_T1 5
2838 : #define BEA_MIN_DELTA_QP_T2 5
2839 : #define BEA_DISTANSE_RATIO_T0 900
2840 : #define BEA_DISTANSE_RATIO_T1 600
2841 : #define ACTIVE_PICTURE_ZZ_COST_TH 29
2842 :
2843 : #define BEA_MAX_DELTA_QP 1
2844 :
2845 : #define FAILING_MOTION_DELTA_QP -5
2846 : #define FAILING_MOTION_VAR_THRSLHD 50
2847 : static const uint8_t intra_area_th_class_1[MAX_HIERARCHICAL_LEVEL][MAX_TEMPORAL_LAYERS] = { // [Highest Temporal Layer] [Temporal Layer Index]
2848 : { 20 },
2849 : { 30, 20 },
2850 : { 40, 30, 20 },
2851 : { 50, 40, 30, 20 },
2852 : { 50, 40, 30, 20, 10 },
2853 : { 50, 40, 30, 20, 10, 10 }
2854 : };
2855 :
2856 : #define NON_MOVING_SCORE_0 0
2857 : #define NON_MOVING_SCORE_1 10
2858 : #define NON_MOVING_SCORE_2 20
2859 : #define NON_MOVING_SCORE_3 30
2860 : #define INVALID_NON_MOVING_SCORE (uint8_t) ~0
2861 :
2862 : // Picture split into regions for analysis (SCD, Dynamic GOP)
2863 : #define CLASS_SUB_0_REGION_SPLIT_PER_WIDTH 1
2864 : #define CLASS_SUB_0_REGION_SPLIT_PER_HEIGHT 1
2865 :
2866 : #define CLASS_1_REGION_SPLIT_PER_WIDTH 2
2867 : #define CLASS_1_REGION_SPLIT_PER_HEIGHT 2
2868 :
2869 : #define HIGHER_THAN_CLASS_1_REGION_SPLIT_PER_WIDTH 4
2870 : #define HIGHER_THAN_CLASS_1_REGION_SPLIT_PER_HEIGHT 4
2871 :
2872 : // Dynamic GOP activity TH - to tune
2873 :
2874 : #define DYNAMIC_GOP_SUB_1080P_L6_VS_L5_COST_TH 11
2875 : #define DYNAMIC_GOP_SUB_1080P_L5_VS_L4_COST_TH 19
2876 : #define DYNAMIC_GOP_SUB_1080P_L4_VS_L3_COST_TH 30 // No L4_VS_L3 - 25 is the TH after 1st round of tuning
2877 :
2878 : #define DYNAMIC_GOP_ABOVE_1080P_L6_VS_L5_COST_TH 15//25//5//
2879 : #define DYNAMIC_GOP_ABOVE_1080P_L5_VS_L4_COST_TH 25//28//9//
2880 : #define DYNAMIC_GOP_ABOVE_1080P_L4_VS_L3_COST_TH 30 // No L4_VS_L3 - 28 is the TH after 1st round of tuning
2881 : #define DYNAMIC_GOP_SUB_480P_L6_VS_L5_COST_TH 9
2882 :
2883 : #define SB_COMPLEXITY_NON_MOVING_INDEX_TH_0 30
2884 : #define SB_COMPLEXITY_NON_MOVING_INDEX_TH_1 29
2885 : #define SB_COMPLEXITY_NON_MOVING_INDEX_TH_2 23
2886 :
2887 : #define GRADUAL_LUMINOSITY_CHANGE_TH 3
2888 : #define FADED_LCU_PERCENTAGE_TH 10
2889 : #define FADED_PICTURES_TH 15
2890 : #define CLASS_SUB_0_PICTURE_ACTIVITY_REGIONS_TH 1
2891 : #define CLASS_1_SIZE_PICTURE_ACTIVITY_REGIONS_TH 2
2892 : #define HIGHER_THAN_CLASS_1_PICTURE_ACTIVITY_REGIONS_TH 8
2893 :
2894 : #define IS_COMPLEX_LCU_VARIANCE_TH 100
2895 : #define IS_COMPLEX_LCU_FLAT_VARIANCE_TH 10
2896 : #define IS_COMPLEX_LCU_VARIANCE_DEVIATION_TH 13
2897 : #define IS_COMPLEX_LCU_ZZ_SAD_FACTOR_TH 25
2898 :
2899 : #define MAX_SUPPORTED_SEGMENTS 7
2900 : #define NUM_QPS 52
2901 :
2902 : // The EbAuraStatus type is used to describe the aura status
2903 : #define EbAuraStatus uint8_t
2904 : #define AURA_STATUS_0 0
2905 : #define AURA_STATUS_1 1
2906 : #define AURA_STATUS_2 2
2907 : #define AURA_STATUS_3 3
2908 : #define INVALID_AURA_STATUS 128
2909 :
2910 : // Aura detection definitions
2911 : #define AURA_4K_DISTORTION_TH 25
2912 : #define AURA_4K_DISTORTION_TH_6L 20
2913 :
2914 : // The EB_4L_PRED_ERROR_CLASS type is used to inform about the prediction error compared to 4L
2915 : #define EB_4L_PRED_ERROR_CLASS uint8_t
2916 : #define PRED_ERROR_CLASS_0 0
2917 : #define PRED_ERROR_CLASS_1 1
2918 : #define INVALID_PRED_ERROR_CLASS 128
2919 :
2920 : #define EbScdMode uint8_t
2921 : #define SCD_MODE_0 0 // SCD OFF
2922 : #define SCD_MODE_1 1 // Light SCD (histograms generation on the 1/16 decimated input)
2923 : #define SCD_MODE_2 2 // Full SCD
2924 :
2925 : #define EbBlockMeanPrec uint8_t
2926 : #define BLOCK_MEAN_PREC_FULL 0
2927 : #define BLOCK_MEAN_PREC_SUB 1
2928 :
2929 : #define EbPmMode uint8_t
2930 : #define PM_MODE_0 0 // 1-stage PM
2931 : #define PM_MODE_1 1 // 2-stage PM 4K
2932 : #define PM_MODE_2 2 // 2-stage PM Sub 4K
2933 :
2934 : #define EB_ZZ_SAD_MODE uint8_t
2935 : #define ZZ_SAD_MODE_0 0 // ZZ SAD on Decimated resolution
2936 : #define ZZ_SAD_MODE_1 1 // ZZ SAD on Full resolution
2937 :
2938 : #define EbPfMode uint8_t
2939 : #define PF_OFF 0
2940 : #define PF_N2 1
2941 : #define PF_N4 2
2942 : #define STAGE uint8_t
2943 : #define ED_STAGE 1 // ENCDEC stage
2944 :
2945 : #define EB_TRANS_COEFF_SHAPE uint8_t
2946 : #define DEFAULT_SHAPE 0
2947 : #define N2_SHAPE 1
2948 : #define N4_SHAPE 2
2949 : #define ONLY_DC_SHAPE 3
2950 :
2951 : #define EB_CHROMA_LEVEL uint8_t
2952 : #define CHROMA_MODE_0 0 // Full chroma search @ MD
2953 : #define CHROMA_MODE_1 1 // Fast chroma search @ MD
2954 : #define CHROMA_MODE_2 2 // Chroma blind @ MD + CFL @ EP
2955 : #define CHROMA_MODE_3 3 // Chroma blind @ MD + no CFL @ EP
2956 :
2957 : typedef enum EbSbComplexityStatus
2958 : {
2959 : SB_COMPLEXITY_STATUS_0 = 0,
2960 : SB_COMPLEXITY_STATUS_1 = 1,
2961 : SB_COMPLEXITY_STATUS_2 = 2,
2962 : SB_COMPLEXITY_STATUS_INVALID = (uint8_t)~0
2963 : } EbSbComplexityStatus;
2964 :
2965 : typedef enum EbCleanUpMode
2966 : {
2967 : CLEAN_UP_MODE_0 = 0,
2968 : CLEAN_UP_MODE_1 = 1
2969 : } EbCleanUpMode;
2970 :
2971 : typedef enum EbSaoMode
2972 : {
2973 : SAO_MODE_0 = 0,
2974 : SAO_MODE_1 = 1
2975 : } EbSaoMode;
2976 :
2977 : typedef enum EbCu8x8Mode
2978 : {
2979 : CU_8x8_MODE_0 = 0, // Perform OIS, Full_Search, Fractional_Search & Bipred for CU_8x8
2980 : CU_8x8_MODE_1 = 1 // Perform OIS and only Full_Search for CU_8x8
2981 : } EbCu8x8Mode;
2982 :
2983 : typedef enum EbPictureDepthMode
2984 : {
2985 : PIC_ALL_DEPTH_MODE = 0, // ALL sq and nsq: SB size -> 4x4
2986 : PIC_ALL_C_DEPTH_MODE = 1, // ALL sq and nsq with control : SB size -> 4x4
2987 : PIC_SQ_DEPTH_MODE = 2, // ALL sq: SB size -> 4x4
2988 : PIC_SQ_NON4_DEPTH_MODE = 3, // SQ: SB size -> 8x8
2989 : PIC_OPEN_LOOP_DEPTH_MODE = 4, // Early Inter Depth Decision: SB size -> 8x8
2990 : PIC_SB_SWITCH_DEPTH_MODE = 5 // Adaptive Depth Partitioning
2991 : } EbPictureDepthMode;
2992 :
2993 : #define EB_SB_DEPTH_MODE uint8_t
2994 : #define SB_SQ_BLOCKS_DEPTH_MODE 1
2995 : #define SB_SQ_NON4_BLOCKS_DEPTH_MODE 2
2996 : #define SB_OPEN_LOOP_DEPTH_MODE 3
2997 : #define SB_FAST_OPEN_LOOP_DEPTH_MODE 4
2998 : #define SB_PRED_OPEN_LOOP_DEPTH_MODE 5
2999 :
3000 : typedef enum EbIntrA4x4SearchMethod
3001 : {
3002 : INTRA4x4_OFF = 0,
3003 : INTRA4x4_INLINE_SEARCH = 1,
3004 : INTRA4x4_REFINEMENT_SEARCH = 2,
3005 : } EbIntrA4x4SearchMethod;
3006 :
3007 : static const int32_t global_motion_threshold[MAX_HIERARCHICAL_LEVEL][MAX_TEMPORAL_LAYERS] = { // [Highest Temporal Layer] [Temporal Layer Index]
3008 : { 2 },
3009 : { 4, 2 },
3010 : { 8, 4, 2 },
3011 : { 16, 8, 4, 2 },
3012 : { 32, 16, 8, 4, 2 }, // Derived by analogy from 4-layer settings
3013 : { 64, 32, 16, 8, 4, 2 }
3014 : };
3015 :
3016 : static const int32_t hme_level_0_search_area_multiplier_x[MAX_HIERARCHICAL_LEVEL][MAX_TEMPORAL_LAYERS] = { // [Highest Temporal Layer] [Temporal Layer Index]
3017 : { 100 },
3018 : { 100, 100 },
3019 : { 100, 100, 100 },
3020 : { 200, 140, 100, 70 },
3021 : { 350, 200, 100, 100, 100 },
3022 : { 525, 350, 200, 100, 100, 100 }
3023 : };
3024 :
3025 : static const int32_t hme_level_0_search_area_multiplier_y[MAX_HIERARCHICAL_LEVEL][MAX_TEMPORAL_LAYERS] = { // [Highest Temporal Layer] [Temporal Layer Index]
3026 : { 100 },
3027 : { 100, 100 },
3028 : { 100, 100, 100 },
3029 : { 200, 140, 100, 70 },
3030 : { 350, 200, 100, 100, 100 },
3031 : { 525, 350, 200, 100, 100, 100 }
3032 : };
3033 :
3034 : typedef enum RasterScanCuIndex
3035 : {
3036 : // 2Nx2N [85 partitions]
3037 : RASTER_SCAN_CU_INDEX_64x64 = 0,
3038 : RASTER_SCAN_CU_INDEX_32x32_0 = 1,
3039 : RASTER_SCAN_CU_INDEX_32x32_1 = 2,
3040 : RASTER_SCAN_CU_INDEX_32x32_2 = 3,
3041 : RASTER_SCAN_CU_INDEX_32x32_3 = 4,
3042 : RASTER_SCAN_CU_INDEX_16x16_0 = 5,
3043 : RASTER_SCAN_CU_INDEX_16x16_1 = 6,
3044 : RASTER_SCAN_CU_INDEX_16x16_2 = 7,
3045 : RASTER_SCAN_CU_INDEX_16x16_3 = 8,
3046 : RASTER_SCAN_CU_INDEX_16x16_4 = 9,
3047 : RASTER_SCAN_CU_INDEX_16x16_5 = 10,
3048 : RASTER_SCAN_CU_INDEX_16x16_6 = 11,
3049 : RASTER_SCAN_CU_INDEX_16x16_7 = 12,
3050 : RASTER_SCAN_CU_INDEX_16x16_8 = 13,
3051 : RASTER_SCAN_CU_INDEX_16x16_9 = 14,
3052 : RASTER_SCAN_CU_INDEX_16x16_10 = 15,
3053 : RASTER_SCAN_CU_INDEX_16x16_11 = 16,
3054 : RASTER_SCAN_CU_INDEX_16x16_12 = 17,
3055 : RASTER_SCAN_CU_INDEX_16x16_13 = 18,
3056 : RASTER_SCAN_CU_INDEX_16x16_14 = 19,
3057 : RASTER_SCAN_CU_INDEX_16x16_15 = 20,
3058 : RASTER_SCAN_CU_INDEX_8x8_0 = 21,
3059 : RASTER_SCAN_CU_INDEX_8x8_1 = 22,
3060 : RASTER_SCAN_CU_INDEX_8x8_2 = 23,
3061 : RASTER_SCAN_CU_INDEX_8x8_3 = 24,
3062 : RASTER_SCAN_CU_INDEX_8x8_4 = 25,
3063 : RASTER_SCAN_CU_INDEX_8x8_5 = 26,
3064 : RASTER_SCAN_CU_INDEX_8x8_6 = 27,
3065 : RASTER_SCAN_CU_INDEX_8x8_7 = 28,
3066 : RASTER_SCAN_CU_INDEX_8x8_8 = 29,
3067 : RASTER_SCAN_CU_INDEX_8x8_9 = 30,
3068 : RASTER_SCAN_CU_INDEX_8x8_10 = 31,
3069 : RASTER_SCAN_CU_INDEX_8x8_11 = 32,
3070 : RASTER_SCAN_CU_INDEX_8x8_12 = 33,
3071 : RASTER_SCAN_CU_INDEX_8x8_13 = 34,
3072 : RASTER_SCAN_CU_INDEX_8x8_14 = 35,
3073 : RASTER_SCAN_CU_INDEX_8x8_15 = 36,
3074 : RASTER_SCAN_CU_INDEX_8x8_16 = 37,
3075 : RASTER_SCAN_CU_INDEX_8x8_17 = 38,
3076 : RASTER_SCAN_CU_INDEX_8x8_18 = 39,
3077 : RASTER_SCAN_CU_INDEX_8x8_19 = 40,
3078 : RASTER_SCAN_CU_INDEX_8x8_20 = 41,
3079 : RASTER_SCAN_CU_INDEX_8x8_21 = 42,
3080 : RASTER_SCAN_CU_INDEX_8x8_22 = 43,
3081 : RASTER_SCAN_CU_INDEX_8x8_23 = 44,
3082 : RASTER_SCAN_CU_INDEX_8x8_24 = 45,
3083 : RASTER_SCAN_CU_INDEX_8x8_25 = 46,
3084 : RASTER_SCAN_CU_INDEX_8x8_26 = 47,
3085 : RASTER_SCAN_CU_INDEX_8x8_27 = 48,
3086 : RASTER_SCAN_CU_INDEX_8x8_28 = 49,
3087 : RASTER_SCAN_CU_INDEX_8x8_29 = 50,
3088 : RASTER_SCAN_CU_INDEX_8x8_30 = 51,
3089 : RASTER_SCAN_CU_INDEX_8x8_31 = 52,
3090 : RASTER_SCAN_CU_INDEX_8x8_32 = 53,
3091 : RASTER_SCAN_CU_INDEX_8x8_33 = 54,
3092 : RASTER_SCAN_CU_INDEX_8x8_34 = 55,
3093 : RASTER_SCAN_CU_INDEX_8x8_35 = 56,
3094 : RASTER_SCAN_CU_INDEX_8x8_36 = 57,
3095 : RASTER_SCAN_CU_INDEX_8x8_37 = 58,
3096 : RASTER_SCAN_CU_INDEX_8x8_38 = 59,
3097 : RASTER_SCAN_CU_INDEX_8x8_39 = 60,
3098 : RASTER_SCAN_CU_INDEX_8x8_40 = 61,
3099 : RASTER_SCAN_CU_INDEX_8x8_41 = 62,
3100 : RASTER_SCAN_CU_INDEX_8x8_42 = 63,
3101 : RASTER_SCAN_CU_INDEX_8x8_43 = 64,
3102 : RASTER_SCAN_CU_INDEX_8x8_44 = 65,
3103 : RASTER_SCAN_CU_INDEX_8x8_45 = 66,
3104 : RASTER_SCAN_CU_INDEX_8x8_46 = 67,
3105 : RASTER_SCAN_CU_INDEX_8x8_47 = 68,
3106 : RASTER_SCAN_CU_INDEX_8x8_48 = 69,
3107 : RASTER_SCAN_CU_INDEX_8x8_49 = 70,
3108 : RASTER_SCAN_CU_INDEX_8x8_50 = 71,
3109 : RASTER_SCAN_CU_INDEX_8x8_51 = 72,
3110 : RASTER_SCAN_CU_INDEX_8x8_52 = 73,
3111 : RASTER_SCAN_CU_INDEX_8x8_53 = 74,
3112 : RASTER_SCAN_CU_INDEX_8x8_54 = 75,
3113 : RASTER_SCAN_CU_INDEX_8x8_55 = 76,
3114 : RASTER_SCAN_CU_INDEX_8x8_56 = 77,
3115 : RASTER_SCAN_CU_INDEX_8x8_57 = 78,
3116 : RASTER_SCAN_CU_INDEX_8x8_58 = 79,
3117 : RASTER_SCAN_CU_INDEX_8x8_59 = 80,
3118 : RASTER_SCAN_CU_INDEX_8x8_60 = 81,
3119 : RASTER_SCAN_CU_INDEX_8x8_61 = 82,
3120 : RASTER_SCAN_CU_INDEX_8x8_62 = 83,
3121 : RASTER_SCAN_CU_INDEX_8x8_63 = 84
3122 : } RasterScanCuIndex;
3123 :
3124 : static const uint32_t raster_scan_cu_x[CU_MAX_COUNT] =
3125 : {
3126 : 0,
3127 : 0, 32,
3128 : 0, 32,
3129 : 0, 16, 32, 48,
3130 : 0, 16, 32, 48,
3131 : 0, 16, 32, 48,
3132 : 0, 16, 32, 48,
3133 : 0, 8, 16, 24, 32, 40, 48, 56,
3134 : 0, 8, 16, 24, 32, 40, 48, 56,
3135 : 0, 8, 16, 24, 32, 40, 48, 56,
3136 : 0, 8, 16, 24, 32, 40, 48, 56,
3137 : 0, 8, 16, 24, 32, 40, 48, 56,
3138 : 0, 8, 16, 24, 32, 40, 48, 56,
3139 : 0, 8, 16, 24, 32, 40, 48, 56,
3140 : 0, 8, 16, 24, 32, 40, 48, 56
3141 : };
3142 :
3143 : static const uint32_t raster_scan_cu_y[CU_MAX_COUNT] =
3144 : {
3145 : 0,
3146 : 0, 0,
3147 : 32, 32,
3148 : 0, 0, 0, 0,
3149 : 16, 16, 16, 16,
3150 : 32, 32, 32, 32,
3151 : 48, 48, 48, 48,
3152 : 0, 0, 0, 0, 0, 0, 0, 0,
3153 : 8, 8, 8, 8, 8, 8, 8, 8,
3154 : 16, 16, 16, 16, 16, 16, 16, 16,
3155 : 24, 24, 24, 24, 24, 24, 24, 24,
3156 : 32, 32, 32, 32, 32, 32, 32, 32,
3157 : 40, 40, 40, 40, 40, 40, 40, 40,
3158 : 48, 48, 48, 48, 48, 48, 48, 48,
3159 : 56, 56, 56, 56, 56, 56, 56, 56
3160 : };
3161 :
3162 : static const uint32_t raster_scan_cu_size[CU_MAX_COUNT] =
3163 : { 64,
3164 : 32, 32,
3165 : 32, 32,
3166 : 16, 16, 16, 16,
3167 : 16, 16, 16, 16,
3168 : 16, 16, 16, 16,
3169 : 16, 16, 16, 16,
3170 : 8, 8, 8, 8, 8, 8, 8, 8,
3171 : 8, 8, 8, 8, 8, 8, 8, 8,
3172 : 8, 8, 8, 8, 8, 8, 8, 8,
3173 : 8, 8, 8, 8, 8, 8, 8, 8,
3174 : 8, 8, 8, 8, 8, 8, 8, 8,
3175 : 8, 8, 8, 8, 8, 8, 8, 8,
3176 : 8, 8, 8, 8, 8, 8, 8, 8,
3177 : 8, 8, 8, 8, 8, 8, 8, 8
3178 : };
3179 :
3180 : static const uint32_t RASTER_SCAN_CU_DEPTH[CU_MAX_COUNT] =
3181 : { 0,
3182 : 1, 1,
3183 : 1, 1,
3184 : 2, 2, 2, 2,
3185 : 2, 2, 2, 2,
3186 : 2, 2, 2, 2,
3187 : 2, 2, 2, 2,
3188 : 3, 3, 3, 3, 3, 3, 3, 3,
3189 : 3, 3, 3, 3, 3, 3, 3, 3,
3190 : 3, 3, 3, 3, 3, 3, 3, 3,
3191 : 3, 3, 3, 3, 3, 3, 3, 3,
3192 : 3, 3, 3, 3, 3, 3, 3, 3,
3193 : 3, 3, 3, 3, 3, 3, 3, 3,
3194 : 3, 3, 3, 3, 3, 3, 3, 3,
3195 : 3, 3, 3, 3, 3, 3, 3, 3
3196 : };
3197 :
3198 : static const uint32_t raster_scan_to_md_scan[CU_MAX_COUNT] =
3199 : {
3200 : 0,
3201 : 1, 22,
3202 : 43, 64,
3203 : 2, 7, 23, 28,
3204 : 12, 17, 33, 38,
3205 : 44, 49, 65, 70,
3206 : 54, 59, 75, 80,
3207 : 3, 4, 8, 9, 24, 25, 29, 30,
3208 : 5, 6, 10, 11, 26, 27, 31, 32,
3209 : 13, 14, 18, 19, 34, 35, 39, 40,
3210 : 15, 16, 20, 21, 36, 37, 41, 42,
3211 : 45, 46, 50, 51, 66, 67, 71, 72,
3212 : 47, 48, 52, 53, 68, 69, 73, 74,
3213 : 55, 56, 60, 61, 76, 77, 81, 82,
3214 : 57, 58, 62, 63, 78, 79, 83, 84
3215 : };
3216 :
3217 : static const uint32_t ParentBlockIndex[85] = { 0, 0, 0, 2, 2, 2, 2, 0, 7, 7, 7, 7, 0, 12, 12, 12, 12, 0, 17, 17, 17, 17, 0, 0,
3218 : 23, 23, 23, 23, 0, 28, 28, 28, 28, 0, 33, 33, 33, 33, 0, 38, 38, 38, 38, 0, 0,
3219 : 44, 44, 44, 44, 0, 49, 49, 49, 49, 0, 54, 54, 54, 54, 0, 59, 59, 59, 59, 0, 0,
3220 : 65, 65, 65, 65, 0, 70, 70, 70, 70, 0, 75, 75, 75, 75, 0, 80, 80, 80, 80 };
3221 :
3222 : static const uint32_t md_scan_to_raster_scan[CU_MAX_COUNT] =
3223 : {
3224 : 0,
3225 : 1,
3226 : 5, 21, 22, 29, 30,
3227 : 6, 23, 24, 31, 32,
3228 : 9, 37, 38, 45, 46,
3229 : 10, 39, 40, 47, 48,
3230 : 2,
3231 : 7, 25, 26, 33, 34,
3232 : 8, 27, 28, 35, 36,
3233 : 11, 41, 42, 49, 50,
3234 : 12, 43, 44, 51, 52,
3235 : 3,
3236 : 13, 53, 54, 61, 62,
3237 : 14, 55, 56, 63, 64,
3238 : 17, 69, 70, 77, 78,
3239 : 18, 71, 72, 79, 80,
3240 : 4,
3241 : 15, 57, 58, 65, 66,
3242 : 16, 59, 60, 67, 68,
3243 : 19, 73, 74, 81, 82,
3244 : 20, 75, 76, 83, 84
3245 : };
3246 :
3247 : static const uint32_t raster_scan_cu_parent_index[CU_MAX_COUNT] =
3248 : { 0,
3249 : 0, 0,
3250 : 0, 0,
3251 : 1, 1, 2, 2,
3252 : 1, 1, 2, 2,
3253 : 3, 3, 4, 4,
3254 : 3, 3, 4, 4,
3255 : 5, 5, 6, 6, 7, 7, 8, 8,
3256 : 5, 5, 6, 6, 7, 7, 8, 8,
3257 : 9, 9, 10, 10, 11, 11, 12, 12,
3258 : 9, 9, 10, 10, 11, 11, 12, 12,
3259 : 13, 13, 14, 14, 15, 15, 16, 16,
3260 : 13, 13, 14, 14, 15, 15, 16, 16,
3261 : 17, 17, 18, 18, 19, 19, 20, 20,
3262 : 17, 17, 18, 18, 19, 19, 20, 20
3263 : };
3264 :
3265 : #define UNCOMPRESS_SAD(x) ( ((x) & 0x1FFF)<<(((x)>>13) & 7) )
3266 :
3267 : static const uint32_t MD_SCAN_TO_OIS_32x32_SCAN[CU_MAX_COUNT] =
3268 : {
3269 : /*0 */0,
3270 : /*1 */0,
3271 : /*2 */0,
3272 : /*3 */0,
3273 : /*4 */0,
3274 : /*5 */0,
3275 : /*6 */0,
3276 : /*7 */0,
3277 : /*8 */0,
3278 : /*9 */0,
3279 : /*10 */0,
3280 : /*11 */0,
3281 : /*12 */0,
3282 : /*13 */0,
3283 : /*14 */0,
3284 : /*15 */0,
3285 : /*16 */0,
3286 : /*17 */0,
3287 : /*18 */0,
3288 : /*19 */0,
3289 : /*20 */0,
3290 : /*21 */0,
3291 : /*22 */1,
3292 : /*23 */1,
3293 : /*24 */1,
3294 : /*25 */1,
3295 : /*26 */1,
3296 : /*27 */1,
3297 : /*28 */1,
3298 : /*29 */1,
3299 : /*30 */1,
3300 : /*31 */1,
3301 : /*32 */1,
3302 : /*33 */1,
3303 : /*34 */1,
3304 : /*35 */1,
3305 : /*36 */1,
3306 : /*37 */1,
3307 : /*38 */1,
3308 : /*39 */1,
3309 : /*40 */1,
3310 : /*41 */1,
3311 : /*42 */1,
3312 : /*43 */2,
3313 : /*44 */2,
3314 : /*45 */2,
3315 : /*46 */2,
3316 : /*47 */2,
3317 : /*48 */2,
3318 : /*49 */2,
3319 : /*50 */2,
3320 : /*51 */2,
3321 : /*52 */2,
3322 : /*53 */2,
3323 : /*54 */2,
3324 : /*55 */2,
3325 : /*56 */2,
3326 : /*57 */2,
3327 : /*58 */2,
3328 : /*59 */2,
3329 : /*60 */2,
3330 : /*61 */2,
3331 : /*62 */2,
3332 : /*63 */2,
3333 : /*64 */3,
3334 : /*65 */3,
3335 : /*66 */3,
3336 : /*67 */3,
3337 : /*68 */3,
3338 : /*69 */3,
3339 : /*70 */3,
3340 : /*71 */3,
3341 : /*72 */3,
3342 : /*73 */3,
3343 : /*74 */3,
3344 : /*75 */3,
3345 : /*76 */3,
3346 : /*77 */3,
3347 : /*78 */3,
3348 : /*79 */3,
3349 : /*80 */3,
3350 : /*81 */3,
3351 : /*82 */3,
3352 : /*83 */3,
3353 : /*84 */3,
3354 : };
3355 :
3356 : #if TWO_PASS
3357 : typedef struct stat_struct_t
3358 : {
3359 : uint32_t referenced_area[MAX_NUMBER_OF_TREEBLOCKS_PER_PICTURE];
3360 : } stat_struct_t;
3361 : #if TWO_PASS_IMPROVEMENT
3362 : #define TWO_PASS_IR_THRSHLD 40 // Intra refresh threshold used to reduce the reference area.
3363 : // If the periodic Intra refresh is less than the threshold,
3364 : // the referenced area is normalized
3365 : #endif
3366 : #endif
3367 : #define SC_MAX_LEVEL 2 // 2 sets of HME/ME settings are used depending on the scene content mode
3368 :
3369 : /******************************************************************************
3370 : ME/HME settings
3371 : *******************************************************************************/
3372 : // M0 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12
3373 : static const uint8_t enable_hme_flag[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3374 : {
3375 : { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_576p_RANGE_OR_LOWER
3376 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_720P_RANGE/INPUT_SIZE_1080i_RANGE
3377 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_1080p_RANGE
3378 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_4K_RANGE
3379 : },{
3380 : { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_576p_RANGE_OR_LOWER
3381 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_720P_RANGE/INPUT_SIZE_1080i_RANGE
3382 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_1080p_RANGE
3383 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_4K_RANGE
3384 : }
3385 : };
3386 : // M0 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12
3387 : static const uint8_t enable_hme_level0_flag[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3388 : {
3389 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_576p_RANGE_OR_LOWER
3390 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_720P_RANGE/INPUT_SIZE_1080i_RANGE
3391 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_1080p_RANGE
3392 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_4K_RANGE
3393 : },{
3394 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_576p_RANGE_OR_LOWER
3395 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_720P_RANGE/INPUT_SIZE_1080i_RANGE
3396 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_1080p_RANGE
3397 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_4K_RANGE
3398 : }
3399 : };
3400 :
3401 : static const uint16_t hme_level0_total_search_area_width[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3402 : {
3403 : { 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48 },
3404 : { 96, 96, 96, 96, 112, 48, 48, 48, 48, 48, 48, 48, 48 },
3405 : { 112, 128, 128, 128, 128, 48, 48, 48, 48, 48, 48, 48, 48 },
3406 : { 128, 128, 128, 128, 128, 96, 96, 96, 96, 96, 96, 96, 96 },
3407 : } , {
3408 : { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
3409 : { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
3410 : { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
3411 : { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 }
3412 : }
3413 : };
3414 :
3415 : static const uint16_t hme_level0_search_area_in_width_array_left[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3416 : {
3417 : { 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 },
3418 : { 48, 48, 56, 56, 56, 24, 24, 24, 24, 24, 24, 24, 24 },
3419 : { 64, 64, 64, 64, 64, 24, 24, 24, 24, 24, 24, 24, 24 },
3420 : { 64, 64, 64, 64, 64, 48, 48, 48, 48, 48, 48, 48, 48 }
3421 : } , {
3422 : { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
3423 : { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
3424 : { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
3425 : { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 }
3426 : }
3427 : };
3428 : static const uint16_t hme_level0_search_area_in_width_array_right[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3429 : {
3430 : { 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 },
3431 : { 56, 56, 56, 56, 56, 24, 24, 24, 24, 24, 24, 24, 24 },
3432 : { 64, 64, 64, 64, 64, 24, 24, 24, 24, 24, 24, 24, 24 },
3433 : { 64, 64, 64, 64, 64, 48, 48, 48, 48, 48, 48, 48, 48 }
3434 : } , {
3435 : { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
3436 : { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
3437 : { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
3438 : { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 }
3439 : }
3440 : };
3441 : static const uint16_t hme_level0_total_search_area_height[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3442 : {
3443 : { 40, 40, 40, 40, 40, 24, 24, 24, 24, 24, 24, 24, 24 },
3444 : { 64, 64, 64, 64, 64, 24, 24, 24, 24, 24, 24, 24, 24 },
3445 : { 80, 80, 80, 80, 80, 24, 24, 24, 24, 24, 24, 24, 24 },
3446 : { 80, 80, 80, 80, 80, 24, 24, 24, 24, 24, 24, 24, 24 }
3447 : } , {
3448 : { 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80 },
3449 : { 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80 },
3450 : { 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80 },
3451 : { 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80 }
3452 : }
3453 : };
3454 : static const uint16_t hme_level0_search_area_in_height_array_top[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3455 : {
3456 : { 20, 20, 20, 20, 20, 12, 12, 12, 12, 12, 12, 12, 12 },
3457 : { 32, 32, 32, 32, 32, 12, 12, 12, 12, 12, 12, 12, 12 },
3458 : { 40, 40, 40, 40, 40, 12, 12, 12, 12, 12, 12, 12, 12 },
3459 : { 40, 40, 40, 40, 40, 12, 12, 12, 12, 12, 12, 12, 12 }
3460 : } , {
3461 : { 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 },
3462 : { 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 },
3463 : { 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 },
3464 : { 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 }
3465 : }
3466 : };
3467 : static const uint16_t hme_level0_search_area_in_height_array_bottom[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3468 : {
3469 : { 20, 20, 20, 20, 20, 12, 12, 12, 12, 12, 12, 12, 12 },
3470 : { 32, 32, 32, 32, 32, 12, 12, 12, 12, 12, 12, 12, 12 },
3471 : { 40, 40, 40, 40, 40, 12, 12, 12, 12, 12, 12, 12, 12 },
3472 : { 40, 40, 40, 40, 40, 12, 12, 12, 12, 12, 12, 12, 12 }
3473 : }, {
3474 : { 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 },
3475 : { 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 },
3476 : { 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 },
3477 : { 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 }
3478 : }
3479 : };
3480 :
3481 : // HME LEVEL 1
3482 : // M0 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12
3483 : static const uint8_t enable_hme_level1_flag[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3484 : {
3485 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, // INPUT_SIZE_576p_RANGE_OR_LOWER
3486 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, // INPUT_SIZE_720P_RANGE/INPUT_SIZE_1080i_RANGE
3487 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, // INPUT_SIZE_1080p_RANGE
3488 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 } // INPUT_SIZE_4K_RANGE
3489 : }, {
3490 : { 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, // INPUT_SIZE_576p_RANGE_OR_LOWER
3491 : { 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, // INPUT_SIZE_720P_RANGE/INPUT_SIZE_1080i_RANGE
3492 : { 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, // INPUT_SIZE_1080p_RANGE
3493 : { 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } // INPUT_SIZE_4K_RANGE
3494 : }
3495 : };
3496 : static const uint16_t hme_level1_search_area_in_width_array_left[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3497 : {
3498 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3499 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3500 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3501 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 }
3502 : } , {
3503 : { 16, 16, 16, 16, 16, 8, 8, 8, 32, 8, 8, 8, 8 },
3504 : { 16, 16, 16, 16, 16, 8, 8, 8, 32, 8, 8, 8, 8 },
3505 : { 16, 16, 16, 16, 16, 8, 8, 8, 32, 8, 8, 8, 8 },
3506 : { 16, 16, 16, 16, 16, 8, 8, 8, 32, 8, 8, 8, 8 }
3507 : }
3508 : };
3509 : static const uint16_t hme_level1_search_area_in_width_array_right[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3510 : {
3511 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3512 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3513 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3514 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 }
3515 : } , {
3516 : { 16, 16, 16, 16, 16, 8, 8, 8, 32, 8, 8, 8, 8 },
3517 : { 16, 16, 16, 16, 16, 8, 8, 8, 32, 8, 8, 8, 8 },
3518 : { 16, 16, 16, 16, 16, 8, 8, 8, 32, 8, 8, 8, 8 },
3519 : { 16, 16, 16, 16, 16, 8, 8, 8, 32, 8, 8, 8, 8 }
3520 : }
3521 : };
3522 : static const uint16_t hme_level1_search_area_in_height_array_top[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3523 : {
3524 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3525 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3526 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3527 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 }
3528 : } , {
3529 : { 16, 16, 16, 16, 16, 8, 8, 8, 32, 8, 8, 8, 8 },
3530 : { 16, 16, 16, 16, 16, 8, 8, 8, 32, 8, 8, 8, 8 },
3531 : { 16, 16, 16, 16, 16, 8, 8, 8, 32, 8, 8, 8, 8 },
3532 : { 16, 16, 16, 16, 16, 8, 8, 8, 32, 8, 8, 8, 8 }
3533 : }
3534 : };
3535 : static const uint16_t hme_level1_search_area_in_height_array_bottom[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3536 : {
3537 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3538 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3539 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3540 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 }
3541 : } , {
3542 : { 16, 16, 16, 16, 16, 8, 8, 8, 32, 8, 8, 8, 8 },
3543 : { 16, 16, 16, 16, 16, 8, 8, 8, 32, 8, 8, 8, 8 },
3544 : { 16, 16, 16, 16, 16, 8, 8, 8, 32, 8, 8, 8, 8 },
3545 : { 16, 16, 16, 16, 16, 8, 8, 8, 32, 8, 8, 8, 8 }
3546 : }
3547 : };
3548 : // HME LEVEL 2
3549 : // M0 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12
3550 : static const uint8_t enable_hme_level2_flag[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3551 : {
3552 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, // INPUT_SIZE_576p_RANGE_OR_LOWER
3553 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, // INPUT_SIZE_720P_RANGE/INPUT_SIZE_1080i_RANGE
3554 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, // INPUT_SIZE_1080p_RANGE
3555 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 } // INPUT_SIZE_4K_RANGE
3556 : },{
3557 : { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // INPUT_SIZE_576p_RANGE_OR_LOWER
3558 : { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // INPUT_SIZE_720P_RANGE/INPUT_SIZE_1080i_RANGE
3559 : { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // INPUT_SIZE_1080p_RANGE
3560 : { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } // INPUT_SIZE_4K_RANGE
3561 : }
3562 : };
3563 : static const uint16_t hme_level2_search_area_in_width_array_left[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3564 : {
3565 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3566 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3567 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3568 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 }
3569 : } , {
3570 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3571 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3572 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3573 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 }
3574 : }
3575 : };
3576 : static const uint16_t hme_level2_search_area_in_width_array_right[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3577 : {
3578 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3579 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3580 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3581 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 }
3582 : } , {
3583 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3584 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3585 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3586 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 }
3587 : }
3588 : };
3589 : static const uint16_t hme_level2_search_area_in_height_array_top[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3590 : {
3591 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3592 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3593 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3594 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 }
3595 : } , {
3596 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3597 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3598 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3599 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 }
3600 : }
3601 : };
3602 : static const uint16_t hme_level2_search_area_in_height_array_bottom[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3603 : {
3604 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3605 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3606 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3607 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 }
3608 : } , {
3609 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3610 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3611 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3612 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 }
3613 : }
3614 : };
3615 :
3616 : static const uint16_t search_area_width[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3617 : {
3618 : { 128, 128, 128, 128, 64, 64, 64, 64, 48, 16, 16, 16, 16 },
3619 : { 160, 160, 160, 160, 64, 64, 64, 64, 48, 16, 16, 16, 16 },
3620 : { 192, 192, 192, 192, 64, 64, 64, 64, 48, 16, 16, 16, 16 },
3621 : { 192, 192, 192, 192, 64, 64, 64, 64, 48, 16, 16, 16, 16 },
3622 : } , {
3623 : {480 , 480, 480, 144, 144, 88, 48, 48, 48, 48, 48, 48, 48 },
3624 : {480 , 480, 480, 144, 144, 88, 48, 48, 48, 48, 48, 48, 48 },
3625 : {960 , 640, 640, 288, 288, 168, 128, 128, 64, 80, 80, 80, 80 },
3626 : {960 , 640, 640, 288, 288, 168, 128, 128, 64, 80, 80, 80, 80 }
3627 : }
3628 : };
3629 : static const uint16_t search_area_height[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3630 : {
3631 : { 128, 128, 128, 128, 32, 32, 32, 32, 16, 9, 9, 9, 9 },
3632 : { 160, 160, 160, 160, 32, 32, 32, 32, 16, 9, 9, 9, 9 },
3633 : { 192, 192, 192, 192, 32, 32, 32, 32, 16, 9, 9, 9, 9 },
3634 : { 192, 192, 192, 192, 32, 32, 32, 32, 16, 9, 9, 9, 9 }
3635 : } , {
3636 : {480 , 480, 480, 144, 144, 88, 48, 48, 48, 48, 48, 48, 48 },
3637 : {480 , 480, 480, 144, 144, 88, 48, 48, 48, 48, 48, 48, 48 },
3638 : {960 , 640, 640, 288, 288, 168, 80, 80, 48, 80, 80, 80, 80 },
3639 : {960 , 640, 640, 288, 288, 168, 80, 80, 48, 80, 80, 80, 80 }
3640 : }
3641 :
3642 : // M0 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12
3643 : };
3644 :
3645 : /******************************************************************************
3646 : ME/HME settings for Altref Temporal Filtering
3647 : *******************************************************************************/
3648 : // M0 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12
3649 : static const uint8_t tf_enable_hme_flag[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3650 : {
3651 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_576p_RANGE_OR_LOWER
3652 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_720P_RANGE/INPUT_SIZE_1080i_RANGE
3653 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_1080p_RANGE
3654 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_4K_RANGE
3655 : },{
3656 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_576p_RANGE_OR_LOWER
3657 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_720P_RANGE/INPUT_SIZE_1080i_RANGE
3658 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_1080p_RANGE
3659 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_4K_RANGE
3660 : }
3661 : };
3662 : // M0 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12
3663 : static const uint8_t tf_enable_hme_level0_flag[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3664 : {
3665 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_576p_RANGE_OR_LOWER
3666 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_720P_RANGE/INPUT_SIZE_1080i_RANGE
3667 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_1080p_RANGE
3668 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_4K_RANGE
3669 : },{
3670 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_576p_RANGE_OR_LOWER
3671 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_720P_RANGE/INPUT_SIZE_1080i_RANGE
3672 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_1080p_RANGE
3673 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // INPUT_SIZE_4K_RANGE
3674 : }
3675 : };
3676 :
3677 : static const uint16_t tf_hme_level0_total_search_area_width[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3678 : {
3679 : { 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48 },
3680 : { 112, 112, 112, 112, 112, 48, 48, 48, 48, 48, 48, 48, 48 },
3681 : { 128, 128, 128, 128, 128, 48, 48, 48, 48, 48, 48, 48, 48 },
3682 : { 128, 128, 128, 128, 128, 96, 96, 96, 96, 96, 96, 96, 96 },
3683 : } , {
3684 : { 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48 },
3685 : { 112, 112, 112, 112, 112, 48, 48, 48, 48, 48, 48, 48, 48 },
3686 : { 128, 128, 128, 128, 128, 48, 48, 48, 48, 48, 48, 48, 48 },
3687 : { 128, 128, 128, 128, 128, 96, 96, 96, 96, 96, 96, 96, 96 },
3688 : }
3689 : };
3690 :
3691 : static const uint16_t tf_hme_level0_search_area_in_width_array_left[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3692 : {
3693 : { 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 },
3694 : { 56, 56, 56, 56, 56, 24, 24, 24, 24, 24, 24, 24, 24 },
3695 : { 64, 64, 64, 64, 64, 24, 24, 24, 24, 24, 24, 24, 24 },
3696 : { 64, 64, 64, 64, 64, 48, 48, 48, 48, 48, 48, 48, 48 }
3697 : } , {
3698 : { 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 },
3699 : { 56, 56, 56, 56, 56, 24, 24, 24, 24, 24, 24, 24, 24 },
3700 : { 64, 64, 64, 64, 64, 24, 24, 24, 24, 24, 24, 24, 24 },
3701 : { 64, 64, 64, 64, 64, 48, 48, 48, 48, 48, 48, 48, 48 }
3702 : }
3703 : };
3704 : static const uint16_t tf_hme_level0_search_area_in_width_array_right[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3705 : {
3706 : { 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 },
3707 : { 56, 56, 56, 56, 56, 24, 24, 24, 24, 24, 24, 24, 24 },
3708 : { 64, 64, 64, 64, 64, 24, 24, 24, 24, 24, 24, 24, 24 },
3709 : { 64, 64, 64, 64, 64, 48, 48, 48, 48, 48, 48, 48, 48 }
3710 : } , {
3711 : { 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 },
3712 : { 56, 56, 56, 56, 56, 24, 24, 24, 24, 24, 24, 24, 24 },
3713 : { 64, 64, 64, 64, 64, 24, 24, 24, 24, 24, 24, 24, 24 },
3714 : { 64, 64, 64, 64, 64, 48, 48, 48, 48, 48, 48, 48, 48 }
3715 : }
3716 : };
3717 : static const uint16_t tf_hme_level0_total_search_area_height[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3718 : {
3719 : { 40, 40, 40, 40, 40, 24, 24, 24, 24, 24, 24, 24, 24 },
3720 : { 64, 64, 64, 64, 64, 24, 24, 24, 24, 24, 24, 24, 24 },
3721 : { 80, 80, 80, 80, 80, 24, 24, 24, 24, 24, 24, 24, 24 },
3722 : { 80, 80, 80, 80, 80, 24, 24, 24, 24, 24, 24, 24, 24 }
3723 : } , {
3724 : { 40, 40, 40, 40, 40, 24, 24, 24, 24, 24, 24, 24, 24 },
3725 : { 64, 64, 64, 64, 64, 24, 24, 24, 24, 24, 24, 24, 24 },
3726 : { 80, 80, 80, 80, 80, 24, 24, 24, 24, 24, 24, 24, 24 },
3727 : { 80, 80, 80, 80, 80, 24, 24, 24, 24, 24, 24, 24, 24 }
3728 : }
3729 : };
3730 : static const uint16_t tf_hme_level0_search_area_in_height_array_top[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3731 : {
3732 : { 20, 20, 20, 20, 20, 12, 12, 12, 12, 12, 12, 12, 12 },
3733 : { 32, 32, 32, 32, 32, 12, 12, 12, 12, 12, 12, 12, 12 },
3734 : { 40, 40, 40, 40, 40, 12, 12, 12, 12, 12, 12, 12, 12 },
3735 : { 40, 40, 40, 40, 40, 12, 12, 12, 12, 12, 12, 12, 12 }
3736 : } , {
3737 : { 20, 20, 20, 20, 20, 12, 12, 12, 12, 12, 12, 12, 12 },
3738 : { 32, 32, 32, 32, 32, 12, 12, 12, 12, 12, 12, 12, 12 },
3739 : { 40, 40, 40, 40, 40, 12, 12, 12, 12, 12, 12, 12, 12 },
3740 : { 40, 40, 40, 40, 40, 12, 12, 12, 12, 12, 12, 12, 12 }
3741 : }
3742 : };
3743 : static const uint16_t tf_hme_level0_search_area_in_height_array_bottom[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3744 : {
3745 : { 20, 20, 20, 20, 20, 12, 12, 12, 12, 12, 12, 12, 12 },
3746 : { 32, 32, 32, 32, 32, 12, 12, 12, 12, 12, 12, 12, 12 },
3747 : { 40, 40, 40, 40, 40, 12, 12, 12, 12, 12, 12, 12, 12 },
3748 : { 40, 40, 40, 40, 40, 12, 12, 12, 12, 12, 12, 12, 12 }
3749 : }, {
3750 : { 20, 20, 20, 20, 20, 12, 12, 12, 12, 12, 12, 12, 12 },
3751 : { 32, 32, 32, 32, 32, 12, 12, 12, 12, 12, 12, 12, 12 },
3752 : { 40, 40, 40, 40, 40, 12, 12, 12, 12, 12, 12, 12, 12 },
3753 : { 40, 40, 40, 40, 40, 12, 12, 12, 12, 12, 12, 12, 12 }
3754 : }
3755 : };
3756 :
3757 : // HME LEVEL 1
3758 : // M0 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12
3759 : static const uint8_t tf_enable_hme_level1_flag[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3760 : {
3761 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, // INPUT_SIZE_576p_RANGE_OR_LOWER
3762 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, // INPUT_SIZE_720P_RANGE/INPUT_SIZE_1080i_RANGE
3763 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, // INPUT_SIZE_1080p_RANGE
3764 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 } // INPUT_SIZE_4K_RANGE
3765 : }, {
3766 : { 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, // INPUT_SIZE_576p_RANGE_OR_LOWER
3767 : { 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, // INPUT_SIZE_720P_RANGE/INPUT_SIZE_1080i_RANGE
3768 : { 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, // INPUT_SIZE_1080p_RANGE
3769 : { 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 } // INPUT_SIZE_4K_RANGE
3770 : }
3771 : };
3772 : static const uint16_t tf_hme_level1_search_area_in_width_array_left[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3773 : {
3774 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3775 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3776 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3777 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 }
3778 : } , {
3779 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3780 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3781 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3782 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 }
3783 : }
3784 : };
3785 : static const uint16_t tf_hme_level1_search_area_in_width_array_right[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3786 : {
3787 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3788 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3789 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3790 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 }
3791 : } , {
3792 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3793 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3794 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3795 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 }
3796 : }
3797 : };
3798 : static const uint16_t tf_hme_level1_search_area_in_height_array_top[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3799 : {
3800 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3801 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3802 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3803 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 }
3804 : } , {
3805 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3806 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3807 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3808 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 }
3809 : }
3810 : };
3811 : static const uint16_t tf_hme_level1_search_area_in_height_array_bottom[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3812 : {
3813 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3814 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3815 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3816 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 }
3817 : } , {
3818 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3819 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3820 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 },
3821 : { 16, 16, 16, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8 }
3822 : }
3823 : };
3824 : // HME LEVEL 2
3825 : // M0 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12
3826 : static const uint8_t tf_enable_hme_level2_flag[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3827 : {
3828 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, // INPUT_SIZE_576p_RANGE_OR_LOWER
3829 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, // INPUT_SIZE_720P_RANGE/INPUT_SIZE_1080i_RANGE
3830 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, // INPUT_SIZE_1080p_RANGE
3831 : { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 } // INPUT_SIZE_4K_RANGE
3832 : },{
3833 : { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // INPUT_SIZE_576p_RANGE_OR_LOWER
3834 : { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // INPUT_SIZE_720P_RANGE/INPUT_SIZE_1080i_RANGE
3835 : { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // INPUT_SIZE_1080p_RANGE
3836 : { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } // INPUT_SIZE_4K_RANGE
3837 : }
3838 : };
3839 : static const uint16_t tf_hme_level2_search_area_in_width_array_left[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3840 : {
3841 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3842 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3843 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3844 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 }
3845 : } , {
3846 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3847 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3848 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3849 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 }
3850 : }
3851 : };
3852 : static const uint16_t tf_hme_level2_search_area_in_width_array_right[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3853 : {
3854 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3855 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3856 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3857 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 }
3858 : } , {
3859 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3860 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3861 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3862 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 }
3863 : }
3864 : };
3865 : static const uint16_t tf_hme_level2_search_area_in_height_array_top[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3866 : {
3867 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3868 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3869 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3870 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 }
3871 : } , {
3872 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3873 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3874 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3875 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 }
3876 : }
3877 : };
3878 : static const uint16_t tf_hme_level2_search_area_in_height_array_bottom[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3879 : {
3880 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3881 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3882 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3883 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 }
3884 : } , {
3885 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3886 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3887 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 },
3888 : { 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4 }
3889 : }
3890 : };
3891 :
3892 : static const uint16_t tf_search_area_width[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3893 : {
3894 : { 64, 64, 64, 64, 64, 64, 64, 64, 48, 16, 16, 16, 16 },
3895 : { 112, 112, 64, 64, 64, 64, 64, 64, 48, 16, 16, 16, 16 },
3896 : { 128, 128, 64, 64, 64, 64, 64, 64, 48, 16, 16, 16, 16 },
3897 : { 128, 128, 64, 64, 64, 64, 64, 64, 48, 16, 16, 16, 16 }
3898 : } , {
3899 : { 64, 64, 64, 64, 64, 64, 64, 64, 48, 16, 16, 16, 16 },
3900 : { 112, 112, 64, 64, 64, 64, 64, 64, 48, 16, 16, 16, 16 },
3901 : { 128, 128, 64, 64, 64, 64, 64, 64, 48, 16, 16, 16, 16 },
3902 : { 128, 128, 64, 64, 64, 64, 64, 64, 48, 16, 16, 16, 16 }
3903 : }
3904 : };
3905 : static const uint16_t tf_search_area_height[SC_MAX_LEVEL][INPUT_SIZE_COUNT][MAX_SUPPORTED_MODES] = {
3906 : {
3907 : { 64, 64, 64, 64, 32, 32, 32, 32, 16, 9, 9, 9, 9 },
3908 : { 112, 112, 64, 64, 32, 32, 32, 32, 16, 9, 9, 9, 9 },
3909 : { 128, 128, 64, 64, 32, 32, 32, 32, 16, 9, 9, 9, 9 },
3910 : { 128, 128, 64, 64, 32, 32, 32, 32, 16, 9, 9, 9, 9 }
3911 : } , {
3912 : { 64, 64, 64, 64, 32, 32, 32, 32, 16, 9, 9, 9, 9 },
3913 : { 112, 112, 64, 64, 32, 32, 32, 32, 16, 9, 9, 9, 9 },
3914 : { 128, 128, 64, 64, 32, 32, 32, 32, 16, 9, 9, 9, 9 },
3915 : { 128, 128, 64, 64, 32, 32, 32, 32, 16, 9, 9, 9, 9 }
3916 : }
3917 :
3918 : // M0 M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12
3919 : };
3920 :
3921 : static const uint16_t ep_to_pa_block_index[BLOCK_MAX_COUNT_SB_64] = {
3922 : 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3923 : 1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3924 : 2 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3925 : 3 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3926 : 4 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3927 : 5 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3928 : 6 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3929 : 7 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3930 : 8 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3931 : 9 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3932 : 10,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3933 : 11,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3934 : 12,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3935 : 13,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3936 : 14,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3937 : 15,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3938 : 16,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3939 : 17,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3940 : 18,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3941 : 19,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3942 : 20,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3943 : 21,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3944 : 22,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3945 : 23,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3946 : 24,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3947 : 25,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3948 : 26,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3949 : 27,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3950 : 28,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3951 : 29,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3952 : 30,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3953 : 31,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3954 : 32,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3955 : 33,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3956 : 34,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3957 : 35,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3958 : 36,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3959 : 37,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3960 : 38,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3961 : 39,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3962 : 40,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3963 : 41,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3964 : 42,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3965 : 43,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3966 : 44,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3967 : 45,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3968 : 46,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3969 : 47,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3970 : 48,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3971 : 49,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3972 : 50,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3973 : 51,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3974 : 52,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3975 : 53,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3976 : 54,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3977 : 55,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3978 : 56,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3979 : 57,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3980 : 58,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3981 : 59,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3982 : 60,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3983 : 61,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3984 : 62,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3985 : 63,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3986 : 64,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3987 : 65,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3988 : 66,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3989 : 67,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3990 : 68,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3991 : 69,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3992 : 70,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3993 : 71,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3994 : 72,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3995 : 73,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3996 : 74,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3997 : 75,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3998 : 76,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
3999 : 77,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
4000 : 78,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
4001 : 79,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
4002 : 80,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
4003 : 81,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
4004 : 82,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
4005 : 83,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,
4006 : 84,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0
4007 : };
4008 : #ifdef __cplusplus
4009 : }
4010 : #endif
4011 : #endif // EbDefinitions_h
4012 : /* File EOF */
|