m_pFeatureSearchPreparation); ASSERT_TRUE (ENC_RETURN_SUCCESS == iReturn); iReturn = RequestScreenBlockFeatureStorage (m_pMa, m_iWidth, m_iHeight, kiNeedFeatureStorage, m_pScreenBlockFeatureStorage); ASSERT_TRUE (ENC_RETURN_SUCCESS == iReturn); SMVUnitXY sTargetMv; for (int i = sSlice.sMvStartMin.iMvX; i <= sSlice.sMvStartMax.iMvX; i++) { for (int j = sSlice.sMvStartMin.iMvY; j <= sSlice.sMvStartMax.iMvY; j++) { if (i == 0 || j == 0) continue; //exclude x=0 or y=0 since that will be skipped by FME bool bDataGeneratorSucceed = false; bool bFoundMatch = false; if (!YUVPixelDataGenerator (m_pRefData, m_iWidth, m_iHeight, m_iWidth)) continue; bDataGeneratorSucceed = true; sTargetMv.iMvX = i; sTargetMv.iMvY = j; CopyTargetBlock (m_pSrcBlock, m_iMaxSearchBlock, sTargetMv, m_iWidth, pRefPicCenter); //clean sMe status sMe.uiBlockSize = BLOCK_8x8; sMe.pEncMb = m_pSrcBlock; sMe.pRefMb = pRefPicCenter; sMe.pColoRefMb = pRefPicCenter; sMe.sMv.iMvX = sMe.sMv.iMvY = 0; sMe.uiSadCost = sMe.uiSatdCost = kiMaxBlock16Sad; //begin FME process PerformFMEPreprocess (&sFuncList, &sRef, m_pFeatureSearchPreparation->pFeatureOfBlock, m_pScreenBlockFeatureStorage); m_pScreenBlockFeatureStorage->uiSadCostThreshold[BLOCK_8x8] = UINT_MAX;//to avoid early skip uint32_t uiMaxSearchPoint = INT_MAX; SFeatureSearchIn sFeatureSearchIn = {0}; if (SetFeatureSearchIn (&sFuncList, sMe, &sSlice, m_pScreenBlockFeatureStorage, m_iMaxSearchBlock, m_iWidth, &sFeatureSearchIn)) { MotionEstimateFeatureFullSearch (sFeatureSearchIn, uiMaxSearchPoint, &sMe); } bool bMvMatch = sMe.sMv.iMvX == sTargetMv.iMvX && sMe.sMv.iMvY == sTargetMv.iMvY; bool bFeatureMatch = (* (m_pScreenBlockFeatureStorage->pFeatureOfBlockPointer + (m_iHeight / 2 + sTargetMv.iMvY) * (m_iWidth - 8) + (m_iWidth / 2 + sTargetMv.iMvX)) == * (m_pScreenBlockFeatureStorage->pFeatureOfBlockPointer + (m_iHeight / 2 + sMe.sMv.iMvY) * (m_iWidth - 8) + (m_iWidth / 2 + sMe.sMv.iMvX))) && ((sMe.pMvdCost[sMe.sMv.iMvY << 2] + sMe.pMvdCost[sMe.sMv.iMvX << 2]) <= (sMe.pMvdCost[sTargetMv.iMvY << 2] + sMe.pMvdCost[sTargetMv.iMvX << 2])); //the last selection may be affected by MVDcost, that is when smaller Mv will be better bFoundMatch = bMvMatch || bFeatureMatch; if (bDataGeneratorSucceed) { //if DataGenerator never succeed, there is no meaning to check iTryTimes if (!bFoundMatch) { printf ("TestFeatureSearch Target: %d,%d, Result: %d,%d\n", sTargetMv.iMvX, sTargetMv.iMvY, sMe.sMv.iMvX, sMe.sMv.iMvY); } EXPECT_TRUE (bFoundMatch); } } }} Lines 501–565 of 565. Previous lines
m_pFeatureSearchPreparation); ASSERT_TRUE (ENC_RETURN_SUCCESS == iReturn); iReturn = RequestScreenBlockFeatureStorage (m_pMa, m_iWidth, m_iHeight, kiNeedFeatureStorage, m_pScreenBlockFeatureStorage); ASSERT_TRUE (ENC_RETURN_SUCCESS == iReturn); SMVUnitXY sTargetMv; for (int i = sSlice.sMvStartMin.iMvX; i <= sSlice.sMvStartMax.iMvX; i++) { for (int j = sSlice.sMvStartMin.iMvY; j <= sSlice.sMvStartMax.iMvY; j++) { if (i == 0 || j == 0) continue; //exclude x=0 or y=0 since that will be skipped by FME bool bDataGeneratorSucceed = false; bool bFoundMatch = false; if (!YUVPixelDataGenerator (m_pRefData, m_iWidth, m_iHeight, m_iWidth)) continue; bDataGeneratorSucceed = true; sTargetMv.iMvX = i; sTargetMv.iMvY = j; CopyTargetBlock (m_pSrcBlock, m_iMaxSearchBlock, sTargetMv, m_iWidth, pRefPicCenter); //clean sMe status sMe.uiBlockSize = BLOCK_8x8; sMe.pEncMb = m_pSrcBlock; sMe.pRefMb = pRefPicCenter; sMe.pColoRefMb = pRefPicCenter; sMe.sMv.iMvX = sMe.sMv.iMvY = 0; sMe.uiSadCost = sMe.uiSatdCost = kiMaxBlock16Sad; //begin FME process PerformFMEPreprocess (&sFuncList, &sRef, m_pFeatureSearchPreparation->pFeatureOfBlock, m_pScreenBlockFeatureStorage); m_pScreenBlockFeatureStorage->uiSadCostThreshold[BLOCK_8x8] = UINT_MAX;//to avoid early skip uint32_t uiMaxSearchPoint = INT_MAX; SFeatureSearchIn sFeatureSearchIn = {0}; if (SetFeatureSearchIn (&sFuncList, sMe, &sSlice, m_pScreenBlockFeatureStorage, m_iMaxSearchBlock, m_iWidth, &sFeatureSearchIn)) { MotionEstimateFeatureFullSearch (sFeatureSearchIn, uiMaxSearchPoint, &sMe); } bool bMvMatch = sMe.sMv.iMvX == sTargetMv.iMvX && sMe.sMv.iMvY == sTargetMv.iMvY; bool bFeatureMatch = (* (m_pScreenBlockFeatureStorage->pFeatureOfBlockPointer + (m_iHeight / 2 + sTargetMv.iMvY) * (m_iWidth - 8) + (m_iWidth / 2 + sTargetMv.iMvX)) == * (m_pScreenBlockFeatureStorage->pFeatureOfBlockPointer + (m_iHeight / 2 + sMe.sMv.iMvY) * (m_iWidth - 8) + (m_iWidth / 2 + sMe.sMv.iMvX))) && ((sMe.pMvdCost[sMe.sMv.iMvY << 2] + sMe.pMvdCost[sMe.sMv.iMvX << 2]) <= (sMe.pMvdCost[sTargetMv.iMvY << 2] + sMe.pMvdCost[sTargetMv.iMvX << 2])); //the last selection may be affected by MVDcost, that is when smaller Mv will be better bFoundMatch = bMvMatch || bFeatureMatch; if (bDataGeneratorSucceed) { //if DataGenerator never succeed, there is no meaning to check iTryTimes if (!bFoundMatch) { printf ("TestFeatureSearch Target: %d,%d, Result: %d,%d\n", sTargetMv.iMvX, sTargetMv.iMvY, sMe.sMv.iMvX, sMe.sMv.iMvY); } EXPECT_TRUE (bFoundMatch); } } } }