19 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
* |
* |
22 |
* $Id: estimation_gmc.c,v 1.1.2.1 2003-09-10 22:18:59 edgomez Exp $ |
* $Id: estimation_gmc.c,v 1.1.2.2 2003-09-30 18:20:31 edgomez Exp $ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
42 |
CheckCandidate16I(const int x, const int y, const SearchData * const data, const unsigned int Direction) |
CheckCandidate16I(const int x, const int y, const SearchData * const data, const unsigned int Direction) |
43 |
{ |
{ |
44 |
int sad; |
int sad; |
|
// int xc, yc; |
|
45 |
const uint8_t * Reference; |
const uint8_t * Reference; |
|
// VECTOR * current; |
|
46 |
|
|
47 |
if ( (x > data->max_dx) || ( x < data->min_dx) |
if ( (x > data->max_dx) || ( x < data->min_dx) |
48 |
|| (y > data->max_dy) || (y < data->min_dy) ) return; |
|| (y > data->max_dy) || (y < data->min_dy) ) return; |
49 |
|
|
50 |
Reference = GetReference(x, y, data); |
Reference = GetReference(x, y, data); |
|
// xc = x; yc = y; |
|
51 |
|
|
52 |
sad = sad16(data->Cur, Reference, data->iEdgedWidth, 256*4096); |
sad = sad16(data->Cur, Reference, data->iEdgedWidth, 256*4096); |
|
// sad += d_mv_bits(x, y, data->predMV, data->iFcode, 0, 0); |
|
|
|
|
|
/* if (data->chroma) sad += ChromaSAD((xc >> 1) + roundtab_79[xc & 0x3], |
|
|
(yc >> 1) + roundtab_79[yc & 0x3], data); |
|
|
*/ |
|
53 |
|
|
54 |
if (sad < data->iMinSAD[0]) { |
if (sad < data->iMinSAD[0]) { |
55 |
data->iMinSAD[0] = sad; |
data->iMinSAD[0] = sad; |
164 |
const IMAGE * const pRefHV) |
const IMAGE * const pRefHV) |
165 |
{ |
{ |
166 |
|
|
167 |
const int deltax=8; // upper bound for difference between a MV and it's neighbour MVs |
const int deltax=8; /* upper bound for difference between a MV and it's neighbour MVs */ |
168 |
const int deltay=8; |
const int deltay=8; |
169 |
const unsigned int gradx=512; // lower bound for gradient in MB (ignore "flat" blocks) |
const unsigned int gradx=512; /* lower bound for gradient in MB (ignore "flat" blocks) */ |
170 |
const unsigned int grady=512; |
const unsigned int grady=512; |
171 |
|
|
172 |
double sol[4] = { 0., 0., 0., 0. }; |
double sol[4] = { 0., 0., 0., 0. }; |
177 |
|
|
178 |
int MBh = pParam->mb_height; |
int MBh = pParam->mb_height; |
179 |
int MBw = pParam->mb_width; |
int MBw = pParam->mb_width; |
180 |
const int minblocks = 9; //MBh*MBw/32+3; /* just some reasonable number 3% + 3 */ |
const int minblocks = 9; /* was = /MBh*MBw/32+3 */ /* just some reasonable number 3% + 3 */ |
181 |
const int maxblocks = MBh*MBw/4; /* just some reasonable number 3% + 3 */ |
const int maxblocks = MBh*MBw/4; /* just some reasonable number 3% + 3 */ |
182 |
|
|
183 |
int num=0; |
int num=0; |
189 |
|
|
190 |
/* block based ME isn't done, yet, so do a quick presearch */ |
/* block based ME isn't done, yet, so do a quick presearch */ |
191 |
|
|
192 |
// filter mask of all blocks |
/* filter mask of all blocks */ |
193 |
|
|
194 |
for (my = 0; my < (uint32_t)MBh; my++) |
for (my = 0; my < (uint32_t)MBh; my++) |
195 |
for (mx = 0; mx < (uint32_t)MBw; mx++) |
for (mx = 0; mx < (uint32_t)MBw; mx++) |
395 |
int gmcminSAD=0; |
int gmcminSAD=0; |
396 |
int gmcSAD=0; |
int gmcSAD=0; |
397 |
int direction; |
int direction; |
398 |
// int mx,my; |
#if 0 |
399 |
|
int mx,my; |
400 |
|
#endif |
401 |
|
|
402 |
|
#if 0 |
403 |
/* use many blocks... */ |
/* use many blocks... */ |
404 |
/* for (my = 0; my < (uint32_t)pParam->mb_height; my++) |
for (my = 0; my < (uint32_t)pParam->mb_height; my++) { |
405 |
for (mx = 0; mx < (uint32_t)pParam->mb_width; mx++) |
for (mx = 0; mx < (uint32_t)pParam->mb_width; mx++) { |
|
{ |
|
406 |
const int mbnum = mx + my * pParam->mb_width; |
const int mbnum = mx + my * pParam->mb_width; |
407 |
pMBs[mbnum].mcsel=1; |
pMBs[mbnum].mcsel=1; |
408 |
} |
} |
409 |
*/ |
} |
410 |
|
#endif |
411 |
|
|
412 |
|
#if 0 |
413 |
/* or rather don't use too many blocks... */ |
/* or rather don't use too many blocks... */ |
414 |
/* |
for (my = 1; my < (uint32_t)MBh-1; my++) { |
415 |
for (my = 1; my < (uint32_t)MBh-1; my++) |
for (mx = 1; mx < (uint32_t)MBw-1; mx++) { |
|
for (mx = 1; mx < (uint32_t)MBw-1; mx++) |
|
|
{ |
|
416 |
const int mbnum = mx + my * MBw; |
const int mbnum = mx + my * MBw; |
417 |
if (MBmask[mbnum-1]) |
if (MBmask[mbnum-1]) |
418 |
MBmask[mbnum-1]=0; |
MBmask[mbnum-1]=0; |
421 |
MBmask[mbnum-1]=0; |
MBmask[mbnum-1]=0; |
422 |
|
|
423 |
} |
} |
424 |
*/ |
} |
425 |
|
#endif |
426 |
|
|
427 |
gmcminSAD = globalSAD(&bestwp, pParam, pMBs, current, pRef, pCurr, GMCblock); |
gmcminSAD = globalSAD(&bestwp, pParam, pMBs, current, pRef, pCurr, GMCblock); |
428 |
|
|
429 |
if ( (reference->coding_type == S_VOP) |
if ( (reference->coding_type == S_VOP) |