TI8168 编解码例子

/*******************************************************************************
 *                                                                             *
 * Copyright (c) 2009 Texas Instruments Incorporated - http://www.ti.com/      *
 *                        ALL RIGHTS RESERVED                                  *
 *                                                                             *
 ******************************************************************************/

#include 


/**
                         SRC (YUV420SP)
                          |
                          |
                         ENC (BitStream)
                          |
                         IPC_BITS_OUT_M3 (BitStream)
                          |
                         IPC_BITS_IN_A8 (BitStream)
                          |
                         fwrite() - write to harddisk
                          |
                         fread() - read from harddisk
                          |
                         IPC_BITS_OUT_A8 (BitStream)
                          |
                         IPC_BITS_IN_M3 (BitStream)
                          |
                         DEC (YUV420SP)
                          |
                          |
                         SNK
*/
#define SRC_NUM_CH 16
static SystemVideo_Ivahd2ChMap_Tbl systemVid_encDecIvaChMapTbl =
{
    .isPopulated = 1,
    .ivaMap[0] = 
    {
        .EncNumCh  = 10,
        .EncChList = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 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[1] = 
    {
        .EncNumCh  = 0, 
        .EncChList = {16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31},
        .DecNumCh  = 12,
        .DecChList = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 0 , 0, 0},
    },
    .ivaMap[2] = 
    {
        .EncNumCh  = 6,
        .EncChList = {10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        .DecNumCh  = 4,
        .DecChList = {12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    },
};

Void Chains_multiChEncDecLoopBack(Chains_Ctrl *chainsCfg)
{
    NullSrcLink_CreateParams srcPrm;
    EncLink_CreateParams     encPrm;
    DecLink_CreateParams     decPrm;
    NullLink_CreateParams    snkPrm;
    IpcLink_CreateParams     ipcOutVpssPrm;
    IpcLink_CreateParams     ipcInVpssPrm;
    IpcLink_CreateParams     ipcOutVideoPrm;
    IpcLink_CreateParams     ipcInVideoPrm;
    IpcBitsOutLinkHLOS_CreateParams   ipcBitsOutHostPrm;
    IpcBitsOutLinkRTOS_CreateParams   ipcBitsOutVideoPrm;
    IpcBitsInLinkHLOS_CreateParams    ipcBitsInHostPrm;
    IpcBitsInLinkRTOS_CreateParams    ipcBitsInVideoPrm;
    Int i;
    Bool isProgressive;
    System_LinkInfo bitsProducerLinkInfo;

    UInt32 srcId, encId, decId, snkId;
    UInt32 ipcOutVpssId, ipcInVpssId;
    UInt32 ipcOutVideoId, ipcInVideoId;
    UInt32 ipcBitsOutVideoId, ipcBitsInHostId;
    UInt32 ipcBitsInVideoId, ipcBitsOutHostId;
    char ch;

    Chains_ipcBitsInit();
    CHAINS_INIT_STRUCT(IpcLink_CreateParams,ipcOutVpssPrm);
    CHAINS_INIT_STRUCT(IpcLink_CreateParams,ipcInVpssPrm);
    CHAINS_INIT_STRUCT(IpcLink_CreateParams,ipcOutVideoPrm);
    CHAINS_INIT_STRUCT(IpcLink_CreateParams,ipcInVideoPrm);
    CHAINS_INIT_STRUCT(IpcBitsOutLinkHLOS_CreateParams,ipcBitsOutHostPrm);
    CHAINS_INIT_STRUCT(IpcBitsOutLinkRTOS_CreateParams,ipcBitsOutVideoPrm);
    CHAINS_INIT_STRUCT(IpcBitsInLinkHLOS_CreateParams,ipcBitsInHostPrm);
    CHAINS_INIT_STRUCT(IpcBitsInLinkRTOS_CreateParams,ipcBitsInVideoPrm);
    CHAINS_INIT_STRUCT(DecLink_CreateParams, decPrm);
    CHAINS_INIT_STRUCT(EncLink_CreateParams, encPrm);

    srcId  = SYSTEM_VPSS_LINK_ID_NULL_SRC_0;
    encId  = SYSTEM_LINK_ID_VENC_0;
    decId  = SYSTEM_LINK_ID_VDEC_0;
    snkId  = SYSTEM_VPSS_LINK_ID_NULL_0;

    ipcOutVpssId = SYSTEM_VPSS_LINK_ID_IPC_OUT_M3_0;
    ipcInVideoId = SYSTEM_VIDEO_LINK_ID_IPC_IN_M3_0;
    ipcOutVideoId= SYSTEM_VIDEO_LINK_ID_IPC_OUT_M3_0;
    ipcInVpssId  = SYSTEM_VPSS_LINK_ID_IPC_IN_M3_0;

    ipcBitsOutVideoId = SYSTEM_VIDEO_LINK_ID_IPC_BITS_OUT_0;
    ipcBitsInHostId   = SYSTEM_HOST_LINK_ID_IPC_BITS_IN_0;
    ipcBitsOutHostId  = SYSTEM_HOST_LINK_ID_IPC_BITS_OUT_0;
    ipcBitsInVideoId  = SYSTEM_VIDEO_LINK_ID_IPC_BITS_IN_0;


    srcPrm.tilerEnable = TRUE;
    isProgressive = TRUE;

    System_linkControl(
        SYSTEM_LINK_ID_M3VIDEO,
        SYSTEM_COMMON_CMD_SET_CH2IVAHD_MAP_TBL,
        &systemVid_encDecIvaChMapTbl,
        sizeof(SystemVideo_Ivahd2ChMap_Tbl),
        TRUE
    );

    srcPrm.outQueParams.nextLink = ipcOutVpssId;
    if (isProgressive){
        srcPrm.timerPeriod          = 30;
    }else {
        srcPrm.timerPeriod          = 15;
    }
    srcPrm.inputInfo.numCh          = SRC_NUM_CH;
    for(i=0; idataFormat = SYSTEM_DF_YUV420SP_UV;
        pChInfo->memType    = SYSTEM_MT_TILEDMEM;
        pChInfo->width      = 720;
        if (isProgressive){
            pChInfo->height     = 480;
            pChInfo->scanFormat = SYSTEM_SF_PROGRESSIVE;
        } else{
            pChInfo->height     = 480/2;
            pChInfo->scanFormat = SYSTEM_SF_INTERLACED;
        }
        pChInfo->pitch[0]   = SystemUtils_align(pChInfo->width+pChInfo->startX,
                                                SYSTEM_BUFFER_ALIGNMENT);
        pChInfo->pitch[1]   = pChInfo->pitch[0];
        pChInfo->pitch[2]   = 0;
    }

    ipcOutVpssPrm.inQueParams.prevLinkId    = srcId;
    ipcOutVpssPrm.inQueParams.prevLinkQueId = 1;
    ipcOutVpssPrm.numOutQue                 = 1;
    ipcOutVpssPrm.outQueParams[0].nextLink     = ipcInVideoId;
    ipcOutVpssPrm.notifyNextLink            = TRUE;
    ipcOutVpssPrm.notifyPrevLink            = TRUE;
    ipcOutVpssPrm.noNotifyMode              = FALSE;

    ipcInVideoPrm.inQueParams.prevLinkId    = ipcOutVpssId;
    ipcInVideoPrm.inQueParams.prevLinkQueId = 0;
    ipcInVideoPrm.numOutQue                 = 1;
    ipcInVideoPrm.outQueParams[0].nextLink     = encId;
    ipcInVideoPrm.notifyNextLink            = TRUE;
    ipcInVideoPrm.notifyPrevLink            = TRUE;
    ipcInVideoPrm.noNotifyMode              = FALSE;

    for (i=0; i

你可能感兴趣的:(TI,8148)