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_pvop.c,v 1.3 2004-04-12 14:05:08 edgomez Exp $ |
* $Id: estimation_pvop.c,v 1.8 2004-07-08 07:12:54 syskin Exp $ |
25 |
* |
* |
26 |
****************************************************************************/ |
****************************************************************************/ |
27 |
|
|
42 |
|
|
43 |
static const int xvid_me_lambda_vec8[32] = |
static const int xvid_me_lambda_vec8[32] = |
44 |
{ 0 ,(int)(1.00235 * NEIGH_TEND_8X8 + 0.5), |
{ 0 ,(int)(1.00235 * NEIGH_TEND_8X8 + 0.5), |
45 |
(int)(1.15582 + NEIGH_TEND_8X8 + 0.5), (int)(1.31976*NEIGH_TEND_8X8 + 0.5), |
(int)(1.15582*NEIGH_TEND_8X8 + 0.5), (int)(1.31976*NEIGH_TEND_8X8 + 0.5), |
46 |
(int)(1.49591*NEIGH_TEND_8X8 + 0.5), (int)(1.68601*NEIGH_TEND_8X8 + 0.5), |
(int)(1.49591*NEIGH_TEND_8X8 + 0.5), (int)(1.68601*NEIGH_TEND_8X8 + 0.5), |
47 |
(int)(1.89187*NEIGH_TEND_8X8 + 0.5), (int)(2.11542*NEIGH_TEND_8X8 + 0.5), |
(int)(1.89187*NEIGH_TEND_8X8 + 0.5), (int)(2.11542*NEIGH_TEND_8X8 + 0.5), |
48 |
(int)(2.35878*NEIGH_TEND_8X8 + 0.5), (int)(2.62429*NEIGH_TEND_8X8 + 0.5), |
(int)(2.35878*NEIGH_TEND_8X8 + 0.5), (int)(2.62429*NEIGH_TEND_8X8 + 0.5), |
63 |
CheckCandidate16(const int x, const int y, SearchData * const data, const unsigned int Direction) |
CheckCandidate16(const int x, const int y, SearchData * const data, const unsigned int Direction) |
64 |
{ |
{ |
65 |
const uint8_t * Reference; |
const uint8_t * Reference; |
66 |
int32_t sad; uint32_t t; |
int32_t sad, xc, yc; uint32_t t; |
67 |
|
VECTOR * current; |
68 |
|
|
69 |
if ( (x > data->max_dx) || (x < data->min_dx) |
if ( (x > data->max_dx) || (x < data->min_dx) |
70 |
|| (y > data->max_dy) || (y < data->min_dy) ) return; |
|| (y > data->max_dy) || (y < data->min_dy) ) return; |
71 |
|
|
72 |
|
if (data->qpel_precision) { /* x and y are in 1/4 precision */ |
73 |
|
Reference = xvid_me_interpolate16x16qpel(x, y, 0, data); |
74 |
|
current = data->currentQMV; |
75 |
|
xc = x/2; yc = y/2; |
76 |
|
} else { |
77 |
Reference = GetReference(x, y, data); |
Reference = GetReference(x, y, data); |
78 |
|
current = data->currentMV; |
79 |
|
xc = x; yc = y; |
80 |
|
} |
81 |
|
|
82 |
sad = sad16v(data->Cur, Reference, data->iEdgedWidth, data->temp); |
sad = sad16v(data->Cur, Reference, data->iEdgedWidth, data->temp); |
83 |
t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel, 0); |
t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision, 0); |
84 |
|
|
85 |
sad += (data->lambda16 * t * sad)>>10; |
sad += (data->lambda16 * t * sad)>>10; |
86 |
data->temp[0] += (data->lambda8 * t * (data->temp[0] + NEIGH_8X8_BIAS))>>10; |
data->temp[0] += (data->lambda8 * t * (data->temp[0] + NEIGH_8X8_BIAS))>>10; |
87 |
|
|
88 |
if (data->chroma) { |
if (data->chroma) { |
89 |
if (sad >= data->iMinSAD[0]) goto no16; |
if (sad >= data->iMinSAD[0]) goto no16; |
90 |
sad += xvid_me_ChromaSAD((x >> 1) + roundtab_79[x & 0x3], |
sad += xvid_me_ChromaSAD((xc >> 1) + roundtab_79[xc & 0x3], |
91 |
(y >> 1) + roundtab_79[y & 0x3], data); |
(yc >> 1) + roundtab_79[yc & 0x3], data); |
92 |
} |
} |
93 |
|
|
94 |
if (sad < data->iMinSAD[0]) { |
if (sad < data->iMinSAD[0]) { |
95 |
data->iMinSAD[0] = sad; |
data->iMinSAD[0] = sad; |
96 |
data->currentMV[0].x = x; data->currentMV[0].y = y; |
current[0].x = x; current[0].y = y; |
97 |
data->dir = Direction; |
data->dir = Direction; |
98 |
} |
} |
99 |
|
|
100 |
no16: |
no16: |
101 |
if (data->temp[0] < data->iMinSAD[1]) { |
if (data->temp[0] < data->iMinSAD[1]) { |
102 |
data->iMinSAD[1] = data->temp[0]; data->currentMV[1].x = x; data->currentMV[1].y = y; } |
data->iMinSAD[1] = data->temp[0]; current[1].x = x; current[1].y = y; } |
103 |
if (data->temp[1] < data->iMinSAD[2]) { |
if (data->temp[1] < data->iMinSAD[2]) { |
104 |
data->iMinSAD[2] = data->temp[1]; data->currentMV[2].x = x; data->currentMV[2].y = y; } |
data->iMinSAD[2] = data->temp[1]; current[2].x = x; current[2].y = y; } |
105 |
if (data->temp[2] < data->iMinSAD[3]) { |
if (data->temp[2] < data->iMinSAD[3]) { |
106 |
data->iMinSAD[3] = data->temp[2]; data->currentMV[3].x = x; data->currentMV[3].y = y; } |
data->iMinSAD[3] = data->temp[2]; current[3].x = x; current[3].y = y; } |
107 |
if (data->temp[3] < data->iMinSAD[4]) { |
if (data->temp[3] < data->iMinSAD[4]) { |
108 |
data->iMinSAD[4] = data->temp[3]; data->currentMV[4].x = x; data->currentMV[4].y = y; } |
data->iMinSAD[4] = data->temp[3]; current[4].x = x; current[4].y = y; } |
|
} |
|
|
|
|
|
static void |
|
|
CheckCandidate16_qpel(const int x, const int y, SearchData * const data, const unsigned int Direction) |
|
|
{ |
|
|
const uint8_t *Reference; |
|
|
int32_t sad; uint32_t t; |
|
|
|
|
|
if ( (x > data->max_dx) || (x < data->min_dx) |
|
|
|| (y > data->max_dy) || (y < data->min_dy) ) return; |
|
|
|
|
|
Reference = xvid_me_interpolate16x16qpel(x, y, 0, data); |
|
|
|
|
|
sad = sad16v(data->Cur, Reference, data->iEdgedWidth, data->temp); |
|
|
t = d_mv_bits(x, y, data->predMV, data->iFcode, 0, 0); |
|
|
|
|
|
sad += (data->lambda16 * t * sad)>>10; |
|
|
data->temp[0] += (data->lambda8 * t * (data->temp[0] + NEIGH_8X8_BIAS))>>10; |
|
|
|
|
|
if (data->chroma && (sad < data->iMinSAD[0] || sad < data->iMinSAD2) ) |
|
|
sad += xvid_me_ChromaSAD(((x/2) >> 1) + roundtab_79[(x/2) & 0x3], |
|
|
((y/2) >> 1) + roundtab_79[(y/2) & 0x3], data); |
|
|
|
|
|
if (data->temp[0] < data->iMinSAD[1]) { |
|
|
data->iMinSAD[1] = data->temp[0]; data->currentQMV[1].x = x; data->currentQMV[1].y = y; } |
|
|
if (data->temp[1] < data->iMinSAD[2]) { |
|
|
data->iMinSAD[2] = data->temp[1]; data->currentQMV[2].x = x; data->currentQMV[2].y = y; } |
|
|
if (data->temp[2] < data->iMinSAD[3]) { |
|
|
data->iMinSAD[3] = data->temp[2]; data->currentQMV[3].x = x; data->currentQMV[3].y = y; } |
|
|
if (data->temp[3] < data->iMinSAD[4]) { |
|
|
data->iMinSAD[4] = data->temp[3]; data->currentQMV[4].x = x; data->currentQMV[4].y = y; } |
|
|
|
|
|
if (sad < data->iMinSAD[0]) { |
|
|
data->iMinSAD2 = *(data->iMinSAD); |
|
|
data->currentQMV2.x = data->currentQMV->x; |
|
|
data->currentQMV2.y = data->currentQMV->y; |
|
|
|
|
|
data->iMinSAD[0] = sad; |
|
|
data->currentQMV[0].x = x; data->currentQMV[0].y = y; |
|
|
} else if (sad < data->iMinSAD2) { |
|
|
data->iMinSAD2 = sad; |
|
|
data->currentQMV2.x = x; data->currentQMV2.y = y; |
|
|
} |
|
109 |
} |
} |
110 |
|
|
111 |
static void |
static void |
139 |
} |
} |
140 |
|
|
141 |
static void |
static void |
|
CheckCandidate8_qpel(const int x, const int y, SearchData * const data, const unsigned int Direction) |
|
|
{ |
|
|
int32_t sad; uint32_t t; |
|
|
const uint8_t * Reference; |
|
|
VECTOR * current; |
|
|
|
|
|
if ( (x > data->max_dx) || (x < data->min_dx) |
|
|
|| (y > data->max_dy) || (y < data->min_dy) ) return; |
|
|
|
|
|
/* x and y are in 1/4 precision */ |
|
|
Reference = xvid_me_interpolate8x8qpel(x, y, 0, 0, data); |
|
|
current = data->currentQMV; |
|
|
|
|
|
sad = sad8(data->Cur, Reference, data->iEdgedWidth); |
|
|
t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision, 0); |
|
|
|
|
|
sad += (data->lambda8 * t * (sad+NEIGH_8X8_BIAS))>>10; |
|
|
|
|
|
if (sad < *(data->iMinSAD)) { |
|
|
data->iMinSAD2 = *(data->iMinSAD); |
|
|
data->currentQMV2.x = data->currentQMV->x; |
|
|
data->currentQMV2.y = data->currentQMV->y; |
|
|
|
|
|
*(data->iMinSAD) = sad; |
|
|
data->currentQMV->x = x; data->currentQMV->y = y; |
|
|
data->dir = Direction; |
|
|
} else if (sad < data->iMinSAD2) { |
|
|
data->iMinSAD2 = sad; |
|
|
data->currentQMV2.x = x; data->currentQMV2.y = y; |
|
|
} |
|
|
} |
|
|
|
|
|
static void |
|
142 |
CheckCandidate32(const int x, const int y, SearchData * const data, const unsigned int Direction) |
CheckCandidate32(const int x, const int y, SearchData * const data, const unsigned int Direction) |
143 |
{ |
{ |
144 |
uint32_t t; |
uint32_t t; |
312 |
const IMAGE * const pCurrent, |
const IMAGE * const pCurrent, |
313 |
const IMAGE * const pRef, |
const IMAGE * const pRef, |
314 |
const IMAGE * const vGMC, |
const IMAGE * const vGMC, |
315 |
const int coding_type) |
const int coding_type, |
316 |
|
const int skip_sad) |
317 |
{ |
{ |
318 |
int mode = MODE_INTER; |
int mode = MODE_INTER; |
319 |
int mcsel = 0; |
int mcsel = 0; |
339 |
} |
} |
340 |
|
|
341 |
/* final skip decision, a.k.a. "the vector you found, really that good?" */ |
/* final skip decision, a.k.a. "the vector you found, really that good?" */ |
342 |
if (skip_possible && (pMB->sad16 < (int)iQuant * MAX_SAD00_FOR_SKIP)) |
if (skip_possible && (skip_sad < (int)iQuant * MAX_SAD00_FOR_SKIP)) |
343 |
if ( (100*sad)/(pMB->sad16+1) > FINAL_SKIP_THRESH) |
if ( (100*skip_sad)/(pMB->sad16+1) > FINAL_SKIP_THRESH) |
344 |
if (Data->chroma || xvid_me_SkipDecisionP(pCurrent, pRef, x, y, Data->iEdgedWidth/2, iQuant, Data->rrv)) { |
if (Data->chroma || xvid_me_SkipDecisionP(pCurrent, pRef, x, y, Data->iEdgedWidth/2, iQuant, Data->rrv)) { |
345 |
mode = MODE_NOT_CODED; |
mode = MODE_NOT_CODED; |
346 |
sad = 0; |
sad = 0; |
478 |
SearchData * const Data) |
SearchData * const Data) |
479 |
{ |
{ |
480 |
int i = 0; |
int i = 0; |
481 |
|
VECTOR vbest_q; int32_t sbest_q; |
482 |
CheckFunc * CheckCandidate; |
CheckFunc * CheckCandidate; |
483 |
*Data->iMinSAD = *(OldData->iMinSAD + 1 + block); |
*Data->iMinSAD = *(OldData->iMinSAD + 1 + block); |
484 |
*Data->currentMV = *(OldData->currentMV + 1 + block); |
*Data->currentMV = *(OldData->currentMV + 1 + block); |
498 |
|
|
499 |
if (MotionFlags & (XVID_ME_EXTSEARCH8|XVID_ME_HALFPELREFINE8|XVID_ME_QUARTERPELREFINE8)) { |
if (MotionFlags & (XVID_ME_EXTSEARCH8|XVID_ME_HALFPELREFINE8|XVID_ME_QUARTERPELREFINE8)) { |
500 |
|
|
501 |
|
vbest_q = Data->currentQMV[0]; |
502 |
|
sbest_q = Data->iMinSAD[0]; |
503 |
|
|
504 |
if (Data->rrv) i = 16; else i = 8; |
if (Data->rrv) i = 16; else i = 8; |
505 |
|
|
506 |
Data->RefP[0] = OldData->RefP[0] + i * ((block&1) + Data->iEdgedWidth*(block>>1)); |
Data->RefP[0] = OldData->RefP[0] + i * ((block&1) + Data->iEdgedWidth*(block>>1)); |
518 |
else CheckCandidate = CheckCandidate16no4v; |
else CheckCandidate = CheckCandidate16no4v; |
519 |
|
|
520 |
if (MotionFlags & XVID_ME_EXTSEARCH8 && (!(MotionFlags & XVID_ME_EXTSEARCH_RD))) { |
if (MotionFlags & XVID_ME_EXTSEARCH8 && (!(MotionFlags & XVID_ME_EXTSEARCH_RD))) { |
|
int32_t temp_sad = *(Data->iMinSAD); /* store current MinSAD */ |
|
521 |
|
|
522 |
MainSearchFunc *MainSearchPtr; |
MainSearchFunc *MainSearchPtr; |
523 |
if (MotionFlags & XVID_ME_USESQUARES8) MainSearchPtr = xvid_me_SquareSearch; |
if (MotionFlags & XVID_ME_USESQUARES8) MainSearchPtr = xvid_me_SquareSearch; |
525 |
else MainSearchPtr = xvid_me_DiamondSearch; |
else MainSearchPtr = xvid_me_DiamondSearch; |
526 |
|
|
527 |
MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, 255, CheckCandidate); |
MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, 255, CheckCandidate); |
528 |
|
} |
529 |
|
|
530 |
if(*(Data->iMinSAD) < temp_sad) { |
if(!Data->qpel) { |
531 |
Data->currentQMV->x = 2 * Data->currentMV->x; /* update our qpel vector */ |
/* halfpel mode */ |
532 |
|
if (MotionFlags & XVID_ME_HALFPELREFINE8) |
533 |
|
/* perform halfpel refine of current best vector */ |
534 |
|
xvid_me_SubpelRefine(Data->currentMV[0], Data, CheckCandidate, 0); |
535 |
|
} else { |
536 |
|
/* qpel mode */ |
537 |
|
Data->currentQMV->x = 2*Data->currentMV->x; |
538 |
Data->currentQMV->y = 2 * Data->currentMV->y; |
Data->currentQMV->y = 2 * Data->currentMV->y; |
|
} |
|
|
} |
|
539 |
|
|
540 |
|
if(MotionFlags & XVID_ME_FASTREFINE8) { |
541 |
|
/* fast */ |
542 |
|
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 3, |
543 |
|
pParam->width, pParam->height, Data->iFcode, 2, 0); |
544 |
|
FullRefine_Fast(Data, CheckCandidate8, 0); |
545 |
|
} else if(MotionFlags & XVID_ME_QUARTERPELREFINE8) { |
546 |
|
/* full */ |
547 |
if (MotionFlags & XVID_ME_HALFPELREFINE8) { |
if (MotionFlags & XVID_ME_HALFPELREFINE8) { |
548 |
int32_t temp_sad = *(Data->iMinSAD); /* store current MinSAD */ |
xvid_me_SubpelRefine(Data->currentMV[0], Data, CheckCandidate8, 0); /* hpel part */ |
549 |
|
Data->currentQMV->x = 2*Data->currentMV->x; |
|
xvid_me_SubpelRefine(Data, CheckCandidate); /* perform halfpel refine of current best vector */ |
|
|
|
|
|
if(*(Data->iMinSAD) < temp_sad) { /* we have found a better match */ |
|
|
Data->currentQMV->x = 2 * Data->currentMV->x; /* update our qpel vector */ |
|
550 |
Data->currentQMV->y = 2 * Data->currentMV->y; |
Data->currentQMV->y = 2 * Data->currentMV->y; |
551 |
} |
} |
|
} |
|
552 |
|
|
|
if (Data->qpel && (MotionFlags & XVID_ME_QUARTERPELREFINE8)) { |
|
|
Data->qpel_precision = 1; |
|
553 |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 3, |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 3, |
554 |
pParam->width, pParam->height, Data->iFcode, 2, 0); |
pParam->width, pParam->height, Data->iFcode, 2, 0); |
555 |
|
Data->qpel_precision = 1; |
556 |
|
|
557 |
if((MotionFlags & XVID_ME_FASTREFINE8) && (!Data->rrv)) |
xvid_me_SubpelRefine(Data->currentQMV[0], Data, CheckCandidate8, 0); /* qpel part */ |
558 |
SubpelRefine_Fast(Data, CheckCandidate8_qpel); |
} |
|
else |
|
|
xvid_me_SubpelRefine(Data, CheckCandidate); |
|
559 |
} |
} |
560 |
|
|
561 |
|
if (sbest_q <= Data->iMinSAD[0]) /* we have not found a better match */ |
562 |
|
Data->currentQMV[0] = vbest_q; |
563 |
|
|
564 |
} |
} |
565 |
|
|
566 |
if (Data->rrv) { |
if (Data->rrv) { |
567 |
Data->currentMV->x = RRV_MV_SCALEDOWN(Data->currentMV->x); |
Data->currentMV->x = RRV_MV_SCALEDOWN(Data->currentMV->x); |
568 |
Data->currentMV->y = RRV_MV_SCALEDOWN(Data->currentMV->y); |
Data->currentMV->y = RRV_MV_SCALEDOWN(Data->currentMV->y); |
569 |
} |
} else if(Data->qpel) { |
|
|
|
|
if(Data->qpel) { |
|
570 |
pMB->pmvs[block].x = Data->currentQMV->x - Data->predMV.x; |
pMB->pmvs[block].x = Data->currentQMV->x - Data->predMV.x; |
571 |
pMB->pmvs[block].y = Data->currentQMV->y - Data->predMV.y; |
pMB->pmvs[block].y = Data->currentQMV->y - Data->predMV.y; |
572 |
pMB->qmvs[block] = *Data->currentQMV; |
pMB->qmvs[block] = *Data->currentQMV; |
719 |
} |
} |
720 |
} |
} |
721 |
|
|
722 |
|
|
723 |
|
if(!Data->qpel) { |
724 |
|
/* halfpel mode */ |
725 |
if (MotionFlags & XVID_ME_HALFPELREFINE16) |
if (MotionFlags & XVID_ME_HALFPELREFINE16) |
726 |
xvid_me_SubpelRefine(Data, CheckCandidate); |
xvid_me_SubpelRefine(Data->currentMV[0], Data, CheckCandidate, 0); |
727 |
|
} else { |
728 |
|
/* qpel mode */ |
729 |
|
|
730 |
for(i = 0; i < 5; i++) { |
for(i = 0; i < 5; i++) { |
731 |
Data->currentQMV[i].x = 2 * Data->currentMV[i].x; /* initialize qpel vectors */ |
Data->currentQMV[i].x = 2 * Data->currentMV[i].x; /* initialize qpel vectors */ |
732 |
Data->currentQMV[i].y = 2 * Data->currentMV[i].y; |
Data->currentQMV[i].y = 2 * Data->currentMV[i].y; |
733 |
} |
} |
734 |
|
if(MotionFlags & XVID_ME_FASTREFINE16 && MotionFlags & XVID_ME_QUARTERPELREFINE16) { |
735 |
if (Data->qpel) { |
/* fast */ |
736 |
|
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 4, |
737 |
|
pParam->width, pParam->height, Data->iFcode, 2, 0); |
738 |
|
FullRefine_Fast(Data, CheckCandidate, 0); |
739 |
|
} else { |
740 |
|
if(MotionFlags & (XVID_ME_QUARTERPELREFINE16 | XVID_ME_QUARTERPELREFINE16_RD)) { |
741 |
|
/* full */ |
742 |
|
if (MotionFlags & XVID_ME_HALFPELREFINE16) { |
743 |
|
xvid_me_SubpelRefine(Data->currentMV[0], Data, CheckCandidate, 0); /* hpel part */ |
744 |
|
for(i = 0; i < 5; i++) { |
745 |
|
Data->currentQMV[i].x = 2 * Data->currentMV[i].x; |
746 |
|
Data->currentQMV[i].y = 2 * Data->currentMV[i].y; |
747 |
|
} |
748 |
|
} |
749 |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 4, |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 4, |
750 |
pParam->width, pParam->height, Data->iFcode, 2, 0); |
pParam->width, pParam->height, Data->iFcode, 2, 0); |
751 |
Data->qpel_precision = 1; |
Data->qpel_precision = 1; |
752 |
if (MotionFlags & XVID_ME_QUARTERPELREFINE16) { |
if(MotionFlags & XVID_ME_QUARTERPELREFINE16) |
753 |
if(MotionFlags & XVID_ME_FASTREFINE16) |
xvid_me_SubpelRefine(Data->currentQMV[0], Data, CheckCandidate, 0); /* qpel part */ |
754 |
SubpelRefine_Fast(Data, CheckCandidate16_qpel); |
} |
|
else |
|
|
xvid_me_SubpelRefine(Data, CheckCandidate16_qpel); |
|
755 |
} |
} |
756 |
} |
} |
757 |
|
|
768 |
Search8(Data, 2*x + 1, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 3, &Data8); |
Search8(Data, 2*x + 1, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 3, &Data8); |
769 |
|
|
770 |
if ((Data->chroma) && (!(VopFlags & XVID_VOP_MODEDECISION_RD))) { |
if ((Data->chroma) && (!(VopFlags & XVID_VOP_MODEDECISION_RD))) { |
771 |
/* chroma is only used for comparsion to INTER. if the comparsion will be done in BITS domain, it will not be used */ |
/* chroma is only used for comparison to INTER. if the comparison will be done in RD domain, it will not be used */ |
772 |
int sumx = 0, sumy = 0; |
int sumx = 0, sumy = 0; |
773 |
|
|
774 |
if (Data->qpel) |
if (Data->qpel) |
825 |
if ((VopFlags & XVID_VOP_GREYSCALE) || (VopFlags & XVID_VOP_REDUCED)) |
if ((VopFlags & XVID_VOP_GREYSCALE) || (VopFlags & XVID_VOP_REDUCED)) |
826 |
Flags &= ~(XVID_ME_CHROMA_PVOP + XVID_ME_CHROMA_BVOP); |
Flags &= ~(XVID_ME_CHROMA_PVOP + XVID_ME_CHROMA_BVOP); |
827 |
|
|
828 |
|
if (Flags & XVID_ME_FASTREFINE8) |
829 |
|
Flags &= ~XVID_ME_HALFPELREFINE8_RD; |
830 |
|
|
831 |
|
if (Flags & XVID_ME_FASTREFINE16) |
832 |
|
Flags &= ~XVID_ME_HALFPELREFINE16_RD; |
833 |
|
|
834 |
return Flags; |
return Flags; |
835 |
} |
} |
836 |
|
|
874 |
Data.dctSpace = dct_space; |
Data.dctSpace = dct_space; |
875 |
Data.quant_type = !(pParam->vol_flags & XVID_VOL_MPEGQUANT); |
Data.quant_type = !(pParam->vol_flags & XVID_VOL_MPEGQUANT); |
876 |
Data.mpeg_quant_matrices = pParam->mpeg_quant_matrices; |
Data.mpeg_quant_matrices = pParam->mpeg_quant_matrices; |
|
Data.iMinSAD2 = 0; |
|
877 |
|
|
878 |
if ((current->vop_flags & XVID_VOP_REDUCED)) { |
if ((current->vop_flags & XVID_VOP_REDUCED)) { |
879 |
mb_width = (pParam->width + 31) / 32; |
mb_width = (pParam->width + 31) / 32; |
899 |
pRef->y + (x + y * iEdgedWidth) * 32, |
pRef->y + (x + y * iEdgedWidth) * 32, |
900 |
pParam->edged_width, pMB->sad8 ); |
pParam->edged_width, pMB->sad8 ); |
901 |
|
|
902 |
|
sad00 = 4*MAX(MAX(pMB->sad8[0], pMB->sad8[1]), MAX(pMB->sad8[2], pMB->sad8[3])); |
903 |
|
|
904 |
if (Data.chroma) { |
if (Data.chroma) { |
905 |
Data.chromaSAD = sad8(pCurrent->u + x*8 + y*(iEdgedWidth/2)*8, |
Data.chromaSAD = sad8(pCurrent->u + x*8 + y*(iEdgedWidth/2)*8, |
906 |
pRef->u + x*8 + y*(iEdgedWidth/2)*8, iEdgedWidth/2) |
pRef->u + x*8 + y*(iEdgedWidth/2)*8, iEdgedWidth/2) |
907 |
+ sad8(pCurrent->v + (x + y*(iEdgedWidth/2))*8, |
+ sad8(pCurrent->v + (x + y*(iEdgedWidth/2))*8, |
908 |
pRef->v + (x + y*(iEdgedWidth/2))*8, iEdgedWidth/2); |
pRef->v + (x + y*(iEdgedWidth/2))*8, iEdgedWidth/2); |
909 |
pMB->sad16 += Data.chromaSAD; |
pMB->sad16 += Data.chromaSAD; |
910 |
|
sad00 += Data.chromaSAD; |
911 |
} |
} |
912 |
|
|
|
sad00 = pMB->sad16; |
|
|
|
|
913 |
/* initial skip decision */ |
/* initial skip decision */ |
914 |
/* no early skip for GMC (global vector = skip vector is unknown!) */ |
/* no early skip for GMC (global vector = skip vector is unknown!) */ |
915 |
if (current->coding_type != S_VOP) { /* no fast SKIP for S(GMC)-VOPs */ |
if (current->coding_type != S_VOP) { /* no fast SKIP for S(GMC)-VOPs */ |
963 |
else |
else |
964 |
ModeDecision_SAD(&Data, pMB, pMBs, x, y, pParam, |
ModeDecision_SAD(&Data, pMB, pMBs, x, y, pParam, |
965 |
MotionFlags, current->vop_flags, current->vol_flags, |
MotionFlags, current->vop_flags, current->vol_flags, |
966 |
pCurrent, pRef, pGMC, current->coding_type); |
pCurrent, pRef, pGMC, current->coding_type, sad00); |
967 |
|
|
968 |
|
|
969 |
if (pMB->mode == MODE_INTRA) |
if (pMB->mode == MODE_INTRA) |