47 |
#define FINAL_SKIP_THRESH (50) |
#define FINAL_SKIP_THRESH (50) |
48 |
#define MAX_SAD00_FOR_SKIP (20) |
#define MAX_SAD00_FOR_SKIP (20) |
49 |
#define MAX_CHROMA_SAD_FOR_SKIP (22) |
#define MAX_CHROMA_SAD_FOR_SKIP (22) |
50 |
#define SKIP_THRESH_B (25) |
#define SKIP_THRESH_B (15) |
51 |
|
|
52 |
#define CHECK_CANDIDATE(X,Y,D) { \ |
#define CHECK_CANDIDATE(X,Y,D) { \ |
53 |
(*CheckCandidate)((const int)(X),(const int)(Y), (D), &iDirection, data ); } |
(*CheckCandidate)((const int)(X),(const int)(Y), (D), &iDirection, data ); } |
137 |
Interpolate8x8qpel(const int x, const int y, const int block, const int dir, const SearchData * const data) |
Interpolate8x8qpel(const int x, const int y, const int block, const int dir, const SearchData * const data) |
138 |
{ |
{ |
139 |
// create or find a qpel-precision reference picture; return pointer to it |
// create or find a qpel-precision reference picture; return pointer to it |
140 |
uint8_t * Reference = (uint8_t *)data->RefQ; |
uint8_t * Reference = (uint8_t *)data->RefQ + 16*dir; |
141 |
const int32_t iEdgedWidth = data->iEdgedWidth; |
const int32_t iEdgedWidth = data->iEdgedWidth; |
142 |
const uint32_t rounding = data->rounding; |
const uint32_t rounding = data->rounding; |
143 |
const int halfpel_x = x/2; |
const int halfpel_x = x/2; |
182 |
Interpolate16x16qpel(const int x, const int y, const int dir, const SearchData * const data) |
Interpolate16x16qpel(const int x, const int y, const int dir, const SearchData * const data) |
183 |
{ |
{ |
184 |
// create or find a qpel-precision reference picture; return pointer to it |
// create or find a qpel-precision reference picture; return pointer to it |
185 |
uint8_t * Reference = (uint8_t *)data->RefQ; |
uint8_t * Reference = (uint8_t *)data->RefQ + 16*dir; |
186 |
const int32_t iEdgedWidth = data->iEdgedWidth; |
const int32_t iEdgedWidth = data->iEdgedWidth; |
187 |
const uint32_t rounding = data->rounding; |
const uint32_t rounding = data->rounding; |
188 |
const int halfpel_x = x/2; |
const int halfpel_x = x/2; |
1368 |
Data->min_dy *= 2; |
Data->min_dy *= 2; |
1369 |
Data->referencemv = b_mb->qmvs; |
Data->referencemv = b_mb->qmvs; |
1370 |
} else Data->referencemv = b_mb->mvs; |
} else Data->referencemv = b_mb->mvs; |
1371 |
Data->qpel_precision = 0; // it'm a trick. it's 1 not 0, but we need 0 here |
Data->qpel_precision = 0; // it's a trick. it's 1 not 0, but we need 0 here |
1372 |
|
|
1373 |
for (k = 0; k < 4; k++) { |
for (k = 0; k < 4; k++) { |
1374 |
pMB->mvs[k].x = Data->directmvF[k].x = ((TRB * Data->referencemv[k].x) / TRD); |
pMB->mvs[k].x = Data->directmvF[k].x = ((TRB * Data->referencemv[k].x) / TRD); |
1458 |
*Data->iMinSAD += 1 * Data->lambda16; // one bit is needed to code direct mode |
*Data->iMinSAD += 1 * Data->lambda16; // one bit is needed to code direct mode |
1459 |
*best_sad = *Data->iMinSAD; |
*best_sad = *Data->iMinSAD; |
1460 |
|
|
1461 |
// if (b_mb->mode == MODE_INTER4V) |
if (b_mb->mode == MODE_INTER4V) |
1462 |
pMB->mode = MODE_DIRECT; |
pMB->mode = MODE_DIRECT; |
1463 |
// else pMB->mode = MODE_DIRECT_NO4V; //for faster compensation |
else pMB->mode = MODE_DIRECT_NO4V; //for faster compensation |
1464 |
|
|
1465 |
pMB->pmvs[3] = *Data->currentMV; |
pMB->pmvs[3] = *Data->currentMV; |
1466 |
|
|
1535 |
bData.RefV = fData->bRefV = b_RefV + (x + y * iEdgedWidth) * 16; |
bData.RefV = fData->bRefV = b_RefV + (x + y * iEdgedWidth) * 16; |
1536 |
bData.RefHV = fData->bRefHV = b_RefHV + (x + y * iEdgedWidth) * 16; |
bData.RefHV = fData->bRefHV = b_RefHV + (x + y * iEdgedWidth) * 16; |
1537 |
bData.RefQ = fData->RefQ; |
bData.RefQ = fData->RefQ; |
1538 |
fData->qpel_precision = bData.qpel_precision = 0; |
fData->qpel_precision = bData.qpel_precision = 0; bData.qpel = fData->qpel; |
1539 |
bData.rounding = 0; |
bData.rounding = 0; |
1540 |
|
|
1541 |
bData.bpredMV = fData->predMV = *f_predMV; |
bData.bpredMV = fData->predMV = *f_predMV; |
1546 |
get_range(&bData.min_dx, &bData.max_dx, &bData.min_dy, &bData.max_dy, x, y, 16, pParam->width, pParam->height, bcode, pParam->m_quarterpel); |
get_range(&bData.min_dx, &bData.max_dx, &bData.min_dy, &bData.max_dy, x, y, 16, pParam->width, pParam->height, bcode, pParam->m_quarterpel); |
1547 |
|
|
1548 |
if (fData->currentMV[0].x > fData->max_dx) fData->currentMV[0].x = fData->max_dx; |
if (fData->currentMV[0].x > fData->max_dx) fData->currentMV[0].x = fData->max_dx; |
1549 |
if (fData->currentMV[0].x < fData->min_dx) fData->currentMV[0].x = fData->min_dy; |
if (fData->currentMV[0].x < fData->min_dx) fData->currentMV[0].x = fData->min_dx; |
1550 |
if (fData->currentMV[0].y > fData->max_dy) fData->currentMV[0].y = fData->max_dx; |
if (fData->currentMV[0].y > fData->max_dy) fData->currentMV[0].y = fData->max_dy; |
1551 |
if (fData->currentMV[0].y > fData->min_dy) fData->currentMV[0].y = fData->min_dy; |
if (fData->currentMV[0].y < fData->min_dy) fData->currentMV[0].y = fData->min_dy; |
1552 |
|
|
1553 |
if (fData->currentMV[1].x > bData.max_dx) fData->currentMV[1].x = bData.max_dx; |
if (fData->currentMV[1].x > bData.max_dx) fData->currentMV[1].x = bData.max_dx; |
1554 |
if (fData->currentMV[1].x < bData.min_dx) fData->currentMV[1].x = bData.min_dy; |
if (fData->currentMV[1].x < bData.min_dx) fData->currentMV[1].x = bData.min_dx; |
1555 |
if (fData->currentMV[1].y > bData.max_dy) fData->currentMV[1].y = bData.max_dx; |
if (fData->currentMV[1].y > bData.max_dy) fData->currentMV[1].y = bData.max_dy; |
1556 |
if (fData->currentMV[1].y > bData.min_dy) fData->currentMV[1].y = bData.min_dy; |
if (fData->currentMV[1].y < bData.min_dy) fData->currentMV[1].y = bData.min_dy; |
1557 |
|
|
1558 |
CheckCandidateInt(fData->currentMV[0].x, fData->currentMV[0].y, 255, &iDirection, fData); |
CheckCandidateInt(fData->currentMV[0].x, fData->currentMV[0].y, 255, &iDirection, fData); |
1559 |
|
|
1582 |
*fData->iMinSAD += 2 * fData->lambda16; // two bits are needed to code interpolate mode. |
*fData->iMinSAD += 2 * fData->lambda16; // two bits are needed to code interpolate mode. |
1583 |
|
|
1584 |
if (fData->qpel) { |
if (fData->qpel) { |
1585 |
|
CheckCandidate = CheckCandidateInt; |
1586 |
fData->qpel_precision = bData.qpel_precision = 1; |
fData->qpel_precision = bData.qpel_precision = 1; |
1587 |
get_range(&fData->min_dx, &fData->max_dx, &fData->min_dy, &fData->max_dy, x, y, 16, pParam->width, pParam->height, fcode, 0); |
get_range(&fData->min_dx, &fData->max_dx, &fData->min_dy, &fData->max_dy, x, y, 16, pParam->width, pParam->height, fcode, 0); |
1588 |
get_range(&bData.min_dx, &bData.max_dx, &bData.min_dy, &bData.max_dy, x, y, 16, pParam->width, pParam->height, bcode, 0); |
get_range(&bData.min_dx, &bData.max_dx, &bData.min_dy, &bData.max_dy, x, y, 16, pParam->width, pParam->height, bcode, 0); |
2038 |
} |
} |
2039 |
|
|
2040 |
#define INTRA_THRESH 1350 |
#define INTRA_THRESH 1350 |
2041 |
#define INTER_THRESH 900 |
#define INTER_THRESH 1200 |
2042 |
|
|
2043 |
|
|
2044 |
int |
int |
2071 |
IntraThresh -= (IntraThresh * (maxIntra - 5*(maxIntra - intraCount)))/maxIntra; |
IntraThresh -= (IntraThresh * (maxIntra - 5*(maxIntra - intraCount)))/maxIntra; |
2072 |
|
|
2073 |
|
|
2074 |
InterThresh += 300 * (1 - bCount); |
InterThresh += 400 * (1 - bCount); |
2075 |
if (InterThresh < 200) InterThresh = 200; |
if (InterThresh < 200) InterThresh = 200; |
2076 |
|
|
2077 |
if (sadInit) (*sadInit) (); |
if (sadInit) (*sadInit) (); |