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

📄 tskprocess.c

📁 DM642 网络测试原程序 包括视频采集和压缩,解压缩编码
💻 C
📖 第 1 页 / 共 2 页
字号:

        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 Encode Parameters
        thrProcess.cellListEncode[(chanNum*PROCESSNUMCELLS) + 0].algParams =
                                                (IALG_Params *)&IJPEGENC_PARAMS;

        UTL_logDebug1("JPEGEncoder registerd Channel Number: %d", 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().
         */
        cell = &thrProcess.cellListDecode[(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
        thrProcess.cellListDecode[(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 tskProcessStart()
{
    int chanNum;
    for( chanNum=0; chanNum < PROCESSNUMCHANNELS; chanNum++ )
    {
        // open the encode channel: this causes the algorithms to be created
        CHAN_open( &thrProcess.chanListEncode[chanNum],
                   &thrProcess.cellListEncode[(chanNum*PROCESSNUMCELLS)],
                   PROCESSNUMCELLS, NULL );

        // open the decode channel: this causes the algorithms to be created
        CHAN_open( &thrProcess.chanListDecode[chanNum],
                   &thrProcess.cellListDecode[(chanNum*PROCESSNUMCELLS)],
                   PROCESSNUMCELLS, NULL );

    }
}


static Void checkMsg()
{
    CtrlMsg rxMsg;
    Int index;
    Int quality;
    ICELL_Handle handle;

    IJPEGENC_Params jpegencParams;
    int cell_no;

    // check message in "mbxProc"
    while( MBX_pend( &mbxProcess, &rxMsg, 0) )
    {
        switch (rxMsg.cmd)
        {
            case MSGFRAMECHANGE:  // frame ratio value changed
            {
                index = rxMsg.arg1;  // get the index number
                UTL_assert( (index >= 0) && (index < PROCESSNUMCHANNELS));
                // update the local value
                if (index < PROCESSNUMCHANNELS)
                    thrProcess.frameRateControl[index] = rxMsg.arg2;

                break;
            }

            case MSGQUALCHANGE: //quality rate value changed
            {
                index = rxMsg.arg1;  // get the index number
                UTL_assert( (index >= 0) && (index < PROCESSNUMCHANNELS));
                if (index < PROCESSNUMCHANNELS)
                {
                    jpegencParams =  IJPEGENC_PARAMS;
                    cell_no = rxMsg.arg2;
                    UTL_assert( (cell_no >= 0) && (cell_no < PROCESSNUMCELLS));

                    quality = rxMsg.arg3;
                    UTL_assert( (quality >= 0) &&
                                 (quality <= 100));

                    jpegencParams.quality = quality;

                    if ((quality > 0) && (quality <= 100))
                    {
                       handle = &(thrProcess.cellListEncode[index]);

                       thrProcess.cellListEncode[cell_no].cellFxns->cellControl
                       (
                           handle,
                          (IALG_Cmd) (IJPEG_SETSTATUS),
                          (IALG_Status*)(&(jpegencParams))
                       );
                    }
               }

               break;
            }

            default:
                break;
        }
    }
}


extern int SystemReady;


void tskProcess()
{
    int i;
    ScomMessage *pMsgBuf;
    ScomMessage scomMsg;
    void *inBuf[3];
    void *outBuf[3];
    int  jpg_size;
    int framenum=0;
    CHAN_Handle chanHandle;
    SCOM_Handle fromInputtoProc,fromProctoInput;
    SCOM_Handle fromOuttoProc,fromProctoOut;
    SCOM_Handle fromNettoProc,fromProctoNet;

    fromInputtoProc = SCOM_open("INTOPROC");
    fromProctoInput = SCOM_open("PROCTOIN");
    fromProctoOut   = SCOM_open("PROCTOOUT");
    fromOuttoProc   = SCOM_open("OUTTOPROC");
    fromProctoNet   = SCOM_open("PROCTONET");
    fromNettoProc   = SCOM_open("NETTOPROC");

    while(1)
    {
        checkMsg();

        framenum++;

        for(i=0; i<PROCESSNUMCHANNELS; i++)
        {
            // Get Input Buffer
            pMsgBuf = SCOM_getMsg(fromInputtoProc, SYS_FOREVER);

            // If we're skipping this frame, just give the SCOM msg
            // back to the input function and continue the for loop.
            if( thrProcess.frameRateControl[i] != 0 &&
                (framenum % thrProcess.frameRateControl[i]) )
            {
                // Tell the capture routine we're done
                SCOM_putMsg(fromProctoInput,pMsgBuf);
                continue;
            }

            if( netcmdArgs[CMD_SHOWCLOCK] )
                tagScreen( pMsgBuf->bufY );

            //
            // Handle Encode Channel
            //
            chanHandle = &thrProcess.chanListEncode[i];
            chanHandle->state = CHAN_ACTIVE;

            // Channel Input
            inBuf[0] = pMsgBuf->bufY;
            inBuf[1] = pMsgBuf->bufU;
            inBuf[2] = pMsgBuf->bufV;
            ICC_setBuf( chanHandle->cellSet[0].inputIcc[0],
                        inBuf, sizeof(void *) * 3 );

            // Channel Output
            outBuf[0] = &jpg_size;
            outBuf[1] = jpg_img;
            ICC_setBuf( chanHandle->cellSet[0].outputIcc[0],
                        outBuf, sizeof(void *) * 2 );

            // Execute Channel
            CHAN_execute( chanHandle, framenum );

            //
            // Pass JPG to network task
            //
            scomMsg.sizeLinear = jpg_size;
            scomMsg.motion = checkMotion( pMsgBuf->bufY );
            scomMsg.bufLinear  = jpg_img;

            // Tell the capture routine we're done with its buffer
            SCOM_putMsg( fromProctoInput, pMsgBuf );

            // Give the JPG to networking
            SCOM_putMsg( fromProctoNet, &scomMsg );

            // Get our message buffer back from networking
            pMsgBuf = SCOM_getMsg( fromNettoProc, SYS_FOREVER );

            // JPG size may have changed
            jpg_size = pMsgBuf->sizeLinear;

            if( !jpg_size )
                continue;

            //
            // Handle Decode Channel
            //
            chanHandle = &thrProcess.chanListDecode[i];
            chanHandle->state = CHAN_ACTIVE;

            inBuf[0] = &jpg_size;
            inBuf[1] = jpg_img;
            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
            CHAN_execute( chanHandle, framenum );

            if( netcmdArgs[CMD_SHOWDOTS] )
                showMotion( dec_out_y );

            // 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( fromProctoOut, &scomMsg );

            // Get our message buffer back from display
            SCOM_getMsg(fromOuttoProc, SYS_FOREVER);
        }
    }
}




⌨️ 快捷键说明

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