Int32 AlgLink_algProcessData(AlgLink_Obj * pObj) { UInt32 frameId; System_LinkInQueParams *pInQueParams; FVID2_Frame *pFrame; FVID2_FrameList frameList; pInQueParams = &pObj->createArgs.inQueParams; System_getLinksFullFrames(pInQueParams->prevLinkId, pInQueParams->prevLinkQueId, &frameList); if (frameList.numFrames) { /* SCD should be done first as it requires to operate on raw YUV */ if (pObj->createArgs.enableSCDAlg) { AlgLink_ScdalgProcessData(&pObj->scdAlg, &frameList, &pObj->outObj[0].bufOutQue); #if 0 if (status == FVID2_SOK) { /* Send-out the output bitbuffer */ System_sendLinkCmd(pObj->createArgs.outQueParams[ALG_LINK_SCD_OUT_QUE].nextLink, SYSTEM_CMD_NEW_DATA); } #endif } for(frameId=0; frameId<frameList.numFrames; frameId++) { pFrame = frameList.frames[frameId]; if(pFrame->channelNum >= pObj->inQueInfo.numCh) continue; // do SW OSD if (pObj->createArgs.enableOSDAlg) { AlgLink_OsdalgProcessFrame(&pObj->osdAlg, pFrame); } } System_putLinksEmptyFrames(pInQueParams->prevLinkId, pInQueParams->prevLinkQueId, &frameList); } return FVID2_SOK; }
Int32 IpcOutM3Link_processFrames(IpcOutM3Link_Obj * pObj) { System_LinkInQueParams *pInQueParams; FVID2_FrameList frameList; FVID2_Frame *pFrame; SystemIpcM3_ListElem *pListElem; Int32 status; Int32 frameId; IpcOutM3Link_ChObj *pChObj; pInQueParams = &pObj->createArgs.inQueParams; System_getLinksFullFrames(pInQueParams->prevLinkId, pInQueParams->prevLinkQueId, &frameList); pObj->freeFrameList.numFrames = 0; if (frameList.numFrames) { #ifdef SYSTEM_DEBUG_IPC_RT Vps_printf(" %d: IPC_OUT_M3 : Received %d frames !!!\n", Utils_getCurTimeInMsec(), frameList.numFrames); #endif pObj->totalFrameCount += frameList.numFrames; for (frameId = 0; frameId < frameList.numFrames; frameId++) { Bool doFrameDrop; pFrame = frameList.frames[frameId]; pChObj = &pObj->chObj[pFrame->channelNum]; pChObj->inFrameRecvCount++; doFrameDrop = Utils_doSkipFrame(&(pChObj->frameSkipCtx)); /* frame skipped due to user setting */ if(doFrameDrop) { pChObj->inFrameUserSkipCount++; pObj->freeFrameList.frames[pObj->freeFrameList.numFrames] = pFrame; pObj->freeFrameList.numFrames++; UTILS_assert(pObj->freeFrameList.numFrames <= FVID2_MAX_FVID_FRAME_PTR); continue;; } status = Utils_queGet(&pObj->listElemQue, (Ptr *) & pListElem, 1, BIOS_NO_WAIT); if (status != FVID2_SOK) { /* normally this condition should not happen, if it happens * return the frame back to its generator */ #if 0 Vps_printf(" IPC_OUT: Dropping frame\n"); #endif pObj->freeFrameList.frames[pObj->freeFrameList.numFrames] = pFrame; pObj->freeFrameList.numFrames++; UTILS_assert(pObj->freeFrameList.numFrames <= FVID2_MAX_FVID_FRAME_PTR); pChObj->inFrameUserSkipCount++; continue; } pListElem->pFrame = pFrame; /* no need to do cache ops since this is inter-M3 list */ status = ListMP_putTail(pObj->listMPOutHndl, &pListElem->listElem); UTILS_assert(status == ListMP_S_SUCCESS); pChObj->inFrameProcessCount++; } if (pObj->freeFrameList.numFrames) { System_putLinksEmptyFrames(pInQueParams->prevLinkId, pInQueParams->prevLinkQueId, &pObj->freeFrameList); } if (pObj->createArgs.notifyNextLink) { UTILS_assert(pObj->createArgs.numOutQue == 1); System_ipcSendNotify(pObj->createArgs.outQueParams[0].nextLink); } if (TRUE == pObj->createArgs.noNotifyMode) { if (FALSE == pObj->prd.clkStarted) { IpcOutM3Link_startPrdObj(pObj, IPC_M3OUT_LINK_DONE_PERIOD_MS, FALSE); } } } return FVID2_SOK; }
Int32 DupLink_drvProcessFrames(DupLink_Obj * pObj) { UInt32 frameId, outId; FVID2_Frame *pFrame, *pOrgFrame; System_FrameInfo *pFrameInfo, *pOrgFrameInfo; Int32 status; DupLink_CreateParams *pCreateArgs; pCreateArgs = &pObj->createArgs; System_getLinksFullFrames(pCreateArgs->inQueParams.prevLinkId, pCreateArgs->inQueParams.prevLinkQueId, &pObj->inFrameList); if (pObj->inFrameList.numFrames) { pObj->getFrameCount += pObj->inFrameList.numFrames; for (outId = 0; outId < pCreateArgs->numOutQue; outId++) { pObj->outFrameList[outId].numFrames = 0; } for (frameId = 0; frameId < pObj->inFrameList.numFrames; frameId++) { pOrgFrame = pObj->inFrameList.frames[frameId]; if (pOrgFrame == NULL) continue; pOrgFrameInfo = (System_FrameInfo *) pOrgFrame->appData; UTILS_assert(pOrgFrameInfo != NULL); pOrgFrameInfo->dupCount = pCreateArgs->numOutQue; for (outId = 0; outId < pCreateArgs->numOutQue; outId++) { status = Utils_bufGetEmptyFrame(&pObj->outFrameQue[outId], &pFrame, BIOS_NO_WAIT); UTILS_assert(status == FVID2_SOK); UTILS_assert(pFrame != NULL); pFrameInfo = (System_FrameInfo *) pFrame->appData; UTILS_assert(pFrameInfo != NULL); memcpy(pFrame, pOrgFrame, sizeof(*pOrgFrame)); memcpy(pFrameInfo, pOrgFrameInfo, sizeof(*pOrgFrameInfo)); pFrame->appData = pFrameInfo; pFrameInfo->pDupOrgFrame = pOrgFrame; pObj->outFrameList[outId].frames[pObj->outFrameList[outId]. numFrames] = pFrame; pObj->outFrameList[outId].numFrames++; } } for (outId = 0; outId < pCreateArgs->numOutQue; outId++) { status = Utils_bufPutFull(&pObj->outFrameQue[outId], &pObj->outFrameList[outId]); UTILS_assert(status == FVID2_SOK); if (pCreateArgs->notifyNextLink) { System_sendLinkCmd(pCreateArgs->outQueParams[outId].nextLink, SYSTEM_CMD_NEW_DATA); } } } return FVID2_SOK; }
/* =================================================================== * @func HelloWorldLink_algProcessData * * @desc Process upon the input frame received from previous link * At this place, make a call to algorithm process call * * @modif This function modifies the following structures * * @inputs This function takes the following inputs * <HelloWorldLink_Obj> * Object to hello world link * * @outputs <argument name> * Description of usage * * @return Status of process call * ================================================================== */ Int32 HelloWorldLink_processData(HelloWorldLink_Obj * pObj) { UInt32 frameId; System_LinkInQueParams *pInQueParams; FVID2_Frame *pFrame; FVID2_FrameList frameList; Bitstream_Buf *pOutBuf; Utils_BitBufHndl *bufOutQue; Int32 status; System_FrameInfo *pInFrameInfo; Bitstream_BufList outBitBufList; Bitstream_BufList tempBitBufList; HELLOWORLDALG_Result *pHelloWorldResult = NULL; Uint8* pBufferStart; UInt8 *pBuffer; int i,j; UInt8 *y0pixel,*y1pixel,*upixel,*vpixel; status = FVID2_EFAIL; pInQueParams = &pObj->createArgs.inQueParams; bufOutQue = &pObj->outObj[0].bufOutQue; outBitBufList.numBufs=0; /*************************************************************************/ /* Get input frames from previous link output queue */ /*************************************************************************/ System_getLinksFullFrames(pInQueParams->prevLinkId, pInQueParams->prevLinkQueId, &frameList); /*************************************************************************/ /* If input frame received from queue, get the output buffer from out */ /* queue and process the frame */ /*************************************************************************/ if (frameList.numFrames) { Vps_printf(" %d frameList.numFrames:%d !!!\n", Utils_getCurTimeInMsec(),frameList.numFrames); //pObj->totalFrameCount += frameList.numFrames; /*********************************************************************/ /* Get the outout buffer for each input buffer and process the frame */ /* */ /*********************************************************************/ for(frameId=0; frameId< frameList.numFrames; frameId++) { Bool doFrameDrop = FALSE; pFrame = frameList.frames[frameId]; //pChObj = &pObj->chObj[chIdx]; //pChObj->inFrameRecvCount++; /*********************************************************************/ /* If current frame needs to be processed, get the output buffer */ /* from output queue */ /*********************************************************************/ if(pObj->createArgs.createOutBuf1) { pOutBuf = NULL; // Vps_printf(" bufOutQue->fullQue.count :%d \r\n",bufOutQue->empytQue[0].count); status = Utils_bitbufGetEmptyBuf(bufOutQue, &pOutBuf, 0, //pObj->outObj.ch2poolMap[chIdx], /*Need to change later.*/ BIOS_NO_WAIT); // Vps_printf(" bufOutQue->fullQue.count :%d \r\n",bufOutQue->emptyQue[0].count); if(!((status == FVID2_SOK) && (pOutBuf))) { doFrameDrop = TRUE; } /*********************************************************************/ /* Captured YUV buffers time stamp is passed by all links to next */ /* buffers bu copying the input buffer times stamp to it's output */ /* buffer. This is used for benchmarking system latency. */ /*********************************************************************/ pInFrameInfo = (System_FrameInfo *) pFrame->appData; pOutBuf->lowerTimeStamp = (UInt32)(pInFrameInfo->ts64 & 0xFFFFFFFF); pOutBuf->upperTimeStamp = (UInt32)(pInFrameInfo->ts64 >> 32); pOutBuf->channelNum = pFrame->channelNum; //pOutBuf->fillLength = ; //pOutBuf->frameWidth = ; //pOutBuf->frameHeight = ; pHelloWorldResult = (HELLOWORLDALG_Result *) pOutBuf->addr; } /*********************************************************************/ /* Now input and output buffers available and this frame need not be */ /* skipped, make a call to the algorithm process call and process the*/ /* frame. */ /*********************************************************************/ if(doFrameDrop == FALSE) { /*********************************************************************/ /* Pointer to Luma buffer for processing. */ /*********************************************************************/ //pObj->chParams[chIdx].curFrame = pFrame->addr[0][0]; pInFrameInfo = (System_FrameInfo *) pFrame->appData; //curTime = Utils_getCurTimeInMsec(); // Vps_printf("width:%d ,height: %d \r\n",pInFrameInfo->rtChInfo.width,pInFrameInfo->rtChInfo.height); pBufferStart=pFrame->addr[0][0]; for(i=0;i<pInFrameInfo->rtChInfo.height;i++){ pBuffer=pBufferStart+(i*pInFrameInfo->rtChInfo.width*2); for(j=0;j<pInFrameInfo->rtChInfo.width/2;j++){ y0pixel=pBuffer; y1pixel=pBuffer+2; upixel=pBuffer+1; vpixel=pBuffer+3; if(i==1&&j<5) // Vps_printf("y0pixel: %d ,upixel: %d ,y1pixel: %d ,vpixel: %d \r\n",*y0pixel,*upixel,*y1pixel,*vpixel); *upixel=0; *vpixel=0; pBuffer+=4; //if(i==1&&j<5) // Vps_printf("y0pixel: %d ,upixel: %d ,y1pixel: %d ,vpixel: %d \r\n",*y0pixel,*upixel,*y1pixel,*vpixel); } } // Vps_printf("pbufferstart:%d ,pBuffer:%d ,y0pixel:%d ,vpixel:%d \r\n",pBufferStart,pBuffer,y0pixel,vpixel); /*********************************************************************/ /* Make a call to algorithm process call here */ /*********************************************************************/ HELLOWORLDALG_TI_process(pObj->algHndl, 0, pHelloWorldResult);//HelloWorldLink_algProcess(); /*********************************************************************/ /* Benchmark frame process time */ /*********************************************************************/ //pChObj->inFrameProcessTime += (Utils_getCurTimeInMsec() - curTime); //pChObj->inFrameProcessCount++; outBitBufList.bufs[outBitBufList.numBufs] = pOutBuf; outBitBufList.numBufs++; tempBitBufList.numBufs=outBitBufList.numBufs; } else { //pChObj->inFrameUserSkipCount++; } }
Int32 DisplayLink_drvProcessData(DisplayLink_Obj * pObj) { FVID2_FrameList frameList; FVID2_FrameList freeFrameList; FVID2_FrameList displayFrameList; UInt32 freeFrameNum, elaspedTime; System_LinkInQueParams *pInQueParams; FVID2_Frame *pFrame; Int32 status; UInt32 latency; Int i; UInt32 frameIdx; elaspedTime = Utils_getCurTimeInMsec() - pObj->startTime; if ((elaspedTime - pObj->prevTime) > 24 * 60 * 60 * 1000) { DisplayLink_drvPrintRtStatus(pObj, elaspedTime); pObj->prevTime = elaspedTime; } if(pObj->displayInstId==0) { System_displayUnderflowCheck(FALSE); } do { UInt32 freeQueueId; /* dequeue all completed frames */ status = DisplayLink_drvDeQueue(pObj,&freeFrameList, &freeQueueId); if (freeFrameList.numFrames) { pObj->inFramePutCount += freeFrameList.numFrames; UTILS_assert(freeQueueId < pObj->createArgs.numInputQueues); pInQueParams = &pObj->createArgs.inQueParams[freeQueueId]; System_putLinksEmptyFrames(pInQueParams->prevLinkId, pInQueParams->prevLinkQueId, &freeFrameList); } } while (status == FVID2_SOK); /* Free frames queued in inactive queues immediately */ for (i = 0; i < pObj->createArgs.numInputQueues;i++) { if (i != pObj->curActiveQueue) { frameList.numFrames = 0; pInQueParams = &pObj->createArgs.inQueParams[i]; System_getLinksFullFrames(pInQueParams->prevLinkId, pInQueParams->prevLinkQueId, &frameList); if (frameList.numFrames) { pObj->inFrameGetCount += frameList.numFrames; pObj->inFramePutCount += frameList.numFrames; System_putLinksEmptyFrames(pInQueParams->prevLinkId, pInQueParams->prevLinkQueId, &frameList); } } } UTILS_assert(pObj->curActiveQueue < pObj->createArgs.numInputQueues); pInQueParams = &pObj->createArgs.inQueParams[pObj->curActiveQueue]; /* que frames if any */ System_getLinksFullFrames(pInQueParams->prevLinkId, pInQueParams->prevLinkQueId, &frameList); pObj->inFrameGetCount += frameList.numFrames; freeFrameNum = 0; DisplayLink_drvLock(pObj); frameIdx = 0; while((pObj->maxQueueCount) && (frameIdx < frameList.numFrames)) { pFrame = frameList.frames[frameIdx]; frameIdx++; UTILS_assert(pFrame != NULL); if (pFrame->channelNum == pObj->curDisplayChannelNum) { Bool frameReject; UInt32 pitch0,pitch1; pitch0 = pObj->displayFormat.pitch[0]; pitch1 = pObj->displayFormat.pitch[1]; if (DisplayLink_drvDoInputPitchDoubling(pObj)) { pitch0 /= 2; pitch1 /= 2; } UTILS_assert(DISPLAY_LINK_BLANK_FRAME_CHANNEL_NUM != pFrame->channelNum); pFrame->addr[1][0] = (UInt8 *) pFrame->addr[0][0] + pitch0; pFrame->addr[1][1] = (UInt8 *) pFrame->addr[0][1] + pitch1; #ifdef SYSTEM_DEBUG_DISPLAY_RT Vps_printf(" %d: DISPLAY: Queue %d frames\n", Utils_getCurTimeInMsec(), displayFrameList.numFrames); #endif latency = Utils_getCurTimeInMsec() - pFrame->timeStamp; if(latency>pObj->maxLatency) pObj->maxLatency = latency; if(latency<pObj->minLatency) pObj->minLatency = latency; /* queue frame for display */ displayFrameList.numFrames = 0; DisplayLink_drvSetFrameInfo(pObj, &pFrame, &frameReject); if (pFrame) { if (frameReject) { UTILS_assert(freeFrameNum < UTILS_ARRAYSIZE(freeFrameList.frames)); /* error in queing to display, instead of asserting release the frame and continue */ freeFrameList.frames[freeFrameNum] = pFrame; freeFrameNum++; } else { displayFrameList.frames[displayFrameList.numFrames] = pFrame; displayFrameList.numFrames++; displayFrameList.perListCfg = NULL; DisplayLink_drvHandleDynamicPitchChange(pObj,&displayFrameList); DisplayLink_validateFrameList(pObj, &displayFrameList); pObj->queueCount += displayFrameList.numFrames; pObj->numBufsInDriver++; status = FVID2_queue(pObj->displayHndl, &displayFrameList, 0); pObj->maxQueueCount--; if(status!=FVID2_SOK) { Vps_rprintf(" %d: DISPLAY (%d): Queue to driver failed !!!\n", Utils_getCurTimeInMsec(), pObj->tskId); UTILS_assert(freeFrameNum < UTILS_ARRAYSIZE(freeFrameList.frames)); /* error in queing to display, instead of asserting release the frame and continue */ freeFrameList.frames[freeFrameNum] = pFrame; freeFrameNum++; DisplayLink_drvFreeFrameInfo(pObj, &displayFrameList); } } } } else { UTILS_assert(freeFrameNum < UTILS_ARRAYSIZE(freeFrameList.frames)); freeFrameList.frames[freeFrameNum] = pFrame; freeFrameNum++; } } DisplayLink_drvUnlock(pObj); for (i = frameIdx; i < frameList.numFrames;i++) { UTILS_assert(freeFrameNum < UTILS_ARRAYSIZE(freeFrameList.frames)); freeFrameList.frames[freeFrameNum] = frameList.frames[i]; freeFrameNum++; } if (freeFrameNum) { freeFrameList.numFrames = freeFrameNum; pObj->inFramePutCount += freeFrameList.numFrames; System_putLinksEmptyFrames(pInQueParams->prevLinkId, pInQueParams->prevLinkQueId, &freeFrameList); } return FVID2_SOK; }