| 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 | 11 |
| 12 #ifndef __INC_FINDNEARMV_H | 12 #ifndef __INC_FINDNEARMV_H |
| 13 #define __INC_FINDNEARMV_H | 13 #define __INC_FINDNEARMV_H |
| 14 | 14 |
| 15 #include "mv.h" | 15 #include "mv.h" |
| 16 #include "blockd.h" | 16 #include "blockd.h" |
| 17 #include "modecont.h" | 17 #include "modecont.h" |
| 18 #include "treecoder.h" | 18 #include "treecoder.h" |
| 19 | 19 |
| 20 typedef union | |
| 21 { | |
| 22 unsigned int as_int; | |
| 23 MV as_mv; | |
| 24 } int_mv; /* facilitates rapid equality tests */ | |
| 25 | 20 |
| 26 static void mv_bias(int refmb_ref_frame_sign_bias, int refframe, int_mv *mvp, co
nst int *ref_frame_sign_bias) | 21 static void mv_bias(int refmb_ref_frame_sign_bias, int refframe, int_mv *mvp, co
nst int *ref_frame_sign_bias) |
| 27 { | 22 { |
| 28 MV xmv; | 23 MV xmv; |
| 29 xmv = mvp->as_mv; | 24 xmv = mvp->as_mv; |
| 30 | 25 |
| 31 if (refmb_ref_frame_sign_bias != ref_frame_sign_bias[refframe]) | 26 if (refmb_ref_frame_sign_bias != ref_frame_sign_bias[refframe]) |
| 32 { | 27 { |
| 33 xmv.row *= -1; | 28 xmv.row *= -1; |
| 34 xmv.col *= -1; | 29 xmv.col *= -1; |
| 35 } | 30 } |
| 36 | 31 |
| 37 mvp->as_mv = xmv; | 32 mvp->as_mv = xmv; |
| 38 } | 33 } |
| 39 | 34 |
| 40 #define LEFT_TOP_MARGIN (16 << 3) | 35 #define LEFT_TOP_MARGIN (16 << 3) |
| 41 #define RIGHT_BOTTOM_MARGIN (16 << 3) | 36 #define RIGHT_BOTTOM_MARGIN (16 << 3) |
| 42 static void vp8_clamp_mv(MV *mv, const MACROBLOCKD *xd) | 37 static void vp8_clamp_mv2(int_mv *mv, const MACROBLOCKD *xd) |
| 43 { | 38 { |
| 44 if (mv->col < (xd->mb_to_left_edge - LEFT_TOP_MARGIN)) | 39 if (mv->as_mv.col < (xd->mb_to_left_edge - LEFT_TOP_MARGIN)) |
| 45 mv->col = xd->mb_to_left_edge - LEFT_TOP_MARGIN; | 40 mv->as_mv.col = xd->mb_to_left_edge - LEFT_TOP_MARGIN; |
| 46 else if (mv->col > xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN) | 41 else if (mv->as_mv.col > xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN) |
| 47 mv->col = xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN; | 42 mv->as_mv.col = xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN; |
| 48 | 43 |
| 49 if (mv->row < (xd->mb_to_top_edge - LEFT_TOP_MARGIN)) | 44 if (mv->as_mv.row < (xd->mb_to_top_edge - LEFT_TOP_MARGIN)) |
| 50 mv->row = xd->mb_to_top_edge - LEFT_TOP_MARGIN; | 45 mv->as_mv.row = xd->mb_to_top_edge - LEFT_TOP_MARGIN; |
| 51 else if (mv->row > xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN) | 46 else if (mv->as_mv.row > xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN) |
| 52 mv->row = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN; | 47 mv->as_mv.row = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN; |
| 48 } |
| 49 |
| 50 static void vp8_clamp_mv(int_mv *mv, int mb_to_left_edge, int mb_to_right_edge, |
| 51 int mb_to_top_edge, int mb_to_bottom_edge) |
| 52 { |
| 53 mv->as_mv.col = (mv->as_mv.col < mb_to_left_edge) ? |
| 54 mb_to_left_edge : mv->as_mv.col; |
| 55 mv->as_mv.col = (mv->as_mv.col > mb_to_right_edge) ? |
| 56 mb_to_right_edge : mv->as_mv.col; |
| 57 mv->as_mv.row = (mv->as_mv.row < mb_to_top_edge) ? |
| 58 mb_to_top_edge : mv->as_mv.row; |
| 59 mv->as_mv.row = (mv->as_mv.row > mb_to_bottom_edge) ? |
| 60 mb_to_bottom_edge : mv->as_mv.row; |
| 61 } |
| 62 static unsigned int vp8_check_mv_bounds(int_mv *mv, int mb_to_left_edge, |
| 63 int mb_to_right_edge, int mb_to_top_edge, |
| 64 int mb_to_bottom_edge) |
| 65 { |
| 66 unsigned int need_to_clamp; |
| 67 need_to_clamp = (mv->as_mv.col < mb_to_left_edge) ? 1 : 0; |
| 68 need_to_clamp |= (mv->as_mv.col > mb_to_right_edge) ? 1 : 0; |
| 69 need_to_clamp |= (mv->as_mv.row < mb_to_top_edge) ? 1 : 0; |
| 70 need_to_clamp |= (mv->as_mv.row > mb_to_bottom_edge) ? 1 : 0; |
| 71 return need_to_clamp; |
| 53 } | 72 } |
| 54 | 73 |
| 55 void vp8_find_near_mvs | 74 void vp8_find_near_mvs |
| 56 ( | 75 ( |
| 57 MACROBLOCKD *xd, | 76 MACROBLOCKD *xd, |
| 58 const MODE_INFO *here, | 77 const MODE_INFO *here, |
| 59 MV *nearest, MV *nearby, MV *best, | 78 int_mv *nearest, int_mv *nearby, int_mv *best, |
| 60 int near_mv_ref_cts[4], | 79 int near_mv_ref_cts[4], |
| 61 int refframe, | 80 int refframe, |
| 62 int *ref_frame_sign_bias | 81 int *ref_frame_sign_bias |
| 63 ); | 82 ); |
| 64 | 83 |
| 65 vp8_prob *vp8_mv_ref_probs( | 84 vp8_prob *vp8_mv_ref_probs( |
| 66 vp8_prob p[VP8_MVREFS-1], const int near_mv_ref_ct[4] | 85 vp8_prob p[VP8_MVREFS-1], const int near_mv_ref_ct[4] |
| 67 ); | 86 ); |
| 68 | 87 |
| 69 const B_MODE_INFO *vp8_left_bmi(const MODE_INFO *cur_mb, int b); | |
| 70 | |
| 71 const B_MODE_INFO *vp8_above_bmi(const MODE_INFO *cur_mb, int b, int mi_stride); | |
| 72 | |
| 73 extern const unsigned char vp8_mbsplit_offset[4][16]; | 88 extern const unsigned char vp8_mbsplit_offset[4][16]; |
| 74 | 89 |
| 90 |
| 91 static int left_block_mv(const MODE_INFO *cur_mb, int b) |
| 92 { |
| 93 if (!(b & 3)) |
| 94 { |
| 95 /* On L edge, get from MB to left of us */ |
| 96 --cur_mb; |
| 97 |
| 98 if(cur_mb->mbmi.mode != SPLITMV) |
| 99 return cur_mb->mbmi.mv.as_int; |
| 100 b += 4; |
| 101 } |
| 102 |
| 103 return (cur_mb->bmi + b - 1)->mv.as_int; |
| 104 } |
| 105 |
| 106 static int above_block_mv(const MODE_INFO *cur_mb, int b, int mi_stride) |
| 107 { |
| 108 if (!(b >> 2)) |
| 109 { |
| 110 /* On top edge, get from MB above us */ |
| 111 cur_mb -= mi_stride; |
| 112 |
| 113 if(cur_mb->mbmi.mode != SPLITMV) |
| 114 return cur_mb->mbmi.mv.as_int; |
| 115 b += 16; |
| 116 } |
| 117 |
| 118 return (cur_mb->bmi + b - 4)->mv.as_int; |
| 119 } |
| 120 static B_PREDICTION_MODE left_block_mode(const MODE_INFO *cur_mb, int b) |
| 121 { |
| 122 if (!(b & 3)) |
| 123 { |
| 124 /* On L edge, get from MB to left of us */ |
| 125 --cur_mb; |
| 126 switch (cur_mb->mbmi.mode) |
| 127 { |
| 128 case B_PRED: |
| 129 return (cur_mb->bmi + b + 3)->as_mode; |
| 130 case DC_PRED: |
| 131 return B_DC_PRED; |
| 132 case V_PRED: |
| 133 return B_VE_PRED; |
| 134 case H_PRED: |
| 135 return B_HE_PRED; |
| 136 case TM_PRED: |
| 137 return B_TM_PRED; |
| 138 default: |
| 139 return B_DC_PRED; |
| 140 } |
| 141 } |
| 142 |
| 143 return (cur_mb->bmi + b - 1)->as_mode; |
| 144 } |
| 145 |
| 146 static B_PREDICTION_MODE above_block_mode(const MODE_INFO *cur_mb, int b, int mi
_stride) |
| 147 { |
| 148 if (!(b >> 2)) |
| 149 { |
| 150 /* On top edge, get from MB above us */ |
| 151 cur_mb -= mi_stride; |
| 152 |
| 153 switch (cur_mb->mbmi.mode) |
| 154 { |
| 155 case B_PRED: |
| 156 return (cur_mb->bmi + b + 12)->as_mode; |
| 157 case DC_PRED: |
| 158 return B_DC_PRED; |
| 159 case V_PRED: |
| 160 return B_VE_PRED; |
| 161 case H_PRED: |
| 162 return B_HE_PRED; |
| 163 case TM_PRED: |
| 164 return B_TM_PRED; |
| 165 default: |
| 166 return B_DC_PRED; |
| 167 } |
| 168 } |
| 169 |
| 170 return (cur_mb->bmi + b - 4)->as_mode; |
| 171 } |
| 172 |
| 75 #endif | 173 #endif |
| OLD | NEW |