static Void VcapVencVdecVdis_ipcBitsQueEmptyBitBufs(VcapVencVdecVdis_res resolution, OSA_QueHndl       *emptyQue)
{
    VCODEC_BITSBUF_LIST_S emptyBufList;
    VCODEC_BITSBUF_S *pBuf;
    VDEC_BUF_REQUEST_S reqInfo;
    Int i;
    Int status;
    UInt32 bitBufSize;

    bitBufSize = MCFW_IPCBITS_GET_BITBUF_SIZE(resolution.width,
                                                resolution.height);
    if (bitBufSize <=0 )
        return;

    emptyBufList.numBufs = 0;
    reqInfo.numBufs = VCODEC_BITSBUF_MAX;
    reqInfo.reqType = VDEC_BUFREQTYPE_BUFSIZE;
    for (i = 0; i < VCODEC_BITSBUF_MAX; i++)
    {
        reqInfo.u[i].minBufSize = bitBufSize;
    }
    Vdec_requestBitstreamBuffer(&reqInfo, &emptyBufList, 0);
    for (i = 0; i < emptyBufList.numBufs; i++)
    {
        pBuf = VcapVencVdecVdis_FreeBitBufAlloc();
        OSA_assert(pBuf != NULL);
        *pBuf = emptyBufList.bitsBuf[i];
        OSA_assert(pBuf->bufSize >= bitBufSize );

        status = OSA_quePut(emptyQue,(Int32)pBuf,OSA_TIMEOUT_NONE);
        OSA_assert(status == 0);
    }
}
static Void VcapVencVdecVdis_ipcBitsWriteBitsToFile (FILE  * fpHdr[MCFW_IPC_BITS_MAX_NUM_CHANNELS],
        FILE  * fpBuf[MCFW_IPC_BITS_MAX_NUM_CHANNELS],
        FILE  *fpMvBuf[MCFW_IPC_BITS_MAX_NUM_CHANNELS],
        VCODEC_BITSBUF_LIST_S *bufList,
        UInt32 maxFileSize,
        UInt32 fwriteEnableChannelBitmask,
        Bool wrapOccuredHdr[],
        Bool wrapOccuredBuf[])
{
    Int i;
    VCODEC_BITSBUF_S *pBuf;
    size_t write_cnt;
    static UInt32 maxMvFrameCnt;

    for (i = 0; i < bufList->numBufs; i++)
    {
        UInt32 fileIdx;

        pBuf = &bufList->bitsBuf[i];
        OSA_assert(pBuf->chnId < MCFW_IPC_BITS_MAX_NUM_CHANNELS);
        fileIdx = pBuf->chnId;
        if (fwriteEnableChannelBitmask & (1 << fileIdx) || (fileIdx > 31 && (fwriteEnableChannelBitmask & (1 << (fileIdx-32)))))
        {
            if (FALSE == wrapOccuredBuf[fileIdx])
            {
                wrapOccuredBuf[fileIdx] =
                    VcapVencVdecVdis_ipcBitsWriteWrap(fpBuf[fileIdx],pBuf->filledBufSize, maxFileSize);
            }

            if (FALSE == wrapOccuredBuf[fileIdx])
            {
                write_cnt = fwrite(pBuf->bufVirtAddr,sizeof(char),pBuf->filledBufSize,fpBuf[fileIdx]);
                OSA_assert(write_cnt == pBuf->filledBufSize);
                /*The below check for max frames as 500, means write mv data only for first n frame*/
                if(pBuf->mvDataFilledSize != 0 && maxMvFrameCnt <= 500)
                {
                    maxMvFrameCnt++;
                    write_cnt = fwrite(pBuf->bufVirtAddr + pBuf->mvDataOffset,
                                       sizeof(char), pBuf->mvDataFilledSize,fpMvBuf[fileIdx]);

                    OSA_assert(write_cnt == pBuf->mvDataFilledSize);
                }
            }
            if (FALSE == wrapOccuredHdr[fileIdx])
            {
                wrapOccuredHdr[fileIdx] =
                    VcapVencVdecVdis_ipcBitsWriteWrap(fpHdr[fileIdx],sizeof(*pBuf),maxFileSize);
            }
            if (FALSE == wrapOccuredHdr[fileIdx])
            {
                write_cnt = fwrite(pBuf,sizeof(*pBuf),1,fpHdr[fileIdx]);
                OSA_assert(write_cnt == 1);
            }
        }
    }
}
Esempio n. 3
0
int VIDEO_encryptTskRun(int streamId)
{
  int status=OSA_EFAIL, inBufId, outBufId;
  OSA_BufInfo *pInBufInfo, *pOutBufInfo;
  VIDEO_BufHeader *pInBufHeader, *pOutBufHeader;
  
  pInBufInfo = AVSERVER_bufGetFull( VIDEO_TSK_ENCRYPT, streamId, &inBufId, OSA_TIMEOUT_FOREVER);
  
  OSA_assert(pInBufInfo!=NULL);
  
  if(pInBufInfo!=NULL) {
  
    pOutBufInfo = AVSERVER_bufGetEmpty( VIDEO_TSK_ENCRYPT, streamId, &outBufId, OSA_TIMEOUT_FOREVER);  
    
    OSA_assert(pOutBufInfo!=NULL);    

    #ifdef AVSERVER_DEBUG_VIDEO_ENCRYPT_THR
      #ifdef AVSERVER_DEBUG_RUNNING
      OSA_printf(" ENCRYPT: Stream %d InBuf %d OutBuf %d\n", streamId, inBufId, outBufId);
      #endif
    #endif
  
    if(pOutBufInfo!=NULL) {
  
      pInBufHeader  = (VIDEO_BufHeader*)pInBufInfo->virtAddr;
      pOutBufHeader = (VIDEO_BufHeader*)pOutBufInfo->virtAddr;
      
      OSA_assert(pInBufHeader!=NULL);
      OSA_assert(pOutBufHeader!=NULL);                          

      if(pInBufHeader->encFrameSize > 0) {
      
        status = ALG_encryptRun(gVIDEO_ctrl.encodeStream[streamId].algEncryptHndl, 
                                pInBufInfo->virtAddr, 
                                pOutBufInfo->virtAddr,
                                pInBufHeader->encFrameSize
                              );
        if(status!=OSA_SOK) {
          OSA_ERROR("ALG_encryptRun(%d)\n", streamId);
          pOutBufHeader->encFrameSize = 0;          
        }
      }      

      memcpy(pOutBufHeader, pInBufHeader, sizeof(*pOutBufHeader));
      
      AVSERVER_bufPutFull( VIDEO_TSK_ENCRYPT, streamId, outBufId);          
    }

    AVSERVER_bufPutEmpty( VIDEO_TSK_ENCRYPT, streamId, inBufId);  
  }
  
  return status;
}
Esempio n. 4
0
Int32 Vsys_freeBuf(UInt32 srRegId, UInt8 *virtAddr, UInt32 bufSize)
{
    IHeap_Handle heapHndl;

    heapHndl = SharedRegion_getHeap(srRegId);
    OSA_assert(heapHndl != NULL);

    OSA_assert(virtAddr != NULL);

    Memory_free(heapHndl, virtAddr, bufSize);

    return 0;
}
static Void VcapVencVdecVdis_ipcBitsProcessFullBufs(VcapVencVdecVdis_IpcBitsCtrlThrObj *thrObj,
        VcapVencVdecVdis_IpcBitsCtrlFileObj *fObj)
{
    VCODEC_BITSBUF_LIST_S fullBufList;
    VCODEC_BITSBUF_S *pFullBuf;
    VCODEC_BITSBUF_S *pEmptyBuf;
    Int i,status;
    static Int printStatsInterval = 0;

#ifdef IPC_BITS_DEBUG
    if ((printStatsInterval % MCFW_IPCBITS_INFO_PRINT_INTERVAL) == 0)
    {
        OSA_printf("MCFW_IPCBITS:%s:INFO: periodic print..",__func__);
    }
#endif
    printStatsInterval++;

    Venc_getBitstreamBuffer(&fullBufList, 0);

    for (i = 0; i < fullBufList.numBufs; i++)
    {
        VcapVencVdecVdis_updateStatistics(&fullBufList.bitsBuf[i]);

        if (fullBufList.bitsBuf[i].chnId < Venc_getPrimaryChannels())
        {
            status = OSA_queGet(&thrObj->bufQFreeBufs,(Int32 *)(&pEmptyBuf),
                                OSA_TIMEOUT_FOREVER);
            OSA_assert(status == 0);
            pFullBuf = &fullBufList.bitsBuf[i];
            VcapVencVdecVdis_ipcBitsCopyBitBufInfo(pEmptyBuf,pFullBuf);
            VcapVencVdecVdis_ipcBitsCopyBitBufDataMem2Mem(pEmptyBuf,pFullBuf);
            status = OSA_quePut(&thrObj->bufQFullBufs,
                                (Int32)pEmptyBuf,OSA_TIMEOUT_NONE);
            OSA_assert(status == 0);
        }
    }
    if (fObj->enableFWrite)
    {
        VcapVencVdecVdis_ipcBitsWriteBitsToFile(fObj->fpWrHdr,
                                                fObj->fpWrData,
                                                fObj->fpWrMvData,
                                                &fullBufList,
                                                fObj->maxFileSize,
                                                fObj->fwriteEnableBitMask,
                                                fObj->wrapOccuredHdr,
                                                fObj->wrapOccuredBuf);

    }
    Venc_releaseBitstreamBuffer(&fullBufList);
}
Esempio n. 6
0
Int32 Vsys_allocBuf(UInt32 srRegId, UInt32 bufSize, UInt32 bufAlign, Vsys_AllocBufInfo *bufInfo)
{
    IHeap_Handle heapHndl;

    heapHndl = SharedRegion_getHeap(srRegId);
    OSA_assert(heapHndl != NULL);

    bufInfo->virtAddr = NULL;
    bufInfo->physAddr = NULL;
    bufInfo->srPtr    = 0;

    bufInfo->virtAddr = Memory_alloc(heapHndl, bufSize, bufAlign, NULL);

    if(bufInfo->virtAddr==NULL)
        return -1;

    bufInfo->physAddr = Memory_translate (bufInfo->virtAddr, Memory_XltFlags_Virt2Phys);

    if(bufInfo->physAddr==NULL)
        return -1;

    bufInfo->srPtr = SharedRegion_getSRPtr(bufInfo->virtAddr,srRegId);

    return 0;
}
static Int32 VcapVencVdecVdis_ipcBitsDeInitDmaObj()
{
    Int32 status = OSA_SOK;

    if (gVcapVencVdecVdis_ipcBitsCtrl.dmaObj.useDma)
    {

        status =
        OSA_dmaClose(&gVcapVencVdecVdis_ipcBitsCtrl.dmaObj.dmaChHdnl);
        OSA_assert(status == OSA_SOK);

        status = OSA_dmaExit();
        OSA_assert(status == OSA_SOK);
    }
    return status;
}
Esempio n. 8
0
static
Void mulich_vdec_vdis_set_avsync_prm(AvsyncLink_LinkSynchConfigParams *avsyncPrm,
                                     UInt32 swMsIdx,
                                     VDIS_DEV vdDevId)
{
    Int i;
    Int32 status;

    Vdis_getAvsyncConfig(vdDevId,avsyncPrm);
    avsyncPrm->displayLinkID        = Vdis_getDisplayId(vdDevId);
    avsyncPrm->videoSynchLinkID = gVdisModuleContext.swMsId[swMsIdx];
    avsyncPrm->numCh            = gVdecModuleContext.vdecConfig.numChn;
    avsyncPrm->syncMasterChnum =  AVSYNC_INVALID_CHNUM;
    for (i = 0; i < avsyncPrm->numCh;i++)
    {
        mulich_vdec_vdis_set_avsync_vidque_prm(&avsyncPrm->queCfg[i],
                                               i,
                                               0,
                                               (0 + gVdecModuleContext.vdecConfig.numChn),
                                               vdDevId);
    }
    if (0 == swMsIdx)
    {
        Vdis_setAvsyncConfig(VDIS_DEV_HDMI,avsyncPrm);
    }
    else
    {
        Vdis_setAvsyncConfig(VDIS_DEV_SD,avsyncPrm);
    }

    status = Avsync_configSyncConfigInfo(avsyncPrm);
    OSA_assert(status == 0);
}
Esempio n. 9
0
status_t system_deinit(osa_console_object_t *pobj)
{
    status_t status = OSA_SOK;

    DBG(DBG_INFO, GT_NAME, "system de-initialized ...\n");

    /*
     *  Finalize osa timer.
     */
    status |= osa_timer_deinit();

    /*
     *  Finialize tasklist.
     */
    status |= task_mgr_deinit();

    /*
     *  Finalize debug module.
     */
    DBG(DBG_INFO, GT_NAME, "system de-initialized.\n");

    osa_debugger_deinit();

    OSA_assert(OSA_SOK == status);

    return status;
}
Esempio n. 10
0
static Void VdecVdis_bitsRdInitThrObj()
{
    int status;

    gVdecVdis_obj.thrExit = FALSE;
    status = OSA_semCreate(&gVdecVdis_obj.thrStartSem,1,0);
    OSA_assert(status==OSA_SOK);

    status = OSA_thrCreate(&gVdecVdis_obj.thrHandle,
            VdecVdis_bitsRdSendFxn,
            MCFW_IPCBITS_SENDFXN_TSK_PRI,
            MCFW_IPCBITS_SENDFXN_TSK_STACK_SIZE,
            &gVdecVdis_obj);

    OSA_assert(status==OSA_SOK);
}
Esempio n. 11
0
Int32 AVSYNC_Init()
{
    Int32  status = 0;
    Int64  curTime;
    Int32* key = NULL;

    AVSYNC_AvSyncEnable_t AVSYNC_AvSyncEnable;

    status = AVSYNC_GetSharedDataStructure();

    status = GateMP_open (AVSYNC_GATE_MP_NAME, pAvsyncMPGate);

#ifdef  ENABLE_AVSYNC_STATS_LOG

    avsyncLogThr_exit = 0;
    status = AVSYNC_LogThrCreate();
        OSA_assert(status == OSA_SOK);
#endif

    AVSYNC_AvSyncEnable.avSyncCompEnable = TRUE;
    AVSYNC_Control(AVSync_ComponentEnable, &AVSYNC_AvSyncEnable );

    curTime = AVSYNC_GetCurrentTime();
    printf ("\n\n=============== AVSYNC_curTime = %lld ==================\n", curTime);

    AVSYNC_LockSharedDataStructure(key);

    pAvSyncInfo_obj->timeInfo.wallTimeInTicks = curTime;

    AVSYNC_ReleaseSharedDataStructure(key);

    return OSA_SOK;
}
Esempio n. 12
0
void *OSA_tskThrMain(void *pPrm)
{
  OSA_MsgHndl *pMsg;
  OSA_TskHndl *pPrc;

  pPrc = (OSA_TskHndl *)pPrm;
  OSA_assert(pPrc!=NULL);

  while(1) {

    OSA_assertSuccess( OSA_tskWaitMsg(pPrc, &pMsg) );
    OSA_assert(pPrc->fncMain!=NULL);
    pPrc->fncMain(pPrc, pMsg, pPrc->curState);
  }
  
  return NULL;
} 
Int32 VcapVenc_bitsWriteCreate()
{
    VENC_CALLBACK_S callback;

    Int32 status;

    gVcapVenc_ctrl.fileWriteChn = 0;

    gVcapVenc_ctrl.fileWriteEnable = Demo_getFileWriteEnable();

    if(gVcapVenc_ctrl.fileWriteEnable)
    {
        char path[256];

        Demo_getFileWritePath(path, "/dev/shm");

        gVcapVenc_ctrl.fileWriteChn = Demo_getChId("File Write", gDemo_info.maxVencChannels);

        sprintf(gVcapVenc_ctrl.fileWriteName, "%s/VID_CH%02d.h264", path, gVcapVenc_ctrl.fileWriteChn);
    }

    gVcapVenc_ctrl.exitWrThr = FALSE;
    gVcapVenc_ctrl.isWrThrStopDone = FALSE;

    callback.newDataAvailableCb = VcapVenc_bitsWriteCbFxn;

    /* Register call back with encoder */
    Venc_registerCallback(&callback,
                          (Ptr)&gVcapVenc_ctrl);

    status = OSA_semCreate(&gVcapVenc_ctrl.wrSem, 1, 0);
    OSA_assert(status==OSA_SOK);

    status = OSA_thrCreate(
                 &gVcapVenc_ctrl.wrThrHndl,
                 VcapVenc_bitsWriteMain,
                 OSA_THR_PRI_DEFAULT,
                 0,
                 &gVcapVenc_ctrl
             );

    OSA_assert(status==OSA_SOK);

    return OSA_SOK;
}
Esempio n. 14
0
int OSA_mbxSendMsg(OSA_MbxHndl *pMbxTo, OSA_MbxHndl *pMbxFrom, Uint16 cmd, void *pPrm, Uint16 flags)
{
  OSA_MsgHndl *pSentMsg, *pRcvMsg;
  Bool waitAck;
  int retVal=OSA_SOK;
  OSA_MsgqHndl *ackMbx;

  OSA_assert(pMbxTo!=NULL);

  if(pMbxFrom==NULL) {
    if(flags & OSA_MBX_WAIT_ACK) {
      // if from mail box is NULL, then cannot wait for ACK
      OSA_assert(0);
    }
    ackMbx = NULL;
  } else {
    ackMbx = &pMbxFrom->ackMbx;
  }

  retVal = OSA_msgqSendMsg(&pMbxTo->rcvMbx, ackMbx, cmd, pPrm, flags, &pSentMsg);
  OSA_assertSuccess(retVal);

  if( (flags & OSA_MBX_WAIT_ACK) && ackMbx != NULL ) {

    waitAck = TRUE;

    do {
      // wait for ACK
      retVal = OSA_msgqRecvMsg(ackMbx, &pRcvMsg, OSA_TIMEOUT_FOREVER);
      OSA_assertSuccess(retVal);

      if(pRcvMsg==pSentMsg) {
        // ACK received for sent MSG
        waitAck = FALSE;
        retVal  = OSA_msgGetAckStatus(pRcvMsg);
      }

      OSA_mbxFreeMsg(pRcvMsg);

    } while(waitAck);
  }

  return retVal;
}
Esempio n. 15
0
static void VdecVdis_bitsRdFillEmptyBuf(VCODEC_BITSBUF_S *pEmptyBuf)
{
    int statHdr, statData;
    int curCh;

    curCh = pEmptyBuf->chnId;

    if(gVdecVdis_obj.fpRdHdr[curCh] == NULL)
        return;

    if(gVdecVdis_config.fileInfo[curCh].enable == 0)
        return;

    if(gVdecVdis_obj.switchInputFile)
    {
        if ((gVdecVdis_obj.switchInputFile) && (curCh == gVdecVdis_obj.chId))
        {
            loop_test_open(curCh, gVdecVdis_obj.FileIndex);
            gVdecVdis_obj.switchInputFile = FALSE;
        }
    }

    statHdr  = fscanf(gVdecVdis_obj.fpRdHdr[curCh],"%d",&(pEmptyBuf->filledBufSize));
    
    OSA_assert(pEmptyBuf->filledBufSize <= pEmptyBuf->bufSize);

    statData = read(gVdecVdis_obj.fdRdData[curCh], pEmptyBuf->bufVirtAddr, pEmptyBuf->filledBufSize);

    if( feof(gVdecVdis_obj.fpRdHdr[curCh]) || statData != pEmptyBuf->filledBufSize)
    {
        #ifdef IPCBITS_OUT_HOST_DEBUG
        OSA_printf(" CH%d: Reached the end of file, rewind !!!", curCh);
        #endif
        clearerr(gVdecVdis_obj.fpRdHdr[curCh]);
        
        rewind(gVdecVdis_obj.fpRdHdr[curCh]);
        lseek(gVdecVdis_obj.fdRdData[curCh], 0, SEEK_SET);
        statHdr = fscanf(gVdecVdis_obj.fpRdHdr[curCh],"%d",&(pEmptyBuf->filledBufSize));
        
        OSA_assert(pEmptyBuf->filledBufSize <= pEmptyBuf->bufSize);
        statData = read(gVdecVdis_obj.fdRdData[curCh], pEmptyBuf->bufVirtAddr, pEmptyBuf->filledBufSize);
    }
}
Esempio n. 16
0
Int32 SD_Demo_bitsWriteCreate()
{

    Int32 status;

    gSD_Demo_Ipc_Ctrl.fileWriteChn = 0;

    gSD_Demo_Ipc_Ctrl.fileWriteEnable = SD_Demo_getFileWriteEnable();

    if(gSD_Demo_Ipc_Ctrl.fileWriteEnable)
    {
        char path[256];

        SD_Demo_getFileWritePath(path, "/dev/shm");

        gSD_Demo_Ipc_Ctrl.fileWriteChn = SD_Demo_getChId("File Write", gSD_Demo_ctrl.numCapChannels);

        sprintf(gSD_Demo_Ipc_Ctrl.fileWriteName, "%s/VID_CH%02d.h264", path, gSD_Demo_Ipc_Ctrl.fileWriteChn);
    }

    gSD_Demo_Ipc_Ctrl.exitWrThr = FALSE;
    gSD_Demo_Ipc_Ctrl.isWrThrStopDone = FALSE;


    status = OSA_semCreate(&gSD_Demo_Ipc_Ctrl.wrSem, 1, 0);
    OSA_assert(status==OSA_SOK);

    status = OSA_thrCreate(
                 &gSD_Demo_Ipc_Ctrl.wrThrHndl,
                 SD_Demo_bitsWriteMain,
                 OSA_THR_PRI_DEFAULT,
                 0,
                 &gSD_Demo_Ipc_Ctrl
             );

    OSA_assert(status==OSA_SOK);

    OSA_waitMsecs(100); // allow for print to complete
    return OSA_SOK;
}
Esempio n. 17
0
int OSA_tskBroadcastMsg(OSA_TskHndl *pPrcToList[], OSA_TskHndl *pPrcFrom, Uint16 cmd, void *pPrm, Uint16 flags)
{
  int retVal;

  OSA_MbxHndl *pMbxToList[OSA_MBX_BROADCAST_MAX];
  Uint32 i, numMsg;
  OSA_MbxHndl *pMbxFrom;

  OSA_assert(pPrcToList!=NULL);

  if(pPrcFrom==NULL) {
    pMbxFrom = NULL;
  } else {
    pMbxFrom = &pPrcFrom->mbxHndl;
  }

  for(i=0; i<OSA_MBX_BROADCAST_MAX; i++)
  {
    pMbxToList[i]=NULL;
  }

  numMsg = 0;
  while(pPrcToList[numMsg]!=NULL) {
    pMbxToList[numMsg] = &pPrcToList[numMsg]->mbxHndl;
    numMsg++;
    if(numMsg>=OSA_MBX_BROADCAST_MAX) {
      // cannot broadcast to more than OSA_mbx_BROADCAST_MAX mailboxes
      OSA_assert(0);
    }
  }

  if(numMsg == 0) {
     // no mailboxes in 'to' mailbox list
     return OSA_SOK;
  }

  retVal = OSA_mbxBroadcastMsg(&pMbxToList[0], pMbxFrom, cmd, pPrm, flags);

  return retVal;
}
static
Int   VcapVencVdecVdis_ipcBitsOpenFileHandles()
{
    Int status = OSA_SOK;
    Int i;
    char fileNameHdr[128];
    char fileNameBuffer[128];


    for (i = 0; i < MCFW_IPC_BITS_MAX_NUM_CHANNELS; i++)
    {
        VcapVencVdecVdis_ipcBitsGenerateFileName(gVcapVencVdecVdis_ipcBitsCtrl.fObj.fileDirPath,
                MCFW_IPC_BITS_HDR_FILE_NAME,
                i,
                MCFW_IPC_BITS_FILE_EXTENSION,
                fileNameHdr,
                sizeof(fileNameHdr));
        gVcapVencVdecVdis_ipcBitsCtrl.fObj.fpWrHdr[i] = fopen(fileNameHdr,"wb");
        OSA_assert(gVcapVencVdecVdis_ipcBitsCtrl.fObj.fpWrHdr[i] != NULL);
        if (0 == i)
        {
            gVcapVencVdecVdis_ipcBitsCtrl.fObj.maxFileSize =
                VcapVencVdecVdis_ipcBitsGetMaxFileSizePerChannel(fileNameHdr);
        }
        status =  setvbuf(gVcapVencVdecVdis_ipcBitsCtrl.fObj.fpWrHdr[i],
                          NULL,
                          _IOFBF,
                          MCFW_IPC_BITS_FILEBUF_SIZE_HDR);
        OSA_assert(status != -1);
        gVcapVencVdecVdis_ipcBitsCtrl.fObj.wrapOccuredHdr[i] = FALSE;

        VcapVencVdecVdis_ipcBitsGenerateFileName(gVcapVencVdecVdis_ipcBitsCtrl.fObj.fileDirPath,
                MCFW_IPC_BITS_DATA_FILE_NAME,
                i,
                MCFW_IPC_BITS_FILE_EXTENSION,
                fileNameBuffer,
                sizeof(fileNameBuffer));


        gVcapVencVdecVdis_ipcBitsCtrl.fObj.fpWrData[i] = fopen(fileNameBuffer,"wb");
        OSA_assert(gVcapVencVdecVdis_ipcBitsCtrl.fObj.fpWrData[i] != NULL);
        status =  setvbuf(gVcapVencVdecVdis_ipcBitsCtrl.fObj.fpWrData[i],
                          NULL,
                          _IOFBF,
                          MCFW_IPC_BITS_FILEBUF_SIZE_DATA);
        OSA_assert(status != -1);
        gVcapVencVdecVdis_ipcBitsCtrl.fObj.wrapOccuredBuf[i] = FALSE;

        strncat(fileNameBuffer,".mv",3);
        gVcapVencVdecVdis_ipcBitsCtrl.fObj.fpWrMvData[i] = fopen(fileNameBuffer,"wb");
        OSA_assert(gVcapVencVdecVdis_ipcBitsCtrl.fObj.fpWrMvData[i] != NULL);
        status =  setvbuf(gVcapVencVdecVdis_ipcBitsCtrl.fObj.fpWrMvData[i],
                          NULL,
                          _IOFBF,
                          MCFW_IPC_BITS_FILEBUF_SIZE_DATA);
        OSA_assert(status != -1);
    }
    return status;
}
Esempio n. 19
0
int OSA_tskCreate(OSA_TskHndl *pPrc, OSA_TskFncMain fncMain, Uint32 tskPri, Uint32 tskStackSize, Uint32 initState)
{
  pPrc->curState      = initState;
  pPrc->fncMain       = fncMain;

  OSA_assert(pPrc->fncMain      != NULL);

  OSA_mbxCreate(&pPrc->mbxHndl);

  OSA_assertSuccess( OSA_thrCreate(&pPrc->thrHndl, OSA_tskThrMain, tskPri, tskStackSize,  pPrc) );
  
  return OSA_SOK;
}
Esempio n. 20
0
void loop_test_open(UInt32 fileId, UInt32 fileIndex)
{
    static Uint32 loopNum[64] = {0};
    char   fileNameHdr[MCFW_IPC_BITS_MAX_FULL_PATH_FILENAME_LENGTH];
    VdecVdis_FileInfo *pFileInfo;

    OSA_assert (fileIndex < gVdecVdis_config.fileNum);
    loopNum[fileId] = fileIndex;

    close(gVdecVdis_obj.fdRdData[fileId]);
    
    pFileInfo = &gVdecVdis_config.fileInfo[fileIndex];
    if(strcmp(pFileInfo->codec,"h264") == 0)
        Demo_generateH264HdrFile(pFileInfo->path);
    else if(strcmp(pFileInfo->codec,"mjpeg") == 0)
        Demo_generateMjpgHdrFile(pFileInfo->path);
    else if(strcmp(pFileInfo->codec,"mpeg4") == 0)
        Demo_generateMpeg4HdrFile(pFileInfo->path);

    bzero(fileNameHdr,MCFW_IPC_BITS_MAX_FULL_PATH_FILENAME_LENGTH);
    strcat(fileNameHdr, pFileInfo->path);
    strcat(fileNameHdr,".hdr\0");
    
    if (FALSE == VdecVdis_bitsRdFileExists(fileNameHdr))
    {
        printf(" %d: ERROR: Header File [%s] for [%s] not found !!! \n",
            fileId,
            fileNameHdr,
            pFileInfo->path
        );
    }

    fclose(gVdecVdis_obj.fpRdHdr[fileId]);
    gVdecVdis_obj.fpRdHdr[fileId] = fopen(fileNameHdr,"r");
    OSA_assert(gVdecVdis_obj.fpRdHdr[fileId] != NULL);
    gVdecVdis_obj.fdRdData[fileId] = open(pFileInfo->path, O_RDONLY);
    if(gVdecVdis_obj.fdRdData[fileId]<= 0)
        perror("---------!!!!!!!!!1-----");
}
Esempio n. 21
0
static Void  VdecVdis_ipcFramesInitFrameObj(VdecVdis_IpcFramesBufObj frameObj[],
                                            UInt32 numFrames,
                                            VIDEO_CHANNEL_LIST_INFO_S *chInfoList)
{
    Int i;
    Vsys_AllocBufInfo bufInfo;
    Int32 status;
    UInt32 frameSize;
    char   frameFileName[MAX_INPUT_STR_SIZE];
    UInt32 minChWidth = MCFW_IPCFRAMES_FRAME_INVALID_WIDTH;
    UInt32 minChHeight = MCFW_IPCFRAMES_FRAME_INVALID_HEIGHT;

    OSA_assert(chInfoList->numCh > 0);
    for (i = 0; i < chInfoList->numCh;i++)
    {
        if (chInfoList->chInfo[i].width < minChWidth)
        {
            minChWidth = chInfoList->chInfo[i].width;
        }
        if (chInfoList->chInfo[i].height < minChHeight)
        {
            minChHeight = chInfoList->chInfo[i].height;
        }
    }
    frameSize = MCFW_IPCBITS_GET_YUV422_FRAME_SIZE(minChWidth,
                                                   minChHeight);
    memset(frameObj,0,sizeof(VdecVdis_IpcFramesBufObj) * numFrames);
    for (i = 0; i < numFrames;i++)
    {
        status =
            Vsys_allocBuf(MCFW_IPCFRAMES_SRID,
                          frameSize,
                          MCFW_IPCFRAMES_FRAME_BUF_ALIGN,
                          &bufInfo);
        if (ERROR_NONE == status)
        {
            VdecVdis_ipcFramesInitFrame(&frameObj[i],
                                        &bufInfo,
                                        minChWidth,
                                        minChHeight,
                                        chInfoList->numCh);
            VdecVdis_ipcFramesGetInputFileName(frameFileName,
                                               i,
                                               sizeof(frameFileName)); 
            VdecVdis_ipcFramesInitFrameBuf(frameFileName,
                                           &frameObj[i],
                                           frameSize);
        }
    }

}
Esempio n. 22
0
static void VdecVdis_bitsRdFillEmptyBuf(VCODEC_BITSBUF_S *pEmptyBuf, UInt32 resId)
{
    int statHdr, statData;
    int curCh;

    curCh = VdecVdis_getChnlIdFromBufSize(resId);

    if(gVdecVdis_obj.fpRdHdr[curCh] == NULL)
        return;

    if(gVdecVdis_config.fileInfo[curCh].enable == 0)
        return;

    pEmptyBuf->chnId    = curCh;

    statHdr  = fscanf(gVdecVdis_obj.fpRdHdr[curCh],"%d",&(pEmptyBuf->filledBufSize));
    
    OSA_assert(pEmptyBuf->filledBufSize <= pEmptyBuf->bufSize);

    statData = read(gVdecVdis_obj.fdRdData[curCh], pEmptyBuf->bufVirtAddr, pEmptyBuf->filledBufSize);

    if( feof(gVdecVdis_obj.fpRdHdr[curCh]) || statData != pEmptyBuf->filledBufSize )
    {
        #ifdef IPCBITS_OUT_HOST_DEBUG
        OSA_printf(" CH%d: Reached the end of file, rewind !!!", curCh);
        #endif
        clearerr(gVdecVdis_obj.fpRdHdr[curCh]);

        rewind(gVdecVdis_obj.fpRdHdr[curCh]);
  
        lseek(gVdecVdis_obj.fdRdData[curCh], 0, SEEK_SET);

        statHdr = fscanf(gVdecVdis_obj.fpRdHdr[curCh],"%d",&(pEmptyBuf->filledBufSize));
        
        OSA_assert(pEmptyBuf->filledBufSize <= pEmptyBuf->bufSize);
        statData = read(gVdecVdis_obj.fdRdData[curCh], pEmptyBuf->bufVirtAddr, pEmptyBuf->filledBufSize);
    }
}
Esempio n. 23
0
static Void * VdecVdis_ipcFramesSendFxn(Void * prm)
{
    VdecVdis_IpcFramesCtrl *ipcFramesObj = (VdecVdis_IpcFramesCtrl *) prm;
    VdecVdis_IpcFramesCtrlThrObj *thrObj = &ipcFramesObj->thrObj;
    static Int printStatsInterval = 0;
    VIDEO_FRAMEBUF_LIST_S bufList;
    Int status;

    OSA_printf("MCFW_IPCFRAMES:%s:Entered...",__func__);
    OSA_semWait(&thrObj->thrStartSem,OSA_TIMEOUT_FOREVER);
    OSA_printf("MCFW_IPCFRAMES:Received start signal...");
    while (FALSE == thrObj->exitFramesOutThread)
    {
        VdecVdis_ipcFramesFillBufInfo(&bufList,
                                      ipcFramesObj->frameObj,
                                      OSA_ARRAYSIZE(ipcFramesObj->frameObj));
        if (bufList.numFrames)
        {
            status = Vdis_putFullVideoFrames(&bufList);
            OSA_assert(0 == status);
        }
        status =  Vdis_getEmptyVideoFrames(&bufList,0);
        OSA_assert(0 == status);

        if (bufList.numFrames)
        {
            VdecVdis_ipcFramesPrintFullFrameListInfo(&bufList,"EmptyFrameList");
            VdecVdis_ipcFramesFreeFrameBuf(&bufList,
                                           ipcFramesObj->frameObj,
                                           OSA_ARRAYSIZE(ipcFramesObj->frameObj));
        }
        printStatsInterval++;
        OSA_waitMsecs(MCFW_IPCFRAMES_SENDFXN_PERIOD_MS);
    }
    OSA_printf("MCFW_IPCFRAMES:%s:Leaving...",__func__);
    return NULL;
}
static Int32 VcapVencVdecVdis_ipcBitsInitDmaObj()
{
    Int32 status = OSA_SOK;

    if (gVcapVencVdecVdis_ipcBitsCtrl.dmaObj.useDma)
    {
        status = OSA_dmaInit();
        OSA_assert(status == OSA_SOK);

        status =
        OSA_dmaOpen(&gVcapVencVdecVdis_ipcBitsCtrl.dmaObj.dmaChHdnl,
                    OSA_DMA_MODE_NORMAL,
                    MCFW_IPC_BITS_DMA_MAX_TRANSFERS);
        OSA_assert(status == OSA_SOK);

    }
    if (OSA_SOK != status)
    {
        OSA_printf("DEMO_MCFW_IPC_BITS_CTRL:Disabling DMA as channel open failed[%d]",
                   status);
        gVcapVencVdecVdis_ipcBitsCtrl.dmaObj.useDma = FALSE;
    }
    return status;
}
Esempio n. 25
0
static
Void  Vdec_copyChannelInfo(VIDEO_CHANNEL_LIST_INFO_S *dst,
                           System_LinkQueInfo        *src)
{
    Int i;

    OSA_COMPILETIME_ASSERT(OSA_ARRAYSIZE(src->chInfo)  ==
                           OSA_ARRAYSIZE(dst->chInfo));
    OSA_assert(src->numCh <= OSA_ARRAYSIZE(src->chInfo));
    dst->numCh = src->numCh;
    for (i = 0; i < src->numCh; i++)
    {
        dst->chInfo[i].width  = src->chInfo[i].width;
        dst->chInfo[i].height = src->chInfo[i].height;
    }
}
static
Void VcapVencVdecVdis_FreeBitBufFree(VCODEC_BITSBUF_S * bitBufInfo)
{
    Int entryIndex;
    struct VcapVencVdecVdis_FreeBitBufInfoEntry * entry = NULL;

    OSA_mutexLock(&g_FreeBitBufInfoTbl.mutex);
    entryIndex = VcapVencVdecVdis_FreeBitBufGetIndex(bitBufInfo);
    OSA_assert((entryIndex >= 0) &&
               (entryIndex < OSA_ARRAYSIZE(g_FreeBitBufInfoTbl.tbl)));
    entry = &g_FreeBitBufInfoTbl.tbl[entryIndex];
    entry->nextFreeIndex = g_FreeBitBufInfoTbl.freeIndex;
    g_FreeBitBufInfoTbl.freeIndex = entryIndex;
    OSA_mutexUnlock(&g_FreeBitBufInfoTbl.mutex);

}
static Void VcapVencVdecVdis_ipcBitsCopyBitBufDataMem2Mem(VCODEC_BITSBUF_S *dstBuf,
        VCODEC_BITSBUF_S *srcBuf)
{
    OSA_DmaCopy1D copy1D;

    OSA_assert(srcBuf->filledBufSize < dstBuf->bufSize);
    if(gVcapVencVdecVdis_ipcBitsCtrl.dmaHndl.chId != -1)
    {
        copy1D.srcPhysAddr = (unsigned long)srcBuf->bufPhysAddr;
        copy1D.dstPhysAddr = (unsigned long)dstBuf->bufPhysAddr;
        copy1D.size   = srcBuf->filledBufSize;
        OSA_dmaCopy1D(&gVcapVencVdecVdis_ipcBitsCtrl.dmaHndl,&copy1D,1);
    }
    else
        memcpy(dstBuf->bufVirtAddr,srcBuf->bufVirtAddr,srcBuf->filledBufSize);
}
Void VcapVencVdecVdis_ipcBitsInCbFxn (Ptr cbCtx)
{
    VcapVencVdecVdis_IpcBitsCtrl *app_ipcBitsCtrl;
    static Int printInterval;

    OSA_assert(cbCtx = &gVcapVencVdecVdis_ipcBitsCtrl);
    app_ipcBitsCtrl = cbCtx;
    OSA_semSignal(&app_ipcBitsCtrl->thrObj.bitsInNotifySem);
    #ifdef IPC_BITS_DEBUG
    if ((printInterval % MCFW_IPCBITS_INFO_PRINT_INTERVAL) == 0)
    {
        OSA_printf("MCFW_IPCBITS: Callback function:%s",__func__);
    }
    #endif
    printInterval++;

}
static
Void VcapVencVdecVdis_FreeBitBufDeInit()
{
    Int status,i;

    status = OSA_mutexDelete(&g_FreeBitBufInfoTbl.mutex);
    OSA_assert(status == OSA_SOK);

    for (i = 0; i < (OSA_ARRAYSIZE(g_FreeBitBufInfoTbl.tbl) - 1);i++)
    {
        g_FreeBitBufInfoTbl.tbl[i].nextFreeIndex = (i + 1);
    }
    g_FreeBitBufInfoTbl.tbl[i].nextFreeIndex =
        APP_IPCBITSCTRL_FREE_BITBUFINFO_INVALIDID;
    g_FreeBitBufInfoTbl.freeIndex = 0;

}
Esempio n. 30
0
int OSA_tskSendMsg(OSA_TskHndl *pPrcTo, OSA_TskHndl *pPrcFrom, Uint16 cmd, void *pPrm, Uint16 flags)
{
  int retVal;
  OSA_MbxHndl *pMbxFrom;

  OSA_assert(pPrcTo!=NULL);

  if(pPrcFrom==NULL) {
    pMbxFrom = NULL;
  } else {
    pMbxFrom = &pPrcFrom->mbxHndl;
  }

  retVal = OSA_mbxSendMsg(&pPrcTo->mbxHndl, pMbxFrom, cmd, pPrm, flags);

  return retVal;
}