67 #define MIN_TB_ADDR_ZS(x, y) \
68 s->pps->min_tb_addr_zs[(y) * (s->sps->tb_mask+2) + (x)]
75 if (xN < 0 || yN < 0 ||
80 if( yN_ctb < yCurr_ctb || xN_ctb < xCurr_ctb )
92 int x0,
int y0,
int nPbW,
int nPbH,
93 int xA1,
int yA1,
int partIdx)
95 return !(nPbW << 1 == 1 << log2_cb_size &&
96 nPbH << 1 == 1 << log2_cb_size && partIdx == 1 &&
97 lc->
cu.
x + nPbW > xA1 &&
98 lc->
cu.
y + nPbH <= yA1);
105 int x0,
int y0,
int nPbW,
int nPbH,
106 int xA1,
int yA1,
int partIdx)
110 if (lc->
cu.
x < xA1 && lc->
cu.
y < yA1 &&
111 (lc->
cu.
x + (1 << log2_cb_size)) > xA1 &&
112 (lc->
cu.
y + (1 << log2_cb_size)) > yA1)
114 nPbW, nPbH, xA1, yA1, partIdx);
124 return xN >> plevel == xP >> plevel &&
125 yN >> plevel == yP >> plevel;
128 #define MATCH(x) (A.x == B.x)
139 }
else if (a_pf ==
PF_L0) {
141 }
else if (a_pf ==
PF_L1) {
150 int tx, scale_factor;
152 td = av_clip_int8(td);
153 tb = av_clip_int8(tb);
154 tx = (0x4000 + abs(td / 2)) / td;
155 scale_factor = av_clip((tb * tx + 32) >> 6, -4096, 4095);
156 dst->
x = av_clip_int16((scale_factor * src->
x + 127 +
157 (scale_factor * src->
x < 0)) >> 8);
158 dst->
y = av_clip_int16((scale_factor * src->
y + 127 +
159 (scale_factor * src->
y < 0)) >> 8);
165 RefPicList *refPicList_col,
int listCol,
int refidxCol)
167 int cur_lt = refPicList[X].
isLongTerm[refIdxLx];
168 int col_lt = refPicList_col[listCol].
isLongTerm[refidxCol];
169 int col_poc_diff, cur_poc_diff;
171 if (cur_lt != col_lt) {
177 col_poc_diff = colPic - refPicList_col[listCol].
list[refidxCol];
178 cur_poc_diff = poc - refPicList[X].
list[refIdxLx];
180 if (cur_lt || col_poc_diff == cur_poc_diff || !col_poc_diff) {
181 mvLXCol->
x = mvCol->
x;
182 mvLXCol->
y = mvCol->
y;
184 mv_scale(mvLXCol, mvCol, col_poc_diff, cur_poc_diff);
189 #define CHECK_MVSET(l) \
190 check_mvset(mvLXCol, temp_col.mv + l, \
192 refPicList, X, refIdxLx, \
193 refPicList_col, L ## l, temp_col.ref_idx[l])
197 int refIdxLx,
Mv *mvLXCol,
int X,
210 int check_diffpicount = 0;
212 for (i = 0; i < refPicList[0].
nb_refs; i++) {
213 if (refPicList[0].list[i] > s->
poc)
216 for (i = 0; i < refPicList[1].
nb_refs; i++) {
217 if (refPicList[1].list[i] > s->
poc)
220 if (check_diffpicount == 0 && X == 0)
222 else if (check_diffpicount == 0 && X == 1)
235 #define TAB_MVF(x, y) \
236 tab_mvf[(y) * min_pu_width + x]
238 #define TAB_MVF_PU(v) \
239 TAB_MVF(x ## v ## _pu, y ## v ## _pu)
241 #define DERIVE_TEMPORAL_COLOCATED_MVS \
242 derive_temporal_colocated_mvs(s, temp_col, \
243 refIdxLx, mvLXCol, X, colPic, \
244 ff_hevc_get_ref_list(s, ref, x, y))
250 int nPbW,
int nPbH,
int refIdxLx,
255 int x,
y, x_pu, y_pu;
257 int availableFlagLXCol = 0;
276 y < s->sps->height &&
282 temp_col =
TAB_MVF(x_pu, y_pu);
287 if (tab_mvf && !availableFlagLXCol) {
288 x = x0 + (nPbW >> 1);
289 y = y0 + (nPbH >> 1);
294 temp_col =
TAB_MVF(x_pu, y_pu);
297 return availableFlagLXCol;
300 #define AVAILABLE(cand, v) \
301 (cand && !(TAB_MVF_PU(v).pred_flag == PF_INTRA))
303 #define PRED_BLOCK_AVAILABLE(v) \
304 check_prediction_block_available(s, log2_cb_size, \
305 x0, y0, nPbW, nPbH, \
306 x ## v, y ## v, part_idx)
308 #define COMPARE_MV_REFIDX(a, b) \
309 compareMVrefidx(TAB_MVF_PU(a), TAB_MVF_PU(b))
317 int singleMCLFlag,
int part_idx,
319 struct MvField mergecandlist[])
333 const int xA1 = x0 - 1;
334 const int yA1 = y0 + nPbH - 1;
338 const int xB1 = x0 + nPbW - 1;
339 const int yB1 = y0 - 1;
343 const int xB0 = x0 + nPbW;
344 const int yB0 = y0 - 1;
348 const int xA0 = x0 - 1;
349 const int yA0 = y0 + nPbH;
353 const int xB2 = x0 - 1;
354 const int yB2 = y0 - 1;
365 int nb_merge_cand = 0;
366 int nb_orig_merge_cand = 0;
379 if (!singleMCLFlag && part_idx == 1 &&
387 if (is_available_a1) {
389 if (merge_idx == 0)
return;
396 if (!singleMCLFlag && part_idx == 1 &&
404 if (is_available_a1 && is_available_b1)
407 if (is_available_b1 && check_MER)
414 is_available_b0 = check_B0 &&
AVAILABLE(cand_up_right,
B0);
419 if (is_available_b1 && is_available_b0)
422 if (is_available_b0 && check_MER) {
424 if (merge_idx == nb_merge_cand)
return;
432 is_available_a0 = check_A0 &&
AVAILABLE(cand_bottom_left, A0);
437 if (is_available_a1 && is_available_a0)
440 if (is_available_a0 && check_MER) {
441 mergecandlist[nb_merge_cand] =
TAB_MVF_PU(A0);
442 if (merge_idx == nb_merge_cand)
return;
454 if (is_available_a1 && is_available_b2)
457 if (is_available_b1 && is_available_b2)
460 if (is_available_b2 && check_MER && check_MER_1 && nb_merge_cand != 4) {
462 if (merge_idx == nb_merge_cand)
return;
468 nb_merge_cand < s->sh.max_num_merge_cand) {
469 Mv mv_l0_col, mv_l1_col;
474 0, &mv_l1_col, 1) : 0;
476 if (available_l0 || available_l1) {
477 mergecandlist[nb_merge_cand].
pred_flag = available_l0 + (available_l1 << 1);
479 mergecandlist[nb_merge_cand].
mv[0] = mv_l0_col;
480 mergecandlist[nb_merge_cand].
ref_idx[0] = 0;
483 mergecandlist[nb_merge_cand].
mv[1] = mv_l1_col;
484 mergecandlist[nb_merge_cand].
ref_idx[1] = 0;
486 if (merge_idx == nb_merge_cand)
return;
491 nb_orig_merge_cand = nb_merge_cand;
495 nb_orig_merge_cand < s->sh.max_num_merge_cand) {
499 comb_idx < nb_orig_merge_cand * (nb_orig_merge_cand - 1); comb_idx++) {
502 MvField l0_cand = mergecandlist[l0_cand_idx];
503 MvField l1_cand = mergecandlist[l1_cand_idx];
506 (refPicList[0].list[l0_cand.
ref_idx[0]] !=
508 l0_cand.
mv[0].
x != l1_cand.
mv[1].
x ||
509 l0_cand.
mv[0].
y != l1_cand.
mv[1].
y)) {
513 mergecandlist[nb_merge_cand].
mv[0].
x = l0_cand.
mv[0].
x;
514 mergecandlist[nb_merge_cand].
mv[0].
y = l0_cand.
mv[0].
y;
515 mergecandlist[nb_merge_cand].
mv[1].
x = l1_cand.
mv[1].
x;
516 mergecandlist[nb_merge_cand].
mv[1].
y = l1_cand.
mv[1].
y;
517 if (merge_idx == nb_merge_cand)
return;
524 while (nb_merge_cand < s->sh.max_num_merge_cand) {
526 mergecandlist[nb_merge_cand].
mv[0].
x = 0;
527 mergecandlist[nb_merge_cand].
mv[0].
y = 0;
528 mergecandlist[nb_merge_cand].
mv[1].
x = 0;
529 mergecandlist[nb_merge_cand].
mv[1].
y = 0;
530 mergecandlist[nb_merge_cand].
ref_idx[0] = zero_idx < nb_refs ? zero_idx : 0;
531 mergecandlist[nb_merge_cand].
ref_idx[1] = zero_idx < nb_refs ? zero_idx : 0;
533 if (merge_idx == nb_merge_cand)
return;
543 int nPbH,
int log2_cb_size,
int part_idx,
546 int singleMCLFlag = 0;
547 int nCS = 1 << log2_cb_size;
548 struct MvField mergecand_list[MRG_MAX_NUM_CANDS] = { { { { 0 } } } };
564 singleMCLFlag, part_idx,
565 merge_idx, mergecand_list);
568 (nPbW2 + nPbH2) == 12) {
572 *mv = mergecand_list[merge_idx];
576 int min_pu_width,
int x,
int y,
577 int elist,
int ref_idx_curr,
int ref_idx)
581 int ref_pic_elist = refPicList[elist].
list[
TAB_MVF(x, y).ref_idx[elist]];
582 int ref_pic_curr = refPicList[ref_idx_curr].
list[
ref_idx];
584 if (ref_pic_elist != ref_pic_curr) {
585 int poc_diff = s->
poc - ref_pic_elist;
601 refPicList[pred_flag_index].list[
TAB_MVF(x, y).ref_idx[pred_flag_index]] == refPicList[ref_idx_curr].list[ref_idx]) {
602 *mv =
TAB_MVF(x, y).mv[pred_flag_index];
620 refPicList[pred_flag_index].
isLongTerm[(
TAB_MVF(x, y).ref_idx[pred_flag_index])];
622 if (colIsLongTerm == currIsLongTerm) {
623 *mv =
TAB_MVF(x, y).mv[pred_flag_index];
626 pred_flag_index, ref_idx_curr, ref_idx);
633 #define MP_MX(v, pred, mx) \
634 mv_mp_mode_mx(s, x ## v ## _pu, y ## v ## _pu, pred, \
635 &mx, ref_idx_curr, ref_idx)
637 #define MP_MX_LT(v, pred, mx) \
638 mv_mp_mode_mx_lt(s, x ## v ## _pu, y ## v ## _pu, pred, \
639 &mx, ref_idx_curr, ref_idx)
642 int nPbH,
int log2_cb_size,
int part_idx,
644 int mvp_lx_flag,
int LX)
648 int isScaledFlag_L0 = 0;
649 int availableFlagLXA0 = 0;
650 int availableFlagLXB0 = 0;
651 int numMVPCandLX = 0;
667 int xB1_pu = 0, yB1_pu = 0;
668 int is_available_b1 = 0;
671 int xB2_pu = 0, yB2_pu = 0;
672 int is_available_b2 = 0;
673 Mv mvpcand_list[2] = { { 0 } };
676 int ref_idx_curr = 0;
678 int pred_flag_index_l0;
679 int pred_flag_index_l1;
691 int cand_bottom_left = (y0 + nPbH >= lc->
end_of_tiles_y) ? 0 : cand_left;
695 pred_flag_index_l0 = LX;
696 pred_flag_index_l1 = !LX;
713 if (is_available_a0 || is_available_a1)
716 if (is_available_a0) {
717 availableFlagLXA0 =
MP_MX(A0, pred_flag_index_l0, mxA);
718 if (!availableFlagLXA0)
719 availableFlagLXA0 =
MP_MX(A0, pred_flag_index_l1, mxA);
722 if (is_available_a1 && !availableFlagLXA0) {
723 availableFlagLXA0 =
MP_MX(
A1, pred_flag_index_l0, mxA);
724 if (!availableFlagLXA0)
725 availableFlagLXA0 =
MP_MX(
A1, pred_flag_index_l1, mxA);
728 if (is_available_a0 && !availableFlagLXA0) {
729 availableFlagLXA0 =
MP_MX_LT(A0, pred_flag_index_l0, mxA);
730 if (!availableFlagLXA0)
731 availableFlagLXA0 =
MP_MX_LT(A0, pred_flag_index_l1, mxA);
734 if (is_available_a1 && !availableFlagLXA0) {
735 availableFlagLXA0 =
MP_MX_LT(
A1, pred_flag_index_l0, mxA);
736 if (!availableFlagLXA0)
737 availableFlagLXA0 =
MP_MX_LT(
A1, pred_flag_index_l1, mxA);
740 if(availableFlagLXA0 && !mvp_lx_flag) {
754 if (is_available_b0) {
755 availableFlagLXB0 =
MP_MX(
B0, pred_flag_index_l0, mxB);
756 if (!availableFlagLXB0)
757 availableFlagLXB0 =
MP_MX(
B0, pred_flag_index_l1, mxB);
760 if (!availableFlagLXB0) {
769 if (is_available_b1) {
770 availableFlagLXB0 =
MP_MX(
B1, pred_flag_index_l0, mxB);
771 if (!availableFlagLXB0)
772 availableFlagLXB0 =
MP_MX(
B1, pred_flag_index_l1, mxB);
776 if (!availableFlagLXB0) {
784 if (is_available_b2) {
785 availableFlagLXB0 =
MP_MX(
B2, pred_flag_index_l0, mxB);
786 if (!availableFlagLXB0)
787 availableFlagLXB0 =
MP_MX(
B2, pred_flag_index_l1, mxB);
791 if (isScaledFlag_L0 == 0) {
792 if (availableFlagLXB0) {
793 availableFlagLXA0 = 1;
796 availableFlagLXB0 = 0;
799 if (is_available_b0) {
800 availableFlagLXB0 =
MP_MX_LT(
B0, pred_flag_index_l0, mxB);
801 if (!availableFlagLXB0)
802 availableFlagLXB0 =
MP_MX_LT(
B0, pred_flag_index_l1, mxB);
805 if (is_available_b1 && !availableFlagLXB0) {
806 availableFlagLXB0 =
MP_MX_LT(
B1, pred_flag_index_l0, mxB);
807 if (!availableFlagLXB0)
808 availableFlagLXB0 =
MP_MX_LT(
B1, pred_flag_index_l1, mxB);
811 if (is_available_b2 && !availableFlagLXB0) {
812 availableFlagLXB0 =
MP_MX_LT(
B2, pred_flag_index_l0, mxB);
813 if (!availableFlagLXB0)
814 availableFlagLXB0 =
MP_MX_LT(
B2, pred_flag_index_l1, mxB);
818 if (availableFlagLXA0)
819 mvpcand_list[numMVPCandLX++] = mxA;
821 if (availableFlagLXB0 && (!availableFlagLXA0 || mxA.
x != mxB.
x || mxA.
y != mxB.
y))
822 mvpcand_list[numMVPCandLX++] = mxB;
825 if (numMVPCandLX < 2 && s->sh.slice_temporal_mvp_enabled_flag) {
831 mvpcand_list[numMVPCandLX++] = mv_col;
834 mv->
mv[LX] = mvpcand_list[mvp_lx_flag];