39 |
#include "motion_inlines.h" |
#include "motion_inlines.h" |
40 |
|
|
41 |
static void |
static void |
42 |
CheckCandidate16I(const int x, const int y, const SearchData * const data, const unsigned int Direction) |
CheckCandidate16I(const int x, const int y, 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; |
56 |
data->currentMV[0].x = x; data->currentMV[0].y = y; |
data->currentMV[0].x = x; data->currentMV[0].y = y; |
57 |
*data->dir = Direction; |
data->dir = Direction; |
58 |
} |
} |
59 |
} |
} |
60 |
|
|
129 |
const IMAGE * const pCurrent = ¤t->image; |
const IMAGE * const pCurrent = ¤t->image; |
130 |
const IMAGE * const pReference = &reference->image; |
const IMAGE * const pReference = &reference->image; |
131 |
|
|
|
int32_t iMinSAD[5], temp[5]; |
|
|
VECTOR currentMV[5]; |
|
|
uint32_t dir; |
|
132 |
SearchData Data; |
SearchData Data; |
133 |
memset(&Data, 0, sizeof(SearchData)); |
memset(&Data, 0, sizeof(SearchData)); |
134 |
|
|
135 |
Data.iEdgedWidth = pParam->edged_width; |
Data.iEdgedWidth = pParam->edged_width; |
136 |
Data.rounding = pParam->m_rounding_type; |
Data.rounding = pParam->m_rounding_type; |
137 |
|
|
|
Data.currentMV = ¤tMV[0]; |
|
|
Data.iMinSAD = &iMinSAD[0]; |
|
138 |
Data.iFcode = current->fcode; |
Data.iFcode = current->fcode; |
|
Data.temp = temp; |
|
|
Data.dir = &dir; |
|
139 |
|
|
140 |
if (sadInit) (*sadInit) (); |
if (sadInit) (*sadInit) (); |
141 |
|
|
157 |
const IMAGE * const pRefHV) |
const IMAGE * const pRefHV) |
158 |
{ |
{ |
159 |
|
|
160 |
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 */ |
161 |
const int deltay=8; |
const int deltay=8; |
162 |
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) */ |
163 |
const unsigned int grady=512; |
const unsigned int grady=512; |
164 |
|
|
165 |
double sol[4] = { 0., 0., 0., 0. }; |
double sol[4] = { 0., 0., 0., 0. }; |
170 |
|
|
171 |
int MBh = pParam->mb_height; |
int MBh = pParam->mb_height; |
172 |
int MBw = pParam->mb_width; |
int MBw = pParam->mb_width; |
173 |
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 */ |
174 |
const int maxblocks = MBh*MBw/4; /* just some reasonable number 3% + 3 */ |
const int maxblocks = MBh*MBw/4; /* just some reasonable number 3% + 3 */ |
175 |
|
|
176 |
int num=0; |
int num=0; |
182 |
|
|
183 |
/* block based ME isn't done, yet, so do a quick presearch */ |
/* block based ME isn't done, yet, so do a quick presearch */ |
184 |
|
|
185 |
// filter mask of all blocks |
/* filter mask of all blocks */ |
186 |
|
|
187 |
for (my = 0; my < (uint32_t)MBh; my++) |
for (my = 0; my < (uint32_t)MBh; my++) |
188 |
for (mx = 0; mx < (uint32_t)MBw; mx++) |
for (mx = 0; mx < (uint32_t)MBw; mx++) |
388 |
int gmcminSAD=0; |
int gmcminSAD=0; |
389 |
int gmcSAD=0; |
int gmcSAD=0; |
390 |
int direction; |
int direction; |
391 |
// int mx,my; |
#if 0 |
392 |
|
int mx,my; |
393 |
|
#endif |
394 |
|
|
395 |
|
#if 0 |
396 |
/* use many blocks... */ |
/* use many blocks... */ |
397 |
/* for (my = 0; my < (uint32_t)pParam->mb_height; my++) |
for (my = 0; my < (uint32_t)pParam->mb_height; my++) { |
398 |
for (mx = 0; mx < (uint32_t)pParam->mb_width; mx++) |
for (mx = 0; mx < (uint32_t)pParam->mb_width; mx++) { |
|
{ |
|
399 |
const int mbnum = mx + my * pParam->mb_width; |
const int mbnum = mx + my * pParam->mb_width; |
400 |
pMBs[mbnum].mcsel=1; |
pMBs[mbnum].mcsel=1; |
401 |
} |
} |
402 |
*/ |
} |
403 |
|
#endif |
404 |
|
|
405 |
|
#if 0 |
406 |
/* or rather don't use too many blocks... */ |
/* or rather don't use too many blocks... */ |
407 |
/* |
for (my = 1; my < (uint32_t)MBh-1; my++) { |
408 |
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++) |
|
|
{ |
|
409 |
const int mbnum = mx + my * MBw; |
const int mbnum = mx + my * MBw; |
410 |
if (MBmask[mbnum-1]) |
if (MBmask[mbnum-1]) |
411 |
MBmask[mbnum-1]=0; |
MBmask[mbnum-1]=0; |
414 |
MBmask[mbnum-1]=0; |
MBmask[mbnum-1]=0; |
415 |
|
|
416 |
} |
} |
417 |
*/ |
} |
418 |
|
#endif |
419 |
|
|
420 |
gmcminSAD = globalSAD(&bestwp, pParam, pMBs, current, pRef, pCurr, GMCblock); |
gmcminSAD = globalSAD(&bestwp, pParam, pMBs, current, pRef, pCurr, GMCblock); |
421 |
|
|
422 |
if ( (reference->coding_type == S_VOP) |
if ( (reference->coding_type == S_VOP) |