30 #define PROF_TEMP_SIZE (PROF_BLOCK_SIZE) * sizeof(int16_t)
32 #define TAB_MSM(fc, depth, x, y) fc->tab.msm[(depth)][((y) >> 5) * fc->ps.pps->width32 + ((x) >> 5)]
33 #define TAB_ISPMF(fc, x, y) fc->tab.ispmf[((y) >> 6) * fc->ps.pps->width64 + ((x) >> 6)]
45 const int hs =
fc->ps.sps->hshift[tb->
c_idx];
46 const int vs =
fc->ps.sps->vshift[tb->
c_idx];
47 const int is_chroma = tb->
c_idx != 0;
51 for (
int y = y_tb; y < end; y++) {
52 const int off = y *
fc->ps.pps->min_tu_width + x_tb;
68 memset(
tab + off, v,
w);
79 const int ctb_log2_size =
sps->ctb_log2_size_y;
80 const int ctb_size_mask = (1 << ctb_log2_size) - 1;
83 const int min_cb_width =
fc->ps.pps->min_cb_width;
84 const int x_cb = cu->
x0 >>
sps->min_cb_log2_size_y;
85 const int y_cb = cu->
y0 >>
sps->min_cb_log2_size_y;
86 const int rx = cu->
x0 >> ctb_log2_size;
87 const int ry = cu->
y0 >> ctb_log2_size;
88 const int in_same_ctb_a = ((xQg - 1) >> ctb_log2_size) == rx && (yQg >> ctb_log2_size) == ry;
89 const int in_same_ctb_b = (xQg >> ctb_log2_size) == rx && ((yQg - 1) >> ctb_log2_size) == ry;
90 int qPy_pred, qPy_a, qPy_b;
93 const int first_qg_in_ctu = !(xQg & ctb_size_mask) && !(yQg & ctb_size_mask);
94 const int qPy_up =
fc->tab.qp[
LUMA][x_cb + (y_cb - 1) * min_cb_width];
95 if (first_qg_in_ctu &&
pps->ctb_to_col_bd[xQg >> ctb_log2_size] == xQg >> ctb_log2_size)
106 qPy_b =
fc->tab.qp[
LUMA][x_cb + (y_cb - 1) * min_cb_width];
112 qPy_a =
fc->tab.qp[
LUMA][(x_cb - 1) + y_cb * min_cb_width];
114 av_assert2(qPy_a >= -
fc->ps.sps->qp_bd_offset && qPy_a <= 63);
115 av_assert2(qPy_b >= -
fc->ps.sps->qp_bd_offset && qPy_b <= 63);
117 return (qPy_a + qPy_b + 1) >> 1;
125 const int log2_min_cb_size =
fc->ps.sps->min_cb_log2_size_y;
126 const int x_cb = cu->
x0 >> log2_min_cb_size;
127 const int y_cb = cu->
y0 >> log2_min_cb_size;
130 int x = y_cb *
pps->min_cb_width + x_cb;
132 for (
int y = 0; y < (cb_height >> log2_min_cb_size); y++) {
133 const int width = cb_width >> log2_min_cb_size;
136 x +=
pps->min_cb_width;
159 if (cu_qp_delta > (31 +
sps->qp_bd_offset / 2) || cu_qp_delta < -(32 +
sps->qp_bd_offset / 2))
164 int off =
sps->qp_bd_offset;
165 ep->
qp_y =
FFUMOD(ep->
qp_y + cu_qp_delta + 64 + 2 * off, 64 + off) - off;
190 const int x_center = cu->
x0 + cu->
cb_width / 2;
195 const int sh_chroma_qp_offset[] = {
202 for (
int i =
CB - 1;
i <
CR +
sps->r->sps_joint_cbcr_enabled_flag;
i++) {
203 qp =
sps->chroma_qp_table[
i][qp_chroma];
236 tu->
width = tu_width;
247 const int x0,
const int y0,
const int tb_width,
const int tb_height,
const int c_idx)
266 lc->
coeffs += tb_width * tb_height;
267 tu->
avail[!!c_idx] =
true;
272 const int sub_tu_index,
const int is_isp,
const int is_chroma_coded)
274 uint8_t tu_y_coded_flag = 0;
278 if (!is_sbt_not_coded) {
288 return tu_y_coded_flag;
296 if ((is_128 || is_chroma_coded) &&
299 if (cu_chroma_qp_offset_flag) {
300 int cu_chroma_qp_offset_idx = 0;
301 if (
pps->r->pps_chroma_qp_offset_list_len_minus1 > 0)
319 const int min_cb_width =
pps->min_cb_width;
324 const int is_sbt_not_coded = cu->
sbt_flag &&
326 const int chroma_available = tree_type !=
DUAL_TREE_LUMA &&
sps->r->sps_chroma_format_idc &&
327 (!is_isp || is_isp_last_tu);
328 int ret, xc, yc, wc, hc, is_chroma_coded;
334 const int x_cu = x0 >>
fc->ps.sps->min_cb_log2_size_y;
335 const int y_cu = y0 >>
fc->ps.sps->min_cb_log2_size_y;
339 hc =
SAMPLE_CTB(
fc->tab.cb_height[ch_type], x_cu, y_cu);
341 xc = x0, yc = y0, wc = tu_width, hc = tu_height;
344 if (chroma_available && !is_sbt_not_coded) {
354 has_qp_delta = (is_128 || tu->
coded_flag[
LUMA] || is_chroma_coded) &&
359 add_tb(tu, lc, x0, y0, tu_width, tu_height,
LUMA);
363 if (chroma_available) {
366 add_tb(tu, lc, xc, yc, wc >> hs, hc >> vs,
CB);
367 add_tb(tu, lc, xc, yc, wc >> hs, hc >> vs,
CR);
387 !cu->
sbt_flag && (is_chroma || !is_isp)) {
412 if (tu_width >
sps->max_tb_size_y || tu_height >
sps->max_tb_size_y) {
413 const int ver_split_first = tu_width >
sps->max_tb_size_y && tu_width > tu_height;
414 const int trafo_width = ver_split_first ? (tu_width / 2) : tu_width;
415 const int trafo_height = !ver_split_first ? (tu_height / 2) : tu_height;
417 #define TRANSFORM_TREE(x, y) do { \
418 ret = hls_transform_tree(lc, x, y, trafo_width, trafo_height, ch_type); \
437 #define TRANSFORM_UNIT(x, width, idx) do { \
438 ret = hls_transform_unit(lc, x, y0, width, tu_height, idx, ch_type); \
447 #undef TRANSFORM_UNIT
449 #define TRANSFORM_UNIT(y, height, idx) do { \
450 ret = hls_transform_unit(lc, x0, y, tu_width, height, idx, ch_type); \
459 #undef TRANSFORM_UNIT
486 if (tu_width >
sps->max_tb_size_y || tu_height >
sps->max_tb_size_y) {
487 const int ver_split_first = tu_width >
sps->max_tb_size_y && tu_width > tu_height;
488 const int trafo_width = ver_split_first ? (tu_width / 2) : tu_width;
489 const int trafo_height = !ver_split_first ? (tu_height / 2) : tu_height;
491 #define SKIPPED_TRANSFORM_TREE(x, y) do { \
492 int ret = skipped_transform_tree(lc, x, y, trafo_width, trafo_height); \
510 for (
int i = c_start;
i < c_end;
i++) {
524 int mtt_depth,
int depth_offset,
int part_idx,
VVCSplitMode last_split_mode,
527 int min_qt_size, max_bt_size, max_tt_size, max_mtt_depth;
533 int min_cb_size_y =
sps->min_cb_size_y;
534 int *qt = &
split->qt;
535 int *btv = &
split->btv;
536 int *bth = &
split->bth;
537 int *ttv = &
split->ttv;
538 int *tth = &
split->tth;
540 *qt = *bth = *btv = *tth = *ttv = 1;
546 if (cb_width <= min_qt_size)
550 int chroma_area = (cb_width >>
sps->hshift[1]) * (cb_height >>
sps->vshift[1]);
551 int chroma_width = cb_width >>
sps->hshift[1];
553 if (chroma_width == 8)
555 else if (chroma_width <= 4) {
556 if (chroma_width == 4)
561 *qt = *btv = *bth = *ttv = *tth = 0;
562 if (chroma_area <= 32) {
564 if (chroma_area <= 16)
573 int area = cb_width * cb_height;
579 if (cb_width <= 2 * min_cb_size_y) {
581 if (cb_width <= min_cb_size_y)
584 if (cb_height <= 2 * min_cb_size_y) {
586 if (cb_height <= min_cb_size_y)
589 if (cb_width > max_bt_size || cb_height > max_bt_size)
591 max_tt_size =
FFMIN(64, max_tt_size);
592 if (cb_width > max_tt_size || cb_height > max_tt_size)
594 if (mtt_depth >= max_mtt_depth)
595 *btv = *bth = *ttv = *tth = 0;
596 if (x0 + cb_width >
pps->width) {
600 if (y0 + cb_height <= pps->
height)
602 else if (cb_width > min_qt_size)
605 if (y0 + cb_height >
pps->height) {
606 *btv = *ttv = *tth = 0;
610 if (mtt_depth > 0 && part_idx == 1) {
616 if (cb_width <= 64 && cb_height > 64)
618 if (cb_width > 64 && cb_height <= 64)
626 if ((cb_width == 4 && cb_height == 8) || (cb_width == 8 && cb_height == 4))
637 if (!
sps->r->sps_cclm_enabled_flag)
639 if (!
sps->r->sps_qtbtt_dual_tree_intra_flag || !
IS_I(lc->
sc->
sh.
r) ||
sps->ctb_log2_size_y < 6)
642 const int x64 = x0 >> 6 << 6;
643 const int y64 = y0 >> 6 << 6;
644 const int y32 = y0 >> 5 << 5;
645 const int x64_cu = x64 >>
fc->ps.sps->min_cb_log2_size_y;
646 const int y64_cu = y64 >>
fc->ps.sps->min_cb_log2_size_y;
647 const int y32_cu = y32 >>
fc->ps.sps->min_cb_log2_size_y;
648 const int min_cb_width =
fc->ps.pps->min_cb_width;
649 const int depth =
SAMPLE_CTB(
fc->tab.cqt_depth[1], x64_cu, y64_cu);
650 const int min_depth =
fc->ps.sps->ctb_log2_size_y - 6;
654 enabled =
SAMPLE_CTB(
fc->tab.cb_width[1], x64_cu, y64_cu) == 64 &&
656 enabled |= depth == min_depth && msm64 ==
SPLIT_BT_HOR &&
657 SAMPLE_CTB(
fc->tab.cb_width[1], x64_cu, y32_cu) == 64 &&
659 enabled |= depth > min_depth;
663 const int w =
SAMPLE_CTB(
fc->tab.cb_width[0], x64_cu, y64_cu);
664 const int h =
SAMPLE_CTB(
fc->tab.cb_height[0], x64_cu, y64_cu);
665 const int depth0 =
SAMPLE_CTB(
fc->tab.cqt_depth[0], x64_cu, y64_cu);
667 ((
w < 64 ||
h < 64) && depth0 == min_depth))
676 static int less(
const void *
a,
const void *
b)
678 return *(
const int*)
a - *(
const int*)
b;
686 const int x0 = cu->
x0;
687 const int y0 = cu->
y0;
689 int intra_luma_not_planar_flag = 1;
690 int intra_luma_mpm_remainder = 0;
691 int intra_luma_mpm_flag = 1;
692 int intra_luma_mpm_idx = 0;
696 if (intra_luma_mpm_flag) {
699 if (intra_luma_not_planar_flag)
705 if (!intra_luma_not_planar_flag) {
709 const int x_a = (x0 - 1) >>
sps->min_cb_log2_size_y;
710 const int y_a = (y0 + cu->
cb_height - 1) >>
sps->min_cb_log2_size_y;
711 const int x_b = (x0 + cu->
cb_width - 1) >>
sps->min_cb_log2_size_y;
712 const int y_b = (y0 - 1) >>
sps->min_cb_log2_size_y;
713 int min_cb_width =
fc->ps.pps->min_cb_width;
737 cand[1] = 2 + ((
a + 61) % 64);
738 cand[2] = 2 + ((
a - 1) % 64);
739 cand[3] = 2 + ((
a + 60) % 64);
740 cand[4] = 2 + (
a % 64);
745 const int diff = maxab - minab;
749 cand[2] = 2 + ((minab + 61) % 64);
750 cand[3] = 2 + ((maxab - 1) % 64);
751 cand[4] = 2 + ((minab + 60) % 64);
752 }
else if (
diff >= 62) {
753 cand[2] = 2 + ((minab - 1) % 64);
754 cand[3] = 2 + ((maxab + 61) % 64);
755 cand[4] = 2 + (minab % 64);
756 }
else if (
diff == 2) {
757 cand[2] = 2 + ((minab - 1) % 64);
758 cand[3] = 2 + ((minab + 61) % 64);
759 cand[4] = 2 + ((maxab - 1) % 64);
761 cand[2] = 2 + ((minab + 61) % 64);
762 cand[3] = 2 + ((minab - 1) % 64);
763 cand[4] = 2 + ((maxab + 61) % 64);
767 cand[1] = 2 + ((maxab + 61 ) % 64);
768 cand[2] = 2 + ((maxab - 1) % 64);
769 cand[3] = 2 + ((maxab + 60 ) % 64);
770 cand[4] = 2 + (maxab % 64);
779 if (intra_luma_mpm_flag) {
780 pred = cand[intra_luma_mpm_idx];
783 pred = intra_luma_mpm_remainder + 1;
801 int lfnst_width, lfnst_height, min_lfnst;
810 for (
int j = 0; j < tu->
nb_tbs; j++) {
819 lfnst_width = cb_width >>
sps->hshift[1];
820 lfnst_height = cb_height >>
sps->vshift[1];
827 min_lfnst =
FFMIN(lfnst_width, lfnst_height);
831 if (min_lfnst >= 4) {
850 const uint8_t transform_skip_flag = cu->
tus.
head->
tbs[0].
ts;
853 !transform_skip_flag &&
FFMAX(cb_width, cb_height) <= 32 &&
867 const int x_center = (cu->
x0 + cu->
cb_width / 2) >>
sps->min_cb_log2_size_y;
868 const int y_center = (cu->
y0 + cu->
cb_height / 2) >>
sps->min_cb_log2_size_y;
869 const int min_cb_width =
pps->min_cb_width;
870 const int intra_mip_flag =
SAMPLE_CTB(
fc->tab.imf, x_center, y_center);
871 const int cu_pred_mode =
SAMPLE_CTB(
fc->tab.cpm[0], x_center, y_center);
872 const int intra_pred_mode_y =
SAMPLE_CTB(
fc->tab.ipm, x_center, y_center);
874 if (intra_mip_flag) {
881 return intra_pred_mode_y;
885 const int cclm_mode_flag,
const int cclm_mode_idx,
const int intra_chroma_pred_mode)
891 const int x_cb = cu->
x0 >>
sps->min_cb_log2_size_y;
892 const int y_cb = cu->
y0 >>
sps->min_cb_log2_size_y;
893 const int min_cb_width =
pps->min_cb_width;
894 const int intra_mip_flag =
SAMPLE_CTB(
fc->tab.imf, x_cb, y_cb);
898 intra_chroma_pred_mode == 4 && intra_mip_flag) {
909 if (cclm_mode_flag) {
911 }
else if (intra_chroma_pred_mode == 4){
939 0, 1, 61, 62, 63, 64, 65, 66, 2, 3, 5, 6, 8, 10, 12, 13,
940 14, 16, 18, 20, 22, 23, 24, 26, 28, 30, 31, 33, 34, 35, 36, 37,
941 38, 39, 40, 41, 41, 42, 43, 43, 44, 44, 45, 45, 46, 47, 48, 48,
942 49, 49, 50, 51, 51, 52, 52, 53, 54, 55, 55, 56, 56, 57, 57, 58,
950 int intra_mip_transposed_flag,
int intra_mip_mode)
952 return (intra_mip_mode << 2) | (intra_mip_transposed_flag << 1) | intra_mip_flag;
961 const int log2_min_cb_size =
sps->min_cb_log2_size_y;
962 const int x0 = cu->
x0;
963 const int y0 = cu->
y0;
964 const int x_cb = x0 >> log2_min_cb_size;
965 const int y_cb = y0 >> log2_min_cb_size;
970 if (
sps->r->sps_bdpcm_enabled_flag && cb_width <= sps->max_ts_size && cb_height <= sps->max_ts_size)
975 if (
sps->r->sps_mip_enabled_flag)
980 int x = y_cb *
pps->min_cb_width + x_cb;
981 for (
int y = 0; y < (cb_height>>log2_min_cb_size); y++) {
982 int width = cb_width>>log2_min_cb_size;
984 intra_mip_transposed_flag, intra_mip_mode);
985 memset(&
fc->tab.imf[x], mip_info,
width);
986 x +=
pps->min_cb_width;
990 int intra_subpartitions_mode_flag = 0;
991 if (
sps->r->sps_mrl_enabled_flag && ((y0 %
sps->ctb_size_y) > 0))
994 (cb_width <= sps->max_tb_size_y && cb_height <= sps->max_tb_size_y) &&
998 if (!(x0 & 63) && !(y0 & 63))
999 TAB_ISPMF(
fc, x0, y0) = intra_subpartitions_mode_flag;
1016 if (
sps->r->sps_bdpcm_enabled_flag &&
1025 int cclm_mode_flag = 0;
1026 int cclm_mode_idx = 0;
1027 int intra_chroma_pred_mode = 0;
1051 int pred_mode_ibc_flag;
1055 if (!
IS_I(rsh) ||
sps->r->sps_ibc_enabled_flag) {
1059 (
sps->r->sps_ibc_enabled_flag && !is_128))) {
1079 pred_mode_ibc_flag = 1;
1081 pred_mode_ibc_flag = 0;
1083 pred_mode_ibc_flag = (
IS_I(rsh)) ?
sps->r->sps_ibc_enabled_flag : 0;
1085 if (pred_mode_ibc_flag)
1105 && cb_width <= sps->max_tb_size_y && cb_height <= sps->max_tb_size_y) {
1106 const int sbt_ver_h = cb_width >= 8;
1107 const int sbt_hor_h = cb_height >= 8;
1109 if (sbt_ver_h || sbt_hor_h)
1112 const int sbt_ver_q = cb_width >= 16;
1113 const int sbt_hor_q = cb_height >= 16;
1114 int cu_sbt_quad_flag = 0;
1116 if ((sbt_ver_h || sbt_hor_h) && (sbt_ver_q || sbt_hor_q))
1118 if (cu_sbt_quad_flag) {
1120 if (sbt_ver_q && sbt_hor_q)
1124 if (sbt_ver_h && sbt_hor_h)
1130 const int sbt_min = cu_sbt_quad_flag ? 1 : 2;
1157 const int log2_min_cb_size =
sps->min_cb_log2_size_y;
1158 const int x_cb = cu->
x0 >> log2_min_cb_size;
1159 const int y_cb = cu->
y0 >> log2_min_cb_size;
1160 const int ch_type = cu->
ch_type;
1163 x = y_cb *
pps->min_cb_width + x_cb;
1164 for (y = 0; y < (cu->
cb_height >> log2_min_cb_size); y++) {
1168 fc->tab.cb_pos_x[ch_type][x +
i] = cu->
x0;
1169 fc->tab.cb_pos_y[ch_type][x +
i] = cu->
y0;
1175 x +=
pps->min_cb_width;
1184 const int rx = x0 >>
sps->ctb_log2_size_y;
1185 const int ry = y0 >>
sps->ctb_log2_size_y;
1203 const int cb_width,
const int cb_height,
const int cqt_depth,
const VVCTreeType tree_type)
1212 memset(&cu->
pu, 0,
sizeof(cu->
pu));
1255 for (
int j = 0; j < tu->
nb_tbs; j++) {
1273 const int diff[] = {
1280 mmvd[1] = mmvd[0] = *mmvd_offset;
1285 mmvd[
i] = *mmvd_offset;
1290 mmvd[o].
x = sign ? -mmvd[
i].
x : mmvd[
i].
x;
1291 mmvd[o].
y = sign ? -mmvd[
i].
y : mmvd[
i].
y;
1294 mvf->
mv[0].
x += mmvd[0].
x;
1295 mvf->
mv[0].
y += mmvd[0].
y;
1296 mvf->
mv[1].
x += mmvd[1].
x;
1297 mvf->
mv[1].
y += mmvd[1].
y;
1300 mvf->
mv[idx].
x += mmvd_offset->
x;
1301 mvf->
mv[idx].
y += mmvd_offset->
y;
1311 for (
int i = 0;
i < 2;
i++) {
1314 mi->mv[
i][0] = mvf->
mv[
i];
1335 int merge_subblock_idx = 0;
1337 if (
ph->max_num_subblock_merge_cand > 1) {
1354 if (
sps->r->sps_mmvd_enabled_flag)
1357 int mmvd_cand_flag = 0;
1358 if (
sps->max_num_merge_cand > 1)
1361 merge_idx = mmvd_cand_flag;
1362 }
else if (
sps->max_num_merge_cand > 1) {
1379 if (ciip_avaiable && gpm_avaiable)
1381 return sps->r->sps_ciip_enabled_flag && !cu->
skip_flag &&
1390 int merge_gpm_idx[2];
1395 merge_gpm_idx[1] = 0;
1396 if (
sps->max_num_gpm_merge_cand > 2)
1412 if (
sps->max_num_merge_cand > 1)
1432 const int is_128 = cb_width == 128 || cb_height == 128;
1433 const int ciip_avaiable =
sps->r->sps_ciip_enabled_flag &&
1434 !cu->
skip_flag && (cb_width * cb_height >= 64);
1435 const int gpm_avaiable =
sps->r->sps_gpm_enabled_flag &&
IS_B(rsh) &&
1436 (cb_width >= 8) && (cb_height >=8) &&
1437 (cb_width < 8 * cb_height) && (cb_height < 8 *cb_width);
1439 int regular_merge_flag = 1;
1441 if (!is_128 && (ciip_avaiable || gpm_avaiable))
1443 if (regular_merge_flag) {
1464 if (
sps->max_num_ibc_merge_cand > 1)
1504 for (
int i = 0;
i < 2;
i++) {
1508 for (
int i = 0;
i < 2;
i++) {
1513 for (
int i = 0;
i < 2;
i++) {
1534 if (
sps->r->sps_bcw_enabled_flag &&
mi->pred_flag ==
PF_BI &&
1535 !
w->weight_flag[
L0][
LUMA][
mi->ref_idx[0]] &&
1536 !
w->weight_flag[
L1][
LUMA][
mi->ref_idx[1]] &&
1539 cb_width * cb_height >= 256) {
1552 else if (sym_mvd_flag)
1558 const int num_cp_mv,
const int lx)
1564 int has_no_zero_mvd = 0;
1566 if (lx ==
L1 &&
ph->r->ph_mvd_l1_zero_flag &&
mi->pred_flag ==
PF_BI) {
1567 for (
int j = 0; j < num_cp_mv; j++)
1570 Mv *mvd0 = &mvds[lx][0];
1572 mvd0->
x = -mvds[
L0][0].x;
1573 mvd0->
y = -mvds[
L0][0].y;
1577 has_no_zero_mvd |= (mvd0->
x || mvd0->
y);
1578 for (
int j = 1; j < num_cp_mv; j++) {
1579 Mv *mvd = &mvds[lx][j];
1583 has_no_zero_mvd |= (mvd->
x || mvd->
y);
1586 return has_no_zero_mvd;
1592 for (
int i = 0;
i < 2;
i++) {
1594 if (
mi->pred_flag &
mask) {
1595 for (
int j = 0; j < num_cp_mv; j++) {
1596 const Mv *mvd = &mvds[
i][j];
1597 mi->mv[
i][j].x += mvd->
x * (1 << amvr_shift);
1598 mi->mv[
i][j].y += mvd->
y * (1 << amvr_shift);
1611 int mvp_l0_flag = 0;
1621 if (
sps->max_num_ibc_merge_cand > 1)
1623 if (
sps->r->sps_amvr_enabled_flag && (
mv->x ||
mv->y))
1647 int mvp_lx_flag[2] = {0};
1648 int cu_affine_type_flag = 0;
1650 int amvr_enabled, has_no_zero_mvd = 0, amvr_shift;
1654 if (
sps->r->sps_affine_enabled_flag && cb_width >= 16 && cb_height >= 16) {
1661 num_cp_mv =
mi->motion_model_idc + 1;
1663 if (
sps->r->sps_smvd_enabled_flag && !
ph->r->ph_mvd_l1_zero_flag &&
1668 for (
int i =
L0;
i <=
L1;
i++) {
1670 if (
mi->pred_flag != pred_flag) {
1672 has_no_zero_mvd |=
mvds_decode(lc, mvds, num_cp_mv,
i);
1678 sps->r->sps_amvr_enabled_flag :
sps->r->sps_affine_amvr_enabled_flag;
1679 amvr_enabled &= has_no_zero_mvd;
1683 mi->hpel_if_idx = amvr_shift == 3;
1686 if (
mi->motion_model_idc)
1693 if (
mi->motion_model_idc)
1709 const int poc =
ph->poc;
1711 const int8_t *ref_idx =
mi->ref_idx;
1720 (poc - rp0->
poc == rp1->
poc - poc) &&
1729 if (!
ph->r->ph_bdof_disabled_flag &&
1734 if (!
ph->r->ph_dmvr_disabled_flag &&
1768 MvField *dmvr_mvf =
fc->ref->tab_dmvr_mvf + idx;
1770 memcpy(dmvr_mvf, mvf,
sizeof(
MvField) *
w);
1817 const int is_128 = cb_width > 64 || cb_height > 64;
1818 int pred_mode_plt_flag = 0;
1821 CodingUnit *cu =
add_cu(lc, x0, y0, cb_width, cb_height, cqt_depth, tree_type);
1828 if (
IS_I(rsh) && is_128)
1837 if (pred_mode_plt_flag) {
1848 if (pred_mode_plt_flag) {
1860 }
else if (!pred_mode_plt_flag) {
1905 const int area = cb_width * cb_height;
1907 if ((
IS_I(rsh) &&
sps->r->sps_qtbtt_dual_tree_intra_flag) ||
1917 return 1 + !
IS_I(rsh);
1923 const int cb_width,
const int cb_height,
const VVCSplitMode split,
const int ch_type,
1929 if (mode_type_condition == 1)
1931 else if (mode_type_condition == 2) {
1934 mode_type = mode_type_curr;
1941 int x0,
int y0,
int cb_width,
int cb_height,
int qg_on_y,
int qg_on_c,
1942 int cb_sub_div,
int cqt_depth,
int mtt_depth,
int depth_offset,
int part_idx,
1946 int x0,
int y0,
int cb_width,
int cb_height,
int qg_on_y,
int qg_on_c,
1947 int cb_sub_div,
int cqt_depth,
int mtt_depth,
int depth_offset,
1950 #define CODING_TREE(x, idx) do { \
1951 ret = hls_coding_tree(lc, x, y0, cb_width / 2, cb_height, \
1952 qg_on_y, qg_on_c, cb_sub_div + 1, cqt_depth, mtt_depth + 1, \
1953 depth_offset, idx, SPLIT_BT_VER, tree_type, mode_type); \
1959 const int x1 = x0 + cb_width / 2;
1962 depth_offset += (x0 + cb_width >
pps->width) ? 1 : 0;
1964 if (x1 < pps->
width)
1973 int x0,
int y0,
int cb_width,
int cb_height,
int qg_on_y,
int qg_on_c,
1974 int cb_sub_div,
int cqt_depth,
int mtt_depth,
int depth_offset,
1977 #define CODING_TREE(y, idx) do { \
1978 ret = hls_coding_tree(lc, x0, y, cb_width , cb_height / 2, \
1979 qg_on_y, qg_on_c, cb_sub_div + 1, cqt_depth, mtt_depth + 1, \
1980 depth_offset, idx, SPLIT_BT_HOR, tree_type, mode_type); \
1986 const int y1 = y0 + (cb_height / 2);
1989 depth_offset += (y0 + cb_height >
pps->height) ? 1 : 0;
2000 int x0,
int y0,
int cb_width,
int cb_height,
int qg_on_y,
int qg_on_c,
2001 int cb_sub_div,
int cqt_depth,
int mtt_depth,
int depth_offset,
2004 #define CODING_TREE(x, w, sub_div, idx) do { \
2005 ret = hls_coding_tree(lc, x, y0, w, cb_height, \
2006 qg_on_y, qg_on_c, sub_div, cqt_depth, mtt_depth + 1, \
2007 depth_offset, idx, SPLIT_TT_VER, tree_type, mode_type); \
2013 const int x1 = x0 + cb_width / 4;
2014 const int x2 = x0 + cb_width * 3 / 4;
2030 int x0,
int y0,
int cb_width,
int cb_height,
int qg_on_y,
int qg_on_c,
2031 int cb_sub_div,
int cqt_depth,
int mtt_depth,
int depth_offset,
2034 #define CODING_TREE(y, h, sub_div, idx) do { \
2035 ret = hls_coding_tree(lc, x0, y, cb_width, h, \
2036 qg_on_y, qg_on_c, sub_div, cqt_depth, mtt_depth + 1, \
2037 depth_offset, idx, SPLIT_TT_HOR, tree_type, mode_type); \
2043 const int y1 = y0 + (cb_height / 4);
2044 const int y2 = y0 + (3 * cb_height / 4);
2050 CODING_TREE(y0, cb_height / 4, cb_sub_div + 2, 0);
2051 CODING_TREE(y1, cb_height / 2, cb_sub_div + 1, 1);
2052 CODING_TREE(y2, cb_height / 4, cb_sub_div + 2, 2);
2060 int x0,
int y0,
int cb_width,
int cb_height,
int qg_on_y,
int qg_on_c,
2061 int cb_sub_div,
int cqt_depth,
int mtt_depth,
int depth_offset,
2064 #define CODING_TREE(x, y, idx) do { \
2065 ret = hls_coding_tree(lc, x, y, cb_width / 2, cb_height / 2, \
2066 qg_on_y, qg_on_c, cb_sub_div + 2, cqt_depth + 1, 0, 0, \
2067 idx, SPLIT_QT, tree_type, mode_type); \
2073 const int x1 = x0 + cb_width / 2;
2074 const int y1 = y0 + cb_height / 2;
2078 if (x1 < pps->
width)
2082 if (x1 < pps->
width &&
2092 int x0,
int y0,
int cb_width,
int cb_height,
int qg_on_y,
int qg_on_c,
2093 int cb_sub_div,
int cqt_depth,
int mtt_depth,
int depth_offset,
2105 int x0,
int y0,
int cb_width,
int cb_height,
int qg_on_y,
int qg_on_c,
2106 int cb_sub_div,
int cqt_depth,
int mtt_depth,
int depth_offset,
int part_idx,
2117 if (
pps->r->pps_cu_qp_delta_enabled_flag && qg_on_y && cb_sub_div <= sh->cu_qp_delta_subdiv) {
2123 cb_sub_div <= sh->cu_chroma_qp_offset_subdiv) {
2128 can_split(lc, x0, y0, cb_width, cb_height, mtt_depth, depth_offset, part_idx,
2129 last_split_mode, tree_type_curr, mode_type_curr, &allowed);
2137 if (!(x0 & 31) && !(y0 & 31) && mtt_depth <= 1)
2141 cb_sub_div, cqt_depth, mtt_depth, depth_offset, tree_type, mode_type);
2151 ret =
hls_coding_unit(lc, x0, y0, cb_width, cb_height, cqt_depth, tree_type_curr, mode_type_curr);
2160 const int x0,
const int y0,
const int cb_size,
const int cqt_depth)
2165 const int cb_subdiv = 2 * cqt_depth;
2169 #define DUAL_TREE(x, y) do { \
2170 ret = dual_tree_implicit_qt_split(lc, x, y, cb_size / 2, cqt_depth + 1); \
2175 const int x1 = x0 + (cb_size / 2);
2176 const int y1 = y0 + (cb_size / 2);
2177 if (
pps->r->pps_cu_qp_delta_enabled_flag && cb_subdiv <= sh->cu_qp_delta_subdiv) {
2187 if (x1 < pps->
width)
2195 #define CODING_TREE(tree_type) do { \
2196 const int qg_on_y = tree_type == DUAL_TREE_LUMA; \
2197 ret = hls_coding_tree(lc, x0, y0, cb_size, cb_size, qg_on_y, !qg_on_y, \
2198 cb_subdiv, cqt_depth, 0, 0, 0, SPLIT_NONE, tree_type, MODE_TYPE_ALL); \
2209 #define SET_SAO(elem, value) \
2211 if (!sao_merge_up_flag && !sao_merge_left_flag) \
2212 sao->elem = value; \
2213 else if (sao_merge_left_flag) \
2214 sao->elem = CTB(fc->tab.sao, rx-1, ry).elem; \
2215 else if (sao_merge_up_flag) \
2216 sao->elem = CTB(fc->tab.sao, rx, ry-1).elem; \
2225 int sao_merge_left_flag = 0;
2226 int sao_merge_up_flag = 0;
2235 if (ry > 0 && !sao_merge_left_flag) {
2241 for (c_idx = 0; c_idx < (
fc->ps.sps->r->sps_chroma_format_idc ? 3 : 1); c_idx++) {
2243 if (!sao_used_flag) {
2258 for (
i = 0;
i < 4;
i++)
2262 for (
i = 0;
i < 4;
i++) {
2271 }
else if (c_idx != 2) {
2277 for (
i = 0;
i < 4;
i++) {
2285 sao->
offset_val[c_idx][
i + 1] *= 1 << (
fc->ps.sps->bit_depth -
FFMIN(10,
fc->ps.sps->bit_depth));
2300 uint8_t alf_use_aps_flag = 0;
2303 if (alf_use_aps_flag) {
2311 for (
int c_idx =
CB; c_idx <=
CR; c_idx++) {
2312 const uint8_t alf_enabled_flag =
2314 if (alf_enabled_flag) {
2318 if (alf->
ctb_flag[c_idx] &&
aps->num_chroma_filters > 1)
2323 if (
fc->ps.sps->r->sps_ccalf_enabled_flag) {
2326 for (
int i = 0;
i < 2;
i++) {
2328 if (cc_enabled[
i]) {
2344 const int x0,
const int y0,
const int ctu_idx,
const int rx,
const int ry)
2351 const unsigned int ctb_size =
sps->ctb_size_y;
2356 hls_sao(lc, x0 >>
sps->ctb_log2_size_y, y0 >>
sps->ctb_log2_size_y);
2360 if (
IS_I(rsh) &&
sps->r->sps_qtbtt_dual_tree_intra_flag)
2368 if (rx ==
pps->ctb_to_col_bd[rx + 1] - 1) {
2371 if (!end_of_slice_one_bit)
2374 if (ry ==
pps->ctb_to_row_bd[ry + 1] - 1) {
2376 if (!end_of_tile_one_bit)
2379 if (
fc->ps.sps->r->sps_entropy_coding_sync_enabled_flag) {
2381 if (!end_of_subset_one_bit)
2409 const int idx = mvf->
ref_idx[lx];
2412 max_y[lx][idx] =
FFMAX(max_y[lx][idx], y);
2419 for (
int sby = 0; sby <
mi->num_sb_y; sby++) {
2420 for (
int sbx = 0; sbx <
mi->num_sb_x; sbx++) {
2421 const int x0 = cu->
x0 + sbx * sbw;
2422 const int y0 = cu->
y0 + sby * sbh;
2424 for (
int lx = 0; lx < 2; lx++) {
2427 const int idx = mvf->
ref_idx[lx];
2430 max_y[lx][idx] =
FFMAX(max_y[lx][idx], y + max_dmvr_off);
2442 CTU *ctu =
fc->tab.ctus + rs;
2450 for (
int lx = 0; lx < 2; lx++)
2464 const int ctu_idx,
const int rs,
const int rx,
const int ry)
2469 const int x_ctb = rx <<
sps->ctb_log2_size_y;
2470 const int y_ctb = ry <<
sps->ctb_log2_size_y;
2471 const int ctb_size = 1 <<
sps->ctb_log2_size_y <<
sps->ctb_log2_size_y;
2475 if (rx ==
pps->ctb_to_col_bd[rx]) {
2495 const int rx,
const int ry,
const int rs)
2498 const int ctb_size =
fc->ps.sps->ctb_size_y;
2502 if (
fc->ps.pps->ctb_to_col_bd[rx] !=
fc->ps.pps->ctb_to_col_bd[rx + 1])
2504 if (
fc->ps.pps->ctb_to_row_bd[ry] !=
fc->ps.pps->ctb_to_row_bd[ry + 1])
2508 if (rx > 0 &&
fc->ps.pps->ctb_to_col_bd[rx] !=
fc->ps.pps->ctb_to_col_bd[rx - 1])
2510 if (rx > 0 &&
fc->tab.slice_idx[rs] !=
fc->tab.slice_idx[rs - 1])
2512 if (ry > 0 &&
fc->ps.pps->ctb_to_row_bd[ry] !=
fc->ps.pps->ctb_to_row_bd[ry - 1])
2514 if (ry > 0 &&
fc->tab.slice_idx[rs] !=
fc->tab.slice_idx[rs -
fc->ps.pps->ctb_width])
2523 (
fc->ps.pps->ctb_to_row_bd[ry] ==
fc->ps.pps->ctb_to_row_bd[ry - 1]);
2528 const int x0,
const int y0,
const int w,
const int h)
2563 const int min_cb_log2_size_y =
fc->ps.sps->min_cb_log2_size_y;
2564 const int x = xc >> min_cb_log2_size_y;
2565 const int y = yc >> min_cb_log2_size_y;
2566 return fc->tab.qp[
LUMA][x + y *
fc->ps.pps->min_cb_width];
2570 const int bit_depth,
const int persistent_rice_adaptation_enabled_flag)
2574 persistent_rice_adaptation_enabled_flag ? 2 * (
av_log2(
bit_depth - 10)) : 0;