54 (x0b + nPbW == 1 <<
s->ps.sps->log2_ctb_size) ?
68 #define MIN_TB_ADDR_ZS(x, y) \
69 s->ps.pps->min_tb_addr_zs[(y) * (s->ps.sps->tb_mask+2) + (x)]
71 int xCurr_ctb = xCurr >>
s->ps.sps->log2_ctb_size;
72 int yCurr_ctb = yCurr >>
s->ps.sps->log2_ctb_size;
73 int xN_ctb = xN >>
s->ps.sps->log2_ctb_size;
74 int yN_ctb = yN >>
s->ps.sps->log2_ctb_size;
75 if( yN_ctb < yCurr_ctb || xN_ctb < xCurr_ctb )
78 int Curr =
MIN_TB_ADDR_ZS((xCurr >>
s->ps.sps->log2_min_tb_size) &
s->ps.sps->tb_mask,
79 (yCurr >>
s->ps.sps->log2_min_tb_size) &
s->ps.sps->tb_mask);
81 (yN >>
s->ps.sps->log2_min_tb_size) &
s->ps.sps->tb_mask);
89 uint8_t plevel =
s->ps.pps->log2_parallel_merge_level;
91 return xN >> plevel == xP >> plevel &&
92 yN >> plevel == yP >> plevel;
95 #define MATCH_MV(x) (AV_RN32A(&A.x) == AV_RN32A(&B.x))
96 #define MATCH(x) (A.x == B.x)
101 int a_pf =
A.pred_flag;
102 int b_pf =
B.pred_flag;
107 }
else if (a_pf ==
PF_L0) {
109 }
else if (a_pf ==
PF_L1) {
118 int tx, scale_factor;
122 tx = (0x4000 +
abs(
td / 2)) /
td;
125 (scale_factor *
src->x < 0)) >> 8);
127 (scale_factor *
src->y < 0)) >> 8);
133 const RefPicList *refPicList_col,
int listCol,
int refidxCol)
136 int col_lt = refPicList_col[listCol].
isLongTerm[refidxCol];
137 int col_poc_diff, cur_poc_diff;
139 if (cur_lt != col_lt) {
145 col_poc_diff = colPic - refPicList_col[listCol].
list[refidxCol];
146 cur_poc_diff = poc - refPicList[
X].
list[refIdxLx];
148 if (cur_lt || col_poc_diff == cur_poc_diff || !col_poc_diff) {
149 mvLXCol->
x = mvCol->
x;
150 mvLXCol->
y = mvCol->
y;
152 mv_scale(mvLXCol, mvCol, col_poc_diff, cur_poc_diff);
157 #define CHECK_MVSET(l) \
158 check_mvset(mvLXCol, temp_col.mv + l, \
160 refPicList, X, refIdxLx, \
161 refPicList_col, L ## l, temp_col.ref_idx[l])
165 int refIdxLx,
Mv *mvLXCol,
int X,
178 int check_diffpicount = 0;
180 for (j = 0; j < 2; j++) {
182 if (refPicList[j].
list[
i] >
s->poc) {
188 if (!check_diffpicount) {
194 if (
s->sh.collocated_list ==
L1)
204 #define TAB_MVF(x, y) \
205 tab_mvf[(y) * min_pu_width + x]
207 #define TAB_MVF_PU(v) \
208 TAB_MVF(((x ## v) >> s->ps.sps->log2_min_pu_size), \
209 ((y ## v) >> s->ps.sps->log2_min_pu_size))
211 #define DERIVE_TEMPORAL_COLOCATED_MVS \
212 derive_temporal_colocated_mvs(s, temp_col, \
213 refIdxLx, mvLXCol, X, colPic, \
214 ff_hevc_get_ref_list(s, ref, x, y))
220 int nPbW,
int nPbH,
int refIdxLx,
225 int x, y, x_pu, y_pu;
226 int min_pu_width =
s->ps.sps->min_pu_width;
227 int availableFlagLXCol = 0;
233 memset(mvLXCol, 0,
sizeof(*mvLXCol));
237 tab_mvf =
ref->tab_mvf;
245 (y0 >>
s->ps.sps->log2_ctb_size) == (y >>
s->ps.sps->log2_ctb_size) &&
246 y < s->ps.sps->height &&
247 x < s->ps.sps->width) {
252 x_pu = x >>
s->ps.sps->log2_min_pu_size;
253 y_pu = y >>
s->ps.sps->log2_min_pu_size;
254 temp_col =
TAB_MVF(x_pu, y_pu);
259 if (tab_mvf && !availableFlagLXCol) {
260 x = x0 + (nPbW >> 1);
261 y = y0 + (nPbH >> 1);
266 x_pu = x >>
s->ps.sps->log2_min_pu_size;
267 y_pu = y >>
s->ps.sps->log2_min_pu_size;
268 temp_col =
TAB_MVF(x_pu, y_pu);
271 return availableFlagLXCol;
274 #define AVAILABLE(cand, v) \
275 (cand && !(TAB_MVF_PU(v).pred_flag == PF_INTRA))
277 #define PRED_BLOCK_AVAILABLE(v) \
278 z_scan_block_avail(s, x0, y0, x ## v, y ## v)
280 #define COMPARE_MV_REFIDX(a, b) \
281 compare_mv_ref_idx(TAB_MVF_PU(a), TAB_MVF_PU(b))
290 int singleMCLFlag,
int part_idx,
292 struct MvField mergecandlist[])
295 const MvField *tab_mvf =
s->ref->tab_mvf;
297 const int min_pu_width =
s->ps.sps->min_pu_width;
305 const int xA1 = x0 - 1;
306 const int yA1 = y0 + nPbH - 1;
308 const int xB1 = x0 + nPbW - 1;
309 const int yB1 = y0 - 1;
311 const int xB0 = x0 + nPbW;
312 const int yB0 = y0 - 1;
314 const int xA0 = x0 - 1;
315 const int yA0 = y0 + nPbH;
317 const int xB2 = x0 - 1;
318 const int yB2 = y0 - 1;
321 s->sh.nb_refs[0] :
FFMIN(
s->sh.nb_refs[0],
s->sh.nb_refs[1]);
325 int nb_merge_cand = 0;
326 int nb_orig_merge_cand = 0;
335 if (!singleMCLFlag && part_idx == 1 &&
343 if (is_available_a1) {
351 if (!singleMCLFlag && part_idx == 1 &&
359 if (is_available_b1 &&
362 if (merge_idx == nb_merge_cand)
370 xB0 <
s->ps.sps->width &&
374 if (is_available_b0 &&
377 if (merge_idx == nb_merge_cand)
383 is_available_a0 =
AVAILABLE(cand_bottom_left, A0) &&
384 yA0 <
s->ps.sps->height &&
388 if (is_available_a0 &&
390 mergecandlist[nb_merge_cand] =
TAB_MVF_PU(A0);
391 if (merge_idx == nb_merge_cand)
400 if (is_available_b2 &&
403 nb_merge_cand != 4) {
405 if (merge_idx == nb_merge_cand)
411 if (
s->sh.slice_temporal_mvp_enabled_flag &&
412 nb_merge_cand < s->sh.max_num_merge_cand) {
413 Mv mv_l0_col = { 0 }, mv_l1_col = { 0 };
418 0, &mv_l1_col, 1) : 0;
420 if (available_l0 || available_l1) {
421 mergecandlist[nb_merge_cand].
pred_flag = available_l0 + (available_l1 << 1);
422 AV_ZERO16(mergecandlist[nb_merge_cand].ref_idx);
423 mergecandlist[nb_merge_cand].
mv[0] = mv_l0_col;
424 mergecandlist[nb_merge_cand].
mv[1] = mv_l1_col;
426 if (merge_idx == nb_merge_cand)
432 nb_orig_merge_cand = nb_merge_cand;
435 if (
s->sh.slice_type ==
HEVC_SLICE_B && nb_orig_merge_cand > 1 &&
436 nb_orig_merge_cand < s->sh.max_num_merge_cand) {
439 for (comb_idx = 0; nb_merge_cand <
s->sh.max_num_merge_cand &&
440 comb_idx < nb_orig_merge_cand * (nb_orig_merge_cand - 1); comb_idx++) {
443 MvField l0_cand = mergecandlist[l0_cand_idx];
444 MvField l1_cand = mergecandlist[l1_cand_idx];
453 AV_COPY32(&mergecandlist[nb_merge_cand].
mv[0], &l0_cand.
mv[0]);
454 AV_COPY32(&mergecandlist[nb_merge_cand].
mv[1], &l1_cand.
mv[1]);
455 if (merge_idx == nb_merge_cand)
463 while (nb_merge_cand < s->sh.max_num_merge_cand) {
467 mergecandlist[nb_merge_cand].
ref_idx[0] = zero_idx < nb_refs ? zero_idx : 0;
468 mergecandlist[nb_merge_cand].
ref_idx[1] = zero_idx < nb_refs ? zero_idx : 0;
470 if (merge_idx == nb_merge_cand)
481 int nPbH,
int log2_cb_size,
int part_idx,
485 int singleMCLFlag = 0;
486 int nCS = 1 << log2_cb_size;
491 if (
s->ps.pps->log2_parallel_merge_level > 2 && nCS == 8) {
502 singleMCLFlag, part_idx,
503 merge_idx, mergecand_list);
505 if (mergecand_list[merge_idx].pred_flag ==
PF_BI &&
506 (nPbW2 + nPbH2) == 12) {
510 *
mv = mergecand_list[merge_idx];
514 int min_pu_width,
int x,
int y,
515 int elist,
int ref_idx_curr,
int ref_idx)
518 const MvField *tab_mvf =
s->ref->tab_mvf;
519 int ref_pic_elist = refPicList[elist].
list[
TAB_MVF(x, y).ref_idx[elist]];
520 int ref_pic_curr = refPicList[ref_idx_curr].
list[ref_idx];
522 if (ref_pic_elist != ref_pic_curr) {
523 int poc_diff =
s->poc - ref_pic_elist;
531 Mv *
mv,
int ref_idx_curr,
int ref_idx)
533 const MvField *tab_mvf =
s->ref->tab_mvf;
534 int min_pu_width =
s->ps.sps->min_pu_width;
538 if (((
TAB_MVF(x, y).pred_flag) & (1 << pred_flag_index)) &&
539 refPicList[pred_flag_index].
list[
TAB_MVF(x, y).ref_idx[pred_flag_index]] == refPicList[ref_idx_curr].
list[ref_idx]) {
547 Mv *
mv,
int ref_idx_curr,
int ref_idx)
549 const MvField *tab_mvf =
s->ref->tab_mvf;
550 int min_pu_width =
s->ps.sps->min_pu_width;
554 if ((
TAB_MVF(x, y).pred_flag) & (1 << pred_flag_index)) {
555 int currIsLongTerm = refPicList[ref_idx_curr].
isLongTerm[ref_idx];
558 refPicList[pred_flag_index].
isLongTerm[(
TAB_MVF(x, y).ref_idx[pred_flag_index])];
560 if (colIsLongTerm == currIsLongTerm) {
564 pred_flag_index, ref_idx_curr, ref_idx);
571 #define MP_MX(v, pred, mx) \
573 (x ## v) >> s->ps.sps->log2_min_pu_size, \
574 (y ## v) >> s->ps.sps->log2_min_pu_size, \
575 pred, &mx, ref_idx_curr, ref_idx)
577 #define MP_MX_LT(v, pred, mx) \
578 mv_mp_mode_mx_lt(s, \
579 (x ## v) >> s->ps.sps->log2_min_pu_size, \
580 (y ## v) >> s->ps.sps->log2_min_pu_size, \
581 pred, &mx, ref_idx_curr, ref_idx)
584 int nPbH,
int log2_cb_size,
int part_idx,
586 int mvp_lx_flag,
int LX)
589 const MvField *
const tab_mvf =
s->ref->tab_mvf;
590 int isScaledFlag_L0 = 0;
591 int availableFlagLXA0 = 1;
592 int availableFlagLXB0 = 1;
593 int numMVPCandLX = 0;
594 int min_pu_width =
s->ps.sps->min_pu_width;
607 Mv mvpcand_list[2] = { { 0 } };
612 int pred_flag_index_l0;
613 int pred_flag_index_l1;
621 ref_idx =
mv->ref_idx[LX];
622 pred_flag_index_l0 = LX;
623 pred_flag_index_l1 = !LX;
629 is_available_a0 =
AVAILABLE(cand_bottom_left, A0) &&
630 yA0 <
s->ps.sps->height &&
638 if (is_available_a0 || is_available_a1)
641 if (is_available_a0) {
642 if (
MP_MX(A0, pred_flag_index_l0, mxA)) {
645 if (
MP_MX(A0, pred_flag_index_l1, mxA)) {
650 if (is_available_a1) {
651 if (
MP_MX(
A1, pred_flag_index_l0, mxA)) {
654 if (
MP_MX(
A1, pred_flag_index_l1, mxA)) {
659 if (is_available_a0) {
660 if (
MP_MX_LT(A0, pred_flag_index_l0, mxA)) {
663 if (
MP_MX_LT(A0, pred_flag_index_l1, mxA)) {
668 if (is_available_a1) {
676 availableFlagLXA0 = 0;
685 xB0 <
s->ps.sps->width &&
699 if (is_available_b0) {
700 if (
MP_MX(
B0, pred_flag_index_l0, mxB)) {
703 if (
MP_MX(
B0, pred_flag_index_l1, mxB)) {
709 if (is_available_b1) {
710 if (
MP_MX(
B1, pred_flag_index_l0, mxB)) {
713 if (
MP_MX(
B1, pred_flag_index_l1, mxB)) {
719 if (is_available_b2) {
720 if (
MP_MX(
B2, pred_flag_index_l0, mxB)) {
723 if (
MP_MX(
B2, pred_flag_index_l1, mxB)) {
727 availableFlagLXB0 = 0;
730 if (!isScaledFlag_L0) {
731 if (availableFlagLXB0) {
732 availableFlagLXA0 = 1;
735 availableFlagLXB0 = 0;
738 if (is_available_b0) {
739 availableFlagLXB0 =
MP_MX_LT(
B0, pred_flag_index_l0, mxB);
740 if (!availableFlagLXB0)
741 availableFlagLXB0 =
MP_MX_LT(
B0, pred_flag_index_l1, mxB);
744 if (is_available_b1 && !availableFlagLXB0) {
745 availableFlagLXB0 =
MP_MX_LT(
B1, pred_flag_index_l0, mxB);
746 if (!availableFlagLXB0)
747 availableFlagLXB0 =
MP_MX_LT(
B1, pred_flag_index_l1, mxB);
750 if (is_available_b2 && !availableFlagLXB0) {
751 availableFlagLXB0 =
MP_MX_LT(
B2, pred_flag_index_l0, mxB);
752 if (!availableFlagLXB0)
753 availableFlagLXB0 =
MP_MX_LT(
B2, pred_flag_index_l1, mxB);
757 if (availableFlagLXA0)
758 mvpcand_list[numMVPCandLX++] = mxA;
760 if (availableFlagLXB0 && (!availableFlagLXA0 || mxA.
x != mxB.
x || mxA.
y != mxB.
y))
761 mvpcand_list[numMVPCandLX++] = mxB;
764 if (numMVPCandLX < 2 && s->sh.slice_temporal_mvp_enabled_flag &&
765 mvp_lx_flag == numMVPCandLX) {
771 mvpcand_list[numMVPCandLX++] = mv_col;
774 mv->mv[LX] = mvpcand_list[mvp_lx_flag];