/*****************************************************************************************************************************************/
DPENode::onInit()
{
}
DPENode::onThreadStart()
{
// init DPEStream
mpDPEStream = NSCam::NSIoPipe::NSDpe::IDpeStream::createInstance("VSDOF_DPE");
mpDPEStream->init();
// init the last DMP
mLastDMP_L = mpDMPBufferPool->request();
mLastDMP_R = mpDMPBufferPool->request();
}
DPENode::onData(DataID data, DepthMapRequestPtr& pRequest)
{
// + : reqId=0
switch(data)
case N3D_TO_DPE_MVSV_MASK:
// + : reqID=0 size=0
// enqueue the request into the queue,the request then will be handled during onThreadLoop()
mJobQueue.enque(pRequest);
break;
default://Unrecongnized DataID=%d
}
DPENode::onThreadLoop()
{
DepthMapRequestPtr pRequest;
//check if the queue ready
waitAllQueue(); //will block until queue ready
//dequeue the request
mJobQueue.deque(pRequest);
// mark on-going-request start
this->incExtThreadDependency();
// threadLoop start, reqID=%d
DVEParams enqueParams;
MBOOL bRet = MFALSE;
// prepare the enque configs
if(pRequest->getRequestAttr().opState == eSTATE_NORMAL)
{
prepareDPEEnqueConfig_PVVR(pRequest, enqueParams.mDVEConfigVec)
{
sp<BaseBufferHandler> pBufferHandler = pRequest->getBufferHandler();
// insert the dynamic data
IImageBuffer *pImgBuf_MV_Y, *pImgBuf_SV_Y;
IImageBuffer *pImgBuf_MASK_M , *pImgBuf_MASK_S;
// input buffer
MBOOL bRet = pBufferHandler->getEnqueBuffer(getNodeId(), BID_N3D_OUT_MV_Y, pImgBuf_MV_Y);
pBufferHandler->getEnqueBuffer(getNodeId(), BID_N3D_OUT_SV_Y, pImgBuf_SV_Y);
pBufferHandler->getEnqueBuffer(getNodeId(), BID_N3D_OUT_MASK_M, pImgBuf_MASK_M);
pBufferHandler->getEnqueBuffer(getNodeId(), BID_N3D_OUT_MASK_S, pImgBuf_MASK_S);
pImgBuf_SV_Y->syncCache(eCACHECTRL_FLUSH);
pImgBuf_MV_Y->syncCache(eCACHECTRL_FLUSH);
pImgBuf_MASK_M->syncCache(eCACHECTRL_FLUSH);
pImgBuf_MASK_S->syncCache(eCACHECTRL_FLUSH);
// output buffers
IImageBuffer* pImgBuf_DMP_L = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_DMP_L);
IImageBuffer* pImgBuf_DMP_R = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_DMP_R);
IImageBuffer* pImgBuf_CFM_L = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_CFM_L);
IImageBuffer* pImgBuf_CFM_R = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_CFM_R);
IImageBuffer* pImgBuf_RESPO_L = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_RESPO_L);
IImageBuffer* pImgBuf_RESPO_R = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_RESPO_R);
// read the tuning data from tuning provider
NSIoPipe::DVEConfig dpeConfig;
ENUM_STEREO_SCENARIO scenario = (pRequest->getRequestAttr().isEISOn) ? eSTEREO_SCENARIO_RECORD : eSTEREO_SCENARIO_PREVIEW;
StereoTuningProvider::getDPETuningInfo(&dpeConfig, scenario);
// mask flag: use the tuning provider firstly.
dpeConfig.Dve_Mask_En &= true;
// check the first enque or not
dpeConfig.Dve_Skp_Pre_Dv = (mbFirst) ? true : false;
mbFirst = MFALSE;
// setup IO
DPEInputData input = {pImgBuf_MV_Y, pImgBuf_SV_Y, pImgBuf_MASK_M, pImgBuf_MASK_S,
mLastDMP_L->mImageBuffer.get(), mLastDMP_R->mImageBuffer.get()};
DPEOutputData output = {pImgBuf_DMP_L, pImgBuf_DMP_R, pImgBuf_CFM_L, pImgBuf_CFM_R,
pImgBuf_RESPO_L, pImgBuf_RESPO_R};
setupDPEConfigIO(input, output, dpeConfig)
{
setupDPEConfigIO( DPEInputData input, DPEOutputData output, NSIoPipe::DVEConfig& rDPEConfig )
{
// imgi format: YV12 -> DPE_IMGI_Y_FMT
if(input.pImgBuf_MV_Y->getImgFormat() == eImgFmt_YV12)
{
rDPEConfig.Dve_Imgi_l_Fmt = DPE_IMGI_Y_FMT;
rDPEConfig.Dve_Imgi_r_Fmt = DPE_IMGI_Y_FMT;
}else{/*unsupported format*/return false;}
/*======================================we see function setupDPEBufInfo() firstly ====================================*/
MBOOL DPENode::setupDPEBufInfo(
NSIoPipe::DPEDMAPort dmaPort,
IImageBuffer* pImgBuf,
NSIoPipe::DPEBufInfo& rBufInfo
)
{
// plane 0 address
rBufInfo.memID = pImgBuf->getFD(0);
rBufInfo.dmaport = dmaPort;
rBufInfo.u4BufVA = pImgBuf->getBufVA(0);// Vir Address of pool
rBufInfo.u4BufPA = pImgBuf->getBufPA(0);// Phy Address of pool
rBufInfo.u4BufSize = pImgBuf->getBufSizeInBytes(0);// Per buffer size
rBufInfo.u4Stride = pImgBuf->getBufStridesInBytes(0);// Buffer Stride
return MTRUE;
}
/*====================================================================================================================*/
// setup input enque buffers
if(STEREO_SENSOR_REAR_MAIN_TOP == StereoSettingProvider::getSensorRelativePosition())
{
// Main1 locations: L
setupDPEBufInfo(DMA_DVE_IMGI, input.pImgBuf_MV_Y, rDPEConfig.Dve_Imgi_l);
setupDPEBufInfo(DMA_DVE_IMGI, input.pImgBuf_SV_Y, rDPEConfig.Dve_Imgi_r);
setupDPEBufInfo(DMA_DVE_MASKI, input.pImgBuf_MASK_M, rDPEConfig.Dve_Maski_l);
setupDPEBufInfo(DMA_DVE_MASKI, input.pImgBuf_MASK_S, rDPEConfig.Dve_Maski_r);
}
else
{
// Main1 location: R
setupDPEBufInfo(DMA_DVE_IMGI, input.pImgBuf_SV_Y, rDPEConfig.Dve_Imgi_l);//Input Left View Imgi DMA Port
setupDPEBufInfo(DMA_DVE_IMGI, input.pImgBuf_MV_Y, rDPEConfig.Dve_Imgi_r);//Input Right View Imgi DMA Port
setupDPEBufInfo(DMA_DVE_MASKI, input.pImgBuf_MASK_S, rDPEConfig.Dve_Maski_l);
setupDPEBufInfo(DMA_DVE_MASKI, input.pImgBuf_MASK_M, rDPEConfig.Dve_Maski_r);
}
setupDPEBufInfo(DMA_DVE_DVI, input.pImgBuf_LastDMP_L, rDPEConfig.Dve_Dvi_l);//Input Left View DVI DMA Port (last disparity vector)
setupDPEBufInfo(DMA_DVE_DVI, input.pImgBuf_LastDMP_R, rDPEConfig.Dve_Dvi_r);//Input Right View DVI DMA Port (last disparity vector)
// output
setupDPEBufInfo(DMA_DVE_DVO, output.pImgBuf_DMP_L, rDPEConfig.Dve_Dvo_l);
setupDPEBufInfo(DMA_DVE_DVO, output.pImgBuf_DMP_R, rDPEConfig.Dve_Dvo_r);
setupDPEBufInfo(DMA_DVE_CONFO, output.pImgBuf_CFM_L, rDPEConfig.Dve_Confo_l);
setupDPEBufInfo(DMA_DVE_CONFO, output.pImgBuf_CFM_R, rDPEConfig.Dve_Confo_r);
setupDPEBufInfo(DMA_DVE_RESPO, output.pImgBuf_RESPO_L, rDPEConfig.Dve_Respo_l);
setupDPEBufInfo(DMA_DVE_RESPO, output.pImgBuf_RESPO_R, rDPEConfig.Dve_Respo_r);//o-->out
return MTRUE;
}
}
debugDPEConfig(dpeConfig);
rDPEConfigVec.push_back(dpeConfig);
return MTRUE;
}
}
else
{
//capture
bRet = prepareDPEEnqueConfig_CAP(pRequest, enqueParams.mDVEConfigVec)
{
sp<BaseBufferHandler> pBufferHandler = pRequest->getBufferHandler();
// insert the dynamic data
IImageBuffer *pImgBuf_MV_Y, *pImgBuf_SV_Y;
IImageBuffer *pImgBuf_MASK_M , *pImgBuf_MASK_S;
// input buffer
MBOOL bRet = pBufferHandler->getEnqueBuffer(getNodeId(), BID_N3D_OUT_MV_Y, pImgBuf_MV_Y);
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_N3D_OUT_SV_Y, pImgBuf_SV_Y);
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_N3D_OUT_MASK_M, pImgBuf_MASK_M);
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_N3D_OUT_MASK_S, pImgBuf_MASK_S);
pImgBuf_SV_Y->syncCache(eCACHECTRL_FLUSH);
pImgBuf_MV_Y->syncCache(eCACHECTRL_FLUSH);
pImgBuf_MASK_M->syncCache(eCACHECTRL_FLUSH);
pImgBuf_MASK_S->syncCache(eCACHECTRL_FLUSH);
// last DMP
IImageBuffer* pLastDMP_L = pBufferHandler->requestWorkingBuffer(BID_DPE_INTERNAL_LAST_DMP);
IImageBuffer* pLastDMP_R = pBufferHandler->requestWorkingBuffer(BID_DPE_INTERNAL_LAST_DMP);
memset((void*)pLastDMP_L->getBufVA(0), 0, pLastDMP_L->getBufSizeInBytes(0));
memset((void*)pLastDMP_R->getBufVA(0), 0, pLastDMP_R->getBufSizeInBytes(0));
pLastDMP_L->syncCache(eCACHECTRL_FLUSH);
pLastDMP_R->syncCache(eCACHECTRL_FLUSH);
// output buffers
IImageBuffer* pImgBuf_DMP_L = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_DMP_L);
IImageBuffer* pImgBuf_DMP_R = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_DMP_R);
IImageBuffer* pImgBuf_CFM_L = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_CFM_L);
IImageBuffer* pImgBuf_CFM_R = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_CFM_R);
IImageBuffer* pImgBuf_RESPO_L = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_RESPO_L);
IImageBuffer* pImgBuf_RESPO_R = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_RESPO_R);
MUINT32 DPE_RUN = StereoSettingProvider::getDPECaptureRound();
for(MUINT32 index=0;index<DPE_RUN;index++)
{
NSIoPipe::DVEConfig dpeConfig;
// read the tuning data from tuning provider
StereoTuningProvider::getDPETuningInfo(&dpeConfig, eSTEREO_SCENARIO_CAPTURE);
// mask flag: use the tuning provider firstly.
dpeConfig.Dve_Mask_En &= true;
dpeConfig.Dve_Skp_Pre_Dv = (index == 0) ? true : false;
// setup IO
DPEInputData input = {pImgBuf_MV_Y, pImgBuf_SV_Y, pImgBuf_MASK_M, pImgBuf_MASK_S,
pLastDMP_L, pLastDMP_R};
DPEOutputData output;
// last run
if(index == DPE_RUN-1)
{
output = {pImgBuf_DMP_L, pImgBuf_DMP_R, pImgBuf_CFM_L, pImgBuf_CFM_R,
pImgBuf_RESPO_L, pImgBuf_RESPO_R};
}
else
{
IImageBuffer* pInternalDMP_L = pBufferHandler->requestWorkingBuffer(BID_DPE_INTERNAL_DMP);
IImageBuffer* pInternalDMP_R = pBufferHandler->requestWorkingBuffer(BID_DPE_INTERNAL_DMP);
output = {pInternalDMP_L, pInternalDMP_R, pImgBuf_CFM_L, pImgBuf_CFM_R,
pImgBuf_RESPO_L, pImgBuf_RESPO_R};
// update the last DMP
pLastDMP_L = pInternalDMP_L;
pLastDMP_R = pInternalDMP_R;
}
// setup DPE io
if(!setupDPEConfigIO(input, output, dpeConfig))
{
MY_LOGE("Setup failed!");
return MFALSE;
}
debugDPEConfig(dpeConfig);
rDPEConfigVec.push_back(dpeConfig);
}
}
}
// enque cookie instance
EnqueCookieContainer *pCookieIns = new EnqueCookieContainer(pRequest, this);
enqueParams.mpfnCallback = onDPEEnqueDone;//callback will be called when enque is finished
enqueParams.mpCookie = (void*) pCookieIns;
// start DPE timer
pRequest->mTimer.startDPE();
pRequest->mTimer.startDPEEnque();
// enque start
mpDPEStream->DVEenque(enqueParams);
// queue end
pRequest->mTimer.stopDPEEnque();
// DVE Enque, reqID=0, config time=0 ms
// mind that timer is not stop
return MTRUE;
}
//handleDPEEnqueDone][VSDOF_Profile] 442: +, reqID=0, DPE exec-time=28 msec
DPENode::onDPEEnqueDone(DVEParams& rParams)
{
EnqueCookieContainer* pEnqueCookie = reinterpret_cast<EnqueCookieContainer*>(rParams.mpCookie);
DPENode* pDPENode = reinterpret_cast<DPENode*>(pEnqueCookie->mpNode);
pDPENode->handleDPEEnqueDone(rParams, pEnqueCookie);
}
DPENode::handleDPEEnqueDone(DVEParams& rParams, EnqueCookieContainer* pEnqueCookie)
{
DepthMapRequestPtr pRequest = pEnqueCookie->mRequest;
sp<BaseBufferHandler> pBufferHandler = pRequest->getBufferHandler();
IImageBuffer *pImgBuf_DMP_L, *pImgBuf_DMP_R, *pImgBuf_CFM_L, *pImgBuf_CFM_R;
IImageBuffer *pImgBuf_RESPO_L, *pImgBuf_RESPO_R;
// check flush status
if(mpNodeSignal->getStatus(NodeSignal::STATUS_IN_FLUSH))
goto lbExit;
// stop timer
pRequest->mTimer.stopDPE();
// +, reqID=0, DPE exec-time=28 msec
// get the output buffers and invalidate
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_DPE_OUT_DMP_L, pImgBuf_DMP_L);
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_DPE_OUT_DMP_R, pImgBuf_DMP_R);
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_DPE_OUT_CFM_L, pImgBuf_CFM_L);
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_DPE_OUT_CFM_R, pImgBuf_CFM_R);
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_DPE_OUT_RESPO_L, pImgBuf_RESPO_L);
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_DPE_OUT_RESPO_R, pImgBuf_RESPO_R);
// invalidate
pImgBuf_DMP_L->syncCache(eCACHECTRL_INVALID);
pImgBuf_DMP_R->syncCache(eCACHECTRL_INVALID);
pImgBuf_CFM_L->syncCache(eCACHECTRL_INVALID);
pImgBuf_CFM_R->syncCache(eCACHECTRL_INVALID);
pImgBuf_RESPO_L->syncCache(eCACHECTRL_INVALID);
pImgBuf_RESPO_R->syncCache(eCACHECTRL_INVALID);
// update last DMP, record SmartImageBuffer to avoid release
pBufferHandler->getEnquedSmartBuffer(getNodeId(), BID_DPE_OUT_DMP_L, mLastDMP_L);
pBufferHandler->getEnquedSmartBuffer(getNodeId(), BID_DPE_OUT_DMP_R, mLastDMP_R);
// prepare input for OCC
pBufferHandler->configOutBuffer(getNodeId(), BID_DPE_OUT_DMP_L, eDPETHMAP_PIPE_NODEID_OCC);
pBufferHandler->configOutBuffer(getNodeId(), BID_DPE_OUT_DMP_R, eDPETHMAP_PIPE_NODEID_OCC);
// set ready for DMP output
pRequest->setOutputBufferReady(BID_DPE_OUT_DMP_L);
pRequest->setOutputBufferReady(BID_DPE_OUT_DMP_R);
handleDataAndDump(DPE_OUT_DISPARITY, pRequest);//saveToFile() 2 pictures
// pass MV/SV to OCC
pBufferHandler->configOutBuffer(getNodeId(), BID_N3D_OUT_MV_Y, eDPETHMAP_PIPE_NODEID_OCC);
pBufferHandler->configOutBuffer(getNodeId(), BID_N3D_OUT_SV_Y, eDPETHMAP_PIPE_NODEID_OCC);
// post to OCC node
handleDataAndDump(DPE_TO_OCC_MVSV_DMP_CFM, pRequest);//saveToFile() 4 pictures,but 2 of them are the same as above
lbExit:
// launch onProcessDone
pBufferHandler->onProcessDone(getNodeId());//release resource
delete pEnqueCookie;
// mark on-going-request end
this->decExtThreadDependency();
}
/*****************************************************************************************************************************************/
/*****************************************************************************************************************************************/
DPENode::onInit()
{
}
DPENode::onThreadStart()
{
// init DPEStream
mpDPEStream = NSCam::NSIoPipe::NSDpe::IDpeStream::createInstance("VSDOF_DPE");
mpDPEStream->init();
// init the last DMP
mLastDMP_L = mpDMPBufferPool->request();
mLastDMP_R = mpDMPBufferPool->request();
}
DPENode::onData(DataID data, DepthMapRequestPtr& pRequest)
{
// + : reqId=0
switch(data)
case N3D_TO_DPE_MVSV_MASK:
// + : reqID=0 size=0
// enqueue the request into the queue,the request then will be handled during onThreadLoop()
mJobQueue.enque(pRequest);
break;
default://Unrecongnized DataID=%d
}
DPENode::onThreadLoop()
{
DepthMapRequestPtr pRequest;
//check if the queue ready
waitAllQueue(); //will block until queue ready
//dequeue the request
mJobQueue.deque(pRequest);
// mark on-going-request start
this->incExtThreadDependency();
// threadLoop start, reqID=%d
DVEParams enqueParams;
MBOOL bRet = MFALSE;
// prepare the enque configs
if(pRequest->getRequestAttr().opState == eSTATE_NORMAL)
{
prepareDPEEnqueConfig_PVVR(pRequest, enqueParams.mDVEConfigVec)
{
sp<BaseBufferHandler> pBufferHandler = pRequest->getBufferHandler();
// insert the dynamic data
IImageBuffer *pImgBuf_MV_Y, *pImgBuf_SV_Y;
IImageBuffer *pImgBuf_MASK_M , *pImgBuf_MASK_S;
// input buffer
MBOOL bRet = pBufferHandler->getEnqueBuffer(getNodeId(), BID_N3D_OUT_MV_Y, pImgBuf_MV_Y);
pBufferHandler->getEnqueBuffer(getNodeId(), BID_N3D_OUT_SV_Y, pImgBuf_SV_Y);
pBufferHandler->getEnqueBuffer(getNodeId(), BID_N3D_OUT_MASK_M, pImgBuf_MASK_M);
pBufferHandler->getEnqueBuffer(getNodeId(), BID_N3D_OUT_MASK_S, pImgBuf_MASK_S);
pImgBuf_SV_Y->syncCache(eCACHECTRL_FLUSH);
pImgBuf_MV_Y->syncCache(eCACHECTRL_FLUSH);
pImgBuf_MASK_M->syncCache(eCACHECTRL_FLUSH);
pImgBuf_MASK_S->syncCache(eCACHECTRL_FLUSH);
// output buffers
IImageBuffer* pImgBuf_DMP_L = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_DMP_L);
IImageBuffer* pImgBuf_DMP_R = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_DMP_R);
IImageBuffer* pImgBuf_CFM_L = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_CFM_L);
IImageBuffer* pImgBuf_CFM_R = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_CFM_R);
IImageBuffer* pImgBuf_RESPO_L = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_RESPO_L);
IImageBuffer* pImgBuf_RESPO_R = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_RESPO_R);
// read the tuning data from tuning provider
NSIoPipe::DVEConfig dpeConfig;
ENUM_STEREO_SCENARIO scenario = (pRequest->getRequestAttr().isEISOn) ? eSTEREO_SCENARIO_RECORD : eSTEREO_SCENARIO_PREVIEW;
StereoTuningProvider::getDPETuningInfo(&dpeConfig, scenario);
// mask flag: use the tuning provider firstly.
dpeConfig.Dve_Mask_En &= true;
// check the first enque or not
dpeConfig.Dve_Skp_Pre_Dv = (mbFirst) ? true : false;
mbFirst = MFALSE;
// setup IO
DPEInputData input = {pImgBuf_MV_Y, pImgBuf_SV_Y, pImgBuf_MASK_M, pImgBuf_MASK_S,
mLastDMP_L->mImageBuffer.get(), mLastDMP_R->mImageBuffer.get()};
DPEOutputData output = {pImgBuf_DMP_L, pImgBuf_DMP_R, pImgBuf_CFM_L, pImgBuf_CFM_R,
pImgBuf_RESPO_L, pImgBuf_RESPO_R};
setupDPEConfigIO(input, output, dpeConfig)
{
setupDPEConfigIO( DPEInputData input, DPEOutputData output, NSIoPipe::DVEConfig& rDPEConfig )
{
// imgi format: YV12 -> DPE_IMGI_Y_FMT
if(input.pImgBuf_MV_Y->getImgFormat() == eImgFmt_YV12)
{
rDPEConfig.Dve_Imgi_l_Fmt = DPE_IMGI_Y_FMT;
rDPEConfig.Dve_Imgi_r_Fmt = DPE_IMGI_Y_FMT;
}else{/*unsupported format*/return false;}
/*======================================we see function setupDPEBufInfo() firstly ====================================*/
MBOOL DPENode::setupDPEBufInfo(
NSIoPipe::DPEDMAPort dmaPort,
IImageBuffer* pImgBuf,
NSIoPipe::DPEBufInfo& rBufInfo
)
{
// plane 0 address
rBufInfo.memID = pImgBuf->getFD(0);
rBufInfo.dmaport = dmaPort;
rBufInfo.u4BufVA = pImgBuf->getBufVA(0);// Vir Address of pool
rBufInfo.u4BufPA = pImgBuf->getBufPA(0);// Phy Address of pool
rBufInfo.u4BufSize = pImgBuf->getBufSizeInBytes(0);// Per buffer size
rBufInfo.u4Stride = pImgBuf->getBufStridesInBytes(0);// Buffer Stride
return MTRUE;
}
/*====================================================================================================================*/
// setup input enque buffers
if(STEREO_SENSOR_REAR_MAIN_TOP == StereoSettingProvider::getSensorRelativePosition())
{
// Main1 locations: L
setupDPEBufInfo(DMA_DVE_IMGI, input.pImgBuf_MV_Y, rDPEConfig.Dve_Imgi_l);
setupDPEBufInfo(DMA_DVE_IMGI, input.pImgBuf_SV_Y, rDPEConfig.Dve_Imgi_r);
setupDPEBufInfo(DMA_DVE_MASKI, input.pImgBuf_MASK_M, rDPEConfig.Dve_Maski_l);
setupDPEBufInfo(DMA_DVE_MASKI, input.pImgBuf_MASK_S, rDPEConfig.Dve_Maski_r);
}
else
{
// Main1 location: R
setupDPEBufInfo(DMA_DVE_IMGI, input.pImgBuf_SV_Y, rDPEConfig.Dve_Imgi_l);//Input Left View Imgi DMA Port
setupDPEBufInfo(DMA_DVE_IMGI, input.pImgBuf_MV_Y, rDPEConfig.Dve_Imgi_r);//Input Right View Imgi DMA Port
setupDPEBufInfo(DMA_DVE_MASKI, input.pImgBuf_MASK_S, rDPEConfig.Dve_Maski_l);
setupDPEBufInfo(DMA_DVE_MASKI, input.pImgBuf_MASK_M, rDPEConfig.Dve_Maski_r);
}
setupDPEBufInfo(DMA_DVE_DVI, input.pImgBuf_LastDMP_L, rDPEConfig.Dve_Dvi_l);//Input Left View DVI DMA Port (last disparity vector)
setupDPEBufInfo(DMA_DVE_DVI, input.pImgBuf_LastDMP_R, rDPEConfig.Dve_Dvi_r);//Input Right View DVI DMA Port (last disparity vector)
// output
setupDPEBufInfo(DMA_DVE_DVO, output.pImgBuf_DMP_L, rDPEConfig.Dve_Dvo_l);
setupDPEBufInfo(DMA_DVE_DVO, output.pImgBuf_DMP_R, rDPEConfig.Dve_Dvo_r);
setupDPEBufInfo(DMA_DVE_CONFO, output.pImgBuf_CFM_L, rDPEConfig.Dve_Confo_l);
setupDPEBufInfo(DMA_DVE_CONFO, output.pImgBuf_CFM_R, rDPEConfig.Dve_Confo_r);
setupDPEBufInfo(DMA_DVE_RESPO, output.pImgBuf_RESPO_L, rDPEConfig.Dve_Respo_l);
setupDPEBufInfo(DMA_DVE_RESPO, output.pImgBuf_RESPO_R, rDPEConfig.Dve_Respo_r);//o-->out
return MTRUE;
}
}
debugDPEConfig(dpeConfig);
rDPEConfigVec.push_back(dpeConfig);
return MTRUE;
}
}
else
{
//capture
bRet = prepareDPEEnqueConfig_CAP(pRequest, enqueParams.mDVEConfigVec)
{
sp<BaseBufferHandler> pBufferHandler = pRequest->getBufferHandler();
// insert the dynamic data
IImageBuffer *pImgBuf_MV_Y, *pImgBuf_SV_Y;
IImageBuffer *pImgBuf_MASK_M , *pImgBuf_MASK_S;
// input buffer
MBOOL bRet = pBufferHandler->getEnqueBuffer(getNodeId(), BID_N3D_OUT_MV_Y, pImgBuf_MV_Y);
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_N3D_OUT_SV_Y, pImgBuf_SV_Y);
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_N3D_OUT_MASK_M, pImgBuf_MASK_M);
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_N3D_OUT_MASK_S, pImgBuf_MASK_S);
pImgBuf_SV_Y->syncCache(eCACHECTRL_FLUSH);
pImgBuf_MV_Y->syncCache(eCACHECTRL_FLUSH);
pImgBuf_MASK_M->syncCache(eCACHECTRL_FLUSH);
pImgBuf_MASK_S->syncCache(eCACHECTRL_FLUSH);
// last DMP
IImageBuffer* pLastDMP_L = pBufferHandler->requestWorkingBuffer(BID_DPE_INTERNAL_LAST_DMP);
IImageBuffer* pLastDMP_R = pBufferHandler->requestWorkingBuffer(BID_DPE_INTERNAL_LAST_DMP);
memset((void*)pLastDMP_L->getBufVA(0), 0, pLastDMP_L->getBufSizeInBytes(0));
memset((void*)pLastDMP_R->getBufVA(0), 0, pLastDMP_R->getBufSizeInBytes(0));
pLastDMP_L->syncCache(eCACHECTRL_FLUSH);
pLastDMP_R->syncCache(eCACHECTRL_FLUSH);
// output buffers
IImageBuffer* pImgBuf_DMP_L = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_DMP_L);
IImageBuffer* pImgBuf_DMP_R = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_DMP_R);
IImageBuffer* pImgBuf_CFM_L = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_CFM_L);
IImageBuffer* pImgBuf_CFM_R = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_CFM_R);
IImageBuffer* pImgBuf_RESPO_L = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_RESPO_L);
IImageBuffer* pImgBuf_RESPO_R = pBufferHandler->requestBuffer(getNodeId(), BID_DPE_OUT_RESPO_R);
MUINT32 DPE_RUN = StereoSettingProvider::getDPECaptureRound();
for(MUINT32 index=0;index<DPE_RUN;index++)
{
NSIoPipe::DVEConfig dpeConfig;
// read the tuning data from tuning provider
StereoTuningProvider::getDPETuningInfo(&dpeConfig, eSTEREO_SCENARIO_CAPTURE);
// mask flag: use the tuning provider firstly.
dpeConfig.Dve_Mask_En &= true;
dpeConfig.Dve_Skp_Pre_Dv = (index == 0) ? true : false;
// setup IO
DPEInputData input = {pImgBuf_MV_Y, pImgBuf_SV_Y, pImgBuf_MASK_M, pImgBuf_MASK_S,
pLastDMP_L, pLastDMP_R};
DPEOutputData output;
// last run
if(index == DPE_RUN-1)
{
output = {pImgBuf_DMP_L, pImgBuf_DMP_R, pImgBuf_CFM_L, pImgBuf_CFM_R,
pImgBuf_RESPO_L, pImgBuf_RESPO_R};
}
else
{
IImageBuffer* pInternalDMP_L = pBufferHandler->requestWorkingBuffer(BID_DPE_INTERNAL_DMP);
IImageBuffer* pInternalDMP_R = pBufferHandler->requestWorkingBuffer(BID_DPE_INTERNAL_DMP);
output = {pInternalDMP_L, pInternalDMP_R, pImgBuf_CFM_L, pImgBuf_CFM_R,
pImgBuf_RESPO_L, pImgBuf_RESPO_R};
// update the last DMP
pLastDMP_L = pInternalDMP_L;
pLastDMP_R = pInternalDMP_R;
}
// setup DPE io
if(!setupDPEConfigIO(input, output, dpeConfig))
{
MY_LOGE("Setup failed!");
return MFALSE;
}
debugDPEConfig(dpeConfig);
rDPEConfigVec.push_back(dpeConfig);
}
}
}
// enque cookie instance
EnqueCookieContainer *pCookieIns = new EnqueCookieContainer(pRequest, this);
enqueParams.mpfnCallback = onDPEEnqueDone;//callback will be called when enque is finished
enqueParams.mpCookie = (void*) pCookieIns;
// start DPE timer
pRequest->mTimer.startDPE();
pRequest->mTimer.startDPEEnque();
// enque start
mpDPEStream->DVEenque(enqueParams);
// queue end
pRequest->mTimer.stopDPEEnque();
// DVE Enque, reqID=0, config time=0 ms
// mind that timer is not stop
return MTRUE;
}
//handleDPEEnqueDone][VSDOF_Profile] 442: +, reqID=0, DPE exec-time=28 msec
DPENode::onDPEEnqueDone(DVEParams& rParams)
{
EnqueCookieContainer* pEnqueCookie = reinterpret_cast<EnqueCookieContainer*>(rParams.mpCookie);
DPENode* pDPENode = reinterpret_cast<DPENode*>(pEnqueCookie->mpNode);
pDPENode->handleDPEEnqueDone(rParams, pEnqueCookie);
}
DPENode::handleDPEEnqueDone(DVEParams& rParams, EnqueCookieContainer* pEnqueCookie)
{
DepthMapRequestPtr pRequest = pEnqueCookie->mRequest;
sp<BaseBufferHandler> pBufferHandler = pRequest->getBufferHandler();
IImageBuffer *pImgBuf_DMP_L, *pImgBuf_DMP_R, *pImgBuf_CFM_L, *pImgBuf_CFM_R;
IImageBuffer *pImgBuf_RESPO_L, *pImgBuf_RESPO_R;
// check flush status
if(mpNodeSignal->getStatus(NodeSignal::STATUS_IN_FLUSH))
goto lbExit;
// stop timer
pRequest->mTimer.stopDPE();
// +, reqID=0, DPE exec-time=28 msec
// get the output buffers and invalidate
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_DPE_OUT_DMP_L, pImgBuf_DMP_L);
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_DPE_OUT_DMP_R, pImgBuf_DMP_R);
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_DPE_OUT_CFM_L, pImgBuf_CFM_L);
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_DPE_OUT_CFM_R, pImgBuf_CFM_R);
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_DPE_OUT_RESPO_L, pImgBuf_RESPO_L);
bRet &= pBufferHandler->getEnqueBuffer(getNodeId(), BID_DPE_OUT_RESPO_R, pImgBuf_RESPO_R);
// invalidate
pImgBuf_DMP_L->syncCache(eCACHECTRL_INVALID);
pImgBuf_DMP_R->syncCache(eCACHECTRL_INVALID);
pImgBuf_CFM_L->syncCache(eCACHECTRL_INVALID);
pImgBuf_CFM_R->syncCache(eCACHECTRL_INVALID);
pImgBuf_RESPO_L->syncCache(eCACHECTRL_INVALID);
pImgBuf_RESPO_R->syncCache(eCACHECTRL_INVALID);
// update last DMP, record SmartImageBuffer to avoid release
pBufferHandler->getEnquedSmartBuffer(getNodeId(), BID_DPE_OUT_DMP_L, mLastDMP_L);
pBufferHandler->getEnquedSmartBuffer(getNodeId(), BID_DPE_OUT_DMP_R, mLastDMP_R);
// prepare input for OCC
pBufferHandler->configOutBuffer(getNodeId(), BID_DPE_OUT_DMP_L, eDPETHMAP_PIPE_NODEID_OCC);
pBufferHandler->configOutBuffer(getNodeId(), BID_DPE_OUT_DMP_R, eDPETHMAP_PIPE_NODEID_OCC);
// set ready for DMP output
pRequest->setOutputBufferReady(BID_DPE_OUT_DMP_L);
pRequest->setOutputBufferReady(BID_DPE_OUT_DMP_R);
handleDataAndDump(DPE_OUT_DISPARITY, pRequest);//saveToFile() 2 pictures
// pass MV/SV to OCC
pBufferHandler->configOutBuffer(getNodeId(), BID_N3D_OUT_MV_Y, eDPETHMAP_PIPE_NODEID_OCC);
pBufferHandler->configOutBuffer(getNodeId(), BID_N3D_OUT_SV_Y, eDPETHMAP_PIPE_NODEID_OCC);
// post to OCC node
handleDataAndDump(DPE_TO_OCC_MVSV_DMP_CFM, pRequest);//saveToFile() 4 pictures,but 2 of them are the same as above
lbExit:
// launch onProcessDone
pBufferHandler->onProcessDone(getNodeId());//release resource
delete pEnqueCookie;
// mark on-going-request end
this->decExtThreadDependency();
}
/*****************************************************************************************************************************************/