21 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 |
* |
* |
24 |
* $Id: estimation_common.c,v 1.1.2.1 2003-09-10 22:18:59 edgomez Exp $ |
* $Id: estimation_common.c,v 1.1.2.2 2003-11-19 12:24:25 syskin Exp $ |
25 |
* |
* |
26 |
****************************************************************************/ |
****************************************************************************/ |
27 |
|
|
78 |
****************************************************************************/ |
****************************************************************************/ |
79 |
|
|
80 |
int32_t |
int32_t |
81 |
xvid_me_ChromaSAD(const int dx, const int dy, const SearchData * const data) |
xvid_me_ChromaSAD(const int dx, const int dy, SearchData * const data) |
82 |
{ |
{ |
83 |
int sad; |
int sad; |
84 |
const uint32_t stride = data->iEdgedWidth/2; |
const uint32_t stride = data->iEdgedWidth/2; |
85 |
int offset = (dx>>1) + (dy>>1)*stride; |
int offset = (dx>>1) + (dy>>1)*stride; |
86 |
int next = 1; |
int next = 1; |
87 |
|
|
88 |
if (dx == data->temp[5] && dy == data->temp[6]) return data->temp[7]; /* it has been checked recently */ |
if (dx == data->chromaX && dy == data->chromaY) |
89 |
data->temp[5] = dx; data->temp[6] = dy; /* backup */ |
return data->chromaSAD; /* it has been checked recently */ |
90 |
|
data->chromaX = dx; data->chromaY = dy; /* backup */ |
91 |
|
|
92 |
switch (((dx & 1) << 1) | (dy & 1)) { |
switch (((dx & 1) << 1) | (dy & 1)) { |
93 |
case 0: |
case 0: |
108 |
sad += sad8(data->CurV, data->RefQ, stride); |
sad += sad8(data->CurV, data->RefQ, stride); |
109 |
break; |
break; |
110 |
} |
} |
111 |
data->temp[7] = sad; /* backup, part 2 */ |
data->chromaSAD = sad; /* backup, part 2 */ |
112 |
return sad; |
return sad; |
113 |
} |
} |
114 |
|
|
207 |
} |
} |
208 |
|
|
209 |
void |
void |
210 |
xvid_me_AdvDiamondSearch(int x, int y, const SearchData * const data, |
xvid_me_AdvDiamondSearch(int x, int y, SearchData * const data, |
211 |
int bDirection, CheckFunc * const CheckCandidate) |
int bDirection, CheckFunc * const CheckCandidate) |
212 |
{ |
{ |
213 |
|
|
214 |
/* directions: 1 - left (x-1); 2 - right (x+1), 4 - up (y-1); 8 - down (y+1) */ |
/* directions: 1 - left (x-1); 2 - right (x+1), 4 - up (y-1); 8 - down (y+1) */ |
215 |
|
|
216 |
unsigned int * const iDirection = data->dir; |
unsigned int * const iDirection = &data->dir; |
217 |
|
|
218 |
for(;;) { /* forever */ |
for(;;) { /* forever */ |
219 |
*iDirection = 0; |
*iDirection = 0; |
293 |
} |
} |
294 |
|
|
295 |
void |
void |
296 |
xvid_me_SquareSearch(int x, int y, const SearchData * const data, |
xvid_me_SquareSearch(int x, int y, SearchData * const data, |
297 |
int bDirection, CheckFunc * const CheckCandidate) |
int bDirection, CheckFunc * const CheckCandidate) |
298 |
{ |
{ |
299 |
unsigned int * const iDirection = data->dir; |
unsigned int * const iDirection = &data->dir; |
300 |
|
|
301 |
do { |
do { |
302 |
*iDirection = 0; |
*iDirection = 0; |
315 |
} |
} |
316 |
|
|
317 |
void |
void |
318 |
xvid_me_DiamondSearch(int x, int y, const SearchData * const data, |
xvid_me_DiamondSearch(int x, int y, SearchData * const data, |
319 |
int bDirection, CheckFunc * const CheckCandidate) |
int bDirection, CheckFunc * const CheckCandidate) |
320 |
{ |
{ |
321 |
|
|
322 |
/* directions: 1 - left (x-1); 2 - right (x+1), 4 - up (y-1); 8 - down (y+1) */ |
/* directions: 1 - left (x-1); 2 - right (x+1), 4 - up (y-1); 8 - down (y+1) */ |
323 |
|
|
324 |
unsigned int * const iDirection = data->dir; |
unsigned int * const iDirection = &data->dir; |
325 |
|
|
326 |
do { |
do { |
327 |
*iDirection = 0; |
*iDirection = 0; |
351 |
} |
} |
352 |
|
|
353 |
void |
void |
354 |
xvid_me_SubpelRefine(const SearchData * const data, CheckFunc * const CheckCandidate) |
xvid_me_SubpelRefine(SearchData * const data, CheckFunc * const CheckCandidate) |
355 |
{ |
{ |
356 |
/* Do a half-pel or q-pel refinement */ |
/* Do a half-pel or q-pel refinement */ |
357 |
const VECTOR centerMV = data->qpel_precision ? *data->currentQMV : *data->currentMV; |
const VECTOR centerMV = data->qpel_precision ? *data->currentQMV : *data->currentMV; |