141 |
static const VECTOR zeroMV = { 0, 0 }; |
static const VECTOR zeroMV = { 0, 0 }; |
142 |
VECTOR predMV; |
VECTOR predMV; |
143 |
|
|
144 |
int32_t x, y; |
uint32_t x, y; |
145 |
int32_t iIntra = 0; |
uint32_t iIntra = 0; |
146 |
VECTOR pmv; |
VECTOR pmv; |
147 |
|
|
148 |
if (sadInit) |
if (sadInit) |
153 |
|
|
154 |
MACROBLOCK *const pMB = &pMBs[x + y * iWcount]; |
MACROBLOCK *const pMB = &pMBs[x + y * iWcount]; |
155 |
|
|
|
if (pMB->mode == MODE_NOT_CODED) |
|
|
continue; |
|
|
|
|
156 |
predMV = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0); |
predMV = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0); |
157 |
|
|
158 |
pMB->sad16 = |
pMB->sad16 = |
356 |
{ iMinSAD=iSAD; currMV->x=(X); currMV->y=(Y); iDirection=(D); iFound=0; } } \ |
{ iMinSAD=iSAD; currMV->x=(X); currMV->y=(Y); iDirection=(D); iFound=0; } } \ |
357 |
} |
} |
358 |
|
|
359 |
|
#if 0 |
360 |
/* too slow and not fully functional at the moment */ |
/* too slow and not fully functional at the moment */ |
|
/* |
|
361 |
int32_t ZeroSearch16( |
int32_t ZeroSearch16( |
362 |
const uint8_t * const pRef, |
const uint8_t * const pRef, |
363 |
const uint8_t * const pRefH, |
const uint8_t * const pRefH, |
396 |
return iSAD; |
return iSAD; |
397 |
|
|
398 |
} |
} |
399 |
*/ |
#endif /* 0 */ |
400 |
|
|
401 |
int32_t |
int32_t |
402 |
Diamond16_MainSearch(const uint8_t * const pRef, |
Diamond16_MainSearch(const uint8_t * const pRef, |
690 |
const uint8_t * const cur, |
const uint8_t * const cur, |
691 |
const int x, |
const int x, |
692 |
const int y, |
const int y, |
693 |
int start_x, |
const int start_xi, |
694 |
int start_y, |
const int start_yi, |
695 |
int iMinSAD, |
int iMinSAD, |
696 |
VECTOR * const currMV, |
VECTOR * const currMV, |
697 |
const int center_x, |
const int center_x, |
708 |
{ |
{ |
709 |
|
|
710 |
int32_t iSAD; |
int32_t iSAD; |
711 |
|
int start_x = start_xi, start_y = start_yi; |
712 |
|
|
713 |
/* directions: 1 - left (x-1); 2 - right (x+1), 4 - up (y-1); 8 - down (y+1) */ |
/* directions: 1 - left (x-1); 2 - right (x+1), 4 - up (y-1); 8 - down (y+1) */ |
714 |
|
|
839 |
} |
} |
840 |
while (1); //forever |
while (1); //forever |
841 |
} |
} |
842 |
|
|
843 |
return iMinSAD; |
return iMinSAD; |
844 |
} |
} |
845 |
|
|
846 |
|
/* Disabled bframe specific code */ |
847 |
|
#if 0 |
848 |
|
|
849 |
#define CHECK_MV16_F_INTERPOL(X,Y) { \ |
#define CHECK_MV16_F_INTERPOL(X,Y) { \ |
850 |
if ( ((X) <= f_max_dx) && ((X) >= f_min_dx) \ |
if ( ((X) <= f_max_dx) && ((X) >= f_min_dx) \ |
851 |
&& ((Y) <= f_max_dy) && ((Y) >= f_min_dy) ) \ |
&& ((Y) <= f_max_dy) && ((Y) >= f_min_dy) ) \ |
902 |
{ iMinSAD=iSAD; b_currMV->x=(X); b_currMV->y=(Y); iFound=0;} } \ |
{ iMinSAD=iSAD; b_currMV->x=(X); b_currMV->y=(Y); iFound=0;} } \ |
903 |
} |
} |
904 |
|
|
905 |
|
|
906 |
int32_t |
int32_t |
907 |
Diamond16_InterpolMainSearch( |
Diamond16_InterpolMainSearch(const uint8_t * const f_pRef, |
|
const uint8_t * const f_pRef, |
|
908 |
const uint8_t * const f_pRefH, |
const uint8_t * const f_pRefH, |
909 |
const uint8_t * const f_pRefV, |
const uint8_t * const f_pRefV, |
910 |
const uint8_t * const f_pRefHV, |
const uint8_t * const f_pRefHV, |
1091 |
return iMinSAD; |
return iMinSAD; |
1092 |
} |
} |
1093 |
|
|
1094 |
|
#endif /* 0 */ |
1095 |
|
|
1096 |
int32_t |
int32_t |
1097 |
AdvDiamond8_MainSearch(const uint8_t * const pRef, |
AdvDiamond8_MainSearch(const uint8_t * const pRef, |
1101 |
const uint8_t * const cur, |
const uint8_t * const cur, |
1102 |
const int x, |
const int x, |
1103 |
const int y, |
const int y, |
1104 |
int start_x, |
const int start_xi, |
1105 |
int start_y, |
const int start_yi, |
1106 |
int iMinSAD, |
int iMinSAD, |
1107 |
VECTOR * const currMV, |
VECTOR * const currMV, |
1108 |
const int center_x, |
const int center_x, |
1119 |
{ |
{ |
1120 |
|
|
1121 |
int32_t iSAD; |
int32_t iSAD; |
1122 |
|
int start_x = start_xi, start_y = start_yi; |
1123 |
|
|
1124 |
/* directions: 1 - left (x-1); 2 - right (x+1), 4 - up (y-1); 8 - down (y+1) */ |
/* directions: 1 - left (x-1); 2 - right (x+1), 4 - up (y-1); 8 - down (y+1) */ |
1125 |
|
|
1399 |
} |
} |
1400 |
|
|
1401 |
/* 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; */ |
|
//bPredEq = get_pmvdata(pMBs, x, y, iWcount, 0, pmv, psad); |
|
1402 |
bPredEq = get_pmvdata2(pMBs, iWcount, 0, x, y, 0, pmv, psad); |
bPredEq = get_pmvdata2(pMBs, iWcount, 0, x, y, 0, pmv, psad); |
1403 |
|
|
1404 |
if ((x == 0) && (y == 0)) { |
if ((x == 0) && (y == 0)) { |
1456 |
if ((iMinSAD < 256) || |
if ((iMinSAD < 256) || |
1457 |
((MVequal(*currMV, prevMB->mvs[0])) && |
((MVequal(*currMV, prevMB->mvs[0])) && |
1458 |
((int32_t) iMinSAD < prevMB->sad16))) { |
((int32_t) iMinSAD < prevMB->sad16))) { |
1459 |
if (iMinSAD < 2 * iQuant) // high chances for SKIP-mode |
if (iMinSAD < (int)(2 * iQuant)) // high chances for SKIP-mode |
1460 |
{ |
{ |
1461 |
if (!MVzero(*currMV)) { |
if (!MVzero(*currMV)) { |
1462 |
iMinSAD += MV16_00_BIAS; |
iMinSAD += MV16_00_BIAS; |
1661 |
const uint8_t * const cur, |
const uint8_t * const cur, |
1662 |
const int x, |
const int x, |
1663 |
const int y, |
const int y, |
1664 |
int32_t start_x, |
const int32_t start_x, |
1665 |
int32_t start_y, |
const int32_t start_y, |
1666 |
int32_t iMinSAD, |
int32_t iMinSAD, |
1667 |
VECTOR * const currMV, |
VECTOR * const currMV, |
1668 |
const int center_x, |
const int center_x, |
1731 |
const uint8_t * const cur, |
const uint8_t * const cur, |
1732 |
const int x, |
const int x, |
1733 |
const int y, |
const int y, |
1734 |
int32_t start_x, |
const int32_t start_x, |
1735 |
int32_t start_y, |
const int32_t start_y, |
1736 |
int32_t iMinSAD, |
int32_t iMinSAD, |
1737 |
VECTOR * const currMV, |
VECTOR * const currMV, |
1738 |
const int center_x, |
const int center_x, |
2013 |
} |
} |
2014 |
|
|
2015 |
/* because we might use IF (dx>max_dx) THEN dx=max_dx; */ |
/* because we might use IF (dx>max_dx) THEN dx=max_dx; */ |
|
//bPredEq = get_pmvdata(pMBs, (x >> 1), (y >> 1), iWcount, iSubBlock, pmv, psad); |
|
2016 |
bPredEq = get_pmvdata2(pMBs, iWcount, 0, (x >> 1), (y >> 1), iSubBlock, pmv, psad); |
bPredEq = get_pmvdata2(pMBs, iWcount, 0, (x >> 1), (y >> 1), iSubBlock, pmv, psad); |
2017 |
|
|
2018 |
if ((x == 0) && (y == 0)) { |
if ((x == 0) && (y == 0)) { |
2327 |
max_dy = EVEN(max_dy); |
max_dy = EVEN(max_dy); |
2328 |
} |
} |
2329 |
/* 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; */ |
|
//bPredEq = get_pmvdata(pMBs, x, y, iWcount, 0, pmv, psad); |
|
2330 |
bPredEq = get_pmvdata2(pMBs, iWcount, 0, x, y, 0, pmv, psad); |
bPredEq = get_pmvdata2(pMBs, iWcount, 0, x, y, 0, pmv, psad); |
2331 |
|
|
2332 |
/* Step 4: Calculate SAD around the Median prediction. |
/* Step 4: Calculate SAD around the Median prediction. |
2609 |
max_dy = EVEN(max_dy); |
max_dy = EVEN(max_dy); |
2610 |
} |
} |
2611 |
/* 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; */ |
|
//bPredEq = get_pmvdata(pMBs, x >> 1, y >> 1, iWcount, iSubBlock, pmv[0].x, pmv[0].y, psad); |
|
2612 |
bPredEq = get_pmvdata2(pMBs, iWcount, 0, x >> 1, y >> 1, iSubBlock, pmv, psad); |
bPredEq = get_pmvdata2(pMBs, iWcount, 0, x >> 1, y >> 1, iSubBlock, pmv, psad); |
2613 |
|
|
2614 |
|
|
2788 |
} |
} |
2789 |
|
|
2790 |
|
|
2791 |
|
/* Disabled bframe specific code */ |
2792 |
|
# if 0 |
2793 |
int32_t |
int32_t |
2794 |
PMVfastIntSearch16(const uint8_t * const pRef, |
PMVfastIntSearch16(const uint8_t * const pRef, |
2795 |
const uint8_t * const pRefH, |
const uint8_t * const pRefH, |
2836 |
|
|
2837 |
MainSearch16FuncPtr MainSearchPtr; |
MainSearch16FuncPtr MainSearchPtr; |
2838 |
|
|
2839 |
const MACROBLOCK *const prevMB = prevMBs + x + y * iWcount; |
MACROBLOCK *const prevMB = (MACROBLOCK *const)prevMBs + x + y * iWcount; |
2840 |
MACROBLOCK *const pMB = pMBs + x + y * iWcount; |
MACROBLOCK *const pMB = (MACROBLOCK *const)(pMBs + x + y * iWcount); |
2841 |
|
|
2842 |
int32_t threshA, threshB; |
int32_t threshA, threshB; |
2843 |
int32_t bPredEq; |
int32_t bPredEq; |
2907 |
if ((iMinSAD < 256) || |
if ((iMinSAD < 256) || |
2908 |
((MVequal(*currMV, prevMB->i_mvs[0])) && |
((MVequal(*currMV, prevMB->i_mvs[0])) && |
2909 |
((int32_t) iMinSAD < prevMB->i_sad16))) { |
((int32_t) iMinSAD < prevMB->i_sad16))) { |
2910 |
if (iMinSAD < 2 * iQuant) // high chances for SKIP-mode |
if (iMinSAD < (int)(2 * iQuant)) // high chances for SKIP-mode |
2911 |
{ |
{ |
2912 |
if (!MVzero(*currMV)) { |
if (!MVzero(*currMV)) { |
2913 |
iMinSAD += MV16_00_BIAS; |
iMinSAD += MV16_00_BIAS; |
3076 |
|
|
3077 |
pmv[0] = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0); // get _REAL_ prediction (halfpel possible) |
pmv[0] = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0); // get _REAL_ prediction (halfpel possible) |
3078 |
|
|
|
PMVfastInt16_Terminate_without_Refine: |
|
3079 |
currPMV->x = currMV->x - center_x; |
currPMV->x = currMV->x - center_x; |
3080 |
currPMV->y = currMV->y - center_y; |
currPMV->y = currMV->y - center_y; |
3081 |
return iMinSAD; |
return iMinSAD; |
3082 |
} |
} |
3083 |
|
#endif /* 0 */ |