コード例 #1
0
ファイル: mvref_common.c プロジェクト: nwgat/Mirror-aom
void av1_find_best_ref_mvs(int allow_hp, int_mv *mvlist, int_mv *nearest_mv,
                            int_mv *near_mv) {
  int i;
  // Make sure all the candidates are properly clamped etc
  for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) {
    lower_mv_precision(&mvlist[i].as_mv, allow_hp);
  }
  *nearest_mv = mvlist[0];
  *near_mv = mvlist[1];
}
void vp9_find_best_ref_mvs(MACROBLOCKD *xd, int allow_hp,
                           int_mv *mvlist, int_mv *nearest, int_mv *near) {
  int i;
  // Make sure all the candidates are properly clamped etc
  for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) {
    lower_mv_precision(&mvlist[i].as_mv, allow_hp);
    clamp_mv2(&mvlist[i].as_mv, xd);
  }
  *nearest = mvlist[0];
  *near = mvlist[1];
}
コード例 #3
0
ファイル: mvref_common.c プロジェクト: nwgat/Mirror-aom
static int add_col_ref_mv(const AV1_COMMON *cm,
                          const MV_REF *prev_frame_mvs_base,
                          const MACROBLOCKD *xd,
                          int mi_row, int mi_col,
                          MV_REFERENCE_FRAME ref_frame,
                          int blk_row, int blk_col,
                          uint8_t *refmv_count,
                          CANDIDATE_MV *ref_mv_stack,
                          int16_t *mode_context) {
  const MV_REF *prev_frame_mvs =
      prev_frame_mvs_base + blk_row * cm->mi_cols + blk_col;
  POSITION mi_pos;
  int ref, idx;
  int coll_blk_count = 0;

  mi_pos.row = blk_row;
  mi_pos.col = blk_col;

  if (!is_inside(&xd->tile, mi_col, mi_row, cm->mi_rows, &mi_pos))
    return coll_blk_count;

  for (ref = 0; ref < 2; ++ref) {
    if (prev_frame_mvs->ref_frame[ref] == ref_frame) {
      int_mv this_refmv = prev_frame_mvs->mv[ref];
      lower_mv_precision(&this_refmv.as_mv, cm->allow_high_precision_mv);
      clamp_mv_ref(&this_refmv.as_mv,
                   xd->n8_w << 3, xd->n8_h << 3, xd);

      if (abs(this_refmv.as_mv.row) >= 16 ||
          abs(this_refmv.as_mv.col) >= 16)
        mode_context[ref_frame] |= (1 << ZEROMV_OFFSET);

      for (idx = 0; idx < *refmv_count; ++idx)
        if (this_refmv.as_int == ref_mv_stack[idx].this_mv.as_int)
          break;

      if (idx < *refmv_count)
        ref_mv_stack[idx].weight += 2;

      if (idx == *refmv_count &&
          *refmv_count < MAX_REF_MV_STACK_SIZE) {
        ref_mv_stack[idx].this_mv.as_int = this_refmv.as_int;
        ref_mv_stack[idx].pred_mv = prev_frame_mvs->pred_mv[ref];
        ref_mv_stack[idx].weight = 2;
        ++(*refmv_count);
      }

      ++coll_blk_count;
    }
  }

  return coll_blk_count;
}
コード例 #4
0
ファイル: mvref_common.c プロジェクト: nwgat/Mirror-aom
static uint8_t add_ref_mv_candidate(const MACROBLOCKD *xd,
                                    const MODE_INFO *const candidate_mi,
                                    const MB_MODE_INFO *const candidate,
                                    const MV_REFERENCE_FRAME rf[2],
                                    uint8_t *refmv_count,
                                    CANDIDATE_MV *ref_mv_stack,
                                    const int use_hp,
                                    int len, int block, int col) {
  int index = 0, ref;
  int newmv_count = 0;

  if (rf[1] == NONE) {
    // single reference frame
    for (ref = 0; ref < 2; ++ref) {
      if (candidate->ref_frame[ref] == rf[0]) {
        int_mv this_refmv =
            get_sub_block_mv(candidate_mi, ref, col, block);
        lower_mv_precision(&this_refmv.as_mv, use_hp);
        clamp_mv_ref(&this_refmv.as_mv,
                     xd->n8_w << 3, xd->n8_h << 3, xd);

        for (index = 0; index < *refmv_count; ++index)
          if (ref_mv_stack[index].this_mv.as_int == this_refmv.as_int)
            break;

        if (index < *refmv_count)
          ref_mv_stack[index].weight += 2 * len;

        // Add a new item to the list.
        if (index == *refmv_count) {
          ref_mv_stack[index].this_mv = this_refmv;
          ref_mv_stack[index].pred_mv =
              get_sub_block_pred_mv(candidate_mi, ref, col, block);
          ref_mv_stack[index].weight = 2 * len;
          ++(*refmv_count);

          if (candidate->mode == NEWMV)
            ++newmv_count;
        }

        if (candidate_mi->mbmi.sb_type < BLOCK_8X8 && block >= 0) {
          int alt_block = 3 - block;
          this_refmv =
              get_sub_block_mv(candidate_mi, ref, col, alt_block);
          lower_mv_precision(&this_refmv.as_mv, use_hp);
          clamp_mv_ref(&this_refmv.as_mv,
                       xd->n8_w << 3, xd->n8_h << 3, xd);

          for (index = 0; index < *refmv_count; ++index)
            if (ref_mv_stack[index].this_mv.as_int == this_refmv.as_int)
              break;

          if (index < *refmv_count)
            ref_mv_stack[index].weight += len;

          // Add a new item to the list.
          if (index == *refmv_count) {
            ref_mv_stack[index].this_mv = this_refmv;
            ref_mv_stack[index].pred_mv =
                get_sub_block_pred_mv(candidate_mi, ref, col, alt_block);
            ref_mv_stack[index].weight = len;
            ++(*refmv_count);

            if (candidate->mode == NEWMV)
              ++newmv_count;
          }
        }
      }
    }
  } else {
    // compound reference frame
    if (candidate->ref_frame[0] == rf[0] &&
        candidate->ref_frame[1] == rf[1]) {
      int_mv this_refmv[2] = {
          get_sub_block_mv(candidate_mi, 0, col, block),
          get_sub_block_mv(candidate_mi, 1, col, block)
      };

      for (ref = 0; ref < 2; ++ref) {
        lower_mv_precision(&this_refmv[ref].as_mv, use_hp);
        clamp_mv_ref(&this_refmv[ref].as_mv,
                     xd->n8_w << 3, xd->n8_h << 3, xd);
      }

      for (index = 0; index < *refmv_count; ++index)
        if ((ref_mv_stack[index].this_mv.as_int == this_refmv[0].as_int) &&
            (ref_mv_stack[index].comp_mv.as_int == this_refmv[1].as_int))
          break;

      if (index < *refmv_count)
        ref_mv_stack[index].weight += 2 * len;

      // Add a new item to the list.
      if (index == *refmv_count) {
        ref_mv_stack[index].this_mv = this_refmv[0];
        ref_mv_stack[index].comp_mv = this_refmv[1];
        ref_mv_stack[index].weight = 2 * len;
        ++(*refmv_count);

        if (candidate->mode == NEWMV)
          ++newmv_count;
      }

      if (candidate_mi->mbmi.sb_type < BLOCK_8X8 && block >= 0) {
        int alt_block = 3 - block;
        this_refmv[0] = get_sub_block_mv(candidate_mi, 0, col, alt_block);
        this_refmv[1] = get_sub_block_mv(candidate_mi, 1, col, alt_block);

        for (ref = 0; ref < 2; ++ref) {
          lower_mv_precision(&this_refmv[ref].as_mv, use_hp);
          clamp_mv_ref(&this_refmv[ref].as_mv,
                       xd->n8_w << 3, xd->n8_h << 3, xd);
        }

        for (index = 0; index < *refmv_count; ++index)
          if (ref_mv_stack[index].this_mv.as_int == this_refmv[0].as_int &&
              ref_mv_stack[index].comp_mv.as_int == this_refmv[1].as_int)
            break;

        if (index < *refmv_count)
          ref_mv_stack[index].weight += len;

        // Add a new item to the list.
        if (index == *refmv_count) {
          ref_mv_stack[index].this_mv = this_refmv[0];
          ref_mv_stack[index].comp_mv = this_refmv[1];
          ref_mv_stack[index].weight = len;
          ++(*refmv_count);

          if (candidate->mode == NEWMV)
            ++newmv_count;
        }
      }
    }
  }
  return newmv_count;
}