26 |
* along with this program; if not, write to the xvid_free Software |
* along with this program; if not, write to the xvid_free Software |
27 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
28 |
* |
* |
29 |
* $Id: mbprediction.h,v 1.12 2002-07-03 12:32:50 suxen_drol Exp $ |
* $Id: mbprediction.h,v 1.15 2002-09-08 17:25:10 edgomez Exp $ |
30 |
* |
* |
31 |
*************************************************************************/ |
*************************************************************************/ |
32 |
|
|
|
/****************************************************************************** |
|
|
* * |
|
|
* Revision history: * |
|
|
* * |
|
|
* 29.06.2002 get_pmvdata() bounding * |
|
|
* * |
|
|
******************************************************************************/ |
|
|
|
|
|
|
|
33 |
#ifndef _MBPREDICTION_H_ |
#ifndef _MBPREDICTION_H_ |
34 |
#define _MBPREDICTION_H_ |
#define _MBPREDICTION_H_ |
35 |
|
|
45 |
|
|
46 |
#define MVequal(A,B) ( ((A).x)==((B).x) && ((A).y)==((B).y) ) |
#define MVequal(A,B) ( ((A).x)==((B).x) && ((A).y)==((B).y) ) |
47 |
|
|
48 |
|
/***************************************************************************** |
49 |
|
* Prototypes |
50 |
|
****************************************************************************/ |
51 |
|
|
52 |
void MBPrediction(FRAMEINFO * frame, /* <-- The parameter for ACDC and MV prediction */ |
void MBPrediction(FRAMEINFO * frame, /* <-- The parameter for ACDC and MV prediction */ |
53 |
|
|
54 |
uint32_t x_pos, /* <-- The x position of the MB to be searched */ |
uint32_t x_pos, /* <-- The x position of the MB to be searched */ |
78 |
const int bound); |
const int bound); |
79 |
|
|
80 |
|
|
81 |
/* get_pmvdata returns the median predictor and nothing else */ |
/***************************************************************************** |
82 |
|
* Inlined functions |
83 |
static __inline VECTOR |
****************************************************************************/ |
|
get_pmv(const MACROBLOCK * const pMBs, |
|
|
const uint32_t x, |
|
|
const uint32_t y, |
|
|
const uint32_t x_dim, |
|
|
const uint32_t block) |
|
|
{ |
|
|
|
|
|
int xin1, xin2, xin3; |
|
|
int yin1, yin2, yin3; |
|
|
int vec1, vec2, vec3; |
|
|
VECTOR lneigh, tneigh, trneigh; /* left neighbour, top neighbour, topright neighbour */ |
|
|
VECTOR median; |
|
|
|
|
|
static VECTOR zeroMV = { 0, 0 }; |
|
|
uint32_t index = x + y * x_dim; |
|
|
|
|
|
/* first row (special case) */ |
|
|
if (y == 0 && (block == 0 || block == 1)) { |
|
|
if ((x == 0) && (block == 0)) // first column, first block |
|
|
{ |
|
|
return zeroMV; |
|
|
} |
|
|
if (block == 1) // second block; has only a left neighbour |
|
|
{ |
|
|
return pMBs[index].mvs[0]; |
|
|
} else { /* block==0, but x!=0, so again, there is a left neighbour */ |
|
|
|
|
|
return pMBs[index - 1].mvs[1]; |
|
|
} |
|
|
} |
|
84 |
|
|
85 |
/* |
/* |
86 |
* MODE_INTER, vm18 page 48 |
* MODE_INTER, vm18 page 48 |
95 |
* [ | 3 ] [ 2 | 3 ] [ | ] |
* [ | 3 ] [ 2 | 3 ] [ | ] |
96 |
*/ |
*/ |
97 |
|
|
98 |
|
static __inline VECTOR |
99 |
|
get_pmv2(const MACROBLOCK * const mbs, |
100 |
|
const int mb_width, |
101 |
|
const int bound, |
102 |
|
const int x, |
103 |
|
const int y, |
104 |
|
const int block) |
105 |
|
{ |
106 |
|
static const VECTOR zeroMV = { 0, 0 }; |
107 |
|
|
108 |
|
int lx, ly, lz; /* left */ |
109 |
|
int tx, ty, tz; /* top */ |
110 |
|
int rx, ry, rz; /* top-right */ |
111 |
|
int lpos, tpos, rpos; |
112 |
|
int num_cand, last_cand; |
113 |
|
|
114 |
|
VECTOR pmv[4]; /* left neighbour, top neighbour, top-right neighbour */ |
115 |
|
|
116 |
switch (block) { |
switch (block) { |
117 |
case 0: |
case 0: |
118 |
xin1 = x - 1; |
lx = x - 1; ly = y; lz = 1; |
119 |
yin1 = y; |
tx = x; ty = y - 1; tz = 2; |
120 |
vec1 = 1; /* left */ |
rx = x + 1; ry = y - 1; rz = 2; |
|
xin2 = x; |
|
|
yin2 = y - 1; |
|
|
vec2 = 2; /* top */ |
|
|
xin3 = x + 1; |
|
|
yin3 = y - 1; |
|
|
vec3 = 2; /* top right */ |
|
121 |
break; |
break; |
122 |
case 1: |
case 1: |
123 |
xin1 = x; |
lx = x; ly = y; lz = 0; |
124 |
yin1 = y; |
tx = x; ty = y - 1; tz = 3; |
125 |
vec1 = 0; |
rx = x + 1; ry = y - 1; rz = 2; |
|
xin2 = x; |
|
|
yin2 = y - 1; |
|
|
vec2 = 3; |
|
|
xin3 = x + 1; |
|
|
yin3 = y - 1; |
|
|
vec3 = 2; |
|
126 |
break; |
break; |
127 |
case 2: |
case 2: |
128 |
xin1 = x - 1; |
lx = x - 1; ly = y; lz = 3; |
129 |
yin1 = y; |
tx = x; ty = y; tz = 0; |
130 |
vec1 = 3; |
rx = x; ry = y; rz = 1; |
|
xin2 = x; |
|
|
yin2 = y; |
|
|
vec2 = 0; |
|
|
xin3 = x; |
|
|
yin3 = y; |
|
|
vec3 = 1; |
|
131 |
break; |
break; |
132 |
default: |
default: |
133 |
xin1 = x; |
lx = x; ly = y; lz = 2; |
134 |
yin1 = y; |
tx = x; ty = y; tz = 0; |
135 |
vec1 = 2; |
rx = x; ry = y; rz = 1; |
|
xin2 = x; |
|
|
yin2 = y; |
|
|
vec2 = 0; |
|
|
xin3 = x; |
|
|
yin3 = y; |
|
|
vec3 = 1; |
|
136 |
} |
} |
137 |
|
|
138 |
|
lpos = lx + ly * mb_width; |
139 |
|
rpos = rx + ry * mb_width; |
140 |
|
tpos = tx + ty * mb_width; |
141 |
|
last_cand = num_cand = 0; |
142 |
|
|
143 |
if (xin1 < 0 || /* yin1 < 0 || */ xin1 >= (int32_t) x_dim) { |
if (lpos >= bound && lx >= 0) { |
144 |
lneigh = zeroMV; |
num_cand++; |
145 |
|
last_cand = 1; |
146 |
|
pmv[1] = mbs[lpos].mvs[lz]; |
147 |
} else { |
} else { |
148 |
lneigh = pMBs[xin1 + yin1 * x_dim].mvs[vec1]; |
pmv[1] = zeroMV; |
149 |
} |
} |
150 |
|
|
151 |
if (xin2 < 0 || /* yin2 < 0 || */ xin2 >= (int32_t) x_dim) { |
if (tpos >= bound) { |
152 |
tneigh = zeroMV; |
num_cand++; |
153 |
|
last_cand = 2; |
154 |
|
pmv[2] = mbs[tpos].mvs[tz]; |
155 |
} else { |
} else { |
156 |
tneigh = pMBs[xin2 + yin2 * x_dim].mvs[vec2]; |
pmv[2] = zeroMV; |
157 |
} |
} |
158 |
|
|
159 |
if (xin3 < 0 || /* yin3 < 0 || */ xin3 >= (int32_t) x_dim) { |
if (rpos >= bound && rx < mb_width) { |
160 |
trneigh = zeroMV; |
num_cand++; |
161 |
|
last_cand = 3; |
162 |
|
pmv[3] = mbs[rpos].mvs[rz]; |
163 |
} else { |
} else { |
164 |
trneigh = pMBs[xin3 + yin3 * x_dim].mvs[vec3]; |
pmv[3] = zeroMV; |
165 |
} |
} |
166 |
|
|
167 |
/* median,minimum */ |
/* |
168 |
|
* If there're more than one candidate, we return the median vector |
169 |
|
* edgomez : the special case "no candidates" is handled the same way |
170 |
|
* because all vectors are set to zero. So the median vector |
171 |
|
* is {0,0}, and this is exactly the vector we must return |
172 |
|
* according to the mpeg4 specs. |
173 |
|
*/ |
174 |
|
|
175 |
median.x = |
if (num_cand != 1) { |
176 |
MIN(MAX(lneigh.x, tneigh.x), |
/* set median */ |
177 |
MIN(MAX(tneigh.x, trneigh.x), MAX(lneigh.x, trneigh.x))); |
|
178 |
median.y = |
pmv[0].x = |
179 |
MIN(MAX(lneigh.y, tneigh.y), |
MIN(MAX(pmv[1].x, pmv[2].x), |
180 |
MIN(MAX(tneigh.y, trneigh.y), MAX(lneigh.y, trneigh.y))); |
MIN(MAX(pmv[2].x, pmv[3].x), MAX(pmv[1].x, pmv[3].x))); |
181 |
return median; |
pmv[0].y = |
182 |
|
MIN(MAX(pmv[1].y, pmv[2].y), |
183 |
|
MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y))); |
184 |
|
return pmv[0]; |
185 |
} |
} |
186 |
|
|
187 |
|
return pmv[last_cand]; /* no point calculating median mv */ |
188 |
|
} |
189 |
|
|
|
/* This is somehow a copy of get_pmv, but returning all MVs and Minimum SAD |
|
|
instead of only Median MV */ |
|
190 |
|
|
|
static __inline int |
|
|
get_pmvdata(const MACROBLOCK * const pMBs, |
|
|
const uint32_t x, |
|
|
const uint32_t y, |
|
|
const uint32_t x_dim, |
|
|
const uint32_t block, |
|
|
VECTOR * const pmv, |
|
|
int32_t * const psad) |
|
|
{ |
|
191 |
|
|
192 |
/* |
/* |
193 |
* pmv are filled with: |
* pmv are filled with: |
202 |
* [3]: topright neighbour's SAD |
* [3]: topright neighbour's SAD |
203 |
*/ |
*/ |
204 |
|
|
205 |
int xin1, xin2, xin3; |
static __inline int |
206 |
int yin1, yin2, yin3; |
get_pmvdata2(const MACROBLOCK * const mbs, |
207 |
int vec1, vec2, vec3; |
const int mb_width, |
208 |
|
const int bound, |
209 |
uint32_t index = x + y * x_dim; |
const int x, |
210 |
const VECTOR zeroMV = { 0, 0 }; |
const int y, |
211 |
|
const int block, |
212 |
// first row of blocks (special case) |
VECTOR * const pmv, |
213 |
if (y == 0 && (block == 0 || block == 1)) { |
int32_t * const psad) |
|
if ((x == 0) && (block == 0)) // first column, first block |
|
|
{ |
|
|
pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV; |
|
|
psad[0] = 0; |
|
|
psad[1] = psad[2] = psad[3] = MV_MAX_ERROR; |
|
|
return 0; |
|
|
} |
|
|
if (block == 1) // second block; has only a left neighbour |
|
214 |
{ |
{ |
215 |
pmv[0] = pmv[1] = pMBs[index].mvs[0]; |
static const VECTOR zeroMV = { 0, 0 }; |
|
pmv[2] = pmv[3] = zeroMV; |
|
|
psad[0] = psad[1] = pMBs[index].sad8[0]; |
|
|
psad[2] = psad[3] = MV_MAX_ERROR; |
|
|
return 0; |
|
|
} else { /* block==0, but x!=0, so again, there is a left neighbour */ |
|
|
|
|
|
pmv[0] = pmv[1] = pMBs[index - 1].mvs[1]; |
|
|
pmv[2] = pmv[3] = zeroMV; |
|
|
psad[0] = psad[1] = pMBs[index - 1].sad8[1]; |
|
|
psad[2] = psad[3] = MV_MAX_ERROR; |
|
|
return 0; |
|
|
} |
|
|
} |
|
216 |
|
|
217 |
/* |
int lx, ly, lz; /* left */ |
218 |
* MODE_INTER, vm18 page 48 |
int tx, ty, tz; /* top */ |
219 |
* MODE_INTER4V vm18 page 51 |
int rx, ry, rz; /* top-right */ |
220 |
* |
int lpos, tpos, rpos; |
221 |
* (x,y-1) (x+1,y-1) |
int num_cand, last_cand; |
|
* [ | ] [ | ] |
|
|
* [ 2 | 3 ] [ 2 | ] |
|
|
* |
|
|
* (x-1,y) (x,y) (x+1,y) |
|
|
* [ | 1 ] [ 0 | 1 ] [ 0 | ] |
|
|
* [ | 3 ] [ 2 | 3 ] [ | ] |
|
|
*/ |
|
222 |
|
|
223 |
switch (block) { |
switch (block) { |
224 |
case 0: |
case 0: |
225 |
xin1 = x - 1; |
lx = x - 1; ly = y; lz = 1; |
226 |
yin1 = y; |
tx = x; ty = y - 1; tz = 2; |
227 |
vec1 = 1; /* left */ |
rx = x + 1; ry = y - 1; rz = 2; |
|
xin2 = x; |
|
|
yin2 = y - 1; |
|
|
vec2 = 2; /* top */ |
|
|
xin3 = x + 1; |
|
|
yin3 = y - 1; |
|
|
vec3 = 2; /* top right */ |
|
228 |
break; |
break; |
229 |
case 1: |
case 1: |
230 |
xin1 = x; |
lx = x; ly = y; lz = 0; |
231 |
yin1 = y; |
tx = x; ty = y - 1; tz = 3; |
232 |
vec1 = 0; |
rx = x + 1; ry = y - 1; rz = 2; |
|
xin2 = x; |
|
|
yin2 = y - 1; |
|
|
vec2 = 3; |
|
|
xin3 = x + 1; |
|
|
yin3 = y - 1; |
|
|
vec3 = 2; |
|
233 |
break; |
break; |
234 |
case 2: |
case 2: |
235 |
xin1 = x - 1; |
lx = x - 1; ly = y; lz = 3; |
236 |
yin1 = y; |
tx = x; ty = y; tz = 0; |
237 |
vec1 = 3; |
rx = x; ry = y; rz = 1; |
|
xin2 = x; |
|
|
yin2 = y; |
|
|
vec2 = 0; |
|
|
xin3 = x; |
|
|
yin3 = y; |
|
|
vec3 = 1; |
|
238 |
break; |
break; |
239 |
default: |
default: |
240 |
xin1 = x; |
lx = x; ly = y; lz = 2; |
241 |
yin1 = y; |
tx = x; ty = y; tz = 0; |
242 |
vec1 = 2; |
rx = x; ry = y; rz = 1; |
|
xin2 = x; |
|
|
yin2 = y; |
|
|
vec2 = 0; |
|
|
xin3 = x; |
|
|
yin3 = y; |
|
|
vec3 = 1; |
|
243 |
} |
} |
244 |
|
|
245 |
|
lpos = lx + ly * mb_width; |
246 |
|
rpos = rx + ry * mb_width; |
247 |
|
tpos = tx + ty * mb_width; |
248 |
|
last_cand = num_cand = 0; |
249 |
|
|
250 |
if (xin1 < 0 || xin1 >= (int32_t) x_dim) { |
if (lpos >= bound && lx >= 0) { |
251 |
|
num_cand++; |
252 |
|
last_cand = 1; |
253 |
|
pmv[1] = mbs[lpos].mvs[lz]; |
254 |
|
psad[1] = mbs[lpos].sad8[lz]; |
255 |
|
} else { |
256 |
pmv[1] = zeroMV; |
pmv[1] = zeroMV; |
257 |
psad[1] = MV_MAX_ERROR; |
psad[1] = MV_MAX_ERROR; |
|
} else { |
|
|
pmv[1] = pMBs[xin1 + yin1 * x_dim].mvs[vec1]; |
|
|
psad[1] = pMBs[xin1 + yin1 * x_dim].sad8[vec1]; |
|
258 |
} |
} |
259 |
|
|
260 |
if (xin2 < 0 || xin2 >= (int32_t) x_dim) { |
if (tpos >= bound) { |
261 |
|
num_cand++; |
262 |
|
last_cand = 2; |
263 |
|
pmv[2]= mbs[tpos].mvs[tz]; |
264 |
|
psad[2] = mbs[tpos].sad8[tz]; |
265 |
|
} else { |
266 |
pmv[2] = zeroMV; |
pmv[2] = zeroMV; |
267 |
psad[2] = MV_MAX_ERROR; |
psad[2] = MV_MAX_ERROR; |
|
} else { |
|
|
pmv[2] = pMBs[xin2 + yin2 * x_dim].mvs[vec2]; |
|
|
psad[2] = pMBs[xin2 + yin2 * x_dim].sad8[vec2]; |
|
268 |
} |
} |
269 |
|
|
270 |
if (xin3 < 0 || xin3 >= (int32_t) x_dim) { |
if (rpos >= bound && rx < mb_width) { |
271 |
|
num_cand++; |
272 |
|
last_cand = 3; |
273 |
|
pmv[3] = mbs[rpos].mvs[rz]; |
274 |
|
psad[3] = mbs[rpos].sad8[rz]; |
275 |
|
} else { |
276 |
pmv[3] = zeroMV; |
pmv[3] = zeroMV; |
277 |
psad[3] = MV_MAX_ERROR; |
psad[3] = MV_MAX_ERROR; |
278 |
} else { |
} |
279 |
pmv[3] = pMBs[xin3 + yin3 * x_dim].mvs[vec3]; |
|
280 |
psad[3] = pMBs[xin3 + yin3 * x_dim].sad8[vec3]; |
/* original pmvdata() compatibility hack */ |
281 |
|
if (x == 0 && y == 0 && block == 0) |
282 |
|
{ |
283 |
|
pmv[0] = pmv[1] = pmv[2] = pmv[3] = zeroMV; |
284 |
|
psad[0] = 0; |
285 |
|
psad[1] = psad[2] = psad[3] = MV_MAX_ERROR; |
286 |
|
return 0; |
287 |
|
} |
288 |
|
|
289 |
|
/* if only one valid candidate preictor, the invalid candiates are set to the canidate */ |
290 |
|
if (num_cand == 1) { |
291 |
|
pmv[0] = pmv[last_cand]; |
292 |
|
psad[0] = psad[last_cand]; |
293 |
|
// return MVequal(pmv[0], zeroMV); /* no point calculating median mv and minimum sad */ |
294 |
|
|
295 |
|
/* original pmvdata() compatibility hack */ |
296 |
|
return y==0 && block <= 1 ? 0 : MVequal(pmv[0], zeroMV); |
297 |
} |
} |
298 |
|
|
299 |
if ((MVequal(pmv[1], pmv[2])) && (MVequal(pmv[1], pmv[3]))) { |
if ((MVequal(pmv[1], pmv[2])) && (MVequal(pmv[1], pmv[3]))) { |
300 |
pmv[0] = pmv[1]; |
pmv[0] = pmv[1]; |
301 |
psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]); |
psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]); |
302 |
return 1; |
return 1; |
303 |
|
/* compatibility patch */ |
304 |
|
//return y==0 && block <= 1 ? 0 : 1; |
305 |
} |
} |
306 |
|
|
307 |
/* median,minimum */ |
/* set median, minimum */ |
308 |
|
|
309 |
pmv[0].x = |
pmv[0].x = |
310 |
MIN(MAX(pmv[1].x, pmv[2].x), |
MIN(MAX(pmv[1].x, pmv[2].x), |
312 |
pmv[0].y = |
pmv[0].y = |
313 |
MIN(MAX(pmv[1].y, pmv[2].y), |
MIN(MAX(pmv[1].y, pmv[2].y), |
314 |
MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y))); |
MIN(MAX(pmv[2].y, pmv[3].y), MAX(pmv[1].y, pmv[3].y))); |
315 |
|
|
316 |
psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]); |
psad[0] = MIN(MIN(psad[1], psad[2]), psad[3]); |
317 |
|
|
318 |
return 0; |
return 0; |
319 |
} |
} |
320 |
|
|
321 |
|
/* copies of get_pmv and get_pmvdata for prediction from integer search */ |
|
/* |
|
|
* MODE_INTER, vm18 page 48 |
|
|
* MODE_INTER4V vm18 page 51 |
|
|
* |
|
|
* (x,y-1) (x+1,y-1) |
|
|
* [ | ] [ | ] |
|
|
* [ 2 | 3 ] [ 2 | ] |
|
|
* |
|
|
* (x-1,y) (x,y) (x+1,y) |
|
|
* [ | 1 ] [ 0 | 1 ] [ 0 | ] |
|
|
* [ | 3 ] [ 2 | 3 ] [ | ] |
|
|
*/ |
|
322 |
|
|
323 |
static __inline VECTOR |
static __inline VECTOR |
324 |
get_pmv2(const MACROBLOCK * const mbs, |
get_ipmv(const MACROBLOCK * const mbs, |
325 |
const int mb_width, |
const int mb_width, |
326 |
const int bound, |
const int bound, |
327 |
const int x, |
const int x, |
363 |
lpos = lx + ly * mb_width; |
lpos = lx + ly * mb_width; |
364 |
rpos = rx + ry * mb_width; |
rpos = rx + ry * mb_width; |
365 |
tpos = tx + ty * mb_width; |
tpos = tx + ty * mb_width; |
366 |
num_cand = 0; |
last_cand = num_cand = 0; |
367 |
|
|
368 |
if (lpos >= bound && lx >= 0) { |
if (lpos >= bound && lx >= 0) { |
369 |
num_cand++; |
num_cand++; |
370 |
last_cand = 1; |
last_cand = 1; |
371 |
pmv[1] = mbs[lpos].mvs[lz]; |
pmv[1] = mbs[lpos].i_mvs[lz]; |
372 |
} else { |
} else { |
373 |
pmv[1] = zeroMV; |
pmv[1] = zeroMV; |
374 |
} |
} |
376 |
if (tpos >= bound) { |
if (tpos >= bound) { |
377 |
num_cand++; |
num_cand++; |
378 |
last_cand = 2; |
last_cand = 2; |
379 |
pmv[2] = mbs[tpos].mvs[tz]; |
pmv[2] = mbs[tpos].i_mvs[tz]; |
380 |
} else { |
} else { |
381 |
pmv[2] = zeroMV; |
pmv[2] = zeroMV; |
382 |
} |
} |
384 |
if (rpos >= bound && rx < mb_width) { |
if (rpos >= bound && rx < mb_width) { |
385 |
num_cand++; |
num_cand++; |
386 |
last_cand = 3; |
last_cand = 3; |
387 |
pmv[3] = mbs[rpos].mvs[rz]; |
pmv[3] = mbs[rpos].i_mvs[rz]; |
388 |
} else { |
} else { |
389 |
pmv[3] = zeroMV; |
pmv[3] = zeroMV; |
390 |
} |
} |
391 |
|
|
392 |
/* if only one valid candidate preictor, the invalid candiates are set to the canidate */ |
/* if only one valid candidate predictor, the invalid candiates are set to the canidate */ |
393 |
if (num_cand != 1) { |
if (num_cand != 1) { |
394 |
/* set median */ |
/* set median */ |
395 |
|
|
405 |
return pmv[last_cand]; /* no point calculating median mv */ |
return pmv[last_cand]; /* no point calculating median mv */ |
406 |
} |
} |
407 |
|
|
|
|
|
|
|
|
|
/* |
|
|
* pmv are filled with: |
|
|
* [0]: Median (or whatever is correct in a special case) |
|
|
* [1]: left neighbour |
|
|
* [2]: top neighbour |
|
|
* [3]: topright neighbour |
|
|
* psad are filled with: |
|
|
* [0]: minimum of [1] to [3] |
|
|
* [1]: left neighbour's SAD (NB:[1] to [3] are actually not needed) |
|
|
* [2]: top neighbour's SAD |
|
|
* [3]: topright neighbour's SAD |
|
|
*/ |
|
408 |
static __inline int |
static __inline int |
409 |
get_pmvdata2(const MACROBLOCK * const mbs, |
get_ipmvdata(const MACROBLOCK * const mbs, |
410 |
const int mb_width, |
const int mb_width, |
411 |
const int bound, |
const int bound, |
412 |
const int x, |
const int x, |
448 |
lpos = lx + ly * mb_width; |
lpos = lx + ly * mb_width; |
449 |
rpos = rx + ry * mb_width; |
rpos = rx + ry * mb_width; |
450 |
tpos = tx + ty * mb_width; |
tpos = tx + ty * mb_width; |
451 |
num_cand = 0; |
last_cand = num_cand = 0; |
452 |
|
|
453 |
if (lpos >= bound && lx >= 0) { |
if (lpos >= bound && lx >= 0) { |
454 |
num_cand++; |
num_cand++; |
455 |
last_cand = 1; |
last_cand = 1; |
456 |
pmv[1] = mbs[lpos].mvs[lz]; |
pmv[1] = mbs[lpos].i_mvs[lz]; |
457 |
psad[1] = mbs[lpos].sad8[lz]; |
psad[1] = mbs[lpos].i_sad8[lz]; |
458 |
} else { |
} else { |
459 |
pmv[1] = zeroMV; |
pmv[1] = zeroMV; |
460 |
psad[1] = MV_MAX_ERROR; |
psad[1] = MV_MAX_ERROR; |
463 |
if (tpos >= bound) { |
if (tpos >= bound) { |
464 |
num_cand++; |
num_cand++; |
465 |
last_cand = 2; |
last_cand = 2; |
466 |
pmv[2]= mbs[tpos].mvs[tz]; |
pmv[2]= mbs[tpos].i_mvs[tz]; |
467 |
psad[2] = mbs[tpos].sad8[tz]; |
psad[2] = mbs[tpos].i_sad8[tz]; |
468 |
} else { |
} else { |
469 |
pmv[2] = zeroMV; |
pmv[2] = zeroMV; |
470 |
psad[2] = MV_MAX_ERROR; |
psad[2] = MV_MAX_ERROR; |
473 |
if (rpos >= bound && rx < mb_width) { |
if (rpos >= bound && rx < mb_width) { |
474 |
num_cand++; |
num_cand++; |
475 |
last_cand = 3; |
last_cand = 3; |
476 |
pmv[3] = mbs[rpos].mvs[rz]; |
pmv[3] = mbs[rpos].i_mvs[rz]; |
477 |
psad[3] = mbs[rpos].sad8[rz]; |
psad[3] = mbs[rpos].i_sad8[rz]; |
478 |
} else { |
} else { |
479 |
pmv[3] = zeroMV; |
pmv[3] = zeroMV; |
480 |
psad[3] = MV_MAX_ERROR; |
psad[3] = MV_MAX_ERROR; |