hevc: derive partial merge list

The merge list only needs to be derived up to the merge index.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
This commit is contained in:
Christophe Gisquet 2014-08-08 18:21:01 +00:00 committed by Anton Khirnov
parent 3505b19652
commit ed53cc217f
1 changed files with 33 additions and 9 deletions

View File

@ -311,6 +311,7 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
int nPbW, int nPbH, int nPbW, int nPbH,
int log2_cb_size, int log2_cb_size,
int singleMCLFlag, int part_idx, int singleMCLFlag, int part_idx,
int merge_idx,
struct MvField mergecandlist[]) struct MvField mergecandlist[])
{ {
HEVCLocalContext *lc = &s->HEVClc; HEVCLocalContext *lc = &s->HEVClc;
@ -379,8 +380,12 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
is_available_a1 = 0; is_available_a1 = 0;
} }
if (is_available_a1) if (is_available_a1) {
mergecandlist[nb_merge_cand++] = TAB_MVF_PU(A1); mergecandlist[0] = TAB_MVF_PU(A1);
if (merge_idx == 0)
return;
nb_merge_cand++;
}
// above spatial merge candidate // above spatial merge candidate
is_available_b1 = AVAILABLE(cand_up, B1); is_available_b1 = AVAILABLE(cand_up, B1);
@ -411,8 +416,12 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
if (is_available_b1 && is_available_b0) if (is_available_b1 && is_available_b0)
check_MER = !COMPARE_MV_REFIDX(B0, B1); check_MER = !COMPARE_MV_REFIDX(B0, B1);
if (is_available_b0 && check_MER) if (is_available_b0 && check_MER) {
mergecandlist[nb_merge_cand++] = TAB_MVF_PU(B0); mergecandlist[nb_merge_cand] = TAB_MVF_PU(B0);
if (merge_idx == nb_merge_cand)
return;
nb_merge_cand++;
}
// left bottom spatial merge candidate // left bottom spatial merge candidate
check_MER = 1; check_MER = 1;
@ -426,8 +435,12 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
if (is_available_a1 && is_available_a0) if (is_available_a1 && is_available_a0)
check_MER = !COMPARE_MV_REFIDX(A0, A1); check_MER = !COMPARE_MV_REFIDX(A0, A1);
if (is_available_a0 && check_MER) if (is_available_a0 && check_MER) {
mergecandlist[nb_merge_cand++] = TAB_MVF_PU(A0); mergecandlist[nb_merge_cand] = TAB_MVF_PU(A0);
if (merge_idx == nb_merge_cand)
return;
nb_merge_cand++;
}
// above left spatial merge candidate // above left spatial merge candidate
check_MER = 1; check_MER = 1;
@ -443,8 +456,12 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
if (is_available_b1 && is_available_b2) if (is_available_b1 && is_available_b2)
check_MER_1 = !COMPARE_MV_REFIDX(B2, B1); 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 && check_MER && check_MER_1 && nb_merge_cand != 4) {
mergecandlist[nb_merge_cand++] = TAB_MVF_PU(B2); mergecandlist[nb_merge_cand] = TAB_MVF_PU(B2);
if (merge_idx == nb_merge_cand)
return;
nb_merge_cand++;
}
// temporal motion vector candidate // temporal motion vector candidate
if (s->sh.slice_temporal_mvp_enabled_flag && if (s->sh.slice_temporal_mvp_enabled_flag &&
@ -468,6 +485,8 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
mergecandlist[nb_merge_cand].mv[1] = mv_l1_col; mergecandlist[nb_merge_cand].mv[1] = mv_l1_col;
mergecandlist[nb_merge_cand].ref_idx[1] = 0; mergecandlist[nb_merge_cand].ref_idx[1] = 0;
} }
if (merge_idx == nb_merge_cand)
return;
nb_merge_cand++; nb_merge_cand++;
} }
} }
@ -500,6 +519,8 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
mergecandlist[nb_merge_cand].mv[1].x = l1_cand.mv[1].x; mergecandlist[nb_merge_cand].mv[1].x = l1_cand.mv[1].x;
mergecandlist[nb_merge_cand].mv[1].y = l1_cand.mv[1].y; mergecandlist[nb_merge_cand].mv[1].y = l1_cand.mv[1].y;
mergecandlist[nb_merge_cand].is_intra = 0; mergecandlist[nb_merge_cand].is_intra = 0;
if (merge_idx == nb_merge_cand)
return;
nb_merge_cand++; nb_merge_cand++;
} }
} }
@ -517,6 +538,8 @@ static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
mergecandlist[nb_merge_cand].ref_idx[0] = zero_idx < nb_refs ? zero_idx : 0; mergecandlist[nb_merge_cand].ref_idx[0] = zero_idx < nb_refs ? zero_idx : 0;
mergecandlist[nb_merge_cand].ref_idx[1] = zero_idx < nb_refs ? zero_idx : 0; mergecandlist[nb_merge_cand].ref_idx[1] = zero_idx < nb_refs ? zero_idx : 0;
if (merge_idx == nb_merge_cand)
return;
nb_merge_cand++; nb_merge_cand++;
zero_idx++; zero_idx++;
} }
@ -547,7 +570,8 @@ void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0, int nPbW,
ff_hevc_set_neighbour_available(s, x0, y0, nPbW, nPbH); ff_hevc_set_neighbour_available(s, x0, y0, nPbW, nPbH);
derive_spatial_merge_candidates(s, x0, y0, nPbW, nPbH, log2_cb_size, derive_spatial_merge_candidates(s, x0, y0, nPbW, nPbH, log2_cb_size,
singleMCLFlag, part_idx, mergecand_list); singleMCLFlag, part_idx,
merge_idx, mergecand_list);
if (mergecand_list[merge_idx].pred_flag[0] == 1 && if (mergecand_list[merge_idx].pred_flag[0] == 1 &&
mergecand_list[merge_idx].pred_flag[1] == 1 && mergecand_list[merge_idx].pred_flag[1] == 1 &&