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