| 530 | #define CALC_COST(me_buf, lm) ( pFunc->sSampleDealingFuncs.pfMeCost[kuiPixel](pEncMb, iStrideEnc, me_buf, ME_REFINE_BUF_STRIDE) + lm ) |
| 531 | |
| 532 | inline void MeRefineQuarPixel (SWelsFuncPtrList* pFunc, SWelsME* pMe, SMeRefinePointer* pMeRefine, |
| 533 | const int32_t kiWidth, const int32_t kiHeight, SQuarRefineParams* pParams, int32_t iStrideEnc) { |
| 534 | PWelsSampleAveragingFunc pSampleAvg = pFunc->sMcFuncs.pfSampleAveraging; |
| 535 | int32_t iCurCost; |
| 536 | uint8_t* pEncMb = pMe->pEncMb; |
| 537 | uint8_t* pTmp = NULL; |
| 538 | const uint8_t kuiPixel = pMe->uiBlockSize; |
| 539 | |
| 540 | pSampleAvg (pMeRefine->pQuarPixTmp, ME_REFINE_BUF_STRIDE, pParams->pSrcA[0], ME_REFINE_BUF_STRIDE, |
| 541 | pParams->pSrcB[0], pParams->iStrideA, kiWidth, kiHeight); |
| 542 | |
| 543 | iCurCost = CALC_COST (pMeRefine->pQuarPixTmp, pParams->iLms[0]); |
| 544 | if (iCurCost < pParams->iBestCost) { |
| 545 | pParams->iBestQuarPix = ME_QUAR_PIXEL_TOP; |
| 546 | SWITCH_BEST_TMP_BUF (pMeRefine->pQuarPixBest, pMeRefine->pQuarPixTmp); |
| 547 | } |
| 548 | //=========================(0, 1)=======================// |
| 549 | pSampleAvg (pMeRefine->pQuarPixTmp, ME_REFINE_BUF_STRIDE, pParams->pSrcA[1], |
| 550 | ME_REFINE_BUF_STRIDE, pParams->pSrcB[1], pParams->iStrideA, kiWidth, kiHeight); |
| 551 | iCurCost = CALC_COST (pMeRefine->pQuarPixTmp, pParams->iLms[1]); |
| 552 | if (iCurCost < pParams->iBestCost) { |
| 553 | pParams->iBestQuarPix = ME_QUAR_PIXEL_BOTTOM; |
| 554 | SWITCH_BEST_TMP_BUF (pMeRefine->pQuarPixBest, pMeRefine->pQuarPixTmp); |
| 555 | } |
| 556 | //==========================(-1, 0)=========================// |
| 557 | pSampleAvg (pMeRefine->pQuarPixTmp, ME_REFINE_BUF_STRIDE, pParams->pSrcA[2], |
| 558 | ME_REFINE_BUF_STRIDE, pParams->pSrcB[2], pParams->iStrideB, kiWidth, kiHeight); |
| 559 | iCurCost = CALC_COST (pMeRefine->pQuarPixTmp, pParams->iLms[2]); |
| 560 | if (iCurCost < pParams->iBestCost) { |
| 561 | pParams->iBestQuarPix = ME_QUAR_PIXEL_LEFT; |
| 562 | SWITCH_BEST_TMP_BUF (pMeRefine->pQuarPixBest, pMeRefine->pQuarPixTmp); |
| 563 | } |
| 564 | //==========================(1, 0)=========================// |
| 565 | pSampleAvg (pMeRefine->pQuarPixTmp, ME_REFINE_BUF_STRIDE, pParams->pSrcA[3], |
| 566 | ME_REFINE_BUF_STRIDE, pParams->pSrcB[3], pParams->iStrideB, kiWidth, kiHeight); |
| 567 | |
| 568 | iCurCost = CALC_COST (pMeRefine->pQuarPixTmp, pParams->iLms[3]); |
| 569 | if (iCurCost < pParams->iBestCost) { |
| 570 | pParams->iBestQuarPix = ME_QUAR_PIXEL_RIGHT; |
| 571 | SWITCH_BEST_TMP_BUF (pMeRefine->pQuarPixBest, pMeRefine->pQuarPixTmp); |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | void MeRefineFracPixel (sWelsEncCtx* pEncCtx, uint8_t* pMemPredInterMb, SWelsME* pMe, |
| 576 | SMeRefinePointer* pMeRefine, int32_t iWidth, int32_t iHeight) { |