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

📄 tskprocess.c

📁 TI公司C6000系列DSP(DM642)模拟视频采集与回显源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
 *  Copyright 2003 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
// MPEG-2 loop back tskprocess.c file
#include <std.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 "fvid.h"
#include "cellmpeg2enc.h"  
#include "cellmpeg2dec.h"   
#include "appmain.h"
#include "appThreads.h"
#include "tskProcess.h"          
#include "impeg2vdec.h"

void readparamfile(char *fname,IMPEG2VENC_Params *mpeg2veparam);

/*Input requirements for MPEG-2 decoder module */
#define	MAX_PICT_SIZE		0x098800		/* 610KB.  Enough for 720x576 4:2:0. */
#define		NO_OF_FRAME_BUF			4
#pragma	DATA_ALIGN(frame_all_storage, 32)
far unsigned char frame_all_storage[NO_OF_FRAME_BUF * MAX_PICT_SIZE];
int out_para[40];

/*Buffer to store the bitstream generated by encoder to be passed on to dcoder*/
unsigned char  bitBuf[BIT_BUF_SIZE];

ThrProcess thrProcess;

IMPEG2VDEC_Params mpeg2decParams;
IMPEG2VENC_Params mpeg2encParams;
ICC_Handle  inputIcc;
ICC_Handle  outputIcc;
/*Parameter filename: the parameters for encoding are read from this file */
char hname[80]="test.par";
unsigned int *out[3];

void tskProcessInit()
{
	int chanNum;
	ICELL_Obj  *cell;
    
    /*---------------------------------------------------------*/
    /* Read Parameters from the parameter file                 */
    /*---------------------------------------------------------*/
    readparamfile(hname,&mpeg2encParams);
    
   	mpeg2encParams.outstream = (unsigned int *)bitBuf;
	mpeg2encParams.h_recon_all = 0;
    
    thrProcess.bufIntermediate = bitBuf; 
    
    
    for (chanNum = 0; chanNum < PROCESSNUMCHANNELS ; chanNum++) 
    {

        /*------------------------------------------------------------*/ 
    	/*  register the cells: define what will be input buffers and */
    	/*  what will be output buffers for each cell.                */
    	/*------------------------------------------------------------*/
             
        /*------------------------------------------------------*/
        /*Preparing and registering the MPEG-2 enc cell         */
        /*------------------------------------------------------*/

        /*-----------------------------------------------------------*/
        /* Setup a default cell used to initialize the actual cells  */
        /*-----------------------------------------------------------*/
        ICELL_Obj   defaultCell = ICELL_DEFAULT;

        cell = &thrProcess.cellList[ (chanNum * PROCESSNUMCELLS ) + CELLMPEG2ENC];
        *cell                = defaultCell;
        cell->name           = "MPEG2ENC";
        cell->cellFxns       = &MPEG2ENC_CELLFXNS;            
        cell->algFxns        = (IALG_Fxns *)&MPEG2ENC_IMPEG2ENC;
        cell->algParams      = (IALG_Params *)&mpeg2encParams;
        cell->scrBucketIndex = THRPROCESSSCRBUCKET;

        /*-----------------------------------------------------------*/
        /* Create the inputICC: object used as input interface to the*/ 
        /* enocoder cell                                             */
        /*-----------------------------------------------------------*/
        inputIcc  = (ICC_Handle)ICC_linearCreate( 
                               thrProcess.bufInput[ chanNum ], 
                               sizeof(unsigned char*)*3);
        UTL_assert( inputIcc != NULL);

        
       	/*-----------------------------------------------------------*/
        /* Create the outputICC: object used as output interface to  */ 
        /* enocoder cell                                             */
        /*-----------------------------------------------------------*/
        outputIcc = (ICC_Handle)ICC_linearCreate( 
                                            thrProcess.bufIntermediate,
                                            sizeof(BIT_BUF_SIZE));
        UTL_assert( outputIcc != NULL);

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

        thrProcess.cellList[ (chanNum * PROCESSNUMCELLS) + CELLMPEG2ENC].algParams = 
            (IALG_Params *)&mpeg2encParams;
           
            
        /*------------------------------------------------------*/
        /*Preparing and registering the MPEG-2 dec cell         */
        /*------------------------------------------------------*/
                 
     	cell = &thrProcess.cellList[ (chanNum * PROCESSNUMCELLS ) + CELLMPEG2DEC];
        *cell                = defaultCell;
        cell->name           = "MPEG2DEC";
        cell->cellFxns       = &MPEG2DEC_CELLFXNS;            
        cell->algFxns        = (IALG_Fxns *)&MPEG2DEC_IMPEG2DEC;
        cell->algParams      = (IALG_Params *)&mpeg2decParams;
        cell->scrBucketIndex = THRPROCESSSCRBUCKET;

		
		/*------------------------------------------------------------*/
        /* Input ICC will be for decdoer will be same as output ICC   */
        /* for the encoder cell                                       */
        /*------------------------------------------------------------*/
		inputIcc  =  outputIcc;


        /*-----------------------------------------------------------*/
        /* Create the outputICC: object used as output interface to  */ 
        /* decoder cell                                              */
        /*-----------------------------------------------------------*/
		outputIcc = (ICC_Handle)ICC_linearCreate( 
                                            thrProcess.bufOutput[ chanNum ],
                                            sizeof(unsigned char*)*3);
        UTL_assert( outputIcc != NULL);

        /*------------------------------------------------------------*/
        /* Only one input and one output ICC are needed.              */
        /*------------------------------------------------------------*/
        CHAN_regCell( cell, &inputIcc, 1, &outputIcc, 1 );
        
        thrProcess.cellList[ (chanNum * PROCESSNUMCELLS) + CELLMPEG2DEC].algParams = 
            (IALG_Params *)&mpeg2decParams;
    
        UTL_logDebug1("Channel Number: %d", chanNum);

    }                  
}                   

