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_bvop.c,v 1.1.2.4 2003-11-16 15:32:37 edgomez Exp $ |
* $Id: estimation_bvop.c,v 1.1.2.5 2003-11-19 12:24:25 syskin Exp $ |
25 |
* |
* |
26 |
****************************************************************************/ |
****************************************************************************/ |
27 |
|
|
42 |
|
|
43 |
static int32_t |
static int32_t |
44 |
ChromaSAD2(const int fx, const int fy, const int bx, const int by, |
ChromaSAD2(const int fx, const int fy, const int bx, const int by, |
45 |
const SearchData * const data) |
SearchData * const data) |
46 |
{ |
{ |
47 |
int sad; |
int sad; |
48 |
const uint32_t stride = data->iEdgedWidth/2; |
const uint32_t stride = data->iEdgedWidth/2; |
88 |
} |
} |
89 |
|
|
90 |
static void |
static void |
91 |
CheckCandidateInt(const int xf, const int yf, const SearchData * const data, const unsigned int Direction) |
CheckCandidateInt(const int x, const int y, SearchData * const data, const unsigned int Direction) |
92 |
{ |
{ |
93 |
int32_t sad, xb, yb, xcf, ycf, xcb, ycb; |
int32_t sad, xf, yf, xb, yb, xcf, ycf, xcb, ycb; |
94 |
uint32_t t; |
uint32_t t; |
95 |
|
|
96 |
const uint8_t *ReferenceF, *ReferenceB; |
const uint8_t *ReferenceF, *ReferenceB; |
97 |
VECTOR *current; |
VECTOR *current; |
98 |
|
|
99 |
if ((xf > data->max_dx) || (xf < data->min_dx) || |
if ((x > data->max_dx) || (x < data->min_dx) || |
100 |
(yf > data->max_dy) || (yf < data->min_dy)) |
(y > data->max_dy) || (y < data->min_dy)) |
101 |
return; |
return; |
102 |
|
|
103 |
|
if (Direction == 1) { /* x and y mean forward vector */ |
104 |
|
VECTOR backward = data->qpel_precision ? data->currentQMV[1] : data->currentMV[1]; |
105 |
|
xb = backward.x; |
106 |
|
yb = backward.y; |
107 |
|
xf = x; yf = y; |
108 |
|
} else { /* x and y mean backward vector */ |
109 |
|
VECTOR forward = data->qpel_precision ? data->currentQMV[0] : data->currentMV[0]; |
110 |
|
xf = forward.x; |
111 |
|
yf = forward.y; |
112 |
|
xb = x; yb = y; |
113 |
|
} |
114 |
|
|
115 |
if (!data->qpel_precision) { |
if (!data->qpel_precision) { |
116 |
ReferenceF = GetReference(xf, yf, data); |
ReferenceF = GetReference(xf, yf, data); |
|
xb = data->currentMV[1].x; yb = data->currentMV[1].y; |
|
117 |
ReferenceB = GetReferenceB(xb, yb, 1, data); |
ReferenceB = GetReferenceB(xb, yb, 1, data); |
118 |
current = data->currentMV; |
current = data->currentMV + Direction - 1; |
119 |
xcf = xf; ycf = yf; |
xcf = xf; ycf = yf; |
120 |
xcb = xb; ycb = yb; |
xcb = xb; ycb = yb; |
121 |
} else { |
} else { |
122 |
ReferenceF = xvid_me_interpolate16x16qpel(xf, yf, 0, data); |
ReferenceF = xvid_me_interpolate16x16qpel(xf, yf, 0, data); |
123 |
xb = data->currentQMV[1].x; yb = data->currentQMV[1].y; |
current = data->currentQMV + Direction - 1; |
|
current = data->currentQMV; |
|
124 |
ReferenceB = xvid_me_interpolate16x16qpel(xb, yb, 1, data); |
ReferenceB = xvid_me_interpolate16x16qpel(xb, yb, 1, data); |
125 |
xcf = xf/2; ycf = yf/2; |
xcf = xf/2; ycf = yf/2; |
126 |
xcb = xb/2; ycb = yb/2; |
xcb = xb/2; ycb = yb/2; |
139 |
(ycb >> 1) + roundtab_79[ycb & 0x3], data); |
(ycb >> 1) + roundtab_79[ycb & 0x3], data); |
140 |
|
|
141 |
if (sad < *(data->iMinSAD)) { |
if (sad < *(data->iMinSAD)) { |
142 |
*(data->iMinSAD) = sad; |
*data->iMinSAD = sad; |
143 |
current->x = xf; current->y = yf; |
current->x = x; current->y = y; |
144 |
*data->dir = Direction; |
data->dir = Direction; |
145 |
} |
} |
146 |
} |
} |
147 |
|
|
148 |
static void |
static void |
149 |
CheckCandidateDirect(const int x, const int y, const SearchData * const data, const unsigned int Direction) |
CheckCandidateDirect(const int x, const int y, SearchData * const data, const unsigned int Direction) |
150 |
{ |
{ |
151 |
int32_t sad = 0, xcf = 0, ycf = 0, xcb = 0, ycb = 0; |
int32_t sad = 0, xcf = 0, ycf = 0, xcb = 0, ycb = 0; |
152 |
uint32_t k; |
uint32_t k; |
200 |
(ycb >> 3) + roundtab_76[ycb & 0xf], data); |
(ycb >> 3) + roundtab_76[ycb & 0xf], data); |
201 |
|
|
202 |
if (sad < *(data->iMinSAD)) { |
if (sad < *(data->iMinSAD)) { |
203 |
*(data->iMinSAD) = sad; |
data->iMinSAD[0] = sad; |
204 |
data->currentMV->x = x; data->currentMV->y = y; |
data->currentMV->x = x; data->currentMV->y = y; |
205 |
*data->dir = Direction; |
data->dir = Direction; |
206 |
} |
} |
207 |
} |
} |
208 |
|
|
209 |
static void |
static void |
210 |
CheckCandidateDirectno4v(const int x, const int y, const SearchData * const data, const unsigned int Direction) |
CheckCandidateDirectno4v(const int x, const int y, SearchData * const data, const unsigned int Direction) |
211 |
{ |
{ |
212 |
int32_t sad, xcf, ycf, xcb, ycb; |
int32_t sad, xcf, ycf, xcb, ycb; |
213 |
const uint8_t *ReferenceF; |
const uint8_t *ReferenceF; |
255 |
if (sad < *(data->iMinSAD)) { |
if (sad < *(data->iMinSAD)) { |
256 |
*(data->iMinSAD) = sad; |
*(data->iMinSAD) = sad; |
257 |
data->currentMV->x = x; data->currentMV->y = y; |
data->currentMV->x = x; data->currentMV->y = y; |
258 |
*data->dir = Direction; |
data->dir = Direction; |
259 |
} |
} |
260 |
} |
} |
261 |
|
|
262 |
void |
void |
263 |
CheckCandidate16no4v(const int x, const int y, const SearchData * const data, const unsigned int Direction) |
CheckCandidate16no4v(const int x, const int y, SearchData * const data, const unsigned int Direction) |
264 |
{ |
{ |
265 |
int32_t sad, xc, yc; |
int32_t sad, xc, yc; |
266 |
const uint8_t * Reference; |
const uint8_t * Reference; |
294 |
if (sad < *(data->iMinSAD)) { |
if (sad < *(data->iMinSAD)) { |
295 |
*(data->iMinSAD) = sad; |
*(data->iMinSAD) = sad; |
296 |
current->x = x; current->y = y; |
current->x = x; current->y = y; |
297 |
*data->dir = Direction; |
data->dir = Direction; |
298 |
} |
} |
299 |
} |
} |
300 |
|
|
302 |
ChoosePred(const MACROBLOCK * const pMB, const uint32_t mode) |
ChoosePred(const MACROBLOCK * const pMB, const uint32_t mode) |
303 |
{ |
{ |
304 |
/* the stupidiest function ever */ |
/* the stupidiest function ever */ |
305 |
return (mode == MODE_FORWARD) ? pMB->mvs[0] : pMB->b_mvs[0]; |
return (mode == MODE_FORWARD ? pMB->mvs[0] : pMB->b_mvs[0]); |
306 |
} |
} |
307 |
|
|
308 |
static void __inline |
static void __inline |
365 |
*Data->iMinSAD = MV_MAX_ERROR; |
*Data->iMinSAD = MV_MAX_ERROR; |
366 |
Data->iFcode = iFcode; |
Data->iFcode = iFcode; |
367 |
Data->qpel_precision = 0; |
Data->qpel_precision = 0; |
368 |
Data->temp[5] = Data->temp[6] = Data->temp[7] = 256*4096; /* reset chroma-sad cache */ |
Data->chromaX = Data->chromaX = Data->chromaSAD = 256*4096; /* reset chroma-sad cache */ |
369 |
|
|
370 |
Data->RefP[0] = pRef->y + (x + Data->iEdgedWidth*y) * 16; |
Data->RefP[0] = pRef->y + (x + Data->iEdgedWidth*y) * 16; |
371 |
Data->RefP[2] = pRefH + (x + Data->iEdgedWidth*y) * 16; |
Data->RefP[2] = pRefH + (x + Data->iEdgedWidth*y) * 16; |
396 |
else MainSearchPtr = xvid_me_DiamondSearch; |
else MainSearchPtr = xvid_me_DiamondSearch; |
397 |
|
|
398 |
if (*Data->iMinSAD > 512) { |
if (*Data->iMinSAD > 512) { |
399 |
unsigned int mask = make_mask(pmv, 7, *Data->dir); |
unsigned int mask = make_mask(pmv, 7, Data->dir); |
400 |
MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, mask, CheckCandidate16no4v); |
MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, mask, CheckCandidate16no4v); |
401 |
} |
} |
402 |
|
|
622 |
return skip_sad; |
return skip_sad; |
623 |
} |
} |
624 |
|
|
625 |
|
|
626 |
|
static void set_range(int * range, SearchData * Data) |
627 |
|
{ |
628 |
|
Data->min_dx = range[0]; |
629 |
|
Data->max_dx = range[1]; |
630 |
|
Data->min_dy = range[2]; |
631 |
|
Data->max_dy = range[3]; |
632 |
|
} |
633 |
|
|
634 |
|
static void |
635 |
|
SubpelRefine_dir(SearchData * const data, CheckFunc * const CheckCandidate, const int dir) |
636 |
|
{ |
637 |
|
/* Do a half-pel or q-pel refinement */ |
638 |
|
const VECTOR centerMV = data->qpel_precision ? |
639 |
|
data->currentQMV[dir-1] : data->currentMV[dir-1]; |
640 |
|
|
641 |
|
CHECK_CANDIDATE(centerMV.x, centerMV.y - 1, dir); |
642 |
|
CHECK_CANDIDATE(centerMV.x + 1, centerMV.y - 1, dir); |
643 |
|
CHECK_CANDIDATE(centerMV.x + 1, centerMV.y, dir); |
644 |
|
CHECK_CANDIDATE(centerMV.x + 1, centerMV.y + 1, dir); |
645 |
|
CHECK_CANDIDATE(centerMV.x, centerMV.y + 1, dir); |
646 |
|
CHECK_CANDIDATE(centerMV.x - 1, centerMV.y + 1, dir); |
647 |
|
CHECK_CANDIDATE(centerMV.x - 1, centerMV.y, dir); |
648 |
|
CHECK_CANDIDATE(centerMV.x - 1, centerMV.y - 1, dir); |
649 |
|
} |
650 |
|
|
651 |
static void |
static void |
652 |
SearchInterpolate(const IMAGE * const f_Ref, |
SearchInterpolate(const IMAGE * const f_Ref, |
653 |
const uint8_t * const f_RefH, |
const uint8_t * const f_RefH, |
666 |
const VECTOR * const b_predMV, |
const VECTOR * const b_predMV, |
667 |
MACROBLOCK * const pMB, |
MACROBLOCK * const pMB, |
668 |
int32_t * const best_sad, |
int32_t * const best_sad, |
669 |
SearchData * const fData) |
SearchData * const Data) |
670 |
|
|
671 |
{ |
{ |
672 |
int i, j; |
int i, j; |
673 |
SearchData bData; |
int b_range[4], f_range[4]; |
674 |
|
|
675 |
|
Data->qpel_precision = 0; |
676 |
|
*Data->iMinSAD = 4096*256; |
677 |
|
Data->iFcode = fcode; Data->bFcode = bcode; |
678 |
|
|
679 |
|
i = (x + y * Data->iEdgedWidth) * 16; |
680 |
|
|
681 |
|
Data->RefP[0] = f_Ref->y + i; |
682 |
|
Data->RefP[2] = f_RefH + i; |
683 |
|
Data->RefP[1] = f_RefV + i; |
684 |
|
Data->RefP[3] = f_RefHV + i; |
685 |
|
Data->b_RefP[0] = b_Ref->y + i; |
686 |
|
Data->b_RefP[2] = b_RefH + i; |
687 |
|
Data->b_RefP[1] = b_RefV + i; |
688 |
|
Data->b_RefP[3] = b_RefHV + i; |
689 |
|
Data->RefP[4] = f_Ref->u + (x + (Data->iEdgedWidth/2) * y) * 8; |
690 |
|
Data->RefP[5] = f_Ref->v + (x + (Data->iEdgedWidth/2) * y) * 8; |
691 |
|
Data->b_RefP[4] = b_Ref->u + (x + (Data->iEdgedWidth/2) * y) * 8; |
692 |
|
Data->b_RefP[5] = b_Ref->v + (x + (Data->iEdgedWidth/2) * y) * 8; |
693 |
|
|
694 |
|
Data->predMV = *f_predMV; |
695 |
|
Data->bpredMV = *b_predMV; |
696 |
|
|
697 |
|
Data->currentMV[0] = Data->currentMV[2]; /* forward search left its vector here */ |
698 |
|
|
699 |
fData->qpel_precision = 0; |
get_range(f_range, f_range+1, f_range+2, f_range+3, x, y, 4, pParam->width, pParam->height, fcode - Data->qpel, 1, 0); |
700 |
memcpy(&bData, fData, sizeof(SearchData)); /* quick copy of common data */ |
get_range(b_range, b_range+1, b_range+2, b_range+3, x, y, 4, pParam->width, pParam->height, bcode - Data->qpel, 1, 0); |
|
*fData->iMinSAD = 4096*256; |
|
|
bData.currentMV++; bData.currentQMV++; |
|
|
fData->iFcode = bData.bFcode = fcode; fData->bFcode = bData.iFcode = bcode; |
|
|
|
|
|
i = (x + y * fData->iEdgedWidth) * 16; |
|
|
|
|
|
bData.b_RefP[0] = fData->RefP[0] = f_Ref->y + i; |
|
|
bData.b_RefP[2] = fData->RefP[2] = f_RefH + i; |
|
|
bData.b_RefP[1] = fData->RefP[1] = f_RefV + i; |
|
|
bData.b_RefP[3] = fData->RefP[3] = f_RefHV + i; |
|
|
bData.RefP[0] = fData->b_RefP[0] = b_Ref->y + i; |
|
|
bData.RefP[2] = fData->b_RefP[2] = b_RefH + i; |
|
|
bData.RefP[1] = fData->b_RefP[1] = b_RefV + i; |
|
|
bData.RefP[3] = fData->b_RefP[3] = b_RefHV + i; |
|
|
bData.b_RefP[4] = fData->RefP[4] = f_Ref->u + (x + (fData->iEdgedWidth/2) * y) * 8; |
|
|
bData.b_RefP[5] = fData->RefP[5] = f_Ref->v + (x + (fData->iEdgedWidth/2) * y) * 8; |
|
|
bData.RefP[4] = fData->b_RefP[4] = b_Ref->u + (x + (fData->iEdgedWidth/2) * y) * 8; |
|
|
bData.RefP[5] = fData->b_RefP[5] = b_Ref->v + (x + (fData->iEdgedWidth/2) * y) * 8; |
|
|
bData.dir = fData->dir; |
|
|
|
|
|
bData.bpredMV = fData->predMV = *f_predMV; |
|
|
fData->bpredMV = bData.predMV = *b_predMV; |
|
|
fData->currentMV[0] = fData->currentMV[2]; |
|
|
|
|
|
get_range(&fData->min_dx, &fData->max_dx, &fData->min_dy, &fData->max_dy, x, y, 4, pParam->width, pParam->height, fcode - fData->qpel, 1, 0); |
|
|
get_range(&bData.min_dx, &bData.max_dx, &bData.min_dy, &bData.max_dy, x, y, 4, pParam->width, pParam->height, bcode - fData->qpel, 1, 0); |
|
|
|
|
|
if (fData->currentMV[0].x > fData->max_dx) fData->currentMV[0].x = fData->max_dx; |
|
|
if (fData->currentMV[0].x < fData->min_dx) fData->currentMV[0].x = fData->min_dx; |
|
|
if (fData->currentMV[0].y > fData->max_dy) fData->currentMV[0].y = fData->max_dy; |
|
|
if (fData->currentMV[0].y < fData->min_dy) fData->currentMV[0].y = fData->min_dy; |
|
|
|
|
|
if (fData->currentMV[1].x > bData.max_dx) fData->currentMV[1].x = bData.max_dx; |
|
|
if (fData->currentMV[1].x < bData.min_dx) fData->currentMV[1].x = bData.min_dx; |
|
|
if (fData->currentMV[1].y > bData.max_dy) fData->currentMV[1].y = bData.max_dy; |
|
|
if (fData->currentMV[1].y < bData.min_dy) fData->currentMV[1].y = bData.min_dy; |
|
701 |
|
|
702 |
CheckCandidateInt(fData->currentMV[0].x, fData->currentMV[0].y, fData, 255); |
if (Data->currentMV[0].x > f_range[1]) Data->currentMV[0].x = f_range[1]; |
703 |
|
if (Data->currentMV[0].x < f_range[0]) Data->currentMV[0].x = f_range[0]; |
704 |
|
if (Data->currentMV[0].y > f_range[3]) Data->currentMV[0].y = f_range[3]; |
705 |
|
if (Data->currentMV[0].y < f_range[2]) Data->currentMV[0].y = f_range[2]; |
706 |
|
|
707 |
|
if (Data->currentMV[1].x > b_range[1]) Data->currentMV[1].x = b_range[1]; |
708 |
|
if (Data->currentMV[1].x < b_range[0]) Data->currentMV[1].x = b_range[0]; |
709 |
|
if (Data->currentMV[1].y > b_range[3]) Data->currentMV[1].y = b_range[3]; |
710 |
|
if (Data->currentMV[1].y < b_range[2]) Data->currentMV[1].y = b_range[2]; |
711 |
|
|
712 |
|
set_range(f_range, Data); |
713 |
|
|
714 |
|
CheckCandidateInt(Data->currentMV[0].x, Data->currentMV[0].y, Data, 1); |
715 |
|
|
716 |
/* diamond */ |
/* diamond */ |
717 |
do { |
do { |
718 |
*fData->dir = 255; |
Data->dir = 0; |
719 |
/* forward MV moves */ |
/* forward MV moves */ |
720 |
i = fData->currentMV[0].x; j = fData->currentMV[0].y; |
i = Data->currentMV[0].x; j = Data->currentMV[0].y; |
721 |
|
|
722 |
CheckCandidateInt(i + 1, j, fData, 0); |
CheckCandidateInt(i + 1, j, Data, 1); |
723 |
CheckCandidateInt(i, j + 1, fData, 0); |
CheckCandidateInt(i, j + 1, Data, 1); |
724 |
CheckCandidateInt(i - 1, j, fData, 0); |
CheckCandidateInt(i - 1, j, Data, 1); |
725 |
CheckCandidateInt(i, j - 1, fData, 0); |
CheckCandidateInt(i, j - 1, Data, 1); |
726 |
|
|
727 |
/* backward MV moves */ |
/* backward MV moves */ |
728 |
i = fData->currentMV[1].x; j = fData->currentMV[1].y; |
set_range(b_range, Data); |
729 |
fData->currentMV[2] = fData->currentMV[0]; |
i = Data->currentMV[1].x; j = Data->currentMV[1].y; |
730 |
CheckCandidateInt(i + 1, j, &bData, 0); |
|
731 |
CheckCandidateInt(i, j + 1, &bData, 0); |
CheckCandidateInt(i + 1, j, Data, 2); |
732 |
CheckCandidateInt(i - 1, j, &bData, 0); |
CheckCandidateInt(i, j + 1, Data, 2); |
733 |
CheckCandidateInt(i, j - 1, &bData, 0); |
CheckCandidateInt(i - 1, j, Data, 2); |
734 |
|
CheckCandidateInt(i, j - 1, Data, 2); |
735 |
|
|
736 |
|
set_range(f_range, Data); |
737 |
|
|
738 |
} while (!(*fData->dir)); |
} while (Data->dir != 0); |
739 |
|
|
740 |
/* qpel refinement */ |
/* qpel refinement */ |
741 |
if (fData->qpel) { |
if (Data->qpel) { |
742 |
if (*fData->iMinSAD > *best_sad + 500) return; |
if (*Data->iMinSAD > *best_sad + 500) return; |
743 |
fData->qpel_precision = bData.qpel_precision = 1; |
Data->qpel_precision = 1; |
744 |
get_range(&fData->min_dx, &fData->max_dx, &fData->min_dy, &fData->max_dy, x, y, 4, pParam->width, pParam->height, fcode, 2, 0); |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 4, pParam->width, pParam->height, fcode, 2, 0); |
745 |
get_range(&bData.min_dx, &bData.max_dx, &bData.min_dy, &bData.max_dy, x, y, 4, pParam->width, pParam->height, bcode, 2, 0); |
|
746 |
fData->currentQMV[2].x = fData->currentQMV[0].x = 2 * fData->currentMV[0].x; |
Data->currentQMV[0].x = 2 * Data->currentMV[0].x; |
747 |
fData->currentQMV[2].y = fData->currentQMV[0].y = 2 * fData->currentMV[0].y; |
Data->currentQMV[0].y = 2 * Data->currentMV[0].y; |
748 |
fData->currentQMV[1].x = 2 * fData->currentMV[1].x; |
Data->currentQMV[1].x = 2 * Data->currentMV[1].x; |
749 |
fData->currentQMV[1].y = 2 * fData->currentMV[1].y; |
Data->currentQMV[1].y = 2 * Data->currentMV[1].y; |
750 |
xvid_me_SubpelRefine(fData, CheckCandidateInt); |
SubpelRefine_dir(Data, CheckCandidateInt, 1); |
751 |
if (*fData->iMinSAD > *best_sad + 300) return; |
if (*Data->iMinSAD > *best_sad + 300) return; |
752 |
fData->currentQMV[2] = fData->currentQMV[0]; |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 4, pParam->width, pParam->height, bcode, 2, 0); |
753 |
xvid_me_SubpelRefine(&bData, CheckCandidateInt); |
SubpelRefine_dir(Data, CheckCandidateInt, 2); |
754 |
} |
} |
755 |
|
|
756 |
*fData->iMinSAD += (2+3) * fData->lambda16; /* two bits are needed to code interpolate mode. */ |
*Data->iMinSAD += (2+3) * Data->lambda16; /* two bits are needed to code interpolate mode. */ |
757 |
|
|
758 |
if (*fData->iMinSAD < *best_sad) { |
if (*Data->iMinSAD < *best_sad) { |
759 |
*best_sad = *fData->iMinSAD; |
*best_sad = *Data->iMinSAD; |
760 |
pMB->mvs[0] = fData->currentMV[0]; |
pMB->mvs[0] = Data->currentMV[0]; |
761 |
pMB->b_mvs[0] = fData->currentMV[1]; |
pMB->b_mvs[0] = Data->currentMV[1]; |
762 |
pMB->mode = MODE_INTERPOLATE; |
pMB->mode = MODE_INTERPOLATE; |
763 |
if (fData->qpel) { |
if (Data->qpel) { |
764 |
pMB->qmvs[0] = fData->currentQMV[0]; |
pMB->qmvs[0] = Data->currentQMV[0]; |
765 |
pMB->b_qmvs[0] = fData->currentQMV[1]; |
pMB->b_qmvs[0] = Data->currentQMV[1]; |
766 |
pMB->pmvs[1].x = pMB->qmvs[0].x - f_predMV->x; |
pMB->pmvs[1].x = pMB->qmvs[0].x - f_predMV->x; |
767 |
pMB->pmvs[1].y = pMB->qmvs[0].y - f_predMV->y; |
pMB->pmvs[1].y = pMB->qmvs[0].y - f_predMV->y; |
768 |
pMB->pmvs[0].x = pMB->b_qmvs[0].x - b_predMV->x; |
pMB->pmvs[0].x = pMB->b_qmvs[0].x - b_predMV->x; |
808 |
/* some pre-inintialized data for the rest of the search */ |
/* some pre-inintialized data for the rest of the search */ |
809 |
|
|
810 |
SearchData Data; |
SearchData Data; |
|
int32_t iMinSAD; |
|
|
uint32_t dir; |
|
|
VECTOR currentMV[3]; |
|
|
VECTOR currentQMV[3]; |
|
|
int32_t temp[8]; |
|
811 |
memset(&Data, 0, sizeof(SearchData)); |
memset(&Data, 0, sizeof(SearchData)); |
812 |
|
|
813 |
Data.iEdgedWidth = pParam->edged_width; |
Data.iEdgedWidth = pParam->edged_width; |
|
Data.currentMV = currentMV; Data.currentQMV = currentQMV; |
|
|
Data.iMinSAD = &iMinSAD; |
|
814 |
Data.lambda16 = xvid_me_lambda_vec16[MAX(frame->quant-2, 2)]; |
Data.lambda16 = xvid_me_lambda_vec16[MAX(frame->quant-2, 2)]; |
815 |
Data.qpel = pParam->vol_flags & XVID_VOL_QUARTERPEL ? 1 : 0; |
Data.qpel = pParam->vol_flags & XVID_VOL_QUARTERPEL ? 1 : 0; |
816 |
Data.rounding = 0; |
Data.rounding = 0; |
817 |
Data.chroma = frame->motion_flags & XVID_ME_CHROMA_BVOP; |
Data.chroma = frame->motion_flags & XVID_ME_CHROMA_BVOP; |
|
Data.temp = temp; |
|
|
Data.dir = &dir; |
|
818 |
Data.iQuant = frame->quant; |
Data.iQuant = frame->quant; |
819 |
|
|
820 |
Data.RefQ = f_refV->u; /* a good place, also used in MC (for similar purpose) */ |
Data.RefQ = f_refV->u; /* a good place, also used in MC (for similar purpose) */ |
832 |
if (b_reference->coding_type != S_VOP) |
if (b_reference->coding_type != S_VOP) |
833 |
if (b_mb->mode == MODE_NOT_CODED) { |
if (b_mb->mode == MODE_NOT_CODED) { |
834 |
pMB->mode = MODE_NOT_CODED; |
pMB->mode = MODE_NOT_CODED; |
835 |
pMB->mvs[0] = zeroMV; |
pMB->mvs[0] = pMB->b_mvs[0] = zeroMV; |
|
pMB->b_mvs[0] = zeroMV; |
|
836 |
continue; |
continue; |
837 |
} |
} |
838 |
|
|