#include "TComMP.h" //#include "../TLibSynth/TComMatrix.h" //#include "../TLibSynth/TSynthD2Z.h" //#include "../TLibSynth/TSynthZ2D.h" //#include "../TLibSynth/TSynthD2D.h" #if POZNAN_MP_USE_DEPTH_MAP_GENERATION #include "../TLibCommon/TComDepthMapGenerator.h" #else #include "../../App/TAppCommon/TAppComCamPara.h" #endif #if POZNAN_MP #if POZNAN_MP_USE_DEPTH_MAP_GENERATION TComMP::TComMP(UInt uiHeight, UInt uiWidth) #else //TComMP::TComMP(UInt uiHeight, UInt uiWidth, TAppComCamPara* pcCameraData) TComMP::TComMP(UInt uiHeight, UInt uiWidth, Int**** aiBaseViewShiftLUT) #endif { m_ppiMvPtCorrX = NULL; m_ppiMvPtCorrY = NULL; m_ppiMvPtCorrZ = NULL; m_ppiMvPtCorrRefViewIdx = NULL; m_pppcRefCU = NULL; m_ppuicRefPartAddr = NULL; m_bInit = false; m_bEnabled = false; m_bDBMPEnabled = false; m_uiHeight = 0; m_uiWidth = 0; m_pcRefPicsList = NULL; m_pcDepthRefPicsList = NULL; #if POZNAN_MP_USE_DEPTH_MAP_GENERATION m_pcDepthMapGenerator = NULL; #else //m_pcCameraData = NULL; m_aiBaseViewShiftLUT = NULL; #if POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE m_ppiTempMvPtCorrX = NULL; m_ppiTempMvPtCorrY = NULL; m_ppiTempMvPtCorrZ = NULL; #endif #endif #if POZNAN_DBMP_CALC_PRED_DATA m_piTempL0RefIdx = NULL; m_piTempL0MvX = NULL; m_piTempL0MvY = NULL; m_piTempL1RefIdx = NULL; m_piTempL1MvX = NULL; m_piTempL1MvY = NULL; m_piTempBuff = NULL; m_piResBuff = NULL; #endif #if POZNAN_MP_USE_DEPTH_MAP_GENERATION if(uiHeight>0 && uiWidth>0) init(uiHeight, uiWidth); #else //if(uiHeight>0 && uiWidth>0) init(uiHeight, uiWidth, pcCameraData); if(uiHeight>0 && uiWidth>0) init(uiHeight, uiWidth, aiBaseViewShiftLUT); #endif } TComMP::~TComMP() { uninit(); } #if POZNAN_MP_USE_DEPTH_MAP_GENERATION Void TComMP::init(UInt uiHeight, UInt uiWidth) #else //Void TComMP::init(UInt uiHeight, UInt uiWidth, TAppComCamPara* pcCameraData) Void TComMP::init(UInt uiHeight, UInt uiWidth, Int**** aiBaseViewShiftLUT) #endif { if(m_bInit) uninit(); m_bInit = true; m_bEnabled = false; m_bDBMPEnabled = false; m_uiHeight = uiHeight; m_uiWidth = uiWidth; m_pcRefPicsList = NULL; m_pcDepthRefPicsList = NULL; #if POZNAN_MP_USE_DEPTH_MAP_GENERATION m_pcDepthMapGenerator = NULL; #else //m_pcCameraData = pcCameraData; m_aiBaseViewShiftLUT = aiBaseViewShiftLUT; #endif Short* piPtr; UShort* puiPtr; TComDataCU** ppcPtr; m_ppiMvPtCorrX = (Short**)malloc(sizeof(Short*)*m_uiHeight); piPtr = (Short*)malloc(sizeof(Short)*m_uiHeight*m_uiWidth); for(UInt i=0,addr=0;icreate(uiSize); apcDBMPPredMVField[1] = new TComCUMvField(); apcDBMPPredMVField[1]->create(uiSize); #endif } #if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA Void TComMP::initArrayMap(UInt uiViewId, Bool bIsDepth) { if(bIsDepth) uiViewId += MAX_NUMBER_VIEWS; if(m_ppiL0RefPOC.count(uiViewId)) return; PUT_MP_ARRAY_TYPE** ppiTemp; PUT_MP_ARRAY_TYPE* piTemp; /* ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i(uiViewId, ppiTemp)); ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i(uiViewId, ppiTemp)); ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i(uiViewId, ppiTemp)); ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i(uiViewId, ppiTemp)); ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i(uiViewId, ppiTemp)); ppiTemp = new PUT_MP_ARRAY_TYPE*[m_uiHeight]; for(Int i=0;i(uiViewId, ppiTemp)); */ ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight); piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth); for(UInt i=0, addr=0;i(uiViewId, ppiTemp)); ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight); piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth); for(UInt i=0, addr=0;i(uiViewId, ppiTemp)); ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight); piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth); for(UInt i=0, addr=0;i(uiViewId, ppiTemp)); ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight); piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth); for(UInt i=0, addr=0;i(uiViewId, ppiTemp)); ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight); piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth); for(UInt i=0, addr=0;i(uiViewId, ppiTemp)); ppiTemp = (PUT_MP_ARRAY_TYPE**)malloc(sizeof(PUT_MP_ARRAY_TYPE*)*m_uiHeight); piTemp = (PUT_MP_ARRAY_TYPE*)malloc(sizeof(PUT_MP_ARRAY_TYPE)*m_uiHeight*m_uiWidth); for(UInt i=0, addr=0;i(uiViewId, ppiTemp)); } #endif Void TComMP::uninit() { if(!m_bInit) return; m_bInit = false; m_bEnabled = false; m_bDBMPEnabled = false; m_pcRefPicsList = NULL; m_pcDepthRefPicsList = NULL; #if POZNAN_MP_USE_DEPTH_MAP_GENERATION m_pcDepthMapGenerator = NULL; #else //m_pcCameraData = NULL; m_aiBaseViewShiftLUT = NULL; #endif if(m_ppiMvPtCorrX!=NULL) { //for(Int i=0;isecond; if(ppiTemp!=NULL) { //for(Int i=0;isecond; if(ppiTemp!=NULL) { //for(Int i=0;isecond; if(ppiTemp!=NULL) { //for(Int i=0;isecond; if(ppiTemp!=NULL) { //for(Int i=0;isecond; if(ppiTemp!=NULL) { //for(Int i=0;isecond; if(ppiTemp!=NULL) { //for(Int i=0;idestroy(); delete apcDBMPPredMVField[0]; apcDBMPPredMVField[0] = NULL; apcDBMPPredMVField[1]->destroy(); delete apcDBMPPredMVField[1]; apcDBMPPredMVField[1] = NULL; #endif m_uiHeight = 0; m_uiWidth = 0; } Void TComMP::clear() { Int i,j; m_bEnabled = false; m_bDBMPEnabled = false; for(i=0;igetSlice(0)->isIntra()) return true; //no motion compenstation is used!!! UInt uiViewId = pcPic->getSPS()->getViewId(); //pcPic->getViewIdx();//??? UInt uiPOC = pcPic->getPOC(); Bool bIsDepth = pcPic->getSPS()->isDepth(); if(uiViewId==0) return true; //no reference view available!!! #if POZNAN_MP_USE_DEPTH_MAP_GENERATION if(pcPic->getPredDepthMap()==NULL) return false; //no depth available!!! #else if(m_pcDepthRefPicsList->empty()) return false; //no depth in reference views available!!! #endif Int iRefX, iRefY; Int iCurX, iCurY; UInt uiRefViewId; TComPic* pcRefPic; Int iDisparity; TComDataCU* pcRefCU; #if POZNAN_MP_USE_DEPTH_MAP_GENERATION Int iShiftX; Int iAddX; #else Int iSynthViewIdx; Int** ppiShiftLUTLeft; TComPic* pcDepthPic; Int iStride; Pel* pDepth; //Bool bIsLeft; Int iDepth; #if POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE Int iSrcX, iSrcY; #endif #endif Bool bIsRefNoISliceAvailable = false; Bool bIsAnchorPicture = false; clear(); #if POZNAN_MP_USE_DEPTH_MAP_GENERATION for( UInt uiIdx = 0; uiIdx < uiViewId; uiIdx++ ) //for( UInt uiIdx = uiViewId-1; uiIdx >= uiViewId; uiIdx-- ) { uiRefViewId = m_pcDepthMapGenerator->getBaseViewId( uiIdx ); iShiftX = m_pcDepthMapGenerator->getSubSampExpX() + 2; iAddX = ( 1 << iShiftX ) >> 1; pcRefPic = (*m_pcRefPicsList)[uiRefViewId]; if(!pcRefPic->getSlice(0)->isIntra()) bIsRefNoISliceAvailable = true; else bIsAnchorPicture = true; for(iCurY=0; iCurY<(Int)m_uiHeight; iCurY++) for(iCurX=0; iCurX<(Int)m_uiWidth; iCurX++) if((m_ppiMvPtCorrX[iCurY][iCurX]==TComMP::OCCLUSION || m_ppiMvPtCorrY[iCurY][iCurX]==TComMP::OCCLUSION)) { iDisparity = m_pcDepthMapGenerator->getDisparity( pcPic, iCurX >> m_pcDepthMapGenerator->getSubSampExpX(), iCurY >> m_pcDepthMapGenerator->getSubSampExpY(), uiRefViewId ); iRefX = iCurX + ( ( iDisparity + iAddX ) >> iShiftX ); iRefY = iCurY; if(iRefX>=0 && iRefX=0 && iRefYgetPredDepthMap()->getLumaAddr( 0 ); Int iStride = pcPic->getPredDepthMap()->getStride (); Int iPrdDepth = piPdmMap[ iCurX + iCurY * iStride ]; m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iPrdDepth; //m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDisparity; pcRefCU = pcRefPic->getCU((UInt)(iRefY/pcRefPic->getSlice(0)->getSPS()->getMaxCUHeight()*pcRefPic->getFrameWidthInCU() + iRefX/pcRefPic->getSlice(0)->getSPS()->getMaxCUWidth())); m_pppcRefCU[iCurY][iCurX] = pcRefCU; m_ppuicRefPartAddr[iCurY][iCurX] = (UShort)g_auiRasterToZscan[(iRefY-pcRefCU->getCUPelY())/pcRefPic->getMinCUHeight()*pcRefPic->getNumPartInWidth()+(iRefX-pcRefCU->getCUPelX())/pcRefPic->getMinCUWidth()]; } } } #else #if POZNAN_MP_USE_CURRENT_VIEW_DEPTH_MAP_IF_AVAILABLE //pcDepthPic = GetPicFromList(m_pcDepthRefPicsList, uiPOC, uiViewId); if(pcPic->getSlice(0)->getDepthPic()!=NULL && pcPic->getSlice(0)->getDepthPic()->getReconMark()) pcDepthPic = pcPic->getSlice(0)->getDepthPic(); else pcDepthPic = NULL; if(pcDepthPic!=NULL) { pDepth = pcDepthPic->getPicYuvRec()->getLumaAddr(); iStride = pcDepthPic->getPicYuvRec()->getStride(); for( UInt uiIdx = 0; uiIdx < uiViewId; uiIdx++ ) //for( UInt uiIdx = uiViewId-1; uiIdx >= uiViewId; uiIdx-- ) { uiRefViewId = uiIdx; pcRefPic = GetPicFromList(m_pcRefPicsList, uiPOC, uiRefViewId); assert(pcRefPic!=NULL);//test if(pcRefPic==NULL) return false; //No ref pic with current POC and RefView found in ref list!!! if(!pcRefPic->getSlice(0)->isIntra()) bIsRefNoISliceAvailable = true; else bIsAnchorPicture = true; //ppiShiftLUTLeft = m_pcCameraData->getBaseViewShiftLUTI()[uiViewId][uiRefViewId]; ppiShiftLUTLeft = m_aiBaseViewShiftLUT[uiViewId][uiRefViewId]; clearTemp(); for(iCurY=0; iCurY<(Int)m_uiHeight; iCurY++) for(iCurX=0; iCurX<(Int)m_uiWidth; iCurX++) { //Check if point already has its reference: if(m_ppiMvPtCorrX[iCurY][iCurX]!=TComMP::OCCLUSION && m_ppiMvPtCorrY[iCurY][iCurX]!=TComMP::OCCLUSION) continue; iDepth = pDepth[ iCurX + iCurY * iStride ]; iDepth = RemoveBitIncrement(iDepth); assert( iDepth >= 0 && iDepth <= 256 ); //if(bIsLeft) iDisparity = ppiShiftLUTLeft[0][iDepth]; //else iDisparity = -ppiShiftLUTLeft[0][iDepth]; iDisparity = ppiShiftLUTLeft[0][iDepth]; //!!! iRefX = iCurX - ( ( iDisparity + 2 ) >> 2 ); iRefY = iCurY; if(iRefX>=0 && iRefX=0 && iRefYgetCU((UInt)(iRefY/pcRefPic->getSlice(0)->getSPS()->getMaxCUHeight()*pcRefPic->getFrameWidthInCU() + iRefX/pcRefPic->getSlice(0)->getSPS()->getMaxCUWidth())); m_pppcRefCU[iCurY][iCurX] = pcRefCU; m_ppuicRefPartAddr[iCurY][iCurX] = (UShort)g_auiRasterToZscan[(iRefY-pcRefCU->getCUPelY())/pcRefPic->getMinCUHeight()*pcRefPic->getNumPartInWidth()+(iRefX-pcRefCU->getCUPelX())/pcRefPic->getMinCUWidth()]; m_ppiTempMvPtCorrX[iRefY][iRefX] = iCurX; m_ppiTempMvPtCorrY[iRefY][iRefX] = iCurY; m_ppiTempMvPtCorrZ[iRefY][iRefX] = (Short)iDepth; //m_ppiTempMvPtCorrZ[iRefY][iRefX] = (Short)iDisparity; } else if((Short)iDepth>m_ppiTempMvPtCorrZ[iRefY][iRefX]) //Point assigned earlier to this location is occluded //else if((Short)iDisparity>m_ppiTempMvPtCorrZ[iRefY][iRefX]) //Point assigned earlier to this location is occluded { m_ppiMvPtCorrRefViewIdx[iCurY][iCurX] = (Short)uiRefViewId; m_ppiMvPtCorrX[iCurY][iCurX] = (Short)iRefX; m_ppiMvPtCorrY[iCurY][iCurX] = (Short)iRefY; m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDepth; //m_ppiMvPtCorrZ[iCurY][iCurX] = (Short)iDisparity; pcRefCU = pcRefPic->getCU((UInt)(iRefY/pcRefPic->getSlice(0)->getSPS()->getMaxCUHeight()*pcRefPic->getFrameWidthInCU() + iRefX/pcRefPic->getSlice(0)->getSPS()->getMaxCUWidth())); m_pppcRefCU[iCurY][iCurX] = pcRefCU; m_ppuicRefPartAddr[iCurY][iCurX] = (UShort)g_auiRasterToZscan[(iRefY-pcRefCU->getCUPelY())/pcRefPic->getMinCUHeight()*pcRefPic->getNumPartInWidth()+(iRefX-pcRefCU->getCUPelX())/pcRefPic->getMinCUWidth()]; m_ppiTempMvPtCorrX[iRefY][iRefX] = iCurX; m_ppiTempMvPtCorrY[iRefY][iRefX] = iCurY; m_ppiTempMvPtCorrZ[iRefY][iRefX] = (Short)iDepth; //m_ppiTempMvPtCorrZ[iRefY][iRefX] = (Short)iDisparity; //Mark point assigned earlier to this location as occluded: m_ppiMvPtCorrRefViewIdx[iSrcY][iSrcX] = TComMP::OCCLUSION; m_ppiMvPtCorrX[iSrcY][iSrcX] = TComMP::OCCLUSION; m_ppiMvPtCorrY[iSrcY][iSrcX] = TComMP::OCCLUSION; //m_ppiMvPtCorrZ[iSrcY][iSrcX] = 0x7FFF; m_ppiMvPtCorrZ[iSrcY][iSrcX] = TComMP::OCCLUSION; m_pppcRefCU[iSrcY][iSrcX] = NULL; m_ppuicRefPartAddr[iSrcY][iSrcX] = 0; } } } } } else #endif { iSynthViewIdx = uiViewId; for( UInt uiIdx = 0; uiIdx < uiViewId; uiIdx++ ) //for( UInt uiIdx = uiViewId-1; uiIdx >= uiViewId; uiIdx-- ) { uiRefViewId = uiIdx; pcRefPic = GetPicFromList(m_pcRefPicsList, uiPOC, uiRefViewId); assert(pcRefPic!=NULL);//test if(pcRefPic==NULL) return false; //No ref pic with current POC and RefView found in ref list!!! if(!pcRefPic->getSlice(0)->isIntra()) bIsRefNoISliceAvailable = true; else bIsAnchorPicture = true; //ppiShiftLUTLeft = m_pcCameraData->getBaseViewShiftLUTI()[uiRefViewId][iSynthViewIdx]; ppiShiftLUTLeft = m_aiBaseViewShiftLUT[uiRefViewId][iSynthViewIdx]; pcDepthPic = GetPicFromList(m_pcDepthRefPicsList, uiPOC, uiRefViewId); assert(pcDepthPic!=NULL);//test if(pcDepthPic==NULL) return false; //No depth with current POC and RefView found in ref list!!! pDepth = pcDepthPic->getPicYuvRec()->getLumaAddr(); iStride = pcDepthPic->getPicYuvRec()->getStride(); //bIsLeft = m_pcCameraData->isLeftView(iSynthViewIdx, uiRefViewId); for(iRefY=0; iRefY<(Int)m_uiHeight; iRefY++) for(iRefX=0; iRefX<(Int)m_uiWidth; iRefX++) { iDepth = pDepth[ iRefX + iRefY * iStride ]; iDepth = RemoveBitIncrement(iDepth); assert( iDepth >= 0 && iDepth <= 256 ); //if(bIsLeft) iDisparity = ppiShiftLUTLeft[0][iDepth]; //else iDisparity = -ppiShiftLUTLeft[0][iDepth]; iDisparity = ppiShiftLUTLeft[0][iDepth]; //!!! iCurX = iRefX - ( ( iDisparity + 2 ) >> 2 ); iCurY = iRefY; if(iCurX>=0 && iCurX=0 && iCurYgetCU((UInt)(iRefY/pcRefPic->getSlice(0)->getSPS()->getMaxCUHeight()*pcRefPic->getFrameWidthInCU() + iRefX/pcRefPic->getSlice(0)->getSPS()->getMaxCUWidth())); m_pppcRefCU[iCurY][iCurX] = pcRefCU; m_ppuicRefPartAddr[iCurY][iCurX] = (UShort)g_auiRasterToZscan[(iRefY-pcRefCU->getCUPelY())/pcRefPic->getMinCUHeight()*pcRefPic->getNumPartInWidth()+(iRefX-pcRefCU->getCUPelX())/pcRefPic->getMinCUWidth()]; } } } } #endif #if POZNAN_MP_FILL fillMultiview(uiViewId); #endif #if POZNAN_DBMP & !POZNAN_DBMP_COMPRESS_ME_DATA for( UInt uiIdx = 0; uiIdx <= uiViewId; uiIdx++ ) initArrayMap(uiIdx, bIsDepth); #endif m_uiView = uiViewId; m_uiPOC = uiPOC; m_bIsDepth = bIsDepth; m_bEnabled = true; #if POZNAN_DBMP m_bDBMPEnabled = (pcPic->getSPS()->getDBMP() > 0) & m_bEnabled & bIsRefNoISliceAvailable; //no reference view with motion data available #if POZNAN_DBMP_USE_IN_NONANCHOR_PIC_ONLY m_bDBMPEnabled &= !bIsAnchorPicture; //is non-anchor picture #endif #if !POZNAN_DBMP_USE_FOR_TEXTURE if(!m_bIsDepth) m_bDBMPEnabled = false; #endif #if !POZNAN_DBMP_USE_FOR_DEPTH if(m_bIsDepth) m_bDBMPEnabled = false; #endif #else m_bDBMPEnabled = false; #endif return true; } #if POZNAN_MP_FILL Void TComMP::fillMultiview(UInt uiViewId) { Int iPicXpos,iPicYpos; Int iRefXpos,iRefYpos; Int iRefXPos1,iRefYPos1,iRefXPos2,iRefYPos2; for(iPicYpos=0; iPicYpos<(Int)m_uiHeight;iPicYpos++) for(iPicXpos=0; iPicXpos<(Int)m_uiWidth;iPicXpos++) if(m_ppiMvPtCorrX[iPicYpos][iPicXpos] == TComMP::OCCLUSION) { //Check left-hand neighbours: iRefXPos1=TComMP::OCCLUSION; iRefYPos1=TComMP::OCCLUSION; iRefYpos=iPicYpos; for(iRefXpos=iPicXpos-1;iRefXpos>=0;iRefXpos--) if(m_ppiMvPtCorrX[iRefYpos][iRefXpos]!=TComMP::OCCLUSION)//Counterpart pixel in reference view exists { iRefXPos1 = iRefXpos; iRefYPos1 = iRefYpos; break; } //Check right-hand neighbours: iRefXPos2=TComMP::OCCLUSION; iRefYPos2=TComMP::OCCLUSION; iRefYpos=iPicYpos; for(iRefXpos=iPicXpos+1;iRefXposm_ppiMvPtCorrZ[iRefYPos2][iRefXPos2]) { iRefXpos=iRefXPos2; iRefYpos=iRefYPos2; } else { iRefXpos=iRefXPos1; iRefYpos=iRefYPos1; } } else { iRefXpos=iRefXPos2; iRefYpos=iRefYPos2; } if(iRefXpos==TComMP::OCCLUSION && iRefYpos==TComMP::OCCLUSION) continue; #elif POZNAN_MP_FILL_TYPE==1 //Choose point with larger disparity: if(iRefXPos1!=TComMP::OCCLUSION && iRefYPos1!=TComMP::OCCLUSION) { if(iRefXPos2!=TComMP::OCCLUSION && iRefYPos2!=TComMP::OCCLUSION && m_ppiMvPtCorrZ[iRefYPos1][iRefXPos1]* pcListPic,UInt uiPOC, UInt uiView) //Get Pic from list based on POC ad View { // find current position std::vector::iterator iterPic; TComPic* pcPic = NULL; for(iterPic = pcListPic->begin(); iterPic != pcListPic->end(); iterPic++) { pcPic = *(iterPic); if((pcPic->getPOC() == (Int)uiPOC) && (pcPic->getViewIdx() == (Int)uiView) && pcPic->getReconMark()) return pcPic; //if((pcPic->getPOC() == (Int)uiPOC) && (pcPic->getViewIdx() == (Int)uiView) ) return pcPic; } assert (0); return NULL; } Int TComMP::GetRepresentativeVal(UInt &uiCntMax, Int* piIn, UInt uiLen, Int* piTemp, Bool bUseRestrictedVal, Int iRestrictedVal) { UInt i,j,cnt,idx; uiCntMax = 0; idx = -1; for(i=0;iuiCntMax || (cnt==uiCntMax && abs(piIn[i])getSlice()->getSPS()->getViewId(); Bool bIsDepth = pcCU->getSlice()->getSPS()->isDepth(); Int iRefIdx; TComPic* pcPic; TComMP* pcMP = pcCU->getSlice()->getMP(); TComDataCU*pcRefCU = pcMP->getMPCRefCU()[y][x]; UInt uiRefPartAddr = pcMP->getMPCRefPartAddr()[y][x]; Int x_ref = pcMP->getMPCx()[y][x]; Int y_ref = pcMP->getMPCy()[y][x]; ref_frame0 = -1; ref_frame1 = -1; if(pcRefCU != NULL) //Point has its counterpart in the reference view { #if !POZNAN_DBMP_COMPRESS_ME_DATA if(pcRefCU->getMergeIndex(uiRefPartAddr)==POZNAN_DBMP_MRG_CAND) { UInt uiRefViewId = pcRefCU->getSlice()->getSPS()->getViewId(); ref_frame0 = pcMP->getL0RefPOC(uiRefViewId, bIsDepth)[y_ref][x_ref]; mv0.setHor(pcMP->getL0MvX(uiRefViewId, bIsDepth)[y_ref][x_ref]); mv0.setVer(pcMP->getL0MvY(uiRefViewId, bIsDepth)[y_ref][x_ref]); ref_frame1 = pcMP->getL1RefPOC(uiRefViewId, bIsDepth)[y_ref][x_ref]; mv1.setHor(pcMP->getL1MvX(uiRefViewId, bIsDepth)[y_ref][x_ref]); mv1.setVer(pcMP->getL1MvY(uiRefViewId, bIsDepth)[y_ref][x_ref]); } else { #endif if(pcRefCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiRefPartAddr)>=0) { ref_frame0 = pcRefCU->getSlice()->getRefPOC( REF_PIC_LIST_0, pcRefCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiRefPartAddr) ); mv0 = pcRefCU->getCUMvField( REF_PIC_LIST_0 )->getMv( uiRefPartAddr ); } if(pcRefCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiRefPartAddr)>=0) { ref_frame1 = pcRefCU->getSlice()->getRefPOC( REF_PIC_LIST_1, pcRefCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiRefPartAddr) ); mv1 = pcRefCU->getCUMvField( REF_PIC_LIST_1 )->getMv( uiRefPartAddr ); } #if !POZNAN_DBMP_COMPRESS_ME_DATA } #endif } //Find ref_frame0 index on REF_PIC_LIST_0 ref_frame0_idx = -1; if(ref_frame0 != -1) { for( iRefIdx = 0; iRefIdx < pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_0); iRefIdx++ ) { pcPic = pcCU->getSlice()->getRefPic( REF_PIC_LIST_0, iRefIdx ); if(ref_frame0 == pcPic->getPOC() && uiViewId==pcPic->getSPS()->getViewId()){ ref_frame0_idx = iRefIdx; break;} } if(ref_frame0_idx == -1) ref_frame0 = -1; } //Find ref_frame1 index on REF_PIC_LIST_1 ref_frame1_idx = -1; if(ref_frame1 != -1) { for( iRefIdx = 0; iRefIdx < pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_1); iRefIdx++ ) { pcPic = pcCU->getSlice()->getRefPic( REF_PIC_LIST_1, iRefIdx ); if(ref_frame1 == pcPic->getPOC() && uiViewId==pcCU->getSlice()->getSPS()->getViewId()){ ref_frame1_idx = iRefIdx; break;} } if(ref_frame1_idx == -1) ref_frame1 = -1; } if(ref_frame0_idx < 0 && ref_frame1_idx < 0) //No counterpart pixel in reference view found or no motion data was found { ref_frame0_idx = ref_frame0_idx_2nd; mv0 = mv0_2nd; if(ref_frame0_idx_2nd == -1) ref_frame0 = -1; else ref_frame0 = pcCU->getSlice()->getRefPic( REF_PIC_LIST_0, ref_frame0_idx_2nd )->getPOC(); ref_frame1_idx = ref_frame1_idx_2nd; mv1 = mv1_2nd; if(ref_frame1_idx_2nd == -1) ref_frame1 = -1; else ref_frame1 = pcCU->getSlice()->getRefPic( REF_PIC_LIST_1, ref_frame1_idx_2nd )->getPOC(); } else //Counterpart point with motion data was found { if(ref_frame0_idx < 0) { ref_frame0_idx = -1; mv0.setZero(); } else { //use mv0 and RefIdx obtained by the DBMP algorithm } if(ref_frame1_idx < 0) { ref_frame1_idx = -1; mv1.setZero(); } else { //use mv0 and RefIdx obtained by the DBMP algorithm } } } #if !POZNAN_DBMP_COMPRESS_ME_DATA Void TComMP::saveDBMPData(TComDataCU* pcCU) { if(!isDBMPEnabled()) return; Int px,py,x,y,iCUBaseX,iCUBaseY; Int ref_frame0, ref_frame1; Int ref_frame0_idx, ref_frame1_idx; TComMv mv0,mv1; Int ref_frame0_idx_2nd, ref_frame1_idx_2nd; TComMv mv0_2nd,mv1_2nd; UInt uiViewId = pcCU->getSlice()->getSPS()->getViewId(); Bool bIsDepth = pcCU->getSlice()->getSPS()->isDepth(); Int iWidth = g_uiMaxCUWidth>>g_uiMaxCUDepth; Int iHeight = g_uiMaxCUHeight>>g_uiMaxCUDepth; for (UInt uiPartAddr = 0; uiPartAddr < pcCU->getTotalNumPart(); uiPartAddr++ ) { if(pcCU->getMergeIndex(uiPartAddr)==POZNAN_DBMP_MRG_CAND) { #if POZNAN_DBMP_CALC_PRED_DATA ref_frame0_idx_2nd = pcCU->getCUMvField2nd(REF_PIC_LIST_0)->getRefIdx(uiPartAddr); mv0_2nd = pcCU->getCUMvField2nd( REF_PIC_LIST_0 )->getMv( uiPartAddr ); ref_frame1_idx_2nd = pcCU->getCUMvField2nd(REF_PIC_LIST_1)->getRefIdx(uiPartAddr); mv1_2nd = pcCU->getCUMvField2nd( REF_PIC_LIST_1 )->getMv( uiPartAddr ); #else ref_frame0_idx_2nd = pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiPartAddr); mv0_2nd = pcCU->getCUMvField( REF_PIC_LIST_0 )->getMv( uiPartAddr ); ref_frame1_idx_2nd = pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiPartAddr); mv1_2nd = pcCU->getCUMvField( REF_PIC_LIST_1 )->getMv( uiPartAddr ); #endif iCUBaseX = pcCU->getCUPelX()+g_auiRasterToPelX[ g_auiZscanToRaster[uiPartAddr] ]; iCUBaseY = pcCU->getCUPelY()+g_auiRasterToPelY[ g_auiZscanToRaster[uiPartAddr] ]; for( py = 0; py < iHeight; py++) { y = iCUBaseY+py; for( px = 0; px < iWidth; px++) { x = iCUBaseX+px; getDBMPPredData(pcCU, x, y, ref_frame0, ref_frame0_idx, mv0, ref_frame0_idx_2nd, mv0_2nd, ref_frame1, ref_frame1_idx, mv1, ref_frame1_idx_2nd, mv1_2nd); setL0RefPOC(uiViewId,bIsDepth,x,y,ref_frame0); setL0MvX(uiViewId,bIsDepth,x,y,mv0.getHor()); setL0MvY(uiViewId,bIsDepth,x,y,mv0.getVer()); setL1RefPOC(uiViewId,bIsDepth,x,y,ref_frame1); setL1MvX(uiViewId,bIsDepth,x,y,mv1.getHor()); setL1MvY(uiViewId,bIsDepth,x,y,mv1.getVer()); } } } } } #endif #endif #if POZNAN_DBMP_CALC_PRED_DATA Void TComMP::calcDBMPPredData(TComDataCU* pcCU, UInt uiAbsPartIdx, Int &ref_frame0_idx, TComMv &mv0, Int &ref_frame1_idx, TComMv &mv1) { if(!isDBMPEnabled() || pcCU->getMergeIndex(uiAbsPartIdx)!=POZNAN_DBMP_MRG_CAND) return; Int iWidth,iHeight; Int x,y,iCUBaseX,iCUBaseY; switch(pcCU->getPartitionSize( uiAbsPartIdx )) { case SIZE_2Nx2N: iWidth = pcCU->getWidth(uiAbsPartIdx); iHeight = pcCU->getHeight(uiAbsPartIdx); break; case SIZE_2NxN: iWidth = pcCU->getWidth(uiAbsPartIdx); iHeight = pcCU->getHeight(uiAbsPartIdx) >> 1; break; case SIZE_Nx2N: iWidth = pcCU->getWidth(uiAbsPartIdx) >> 1; iHeight = pcCU->getHeight(uiAbsPartIdx); break; case SIZE_NxN: iWidth = pcCU->getWidth(uiAbsPartIdx) >> 1; iHeight = pcCU->getHeight(uiAbsPartIdx) >> 1; break; default: assert(0); } Int ref_frame0, ref_frame1; Int ref_frame0_idx_2nd = pcCU->getCUMvField2nd(REF_PIC_LIST_0)->getRefIdx(uiAbsPartIdx); TComMv mv0_2nd = pcCU->getCUMvField2nd( REF_PIC_LIST_0 )->getMv( uiAbsPartIdx ); Int ref_frame1_idx_2nd = pcCU->getCUMvField2nd(REF_PIC_LIST_1)->getRefIdx(uiAbsPartIdx); TComMv mv1_2nd = pcCU->getCUMvField2nd( REF_PIC_LIST_1 )->getMv( uiAbsPartIdx ); iCUBaseX = pcCU->getCUPelX()+g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; iCUBaseY = pcCU->getCUPelY()+g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; UInt uiPointCnt = 0; for( y = iCUBaseY; y < iCUBaseY+iHeight; y++) for( x = iCUBaseX; x < iCUBaseX+iWidth; x++) { getDBMPPredData(pcCU, x, y, ref_frame0, ref_frame0_idx, mv0, ref_frame0_idx_2nd, mv0_2nd, ref_frame1, ref_frame1_idx, mv1, ref_frame1_idx_2nd, mv1_2nd); m_piTempL0RefIdx[uiPointCnt] = ref_frame0_idx; m_piTempL0MvX[uiPointCnt] = mv0.getHor(); m_piTempL0MvY[uiPointCnt] = mv0.getVer(); m_piTempL1RefIdx[uiPointCnt] = ref_frame1_idx; m_piTempL1MvX[uiPointCnt] = mv1.getHor(); m_piTempL1MvY[uiPointCnt] = mv1.getVer(); uiPointCnt++; } xCalcDBMPPredData(uiPointCnt, ref_frame0_idx, mv0, ref_frame1_idx, mv1); } Void TComMP::setDBMPPredMVField(RefPicList eRefListIdx, TComDataCU* pcCU) { apcDBMPPredMVField[eRefListIdx]->copyFrom(pcCU->getCUMvField(eRefListIdx), pcCU->getTotalNumPart(), 0); } Void TComMP::setDBMPPredMVField(RefPicList eRefListIdx, TComDataCU* pcCU, Int iNumPartSrc, Int iPartAddrDst) { apcDBMPPredMVField[eRefListIdx]->copyFrom(pcCU->getCUMvField(eRefListIdx), iNumPartSrc, iPartAddrDst); } #endif #if POZNAN_DBMP_CALC_PRED_DATA Void TComMP::xCalcDBMPPredData(UInt uiCnt, Int &ref_frame0_idx, TComMv &mv0, Int &ref_frame1_idx, TComMv &mv1) { if(uiCnt==0) return; Int iVal; UInt i,uiCntMax,uiCntTemp; //for(i=0;i