81#define PU_GET_X(part_mode, cu_width, cu_x, i) \
82 ((cu_x) + kvz_part_mode_offsets[(part_mode)][(i)][0] * (cu_width) / 4)
93#define PU_GET_Y(part_mode, cu_width, cu_y, i) \
94 ((cu_y) + kvz_part_mode_offsets[(part_mode)][(i)][1] * (cu_width) / 4)
104#define PU_GET_W(part_mode, cu_width, i) \
105 (kvz_part_mode_sizes[(part_mode)][(i)][0] * (cu_width) / 4)
115#define PU_GET_H(part_mode, cu_width, i) \
116 (kvz_part_mode_sizes[(part_mode)][(i)][1] * (cu_width) / 4)
153#if KVZ_SEL_ENCRYPTION
167#define CU_GET_MV_CAND(cu_info_ptr, reflist) \
168 (((reflist) == 0) ? (cu_info_ptr)->inter.mv_cand0 : (cu_info_ptr)->inter.mv_cand1)
170#define CU_SET_MV_CAND(cu_info_ptr, reflist, value) \
172 if ((reflist) == 0) { \
173 (cu_info_ptr)->inter.mv_cand0 = (value); \
175 (cu_info_ptr)->inter.mv_cand1 = (value); \
179#define CHECKPOINT_CU(prefix_str, cu) CHECKPOINT(prefix_str " type=%d depth=%d part_size=%d tr_depth=%d coded=%d " \
180 "skipped=%d merged=%d merge_idx=%d cbf.y=%d cbf.u=%d cbf.v=%d " \
181 "intra[0].cost=%u intra[0].bitcost=%u intra[0].mode=%d intra[0].mode_chroma=%d intra[0].tr_skip=%d " \
182 "intra[1].cost=%u intra[1].bitcost=%u intra[1].mode=%d intra[1].mode_chroma=%d intra[1].tr_skip=%d " \
183 "intra[2].cost=%u intra[2].bitcost=%u intra[2].mode=%d intra[2].mode_chroma=%d intra[2].tr_skip=%d " \
184 "intra[3].cost=%u intra[3].bitcost=%u intra[3].mode=%d intra[3].mode_chroma=%d intra[3].tr_skip=%d " \
185 "inter.cost=%u inter.bitcost=%u inter.mv[0]=%d inter.mv[1]=%d inter.mvd[0]=%d inter.mvd[1]=%d " \
186 "inter.mv_cand=%d inter.mv_ref=%d inter.mv_dir=%d inter.mode=%d" \
187 , (cu).type, (cu).depth, (cu).part_size, (cu).tr_depth, (cu).coded, \
188 (cu).skipped, (cu).merged, (cu).merge_idx, (cu).cbf.y, (cu).cbf.u, (cu).cbf.v, \
189 (cu).intra[0].cost, (cu).intra[0].bitcost, (cu).intra[0].mode, (cu).intra[0].mode_chroma, (cu).intra[0].tr_skip, \
190 (cu).intra[1].cost, (cu).intra[1].bitcost, (cu).intra[1].mode, (cu).intra[1].mode_chroma, (cu).intra[1].tr_skip, \
191 (cu).intra[2].cost, (cu).intra[2].bitcost, (cu).intra[2].mode, (cu).intra[2].mode_chroma, (cu).intra[2].tr_skip, \
192 (cu).intra[3].cost, (cu).intra[3].bitcost, (cu).intra[3].mode, (cu).intra[3].mode_chroma, (cu).intra[3].tr_skip, \
193 (cu).inter.cost, (cu).inter.bitcost, (cu).inter.mv[0], (cu).inter.mv[1], (cu).inter.mvd[0], (cu).inter.mvd[1], \
194 (cu).inter.mv_cand, (cu).inter.mv_ref, (cu).inter.mv_dir, (cu).inter.mode)
212 const unsigned width,
224#define SUB_SCU(xy) ((xy) & (LCU_WIDTH - 1))
226#define LCU_CU_WIDTH 16
227#define LCU_T_CU_WIDTH (LCU_CU_WIDTH + 1)
228#define LCU_CU_OFFSET (LCU_T_CU_WIDTH + 1)
229#define SCU_WIDTH (LCU_WIDTH / LCU_CU_WIDTH)
232#define LCU_REF_PX_WIDTH (LCU_WIDTH + LCU_WIDTH / 2)
344#define LCU_GET_TOP_RIGHT_CU(lcu) \
345 (&(lcu)->cu[LCU_T_CU_WIDTH * LCU_T_CU_WIDTH])
355#define LCU_GET_CU_AT_PX(lcu, x_px, y_px) \
356 (&(lcu)->cu[LCU_CU_OFFSET + ((x_px) >> 2) + ((y_px) >> 2) * LCU_T_CU_WIDTH])
387 assert(width % 4 == 0 && width >= 4 && width <= 64);
388 assert(x % 4 == 0 && x < width);
389 assert(y % 4 == 0 && y < width);
395 result += x / 32 * (32*32);
396 result += y / 32 * (64*32);
401 result += x / 16 * (16*16);
402 result += y / 16 * (32*16);
424#define CHECKPOINT_LCU(prefix_str, lcu) do { \
425 CHECKPOINT_CU(prefix_str " cu[0]", (lcu).cu[0]); \
426 CHECKPOINT_CU(prefix_str " cu[1]", (lcu).cu[1]); \
427 CHECKPOINT_CU(prefix_str " cu[2]", (lcu).cu[2]); \
428 CHECKPOINT_CU(prefix_str " cu[3]", (lcu).cu[3]); \
429 CHECKPOINT_CU(prefix_str " cu[4]", (lcu).cu[4]); \
430 CHECKPOINT_CU(prefix_str " cu[5]", (lcu).cu[5]); \
431 CHECKPOINT_CU(prefix_str " cu[6]", (lcu).cu[6]); \
432 CHECKPOINT_CU(prefix_str " cu[7]", (lcu).cu[7]); \
433 CHECKPOINT_CU(prefix_str " cu[8]", (lcu).cu[8]); \
434 CHECKPOINT_CU(prefix_str " cu[9]", (lcu).cu[9]); \
435 CHECKPOINT_CU(prefix_str " cu[10]", (lcu).cu[10]); \
436 CHECKPOINT_CU(prefix_str " cu[11]", (lcu).cu[11]); \
437 CHECKPOINT_CU(prefix_str " cu[12]", (lcu).cu[12]); \
438 CHECKPOINT_CU(prefix_str " cu[13]", (lcu).cu[13]); \
439 CHECKPOINT_CU(prefix_str " cu[14]", (lcu).cu[14]); \
440 CHECKPOINT_CU(prefix_str " cu[15]", (lcu).cu[15]); \
441 CHECKPOINT_CU(prefix_str " cu[16]", (lcu).cu[16]); \
442 CHECKPOINT_CU(prefix_str " cu[17]", (lcu).cu[17]); \
443 CHECKPOINT_CU(prefix_str " cu[18]", (lcu).cu[18]); \
444 CHECKPOINT_CU(prefix_str " cu[19]", (lcu).cu[19]); \
445 CHECKPOINT_CU(prefix_str " cu[20]", (lcu).cu[20]); \
446 CHECKPOINT_CU(prefix_str " cu[21]", (lcu).cu[21]); \
447 CHECKPOINT_CU(prefix_str " cu[22]", (lcu).cu[22]); \
448 CHECKPOINT_CU(prefix_str " cu[23]", (lcu).cu[23]); \
449 CHECKPOINT_CU(prefix_str " cu[24]", (lcu).cu[24]); \
450 CHECKPOINT_CU(prefix_str " cu[25]", (lcu).cu[25]); \
451 CHECKPOINT_CU(prefix_str " cu[26]", (lcu).cu[26]); \
452 CHECKPOINT_CU(prefix_str " cu[27]", (lcu).cu[27]); \
453 CHECKPOINT_CU(prefix_str " cu[28]", (lcu).cu[28]); \
454 CHECKPOINT_CU(prefix_str " cu[29]", (lcu).cu[29]); \
455 CHECKPOINT_CU(prefix_str " cu[30]", (lcu).cu[30]); \
456 CHECKPOINT_CU(prefix_str " cu[31]", (lcu).cu[31]); \
457 CHECKPOINT_CU(prefix_str " cu[32]", (lcu).cu[32]); \
458 CHECKPOINT_CU(prefix_str " cu[33]", (lcu).cu[33]); \
459 CHECKPOINT_CU(prefix_str " cu[34]", (lcu).cu[34]); \
460 CHECKPOINT_CU(prefix_str " cu[35]", (lcu).cu[35]); \
461 CHECKPOINT_CU(prefix_str " cu[36]", (lcu).cu[36]); \
462 CHECKPOINT_CU(prefix_str " cu[37]", (lcu).cu[37]); \
463 CHECKPOINT_CU(prefix_str " cu[38]", (lcu).cu[38]); \
464 CHECKPOINT_CU(prefix_str " cu[39]", (lcu).cu[39]); \
465 CHECKPOINT_CU(prefix_str " cu[40]", (lcu).cu[40]); \
466 CHECKPOINT_CU(prefix_str " cu[41]", (lcu).cu[41]); \
467 CHECKPOINT_CU(prefix_str " cu[42]", (lcu).cu[42]); \
468 CHECKPOINT_CU(prefix_str " cu[43]", (lcu).cu[43]); \
469 CHECKPOINT_CU(prefix_str " cu[44]", (lcu).cu[44]); \
470 CHECKPOINT_CU(prefix_str " cu[45]", (lcu).cu[45]); \
471 CHECKPOINT_CU(prefix_str " cu[46]", (lcu).cu[46]); \
472 CHECKPOINT_CU(prefix_str " cu[47]", (lcu).cu[47]); \
473 CHECKPOINT_CU(prefix_str " cu[48]", (lcu).cu[48]); \
474 CHECKPOINT_CU(prefix_str " cu[49]", (lcu).cu[49]); \
475 CHECKPOINT_CU(prefix_str " cu[50]", (lcu).cu[50]); \
476 CHECKPOINT_CU(prefix_str " cu[51]", (lcu).cu[51]); \
477 CHECKPOINT_CU(prefix_str " cu[52]", (lcu).cu[52]); \
478 CHECKPOINT_CU(prefix_str " cu[53]", (lcu).cu[53]); \
479 CHECKPOINT_CU(prefix_str " cu[54]", (lcu).cu[54]); \
480 CHECKPOINT_CU(prefix_str " cu[55]", (lcu).cu[55]); \
481 CHECKPOINT_CU(prefix_str " cu[56]", (lcu).cu[56]); \
482 CHECKPOINT_CU(prefix_str " cu[57]", (lcu).cu[57]); \
483 CHECKPOINT_CU(prefix_str " cu[58]", (lcu).cu[58]); \
484 CHECKPOINT_CU(prefix_str " cu[59]", (lcu).cu[59]); \
485 CHECKPOINT_CU(prefix_str " cu[60]", (lcu).cu[60]); \
486 CHECKPOINT_CU(prefix_str " cu[61]", (lcu).cu[61]); \
487 CHECKPOINT_CU(prefix_str " cu[62]", (lcu).cu[62]); \
488 CHECKPOINT_CU(prefix_str " cu[63]", (lcu).cu[63]); \
489 CHECKPOINT_CU(prefix_str " cu[64]", (lcu).cu[64]); \
490 CHECKPOINT_CU(prefix_str " cu[65]", (lcu).cu[65]); \
491 CHECKPOINT_CU(prefix_str " cu[66]", (lcu).cu[66]); \
492 CHECKPOINT_CU(prefix_str " cu[67]", (lcu).cu[67]); \
493 CHECKPOINT_CU(prefix_str " cu[68]", (lcu).cu[68]); \
494 CHECKPOINT_CU(prefix_str " cu[69]", (lcu).cu[69]); \
495 CHECKPOINT_CU(prefix_str " cu[70]", (lcu).cu[70]); \
496 CHECKPOINT_CU(prefix_str " cu[71]", (lcu).cu[71]); \
497 CHECKPOINT_CU(prefix_str " cu[72]", (lcu).cu[72]); \
498 CHECKPOINT_CU(prefix_str " cu[73]", (lcu).cu[73]); \
499 CHECKPOINT_CU(prefix_str " cu[74]", (lcu).cu[74]); \
500 CHECKPOINT_CU(prefix_str " cu[75]", (lcu).cu[75]); \
501 CHECKPOINT_CU(prefix_str " cu[76]", (lcu).cu[76]); \
502 CHECKPOINT_CU(prefix_str " cu[77]", (lcu).cu[77]); \
503 CHECKPOINT_CU(prefix_str " cu[78]", (lcu).cu[78]); \
504 CHECKPOINT_CU(prefix_str " cu[79]", (lcu).cu[79]); \
505 CHECKPOINT_CU(prefix_str " cu[80]", (lcu).cu[80]); \
506 CHECKPOINT_CU(prefix_str " cu[81]", (lcu).cu[81]); \
510#define NUM_CBF_DEPTHS 5
571#define GET_SPLITDATA(CU,curDepth) ((CU)->depth > curDepth)
572#define SET_SPLITDATA(CU,flag) { (CU)->split=(flag); }
const uint8_t kvz_part_mode_sizes[][4][2]
PU sizes.
Definition cu.c:81
#define LCU_T_CU_WIDTH
Definition cu.h:227
#define NUM_CBF_DEPTHS
Definition cu.h:510
static void cbf_copy(uint16_t *cbf, uint16_t src, color_t plane)
Copy cbf flags.
Definition cu.h:565
cu_type_t
Definition cu.h:50
@ CU_INTRA
Definition cu.h:52
@ CU_INTER
Definition cu.h:53
@ CU_PCM
Definition cu.h:54
@ CU_NOTSET
Definition cu.h:51
cu_array_t * kvz_cu_array_alloc(const int width, const int height)
Allocate a CU array.
Definition cu.c:113
const cu_info_t * kvz_cu_array_at_const(const cu_array_t *cua, unsigned x_px, unsigned y_px)
Definition cu.c:99
static unsigned xy_to_zorder(unsigned width, unsigned x, unsigned y)
Convert (x, y) coordinates to z-order index.
Definition cu.h:385
cu_array_t * kvz_cu_array_copy_ref(cu_array_t *cua)
Get a new pointer to a cu array.
Definition cu.c:197
void kvz_cu_array_free(cu_array_t **cua_ptr)
Definition cu.c:167
static const uint16_t cbf_masks[5]
Definition cu.h:511
static int cbf_is_set_any(uint16_t cbf, int depth)
Check if CBF in a given level >= depth is true.
Definition cu.h:524
static void cbf_set(uint16_t *cbf, int depth, color_t plane)
Set CBF in a level to true.
Definition cu.h:534
static void cbf_set_conditionally(uint16_t *cbf, uint16_t child_cbfs[3], int depth, color_t plane)
Set CBF in a level to true if it is set at a lower level in any of the child_cbfs.
Definition cu.h:544
const uint8_t kvz_part_mode_offsets[][4][2]
PU offsets.
Definition cu.c:63
void kvz_cu_array_copy_from_lcu(cu_array_t *dst, int dst_x, int dst_y, const lcu_t *src)
Copy an lcu to a cu array.
Definition cu.c:217
#define LCU_REF_PX_WIDTH
Definition cu.h:232
lcu_coeff_t
Definition cu.h:296
static void copy_coeffs(const coeff_t *__restrict src, coeff_t *__restrict dest, size_t width)
Copy a part of a coeff_t array to another.
Definition cu.h:366
static void cbf_clear(uint16_t *cbf, int depth, color_t plane)
Set CBF in a levels <= depth to false.
Definition cu.h:557
const uint8_t kvz_part_mode_num_parts[]
Number of PUs in a CU.
Definition cu.c:45
part_mode_t
Definition cu.h:57
@ SIZE_2NxN
Definition cu.h:59
@ SIZE_Nx2N
Definition cu.h:60
@ SIZE_2NxnD
Definition cu.h:63
@ SIZE_nLx2N
Definition cu.h:64
@ SIZE_nRx2N
Definition cu.h:65
@ SIZE_2NxnU
Definition cu.h:62
@ SIZE_2Nx2N
Definition cu.h:58
@ SIZE_NxN
Definition cu.h:61
cu_array_t * kvz_cu_subarray(cu_array_t *base, const unsigned x_offset, const unsigned y_offset, const unsigned width, const unsigned height)
Definition cu.c:133
static int cbf_is_set(uint16_t cbf, int depth, color_t plane)
Check if CBF in a given level >= depth is true.
Definition cu.h:516
cu_info_t * kvz_cu_array_at(cu_array_t *cua, unsigned x_px, unsigned y_px)
Definition cu.c:93
Header that is included in every other header.
color_t
Definition global.h:309
@ COLOR_V
Definition global.h:309
@ COLOR_Y
Definition global.h:309
@ COLOR_U
Definition global.h:309
#define INLINE
Definition global.h:240
#define MAX_TILES_PER_DIM
Definition global.h:232
#define LCU_LUMA_SIZE
Definition global.h:168
#define ALIGNED(alignment)
Definition global.h:251
#define LCU_CHROMA_SIZE
Definition global.h:169
int16_t coeff_t
Definition global.h:115
A reference counted YUV pixel buffer.
This file defines the public API of Kvazaar when used as a library.
uint8_t kvz_pixel
Definition kvazaar.h:95
cu_info_t * data
cu array
Definition cu.h:198
int32_t width
width of the array in pixels
Definition cu.h:199
int32_t height
height of the array in pixels
Definition cu.h:200
struct cu_array_t * base
base cu array or NULL
Definition cu.h:197
int32_t refcount
number of references to this cu_array
Definition cu.h:202
int32_t stride
stride of the array in pixels
Definition cu.h:201
Struct for CU info.
Definition cu.h:130
uint16_t cbf
Definition cu.h:140
uint8_t merge_idx
merge index
Definition cu.h:137
uint8_t part_size
partition mode, one of part_mode_t values
Definition cu.h:133
uint8_t qp
QP used for the CU.
Definition cu.h:147
uint8_t tr_skip
transform skip flag
Definition cu.h:138
uint8_t tr_depth
transform depth
Definition cu.h:134
uint8_t mv_cand0
Definition cu.h:160
uint8_t type
block type, one of cu_type_t values
Definition cu.h:131
int8_t mode
Definition cu.h:151
uint8_t mv_dir
Definition cu.h:162
uint8_t mv_cand1
Definition cu.h:161
uint8_t depth
depth / size of this block
Definition cu.h:132
int8_t mode_chroma
Definition cu.h:152
uint8_t skipped
flag to indicate this block is skipped
Definition cu.h:135
uint8_t merged
flag to indicate this block is merged
Definition cu.h:136
Top and left intra reference pixels for LCU.
Definition cu.h:239
lcu_ref_px_t left_ref
Reference pixels from adjacent LCUs.
Definition cu.h:301
lcu_coeff_t coeff
We get the coefficients as a byproduct of doing reconstruction during the search.
Definition cu.h:309
lcu_yuv_t rec
LCU reconstructed pixels.
Definition cu.h:303
lcu_ref_px_t top_ref
Reference pixels from adjacent LCUs.
Definition cu.h:300
lcu_yuv_t ref
LCU reference pixels.
Definition cu.h:302