53 |
(*CheckCandidate)((const int)(X),(const int)(Y), (D), &iDirection, data ); } |
(*CheckCandidate)((const int)(X),(const int)(Y), (D), &iDirection, data ); } |
54 |
|
|
55 |
#define GET_REFERENCE(X, Y, REF) { \ |
#define GET_REFERENCE(X, Y, REF) { \ |
56 |
switch ( ((X&1)<<1) + (Y&1) ) \ |
switch ( (((X)&1)<<1) + ((Y)&1) ) \ |
57 |
{ \ |
{ \ |
58 |
case 0 : REF = data->Ref + (X)/2 + ((Y)/2)*(data->iEdgedWidth); break; \ |
case 0 : REF = data->Ref + (X)/2 + ((Y)/2)*(data->iEdgedWidth); break; \ |
59 |
case 1 : REF = data->RefV + (X)/2 + (((Y)-1)/2)*(data->iEdgedWidth); break; \ |
case 1 : REF = data->RefV + (X)/2 + (((Y)-1)/2)*(data->iEdgedWidth); break; \ |
95 |
static void |
static void |
96 |
CheckCandidate16(const int x, const int y, const int Direction, int * const dir, const SearchData * const data) |
CheckCandidate16(const int x, const int y, const int Direction, int * const dir, const SearchData * const data) |
97 |
{ |
{ |
|
int32_t * const sad = data->temp; |
|
98 |
int t; |
int t; |
99 |
const uint8_t * Reference; |
const uint8_t * Reference; |
100 |
|
|
108 |
default : Reference = data->RefHV + (x-1)/2 + ((y-1)/2)*(data->iEdgedWidth); break; |
default : Reference = data->RefHV + (x-1)/2 + ((y-1)/2)*(data->iEdgedWidth); break; |
109 |
} |
} |
110 |
|
|
111 |
data->temp[0] = sad16v(data->Cur, Reference, data->iEdgedWidth, sad+1); |
data->temp[0] = sad16v(data->Cur, Reference, data->iEdgedWidth, data->temp + 1); |
112 |
|
|
113 |
|
if(data->quarterpel) |
114 |
|
t = d_mv_bits(2*x - data->predQMV.x, 2*y - data->predQMV.y, data->iFcode); |
115 |
|
else |
116 |
t = d_mv_bits(x - data->predMV.x, y - data->predMV.y, data->iFcode); |
t = d_mv_bits(x - data->predMV.x, y - data->predMV.y, data->iFcode); |
117 |
|
|
118 |
data->temp[0] += lambda_vec16[data->iQuant] * t; |
data->temp[0] += lambda_vec16[data->iQuant] * t; |
119 |
data->temp[1] += lambda_vec8[data->iQuant] * t; |
data->temp[1] += lambda_vec8[data->iQuant] * t; |
120 |
|
|
151 |
default : Reference = data->RefHV + (x-1)/2 + ((y-1)/2)*(data->iEdgedWidth); break; |
default : Reference = data->RefHV + (x-1)/2 + ((y-1)/2)*(data->iEdgedWidth); break; |
152 |
} |
} |
153 |
|
|
154 |
|
if(data->quarterpel) |
155 |
|
sad = lambda_vec16[data->iQuant] * |
156 |
|
d_mv_bits(2*x - data->predQMV.x, 2*y - data->predQMV.y, data->iFcode); |
157 |
|
else |
158 |
sad = lambda_vec16[data->iQuant] * |
sad = lambda_vec16[data->iQuant] * |
159 |
d_mv_bits(x - data->predMV.x, y - data->predMV.y, data->iFcode); |
d_mv_bits(x - data->predMV.x, y - data->predMV.y, data->iFcode); |
160 |
|
|
161 |
sad += sad16(data->Cur, Reference, data->iEdgedWidth, MV_MAX_ERROR); |
sad += sad16(data->Cur, Reference, data->iEdgedWidth, MV_MAX_ERROR); |
162 |
|
|
163 |
if (sad < *(data->iMinSAD)) { |
if (sad < *(data->iMinSAD)) { |
173 |
// Important: This is no general usable routine! x and y must be +/-1 (qpel resolution!) |
// Important: This is no general usable routine! x and y must be +/-1 (qpel resolution!) |
174 |
// around currentMV! |
// around currentMV! |
175 |
{ |
{ |
|
int32_t * const sad = data->temp; |
|
176 |
int t; |
int t; |
177 |
uint8_t * Reference = (uint8_t *) data->RefQ; |
uint8_t * Reference = (uint8_t *) data->RefQ; |
178 |
const uint8_t *ref1, *ref2, *ref3, *ref4; |
const uint8_t *ref1, *ref2, *ref3, *ref4; |
224 |
break; |
break; |
225 |
} |
} |
226 |
|
|
227 |
data->temp[0] = sad16v(data->Cur, Reference, data->iEdgedWidth, sad+1); |
data->temp[0] = sad16v(data->Cur, Reference, data->iEdgedWidth, data->temp+1); |
228 |
|
|
229 |
t = d_mv_bits(x - data->predQMV.x, y - data->predQMV.y, data->iFcode); |
t = d_mv_bits(x - data->predQMV.x, y - data->predQMV.y, data->iFcode); |
230 |
data->temp[0] += lambda_vec16[data->iQuant] * t; |
data->temp[0] += lambda_vec16[data->iQuant] * t; |
233 |
if (data->temp[0] < data->iMinSAD[0]) { |
if (data->temp[0] < data->iMinSAD[0]) { |
234 |
data->iMinSAD[0] = data->temp[0]; |
data->iMinSAD[0] = data->temp[0]; |
235 |
data->currentQMV[0].x = x; data->currentQMV[0].y = y; |
data->currentQMV[0].x = x; data->currentQMV[0].y = y; |
236 |
*dir = Direction; } |
/* *dir = Direction;*/ } |
237 |
|
|
238 |
if (data->temp[1] < data->iMinSAD[1]) { |
if (data->temp[1] < data->iMinSAD[1]) { |
239 |
data->iMinSAD[1] = data->temp[1]; data->currentQMV[1].x = x; data->currentQMV[1].y = y; } |
data->iMinSAD[1] = data->temp[1]; data->currentQMV[1].x = x; data->currentQMV[1].y = y; } |
310 |
if (sad < *(data->iMinSAD)) { |
if (sad < *(data->iMinSAD)) { |
311 |
*(data->iMinSAD) = sad; |
*(data->iMinSAD) = sad; |
312 |
data->currentQMV[0].x = x; data->currentQMV[0].y = y; |
data->currentQMV[0].x = x; data->currentQMV[0].y = y; |
313 |
*dir = Direction; |
// *dir = Direction; |
314 |
} |
} |
315 |
} |
} |
316 |
|
|
495 |
} |
} |
496 |
|
|
497 |
sad = sad8(data->Cur, Reference, data->iEdgedWidth); |
sad = sad8(data->Cur, Reference, data->iEdgedWidth); |
498 |
|
|
499 |
|
if(data->quarterpel) |
500 |
|
sad += lambda_vec8[data->iQuant] * d_mv_bits(2*x - data->predQMV.x, 2*y - data->predQMV.y, data->iFcode); |
501 |
|
else |
502 |
sad += lambda_vec8[data->iQuant] * d_mv_bits(x - data->predMV.x, y - data->predMV.y, data->iFcode); |
sad += lambda_vec8[data->iQuant] * d_mv_bits(x - data->predMV.x, y - data->predMV.y, data->iFcode); |
503 |
|
|
504 |
if (sad < *(data->iMinSAD)) { |
if (sad < *(data->iMinSAD)) { |
821 |
Data.temp = temp; |
Data.temp = temp; |
822 |
Data.iFcode = current->fcode; |
Data.iFcode = current->fcode; |
823 |
Data.rounding = pParam->m_rounding_type; |
Data.rounding = pParam->m_rounding_type; |
824 |
|
Data.quarterpel = pParam->m_quarterpel; |
825 |
|
|
826 |
if((qimage = (uint8_t *) malloc(32 * pParam->edged_width)) == NULL) |
if((qimage = (uint8_t *) malloc(32 * pParam->edged_width)) == NULL) |
827 |
return 0; // allocate some mem for qpel interpolated blocks |
return 1; // allocate some mem for qpel interpolated blocks |
828 |
// somehow this is dirty since I think we shouldn't use malloc outside |
// somehow this is dirty since I think we shouldn't use malloc outside |
829 |
// encoder_create() - so please fix me! |
// encoder_create() - so please fix me! |
830 |
|
|
1008 |
for(i = 0; i < 5; i++) |
for(i = 0; i < 5; i++) |
1009 |
Data->currentMV[i].x = Data->currentMV[i].y = 0; |
Data->currentMV[i].x = Data->currentMV[i].y = 0; |
1010 |
|
|
1011 |
|
if(Data->quarterpel) |
1012 |
|
i = d_mv_bits(Data->predQMV.x, Data->predQMV.y, Data->iFcode); |
1013 |
|
else |
1014 |
i = d_mv_bits(Data->predMV.x, Data->predMV.y, Data->iFcode); |
i = d_mv_bits(Data->predMV.x, Data->predMV.y, Data->iFcode); |
1015 |
|
|
1016 |
Data->iMinSAD[0] = pMB->sad16 + lambda_vec16[iQuant] * i; |
Data->iMinSAD[0] = pMB->sad16 + lambda_vec16[iQuant] * i; |
1017 |
Data->iMinSAD[1] = pMB->sad8[0] + lambda_vec8[iQuant] * i; |
Data->iMinSAD[1] = pMB->sad8[0] + lambda_vec8[iQuant] * i; |
1018 |
Data->iMinSAD[2] = pMB->sad8[1]; |
Data->iMinSAD[2] = pMB->sad8[1]; |
1101 |
else |
else |
1102 |
CheckCandidate = CheckCandidate16no4v_qpel; |
CheckCandidate = CheckCandidate16no4v_qpel; |
1103 |
|
|
1104 |
|
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
1105 |
|
pParam->width, pParam->height, Data->iFcode, 0); // get real range |
1106 |
|
|
1107 |
QuarterpelRefine(Data); |
QuarterpelRefine(Data); |
1108 |
} |
} |
1109 |
|
|
1163 |
Data->iMinSAD = OldData->iMinSAD + 1 + block; |
Data->iMinSAD = OldData->iMinSAD + 1 + block; |
1164 |
Data->currentMV = OldData->currentMV + 1 + block; |
Data->currentMV = OldData->currentMV + 1 + block; |
1165 |
Data->currentQMV = OldData->currentQMV + 1 + block; |
Data->currentQMV = OldData->currentQMV + 1 + block; |
1166 |
|
Data->quarterpel = OldData->quarterpel; |
1167 |
|
|
1168 |
if (block != 0) { |
if(Data->quarterpel) // add d_mv_bits[qpel] everywhere but not in 0 (it's already there) |
1169 |
if(pParam->m_quarterpel) { |
{ |
1170 |
|
if (block != 0) |
1171 |
*(Data->iMinSAD) += lambda_vec8[Data->iQuant] * |
*(Data->iMinSAD) += lambda_vec8[Data->iQuant] * |
1172 |
d_mv_bits( Data->currentQMV->x - Data->predQMV.x, |
d_mv_bits( Data->currentQMV->x - Data->predQMV.x, |
1173 |
Data->currentQMV->y - Data->predQMV.y, |
Data->currentQMV->y - Data->predQMV.y, |
1174 |
Data->iFcode); |
Data->iFcode); |
1175 |
} |
|
1176 |
else { |
} else // add d_mv_bits[hpel] everywhere but not in 0 (it's already there) |
1177 |
|
if (block != 0) |
1178 |
*(Data->iMinSAD) += lambda_vec8[Data->iQuant] * |
*(Data->iMinSAD) += lambda_vec8[Data->iQuant] * |
1179 |
d_mv_bits( Data->currentMV->x - Data->predMV.x, |
d_mv_bits( Data->currentMV->x - Data->predMV.x, |
1180 |
Data->currentMV->y - Data->predMV.y, |
Data->currentMV->y - Data->predMV.y, |
1181 |
Data->iFcode); |
Data->iFcode); |
|
} |
|
|
} |
|
|
|
|
1182 |
|
|
1183 |
if (MotionFlags & (PMV_EXTSEARCH8|PMV_HALFPELREFINE8)) { |
if (MotionFlags & (PMV_EXTSEARCH8|PMV_HALFPELREFINE8)) { |
1184 |
|
|
1205 |
|
|
1206 |
(*MainSearchPtr)(Data->currentMV->x, Data->currentMV->y, Data, 255); |
(*MainSearchPtr)(Data->currentMV->x, Data->currentMV->y, Data, 255); |
1207 |
|
|
1208 |
if(*(Data->iMinSAD) < temp_sad) { |
if(*(Data->iMinSAD) < temp_sad) { //found a better match? |
1209 |
Data->currentQMV->x = 2 * Data->currentMV->x; // update our qpel vector |
Data->currentQMV->x = 2 * Data->currentMV->x; // update our qpel vector |
1210 |
Data->currentQMV->y = 2 * Data->currentMV->y; |
Data->currentQMV->y = 2 * Data->currentMV->y; |
1211 |
} |
} |
1222 |
} |
} |
1223 |
} |
} |
1224 |
|
|
1225 |
if(pParam->m_quarterpel) { |
if((Data->quarterpel) && (!(Data->currentQMV->x & 1)) && (!(Data->currentQMV->y & 1)) && |
|
if((!(Data->currentQMV->x & 1)) && (!(Data->currentQMV->y & 1)) && |
|
1226 |
(MotionFlags & PMV_QUARTERPELREFINE8)) { |
(MotionFlags & PMV_QUARTERPELREFINE8)) { |
1227 |
|
|
1228 |
CheckCandidate = CheckCandidate8_qpel; |
CheckCandidate = CheckCandidate8_qpel; |
1229 |
|
|
1230 |
|
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 8, |
1231 |
|
pParam->width, pParam->height, OldData->iFcode, 0); // get real range |
1232 |
|
|
1233 |
QuarterpelRefine(Data); |
QuarterpelRefine(Data); |
1234 |
} |
} |
1235 |
} |
} |
|
} |
|
1236 |
|
|
1237 |
if(pParam->m_quarterpel) { |
if(pParam->m_quarterpel) { |
1238 |
pMB->pmvs[block].x = Data->currentQMV->x - Data->predQMV.x; |
pMB->pmvs[block].x = Data->currentQMV->x - Data->predQMV.x; |
1246 |
pMB->mvs[block] = *(Data->currentMV); |
pMB->mvs[block] = *(Data->currentMV); |
1247 |
pMB->qmvs[block] = *(Data->currentQMV); |
pMB->qmvs[block] = *(Data->currentQMV); |
1248 |
|
|
1249 |
pMB->sad8[block] = 4 * (*Data->iMinSAD); |
pMB->sad8[block] = 4 * (*Data->iMinSAD); // Isibaar: why? |
1250 |
} |
} |
1251 |
|
|
1252 |
/* B-frames code starts here */ |
/* B-frames code starts here */ |
1447 |
|
|
1448 |
// skip decision |
// skip decision |
1449 |
if (*Data->iMinSAD - 2 * lambda_vec16[Data->iQuant] < (int32_t)Data->iQuant * SKIP_THRESH_B) { |
if (*Data->iMinSAD - 2 * lambda_vec16[Data->iQuant] < (int32_t)Data->iQuant * SKIP_THRESH_B) { |
1450 |
//checking chroma. everything copied from MC |
//possible skip - checking chroma. everything copied from MC |
1451 |
//this is not full chroma compensation, only it's fullpel approximation. should work though |
//this is not full chroma compensation, only it's fullpel approximation. should work though |
1452 |
int sum, dx, dy, b_dx, b_dy; |
int sum, dx, dy, b_dx, b_dy; |
1453 |
|
|
1757 |
|
|
1758 |
/* Hinted ME starts here */ |
/* Hinted ME starts here */ |
1759 |
|
|
1760 |
static __inline void |
static void |
1761 |
Search8hinted( const SearchData * const OldData, |
Search8hinted( const SearchData * const OldData, |
1762 |
const int x, const int y, |
const int x, const int y, |
1763 |
const uint32_t MotionFlags, |
const uint32_t MotionFlags, |
1764 |
const MBParam * const pParam, |
const MBParam * const pParam, |
1765 |
MACROBLOCK * const pMB, |
MACROBLOCK * const pMB, |
1766 |
const MACROBLOCK * const pMBs, |
const MACROBLOCK * const pMBs, |
1767 |
const int block) |
const int block, |
1768 |
|
SearchData * const Data) |
1769 |
{ |
{ |
1770 |
SearchData Data; |
int32_t temp_sad; |
1771 |
MainSearchFunc *MainSearchPtr; |
MainSearchFunc *MainSearchPtr; |
1772 |
|
Data->predMV = get_pmv2(pMBs, pParam->mb_width, 0, x/2 , y/2, block); |
1773 |
|
Data->predQMV = get_qpmv2(pMBs, pParam->mb_width, 0, x/2 , y/2, block); |
1774 |
|
Data->iMinSAD = OldData->iMinSAD + 1 + block; |
1775 |
|
Data->currentMV = OldData->currentMV + 1 + block; |
1776 |
|
Data->currentQMV = OldData->currentQMV + 1 + block; |
1777 |
|
Data->quarterpel = OldData->quarterpel; |
1778 |
|
|
1779 |
Data.predMV = get_pmv2(pMBs, pParam->mb_width, 0, x/2 , y/2, block); |
if (block != 0) { |
1780 |
Data.iMinSAD = OldData->iMinSAD + 1 + block; |
if(pParam->m_quarterpel) { |
1781 |
Data.currentMV = OldData->currentMV+1+block; |
*(Data->iMinSAD) += lambda_vec8[Data->iQuant] * |
1782 |
Data.iFcode = OldData->iFcode; |
d_mv_bits( Data->currentQMV->x - Data->predQMV.x, |
1783 |
Data.iQuant = OldData->iQuant; |
Data->currentQMV->y - Data->predQMV.y, |
1784 |
|
Data->iFcode); |
1785 |
Data.Ref = OldData->Ref + 8 * ((block&1) + pParam->edged_width*(block>>1)); |
} |
1786 |
Data.RefH = OldData->RefH + 8 * ((block&1) + pParam->edged_width*(block>>1)); |
else { |
1787 |
Data.RefV = OldData->RefV + 8 * ((block&1) + pParam->edged_width*(block>>1)); |
*(Data->iMinSAD) += lambda_vec8[Data->iQuant] * |
1788 |
Data.RefHV = OldData->RefHV + 8 * ((block&1) + pParam->edged_width*(block>>1)); |
d_mv_bits( Data->currentMV->x - Data->predMV.x, |
1789 |
Data.iEdgedWidth = pParam->edged_width; |
Data->currentMV->y - Data->predMV.y, |
1790 |
Data.Cur = OldData->Cur + 8 * ((block&1) + pParam->edged_width*(block>>1)); |
Data->iFcode); |
1791 |
|
} |
1792 |
CheckCandidate = CheckCandidate8; |
} |
1793 |
|
|
1794 |
if (block != 0) |
Data->Ref = OldData->Ref + 8 * ((block&1) + pParam->edged_width*(block>>1)); |
1795 |
*(Data.iMinSAD) += lambda_vec8[Data.iQuant] * |
Data->RefH = OldData->RefH + 8 * ((block&1) + pParam->edged_width*(block>>1)); |
1796 |
d_mv_bits( Data.currentMV->x - Data.predMV.x, |
Data->RefV = OldData->RefV + 8 * ((block&1) + pParam->edged_width*(block>>1)); |
1797 |
Data.currentMV->y - Data.predMV.y, |
Data->RefHV = OldData->RefHV + 8 * ((block&1) + pParam->edged_width*(block>>1)); |
1798 |
Data.iFcode); |
Data->RefQ = OldData->RefQ; |
1799 |
|
|
1800 |
|
Data->Cur = OldData->Cur + 8 * ((block&1) + pParam->edged_width*(block>>1)); |
1801 |
|
|
1802 |
get_range(&Data.min_dx, &Data.max_dx, &Data.min_dy, &Data.max_dy, x, y, 8, |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 8, |
1803 |
pParam->width, pParam->height, OldData->iFcode, pParam->m_quarterpel); |
pParam->width, pParam->height, OldData->iFcode, pParam->m_quarterpel); |
1804 |
|
|
1805 |
if (pMB->mode == MODE_INTER4V) { |
CheckCandidate = CheckCandidate8; |
1806 |
int dummy; |
|
1807 |
CheckCandidate8(pMB->mvs[block].x, pMB->mvs[block].y, 0, &dummy, &Data); } |
temp_sad = *(Data->iMinSAD); // store current MinSAD |
1808 |
|
|
1809 |
if (MotionFlags & PMV_USESQUARES8) MainSearchPtr = SquareSearch; |
if (MotionFlags & PMV_USESQUARES8) MainSearchPtr = SquareSearch; |
1810 |
else if (MotionFlags & PMV_ADVANCEDDIAMOND8) MainSearchPtr = AdvDiamondSearch; |
else if (MotionFlags & PMV_ADVANCEDDIAMOND8) MainSearchPtr = AdvDiamondSearch; |
1811 |
else MainSearchPtr = DiamondSearch; |
else MainSearchPtr = DiamondSearch; |
1812 |
|
|
1813 |
(*MainSearchPtr)(Data.currentMV->x, Data.currentMV->y, &Data, 255); |
(*MainSearchPtr)(Data->currentMV->x, Data->currentMV->y, Data, 255); |
1814 |
|
|
1815 |
|
if(*(Data->iMinSAD) < temp_sad) { |
1816 |
|
Data->currentQMV->x = 2 * Data->currentMV->x; // update our qpel vector |
1817 |
|
Data->currentQMV->y = 2 * Data->currentMV->y; |
1818 |
|
} |
1819 |
|
|
1820 |
|
if (MotionFlags & PMV_HALFPELREFINE8) { |
1821 |
|
temp_sad = *(Data->iMinSAD); // store current MinSAD |
1822 |
|
|
1823 |
|
HalfpelRefine(Data); // perform halfpel refine of current best vector |
1824 |
|
|
1825 |
|
if(*(Data->iMinSAD) < temp_sad) { // we have found a better match |
1826 |
|
Data->currentQMV->x = 2 * Data->currentMV->x; // update our qpel vector |
1827 |
|
Data->currentQMV->y = 2 * Data->currentMV->y; |
1828 |
|
} |
1829 |
|
} |
1830 |
|
|
1831 |
if (MotionFlags & PMV_HALFPELREFINE8) HalfpelRefine(&Data); |
if((Data->quarterpel) && (!(Data->currentQMV->x & 1)) && (!(Data->currentQMV->y & 1)) && |
1832 |
|
(MotionFlags & PMV_QUARTERPELREFINE8)) { |
1833 |
|
|
1834 |
|
CheckCandidate = CheckCandidate8_qpel; |
1835 |
|
|
1836 |
pMB->pmvs[block].x = Data.currentMV->x - Data.predMV.x; |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 8, |
1837 |
pMB->pmvs[block].y = Data.currentMV->y - Data.predMV.y; |
pParam->width, pParam->height, OldData->iFcode, 0); // get real range |
1838 |
pMB->mvs[block] = *(Data.currentMV); |
|
1839 |
pMB->sad8[block] = 4 * (*(Data.iMinSAD)); |
QuarterpelRefine(Data); |
1840 |
|
} |
1841 |
|
|
1842 |
|
if(pParam->m_quarterpel) { |
1843 |
|
pMB->pmvs[block].x = Data->currentQMV->x - Data->predQMV.x; |
1844 |
|
pMB->pmvs[block].y = Data->currentQMV->y - Data->predQMV.y; |
1845 |
|
} |
1846 |
|
else { |
1847 |
|
pMB->pmvs[block].x = Data->currentMV->x - Data->predMV.x; |
1848 |
|
pMB->pmvs[block].y = Data->currentMV->y - Data->predMV.y; |
1849 |
|
} |
1850 |
|
|
1851 |
|
pMB->mvs[block] = *(Data->currentMV); |
1852 |
|
pMB->qmvs[block] = *(Data->currentQMV); |
1853 |
|
|
1854 |
|
pMB->sad8[block] = 4 * (*Data->iMinSAD); |
1855 |
} |
} |
1856 |
|
|
1857 |
|
|
1860 |
const uint8_t * const pRefH, |
const uint8_t * const pRefH, |
1861 |
const uint8_t * const pRefV, |
const uint8_t * const pRefV, |
1862 |
const uint8_t * const pRefHV, |
const uint8_t * const pRefHV, |
1863 |
|
const uint8_t * const pRefQ, |
1864 |
const IMAGE * const pCur, |
const IMAGE * const pCur, |
1865 |
const int x, |
const int x, |
1866 |
const int y, |
const int y, |
1878 |
int i, t; |
int i, t; |
1879 |
MainSearchFunc * MainSearchPtr; |
MainSearchFunc * MainSearchPtr; |
1880 |
|
|
1881 |
|
Data->predQMV = get_qpmv2(pMBs, pParam->mb_width, 0, x, y, 0); |
1882 |
Data->predMV = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0); |
Data->predMV = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0); |
1883 |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
1884 |
pParam->width, pParam->height, Data->iFcode, pParam->m_quarterpel); |
pParam->width, pParam->height, Data->iFcode, pParam->m_quarterpel); |
1888 |
Data->RefH = pRefH + (x + iEdgedWidth*y) * 16; |
Data->RefH = pRefH + (x + iEdgedWidth*y) * 16; |
1889 |
Data->RefV = pRefV + (x + iEdgedWidth*y) * 16; |
Data->RefV = pRefV + (x + iEdgedWidth*y) * 16; |
1890 |
Data->RefHV = pRefHV + (x + iEdgedWidth*y) * 16; |
Data->RefHV = pRefHV + (x + iEdgedWidth*y) * 16; |
1891 |
|
Data->RefQ = pRefQ; |
1892 |
|
|
1893 |
Data->iQuant = iQuant; |
Data->iQuant = iQuant; |
1894 |
|
|
1895 |
if (!(MotionFlags & PMV_HALFPEL16)) { |
if (!(MotionFlags & PMV_HALFPEL16)) { |
1935 |
|
|
1936 |
if (MotionFlags & PMV_HALFPELREFINE16) HalfpelRefine(Data); |
if (MotionFlags & PMV_HALFPELREFINE16) HalfpelRefine(Data); |
1937 |
|
|
1938 |
|
for(i = 0; i < 5; i++) { |
1939 |
|
Data->currentQMV[i].x = 2 * Data->currentMV[i].x; // initialize qpel vectors |
1940 |
|
Data->currentQMV[i].y = 2 * Data->currentMV[i].y; |
1941 |
|
} |
1942 |
|
|
1943 |
|
if((pParam->m_quarterpel) && (MotionFlags & PMV_QUARTERPELREFINE16)) { |
1944 |
if (inter4v) |
if (inter4v) |
1945 |
for(i = 0; i < 4; i++) |
CheckCandidate = CheckCandidate16_qpel; |
1946 |
Search8hinted(Data, 2*x+(i&1), 2*y+(i>>1), MotionFlags, pParam, pMB, pMBs, i); |
else |
1947 |
|
CheckCandidate = CheckCandidate16no4v_qpel; |
1948 |
|
|
1949 |
|
get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16, |
1950 |
|
pParam->width, pParam->height, Data->iFcode, 0); // get real range |
1951 |
|
|
1952 |
|
QuarterpelRefine(Data); |
1953 |
|
} |
1954 |
|
|
1955 |
|
if (inter4v) { |
1956 |
|
SearchData Data8; |
1957 |
|
Data8.iFcode = Data->iFcode; |
1958 |
|
Data8.iQuant = Data->iQuant; |
1959 |
|
Data8.iEdgedWidth = Data->iEdgedWidth; |
1960 |
|
Search8hinted(Data, 2*x, 2*y, MotionFlags, pParam, pMB, pMBs, 0, &Data8); |
1961 |
|
Search8hinted(Data, 2*x + 1, 2*y, MotionFlags, pParam, pMB, pMBs, 1, &Data8); |
1962 |
|
Search8hinted(Data, 2*x, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 2, &Data8); |
1963 |
|
Search8hinted(Data, 2*x + 1, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 3, &Data8); |
1964 |
|
} |
1965 |
|
|
1966 |
if (!(inter4v) || |
if (!(inter4v) || |
1967 |
(Data->iMinSAD[0] < Data->iMinSAD[1] + Data->iMinSAD[2] + Data->iMinSAD[3] + |
(Data->iMinSAD[0] < Data->iMinSAD[1] + Data->iMinSAD[2] + Data->iMinSAD[3] + |
1999 |
const IMAGE *const pRef = &reference->image; |
const IMAGE *const pRef = &reference->image; |
2000 |
|
|
2001 |
uint32_t x, y; |
uint32_t x, y; |
2002 |
|
uint8_t *qimage; |
2003 |
int32_t temp[5], quant = current->quant; |
int32_t temp[5], quant = current->quant; |
2004 |
int32_t iMinSAD[5]; |
int32_t iMinSAD[5]; |
2005 |
VECTOR currentMV[5]; |
VECTOR currentMV[5]; |
2006 |
|
VECTOR currentQMV[5]; |
2007 |
SearchData Data; |
SearchData Data; |
2008 |
Data.iEdgedWidth = pParam->edged_width; |
Data.iEdgedWidth = pParam->edged_width; |
2009 |
Data.currentMV = currentMV; |
Data.currentMV = currentMV; |
2010 |
|
Data.currentQMV = currentQMV; |
2011 |
Data.iMinSAD = iMinSAD; |
Data.iMinSAD = iMinSAD; |
2012 |
Data.temp = temp; |
Data.temp = temp; |
2013 |
Data.iFcode = current->fcode; |
Data.iFcode = current->fcode; |
2014 |
|
Data.rounding = pParam->m_rounding_type; |
2015 |
|
|
2016 |
|
if((qimage = (uint8_t *) malloc(32 * pParam->edged_width)) == NULL) |
2017 |
|
return; // allocate some mem for qpel interpolated blocks |
2018 |
|
// somehow this is dirty since I think we shouldn't use malloc outside |
2019 |
|
// encoder_create() - so please fix me! |
2020 |
|
|
2021 |
if (sadInit) (*sadInit) (); |
if (sadInit) (*sadInit) (); |
2022 |
|
|
2040 |
pMB->quant = quant; |
pMB->quant = quant; |
2041 |
} |
} |
2042 |
|
|
2043 |
SearchPhinted(pRef->y, pRefH->y, pRefV->y, pRefHV->y, pCurrent, x, |
SearchPhinted(pRef->y, pRefH->y, pRefV->y, pRefHV->y, qimage, pCurrent, x, |
2044 |
y, current->motion_flags, pMB->quant, |
y, current->motion_flags, pMB->quant, |
2045 |
pParam, pMBs, current->global_flags & XVID_INTER4V, pMB, |
pParam, pMBs, current->global_flags & XVID_INTER4V, pMB, |
2046 |
&Data); |
&Data); |
2047 |
|
|
2048 |
} |
} |
2049 |
} |
} |
2050 |
|
free(qimage); |
2051 |
} |
} |
2052 |
|
|
2053 |
static __inline int |
static __inline int |