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 (15) |
#define SKIP_THRESH_B (25) |
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 ); } |
54 |
|
|
55 |
#define iDiamondSize 2 |
#define iDiamondSize 2 |
56 |
|
|
57 |
|
static VECTOR |
58 |
|
GlobalMotionEst(const MACROBLOCK * const pMBs, |
59 |
|
const MBParam * const pParam, const uint32_t iFcode); |
60 |
|
|
61 |
|
|
62 |
static __inline int |
static __inline int |
63 |
d_mv_bits(int x, int y, const uint32_t iFcode) |
d_mv_bits(int x, int y, const uint32_t iFcode) |
64 |
{ |
{ |
1460 |
|
|
1461 |
SubpelRefine(Data); |
SubpelRefine(Data); |
1462 |
|
|
1463 |
*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 |
1464 |
*best_sad = *Data->iMinSAD; |
*best_sad = *Data->iMinSAD; |
1465 |
|
|
1466 |
if (b_mb->mode == MODE_INTER4V) |
if (b_mb->mode == MODE_INTER4V) |
1540 |
bData.RefV = fData->bRefV = b_RefV + (x + y * iEdgedWidth) * 16; |
bData.RefV = fData->bRefV = b_RefV + (x + y * iEdgedWidth) * 16; |
1541 |
bData.RefHV = fData->bRefHV = b_RefHV + (x + y * iEdgedWidth) * 16; |
bData.RefHV = fData->bRefHV = b_RefHV + (x + y * iEdgedWidth) * 16; |
1542 |
bData.RefQ = fData->RefQ; |
bData.RefQ = fData->RefQ; |
1543 |
fData->qpel_precision = bData.qpel_precision = 0; |
fData->qpel_precision = bData.qpel_precision = 0; bData.qpel = fData->qpel; |
1544 |
bData.rounding = 0; |
bData.rounding = 0; |
1545 |
|
|
1546 |
bData.bpredMV = fData->predMV = *f_predMV; |
bData.bpredMV = fData->predMV = *f_predMV; |
1551 |
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); |
1552 |
|
|
1553 |
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; |
1554 |
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; |
1555 |
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; |
1556 |
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; |
1557 |
|
|
1558 |
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; |
1559 |
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; |
1560 |
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; |
1561 |
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; |
1562 |
|
|
1563 |
CheckCandidateInt(fData->currentMV[0].x, fData->currentMV[0].y, 255, &iDirection, fData); |
CheckCandidateInt(fData->currentMV[0].x, fData->currentMV[0].y, 255, &iDirection, fData); |
1564 |
|
|
1584 |
|
|
1585 |
} while (!(iDirection)); |
} while (!(iDirection)); |
1586 |
|
|
|
*fData->iMinSAD += 2 * fData->lambda16; // two bits are needed to code interpolate mode. |
|
|
|
|
1587 |
if (fData->qpel) { |
if (fData->qpel) { |
1588 |
|
CheckCandidate = CheckCandidateInt; |
1589 |
fData->qpel_precision = bData.qpel_precision = 1; |
fData->qpel_precision = bData.qpel_precision = 1; |
1590 |
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); |
1591 |
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); |
1598 |
SubpelRefine(&bData); |
SubpelRefine(&bData); |
1599 |
} |
} |
1600 |
|
|
1601 |
|
*fData->iMinSAD += 2 * fData->lambda16; // two bits are needed to code interpolate mode. |
1602 |
|
|
1603 |
if (*fData->iMinSAD < *best_sad) { |
if (*fData->iMinSAD < *best_sad) { |
1604 |
*best_sad = *fData->iMinSAD; |
*best_sad = *fData->iMinSAD; |
1605 |
pMB->mvs[0] = fData->currentMV[0]; |
pMB->mvs[0] = fData->currentMV[0]; |
1660 |
Data.iEdgedWidth = pParam->edged_width; |
Data.iEdgedWidth = pParam->edged_width; |
1661 |
Data.currentMV = currentMV; Data.currentQMV = currentQMV; |
Data.currentMV = currentMV; Data.currentQMV = currentQMV; |
1662 |
Data.iMinSAD = &iMinSAD; |
Data.iMinSAD = &iMinSAD; |
1663 |
Data.lambda16 = lambda_vec16[frame->quant]; |
Data.lambda16 = lambda_vec16[frame->quant] + 2; |
1664 |
Data.qpel = pParam->m_quarterpel; |
Data.qpel = pParam->m_quarterpel; |
1665 |
Data.rounding = 0; |
Data.rounding = 0; |
1666 |
|
|
1757 |
case MODE_DIRECT: |
case MODE_DIRECT: |
1758 |
case MODE_DIRECT_NO4V: |
case MODE_DIRECT_NO4V: |
1759 |
d_count++; |
d_count++; |
|
break; |
|
1760 |
default: |
default: |
1761 |
break; |
break; |
1762 |
} |
} |