| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <limits.h> | |
| 12 | |
| 13 #include "vp9/common/vp9_findnearmv.h" | 11 #include "vp9/common/vp9_findnearmv.h" |
| 14 #include "vp9/common/vp9_mvref_common.h" | 12 #include "vp9/common/vp9_mvref_common.h" |
| 15 #include "vp9/common/vp9_sadmxn.h" | |
| 16 | 13 |
| 17 static void lower_mv_precision(int_mv *mv, int usehp) { | 14 static void lower_mv_precision(MV *mv, int allow_hp) { |
| 18 if (!usehp || !vp9_use_mv_hp(&mv->as_mv)) { | 15 const int use_hp = allow_hp && vp9_use_mv_hp(mv); |
| 19 if (mv->as_mv.row & 1) | 16 if (!use_hp) { |
| 20 mv->as_mv.row += (mv->as_mv.row > 0 ? -1 : 1); | 17 if (mv->row & 1) |
| 21 if (mv->as_mv.col & 1) | 18 mv->row += (mv->row > 0 ? -1 : 1); |
| 22 mv->as_mv.col += (mv->as_mv.col > 0 ? -1 : 1); | 19 if (mv->col & 1) |
| 20 mv->col += (mv->col > 0 ? -1 : 1); |
| 23 } | 21 } |
| 24 } | 22 } |
| 25 | 23 |
| 26 | 24 |
| 27 void vp9_find_best_ref_mvs(MACROBLOCKD *xd, | 25 void vp9_find_best_ref_mvs(MACROBLOCKD *xd, |
| 28 int_mv *mvlist, | 26 int_mv *mvlist, |
| 29 int_mv *nearest, | 27 int_mv *nearest, |
| 30 int_mv *near) { | 28 int_mv *near) { |
| 31 int i; | 29 int i; |
| 32 // Make sure all the candidates are properly clamped etc | 30 // Make sure all the candidates are properly clamped etc |
| 33 for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) { | 31 for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) { |
| 34 lower_mv_precision(&mvlist[i], xd->allow_high_precision_mv); | 32 lower_mv_precision(&mvlist[i].as_mv, xd->allow_high_precision_mv); |
| 35 clamp_mv2(&mvlist[i], xd); | 33 clamp_mv2(&mvlist[i].as_mv, xd); |
| 36 } | 34 } |
| 37 *nearest = mvlist[0]; | 35 *nearest = mvlist[0]; |
| 38 *near = mvlist[1]; | 36 *near = mvlist[1]; |
| 39 } | 37 } |
| 40 | 38 |
| 41 void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd, | 39 void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd, |
| 42 int_mv *dst_nearest, | 40 int_mv *dst_nearest, |
| 43 int_mv *dst_near, | 41 int_mv *dst_near, |
| 44 int block_idx, int ref_idx) { | 42 int block_idx, int ref_idx, |
| 43 int mi_row, int mi_col) { |
| 45 int_mv dst_list[MAX_MV_REF_CANDIDATES]; | 44 int_mv dst_list[MAX_MV_REF_CANDIDATES]; |
| 46 int_mv mv_list[MAX_MV_REF_CANDIDATES]; | 45 int_mv mv_list[MAX_MV_REF_CANDIDATES]; |
| 47 MODE_INFO *mi = xd->mode_info_context; | 46 MODE_INFO *const mi = xd->mode_info_context; |
| 48 MB_MODE_INFO *const mbmi = &mi->mbmi; | |
| 49 | 47 |
| 50 assert(ref_idx == 0 || ref_idx == 1); | 48 assert(ref_idx == 0 || ref_idx == 1); |
| 51 assert(MAX_MV_REF_CANDIDATES == 2); // makes code here slightly easier | 49 assert(MAX_MV_REF_CANDIDATES == 2); // makes code here slightly easier |
| 52 | 50 |
| 53 vp9_find_mv_refs_idx(cm, xd, xd->mode_info_context, | 51 vp9_find_mv_refs_idx(cm, xd, mi, xd->prev_mode_info_context, |
| 54 xd->prev_mode_info_context, | 52 mi->mbmi.ref_frame[ref_idx], |
| 55 mbmi->ref_frame[ref_idx], | 53 mv_list, block_idx, mi_row, mi_col); |
| 56 mv_list, cm->ref_frame_sign_bias, block_idx); | |
| 57 | 54 |
| 58 dst_list[1].as_int = 0; | 55 dst_list[1].as_int = 0; |
| 59 if (block_idx == 0) { | 56 if (block_idx == 0) { |
| 60 memcpy(dst_list, mv_list, MAX_MV_REF_CANDIDATES * sizeof(int_mv)); | 57 memcpy(dst_list, mv_list, MAX_MV_REF_CANDIDATES * sizeof(int_mv)); |
| 61 } else if (block_idx == 1 || block_idx == 2) { | 58 } else if (block_idx == 1 || block_idx == 2) { |
| 62 int dst = 0, n; | 59 int dst = 0, n; |
| 63 union b_mode_info *bmi = mi->bmi; | 60 union b_mode_info *bmi = mi->bmi; |
| 64 | 61 |
| 65 dst_list[dst++].as_int = bmi[0].as_mv[ref_idx].as_int; | 62 dst_list[dst++].as_int = bmi[0].as_mv[ref_idx].as_int; |
| 66 for (n = 0; dst < MAX_MV_REF_CANDIDATES && | 63 for (n = 0; dst < MAX_MV_REF_CANDIDATES && |
| (...skipping 13 matching lines...) Expand all Loading... |
| 80 dst_list[dst++].as_int = bmi[0].as_mv[ref_idx].as_int; | 77 dst_list[dst++].as_int = bmi[0].as_mv[ref_idx].as_int; |
| 81 for (n = 0; dst < MAX_MV_REF_CANDIDATES && | 78 for (n = 0; dst < MAX_MV_REF_CANDIDATES && |
| 82 n < MAX_MV_REF_CANDIDATES; n++) | 79 n < MAX_MV_REF_CANDIDATES; n++) |
| 83 if (mv_list[n].as_int != dst_list[0].as_int) | 80 if (mv_list[n].as_int != dst_list[0].as_int) |
| 84 dst_list[dst++].as_int = mv_list[n].as_int; | 81 dst_list[dst++].as_int = mv_list[n].as_int; |
| 85 } | 82 } |
| 86 | 83 |
| 87 dst_nearest->as_int = dst_list[0].as_int; | 84 dst_nearest->as_int = dst_list[0].as_int; |
| 88 dst_near->as_int = dst_list[1].as_int; | 85 dst_near->as_int = dst_list[1].as_int; |
| 89 } | 86 } |
| OLD | NEW |