⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tskdecode.c

📁 基于DM642的JPEG图象编解码的网络传输程序
💻 C
字号:
#include <std.h>
#include <tsk.h>
#include <stdio.h>
#include <csl.h>
#include <csl_cache.h>
#include <csl_dat.h>
#include <chan.h>
#include <scom.h>
#include <utl.h>
#include <ialg.h>

#include "fvid.h"
#include "celljpegenc_ti.h"
#include "celljpegdec_ti.h"
#include "appmain.h"
#include "appThreads.h"
#include "tskDecode.h"
#include "appBiosObjects.h"

#include "c:\ti\c6000\ndk\inc\netmain.h"

IJPEGDEC_Params   jpegdecParams;

#pragma DATA_ALIGN(dec_out_y, 128);
#pragma DATA_ALIGN(dec_out_u, 128);
#pragma DATA_ALIGN(dec_out_v, 128);
unsigned char dec_out_y[720 * 480];
unsigned char dec_out_u[360 * 240];
unsigned char dec_out_v[360 * 240];

ThrDecode thrDecode;

void tskDecodeInit()
{
    int chanNum;
    ICELL_Obj  *cell;
    ICC_Handle  inputIcc;
    ICC_Handle  outputIcc;

    /*----------------------------------------------------*/
    /* Call JPEG specific user initialization if any.     */
    /*----------------------------------------------------*/
    JPEGDEC_TI_init();

    /*----------------------------------------------------*/
    /* Set up params for all XDAIS algorithms.            */
    /*----------------------------------------------------*/
    jpegdecParams = IJPEGDEC_PARAMS;

    for (chanNum = 0; chanNum < PROCESSNUMCHANNELS ; chanNum++)
    {
        /*
         * JPEGDEC: create an input and output linear ICC:
         * The address to the ICC's will be set in the thrProcessRun()
         * function via the ICC_setBuf().
         */
        ICELL_Obj   defaultCell = ICELL_DEFAULT;

        cell = &thrDecode.cellList[(chanNum*PROCESSNUMCHANNELS) + 0];
        *cell                = defaultCell;
        cell->name           = "JPEGDEC";
        cell->cellFxns       = &JPEGDEC_CELLFXNS;
        cell->algFxns        = (IALG_Fxns *)&JPEGDEC_IJPEGDEC;
        cell->algParams      = (IALG_Params *)&IJPEGDEC_PARAMS;
        cell->scrBucketIndex = THRIOSSCRBUCKET;

        inputIcc  = (ICC_Handle)ICC_linearCreate(NULL, 0);
        UTL_assert( inputIcc != NULL);

        outputIcc = (ICC_Handle)ICC_linearCreate(NULL, 0);
        UTL_assert( outputIcc != NULL);

        // Only one input and one output ICC are needed.
        CHAN_regCell( cell, &inputIcc, 1, &outputIcc, 1 );

        // Setup Decode Parameters
        thrDecode.cellList[(chanNum*PROCESSNUMCELLS) + 0].algParams =
                                               (IALG_Params *)&IJPEGDEC_PARAMS;

        UTL_logDebug1("JPEGDecoder registerd Channel Number: %d", chanNum);
    }

    memset(dec_out_y, 0x0,  sizeof(dec_out_y));
    memset(dec_out_u, 0x80, sizeof(dec_out_u));
    memset(dec_out_v, 0x80, sizeof(dec_out_v));

    CACHE_clean(CACHE_L2ALL, 0, 0);
    CACHE_clean(CACHE_L2ALL, 0, 0);
}

void tskDecodeStart()
{
    int chanNum;
    for( chanNum=0; chanNum < PROCESSNUMCHANNELS; chanNum++ )
    {
        // open the decode channel: this causes the algorithms to be created
        CHAN_open( &thrDecode.chanList[chanNum],
                   &thrDecode.cellList[(chanNum*PROCESSNUMCELLS)],
                   PROCESSNUMCELLS, NULL );

    }
}

void tskDecode()
{
    int i;
    ScomMessage *pMsgBuf;
    ScomMessage scomMsg;
    void *inBuf[3];
    void *outBuf[3];
    int  frame_num = 0;
    CHAN_Handle chanHandle;
    SCOM_Handle hs_Out2Dec,hs_Dec2Out;
    SCOM_Handle hs_JPG2Dec,hs_Dec2JPG;

    hs_Out2Dec = SCOM_open("OUT2DEC");
    hs_Dec2Out = SCOM_open("DEC2OUT");
    hs_JPG2Dec = SCOM_open("NET2DEC");
    hs_Dec2JPG = SCOM_open("DEC2NET");

    if( !hs_Out2Dec || !hs_Dec2Out || !hs_JPG2Dec || !hs_Dec2JPG )
    {
        for(;;);
    }

    while(1)
    {
        frame_num++;

        for(i=0; i<PROCESSNUMCHANNELS; i++)
        {
            // Get a JPEG file
            pMsgBuf = SCOM_getMsg( hs_JPG2Dec, SYS_FOREVER );

            //
            // Handle Decode Channel
            //

            chanHandle = &thrDecode.chanList[i];
            chanHandle->state = CHAN_ACTIVE;

            inBuf[0] = &(pMsgBuf->sizeLinear);
            inBuf[1] = pMsgBuf->bufLinear;
            ICC_setBuf( chanHandle->cellSet[0].inputIcc[0],
                        inBuf, sizeof(void *) * 2 );

            outBuf[0] = (void *)dec_out_y;
            outBuf[1] = (void *)dec_out_u;
            outBuf[2] = (void *)dec_out_v;
            ICC_setBuf( chanHandle->cellSet[0].outputIcc[0],
                        outBuf, sizeof(void *) * 3 );

            // Execute Channel
            TSK_setpri( TSK_self(), 6 );
            CHAN_execute( chanHandle, frame_num );
            TSK_setpri( TSK_self(), 5 );

            // We're done with the JPEG file now
            SCOM_putMsg( hs_Dec2JPG, pMsgBuf );

            // Send the buffer to the display task
            scomMsg.bufY = (void *)dec_out_y;
            scomMsg.bufU = (void *)dec_out_u;
            scomMsg.bufV = (void *)dec_out_v;
            SCOM_putMsg( hs_Dec2Out, &scomMsg );

            // Get back the ownership of our linear buffer
            SCOM_getMsg( hs_Out2Dec, SYS_FOREVER );
        }
    }
}




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -