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

📄 tskvideoinput.c

📁 TI公司的DM642 DSP上开发的MPEG2编码源码
💻 C
字号:
#include <std.h>
#include <csl.h>
#include <csl_dat.h>
#include <csl_cache.h>
#include <chan.h>
#include <scom.h>
#include <utl.h>
#include <fvid.h>
#include <tsk.h>
#include <hwi.h>
#include "edc.h"

#include "vport.h"
#include "vportcap.h"

#include "seeddm642.h"
#include "seedvpm642_vcapparams.h"

#include "appMain.h"
#include "appBiosObjects.h"
#include "appThreads.h"

#include "evmdm642_vcapparams.h"
#include "cap_dis_size.h"

#pragma DATA_ALIGN( YArray, 128)
#pragma DATA_ALIGN( CbArray, 128)
#pragma DATA_ALIGN( CrArray, 128)
static unsigned char YArray[LINE_SZ*NUM_LINES*2];
static unsigned char CbArray[(LINE_SZ*NUM_LINES*2)>>1];
static unsigned char CrArray[(LINE_SZ*NUM_LINES*2)>>1];

/* heap IDs defined in the BIOS configuration file */
extern int extHeap;

FVID_Handle  capChan;
int i=0;
int j= 0;
int ledturn = 0;
int videotimeout = 0;
int videorestart = 0;
FVID_Frame *capFrameBuf;
int CaptureIntFlag = 0;

void IntrruptForCapture(Arg id, Arg mask)
{
	CaptureIntFlag = 1;		
}

void tskVideoInputInit()
{

    int             status;

    SEEDVPM642_vCapParamsChan.segId = extHeap;
    SEEDVPM642_vCapParamsTVP5150.hI2C = SEEDVPM642_I2C_hI2C;

    /******************************************************/
    /* initialization of capture driver                   */
    /******************************************************/
	/*打开第一通路*/
	capChan  = FVID_create(	"/VP1ACAPTURE/A/1", 
            				    IOM_INPUT, 
            				    &status, 
            				    (Ptr)&SEEDVPM642_vCapParamsChan, 
            				    NULL); 

    /******************************************************/
    /* configure video encoder 			                  */
    /******************************************************/
    /*配置第一通路的TVP5150*/
    FVID_control( capChan, 
    			  VPORT_CMD_EDC_BASE+EDC_CONFIG, 
        		  (Ptr)&SEEDVPM642_vCapParamsTVP5150);
    /******************************************************/
    /* configure video encoder  intrrupt call back        */
    /*****************************************************
    FVID_control( capChan, 
    			  VPORT_CMD_SET_VINTCB, 
        		  (Ptr)&SEEDVPM642_vCapParamsInt);*/
}

void tskVideoInputStart()
{
    FVID_control(capChan, VPORT_CMD_START, NULL);
}



/* handle video capture, scaling and re-format */
void tskVideoInput()
{
    int frame=0;
    char *outBuf[3];
    char *inBuf[3];
    ScomMessage scomMsg;
    SCOM_Handle hs_In2Out,hs_Out2In;

    hs_In2Out  = SCOM_open("IN2OUT");
    hs_Out2In  = SCOM_open("OUT2IN");

    if( !hs_In2Out || !hs_Out2In )
    {
        for(;;);
    }

    FVID_alloc(capChan, &capFrameBuf);

    while(1)
    {
//        frame++;

        UTL_stsStart( stsCapTime );

        inBuf[0]  = capFrameBuf->frame.iFrm.y1;
        inBuf[1]  = capFrameBuf->frame.iFrm.cb1;
        inBuf[2]  = capFrameBuf->frame.iFrm.cr1;

        outBuf[0] =  (char *)YArray;
        outBuf[1] =  (char *)CbArray;
        outBuf[2] =  (char *)CrArray;

        yuv422to420(inBuf,outBuf, 720, 480);

        UTL_stsStop( stsCapTime );

        // Pass the frame to the input task
        scomMsg.bufY = YArray;
        scomMsg.bufU = CbArray;
        scomMsg.bufV = CrArray;
        LOG_printf(&trace,"Prepared to put msg to output.\n");
        SCOM_putMsg( hs_In2Out, &scomMsg );
        LOG_printf(&trace,"Passed msg to output.\n");
		videotimeout = 0;
        // Calculate how long it takes to capture one frame
        UTL_stsPeriod( stsCycleTime );

        // Get back ownership of our linear buffer
        LOG_printf(&trace,"Waiting to get msg back from output.\n");
        SCOM_getMsg( hs_Out2In, SYS_FOREVER );
        LOG_printf(&trace,"Got msg back from output.\n");
		//set the video link erro
		if(frame++ ==3)
		{
			videorestart= 1;
		}
		if(videorestart==1)
		{
			videotimeout = 0;	
		}
        // Get a new frame from the capture driver
        FVID_exchange(capChan, &capFrameBuf); 
    }
}

⌨️ 快捷键说明

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