32#define PROF_TEMP_SIZE (PROF_BLOCK_SIZE) * sizeof(int16_t)
34#define TAB_MSM(fc, depth, x, y) fc->tab.msm[(depth)][((y) >> 5) * fc->ps.pps->width32 + ((x) >> 5)]
35#define TAB_ISPMF(fc, x, y) fc->tab.ispmf[((y) >> 6) * fc->ps.pps->width64 + ((x) >> 6)]
47 const int hs =
fc->ps.sps->hshift[tb->
c_idx];
48 const int vs =
fc->ps.sps->vshift[tb->
c_idx];
49 const int is_chroma = tb->
c_idx != 0;
53 for (
int y = y_tb; y < end; y++) {
54 const int off = y *
fc->ps.pps->min_tu_width + x_tb;
70 memset(
tab + off, v,
w);
81 const int ctb_log2_size =
sps->ctb_log2_size_y;
82 const int ctb_size_mask = (1 << ctb_log2_size) - 1;
85 const int min_cb_width =
fc->ps.pps->min_cb_width;
86 const int x_cb = cu->
x0 >>
sps->min_cb_log2_size_y;
87 const int y_cb = cu->
y0 >>
sps->min_cb_log2_size_y;
88 const int rx = cu->
x0 >> ctb_log2_size;
89 const int ry = cu->
y0 >> ctb_log2_size;
90 const int in_same_ctb_a = ((xQg - 1) >> ctb_log2_size) == rx && (yQg >> ctb_log2_size) == ry;
91 const int in_same_ctb_b = (xQg >> ctb_log2_size) == rx && ((yQg - 1) >> ctb_log2_size) == ry;
92 int qPy_pred, qPy_a, qPy_b;
95 const int first_qg_in_ctu = !(xQg & ctb_size_mask) && !(yQg & ctb_size_mask);
96 const int qPy_up =
fc->tab.qp[
LUMA][x_cb + (y_cb - 1) * min_cb_width];
97 if (first_qg_in_ctu &&
pps->ctb_to_col_bd[xQg >> ctb_log2_size] == xQg >> ctb_log2_size)
108 qPy_b =
fc->tab.qp[
LUMA][x_cb + (y_cb - 1) * min_cb_width];
114 qPy_a =
fc->tab.qp[
LUMA][(x_cb - 1) + y_cb * min_cb_width];
116 av_assert2(qPy_a >= -
fc->ps.sps->qp_bd_offset && qPy_a <= 63);
117 av_assert2(qPy_b >= -
fc->ps.sps->qp_bd_offset && qPy_b <= 63);
119 return (qPy_a + qPy_b + 1) >> 1;
127 const int log2_min_cb_size =
fc->ps.sps->min_cb_log2_size_y;
128 const int x_cb = cu->
x0 >> log2_min_cb_size;
129 const int y_cb = cu->
y0 >> log2_min_cb_size;
132 int x = y_cb *
pps->min_cb_width + x_cb;
134 for (
int y = 0; y < (cb_height >> log2_min_cb_size); y++) {
135 const int width = cb_width >> log2_min_cb_size;
138 x +=
pps->min_cb_width;
161 if (cu_qp_delta > (31 +
sps->qp_bd_offset / 2) || cu_qp_delta < -(32 +
sps->qp_bd_offset / 2))
166 int off =
sps->qp_bd_offset;
167 ep->
qp_y =
FFUMOD(ep->
qp_y + cu_qp_delta + 64 + 2 * off, 64 + off) - off;
192 const int x_center = cu->
x0 + cu->
cb_width / 2;
197 const int sh_chroma_qp_offset[] = {
204 for (
int i =
CB - 1;
i <
CR +
sps->r->sps_joint_cbcr_enabled_flag;
i++) {
205 qp =
sps->chroma_qp_table[
i][qp_chroma];
238 tu->
width = tu_width;
249 const int x0,
const int y0,
const int tb_width,
const int tb_height,
const int c_idx)
268 lc->
coeffs += tb_width * tb_height;
269 tu->
avail[!!c_idx] =
true;
274 const int sub_tu_index,
const int is_isp,
const int is_chroma_coded)
276 uint8_t tu_y_coded_flag = 0;
280 if (!is_sbt_not_coded) {
290 return tu_y_coded_flag;
298 if ((is_128 || is_chroma_coded) &&
301 if (cu_chroma_qp_offset_flag) {
302 int cu_chroma_qp_offset_idx = 0;
303 if (
pps->r->pps_chroma_qp_offset_list_len_minus1 > 0)
321 const int min_cb_width =
pps->min_cb_width;
326 const int is_sbt_not_coded = cu->
sbt_flag &&
328 const int chroma_available = tree_type !=
DUAL_TREE_LUMA &&
sps->r->sps_chroma_format_idc &&
329 (!is_isp || is_isp_last_tu);
330 int ret, xc, yc, wc, hc, is_chroma_coded;
336 const int x_cu = x0 >>
fc->ps.sps->min_cb_log2_size_y;
337 const int y_cu = y0 >>
fc->ps.sps->min_cb_log2_size_y;
341 hc =
SAMPLE_CTB(
fc->tab.cb_height[ch_type], x_cu, y_cu);
343 xc = x0, yc = y0, wc = tu_width, hc = tu_height;
346 if (chroma_available && !is_sbt_not_coded) {
356 has_qp_delta = (is_128 || tu->
coded_flag[
LUMA] || is_chroma_coded) &&
358 ret =
set_qp_y(lc, x0, y0, has_qp_delta);
361 add_tb(tu, lc, x0, y0, tu_width, tu_height,
LUMA);
365 if (chroma_available) {
368 add_tb(tu, lc, xc, yc, wc >> hs, hc >> vs,
CB);
369 add_tb(tu, lc, xc, yc, wc >> hs, hc >> vs,
CR);
389 !cu->
sbt_flag && (is_chroma || !is_isp)) {
416 if (tu_width >
sps->max_tb_size_y || tu_height >
sps->max_tb_size_y) {
417 const int ver_split_first = tu_width >
sps->max_tb_size_y && tu_width > tu_height;
418 const int trafo_width = ver_split_first ? (tu_width / 2) : tu_width;
419 const int trafo_height = !ver_split_first ? (tu_height / 2) : tu_height;
421 #define TRANSFORM_TREE(x, y) do { \
422 ret = hls_transform_tree(lc, x, y, trafo_width, trafo_height, ch_type); \
441 #define TRANSFORM_UNIT(x, width, idx) do { \
442 ret = hls_transform_unit(lc, x, y0, width, tu_height, idx, ch_type); \
451 #undef TRANSFORM_UNIT
453 #define TRANSFORM_UNIT(y, height, idx) do { \
454 ret = hls_transform_unit(lc, x0, y, tu_width, height, idx, ch_type); \
463 #undef TRANSFORM_UNIT
490 if (tu_width >
sps->max_tb_size_y || tu_height >
sps->max_tb_size_y) {
491 const int ver_split_first = tu_width >
sps->max_tb_size_y && tu_width > tu_height;
492 const int trafo_width = ver_split_first ? (tu_width / 2) : tu_width;
493 const int trafo_height = !ver_split_first ? (tu_height / 2) : tu_height;
495 #define SKIPPED_TRANSFORM_TREE(x, y) do { \
496 int ret = skipped_transform_tree(lc, x, y, trafo_width, trafo_height); \
513 for (
int i = start;
i < end;
i++) {
527 int mtt_depth,
int depth_offset,
int part_idx,
VVCSplitMode last_split_mode,
530 int min_qt_size, max_bt_size, max_tt_size, max_mtt_depth;
536 int min_cb_size_y =
sps->min_cb_size_y;
537 int *qt = &
split->qt;
538 int *btv = &
split->btv;
539 int *bth = &
split->bth;
540 int *ttv = &
split->ttv;
541 int *tth = &
split->tth;
543 *qt = *bth = *btv = *tth = *ttv = 1;
549 if (cb_width <= min_qt_size)
553 int chroma_area = (cb_width >>
sps->hshift[1]) * (cb_height >>
sps->vshift[1]);
554 int chroma_width = cb_width >>
sps->hshift[1];
556 if (chroma_width == 8)
558 else if (chroma_width <= 4) {
559 if (chroma_width == 4)
564 *qt = *btv = *bth = *ttv = *tth = 0;
565 if (chroma_area <= 32) {
567 if (chroma_area <= 16)
576 int area = cb_width * cb_height;
582 if (cb_width <= 2 * min_cb_size_y) {
584 if (cb_width <= min_cb_size_y)
587 if (cb_height <= 2 * min_cb_size_y) {
589 if (cb_height <= min_cb_size_y)
592 if (cb_width > max_bt_size || cb_height > max_bt_size)
594 max_tt_size =
FFMIN(64, max_tt_size);
595 if (cb_width > max_tt_size || cb_height > max_tt_size)
597 if (mtt_depth >= max_mtt_depth)
598 *btv = *bth = *ttv = *tth = 0;
599 if (x0 + cb_width >
pps->width) {
603 if (y0 + cb_height <= pps->
height)
605 else if (cb_width > min_qt_size)
608 if (y0 + cb_height >
pps->height) {
609 *btv = *ttv = *tth = 0;
613 if (mtt_depth > 0 && part_idx == 1) {
619 if (cb_width <= 64 && cb_height > 64)
621 if (cb_width > 64 && cb_height <= 64)
629 if ((cb_width == 4 && cb_height == 8) || (cb_width == 8 && cb_height == 4))
640 if (!
sps->r->sps_cclm_enabled_flag)
642 if (!
sps->r->sps_qtbtt_dual_tree_intra_flag || !
IS_I(lc->
sc->
sh.
r) ||
sps->ctb_log2_size_y < 6)
645 const int x64 = x0 >> 6 << 6;
646 const int y64 = y0 >> 6 << 6;
647 const int y32 = y0 >> 5 << 5;
648 const int x64_cu = x64 >>
fc->ps.sps->min_cb_log2_size_y;
649 const int y64_cu = y64 >>
fc->ps.sps->min_cb_log2_size_y;
650 const int y32_cu = y32 >>
fc->ps.sps->min_cb_log2_size_y;
651 const int min_cb_width =
fc->ps.pps->min_cb_width;
652 const int depth =
SAMPLE_CTB(
fc->tab.cqt_depth[1], x64_cu, y64_cu);
653 const int min_depth =
fc->ps.sps->ctb_log2_size_y - 6;
657 enabled =
SAMPLE_CTB(
fc->tab.cb_width[1], x64_cu, y64_cu) == 64 &&
659 enabled |= depth == min_depth && msm64 ==
SPLIT_BT_HOR &&
660 SAMPLE_CTB(
fc->tab.cb_width[1], x64_cu, y32_cu) == 64 &&
662 enabled |= depth > min_depth;
666 const int w =
SAMPLE_CTB(
fc->tab.cb_width[0], x64_cu, y64_cu);
667 const int h =
SAMPLE_CTB(
fc->tab.cb_height[0], x64_cu, y64_cu);
668 const int depth0 =
SAMPLE_CTB(
fc->tab.cqt_depth[0], x64_cu, y64_cu);
670 ((
w < 64 ||
h < 64) && depth0 == min_depth))
679static int less(
const void *
a,
const void *
b)
681 return *(
const int*)
a - *(
const int*)
b;
689 const int x0 = cu->
x0;
690 const int y0 = cu->
y0;
692 int intra_luma_not_planar_flag = 1;
693 int intra_luma_mpm_remainder = 0;
694 int intra_luma_mpm_flag = 1;
695 int intra_luma_mpm_idx = 0;
699 if (intra_luma_mpm_flag) {
702 if (intra_luma_not_planar_flag)
708 if (!intra_luma_not_planar_flag) {
712 const int x_a = (x0 - 1) >>
sps->min_cb_log2_size_y;
713 const int y_a = (y0 + cu->
cb_height - 1) >>
sps->min_cb_log2_size_y;
714 const int x_b = (x0 + cu->
cb_width - 1) >>
sps->min_cb_log2_size_y;
715 const int y_b = (y0 - 1) >>
sps->min_cb_log2_size_y;
716 int min_cb_width =
fc->ps.pps->min_cb_width;
740 cand[1] = 2 + ((
a + 61) % 64);
741 cand[2] = 2 + ((
a - 1) % 64);
742 cand[3] = 2 + ((
a + 60) % 64);
743 cand[4] = 2 + (
a % 64);
748 const int diff = maxab - minab;
752 cand[2] = 2 + ((minab + 61) % 64);
753 cand[3] = 2 + ((maxab - 1) % 64);
754 cand[4] = 2 + ((minab + 60) % 64);
755 }
else if (
diff >= 62) {
756 cand[2] = 2 + ((minab - 1) % 64);
757 cand[3] = 2 + ((maxab + 61) % 64);
758 cand[4] = 2 + (minab % 64);
759 }
else if (
diff == 2) {
760 cand[2] = 2 + ((minab - 1) % 64);
761 cand[3] = 2 + ((minab + 61) % 64);
762 cand[4] = 2 + ((maxab - 1) % 64);
764 cand[2] = 2 + ((minab + 61) % 64);
765 cand[3] = 2 + ((minab - 1) % 64);
766 cand[4] = 2 + ((maxab + 61) % 64);
770 cand[1] = 2 + ((maxab + 61 ) % 64);
771 cand[2] = 2 + ((maxab - 1) % 64);
772 cand[3] = 2 + ((maxab + 60 ) % 64);
773 cand[4] = 2 + (maxab % 64);
782 if (intra_luma_mpm_flag) {
783 pred = cand[intra_luma_mpm_idx];
786 pred = intra_luma_mpm_remainder + 1;
804 int lfnst_width, lfnst_height, min_lfnst;
813 for (
int j = 0; j < tu->
nb_tbs; j++) {
822 lfnst_width = cb_width >>
sps->hshift[1];
823 lfnst_height = cb_height >>
sps->vshift[1];
830 min_lfnst =
FFMIN(lfnst_width, lfnst_height);
834 if (min_lfnst >= 4) {
853 const uint8_t transform_skip_flag = cu->
tus.
head->
tbs[0].
ts;
856 !transform_skip_flag &&
FFMAX(cb_width, cb_height) <= 32 &&
870 const int x_center = (cu->
x0 + cu->
cb_width / 2) >>
sps->min_cb_log2_size_y;
871 const int y_center = (cu->
y0 + cu->
cb_height / 2) >>
sps->min_cb_log2_size_y;
872 const int min_cb_width =
pps->min_cb_width;
873 const int intra_mip_flag =
SAMPLE_CTB(
fc->tab.imf, x_center, y_center);
874 const int cu_pred_mode =
SAMPLE_CTB(
fc->tab.cpm[0], x_center, y_center);
875 const int intra_pred_mode_y =
SAMPLE_CTB(
fc->tab.ipm, x_center, y_center);
877 if (intra_mip_flag) {
884 return intra_pred_mode_y;
888 const int cclm_mode_flag,
const int cclm_mode_idx,
const int intra_chroma_pred_mode)
894 const int x_cb = cu->
x0 >>
sps->min_cb_log2_size_y;
895 const int y_cb = cu->
y0 >>
sps->min_cb_log2_size_y;
896 const int min_cb_width =
pps->min_cb_width;
897 const int intra_mip_flag =
SAMPLE_CTB(
fc->tab.imf, x_cb, y_cb);
912 if (cclm_mode_flag) {
914 }
else if (intra_chroma_pred_mode == 4){
942 0, 1, 61, 62, 63, 64, 65, 66, 2, 3, 5, 6, 8, 10, 12, 13,
943 14, 16, 18, 20, 22, 23, 24, 26, 28, 30, 31, 33, 34, 35, 36, 37,
944 38, 39, 40, 41, 41, 42, 43, 43, 44, 44, 45, 45, 46, 47, 48, 48,
945 49, 49, 50, 51, 51, 52, 52, 53, 54, 55, 55, 56, 56, 57, 57, 58,
953 int intra_mip_transposed_flag,
int intra_mip_mode)
955 return (intra_mip_mode << 2) | (intra_mip_transposed_flag << 1) | intra_mip_flag;
964 const int log2_min_cb_size =
sps->min_cb_log2_size_y;
965 const int x0 = cu->
x0;
966 const int y0 = cu->
y0;
967 const int x_cb = x0 >> log2_min_cb_size;
968 const int y_cb = y0 >> log2_min_cb_size;
973 if (
sps->r->sps_bdpcm_enabled_flag && cb_width <= sps->max_ts_size && cb_height <= sps->max_ts_size)
978 if (
sps->r->sps_mip_enabled_flag)
983 int x = y_cb *
pps->min_cb_width + x_cb;
984 for (
int y = 0; y < (cb_height>>log2_min_cb_size); y++) {
985 int width = cb_width>>log2_min_cb_size;
987 intra_mip_transposed_flag, intra_mip_mode);
988 memset(&
fc->tab.imf[x], mip_info,
width);
989 x +=
pps->min_cb_width;
993 int intra_subpartitions_mode_flag = 0;
994 if (
sps->r->sps_mrl_enabled_flag && ((y0 %
sps->ctb_size_y) > 0))
997 (cb_width <= sps->max_tb_size_y && cb_height <= sps->max_tb_size_y) &&
1001 if (!(x0 & 63) && !(y0 & 63))
1002 TAB_ISPMF(
fc, x0, y0) = intra_subpartitions_mode_flag;
1017 int cclm_mode_flag = 0;
1018 int cclm_mode_idx = 0;
1019 int intra_chroma_pred_mode = 0;
1023 if (
sps->r->sps_bdpcm_enabled_flag &&
1061 int pred_mode_ibc_flag;
1065 if (!
IS_I(rsh) ||
sps->r->sps_ibc_enabled_flag) {
1068 (
sps->r->sps_ibc_enabled_flag && !is_128))) {
1088 pred_mode_ibc_flag = 1;
1090 pred_mode_ibc_flag = 0;
1092 pred_mode_ibc_flag = (
IS_I(rsh)) ?
sps->r->sps_ibc_enabled_flag : 0;
1094 if (pred_mode_ibc_flag)
1122 && cb_width <= sps->max_tb_size_y && cb_height <= sps->max_tb_size_y) {
1123 const int sbt_ver_h = cb_width >= 8;
1124 const int sbt_hor_h = cb_height >= 8;
1126 if (sbt_ver_h || sbt_hor_h)
1129 const int sbt_ver_q = cb_width >= 16;
1130 const int sbt_hor_q = cb_height >= 16;
1131 int cu_sbt_quad_flag = 0;
1133 if ((sbt_ver_h || sbt_hor_h) && (sbt_ver_q || sbt_hor_q))
1135 if (cu_sbt_quad_flag) {
1137 if (sbt_ver_q && sbt_hor_q)
1141 if (sbt_ver_h && sbt_hor_h)
1147 const int sbt_min = cu_sbt_quad_flag ? 1 : 2;
1177 const int log2_min_cb_size =
sps->min_cb_log2_size_y;
1178 const int x_cb = cu->
x0 >> log2_min_cb_size;
1179 const int y_cb = cu->
y0 >> log2_min_cb_size;
1180 const int ch_type = cu->
ch_type;
1183 x = y_cb *
pps->min_cb_width + x_cb;
1184 for (y = 0; y < (cu->
cb_height >> log2_min_cb_size); y++) {
1188 fc->tab.cb_pos_x[ch_type][x +
i] = cu->
x0;
1189 fc->tab.cb_pos_y[ch_type][x +
i] = cu->
y0;
1195 x +=
pps->min_cb_width;
1204 const int rx = x0 >>
sps->ctb_log2_size_y;
1205 const int ry = y0 >>
sps->ctb_log2_size_y;
1223 const int cb_width,
const int cb_height,
const int cqt_depth,
const VVCTreeType tree_type)
1232 memset(&cu->
pu, 0,
sizeof(cu->
pu));
1275 for (
int j = 0; j < tu->
nb_tbs; j++) {
1293 const int diff[] = {
1300 mmvd[1] = mmvd[0] = *mmvd_offset;
1305 mmvd[
i] = *mmvd_offset;
1310 mmvd[o].
x = sign ? -mmvd[
i].
x : mmvd[
i].
x;
1311 mmvd[o].
y = sign ? -mmvd[
i].
y : mmvd[
i].
y;
1314 mvf->
mv[0].
x += mmvd[0].
x;
1315 mvf->
mv[0].
y += mmvd[0].
y;
1316 mvf->
mv[1].
x += mmvd[1].
x;
1317 mvf->
mv[1].
y += mmvd[1].
y;
1320 mvf->
mv[idx].
x += mmvd_offset->
x;
1321 mvf->
mv[idx].
y += mmvd_offset->
y;
1331 for (
int i = 0;
i < 2;
i++) {
1334 mi->mv[
i][0] = mvf->
mv[
i];
1355 int merge_subblock_idx = 0;
1357 if (
ph->max_num_subblock_merge_cand > 1) {
1374 if (
sps->r->sps_mmvd_enabled_flag)
1377 int mmvd_cand_flag = 0;
1378 if (
sps->max_num_merge_cand > 1)
1381 merge_idx = mmvd_cand_flag;
1382 }
else if (
sps->max_num_merge_cand > 1) {
1399 if (ciip_avaiable && gpm_avaiable)
1401 return sps->r->sps_ciip_enabled_flag && !cu->
skip_flag &&
1410 int merge_gpm_idx[2];
1415 merge_gpm_idx[1] = 0;
1416 if (
sps->max_num_gpm_merge_cand > 2)
1432 if (
sps->max_num_merge_cand > 1)
1452 const int is_128 = cb_width == 128 || cb_height == 128;
1453 const int ciip_avaiable =
sps->r->sps_ciip_enabled_flag &&
1454 !cu->
skip_flag && (cb_width * cb_height >= 64);
1455 const int gpm_avaiable =
sps->r->sps_gpm_enabled_flag &&
IS_B(rsh) &&
1456 (cb_width >= 8) && (cb_height >=8) &&
1457 (cb_width < 8 * cb_height) && (cb_height < 8 *cb_width);
1459 int regular_merge_flag = 1;
1461 if (!is_128 && (ciip_avaiable || gpm_avaiable))
1463 if (regular_merge_flag) {
1484 if (
sps->max_num_ibc_merge_cand > 1)
1524 for (
int i = 0;
i < 2;
i++) {
1528 for (
int i = 0;
i < 2;
i++) {
1533 for (
int i = 0;
i < 2;
i++) {
1554 if (
sps->r->sps_bcw_enabled_flag &&
mi->pred_flag ==
PF_BI &&
1555 !
w->weight_flag[
L0][
LUMA][
mi->ref_idx[0]] &&
1556 !
w->weight_flag[
L1][
LUMA][
mi->ref_idx[1]] &&
1559 cb_width * cb_height >= 256) {
1572 else if (sym_mvd_flag)
1578 const int num_cp_mv,
const int lx)
1584 int has_no_zero_mvd = 0;
1586 if (lx ==
L1 &&
ph->r->ph_mvd_l1_zero_flag &&
mi->pred_flag ==
PF_BI) {
1587 for (
int j = 0; j < num_cp_mv; j++)
1590 Mv *mvd0 = &mvds[lx][0];
1592 mvd0->
x = -mvds[
L0][0].x;
1593 mvd0->
y = -mvds[
L0][0].y;
1597 has_no_zero_mvd |= (mvd0->
x || mvd0->
y);
1598 for (
int j = 1; j < num_cp_mv; j++) {
1599 Mv *mvd = &mvds[lx][j];
1603 has_no_zero_mvd |= (mvd->
x || mvd->
y);
1606 return has_no_zero_mvd;
1612 for (
int i = 0;
i < 2;
i++) {
1614 if (
mi->pred_flag &
mask) {
1615 for (
int j = 0; j < num_cp_mv; j++) {
1616 const Mv *mvd = &mvds[
i][j];
1617 mi->mv[
i][j].x += mvd->
x * (1 << amvr_shift);
1618 mi->mv[
i][j].y += mvd->
y * (1 << amvr_shift);
1631 int mvp_l0_flag = 0;
1641 if (
sps->max_num_ibc_merge_cand > 1)
1643 if (
sps->r->sps_amvr_enabled_flag && (
mv->x ||
mv->y))
1667 int mvp_lx_flag[2] = {0};
1668 int cu_affine_type_flag = 0;
1670 int amvr_enabled, has_no_zero_mvd = 0, amvr_shift;
1674 if (
sps->r->sps_affine_enabled_flag && cb_width >= 16 && cb_height >= 16) {
1681 num_cp_mv =
mi->motion_model_idc + 1;
1683 if (
sps->r->sps_smvd_enabled_flag && !
ph->r->ph_mvd_l1_zero_flag &&
1688 for (
int i =
L0;
i <=
L1;
i++) {
1690 if (
mi->pred_flag != pred_flag) {
1692 has_no_zero_mvd |=
mvds_decode(lc, mvds, num_cp_mv,
i);
1698 sps->r->sps_amvr_enabled_flag :
sps->r->sps_affine_amvr_enabled_flag;
1699 amvr_enabled &= has_no_zero_mvd;
1703 mi->hpel_if_idx = amvr_shift == 3;
1706 if (
mi->motion_model_idc)
1713 if (
mi->motion_model_idc)
1729 const int poc =
ph->poc;
1731 const int8_t *ref_idx =
mi->ref_idx;
1740 (poc - rp0->
poc == rp1->
poc - poc) &&
1749 if (!
ph->r->ph_bdof_disabled_flag &&
1754 if (!
ph->r->ph_dmvr_disabled_flag &&
1788 MvField *dmvr_mvf =
fc->ref->tab_dmvr_mvf + idx;
1790 memcpy(dmvr_mvf, mvf,
sizeof(
MvField) *
w);
1838 for (
int c = start;
c < end;
c++) {
1853 bool *predictor_reused,
const int predictor_size,
const int max_entries)
1856 int nb_predicted = 0;
1858 if (local_dual_tree) {
1863 for (
int i = 0;
i < predictor_size && nb_predicted < max_entries;
i++) {
1874 predictor_reused[
i] =
true;
1875 for (
int c = start;
c < end;
c++)
1880 for (
int c = start;
c < end;
c++)
1887 const int start,
const int end,
const int max_entries)
1891 const int nb_predicted = cu->
plt[start].
size;
1893 const int size = nb_predicted + nb_signaled;
1896 if (nb_signaled < 0)
1899 for (
int c = start;
c < end;
c++) {
1901 for (
int i = nb_predicted;
i <
size;
i++) {
1903 if (dual_tree_luma) {
1915 bool *predictor_reused,
const int predictor_size)
1920 if (local_dual_tree) {
1925 for (
int c = start;
c < end;
c++) {
1931 for (
int j = 0; j < predictor_size &&
i < max_predictor; j++) {
1932 if (!predictor_reused[j]) {
1952 const bool has_qp_delta = escape_present &&
1968#define PALETTE_SET_PIXEL(xc, yc, pix) \
1970 const int off = ((xc) >> hs) + ((yc) >> vs) * tb->tb_width; \
1971 if (sps->bit_depth == 8) \
1977#define PALETTE_INDEX(x, y) index[(y) * width + (x)]
1982#define TRAV_COL(p, wlog, mask) ((p & mask) ^ (-((p >> wlog) & 1) & mask))
1983#define TRAV_ROW(p, hlog) (p >> hlog)
1984#define TRAV(trans, p, wlog, hlog, mask) (trans ? TRAV_ROW((p), hlog) : TRAV_COL((p), wlog, mask))
1985#define TRAV_X(pos) TRAV(transpose, pos, wlog2, hlog2, wmask)
1986#define TRAV_Y(pos) TRAV(!transpose, pos, hlog2, wlog2, hmask)
1989 const int max_index,
const int subset_id,
const bool transpose,
1990 uint8_t *run_type, uint8_t *
index,
int *prev_run_pos,
bool *
adjust)
1997 const int min_pos = subset_id << 4;
1999 const int wmask =
width - 1;
2000 const int hmask =
height - 1;
2003 const int start_idx = tu->
tbs[0].
c_idx;
2011 if (
i > 0 && max_index > 0)
2015 if (max_index > 0 && !
run_copy[
i - min_pos]) {
2017 &&
i > 0 && !run_type[
i - 1]) {
2022 run_type[
i] = run_type[
i - 1];
2029 const int prev_xc =
i > 0 ?
TRAV_X(
i - 1) : 0;
2030 const int prev_yc =
i > 0 ?
TRAV_Y(
i - 1) : 0;
2033 if (max_index > 0 && !
run_copy[
i - min_pos] && !run_type[
i]) {
2034 if (max_index - *
adjust > 0)
2037 const int ref_idx = !run_type[
i - 1] ?
2039 idx += (idx >= ref_idx);
2054 const int c_idx = tb->
c_idx;
2057 const int hs =
sps->hshift[c_idx] -
sps->hshift[start_idx];
2058 const int vs =
sps->vshift[c_idx] -
sps->vshift[start_idx];
2059 uint8_t *u8 = (uint8_t *)tb->
coeffs;
2060 uint16_t *u16 = (uint16_t *)tb->
coeffs;
2065 if (!(xc & hs) && !(yc & vs)) {
2090 const int max_entries = tree_type ==
SINGLE_TREE ? 31 : 15;
2091 const bool local_dual_tree = tree_type !=
SINGLE_TREE &&
2092 (!
IS_I(rsh) || (
IS_I(rsh) && !
sps->r->sps_qtbtt_dual_tree_intra_flag));
2093 bool escape_present =
false;
2097 int prev_run_pos = 0;
2099 int predictor_size, start, end, ret;
2112 predictor_size = pp[start].
size;
2113 memset(reused, 0,
sizeof(reused[0]) * predictor_size);
2115 ret =
palette_predicted(lc, local_dual_tree, start, end, reused, predictor_size, max_entries);
2128 max_index = cu->
plt[start].
size - 1 + escape_present;
2129 if (max_index > 0) {
2134 ret =
palette_qp(lc, tree_type, escape_present);
2158 if (pred_mode_plt_flag) {
2171 }
else if (!pred_mode_plt_flag) {
2185 const int is_128 = cb_width > 64 || cb_height > 64;
2188 CodingUnit *cu =
add_cu(lc, x0, y0, cb_width, cb_height, cqt_depth, tree_type);
2195 if (
IS_I(rsh) && is_128)
2244 const int area = cb_width * cb_height;
2246 if ((
IS_I(rsh) &&
sps->r->sps_qtbtt_dual_tree_intra_flag) ||
2256 return 1 + !
IS_I(rsh);
2262 const int cb_width,
const int cb_height,
const VVCSplitMode split,
const int ch_type,
2268 if (mode_type_condition == 1)
2270 else if (mode_type_condition == 2) {
2273 mode_type = mode_type_curr;
2280 int x0,
int y0,
int cb_width,
int cb_height,
int qg_on_y,
int qg_on_c,
2281 int cb_sub_div,
int cqt_depth,
int mtt_depth,
int depth_offset,
int part_idx,
2285 int x0,
int y0,
int cb_width,
int cb_height,
int qg_on_y,
int qg_on_c,
2286 int cb_sub_div,
int cqt_depth,
int mtt_depth,
int depth_offset,
2289#define CODING_TREE(x, idx) do { \
2290 ret = hls_coding_tree(lc, x, y0, cb_width / 2, cb_height, \
2291 qg_on_y, qg_on_c, cb_sub_div + 1, cqt_depth, mtt_depth + 1, \
2292 depth_offset, idx, SPLIT_BT_VER, tree_type, mode_type); \
2298 const int x1 = x0 + cb_width / 2;
2301 depth_offset += (x0 + cb_width >
pps->width) ? 1 : 0;
2303 if (x1 < pps->
width)
2312 int x0,
int y0,
int cb_width,
int cb_height,
int qg_on_y,
int qg_on_c,
2313 int cb_sub_div,
int cqt_depth,
int mtt_depth,
int depth_offset,
2316#define CODING_TREE(y, idx) do { \
2317 ret = hls_coding_tree(lc, x0, y, cb_width , cb_height / 2, \
2318 qg_on_y, qg_on_c, cb_sub_div + 1, cqt_depth, mtt_depth + 1, \
2319 depth_offset, idx, SPLIT_BT_HOR, tree_type, mode_type); \
2325 const int y1 = y0 + (cb_height / 2);
2328 depth_offset += (y0 + cb_height >
pps->height) ? 1 : 0;
2339 int x0,
int y0,
int cb_width,
int cb_height,
int qg_on_y,
int qg_on_c,
2340 int cb_sub_div,
int cqt_depth,
int mtt_depth,
int depth_offset,
2343#define CODING_TREE(x, w, sub_div, idx) do { \
2344 ret = hls_coding_tree(lc, x, y0, w, cb_height, \
2345 qg_on_y, qg_on_c, sub_div, cqt_depth, mtt_depth + 1, \
2346 depth_offset, idx, SPLIT_TT_VER, tree_type, mode_type); \
2352 const int x1 = x0 + cb_width / 4;
2353 const int x2 = x0 + cb_width * 3 / 4;
2369 int x0,
int y0,
int cb_width,
int cb_height,
int qg_on_y,
int qg_on_c,
2370 int cb_sub_div,
int cqt_depth,
int mtt_depth,
int depth_offset,
2373#define CODING_TREE(y, h, sub_div, idx) do { \
2374 ret = hls_coding_tree(lc, x0, y, cb_width, h, \
2375 qg_on_y, qg_on_c, sub_div, cqt_depth, mtt_depth + 1, \
2376 depth_offset, idx, SPLIT_TT_HOR, tree_type, mode_type); \
2382 const int y1 = y0 + (cb_height / 4);
2383 const int y2 = y0 + (3 * cb_height / 4);
2389 CODING_TREE(y0, cb_height / 4, cb_sub_div + 2, 0);
2390 CODING_TREE(y1, cb_height / 2, cb_sub_div + 1, 1);
2391 CODING_TREE(y2, cb_height / 4, cb_sub_div + 2, 2);
2399 int x0,
int y0,
int cb_width,
int cb_height,
int qg_on_y,
int qg_on_c,
2400 int cb_sub_div,
int cqt_depth,
int mtt_depth,
int depth_offset,
2403#define CODING_TREE(x, y, idx) do { \
2404 ret = hls_coding_tree(lc, x, y, cb_width / 2, cb_height / 2, \
2405 qg_on_y, qg_on_c, cb_sub_div + 2, cqt_depth + 1, 0, 0, \
2406 idx, SPLIT_QT, tree_type, mode_type); \
2412 const int x1 = x0 + cb_width / 2;
2413 const int y1 = y0 + cb_height / 2;
2417 if (x1 < pps->
width)
2421 if (x1 < pps->
width &&
2431 int x0,
int y0,
int cb_width,
int cb_height,
int qg_on_y,
int qg_on_c,
2432 int cb_sub_div,
int cqt_depth,
int mtt_depth,
int depth_offset,
2444 int x0,
int y0,
int cb_width,
int cb_height,
int qg_on_y,
int qg_on_c,
2445 int cb_sub_div,
int cqt_depth,
int mtt_depth,
int depth_offset,
int part_idx,
2456 if (
pps->r->pps_cu_qp_delta_enabled_flag && qg_on_y && cb_sub_div <= sh->cu_qp_delta_subdiv) {
2462 cb_sub_div <= sh->cu_chroma_qp_offset_subdiv) {
2467 can_split(lc, x0, y0, cb_width, cb_height, mtt_depth, depth_offset, part_idx,
2468 last_split_mode, tree_type_curr, mode_type_curr, &allowed);
2476 if (!(x0 & 31) && !(y0 & 31) && mtt_depth <= 1)
2479 ret =
coding_tree[
split - 1](lc, x0, y0, cb_width, cb_height, qg_on_y, qg_on_c,
2480 cb_sub_div, cqt_depth, mtt_depth, depth_offset, tree_type, mode_type);
2484 ret =
hls_coding_tree(lc, x0, y0, cb_width, cb_height, 0, qg_on_c, cb_sub_div,
2490 ret =
hls_coding_unit(lc, x0, y0, cb_width, cb_height, cqt_depth, tree_type_curr, mode_type_curr);
2499 const int x0,
const int y0,
const int cb_size,
const int cqt_depth)
2504 const int cb_subdiv = 2 * cqt_depth;
2508 #define DUAL_TREE(x, y) do { \
2509 ret = dual_tree_implicit_qt_split(lc, x, y, cb_size / 2, cqt_depth + 1); \
2514 const int x1 = x0 + (cb_size / 2);
2515 const int y1 = y0 + (cb_size / 2);
2516 if (
pps->r->pps_cu_qp_delta_enabled_flag && cb_subdiv <= sh->cu_qp_delta_subdiv) {
2526 if (x1 < pps->
width)
2534 #define CODING_TREE(tree_type) do { \
2535 const int qg_on_y = tree_type == DUAL_TREE_LUMA; \
2536 ret = hls_coding_tree(lc, x0, y0, cb_size, cb_size, qg_on_y, !qg_on_y, \
2537 cb_subdiv, cqt_depth, 0, 0, 0, SPLIT_NONE, tree_type, MODE_TYPE_ALL); \
2548#define SET_SAO(elem, value) \
2550 if (!sao_merge_up_flag && !sao_merge_left_flag) \
2551 sao->elem = value; \
2552 else if (sao_merge_left_flag) \
2553 sao->elem = CTB(fc->tab.sao, rx-1, ry).elem; \
2554 else if (sao_merge_up_flag) \
2555 sao->elem = CTB(fc->tab.sao, rx, ry-1).elem; \
2564 int sao_merge_left_flag = 0;
2565 int sao_merge_up_flag = 0;
2574 if (ry > 0 && !sao_merge_left_flag) {
2580 for (c_idx = 0; c_idx < (
fc->ps.sps->r->sps_chroma_format_idc ? 3 : 1); c_idx++) {
2582 if (!sao_used_flag) {
2597 for (
i = 0;
i < 4;
i++)
2601 for (
i = 0;
i < 4;
i++) {
2610 }
else if (c_idx != 2) {
2616 for (
i = 0;
i < 4;
i++) {
2624 sao->
offset_val[c_idx][
i + 1] *= 1 << (
fc->ps.sps->bit_depth -
FFMIN(10,
fc->ps.sps->bit_depth));
2640 uint8_t alf_use_aps_flag = 0;
2643 if (alf_use_aps_flag) {
2651 for (
int c_idx =
CB; c_idx <=
CR; c_idx++) {
2652 const uint8_t alf_enabled_flag =
2654 if (alf_enabled_flag) {
2658 if (alf->
ctb_flag[c_idx] &&
aps->num_chroma_filters > 1)
2663 if (
fc->ps.sps->r->sps_ccalf_enabled_flag) {
2666 for (
int i = 0;
i < 2;
i++) {
2667 if (cc_enabled[
i]) {
2683 const int x0,
const int y0,
const int ctu_idx,
const int rx,
const int ry)
2690 const unsigned int ctb_size =
sps->ctb_size_y;
2695 hls_sao(lc, x0 >>
sps->ctb_log2_size_y, y0 >>
sps->ctb_log2_size_y);
2699 if (
IS_I(rsh) &&
sps->r->sps_qtbtt_dual_tree_intra_flag)
2707 if (rx ==
pps->ctb_to_col_bd[rx + 1] - 1) {
2710 if (!end_of_slice_one_bit)
2713 if (ry ==
pps->ctb_to_row_bd[ry + 1] - 1) {
2715 if (!end_of_tile_one_bit)
2718 if (
fc->ps.sps->r->sps_entropy_coding_sync_enabled_flag) {
2720 if (!end_of_subset_one_bit)
2739 const int top =
pps->subpic_y[idx];
2740 const int bottom = top +
pps->subpic_height[idx];
2754 const int idx = mvf->
ref_idx[lx];
2757 max_y[lx][idx] =
FFMAX(max_y[lx][idx], y);
2764 for (
int sby = 0; sby <
mi->num_sb_y; sby++) {
2765 for (
int sbx = 0; sbx <
mi->num_sb_x; sbx++) {
2766 const int x0 = cu->
x0 + sbx * sbw;
2767 const int y0 = cu->
y0 + sby * sbh;
2769 for (
int lx = 0; lx < 2; lx++) {
2772 const int idx = mvf->
ref_idx[lx];
2775 max_y[lx][idx] =
FFMAX(max_y[lx][idx], y + max_dmvr_off);
2787 CTU *ctu =
fc->tab.ctus + rs;
2795 for (
int lx = 0; lx < 2; lx++)
2809 const int ctu_idx,
const int rs,
const int rx,
const int ry)
2814 const int x_ctb = rx <<
sps->ctb_log2_size_y;
2815 const int y_ctb = ry <<
sps->ctb_log2_size_y;
2816 const int ctb_size = 1 <<
sps->ctb_log2_size_y <<
sps->ctb_log2_size_y;
2820 if (rx ==
pps->ctb_to_col_bd[rx]) {
2840 const int rx,
const int ry,
const int rs)
2843 const int ctb_size =
fc->ps.sps->ctb_size_y;
2847 if (
fc->ps.pps->ctb_to_col_bd[rx] !=
fc->ps.pps->ctb_to_col_bd[rx + 1])
2849 if (
fc->ps.pps->ctb_to_row_bd[ry] !=
fc->ps.pps->ctb_to_row_bd[ry + 1])
2853 if (rx > 0 &&
fc->ps.pps->ctb_to_col_bd[rx] !=
fc->ps.pps->ctb_to_col_bd[rx - 1])
2855 if (rx > 0 &&
fc->tab.slice_idx[rs] !=
fc->tab.slice_idx[rs - 1])
2857 if (ry > 0 &&
fc->ps.pps->ctb_to_row_bd[ry] !=
fc->ps.pps->ctb_to_row_bd[ry - 1])
2859 if (ry > 0 &&
fc->tab.slice_idx[rs] !=
fc->tab.slice_idx[rs -
fc->ps.pps->ctb_width])
2868 (
fc->ps.pps->ctb_to_row_bd[ry] ==
fc->ps.pps->ctb_to_row_bd[ry - 1]);
2873 const int x0,
const int y0,
const int w,
const int h)
2908 const int min_cb_log2_size_y =
fc->ps.sps->min_cb_log2_size_y;
2909 const int x = xc >> min_cb_log2_size_y;
2910 const int y = yc >> min_cb_log2_size_y;
2911 return fc->tab.qp[
LUMA][x + y *
fc->ps.pps->min_cb_width];
2915 const int bit_depth,
const int persistent_rice_adaptation_enabled_flag)
2919 persistent_rice_adaptation_enabled_flag ? 2 * (
av_log2(
bit_depth - 10)) : 0;
2925 const bool has_chroma = chroma_format_idc && tree_type !=
DUAL_TREE_LUMA;
2928 *start = has_luma ?
LUMA :
CB;
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
static char * split(char *message, char delim)
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define i(width, name, range_min, range_max)
static int FUNC sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
static int FUNC ph(CodedBitstreamContext *ctx, RWContext *rw, H266RawPH *current)
static int FUNC aps(CodedBitstreamContext *ctx, RWContext *rw, H266RawAPS *current, int prefix)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static int inter_data(VVCLocalContext *lc)
static void alf_params(VVCLocalContext *lc, const int rx, const int ry)
static void set_qp_c(VVCLocalContext *lc)
static void palette_update_predictor(VVCLocalContext *lc, const bool local_dual_tree, int start, int end, bool *predictor_reused, const int predictor_size)
static void mvp_add_difference(MotionInfo *mi, const int num_cp_mv, const Mv mvds[2][MAX_CONTROL_POINTS], const int amvr_shift)
static int mvp_data(VVCLocalContext *lc)
static int skipped_transform_tree(VVCLocalContext *lc, int x0, int y0, int tu_width, int tu_height)
static const coding_tree_fn coding_tree[]
static void merge_data_block(VVCLocalContext *lc)
void ff_vvc_channel_range(int *start, int *end, const VVCTreeType tree_type, const uint8_t chroma_format_idc)
static void set_cu_tabs(const VVCLocalContext *lc, const CodingUnit *cu)
static int pred_get_y(const VVCLocalContext *lc, const int y0, const Mv *mv, const int height)
static int has_inter_luma(const CodingUnit *cu)
static void merge_data_ciip(VVCLocalContext *lc)
#define TAB_ISPMF(fc, x, y)
static uint8_t tu_y_coded_flag_decode(VVCLocalContext *lc, const int is_sbt_not_coded, const int sub_tu_index, const int is_isp, const int is_chroma_coded)
static void sbt_info(VVCLocalContext *lc, const VVCSPS *sps)
static CodingUnit * add_cu(VVCLocalContext *lc, const int x0, const int y0, const int cb_width, const int cb_height, const int cqt_depth, const VVCTreeType tree_type)
static int coding_tree_btv(VVCLocalContext *lc, int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, VVCTreeType tree_type, VVCModeType mode_type)
static int get_cclm_enabled(const VVCLocalContext *lc, const int x0, const int y0)
static int get_num_intra_subpartitions(enum IspType isp_split_type, int cb_width, int cb_height)
static int hls_coding_tree_unit(VVCLocalContext *lc, const int x0, const int y0, const int ctu_idx, const int rx, const int ry)
static void ctu_get_pred(VVCLocalContext *lc, const int rs)
static void hls_mvd_coding(VVCLocalContext *lc, Mv *mvd)
static void chroma_qp_offset_decode(VVCLocalContext *lc, const int is_128, const int is_chroma_coded)
static TransformUnit * add_tu(VVCFrameContext *fc, CodingUnit *cu, const int x0, const int y0, const int tu_width, const int tu_height)
static int hls_merge_data(VVCLocalContext *lc)
static void set_cb_pos(const VVCFrameContext *fc, const CodingUnit *cu)
static int dual_tree_implicit_qt_split(VVCLocalContext *lc, const int x0, const int y0, const int cb_size, const int cqt_depth)
static void derive_dmvr_bdof_flag(const VVCLocalContext *lc, PredictionUnit *pu)
static TransformBlock * add_tb(TransformUnit *tu, VVCLocalContext *lc, const int x0, const int y0, const int tb_width, const int tb_height, const int c_idx)
static VVCModeType mode_type_decode(VVCLocalContext *lc, const int x0, const int y0, const int cb_width, const int cb_height, const VVCSplitMode split, const int ch_type, const VVCModeType mode_type_curr)
static int palette_subblock_data(VVCLocalContext *lc, const int max_index, const int subset_id, const bool transpose, uint8_t *run_type, uint8_t *index, int *prev_run_pos, bool *adjust)
#define PALETTE_SET_PIXEL(xc, yc, pix)
static void cu_get_max_y(const CodingUnit *cu, int max_y[2][VVC_MAX_REF_ENTRIES], const VVCLocalContext *lc)
static int palette_qp(VVCLocalContext *lc, VVCTreeType tree_type, const bool escape_present)
static int bcw_idx_decode(VVCLocalContext *lc, const MotionInfo *mi, const int cb_width, const int cb_height)
static int hls_transform_tree(VVCLocalContext *lc, int x0, int y0, int tu_width, int tu_height, int ch_type)
void ff_vvc_set_neighbour_available(VVCLocalContext *lc, const int x0, const int y0, const int w, const int h)
#define TAB_MSM(fc, depth, x, y)
static TransformUnit * palette_add_tu(VVCLocalContext *lc, const int start, const int end, const VVCTreeType tree_type)
static void merge_data_regular(VVCLocalContext *lc)
static void derive_mmvd(const VVCLocalContext *lc, MvField *mvf, const Mv *mmvd_offset)
static void derive_chroma_intra_pred_mode(VVCLocalContext *lc, const int cclm_mode_flag, const int cclm_mode_idx, const int intra_chroma_pred_mode)
static int coding_tree_qt(VVCLocalContext *lc, int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, VVCTreeType tree_type, VVCModeType mode_type)
static PredMode pred_mode_decode(VVCLocalContext *lc, const VVCTreeType tree_type, const VVCModeType mode_type)
static int merge_data_ibc(VVCLocalContext *lc)
static int intra_data(VVCLocalContext *lc)
static void set_tb_size(const VVCFrameContext *fc, const TransformBlock *tb)
static void merge_data_subblock(VVCLocalContext *lc)
#define SET_SAO(elem, value)
static int palette_signaled(VVCLocalContext *lc, const bool local_dual_tree, const int start, const int end, const int max_entries)
void ff_vvc_ctu_free_cus(CodingUnit **cus)
int ff_vvc_coding_tree_unit(VVCLocalContext *lc, const int ctu_idx, const int rs, const int rx, const int ry)
parse a CTU
#define TRANSFORM_TREE(x, y)
static void set_tb_tab(uint8_t *tab, uint8_t v, const VVCFrameContext *fc, const TransformBlock *tb)
#define TRANSFORM_UNIT(x, width, idx)
void ff_vvc_decode_neighbour(VVCLocalContext *lc, const int x_ctb, const int y_ctb, const int rx, const int ry, const int rs)
int(* coding_tree_fn)(VVCLocalContext *lc, int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, VVCTreeType tree_type, VVCModeType mode_type)
int ff_vvc_get_qPy(const VVCFrameContext *fc, const int xc, const int yc)
static void deblock_params(VVCLocalContext *lc, const int rx, const int ry)
static void intra_chroma_pred_modes(VVCLocalContext *lc)
static void mv_merge_refine_pred_flag(MvField *mvf, const int width, const int height)
#define PALETTE_INDEX(x, y)
static int palette_predicted(VVCLocalContext *lc, const bool local_dual_tree, int start, int end, bool *predictor_reused, const int predictor_size, const int max_entries)
static int8_t ref_idx_decode(VVCLocalContext *lc, const VVCSH *sh, const int sym_mvd_flag, const int lx)
static int mvp_data_ibc(VVCLocalContext *lc)
static int coding_tree_tth(VVCLocalContext *lc, int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, VVCTreeType tree_type, VVCModeType mode_type)
static void set_qp_c_tab(const VVCLocalContext *lc, const TransformUnit *tu, const TransformBlock *tb)
static int hls_palette_coding(VVCLocalContext *lc, const VVCTreeType tree_type)
static int coding_tree_ttv(VVCLocalContext *lc, int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, VVCTreeType tree_type, VVCModeType mode_type)
static enum IntraPredMode derive_center_luma_intra_pred_mode(const VVCFrameContext *fc, const VVCSPS *sps, const VVCPPS *pps, const CodingUnit *cu)
static void intra_luma_pred_modes(VVCLocalContext *lc)
static void mvf_to_mi(const MvField *mvf, MotionInfo *mi)
static int less(const void *a, const void *b)
static int ciip_flag_decode(VVCLocalContext *lc, const int ciip_avaiable, const int gpm_avaiable, const int is_128)
static void hls_sao(VVCLocalContext *lc, const int rx, const int ry)
static void merge_data_gpm(VVCLocalContext *lc)
#define SKIPPED_TRANSFORM_TREE(x, y)
static void refine_regular_subblock(const VVCLocalContext *lc)
static void fill_dmvr_info(const VVCLocalContext *lc)
static int skipped_transform_tree_unit(VVCLocalContext *lc)
static int coding_tree_bth(VVCLocalContext *lc, int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, VVCTreeType tree_type, VVCModeType mode_type)
static void can_split(const VVCLocalContext *lc, int x0, int y0, int cb_width, int cb_height, int mtt_depth, int depth_offset, int part_idx, VVCSplitMode last_split_mode, VVCTreeType tree_type, VVCModeType mode_type, VVCAllowedSplit *split)
static void set_cb_tab(const VVCLocalContext *lc, uint8_t *tab, const uint8_t v)
static int mvds_decode(VVCLocalContext *lc, Mv mvds[2][MAX_CONTROL_POINTS], const int num_cp_mv, const int lx)
static TransformUnit * alloc_tu(VVCFrameContext *fc, CodingUnit *cu)
static int set_qp_y(VVCLocalContext *lc, const int x0, const int y0, const int has_qp_delta)
void ff_vvc_ep_init_stat_coeff(EntryPoint *ep, const int bit_depth, const int persistent_rice_adaptation_enabled_flag)
static int derive_mode_type_condition(const VVCLocalContext *lc, const VVCSplitMode split, const int cb_width, const int cb_height, const VVCModeType mode_type_curr)
static enum IntraPredMode luma_intra_pred_mode(VVCLocalContext *lc, const int intra_subpartitions_mode_flag)
static MtsIdx mts_idx_decode(VVCLocalContext *lc)
static int hls_transform_unit(VVCLocalContext *lc, int x0, int y0, int tu_width, int tu_height, int sub_tu_index, int ch_type)
static int get_qp_y_pred(const VVCLocalContext *lc)
static int hls_coding_tree(VVCLocalContext *lc, int x0, int y0, int cb_width, int cb_height, int qg_on_y, int qg_on_c, int cb_sub_div, int cqt_depth, int mtt_depth, int depth_offset, int part_idx, VVCSplitMode last_split_mode, VVCTreeType tree_type_curr, VVCModeType mode_type_curr)
static int lfnst_idx_decode(VVCLocalContext *lc)
static CodingUnit * alloc_cu(VVCLocalContext *lc, const int x0, const int y0)
static int hls_coding_unit(VVCLocalContext *lc, int x0, int y0, int cb_width, int cb_height, int cqt_depth, const VVCTreeType tree_type, VVCModeType mode_type)
#define CODING_TREE(x, idx)
static av_always_inline uint8_t pack_mip_info(int intra_mip_flag, int intra_mip_transposed_flag, int intra_mip_mode)
#define BOUNDARY_LEFT_SUBPIC
#define MAX_PALETTE_CU_SIZE
#define MAX_CONTROL_POINTS
#define BOUNDARY_UPPER_SUBPIC
static const uint16_t fc[]
#define MIN_TU_LOG2
MinTbLog2SizeY.
static const int32_t max_pos[4]
Size of the MP-MLQ fixed excitation codebooks.
static void run_copy(const SwsFrame *out, const SwsFrame *in, int y, int h, const SwsPass *pass)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define BOUNDARY_UPPER_SLICE
#define BOUNDARY_LEFT_TILE
#define SAMPLE_CTB(tab, x, y)
#define BOUNDARY_UPPER_TILE
#define BOUNDARY_LEFT_SLICE
int ff_vvc_palette_derive_scale(VVCLocalContext *lc, const TransformUnit *tu, TransformBlock *tb)
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static const int8_t mv[256][2]
static int luma_intra_pred_mode(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCSPS *sps, int x0, int y0, int pu_size, int prev_intra_luma_pred_flag)
8.4.1
@ VVC_MAX_NUM_PALETTE_PREDICTOR_SIZE
static const uint16_t mask[17]
static int adjust(int x, int size)
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
void * av_refstruct_pool_get(AVRefStructPool *pool)
Get an object from the pool, reusing an old one from the pool when available.
#define FF_ARRAY_ELEMS(a)
static const SiprModeParam modes[MODE_COUNT]
static const float pred[4]
uint8_t ctb_flag[3]
alf_ctb_flag[]
uint8_t alf_ctb_filter_alt_idx[2]
alf_ctb_filter_alt_idx[]
uint8_t ctb_filt_set_idx_y
AlfCtbFiltSetIdxY.
uint8_t ctb_cc_idc[2]
alf_ctb_cc_cb_idc, alf_ctb_cc_cr_idc
int max_y[2][VVC_MAX_REF_ENTRIES]
int apply_lfnst_flag[VVC_MAX_SAMPLE_ARRAYS]
ApplyLfnstFlag[].
TransformUnit * head
RefStruct reference.
enum PredMode pred_mode
PredMode.
Palette plt[VVC_MAX_SAMPLE_ARRAYS]
int mip_chroma_direct_flag
MipChromaDirectFlag.
int bdpcm_flag[VVC_MAX_SAMPLE_ARRAYS]
BdpcmFlag.
uint8_t sbt_horizontal_flag
enum IspType isp_split_type
IntraSubPartitionsSplitType.
struct CodingUnit * next
RefStruct reference.
uint8_t skip_flag
cu_skip_flag;
IntraPredMode intra_pred_mode_y
IntraPredModeY.
uint8_t intra_luma_ref_idx
IntraLumaRefLineIdx[][].
IntraPredMode intra_pred_mode_c
IntraPredModeC.
int num_intra_subpartitions
TransformUnit * tail
RefStruct reference.
struct CodingUnit::@377377256006074143206227277326325371142325360110 tus
uint8_t intra_mip_flag
intra_mip_flag
int8_t qp[4]
QpY, Qp′Cb, Qp′Cr, Qp′CbCr.
int num_hmvp_ibc
NumHmvpIbcCand.
int stat_coeff[VVC_MAX_SAMPLE_ARRAYS]
StatCoeff.
Palette pp[VVC_MAX_SAMPLE_ARRAYS]
uint8_t pps_cu_qp_delta_enabled_flag
uint8_t sps_chroma_format_idc
MotionModelIdc motion_model_idc
MotionModelIdc.
uint8_t hpel_if_idx
hpelIfIdx
int8_t ref_idx[2]
refIdxL0, refIdxL1
int16_t x
horizontal component of motion vector
int16_t y
vertical component of motion vector
uint16_t entries[VVC_MAX_NUM_PALETTE_PREDICTOR_SIZE]
uint8_t inter_affine_flag
uint8_t merge_subblock_flag
uint8_t general_merge_flag
uint8_t gpm_partition_idx
VVCRefPic refs[VVC_MAX_REF_ENTRIES]
int offset_sign[3][4]
sao_offset_sign
int16_t offset_val[3][5]
SaoOffsetVal.
int eo_class[3]
sao_eo_class
int offset_abs[3][4]
sao_offset_abs
uint8_t type_idx[3]
sao_type_idx
struct VVCFrameContext::@062157055061031125261364230274065254203010127363 tab
int8_t * qp[VVC_MAX_SAMPLE_ARRAYS]
const VVCSPS * sps
RefStruct reference.
const VVCPPS * pps
RefStruct reference.
int cu_qg_top_left_y
CuQgTopLeftY.
int cu_qg_top_left_x
CuQgTopLeftX.
uint8_t is_cu_qp_delta_coded
IsCuQpDeltaCoded.
int lfnst_zero_out_sig_coeff_flag
LfnstZeroOutSigCoeffFlag.
int mts_dc_only
MtsDcOnly.
struct VVCLocalContext::@205051250062066277310156102146242176100061313175 parse
int infer_tu_cbf_luma
InferTuCbfLuma.
int prev_tu_cbf_y
prevTuCbfY;
uint8_t ctb_up_right_flag
int sbt_num_fourths_tb0
SbtNumFourthsTb0.
int chroma_qp_offset[3]
CuQpOffsetCb, CuQpOffsetCr, CuQpOffsetCbCr.
int mts_zero_out_sig_coeff_flag
MtsZeroOutSigCoeffFlag;.
int is_cu_chroma_qp_offset_coded
IsCuChromaQpOffsetCoded.
int lfnst_dc_only
LfnstDcOnly.
int32_t poc
PicOrderCntVal.
const H266RawPPS * r
RefStruct reference.
int is_scaled
RprConstraintsActiveFlag.
uint8_t max_tt_size[2]
MaxTtSizeY, MaxTtSizeC.
uint8_t min_qt_size[2]
MinQtSizeY, MinQtSizeC.
uint8_t cu_qp_delta_subdiv
CuQpDeltaSubdiv.
const H266RawSliceHeader * r
RefStruct reference.
int8_t slice_qp_y
SliceQpY.
uint32_t num_ctus_in_curr_slice
NumCtusInCurrSlice.
uint8_t max_mtt_depth[2]
MaxMttDepthY, MaxMttDepthC.
int8_t ref_idx_sym[2]
RefIdxSymL0, RefIdxSymL1.
uint8_t max_bt_size[2]
MaxBtSizeY, MaxBtSizeC.
uint8_t cu_chroma_qp_offset_subdiv
CuChromaQpOffsetSubdiv.
uint8_t ctb_log2_size_y
CtbLog2SizeY.
const H266RawSPS * r
RefStruct reference.
static const struct twinvq_data tab
static const double coeff[2][5]
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
int ff_vvc_intra_bdpcm_chroma_dir_flag(VVCLocalContext *lc)
int ff_vvc_abs_mvd_greater0_flag(VVCLocalContext *lc)
int ff_vvc_end_of_slice_flag_decode(VVCLocalContext *lc)
int ff_vvc_pred_mode_ibc_flag(VVCLocalContext *lc, const int is_chroma)
int ff_vvc_palette_predictor_run(VVCLocalContext *lc, const int max)
int ff_vvc_palette_escape_val(VVCLocalContext *lc, const int max)
int ff_vvc_mmvd_merge_flag(VVCLocalContext *lc)
int ff_vvc_sao_offset_abs_decode(VVCLocalContext *lc)
int ff_vvc_sbt_quad_flag(VVCLocalContext *lc)
int ff_vvc_intra_bdpcm_luma_dir_flag(VVCLocalContext *lc)
int ff_vvc_cclm_mode_idx(VVCLocalContext *lc)
int ff_vvc_cabac_init(VVCLocalContext *lc, const int ctu_idx, const int rx, const int ry)
int ff_vvc_cu_skip_flag(VVCLocalContext *lc, const uint8_t *cu_skip_flag)
int ff_vvc_cclm_mode_flag(VVCLocalContext *lc)
int ff_vvc_end_of_tile_one_bit(VVCLocalContext *lc)
int ff_vvc_end_of_subset_one_bit(VVCLocalContext *lc)
int ff_vvc_alf_luma_fixed_filter_idx(VVCLocalContext *lc)
int ff_vvc_abs_mvd_minus2(VVCLocalContext *lc)
int ff_vvc_intra_luma_not_planar_flag(VVCLocalContext *lc, const int intra_subpartitions_mode_flag)
int ff_vvc_mmvd_cand_flag(VVCLocalContext *lc)
int ff_vvc_merge_gpm_partition_idx(VVCLocalContext *lc)
int ff_vvc_intra_bdpcm_luma_flag(VVCLocalContext *lc)
int ff_vvc_sao_offset_sign_decode(VVCLocalContext *lc)
int ff_vvc_alf_luma_prev_filter_idx(VVCLocalContext *lc)
int ff_vvc_sbt_pos_flag(VVCLocalContext *lc)
int ff_vvc_sao_type_idx_decode(VVCLocalContext *lc)
int ff_vvc_lfnst_idx(VVCLocalContext *lc, const int inc)
int ff_vvc_intra_subpartitions_mode_flag(VVCLocalContext *lc)
int ff_vvc_ciip_flag(VVCLocalContext *lc)
int ff_vvc_sym_mvd_flag(VVCLocalContext *lc)
int ff_vvc_alf_use_aps_flag(VVCLocalContext *lc)
int ff_vvc_intra_bdpcm_chroma_flag(VVCLocalContext *lc)
int ff_vvc_amvr_shift(VVCLocalContext *lc, const int inter_affine_flag, const PredMode pred_mode, const int has_amvr_flag)
int ff_vvc_pred_mode_flag(VVCLocalContext *lc, const int is_chroma)
int ff_vvc_intra_luma_mpm_flag(VVCLocalContext *lc)
int ff_vvc_cu_chroma_qp_offset_idx(VVCLocalContext *lc)
int ff_vvc_cu_chroma_qp_offset_flag(VVCLocalContext *lc)
int ff_vvc_mvp_lx_flag(VVCLocalContext *lc)
int ff_vvc_intra_mip_mode(VVCLocalContext *lc)
int ff_vvc_mvd_sign_flag(VVCLocalContext *lc)
int ff_vvc_pred_mode_plt_flag(VVCLocalContext *lc)
int ff_vvc_cu_act_enabled_flag(VVCLocalContext *lc)
int ff_vvc_intra_luma_mpm_idx(VVCLocalContext *lc)
int ff_vvc_sbt_horizontal_flag(VVCLocalContext *lc)
bool ff_vvc_palette_escape_val_present_flag(VVCLocalContext *lc)
int ff_vvc_intra_luma_ref_idx(VVCLocalContext *lc)
int ff_vvc_sao_eo_class_decode(VVCLocalContext *lc)
int ff_vvc_sao_merge_flag_decode(VVCLocalContext *lc)
int ff_vvc_merge_gpm_idx(VVCLocalContext *lc, const int idx)
void ff_vvc_mmvd_offset_coding(VVCLocalContext *lc, Mv *mmvd_offset, const int ph_mmvd_fullpel_only_flag)
int ff_vvc_cu_coded_flag(VVCLocalContext *lc)
int ff_vvc_cu_affine_type_flag(VVCLocalContext *lc)
int ff_vvc_sbt_flag(VVCLocalContext *lc)
int ff_vvc_regular_merge_flag(VVCLocalContext *lc, const int cu_skip_flag)
VVCSplitMode ff_vvc_split_mode(VVCLocalContext *lc, const int x0, const int y0, const int cb_width, const int cb_height, const int cqt_depth, const int mtt_depth, const int ch_type, const VVCAllowedSplit *a)
int ff_vvc_intra_chroma_pred_mode(VVCLocalContext *lc)
int ff_vvc_alf_ctb_cc_idc(VVCLocalContext *lc, const int rx, const int ry, const int idx, const int cc_filters_signalled)
int ff_vvc_intra_mip_flag(VVCLocalContext *lc, const uint8_t *intra_mip_flag)
bool ff_vvc_copy_above_palette_indices_flag(VVCLocalContext *lc)
int ff_vvc_alf_ctb_filter_alt_idx(VVCLocalContext *lc, const int c_idx, const int num_chroma_filters)
int ff_vvc_mts_idx(VVCLocalContext *lc)
int ff_vvc_residual_coding(VVCLocalContext *lc, TransformBlock *tb)
int ff_vvc_tu_cr_coded_flag(VVCLocalContext *lc, int tu_cb_coded_flag)
int ff_vvc_split_cu_flag(VVCLocalContext *lc, const int x0, const int y0, const int cb_width, const int cb_height, const int is_chroma, const VVCAllowedSplit *a)
int ff_vvc_merge_subblock_idx(VVCLocalContext *lc, const int max_num_subblock_merge_cand)
int ff_vvc_tu_cb_coded_flag(VVCLocalContext *lc)
int ff_vvc_new_palette_entries(VVCLocalContext *lc, const int bit_depth)
int ff_vvc_merge_subblock_flag(VVCLocalContext *lc)
bool ff_vvc_palette_transpose_flag(VVCLocalContext *lc)
int ff_vvc_non_inter_flag(VVCLocalContext *lc, const int x0, const int y0, const int ch_type)
int ff_vvc_alf_ctb_flag(VVCLocalContext *lc, const int rx, const int ry, const int c_idx)
int ff_vvc_abs_mvd_greater1_flag(VVCLocalContext *lc)
bool ff_vvc_run_copy_flag(VVCLocalContext *lc, const int prev_run_type, const int prev_run_position, const int cur_pos)
int ff_vvc_sao_band_position_decode(VVCLocalContext *lc)
int ff_vvc_tu_y_coded_flag(VVCLocalContext *lc)
int ff_vvc_intra_mip_transposed_flag(VVCLocalContext *lc)
int ff_vvc_num_signalled_palette_entries(VVCLocalContext *lc, const int max)
int ff_vvc_bcw_idx(VVCLocalContext *lc, const int no_backward_pred_flag)
int ff_vvc_intra_luma_mpm_remainder(VVCLocalContext *lc)
int ff_vvc_transform_skip_flag(VVCLocalContext *lc, const int inc)
int ff_vvc_tu_joint_cbcr_residual_flag(VVCLocalContext *lc, const int tu_cb_coded_flag, const int tu_cr_coded_flag)
int ff_vvc_inter_affine_flag(VVCLocalContext *lc)
int ff_vvc_general_merge_flag(VVCLocalContext *lc)
int ff_vvc_cu_qp_delta_abs(VVCLocalContext *lc)
PredFlag ff_vvc_pred_flag(VVCLocalContext *lc, const int is_b)
int ff_vvc_cu_qp_delta_sign_flag(VVCLocalContext *lc)
int ff_vvc_ref_idx_lx(VVCLocalContext *lc, const uint8_t nb_refs)
enum IspType ff_vvc_isp_split_type(VVCLocalContext *lc, const int intra_subpartitions_mode_flag)
int ff_vvc_merge_idx(VVCLocalContext *lc)
int ff_vvc_palette_idx_idc(VVCLocalContext *lc, const int max_palette_index, const bool adjust)
void ff_vvc_luma_mv_merge_mode(VVCLocalContext *lc, const int merge_idx, const int ciip_flag, MvField *mv)
int ff_vvc_luma_mv_merge_ibc(VVCLocalContext *lc, const int merge_idx, Mv *mv)
void ff_vvc_store_gpm_mvf(const VVCLocalContext *lc, const PredictionUnit *pu)
int ff_vvc_no_backward_pred_flag(const VVCLocalContext *lc)
void ff_vvc_store_mvf(const VVCLocalContext *lc, const MvField *mvf)
void ff_vvc_mvp(VVCLocalContext *lc, const int *mvp_lx_flag, const int amvr_shift, MotionInfo *mi)
void ff_vvc_sb_mv_merge_mode(VVCLocalContext *lc, const int merge_subblock_idx, PredictionUnit *pu)
void ff_vvc_luma_mv_merge_gpm(VVCLocalContext *lc, const int merge_gpm_idx[2], MvField *mv)
void ff_vvc_update_hmvp(VVCLocalContext *lc, const MotionInfo *mi)
MvField * ff_vvc_get_mvf(const VVCFrameContext *fc, const int x0, const int y0)
void ff_vvc_set_intra_mvf(const VVCLocalContext *lc, const bool dmvr, const PredFlag pf, const bool ciip_flag)
void ff_vvc_mv_scale(Mv *dst, const Mv *src, int td, int tb)
int ff_vvc_mvp_ibc(VVCLocalContext *lc, const int mvp_l0_flag, const int amvr_shift, Mv *mv)
void ff_vvc_store_sb_mvs(const VVCLocalContext *lc, PredictionUnit *pu)
void ff_vvc_store_mv(const VVCLocalContext *lc, const MotionInfo *mi)
void ff_vvc_affine_mvp(VVCLocalContext *lc, const int *mvp_lx_flag, const int amvr_shift, MotionInfo *mi)