528 |
const int32_t iEdgedWidth = pParam->edged_width; |
const int32_t iEdgedWidth = pParam->edged_width; |
529 |
const uint8_t * cur = pCur->y + x*16 + y*16*iEdgedWidth; |
const uint8_t * cur = pCur->y + x*16 + y*16*iEdgedWidth; |
530 |
int32_t iSAD; |
int32_t iSAD; |
531 |
int32_t pred_x,pred_y; |
VECTOR pred; |
532 |
|
|
533 |
get_pmv(pMBs, x, y, pParam->mb_width, 0, &pred_x, &pred_y); |
|
534 |
|
pred = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0); |
535 |
|
|
536 |
iSAD = sad16( cur, |
iSAD = sad16( cur, |
537 |
get_ref(pRef, pRefH, pRefV, pRefHV, x, y, 16, 0,0, iEdgedWidth), |
get_ref(pRef, pRefH, pRefV, pRefHV, x, y, 16, 0,0, iEdgedWidth), |
541 |
|
|
542 |
currMV->x = 0; |
currMV->x = 0; |
543 |
currMV->y = 0; |
currMV->y = 0; |
544 |
currPMV->x = -pred_x; |
currPMV->x = -pred.x; |
545 |
currPMV->y = -pred_y; |
currPMV->y = -pred.y; |
546 |
|
|
547 |
return iSAD; |
return iSAD; |
548 |
|
|
1282 |
|
|
1283 |
/* because we might use something like IF (dx>max_dx) THEN dx=max_dx; */ |
/* because we might use something like IF (dx>max_dx) THEN dx=max_dx; */ |
1284 |
bPredEq = get_pmvdata(pMBs, x, y, iWcount, 0, pmv, psad); |
bPredEq = get_pmvdata(pMBs, x, y, iWcount, 0, pmv, psad); |
1285 |
|
// bPredEq = get_pmvdata2(pMBs, iWcount, 0, x, y, 0, pmv, psad); |
1286 |
|
|
1287 |
if ((x == 0) && (y == 0)) { |
if ((x == 0) && (y == 0)) { |
1288 |
threshA = 512; |
threshA = 512; |
1700 |
} |
} |
1701 |
|
|
1702 |
/* because we might use IF (dx>max_dx) THEN dx=max_dx; */ |
/* because we might use IF (dx>max_dx) THEN dx=max_dx; */ |
1703 |
bPredEq = |
bPredEq = get_pmvdata(pMBs, (x >> 1), (y >> 1), iWcount, iSubBlock, pmv, psad); |
1704 |
get_pmvdata(pMBs, (x >> 1), (y >> 1), iWcount, iSubBlock, pmv, psad); |
// bPredEq = get_pmvdata2(pMBs, iWcount, 0, (x >> 1), (y >> 1), iSubBlock, pmv, psad); |
1705 |
|
|
1706 |
if ((x == 0) && (y == 0)) { |
if ((x == 0) && (y == 0)) { |
1707 |
threshA = 512 / 4; |
threshA = 512 / 4; |
2012 |
} |
} |
2013 |
/* because we might use something like IF (dx>max_dx) THEN dx=max_dx; */ |
/* because we might use something like IF (dx>max_dx) THEN dx=max_dx; */ |
2014 |
bPredEq = get_pmvdata(pMBs, x, y, iWcount, 0, pmv, psad); |
bPredEq = get_pmvdata(pMBs, x, y, iWcount, 0, pmv, psad); |
2015 |
|
// bPredEq = get_pmvdata2(pMBs, iWcount, 0, x, y, 0, pmv, psad); |
2016 |
|
|
2017 |
/* Step 4: Calculate SAD around the Median prediction. |
/* Step 4: Calculate SAD around the Median prediction. |
2018 |
MinSAD=SAD |
MinSAD=SAD |
2291 |
} |
} |
2292 |
/* because we might use something like IF (dx>max_dx) THEN dx=max_dx; */ |
/* because we might use something like IF (dx>max_dx) THEN dx=max_dx; */ |
2293 |
bPredEq = get_pmvdata(pMBs, x >> 1, y >> 1, iWcount, iSubBlock, pmv, psad); |
bPredEq = get_pmvdata(pMBs, x >> 1, y >> 1, iWcount, iSubBlock, pmv, psad); |
2294 |
|
// bPredEq = get_pmvdata2(pMBs, iWcount, 0, x >> 1, y >> 1, iSubBlock, pmv, psad); |
2295 |
|
|
2296 |
|
|
2297 |
/* Step 4: Calculate SAD around the Median prediction. |
/* Step 4: Calculate SAD around the Median prediction. |
2525 |
mb->b_mvs[0].y = 0; |
mb->b_mvs[0].y = 0; |
2526 |
continue; |
continue; |
2527 |
} |
} |
2528 |
|
/* force F_SAD16 |
2529 |
|
f_sad16 = 100; |
2530 |
|
b_sad16 = 65535; |
2531 |
|
|
2532 |
|
mb->mode = MODE_FORWARD; |
2533 |
|
mb->mvs[0].x = 1; |
2534 |
|
mb->mvs[0].y = 1; |
2535 |
|
mb->b_mvs[0].x = 1; |
2536 |
|
mb->b_mvs[0].y = 1; |
2537 |
|
continue; |
2538 |
|
^^ force F_SAD16 */ |
2539 |
|
|
2540 |
|
|
2541 |
// forward search |
// forward search |
2542 |
f_sad16 = |
f_sad16 = |
2543 |
SEARCH16(f_ref->y, f_refH->y, f_refV->y, f_refHV->y, |
SEARCH16(f_ref->y, f_refH->y, f_refV->y, f_refHV->y, |
2544 |
&frame->image, i, j, frame->motion_flags, |
&frame->image, i, j, frame->motion_flags, |
2545 |
frame->quant, frame->fcode, pParam, f_mbs, |
frame->quant, frame->fcode, pParam, |
2546 |
f_mbs /* todo */ , |
f_mbs, f_mbs, /* todo */ |
2547 |
&mb->mvs[0], &pmv_dontcare); // ignore pmv |
&mb->mvs[0], &pmv_dontcare); // ignore pmv |
2548 |
|
|
2549 |
// backward search |
// backward search |
2550 |
b_sad16 = SEARCH16(b_ref->y, b_refH->y, b_refV->y, b_refHV->y, &frame->image, i, j, frame->motion_flags, frame->quant, frame->bcode, pParam, b_mbs, b_mbs, /* todo */ |
b_sad16 = SEARCH16(b_ref->y, b_refH->y, b_refV->y, b_refHV->y, |
2551 |
|
&frame->image, i, j, frame->motion_flags, |
2552 |
|
frame->quant, frame->bcode, pParam, |
2553 |
|
b_mbs, b_mbs, /* todo */ |
2554 |
&mb->b_mvs[0], &pmv_dontcare); // ignore pmv |
&mb->b_mvs[0], &pmv_dontcare); // ignore pmv |
2555 |
|
|
2556 |
// interpolate search (simple, but effective) |
// interpolate search (simple, but effective) |
2557 |
|
i_sad16 = 65535; |
2558 |
|
|
2559 |
|
/* |
2560 |
|
x/y range somewhat buggy |
2561 |
i_sad16 = |
i_sad16 = |
2562 |
sad16bi_c(frame->image.y + i * 16 + j * 16 * edged_width, |
sad16bi_c(frame->image.y + i * 16 + j * 16 * edged_width, |
2563 |
get_ref(f_ref->y, f_refH->y, f_refV->y, f_refHV->y, |
get_ref(f_ref->y, f_refH->y, f_refV->y, f_refHV->y, |
2569 |
mb->b_mvs[0].x, |
mb->b_mvs[0].x, |
2570 |
edged_width), |
edged_width), |
2571 |
edged_width); |
edged_width); |
2572 |
|
*/ |
2573 |
|
|
2574 |
// TODO: direct search |
// TODO: direct search |
2575 |
// predictor + range of [-32,32] |
// predictor + range of [-32,32] |