Hi,
Thanks a lots to this forum, I could successfully realize many RDK use cases. I want to realize one more, Multichannel Encoder using Link APIs. (File Read -> ENC -> File write). 16 channel @ 720x576
I feel I connected the Links correctly with correct parameters...
/*******************************************************************************
* *
* Copyright (c) 2009 Texas Instruments Incorporated - http://www.ti.com/ *
* ALL RIGHTS RESERVED *
* *
******************************************************************************/
#include <demos/link_api_demos/common/chains.h>
#include <demos/link_api_demos/video_chains/system_chain.h>
#include <demos/link_api_demos/video_chains/system_frame_chain.h>
/**
FILE (YUV)
|
|
IPC_FRAMES_OUT_A8 (Frames)
|
IPC_FRAMES_IN_M3 (Frames)
|
ENC
|
IPC_BITS_OUT_M3 (Bits Stream)
|
IPC_BITS_IN_A8 (Bits Stream)
|
|
FILE (H264)
*/
#define SRC_NUM_CH 16
#define NUM_BUF_PER_CH 6
#define CH_WIDTH 720
#define CH_HEIGHT 576
static SystemVideo_Ivahd2ChMap_Tbl systemVid_encDecIvaChMapTbl =
{
.isPopulated = 1,
.ivaMap[0] =
{
.EncNumCh = 16,
.EncChList = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 , 14, 15},
.DecNumCh = 0,
.DecChList = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
},
.ivaMap[1] =
{
.EncNumCh = 0,
.EncChList = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
.DecNumCh = 0,
.DecChList = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0},
},
.ivaMap[2] =
{
.EncNumCh = 0,
.EncChList = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
.DecNumCh = 0,
.DecChList = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
},
};
Void Chains_multiChH264Enc(Chains_Ctrl *chainsCfg)
{
IpcFramesOutLinkHLOS_CreateParams ipcFramesOutHostPrm;
IpcFramesInLinkRTOS_CreateParams ipcFramesInVideoPrm;
EncLink_CreateParams encPrm;
IpcBitsOutLinkRTOS_CreateParams ipcBitsOutVideoPrm;
IpcBitsInLinkHLOS_CreateParams ipcBitsInHostPrm;
Int i, SndRcvConfig;
Bool isProgressive;
System_LinkInfo bitsProducerLinkInfo;
UInt32 encId;
UInt32 ipcFramesInVideoId, ipcFramesOutHostId;
UInt32 ipcBitsOutVideoId, ipcBitsInHostId;
char ch;
iChains_ipcBitsInit();
SndRcvConfig = ICHAINS_IPC_FRAMES_SND_ONLY;
iChains_ipcFramesInit(SndRcvConfig);
CHAINS_INIT_STRUCT(IpcFramesOutLinkHLOS_CreateParams,ipcFramesOutHostPrm);
CHAINS_INIT_STRUCT(IpcFramesInLinkRTOS_CreateParams,ipcFramesInVideoPrm);
CHAINS_INIT_STRUCT(EncLink_CreateParams, encPrm);
CHAINS_INIT_STRUCT(IpcBitsOutLinkRTOS_CreateParams,ipcBitsOutVideoPrm);
CHAINS_INIT_STRUCT(IpcBitsInLinkHLOS_CreateParams,ipcBitsInHostPrm);
ipcFramesOutHostId = SYSTEM_HOST_LINK_ID_IPC_FRAMES_OUT_0;
ipcFramesInVideoId = SYSTEM_VIDEO_LINK_ID_IPC_FRAMES_IN_0;
encId = SYSTEM_LINK_ID_VENC_0;
ipcBitsOutVideoId = SYSTEM_VIDEO_LINK_ID_IPC_BITS_OUT_0;
ipcBitsInHostId = SYSTEM_HOST_LINK_ID_IPC_BITS_IN_0;
isProgressive = TRUE;
System_linkControl(
SYSTEM_LINK_ID_M3VIDEO,
SYSTEM_COMMON_CMD_SET_CH2IVAHD_MAP_TBL,
&systemVid_encDecIvaChMapTbl,
sizeof(SystemVideo_Ivahd2ChMap_Tbl),
TRUE
);
/**
* IPC Frames OUT (A8)
* */
ipcFramesOutHostPrm.baseCreateParams.outQueParams[0].nextLink = ipcFramesInVideoId;
ipcFramesOutHostPrm.baseCreateParams.notifyNextLink = FALSE;
ipcFramesOutHostPrm.baseCreateParams.notifyPrevLink = FALSE;
ipcFramesOutHostPrm.baseCreateParams.noNotifyMode = TRUE;
ipcFramesOutHostPrm.baseCreateParams.numOutQue = 1;
ipcFramesOutHostPrm.baseCreateParams.inQueParams.prevLinkId = SYSTEM_LINK_ID_INVALID;
ipcFramesOutHostPrm.inQueInfo.numCh = SRC_NUM_CH;
for (i=0; i<SRC_NUM_CH; i++)
{
ipcFramesOutHostPrm.inQueInfo.chInfo[i].width = CH_WIDTH;
ipcFramesOutHostPrm.inQueInfo.chInfo[i].height = CH_HEIGHT;
ipcFramesOutHostPrm.inQueInfo.chInfo[i].scanFormat = SYSTEM_SF_PROGRESSIVE;
ipcFramesOutHostPrm.inQueInfo.chInfo[i].bufType = 0; // NOT USED
ipcFramesOutHostPrm.inQueInfo.chInfo[i].codingformat = 0; // NOT USED
ipcFramesOutHostPrm.inQueInfo.chInfo[i].dataFormat = 0x07; //FVID2_DF_YUV420SP_UV
ipcFramesOutHostPrm.inQueInfo.chInfo[i].memType = 0; // NON-TILED MEM
ipcFramesOutHostPrm.inQueInfo.chInfo[i].startX = 0; // NOT USED
ipcFramesOutHostPrm.inQueInfo.chInfo[i].startY = 0; // NOT USED
ipcFramesOutHostPrm.inQueInfo.chInfo[i].pitch[0] = CH_WIDTH;
ipcFramesOutHostPrm.inQueInfo.chInfo[i].pitch[1] = CH_WIDTH;
ipcFramesOutHostPrm.inQueInfo.chInfo[i].pitch[2] = 0; // NOT USED
}
/**
* IPC Frames OUT (A8) to IPC Frames IN (Video)
* */
ipcFramesInVideoPrm.baseCreateParams.noNotifyMode = TRUE;
ipcFramesInVideoPrm.baseCreateParams.notifyNextLink = TRUE;
ipcFramesInVideoPrm.baseCreateParams.notifyPrevLink = FALSE;
ipcFramesInVideoPrm.baseCreateParams.inQueParams.prevLinkId = ipcFramesOutHostId;
ipcFramesInVideoPrm.baseCreateParams.inQueParams.prevLinkQueId = 0;
ipcFramesInVideoPrm.baseCreateParams.outQueParams[0].nextLink = encId;
/**
* IPC Frames IN (Video) to Encoder
* */
for (i=0; i<SRC_NUM_CH; i++) {
encPrm.chCreateParams[i].format = IVIDEO_H264HP;
encPrm.chCreateParams[i].profile = IH264_HIGH_PROFILE;
encPrm.chCreateParams[i].dataLayout = IVIDEO_FIELD_SEPARATED;
encPrm.chCreateParams[i].fieldMergeEncodeEnable = FALSE;
encPrm.chCreateParams[i].defaultDynamicParams.intraFrameInterval = 20;
encPrm.chCreateParams[i].encodingPreset = XDM_DEFAULT;
encPrm.chCreateParams[i].enableAnalyticinfo = 0;
encPrm.chCreateParams[i].enableWaterMarking = 0;
encPrm.chCreateParams[i].rateControlPreset =
IVIDEO_STORAGE;
encPrm.chCreateParams[i].defaultDynamicParams.inputFrameRate = 30;
encPrm.chCreateParams[i].defaultDynamicParams.targetBitRate =
(3 * 1000 * 1000);
encPrm.chCreateParams[i].defaultDynamicParams.interFrameInterval = 1;
encPrm.chCreateParams[i].defaultDynamicParams.mvAccuracy =
IVIDENC2_MOTIONVECTOR_QUARTERPEL;
}
encPrm.inQueParams.prevLinkId = ipcFramesInVideoId;
encPrm.inQueParams.prevLinkQueId= 0;
encPrm.outQueParams.nextLink = ipcBitsOutVideoId;
encPrm.numBufPerCh[0] = NUM_BUF_PER_CH;
/**
* Encoder to ipcBitsOutVideo
**/
ipcBitsOutVideoPrm.baseCreateParams.inQueParams.prevLinkId = encId;
ipcBitsOutVideoPrm.baseCreateParams.inQueParams.prevLinkQueId = 0;
ipcBitsOutVideoPrm.baseCreateParams.numOutQue = 1;
ipcBitsOutVideoPrm.baseCreateParams.notifyPrevLink = TRUE;
ipcBitsOutVideoPrm.baseCreateParams.notifyNextLink = FALSE;
ipcBitsOutVideoPrm.baseCreateParams.outQueParams[0].nextLink = ipcBitsInHostId;
/**
* ipcBitsOutVideo to
**/
ipcBitsInHostPrm.baseCreateParams.inQueParams.prevLinkId = ipcBitsOutVideoId;
ipcBitsInHostPrm.baseCreateParams.inQueParams.prevLinkQueId = 0;
ipcBitsInHostPrm.baseCreateParams.notifyNextLink = FALSE;
ipcBitsInHostPrm.baseCreateParams.notifyPrevLink = FALSE;
ipcBitsInHostPrm.baseCreateParams.noNotifyMode = TRUE;
ipcBitsInHostPrm.baseCreateParams.outQueParams[0].nextLink = SYSTEM_LINK_ID_INVALID;
System_linkCreate(ipcFramesOutHostId,&ipcFramesOutHostPrm,sizeof(ipcFramesOutHostPrm));
System_linkCreate(ipcFramesInVideoId,&ipcFramesInVideoPrm,sizeof(ipcFramesInVideoPrm));
System_linkCreate(encId, &encPrm, sizeof(encPrm));
sleep(2);
System_linkCreate(ipcBitsOutVideoId, &ipcBitsOutVideoPrm, sizeof(ipcBitsOutVideoPrm));
System_linkCreate(ipcBitsInHostId, &ipcBitsInHostPrm, sizeof(ipcBitsInHostPrm));
printf("SYSTEM INFO >>> FILE - ENC - FILE Links Created\n");
Chains_memPrintHeapStatus();
{
System_linkStart(ipcBitsInHostId);
System_linkStart(ipcBitsOutVideoId);
System_linkStart(encId);
System_linkStart(ipcFramesInVideoId);
System_linkStart(ipcFramesOutHostId);
/* Start taking CPU load just before starting of links */
Chains_prfLoadCalcEnable(TRUE, FALSE, FALSE);
while(1)
{
ch = Chains_menuRunTime();
if(ch=='0')
break;
if(ch=='i')
System_linkControl(encId, ENC_LINK_CMD_PRINT_IVAHD_STATISTICS, NULL, 0, TRUE);
if(ch=='e')
System_linkControl(encId, ENC_LINK_CMD_PRINT_STATISTICS, NULL, 0, TRUE);
if(ch=='E')
System_linkControl(encId, ENC_LINK_CMD_PRINT_BUFFER_STATISTICS, NULL, 0, TRUE);
}
iChains_ipcBitsStop();
System_linkStop(ipcFramesOutHostId);
System_linkStop(ipcFramesInVideoId);
System_linkStop(encId);
System_linkStop(ipcBitsOutVideoId);
System_linkStop(ipcBitsInHostId);
}
System_linkDelete(ipcBitsInHostId);
System_linkDelete(ipcBitsOutVideoId);
System_linkDelete(encId);
System_linkDelete(ipcFramesInVideoId);
System_linkDelete(ipcFramesOutHostId);
Chains_prfLoadCalcEnable(FALSE, TRUE, FALSE);
iChains_ipcBitsExit();
}
All the links are getting created.. But when I periodically poll for empty video frames ,
status = IpcFramesOutLink_getEmptyVideoFrames(SYSTEM_HOST_LINK_ID_IPC_FRAMES_OUT_0,
&bufList);
I get numFrames as '0'.
Thanks