80 |
return xb + yb; |
return xb + yb; |
81 |
} |
} |
82 |
|
|
83 |
|
static int32_t ChromaSAD2(int fx, int fy, int bx, int by, const SearchData * const data) |
84 |
|
{ |
85 |
|
int sad; |
86 |
|
const uint32_t stride = data->iEdgedWidth/2; |
87 |
|
uint8_t * f_refu = data->RefQ, |
88 |
|
* f_refv = data->RefQ + 8, |
89 |
|
* b_refu = data->RefQ + 16, |
90 |
|
* b_refv = data->RefQ + 24; |
91 |
|
|
92 |
|
switch (((fx & 1) << 1) | (fy & 1)) { |
93 |
|
case 0: |
94 |
|
fx = fx / 2; fy = fy / 2; |
95 |
|
f_refu = (uint8_t*)data->RefCU + fy * stride + fx, stride; |
96 |
|
f_refv = (uint8_t*)data->RefCV + fy * stride + fx, stride; |
97 |
|
break; |
98 |
|
case 1: |
99 |
|
fx = fx / 2; fy = (fy - 1) / 2; |
100 |
|
interpolate8x8_halfpel_v(f_refu, data->RefCU + fy * stride + fx, stride, data->rounding); |
101 |
|
interpolate8x8_halfpel_v(f_refv, data->RefCV + fy * stride + fx, stride, data->rounding); |
102 |
|
break; |
103 |
|
case 2: |
104 |
|
fx = (fx - 1) / 2; fy = fy / 2; |
105 |
|
interpolate8x8_halfpel_h(f_refu, data->RefCU + fy * stride + fx, stride, data->rounding); |
106 |
|
interpolate8x8_halfpel_h(f_refv, data->RefCV + fy * stride + fx, stride, data->rounding); |
107 |
|
break; |
108 |
|
default: |
109 |
|
fx = (fx - 1) / 2; fy = (fy - 1) / 2; |
110 |
|
interpolate8x8_halfpel_hv(f_refu, data->RefCU + fy * stride + fx, stride, data->rounding); |
111 |
|
interpolate8x8_halfpel_hv(f_refv, data->RefCV + fy * stride + fx, stride, data->rounding); |
112 |
|
break; |
113 |
|
} |
114 |
|
|
115 |
|
switch (((bx & 1) << 1) | (by & 1)) { |
116 |
|
case 0: |
117 |
|
bx = bx / 2; by = by / 2; |
118 |
|
b_refu = (uint8_t*)data->b_RefCU + by * stride + bx, stride; |
119 |
|
b_refv = (uint8_t*)data->b_RefCV + by * stride + bx, stride; |
120 |
|
break; |
121 |
|
case 1: |
122 |
|
bx = bx / 2; by = (by - 1) / 2; |
123 |
|
interpolate8x8_halfpel_v(b_refu, data->b_RefCU + by * stride + bx, stride, data->rounding); |
124 |
|
interpolate8x8_halfpel_v(b_refv, data->b_RefCV + by * stride + bx, stride, data->rounding); |
125 |
|
break; |
126 |
|
case 2: |
127 |
|
bx = (bx - 1) / 2; by = by / 2; |
128 |
|
interpolate8x8_halfpel_h(b_refu, data->b_RefCU + by * stride + bx, stride, data->rounding); |
129 |
|
interpolate8x8_halfpel_h(b_refv, data->b_RefCV + by * stride + bx, stride, data->rounding); |
130 |
|
break; |
131 |
|
default: |
132 |
|
bx = (bx - 1) / 2; by = (by - 1) / 2; |
133 |
|
interpolate8x8_halfpel_hv(b_refu, data->b_RefCU + by * stride + bx, stride, data->rounding); |
134 |
|
interpolate8x8_halfpel_hv(b_refv, data->b_RefCV + by * stride + bx, stride, data->rounding); |
135 |
|
break; |
136 |
|
} |
137 |
|
|
138 |
|
sad = sad8bi(data->CurU, b_refu, f_refu, stride); |
139 |
|
sad += sad8bi(data->CurV, b_refv, f_refv, stride); |
140 |
|
|
141 |
|
return sad; |
142 |
|
} |
143 |
|
|
144 |
|
|
145 |
static int32_t |
static int32_t |
146 |
ChromaSAD(int dx, int dy, const SearchData * const data) |
ChromaSAD(int dx, int dy, const SearchData * const data) |
147 |
{ |
{ |
380 |
static void |
static void |
381 |
CheckCandidate16no4v(const int x, const int y, const int Direction, int * const dir, const SearchData * const data) |
CheckCandidate16no4v(const int x, const int y, const int Direction, int * const dir, const SearchData * const data) |
382 |
{ |
{ |
383 |
int32_t sad; |
int32_t sad, xc, yc; |
384 |
const uint8_t * Reference; |
const uint8_t * Reference; |
385 |
uint32_t t; |
uint32_t t; |
386 |
VECTOR * current; |
VECTOR * current; |
393 |
if (data->qpel_precision) { // x and y are in 1/4 precision |
if (data->qpel_precision) { // x and y are in 1/4 precision |
394 |
Reference = Interpolate16x16qpel(x, y, 0, data); |
Reference = Interpolate16x16qpel(x, y, 0, data); |
395 |
current = data->currentQMV; |
current = data->currentQMV; |
396 |
|
xc = x/2; yc = y/2; |
397 |
} else { |
} else { |
398 |
Reference = GetReference(x, y, data); |
Reference = GetReference(x, y, data); |
399 |
current = data->currentMV; |
current = data->currentMV; |
400 |
|
xc = x; yc = y; |
401 |
} |
} |
402 |
t = d_mv_bits(x, y, data->predMV, data->iFcode, |
t = d_mv_bits(x, y, data->predMV, data->iFcode, |
403 |
data->qpel^data->qpel_precision, data->rrv); |
data->qpel^data->qpel_precision, data->rrv); |
405 |
sad = sad16(data->Cur, Reference, data->iEdgedWidth, 256*4096); |
sad = sad16(data->Cur, Reference, data->iEdgedWidth, 256*4096); |
406 |
sad += (data->lambda16 * t * sad)>>10; |
sad += (data->lambda16 * t * sad)>>10; |
407 |
|
|
408 |
|
if (data->chroma) sad += ChromaSAD((xc >> 1) + roundtab_79[xc & 0x3], |
409 |
|
(yc >> 1) + roundtab_79[yc & 0x3], data); |
410 |
|
|
411 |
|
|
412 |
if (sad < *(data->iMinSAD)) { |
if (sad < *(data->iMinSAD)) { |
413 |
*(data->iMinSAD) = sad; |
*(data->iMinSAD) = sad; |
414 |
current->x = x; current->y = y; |
current->x = x; current->y = y; |
415 |
*dir = Direction; } |
*dir = Direction; |
416 |
|
} |
417 |
} |
} |
418 |
|
|
419 |
static void |
static void |
445 |
static void |
static void |
446 |
CheckCandidateInt(const int xf, const int yf, const int Direction, int * const dir, const SearchData * const data) |
CheckCandidateInt(const int xf, const int yf, const int Direction, int * const dir, const SearchData * const data) |
447 |
{ |
{ |
448 |
int32_t sad, xb, yb; |
int32_t sad, xb, yb, xcf, ycf, xcb, ycb; |
449 |
uint32_t t; |
uint32_t t; |
450 |
const uint8_t *ReferenceF, *ReferenceB; |
const uint8_t *ReferenceF, *ReferenceB; |
451 |
VECTOR *current; |
VECTOR *current; |
458 |
xb = data->currentMV[1].x; yb = data->currentMV[1].y; |
xb = data->currentMV[1].x; yb = data->currentMV[1].y; |
459 |
ReferenceB = GetReferenceB(xb, yb, 1, data); |
ReferenceB = GetReferenceB(xb, yb, 1, data); |
460 |
current = data->currentMV; |
current = data->currentMV; |
461 |
|
xcf = xf; ycf = yf; |
462 |
|
xcb = xb; ycb = yb; |
463 |
} else { |
} else { |
464 |
ReferenceF = Interpolate16x16qpel(xf, yf, 0, data); |
ReferenceF = Interpolate16x16qpel(xf, yf, 0, data); |
465 |
xb = data->currentQMV[1].x; yb = data->currentQMV[1].y; |
xb = data->currentQMV[1].x; yb = data->currentQMV[1].y; |
466 |
current = data->currentQMV; |
current = data->currentQMV; |
467 |
ReferenceB = Interpolate16x16qpel(xb, yb, 1, data); |
ReferenceB = Interpolate16x16qpel(xb, yb, 1, data); |
468 |
|
xcf = xf/2; ycf = yf/2; |
469 |
|
xcb = xb/2; ycb = yb/2; |
470 |
} |
} |
471 |
|
|
472 |
t = d_mv_bits(xf, yf, data->predMV, data->iFcode, data->qpel^data->qpel_precision, 0) |
t = d_mv_bits(xf, yf, data->predMV, data->iFcode, data->qpel^data->qpel_precision, 0) |
475 |
sad = sad16bi(data->Cur, ReferenceF, ReferenceB, data->iEdgedWidth); |
sad = sad16bi(data->Cur, ReferenceF, ReferenceB, data->iEdgedWidth); |
476 |
sad += (data->lambda16 * t * sad)>>10; |
sad += (data->lambda16 * t * sad)>>10; |
477 |
|
|
478 |
|
if (data->chroma) sad += ChromaSAD2((xcf >> 1) + roundtab_79[xcf & 0x3], |
479 |
|
(ycf >> 1) + roundtab_79[ycf & 0x3], |
480 |
|
(xcb >> 1) + roundtab_79[xcb & 0x3], |
481 |
|
(ycb >> 1) + roundtab_79[ycb & 0x3], data); |
482 |
|
|
483 |
if (sad < *(data->iMinSAD)) { |
if (sad < *(data->iMinSAD)) { |
484 |
*(data->iMinSAD) = sad; |
*(data->iMinSAD) = sad; |
485 |
current->x = xf; current->y = yf; |
current->x = xf; current->y = yf; |
486 |
*dir = Direction; } |
*dir = Direction; |
487 |
|
} |
488 |
} |
} |
489 |
|
|
490 |
static void |
static void |
491 |
CheckCandidateDirect(const int x, const int y, const int Direction, int * const dir, const SearchData * const data) |
CheckCandidateDirect(const int x, const int y, const int Direction, int * const dir, const SearchData * const data) |
492 |
{ |
{ |
493 |
int32_t sad = 0; |
int32_t sad = 0, xcf = 0, ycf = 0, xcb = 0, ycb = 0; |
494 |
uint32_t k; |
uint32_t k; |
495 |
const uint8_t *ReferenceF; |
const uint8_t *ReferenceF; |
496 |
const uint8_t *ReferenceB; |
const uint8_t *ReferenceB; |
509 |
data->directmvB[k].y |
data->directmvB[k].y |
510 |
: mvs.y - data->referencemv[k].y); |
: mvs.y - data->referencemv[k].y); |
511 |
|
|
512 |
if (( mvs.x > data->max_dx ) || ( mvs.x < data->min_dx ) |
if ( (mvs.x > data->max_dx) | (mvs.x < data->min_dx) |
513 |
|| ( mvs.y > data->max_dy ) || ( mvs.y < data->min_dy ) |
| (mvs.y > data->max_dy) | (mvs.y < data->min_dy) |
514 |
|| ( b_mvs.x > data->max_dx ) || ( b_mvs.x < data->min_dx ) |
| (b_mvs.x > data->max_dx) | (b_mvs.x < data->min_dx) |
515 |
|| ( b_mvs.y > data->max_dy ) || ( b_mvs.y < data->min_dy )) return; |
| (b_mvs.y > data->max_dy) | (b_mvs.y < data->min_dy) ) return; |
516 |
|
|
517 |
|
if (data->qpel) { |
518 |
mvs.x *= 2 - data->qpel; mvs.y *= 2 - data->qpel; |
xcf += mvs.x/2; ycf += mvs.y/2; |
519 |
b_mvs.x *= 2 - data->qpel; b_mvs.y *= 2 - data->qpel; //we move to qpel precision anyway |
xcb += b_mvs.x/2; ycb += b_mvs.y/2; |
520 |
|
} else { |
521 |
|
xcf += mvs.x; ycf += mvs.y; |
522 |
|
xcb += b_mvs.x; ycb += b_mvs.y; |
523 |
|
mvs.x *= 2; mvs.y *= 2; //we move to qpel precision anyway |
524 |
|
b_mvs.x *= 2; b_mvs.y *= 2; |
525 |
|
} |
526 |
|
|
527 |
ReferenceF = Interpolate8x8qpel(mvs.x, mvs.y, k, 0, data); |
ReferenceF = Interpolate8x8qpel(mvs.x, mvs.y, k, 0, data); |
528 |
ReferenceB = Interpolate8x8qpel(b_mvs.x, b_mvs.y, k, 1, data); |
ReferenceB = Interpolate8x8qpel(b_mvs.x, b_mvs.y, k, 1, data); |
534 |
|
|
535 |
sad += (data->lambda16 * d_mv_bits(x, y, zeroMV, 1, 0, 0) * sad)>>10; |
sad += (data->lambda16 * d_mv_bits(x, y, zeroMV, 1, 0, 0) * sad)>>10; |
536 |
|
|
537 |
|
if (data->chroma) sad += ChromaSAD2((xcf >> 3) + roundtab_76[xcf & 0xf], |
538 |
|
(ycf >> 3) + roundtab_76[ycf & 0xf], |
539 |
|
(xcb >> 3) + roundtab_76[xcb & 0xf], |
540 |
|
(ycb >> 3) + roundtab_76[ycb & 0xf], data); |
541 |
|
|
542 |
if (sad < *(data->iMinSAD)) { |
if (sad < *(data->iMinSAD)) { |
543 |
*(data->iMinSAD) = sad; |
*(data->iMinSAD) = sad; |
544 |
data->currentMV->x = x; data->currentMV->y = y; |
data->currentMV->x = x; data->currentMV->y = y; |
545 |
*dir = Direction; } |
*dir = Direction; |
546 |
|
} |
547 |
} |
} |
548 |
|
|
549 |
static void |
static void |
550 |
CheckCandidateDirectno4v(const int x, const int y, const int Direction, int * const dir, const SearchData * const data) |
CheckCandidateDirectno4v(const int x, const int y, const int Direction, int * const dir, const SearchData * const data) |
551 |
{ |
{ |
552 |
int32_t sad; |
int32_t sad, xcf, ycf, xcb, ycb; |
553 |
const uint8_t *ReferenceF; |
const uint8_t *ReferenceF; |
554 |
const uint8_t *ReferenceB; |
const uint8_t *ReferenceB; |
555 |
VECTOR mvs, b_mvs; |
VECTOR mvs, b_mvs; |
566 |
data->directmvB[0].y |
data->directmvB[0].y |
567 |
: mvs.y - data->referencemv[0].y); |
: mvs.y - data->referencemv[0].y); |
568 |
|
|
569 |
if (( mvs.x > data->max_dx ) || ( mvs.x < data->min_dx ) |
if ( (mvs.x > data->max_dx) | (mvs.x < data->min_dx) |
570 |
|| ( mvs.y > data->max_dy ) || ( mvs.y < data->min_dy ) |
| (mvs.y > data->max_dy) | (mvs.y < data->min_dy) |
571 |
|| ( b_mvs.x > data->max_dx ) || ( b_mvs.x < data->min_dx ) |
| (b_mvs.x > data->max_dx) | (b_mvs.x < data->min_dx) |
572 |
|| ( b_mvs.y > data->max_dy ) || ( b_mvs.y < data->min_dy )) return; |
| (b_mvs.y > data->max_dy) | (b_mvs.y < data->min_dy) ) return; |
573 |
|
|
574 |
mvs.x *= 2 - data->qpel; mvs.y *= 2 - data->qpel; |
if (data->qpel) { |
575 |
b_mvs.x *= 2 - data->qpel; b_mvs.y *= 2 - data->qpel; //we move to qpel precision anyway |
xcf = 4*(mvs.x/2); ycf = 4*(mvs.y/2); |
576 |
|
xcb = 4*(b_mvs.x/2); ycb = 4*(b_mvs.y/2); |
577 |
ReferenceF = Interpolate16x16qpel(mvs.x, mvs.y, 0, data); |
ReferenceF = Interpolate16x16qpel(mvs.x, mvs.y, 0, data); |
578 |
ReferenceB = Interpolate16x16qpel(b_mvs.x, b_mvs.y, 1, data); |
ReferenceB = Interpolate16x16qpel(b_mvs.x, b_mvs.y, 1, data); |
579 |
|
} else { |
580 |
|
xcf = 4*mvs.x; ycf = 4*mvs.y; |
581 |
|
xcb = 4*b_mvs.x; ycb = 4*b_mvs.y; |
582 |
|
ReferenceF = GetReference(mvs.x, mvs.y, data); |
583 |
|
ReferenceB = GetReferenceB(b_mvs.x, b_mvs.y, 1, data); |
584 |
|
} |
585 |
|
|
586 |
sad = sad16bi(data->Cur, ReferenceF, ReferenceB, data->iEdgedWidth); |
sad = sad16bi(data->Cur, ReferenceF, ReferenceB, data->iEdgedWidth); |
587 |
sad += (data->lambda16 * d_mv_bits(x, y, zeroMV, 1, 0, 0) * sad)>>10; |
sad += (data->lambda16 * d_mv_bits(x, y, zeroMV, 1, 0, 0) * sad)>>10; |
588 |
|
|
589 |
|
if (data->chroma) sad += ChromaSAD2((xcf >> 3) + roundtab_76[xcf & 0xf], |
590 |
|
(ycf >> 3) + roundtab_76[ycf & 0xf], |
591 |
|
(xcb >> 3) + roundtab_76[xcb & 0xf], |
592 |
|
(ycb >> 3) + roundtab_76[ycb & 0xf], data); |
593 |
|
|
594 |
if (sad < *(data->iMinSAD)) { |
if (sad < *(data->iMinSAD)) { |
595 |
*(data->iMinSAD) = sad; |
*(data->iMinSAD) = sad; |
596 |
data->currentMV->x = x; data->currentMV->y = y; |
data->currentMV->x = x; data->currentMV->y = y; |
597 |
*dir = Direction; } |
*dir = Direction; |
598 |
|
} |
599 |
} |
} |
600 |
|
|
601 |
static void |
static void |
611 |
else Reference = GetReference(x, y, data); |
else Reference = GetReference(x, y, data); |
612 |
|
|
613 |
sad = sad8(data->Cur, Reference, data->iEdgedWidth); |
sad = sad8(data->Cur, Reference, data->iEdgedWidth); |
614 |
t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel && !data->qpel_precision, 0); |
t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision, 0); |
615 |
|
|
616 |
sad += (data->lambda8 * t * (sad+NEIGH_8X8_BIAS))>>10; |
sad += (data->lambda8 * t * (sad+NEIGH_8X8_BIAS))>>10; |
617 |
|
|
856 |
Data.iFcode = current->fcode; |
Data.iFcode = current->fcode; |
857 |
Data.rounding = pParam->m_rounding_type; |
Data.rounding = pParam->m_rounding_type; |
858 |
Data.qpel = pParam->m_quarterpel; |
Data.qpel = pParam->m_quarterpel; |
859 |
Data.chroma = current->motion_flags & ( PMV_CHROMA16 | PMV_CHROMA8 ); |
Data.chroma = current->motion_flags & PMV_CHROMA16; |
860 |
Data.rrv = current->global_flags & XVID_REDUCED; |
Data.rrv = current->global_flags & XVID_REDUCED; |
861 |
|
|
862 |
if ((current->global_flags & XVID_REDUCED)) { |
if ((current->global_flags & XVID_REDUCED)) { |
1373 |
|
|
1374 |
/* search backward or forward */ |
/* search backward or forward */ |
1375 |
static void |
static void |
1376 |
SearchBF( const uint8_t * const pRef, |
SearchBF( const IMAGE * const pRef, |
1377 |
const uint8_t * const pRefH, |
const uint8_t * const pRefH, |
1378 |
const uint8_t * const pRefV, |
const uint8_t * const pRefV, |
1379 |
const uint8_t * const pRefHV, |
const uint8_t * const pRefHV, |
1395 |
*Data->iMinSAD = MV_MAX_ERROR; |
*Data->iMinSAD = MV_MAX_ERROR; |
1396 |
Data->iFcode = iFcode; |
Data->iFcode = iFcode; |
1397 |
Data->qpel_precision = 0; |
Data->qpel_precision = 0; |
1398 |
|
Data->temp[5] = Data->temp[6] = Data->temp[7] = 256*4096; // reset chroma-sad cache |
1399 |
|
|
1400 |
Data->Ref = pRef + (x + y * Data->iEdgedWidth) * 16; |
Data->Ref = pRef->y + (x + y * Data->iEdgedWidth) * 16; |
1401 |
Data->RefH = pRefH + (x + y * Data->iEdgedWidth) * 16; |
Data->RefH = pRefH + (x + y * Data->iEdgedWidth) * 16; |
1402 |
Data->RefV = pRefV + (x + y * Data->iEdgedWidth) * 16; |
Data->RefV = pRefV + (x + y * Data->iEdgedWidth) * 16; |
1403 |
Data->RefHV = pRefHV + (x + y * Data->iEdgedWidth) * 16; |
Data->RefHV = pRefHV + (x + y * Data->iEdgedWidth) * 16; |
1404 |
|
Data->RefCU = pRef->u + (x + y * Data->iEdgedWidth/2) * 8; |
1405 |
|
Data->RefCV = pRef->v + (x + y * Data->iEdgedWidth/2) * 8; |
1406 |
|
|
1407 |
Data->predMV = *predMV; |
Data->predMV = *predMV; |
1408 |
|
|
1542 |
Data->bRefH = b_RefH + k; |
Data->bRefH = b_RefH + k; |
1543 |
Data->bRefV = b_RefV + k; |
Data->bRefV = b_RefV + k; |
1544 |
Data->bRefHV = b_RefHV + k; |
Data->bRefHV = b_RefHV + k; |
1545 |
|
Data->RefCU = f_Ref->u + (x + (Data->iEdgedWidth/2) * y) * 8; |
1546 |
|
Data->RefCV = f_Ref->v + (x + (Data->iEdgedWidth/2) * y) * 8; |
1547 |
|
Data->b_RefCU = b_Ref->u + (x + (Data->iEdgedWidth/2) * y) * 8; |
1548 |
|
Data->b_RefCV = b_Ref->v + (x + (Data->iEdgedWidth/2) * y) * 8; |
1549 |
|
|
1550 |
k = Data->qpel ? 4 : 2; |
k = Data->qpel ? 4 : 2; |
1551 |
Data->max_dx = k * (pParam->width - x * 16); |
Data->max_dx = k * (pParam->width - x * 16); |
1584 |
(*CheckCandidate)(0, 0, 255, &k, Data); |
(*CheckCandidate)(0, 0, 255, &k, Data); |
1585 |
|
|
1586 |
// initial (fast) skip decision |
// initial (fast) skip decision |
1587 |
if (*Data->iMinSAD < pMB->quant * INITIAL_SKIP_THRESH * 2) { |
if (*Data->iMinSAD < pMB->quant * INITIAL_SKIP_THRESH * (2 + Data->chroma?1:0)) { |
1588 |
//possible skip - checking chroma |
//possible skip |
1589 |
|
if (Data->chroma) { |
1590 |
|
pMB->mode = MODE_DIRECT_NONE_MV; |
1591 |
|
return *Data->iMinSAD; // skip. |
1592 |
|
} else { |
1593 |
SkipDecisionB(pCur, f_Ref, b_Ref, pMB, x, y, Data); |
SkipDecisionB(pCur, f_Ref, b_Ref, pMB, x, y, Data); |
1594 |
if (pMB->mode == MODE_DIRECT_NONE_MV) return *Data->iMinSAD; // skip. |
if (pMB->mode == MODE_DIRECT_NONE_MV) return *Data->iMinSAD; // skip. |
1595 |
} |
} |
1596 |
|
} |
1597 |
|
|
1598 |
skip_sad = *Data->iMinSAD; |
skip_sad = *Data->iMinSAD; |
1599 |
|
|
1643 |
} |
} |
1644 |
|
|
1645 |
static void |
static void |
1646 |
SearchInterpolate(const uint8_t * const f_Ref, |
SearchInterpolate(const IMAGE * const f_Ref, |
1647 |
const uint8_t * const f_RefH, |
const uint8_t * const f_RefH, |
1648 |
const uint8_t * const f_RefV, |
const uint8_t * const f_RefV, |
1649 |
const uint8_t * const f_RefHV, |
const uint8_t * const f_RefHV, |
1650 |
const uint8_t * const b_Ref, |
const IMAGE * const b_Ref, |
1651 |
const uint8_t * const b_RefH, |
const uint8_t * const b_RefH, |
1652 |
const uint8_t * const b_RefV, |
const uint8_t * const b_RefV, |
1653 |
const uint8_t * const b_RefHV, |
const uint8_t * const b_RefHV, |
1675 |
fData->iFcode = bData.bFcode = fcode; fData->bFcode = bData.iFcode = bcode; |
fData->iFcode = bData.bFcode = fcode; fData->bFcode = bData.iFcode = bcode; |
1676 |
|
|
1677 |
i = (x + y * fData->iEdgedWidth) * 16; |
i = (x + y * fData->iEdgedWidth) * 16; |
1678 |
bData.bRef = fData->Ref = f_Ref + i; |
bData.bRef = fData->Ref = f_Ref->y + i; |
1679 |
bData.bRefH = fData->RefH = f_RefH + i; |
bData.bRefH = fData->RefH = f_RefH + i; |
1680 |
bData.bRefV = fData->RefV = f_RefV + i; |
bData.bRefV = fData->RefV = f_RefV + i; |
1681 |
bData.bRefHV = fData->RefHV = f_RefHV + i; |
bData.bRefHV = fData->RefHV = f_RefHV + i; |
1682 |
bData.Ref = fData->bRef = b_Ref + i; |
bData.Ref = fData->bRef = b_Ref->y + i; |
1683 |
bData.RefH = fData->bRefH = b_RefH + i; |
bData.RefH = fData->bRefH = b_RefH + i; |
1684 |
bData.RefV = fData->bRefV = b_RefV + i; |
bData.RefV = fData->bRefV = b_RefV + i; |
1685 |
bData.RefHV = fData->bRefHV = b_RefHV + i; |
bData.RefHV = fData->bRefHV = b_RefHV + i; |
1686 |
|
bData.b_RefCU = fData->RefCU = f_Ref->u + (x + (fData->iEdgedWidth/2) * y) * 8; |
1687 |
|
bData.b_RefCV = fData->RefCV = f_Ref->v + (x + (fData->iEdgedWidth/2) * y) * 8; |
1688 |
|
bData.RefCU = fData->b_RefCU = b_Ref->u + (x + (fData->iEdgedWidth/2) * y) * 8; |
1689 |
|
bData.RefCV = fData->b_RefCV = b_Ref->v + (x + (fData->iEdgedWidth/2) * y) * 8; |
1690 |
|
|
1691 |
|
|
1692 |
bData.bpredMV = fData->predMV = *f_predMV; |
bData.bpredMV = fData->predMV = *f_predMV; |
1693 |
fData->bpredMV = bData.predMV = *b_predMV; |
fData->bpredMV = bData.predMV = *b_predMV; |
1804 |
int32_t iMinSAD; |
int32_t iMinSAD; |
1805 |
VECTOR currentMV[3]; |
VECTOR currentMV[3]; |
1806 |
VECTOR currentQMV[3]; |
VECTOR currentQMV[3]; |
1807 |
|
int32_t temp[8]; |
1808 |
memset(&Data, 0, sizeof(SearchData)); |
memset(&Data, 0, sizeof(SearchData)); |
1809 |
Data.iEdgedWidth = pParam->edged_width; |
Data.iEdgedWidth = pParam->edged_width; |
1810 |
Data.currentMV = currentMV; Data.currentQMV = currentQMV; |
Data.currentMV = currentMV; Data.currentQMV = currentQMV; |
1811 |
Data.iMinSAD = &iMinSAD; |
Data.iMinSAD = &iMinSAD; |
1812 |
Data.lambda16 = lambda_vec16[frame->quant]; |
Data.lambda16 = lambda_vec16[frame->quant]; |
|
Data.chroma = frame->quant; |
|
1813 |
Data.qpel = pParam->m_quarterpel; |
Data.qpel = pParam->m_quarterpel; |
1814 |
Data.rounding = 0; |
Data.rounding = 0; |
1815 |
|
Data.chroma = frame->motion_flags & PMV_CHROMA8; |
1816 |
|
Data.temp = temp; |
1817 |
|
|
1818 |
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) |
1819 |
// note: i==horizontal, j==vertical |
// note: i==horizontal, j==vertical |
1833 |
} |
} |
1834 |
|
|
1835 |
Data.Cur = frame->image.y + (j * Data.iEdgedWidth + i) * 16; |
Data.Cur = frame->image.y + (j * Data.iEdgedWidth + i) * 16; |
1836 |
|
Data.CurU = frame->image.u + (j * Data.iEdgedWidth/2 + i) * 8; |
1837 |
|
Data.CurV = frame->image.v + (j * Data.iEdgedWidth/2 + i) * 8; |
1838 |
pMB->quant = frame->quant; |
pMB->quant = frame->quant; |
1839 |
|
|
1840 |
/* direct search comes first, because it (1) checks for SKIP-mode |
/* direct search comes first, because it (1) checks for SKIP-mode |
1853 |
if (pMB->mode == MODE_DIRECT_NONE_MV) { n_count++; continue; } |
if (pMB->mode == MODE_DIRECT_NONE_MV) { n_count++; continue; } |
1854 |
|
|
1855 |
// forward search |
// forward search |
1856 |
SearchBF(f_ref->y, f_refH->y, f_refV->y, f_refHV->y, |
SearchBF(f_ref, f_refH->y, f_refV->y, f_refHV->y, |
1857 |
&frame->image, i, j, |
&frame->image, i, j, |
1858 |
frame->motion_flags, |
frame->motion_flags, |
1859 |
frame->fcode, pParam, |
frame->fcode, pParam, |
1861 |
MODE_FORWARD, &Data); |
MODE_FORWARD, &Data); |
1862 |
|
|
1863 |
// backward search |
// backward search |
1864 |
SearchBF(b_ref->y, b_refH->y, b_refV->y, b_refHV->y, |
SearchBF(b_ref, b_refH->y, b_refV->y, b_refHV->y, |
1865 |
&frame->image, i, j, |
&frame->image, i, j, |
1866 |
frame->motion_flags, |
frame->motion_flags, |
1867 |
frame->bcode, pParam, |
frame->bcode, pParam, |
1869 |
MODE_BACKWARD, &Data); |
MODE_BACKWARD, &Data); |
1870 |
|
|
1871 |
// interpolate search comes last, because it uses data from forward and backward as prediction |
// interpolate search comes last, because it uses data from forward and backward as prediction |
1872 |
SearchInterpolate(f_ref->y, f_refH->y, f_refV->y, f_refHV->y, |
SearchInterpolate(f_ref, f_refH->y, f_refV->y, f_refHV->y, |
1873 |
b_ref->y, b_refH->y, b_refV->y, b_refHV->y, |
b_ref, b_refH->y, b_refV->y, b_refHV->y, |
1874 |
&frame->image, |
&frame->image, |
1875 |
i, j, |
i, j, |
1876 |
frame->fcode, frame->bcode, |
frame->fcode, frame->bcode, |