Merge commit 'ed53cc217f6a6e4ddb35e3f01a79496091dc82dc'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 12 Aug 2014 14:27:17 +0000 (16:27 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 12 Aug 2014 14:27:39 +0000 (16:27 +0200)
* commit 'ed53cc217f6a6e4ddb35e3f01a79496091dc82dc':
  hevc: derive partial merge list

Conflicts:
libavcodec/hevc_mvs.c

See: 4576eff05d94a5e0b853a7a595d31351cc539e7b
Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/hevc_mvs.c

@@@ -332,69 -376,90 +332,74 @@@ static void derive_spatial_merge_candid
          (lc->cu.part_mode == PART_Nx2N ||
           lc->cu.part_mode == PART_nLx2N ||
           lc->cu.part_mode == PART_nRx2N) ||
 -        isDiffMER(s, xA1, yA1, x0, y0)) {
 +        is_diff_mer(s, xA1, yA1, x0, y0)) {
          is_available_a1 = 0;
-             if (merge_idx == 0) return;
 +    } 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_diff_mer(s, xB1, yB1, x0, y0)) {
          is_available_b1 = 0;
-             if (merge_idx == nb_merge_cand) return;
 +    } 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;
 -    check_B0  = PRED_BLOCK_AVAILABLE(B0);
 -
 -    is_available_b0 = check_B0 && AVAILABLE(cand_up_right, B0);
 -
 -    if (isDiffMER(s, xB0, yB0, x0, y0))
 -        is_available_b0 = 0;
 +    is_available_b0 = AVAILABLE(cand_up_right, B0) &&
 +                      xB0 < s->sps->width &&
 +                      PRED_BLOCK_AVAILABLE(B0) &&
 +                      !is_diff_mer(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;
+         if (merge_idx == nb_merge_cand)
+             return;
          nb_merge_cand++;
      }
  
      // left bottom spatial merge candidate
 -    check_MER = 1;
 -    check_A0  = PRED_BLOCK_AVAILABLE(A0);
 -
 -    is_available_a0 = check_A0 && AVAILABLE(cand_bottom_left, A0);
 -
 -    if (isDiffMER(s, xA0, yA0, x0, y0))
 -        is_available_a0 = 0;
 +    is_available_a0 = AVAILABLE(cand_bottom_left, A0) &&
 +                      yA0 < s->sps->height &&
 +                      PRED_BLOCK_AVAILABLE(A0) &&
 +                      !is_diff_mer(s, xA0, yA0, x0, y0);
  
 -    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;
+         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);
 +    is_available_b2 = AVAILABLE(cand_up_left, B2) &&
 +                      !is_diff_mer(s, xB2, yB2, x0, y0);
  
 -    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;
+         if (merge_idx == nb_merge_cand)
+             return;
          nb_merge_cand++;
      }
  
              MvField l0_cand = mergecandlist[l0_cand_idx];
              MvField l1_cand = mergecandlist[l1_cand_idx];
  
 -            if (l0_cand.pred_flag[0] && l1_cand.pred_flag[1] &&
 +            if ((l0_cand.pred_flag & PF_L0) && (l1_cand.pred_flag & PF_L1) &&
                  (refPicList[0].list[l0_cand.ref_idx[0]] !=
                   refPicList[1].list[l1_cand.ref_idx[1]] ||
 -                 l0_cand.mv[0].x != l1_cand.mv[1].x ||
 -                 l0_cand.mv[0].y != l1_cand.mv[1].y)) {
 +                 AV_RN32A(&l0_cand.mv[0]) != AV_RN32A(&l1_cand.mv[1]))) {
                  mergecandlist[nb_merge_cand].ref_idx[0]   = l0_cand.ref_idx[0];
                  mergecandlist[nb_merge_cand].ref_idx[1]   = l1_cand.ref_idx[1];
 -                mergecandlist[nb_merge_cand].pred_flag[0] = 1;
 -                mergecandlist[nb_merge_cand].pred_flag[1] = 1;
 -                mergecandlist[nb_merge_cand].mv[0].x      = l0_cand.mv[0].x;
 -                mergecandlist[nb_merge_cand].mv[0].y      = l0_cand.mv[0].y;
 -                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].is_intra     = 0;
 +                mergecandlist[nb_merge_cand].pred_flag    = PF_BI;
 +                AV_COPY32(&mergecandlist[nb_merge_cand].mv[0], &l0_cand.mv[0]);
 +                AV_COPY32(&mergecandlist[nb_merge_cand].mv[1], &l1_cand.mv[1]);
-                 if (merge_idx == nb_merge_cand) return;
+                 if (merge_idx == nb_merge_cand)
+                     return;
                  nb_merge_cand++;
              }
          }