| 711 | } |
| 712 | |
| 713 | void CWelsPreProcess::BackgroundDetection (SVAAFrameInfo* pVaaInfo, SPicture* pCurPicture, SPicture* pRefPicture, |
| 714 | bool bDetectFlag) { |
| 715 | if (bDetectFlag) { |
| 716 | pVaaInfo->iPicWidth = pCurPicture->iWidthInPixel; |
| 717 | pVaaInfo->iPicHeight = pCurPicture->iHeightInPixel; |
| 718 | |
| 719 | pVaaInfo->iPicStride = pCurPicture->iLineSize[0]; |
| 720 | pVaaInfo->iPicStrideUV = pCurPicture->iLineSize[1]; |
| 721 | pVaaInfo->pCurY = pCurPicture->pData[0]; |
| 722 | pVaaInfo->pRefY = pRefPicture->pData[0]; |
| 723 | pVaaInfo->pCurU = pCurPicture->pData[1]; |
| 724 | pVaaInfo->pRefU = pRefPicture->pData[1]; |
| 725 | pVaaInfo->pCurV = pCurPicture->pData[2]; |
| 726 | pVaaInfo->pRefV = pRefPicture->pData[2]; |
| 727 | |
| 728 | int32_t iMethodIdx = METHOD_BACKGROUND_DETECTION; |
| 729 | SPixMap sSrcPixMap; |
| 730 | SPixMap sRefPixMap; |
| 731 | memset (&sSrcPixMap, 0, sizeof (sSrcPixMap)); |
| 732 | memset (&sRefPixMap, 0, sizeof (sRefPixMap)); |
| 733 | SBGDInterface BGDParam = {0}; |
| 734 | |
| 735 | sSrcPixMap.pPixel[0] = pCurPicture->pData[0]; |
| 736 | sSrcPixMap.pPixel[1] = pCurPicture->pData[1]; |
| 737 | sSrcPixMap.pPixel[2] = pCurPicture->pData[2]; |
| 738 | sSrcPixMap.iSizeInBits = g_kiPixMapSizeInBits; |
| 739 | sSrcPixMap.iStride[0] = pCurPicture->iLineSize[0]; |
| 740 | sSrcPixMap.iStride[1] = pCurPicture->iLineSize[1]; |
| 741 | sSrcPixMap.iStride[2] = pCurPicture->iLineSize[2]; |
| 742 | sSrcPixMap.sRect.iRectWidth = pCurPicture->iWidthInPixel; |
| 743 | sSrcPixMap.sRect.iRectHeight = pCurPicture->iHeightInPixel; |
| 744 | sSrcPixMap.eFormat = VIDEO_FORMAT_I420; |
| 745 | |
| 746 | sRefPixMap.pPixel[0] = pRefPicture->pData[0]; |
| 747 | sRefPixMap.pPixel[1] = pRefPicture->pData[1]; |
| 748 | sRefPixMap.pPixel[2] = pRefPicture->pData[2]; |
| 749 | sRefPixMap.iSizeInBits = g_kiPixMapSizeInBits; |
| 750 | sRefPixMap.iStride[0] = pRefPicture->iLineSize[0]; |
| 751 | sRefPixMap.iStride[1] = pRefPicture->iLineSize[1]; |
| 752 | sRefPixMap.iStride[2] = pRefPicture->iLineSize[2]; |
| 753 | sRefPixMap.sRect.iRectWidth = pRefPicture->iWidthInPixel; |
| 754 | sRefPixMap.sRect.iRectHeight = pRefPicture->iHeightInPixel; |
| 755 | sRefPixMap.eFormat = VIDEO_FORMAT_I420; |
| 756 | |
| 757 | BGDParam.pBackgroundMbFlag = pVaaInfo->pVaaBackgroundMbFlag; |
| 758 | BGDParam.pCalcRes = & (pVaaInfo->sVaaCalcInfo); |
| 759 | m_pInterfaceVp->Set (iMethodIdx, (void*)&BGDParam); |
| 760 | m_pInterfaceVp->Process (iMethodIdx, &sSrcPixMap, &sRefPixMap); |
| 761 | } else { |
| 762 | int32_t iPicWidthInMb = (pCurPicture->iWidthInPixel + 15) >> 4; |
| 763 | int32_t iPicHeightInMb = (pCurPicture->iHeightInPixel + 15) >> 4; |
| 764 | memset (pVaaInfo->pVaaBackgroundMbFlag, 0, iPicWidthInMb * iPicHeightInMb); |
| 765 | } |
| 766 | } |
| 767 | |
| 768 | void CWelsPreProcess::AdaptiveQuantCalculation (SVAAFrameInfo* pVaaInfo, SPicture* pCurPicture, SPicture* pRefPicture) { |
| 769 | pVaaInfo->sAdaptiveQuantParam.pCalcResult = & (pVaaInfo->sVaaCalcInfo); |