summaryrefslogtreecommitdiff
path: root/libavcodec/hevc_mvs.c
diff options
context:
space:
mode:
authorMickaƫl Raulet <mraulet@insa-rennes.fr>2014-07-19 01:12:24 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-07-22 14:17:19 +0200
commitc4d63cd230b7067d5d0918e2895b26ac57b552a7 (patch)
tree5430e8ba7e577a249f6a6c0407b998c409ced98a /libavcodec/hevc_mvs.c
parente9bb45ba7905dea68f44209aa15e0911895e39ea (diff)
downloadffmpeg-c4d63cd230b7067d5d0918e2895b26ac57b552a7.tar.gz
hevc/mvs: simplifying derive_spatial_merge_candidates function
cherry picked from commit 99be11cf08a5628d0bb6ac7f4958bf9dd35cda62 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/hevc_mvs.c')
-rw-r--r--libavcodec/hevc_mvs.c81
1 files changed, 29 insertions, 52 deletions
diff --git a/libavcodec/hevc_mvs.c b/libavcodec/hevc_mvs.c
index a09f70aca1..b2c0bcad0a 100644
--- a/libavcodec/hevc_mvs.c
+++ b/libavcodec/hevc_mvs.c
@@ -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);
-
- if (isDiffMER(s, xB0, yB0, x0, y0))
- is_available_b0 = 0;
+ PRED_BLOCK_AVAILABLE(B0) &&
+ !isDiffMER(s, xB0, yB0, x0, y0);
- 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);
-
- 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);
+ is_available_b2 = AVAILABLE(cand_up_left, B2) &&
+ !isDiffMER(s, xB2, yB2, x0, y0);
- 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++;