Line data Source code
1 : /*
2 : * Copyright(c) 2019 Intel Corporation
3 : * SPDX - License - Identifier: BSD - 2 - Clause - Patent
4 : */
5 :
6 : #ifndef EbCodingUnit_h
7 : #define EbCodingUnit_h
8 :
9 : #include "EbDefinitions.h"
10 : #include "EbSyntaxElements.h"
11 : #include "EbMotionEstimationLcuResults.h"
12 : #include "EbDefinitions.h"
13 : #include "EbPictureBufferDesc.h"
14 : #include "EbPredictionUnit.h"
15 : #include "EbTransformUnit.h"
16 : #include "EbCabacContextModel.h"
17 : #include "hash.h"
18 : #include "EbObject.h"
19 :
20 : #ifdef __cplusplus
21 : extern "C" {
22 : #endif
23 : /*
24 : Requirements:
25 : -Must have enough CodingUnits for every single CU pattern
26 : -Easy to expand/insert CU
27 : -Easy to collapse a CU
28 : -Easy to replace CUs
29 : -Statically Allocated
30 : -Contains the leaf count
31 : */
32 :
33 : // Macros for deblocking filter
34 : #define MAX_LCU_SIZE_IN_4X4BLK (BLOCK_SIZE_64 >> 2)
35 : #define VERTICAL_EDGE_BS_ARRAY_SIZE (MAX_LCU_SIZE_IN_4X4BLK * MAX_LCU_SIZE_IN_4X4BLK)
36 : #define HORIZONTAL_EDGE_BS_ARRAY_SIZE (MAX_LCU_SIZE_IN_4X4BLK * MAX_LCU_SIZE_IN_4X4BLK)
37 :
38 : #define MAX_NUMBER_OF_BS_EDGES_PER_TREEBLOCK 128
39 : #define MAX_NUMBER_OF_LEAFS_PER_TREEBLOCK 64
40 : #define MAX_NUMBER_OF_4x4_TUs_IN_8x8_LEAF 4
41 : #define MAX_CU_COST (0xFFFFFFFFFFFFFFFFull >> 1)
42 : #define MAX_MODE_COST ( 13616969489728 * 8) // RDCOST(6544618, 128 * 128 * 255 * 255, 128 * 128 * 255 * 255) * 8;
43 : #define INVALID_FAST_CANDIDATE_INDEX ~0
44 : #define MAX_OIS_CANDIDATES 61 //18//18
45 :
46 : static const uint32_t intra_hev_cmode_to_intra_av1_mode[35] =
47 : {
48 : /*SMOOTH_PRED */ SMOOTH_PRED, // EB_INTRA_PLANAR
49 : /*DC_PRED */ DC_PRED, // EB_INTRA_DC
50 : /*D203_PRED */ D203_PRED, D203_PRED, D203_PRED, D203_PRED, D203_PRED, D203_PRED, // EB_INTRA_MODE_2 -> EB_INTRA_MODE_7
51 : /*H_PRED */ H_PRED, H_PRED, H_PRED, H_PRED, H_PRED, // EB_INTRA_MODE_8 -> EB_INTRA_HORIZONTAL -> EB_INTRA_MODE_12
52 : /*D157_PRED */ D157_PRED, D157_PRED, D157_PRED, // EB_INTRA_MODE_13 -> EB_INTRA_MODE_15
53 : /*D135_PRED */ D135_PRED, D135_PRED, D135_PRED, D135_PRED, D135_PRED, // EB_INTRA_MODE_16 -> EB_INTRA_MODE_20
54 : /*D113_PRED */ D113_PRED, D113_PRED, D113_PRED, // EB_INTRA_MODE_21 -> EB_INTRA_MODE_23
55 : /*V_PRED */ V_PRED, V_PRED, V_PRED, V_PRED, // EB_INTRA_MODE_24 -> EB_INTRA_VERTICAL -> EB_INTRA_MODE_27
56 : /*D67_PRED */ D67_PRED, D67_PRED, D67_PRED, // EB_INTRA_MODE_28 -> EB_INTRA_MODE_30
57 : /*D45_PRED */ D45_PRED, D45_PRED, D45_PRED, D45_PRED, // EB_INTRA_MODE_31 -> EB_INTRA_MODE_34
58 : };
59 : static const int8_t hevcMode_to_angle_delta_map[35] =
60 : {
61 : /*SMOOTH_PRED */ 0, // EB_INTRA_PLANAR ->
62 : /*DC_PRED */ 0, // EB_INTRA_DC
63 : /*D203_PRED */ 3, 2, 1, 0, -1, -2, // EB_INTRA_MODE_2 -> EB_INTRA_MODE_7
64 : /*H_PRED */ 3, 2, 0, -2, -3, // EB_INTRA_MODE_8 -> EB_INTRA_HORIZONTAL -> EB_INTRA_MODE_12
65 : /*D157_PRED */ 2, 0, -2, // EB_INTRA_MODE_13 -> EB_INTRA_MODE_15
66 : /*D135_PRED */ 3, 2, 0, -2, -3, // EB_INTRA_MODE_16 -> EB_INTRA_MODE_20
67 : /*D113_PRED */ 2, 0, -2, // EB_INTRA_MODE_21 -> EB_INTRA_MODE_23
68 : /*V_PRED */ 3, 2, 0, -2, // EB_INTRA_MODE_24 -> EB_INTRA_VERTICAL -> EB_INTRA_MODE_27
69 : /*D67_PRED */ 2, 0, -2, // EB_INTRA_MODE_28 -> EB_INTRA_MODE_30
70 : /*D45_PRED */ 3, 2, 0, -2, // EB_INTRA_MODE_31 -> EB_INTRA_MODE_34
71 : };
72 : static const uint32_t intra_luma_to_chroma[INTRA_MODES] = // EB_INTRA_PLANAR
73 : {
74 : UV_DC_PRED, // Average of above and left pixels
75 : UV_V_PRED, // Vertical
76 : UV_H_PRED, // Horizontal
77 : UV_D45_PRED, // Directional 45 degree
78 : UV_D135_PRED, // Directional 135 degree
79 : UV_D113_PRED, // Directional 113 degree
80 : UV_D157_PRED, // Directional 157 degree
81 : UV_D203_PRED, // Directional 203 degree
82 : UV_D67_PRED, // Directional 67 degree
83 : UV_SMOOTH_PRED, // Combination of horizontal and vertical interpolation
84 : UV_SMOOTH_V_PRED, // Vertical interpolation
85 : UV_SMOOTH_H_PRED, // Horizontal interpolation
86 : UV_PAETH_PRED, // Predict from the direction of smallest gradient
87 : };
88 :
89 : static const TxType chroma_transform_type[14] =
90 : {
91 : /*UV_DC_PRED, */ DCT_DCT ,
92 : /*UV_V_PRED, */ ADST_DCT ,
93 : /*UV_H_PRED, */ DCT_ADST ,
94 : /*UV_D45_PRED, */ DCT_DCT ,
95 : /*UV_D135_PRED, */ ADST_ADST ,
96 : /*UV_D113_PRED, */ ADST_DCT ,
97 : /*UV_D157_PRED, */ DCT_ADST ,
98 : /*UV_D203_PRED, */ DCT_ADST ,
99 : /*UV_D67_PRED, */ ADST_DCT ,
100 : /*UV_SMOOTH_PRED, */ ADST_ADST ,
101 : /*UV_SMOOTH_V_PRED, */ ADST_DCT ,
102 : /*UV_SMOOTH_H_PRED, */ DCT_ADST ,
103 : /*UV_PAETH_PRED, */ ADST_ADST ,
104 : /*UV_CFL_PRED, */ DCT_DCT,
105 : };
106 : static const uint8_t av1_is_directional_chroma[UV_INTRA_MODES] =
107 : {
108 : /*UV_DC_PRED, */ 0,
109 : /*UV_V_PRED, */ 0,
110 : /*UV_H_PRED, */ 1,
111 : /*UV_D45_PRED, */ 1,
112 : /*UV_D135_PRED, */ 1,
113 : /*UV_D113_PRED, */ 1,
114 : /*UV_D157_PRED, */ 1,
115 : /*UV_D203_PRED, */ 1,
116 : /*UV_D67_PRED, */ 1,
117 : /*UV_SMOOTH_PRED, */ 0,
118 : /* UV_SMOOTH_PRED, */ 0,
119 : /* UV_SMOOTH_V_PRED, */ 0,
120 : /* UV_SMOOTH_H_PRED, */ 0,
121 : /* UV_PAETH_PRED, */ 0,
122 : };
123 : static const uint8_t av1_is_directional[35] =
124 : {
125 : 0, // EB_INTRA_PLANAR
126 : 0, // EB_INTRA_DC
127 : 1, 1, 1, 1, 1, 1, 1, 1, // EB_INTRA_MODE_2 -> EB_INTRA_MODE_9
128 : 1, // EB_INTRA_HORIZONTAL
129 : 1, 1, 1, 1, 1, // EB_INTRA_MODE_11 -> EB_INTRA_MODE_15
130 : 1, 1, 1, 1, 1, // EB_INTRA_MODE_16 -> EB_INTRA_MODE_20
131 : 1, 1, 1, 1, 1, // EB_INTRA_MODE_21 -> EB_INTRA_MODE_25
132 : 1, // EB_INTRA_VERTICAL
133 : 1, 1, 1, 1, // EB_INTRA_MODE_27 -> EB_INTRA_MODE_30
134 : 1, 1, 1, 1, // EB_INTRA_MODE_31 -> EB_INTRA_MODE_34
135 : };
136 : static const uint32_t mode_to_angle_map[] = {
137 : 0, 90, 180, 45, 135, 113, 157, 203, 67, 0, 0, 0, 0,
138 : };
139 62996327 : static INLINE int32_t av1_is_directional_mode(PredictionMode mode) {
140 62996327 : return mode >= V_PRED && mode <= D67_PRED;
141 : }
142 :
143 295368 : static INLINE EbBool av1_use_angle_delta(BlockSize bsize) {
144 295368 : return bsize >= BLOCK_8X8;
145 : }
146 :
147 : struct PictureControlSet;
148 :
149 : typedef struct MV
150 : {
151 : int16_t row;
152 : int16_t col;
153 : } MV;
154 :
155 : typedef union IntMv
156 : {
157 : uint32_t as_int;
158 : MV as_mv;
159 : } IntMv; /* facilitates faster equality tests and copies */
160 :
161 : typedef struct mv32 {
162 : int32_t row;
163 : int32_t col;
164 : } MV32;
165 :
166 : typedef struct CandidateMv
167 : {
168 : IntMv this_mv;
169 : IntMv comp_mv;
170 : int32_t weight;
171 : } CandidateMv;
172 :
173 : #define INTER_TX_SIZE_BUF_LEN 16
174 : #define TXK_TYPE_BUF_LEN 64
175 :
176 : typedef struct FilterIntraModeInfo {
177 : /*!< Specifies the type of intra filtering, and can represent any of the following:
178 : * FILTER_DC_PRED, FILTER_V_PRED, FILTER_H_PRED, FILTER_D157_PRED, FILTER_PAETH_PRED */
179 : FilterIntraMode filter_intra_mode;
180 :
181 : /*!< This bit specifies whether or not intra filtering can be used. */
182 : uint8_t use_filter_intra;
183 : } FilterIntraModeInfo_t;
184 :
185 : typedef struct InterIntraModeParams {
186 : /*!< Specifies the type of intra prediction to be used */
187 : InterIntraMode interintra_mode;
188 :
189 : /*!< equal to 1 specifies that wedge blending should be used.
190 : * wedge_interintra equal to 0 specifies that intra blending should be used. */
191 : uint8_t wedge_interintra;
192 :
193 : /*!< Used to derive the direction and offset of the wedge mask used during blending. */
194 : uint8_t interintra_wedge_index;
195 :
196 : /*!< Specifies the sign of the wedge blend. */
197 : // int interintra_wedge_sign; Always 0
198 : } InterIntraModeParams;
199 :
200 : typedef struct BlockModeInfo {
201 : // Common for both INTER and INTRA blocks
202 : BlockSize sb_type;
203 : PredictionMode mode;
204 : int8_t skip;
205 :
206 : PartitionType partition;
207 :
208 : /*!< 1 indicates that this block will use some default settings and skip mode info.
209 : * 0 indicates that the mode info is not skipped. */
210 : int8_t skip_mode;
211 :
212 : /*!< Specifies which segment is associated with the current intra block being decoded. */
213 : int8_t segment_id;
214 :
215 : /*!< Equal to 1 specifies that the segment_id is taken from the segmentation map. */
216 : int8_t seg_id_predicted;
217 :
218 : /*!< For Lossy mode : Specifies number of Luma TUs in a block
219 : For Lossless mode: Specifies number of Luma TUs for a block of size other than
220 : 128x128, 128x64, 64x128 and 64x64 - computed based on blocksize */
221 : uint8_t num_luma_tus;
222 :
223 : /*!< Offset of first Luma transform info from strat of SB pointer */
224 : uint16_t first_luma_tu_offset;
225 :
226 : /*!< For Lossy mode : Specifies number of Chroma TUs in a block
227 : For Lossless mode: Specifies number of Chroma TUs for a block of size other than
228 : 128x128, 128x64, 64x128 and 64x64 - computed based on blocksize */
229 : uint8_t num_chroma_tus;
230 :
231 : /*!< Offset of first Chroma transform info from strat of SB pointer */
232 : uint16_t first_chroma_tu_offset;
233 :
234 : // Only for INTRA blocks
235 : UvPredictionMode uv_mode;
236 :
237 : uint8_t use_intrabc;
238 :
239 : // Only for INTER blocks
240 :
241 : MvReferenceFrame ref_frame[2];
242 : IntMv mv[2];
243 :
244 : uint16_t ref_mv_idx;
245 :
246 : // interinter members
247 :
248 : InterIntraModeParams interintra_mode_params;
249 :
250 : /*!< Specifies the type of motion compensation to perform. */
251 : MotionMode motion_mode;
252 :
253 : InterIntraMode is_inter_intra;
254 :
255 : /*!< 0 indicates that a distance based weighted scheme should be used for blending.
256 : * 1 indicates that the averaging scheme should be used for blending.*/
257 : uint8_t compound_idx;
258 :
259 : InterInterCompoundData inter_inter_compound;
260 : FilterIntraModeInfo_t filter_intra_mode_info;
261 :
262 : /*!< Specifies how the motion vector used by inter prediction is obtained when using compound prediction. */
263 : uint8_t compound_mode;
264 :
265 : /*!< Specifies the type of filter used in inter prediction. Values 0..3 are allowed
266 : * with the same interpretation as for interpolation_filter. One filter type is specified
267 : * for the vertical filter direction and one for the horizontal filter direction.*/
268 : uint32_t interp_filters;
269 :
270 : /*!< Index of the alpha Cb and alpha Cr combination */
271 : uint8_t cfl_alpha_idx;
272 :
273 : /*!< Contains the sign of the alpha values for U and V packed together into a single syntax element. */
274 : uint8_t cfl_alpha_signs;
275 :
276 : /*!< The actual prediction angle is the base angle + (angle_delta * step). */
277 : int8_t angle_delta[PLANE_TYPES];
278 :
279 : // Number of base colors for Y (0) and UV (1)
280 : uint8_t palette_size[2];
281 :
282 : #if MODE_INFO_DBG
283 : int32_t mi_row;
284 : int32_t mi_col;
285 : #endif
286 : } BlockModeInfo;
287 :
288 : typedef struct MbModeInfo
289 : {
290 : #if CONFIG_RD_DEBUG
291 : RD_STATS rd_stats;
292 : int32_t mi_row;
293 : int32_t mi_col;
294 : #endif
295 : EbWarpedMotionParams wm_params;
296 : int32_t comp_group_idx;
297 :
298 : int8_t cdef_strength;
299 : TxSize tx_size;
300 : uint8_t inter_tx_size[INTER_TX_SIZE_BUF_LEN];
301 : uint8_t tx_depth;
302 : BlockModeInfo block_mi;
303 : #if PAL_SUP
304 : PaletteModeInfo palette_mode_info;
305 : #endif
306 : } MbModeInfo;
307 :
308 : typedef struct {
309 : IntMv mfmv0;
310 : uint8_t ref_frame_offset;
311 : } TPL_MV_REF;
312 : typedef struct {
313 : IntMv mv;
314 : MvReferenceFrame ref_frame;
315 : } MV_REF;
316 :
317 : typedef struct ModeInfo {
318 : MbModeInfo mbmi;
319 : } ModeInfo;
320 :
321 : typedef struct TileInfo
322 : {
323 : int32_t mi_row_start, mi_row_end;
324 : int32_t mi_col_start, mi_col_end;
325 : int32_t tg_horz_boundary;
326 : int32_t tile_row;
327 : int32_t tile_col;
328 : } TileInfo;
329 :
330 : typedef struct MacroBlockDPlane
331 : {
332 : int subsampling_x;
333 : int subsampling_y;
334 : struct Buf2D dst;
335 : struct Buf2D pre[2];
336 : // block size in pixels
337 : uint8_t width, height;
338 : } MacroBlockDPlane;
339 :
340 : typedef struct MacroBlockPlane
341 : {
342 : struct Buf2D src;
343 : /*
344 : DECLARE_ALIGNED(16, int16_t, src_diff[MAX_SB_SQUARE]);
345 : TranLow *qcoeff;
346 : TranLow *coeff;
347 : uint16_t *eobs;
348 : uint8_t *txb_entropy_ctx;
349 :
350 : // Quantizer setings
351 : // These are used/accessed only in the quantization process
352 : // RDO does not / must not depend on any of these values
353 : // All values below share the coefficient scale/shift used in TX
354 : const int16_t *quant_fp_QTX;
355 : const int16_t *round_fp_QTX;
356 : const int16_t *quant_QTX;
357 : const int16_t *quant_shift_QTX;
358 : const int16_t *zbin_QTX;
359 : const int16_t *round_QTX;
360 : const int16_t *dequant_QTX;
361 : */
362 : } MacroBlockPlane;
363 :
364 : struct buf_2d {
365 : uint8_t *buf;
366 : uint8_t *buf0;
367 : int width;
368 : int height;
369 : int stride;
370 : };
371 : typedef struct macroblockd_plane {
372 : int subsampling_x;
373 : int subsampling_y;
374 : struct buf_2d dst;
375 : struct buf_2d pre[2];
376 : uint8_t width, height;
377 : } MACROBLOCKD_PLANE;
378 :
379 : typedef struct MacroBlockD
380 : {
381 : // block dimension in the unit of mode_info.
382 : uint8_t n8_w, n8_h;
383 : uint8_t n4_w, n4_h; // for warped motion
384 : uint8_t ref_mv_count[MODE_CTX_REF_FRAMES];
385 : CandidateMv final_ref_mv_stack[MAX_REF_MV_STACK_SIZE];
386 : uint8_t is_sec_rect;
387 : int32_t up_available;
388 : int32_t left_available;
389 : TileInfo tile;
390 : int32_t mi_stride;
391 : ModeInfo **mi;
392 :
393 : /* Distance of MB away from frame edges in subpixels (1/8th pixel) */
394 : int32_t mb_to_left_edge;
395 : int32_t mb_to_right_edge;
396 : int32_t mb_to_top_edge;
397 : int32_t mb_to_bottom_edge;
398 : uint8_t neighbors_ref_counts[TOTAL_REFS_PER_FRAME];
399 :
400 : uint8_t use_intrabc;
401 : MbModeInfo *above_mbmi;
402 : MbModeInfo *left_mbmi;
403 : MbModeInfo *chroma_above_mbmi;
404 : MbModeInfo *chroma_left_mbmi;
405 : FRAME_CONTEXT *tile_ctx;
406 : TXFM_CONTEXT *above_txfm_context;
407 : TXFM_CONTEXT *left_txfm_context;
408 : TXFM_CONTEXT left_txfm_context_buffer[MAX_MIB_SIZE];
409 : struct macroblockd_plane plane[MAX_MB_PLANE];
410 : #if OBMC_FLAG
411 : BlockSize sb_type;
412 : #endif
413 : } MacroBlockD;
414 :
415 : typedef struct Macroblock
416 : {
417 : int32_t rdmult;
418 : int32_t switchable_restore_cost[RESTORE_SWITCHABLE_TYPES];
419 : int32_t wiener_restore_cost[2];
420 : int32_t sgrproj_restore_cost[2];
421 : } Macroblock;
422 :
423 : typedef struct IntraBcContext
424 : {
425 : int32_t rdmult;
426 : struct MacroBlockDPlane xdplane[MAX_MB_PLANE];
427 : struct MacroBlockPlane plane[MAX_MB_PLANE];
428 : MvLimits mv_limits;
429 : // The equivalend SAD error of one (whole) bit at the current quantizer
430 : // for large blocks.
431 : int sadperbit16;
432 : // The equivalent error at the current rdmult of one whole bit (not one
433 : // bitcost unit).
434 : int errorperbit;
435 : // Store the best motion vector during motion search
436 : IntMv best_mv;
437 : // Store the second best motion vector during full-pixel motion search
438 : IntMv second_best_mv;
439 : MacroBlockD * xd;
440 : int* nmv_vec_cost;
441 : int **mv_cost_stack;
442 : // buffer for hash value calculation of a block
443 : // used only in av1_get_block_hash_value()
444 : // [first hash/second hash]
445 : // [two buffers used ping-pong]
446 : uint32_t *hash_value_buffer[2][2];
447 : uint8_t is_exhaustive_allowed;
448 : CRC_CALCULATOR crc_calculator1;
449 : CRC_CALCULATOR crc_calculator2;
450 : } IntraBcContext;
451 :
452 : typedef struct CodingUnit
453 : {
454 : TransformUnit transform_unit_array[TRANSFORM_UNIT_MAX_COUNT]; // 2-bytes * 21 = 42-bytes
455 : PredictionUnit prediction_unit_array[MAX_NUM_OF_PU_PER_CU]; // 35-bytes * 4 = 140 bytes
456 : InterInterCompoundData interinter_comp;
457 : uint8_t compound_idx;
458 : uint8_t comp_group_idx;
459 : unsigned skip_flag_context : 2;
460 : unsigned prediction_mode_flag : 2;
461 : unsigned block_has_coeff : 1;
462 : unsigned split_flag_context : 2;
463 :
464 : #if !ADD_DELTA_QP_SUPPORT
465 : unsigned qp : 6;
466 : signed delta_qp : 8; // can be signed 8bits
467 : #else
468 : uint16_t qp;
469 : uint16_t ref_qp;
470 : int16_t delta_qp; // can be signed 8bits
471 : int16_t org_delta_qp;
472 : #endif
473 :
474 : // Coded Tree
475 : struct {
476 : unsigned leaf_index : 8;
477 : unsigned split_flag : 1;
478 : unsigned skip_flag : 1;
479 : unsigned mdc_split_flag : 1;
480 : };
481 : #if NO_ENCDEC
482 : EbPictureBufferDesc *quant_tmp;
483 : EbPictureBufferDesc *coeff_tmp;
484 : EbPictureBufferDesc *recon_tmp;
485 : uint32_t cand_buff_index;
486 : #endif
487 : MacroBlockD *av1xd;
488 : // uint8_t ref_mv_count[MODE_CTX_REF_FRAMES];
489 : int16_t inter_mode_ctx[MODE_CTX_REF_FRAMES];
490 : IntMv ref_mvs[MODE_CTX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; //used only for nonCompound modes.
491 : uint8_t drl_index;
492 : PredictionMode pred_mode;
493 : IntMv predmv[2];
494 : uint8_t skip_coeff_context;
495 : uint8_t reference_mode_context;
496 : uint8_t compoud_reference_type_context;
497 : int32_t quantized_dc[3][MAX_TXB_COUNT];
498 : uint32_t is_inter_ctx;
499 : uint32_t interp_filters;
500 : uint8_t segment_id;
501 : uint8_t seg_id_predicted; // valid only when temporal_update is enabled
502 : PartitionType part;
503 : PART shape;
504 : uint16_t mds_idx; //equivalent of leaf_index in the nscu context. we will keep both for now and use the right one on a case by case basis.
505 : uint8_t *neigh_left_recon[3]; //only for MD
506 : uint8_t *neigh_top_recon[3];
507 : uint16_t *neigh_left_recon_16bit[3];
508 : uint16_t *neigh_top_recon_16bit[3];
509 : uint32_t best_d1_blk;
510 : uint8_t tx_depth;
511 : #if II_COMP_FLAG
512 : INTERINTRA_MODE interintra_mode;
513 : uint8_t is_interintra_used;
514 : uint8_t use_wedge_interintra;
515 : int32_t interintra_wedge_index;
516 : int32_t ii_wedge_sign;
517 : #endif
518 : #if FILTER_INTRA_FLAG
519 : uint8_t filter_intra_mode;
520 : #endif
521 : #if PAL_SUP
522 : PaletteInfo palette_info;
523 : #endif
524 : } CodingUnit;
525 :
526 : typedef struct OisCandidate
527 : {
528 : union {
529 : struct {
530 : unsigned distortion : 20;
531 : unsigned valid_distortion : 1;
532 : unsigned : 3;
533 : unsigned intra_mode : 8;
534 : };
535 : uint32_t ois_results;
536 : };
537 : int32_t angle_delta;
538 : } OisCandidate;
539 :
540 : typedef struct OisSbResults
541 : {
542 : uint8_t total_ois_intra_candidate[CU_MAX_COUNT];
543 : OisCandidate* ois_candidate_array[CU_MAX_COUNT];
544 : int8_t best_distortion_index[CU_MAX_COUNT];
545 : } OisSbResults;
546 : typedef struct QpmLcuResults_s {
547 : uint8_t cu_qp;
548 : uint8_t cu_intra_qp;
549 : uint8_t cu_inter_qp;
550 : int8_t delta_qp;
551 : int8_t inner_sb_cu_delta_qp;
552 : } QpmLcuResults_t; // to be cleaned up
553 : typedef struct EdgeLcuResults
554 : {
555 : uint8_t edge_block_num;
556 : uint8_t isolated_high_intensity_sb; // to be cleanedup
557 : } EdgeLcuResults;
558 :
559 : typedef struct LargestCodingUnit
560 : {
561 : EbDctor dctor;
562 : struct PictureControlSet *picture_control_set_ptr;
563 :
564 : CodingUnit *final_cu_arr;
565 : uint32_t final_cu_count;
566 : //for memory free only
567 : MacroBlockD *av1xd;
568 : PartitionType *cu_partition_array;
569 : #if !ADD_DELTA_QP_SUPPORT
570 : unsigned qp : 8;
571 : #endif
572 : unsigned picture_left_edge_flag : 1;
573 : unsigned picture_top_edge_flag : 1;
574 : unsigned picture_right_edge_flag : 1;
575 : unsigned index : 12;
576 : unsigned origin_x : 12;
577 : unsigned origin_y : 12;
578 : #if ADD_DELTA_QP_SUPPORT
579 : uint16_t qp;
580 : int16_t delta_qp;
581 : int16_t org_delta_qp;
582 : #endif
583 : uint32_t total_bits;
584 :
585 : // Quantized Coefficients
586 : EbPictureBufferDesc *quantized_coeff;
587 : #if MDC_ADAPTIVE_LEVEL
588 : uint8_t depth_ranking[NUMBER_OF_DEPTH];
589 : uint64_t depth_cost[NUMBER_OF_DEPTH];
590 : #endif
591 : TileInfo tile_info;
592 : } LargestCodingUnit;
593 :
594 : extern EbErrorType largest_coding_unit_ctor(
595 : LargestCodingUnit *larget_coding_unit_ptr,
596 : uint8_t sb_sz,
597 : uint16_t sb_origin_x,
598 : uint16_t sb_origin_y,
599 : uint16_t sb_index,
600 : struct PictureControlSet *picture_control_set);
601 :
602 : #ifdef __cplusplus
603 : }
604 : #endif
605 : #endif // EbCodingUnit_h
|