mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
hevc/mvs: simplifying derive_spatial_merge_candidates function
cherry picked from commit 99be11cf08a5628d0bb6ac7f4958bf9dd35cda62 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
e9bb45ba79
commit
c4d63cd230
@ -329,8 +329,6 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
|
||||
|
||||
const int nb_refs = (s->sh.slice_type == P_SLICE) ?
|
||||
s->sh.nb_refs[0] : FFMIN(s->sh.nb_refs[0], s->sh.nb_refs[1]);
|
||||
int check_MER = 1;
|
||||
int check_MER_1 = 1;
|
||||
|
||||
int zero_idx = 0;
|
||||
|
||||
@ -343,8 +341,6 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
|
||||
int is_available_b1;
|
||||
int is_available_b2;
|
||||
|
||||
//first left spatial merge candidate
|
||||
is_available_a1 = AVAILABLE(cand_left, A1);
|
||||
|
||||
if (!singleMCLFlag && part_idx == 1 &&
|
||||
(lc->cu.part_mode == PART_Nx2N ||
|
||||
@ -352,84 +348,65 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
|
||||
lc->cu.part_mode == PART_nRx2N) ||
|
||||
isDiffMER(s, xA1, yA1, x0, y0)) {
|
||||
is_available_a1 = 0;
|
||||
} else {
|
||||
is_available_a1 = AVAILABLE(cand_left, A1);
|
||||
if (is_available_a1) {
|
||||
mergecandlist[nb_merge_cand] = TAB_MVF_PU(A1);
|
||||
if (merge_idx == 0) return;
|
||||
nb_merge_cand++;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_available_a1) {
|
||||
mergecandlist[0] = TAB_MVF_PU(A1);
|
||||
if (merge_idx == 0) return;
|
||||
nb_merge_cand++;
|
||||
}
|
||||
|
||||
// above spatial merge candidate
|
||||
is_available_b1 = AVAILABLE(cand_up, B1);
|
||||
|
||||
if (!singleMCLFlag && part_idx == 1 &&
|
||||
(lc->cu.part_mode == PART_2NxN ||
|
||||
lc->cu.part_mode == PART_2NxnU ||
|
||||
lc->cu.part_mode == PART_2NxnD) ||
|
||||
isDiffMER(s, xB1, yB1, x0, y0)) {
|
||||
is_available_b1 = 0;
|
||||
} else {
|
||||
is_available_b1 = AVAILABLE(cand_up, B1);
|
||||
if (is_available_b1 &&
|
||||
!(is_available_a1 && COMPARE_MV_REFIDX(B1, A1))) {
|
||||
mergecandlist[nb_merge_cand] = TAB_MVF_PU(B1);
|
||||
if (merge_idx == nb_merge_cand) return;
|
||||
nb_merge_cand++;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_available_a1 && is_available_b1)
|
||||
check_MER = !COMPARE_MV_REFIDX(B1, A1);
|
||||
|
||||
if (is_available_b1 && check_MER)
|
||||
mergecandlist[nb_merge_cand++] = TAB_MVF_PU(B1);
|
||||
|
||||
// above right spatial merge candidate
|
||||
check_MER = 1;
|
||||
|
||||
is_available_b0 = AVAILABLE(cand_up_right, B0) &&
|
||||
xB0 < s->sps->width &&
|
||||
PRED_BLOCK_AVAILABLE(B0);
|
||||
PRED_BLOCK_AVAILABLE(B0) &&
|
||||
!isDiffMER(s, xB0, yB0, x0, y0);
|
||||
|
||||
if (isDiffMER(s, xB0, yB0, x0, y0))
|
||||
is_available_b0 = 0;
|
||||
|
||||
if (is_available_b1 && is_available_b0)
|
||||
check_MER = !COMPARE_MV_REFIDX(B0, B1);
|
||||
|
||||
if (is_available_b0 && check_MER) {
|
||||
if (is_available_b0 &&
|
||||
!(is_available_b1 && COMPARE_MV_REFIDX(B0, B1))) {
|
||||
mergecandlist[nb_merge_cand] = TAB_MVF_PU(B0);
|
||||
if (merge_idx == nb_merge_cand) return;
|
||||
nb_merge_cand++;
|
||||
}
|
||||
|
||||
// left bottom spatial merge candidate
|
||||
check_MER = 1;
|
||||
|
||||
is_available_a0 = AVAILABLE(cand_bottom_left, A0) &&
|
||||
yA0 < s->sps->height &&
|
||||
PRED_BLOCK_AVAILABLE(A0);
|
||||
PRED_BLOCK_AVAILABLE(A0) &&
|
||||
!isDiffMER(s, xA0, yA0, x0, y0);
|
||||
|
||||
if (isDiffMER(s, xA0, yA0, x0, y0))
|
||||
is_available_a0 = 0;
|
||||
|
||||
if (is_available_a1 && is_available_a0)
|
||||
check_MER = !COMPARE_MV_REFIDX(A0, A1);
|
||||
|
||||
if (is_available_a0 && check_MER) {
|
||||
if (is_available_a0 &&
|
||||
!(is_available_a1 && COMPARE_MV_REFIDX(A0, A1))) {
|
||||
mergecandlist[nb_merge_cand] = TAB_MVF_PU(A0);
|
||||
if (merge_idx == nb_merge_cand) return;
|
||||
nb_merge_cand++;
|
||||
}
|
||||
|
||||
// above left spatial merge candidate
|
||||
check_MER = 1;
|
||||
is_available_b2 = AVAILABLE(cand_up_left, B2) &&
|
||||
!isDiffMER(s, xB2, yB2, x0, y0);
|
||||
|
||||
is_available_b2 = AVAILABLE(cand_up_left, B2);
|
||||
|
||||
if (isDiffMER(s, xB2, yB2, x0, y0))
|
||||
is_available_b2 = 0;
|
||||
|
||||
if (is_available_a1 && is_available_b2)
|
||||
check_MER = !COMPARE_MV_REFIDX(B2, A1);
|
||||
|
||||
if (is_available_b1 && is_available_b2)
|
||||
check_MER_1 = !COMPARE_MV_REFIDX(B2, B1);
|
||||
|
||||
if (is_available_b2 && check_MER && check_MER_1 && nb_merge_cand != 4) {
|
||||
if (is_available_b2 &&
|
||||
!(is_available_a1 && COMPARE_MV_REFIDX(B2, A1)) &&
|
||||
!(is_available_b1 && COMPARE_MV_REFIDX(B2, B1)) &&
|
||||
nb_merge_cand != 4) {
|
||||
mergecandlist[nb_merge_cand] = TAB_MVF_PU(B2);
|
||||
if (merge_idx == nb_merge_cand) return;
|
||||
nb_merge_cand++;
|
||||
|
Loading…
Reference in New Issue
Block a user