/*-------------------------------------------------------*/
/* Create the channel instance : the cell algorithms will*/
/* be instantiated                                       */
/*-------------------------------------------------------*/
void tskProcessStart() 
{
	int chanNum;
	Bool rc;
	for (chanNum = 0; chanNum < PROCESSNUMCHANNELS ; chanNum++) 
	{
		/*------------------------------------------------------------*/
   		/* Open the channel: this causes the algorithms to be created */
        /*------------------------------------------------------------*/
		rc = CHAN_open( &thrProcess.chanList[ chanNum ], 
	                &thrProcess.cellList[ chanNum * PROCESSNUMCELLS ], 
	                PROCESSNUMCELLS ,
	                NULL );
	}
	
	UTL_assert( rc == TRUE );
}


volatile unsigned int frameIdx = 0;
/*-------------------------------------------------------*/
/* The task will handle the processing part :            */
/* -Will get the message from the Input task with input  */
/*  frame pointers                                       */
/* -Will execute the channel to encode followed by decode*/
/* -Will pass the decoded frame pointers to output task  */
/*-------------------------------------------------------*/
void tskProcess()
{
    int i;
    int chanNum;
    Bool rc;
    ScomBufChannels *pMsgBuf;  
              
    DECODE_OUT *decode_out;
    IMPEG2VENC_Status  encstatus;
    char *frame[3];
    unsigned int *bufs;
    
    SCOM_Handle fromInputtoProc,fromProctoOut;
    fromInputtoProc = SCOM_open("INTOPROC");
    fromProctoOut   = SCOM_open("PROCTOOUT");
        
    
    while(1)
    {
        for(i = 0; i<PROCESSNUMCHANNELS; i++) 
        {

	 	    /*-----------------------------------------------------------*/
		  	/* Wait for the message from  input task to recieve captured */
  			/* frame to be cycled through encoding and decoding.
   			/*-----------------------------------------------------------*/
	 	     pMsgBuf = SCOM_getMsg(fromInputtoProc, SYS_FOREVER);

⌨️ 快捷键说明

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