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

📄 tskvideocapturevp2.c

📁 在DM642上实现双通道采集并实现了实时匹配
💻 C
字号:

/*
 *  Copyright 2004 by SEED Incorporated.
 *  All rights reserved. Property of SEED Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
#include <std.h>
#include <tsk.h>
#include <vport.h>
#include <vportcap.h>
#include <tvp51xx.h> 
#include <csl_edma.h>
#include <fvid.h>
#include <csl_dat.h>
#include <csl_cache.h>
#include <scom.h>

#include "seeddm642.h"
#include "seedvpm642cfg.h"
#include "seedvpm642_vcapparams.h"
//#include "seedvpm642_tskvp2a.h"
#pragma DATA_ALIGN(Y2Array,8)
#pragma DATA_ALIGN(Cb2Array,8)
#pragma DATA_ALIGN(Cr2Array,8)
#pragma DATA_SECTION(Y2Array,".spec_data")
#pragma DATA_SECTION(Cb2Array,".spec_data")
#pragma DATA_SECTION(Cr2Array,".spec_data")
   
unsigned char Y2Array[288*720*2];
unsigned char Cb2Array[(288*720*2)>>1];
unsigned char Cr2Array[(288*720*2)>>1];
//extern MBX_Obj VP2CAPTURE;
extern int EXTERNALHEAP;
FVID_Handle capChanCh2;
FVID_Frame *capFrameBuf2;
/*
 * ======== tskVideoCaptureVp2Init ========
 * video capture function init.
 */
void VideoCaptureVp2Init()
{
	int status;
	SEEDVPM642_vCapParamsChan.segId = EXTERNALHEAP ;//EXTERNALHEAP;
    SEEDVPM642_vCapParamsTVP5150.hI2C = SEEDVPM642_I2C_hI2C; /*打开驱动程序*/  

	/******************************************************/
    /* initialization of capture driver                   */
    /******************************************************/
	/*打开第二通路*/
	
	capChanCh2  = FVID_create(	"/VP2CAPTURE/A/1", 
            				    IOM_INPUT, 
            				    &status, 
            				    (Ptr)&SEEDVPM642_vCapParamsChan, 
            				    NULL); 
    	
    /******************************************************/
    /* configure video encoder 			                  */
    /******************************************************/
    /*配置第一通路的TVP5150*/
    FVID_control( capChanCh2, 
    			  VPORT_CMD_EDC_BASE+EDC_CONFIG, 
        		  (Ptr)&SEEDVPM642_vCapParamsTVP5150);	
}
/*
 * ======== tskVideoCaptureVp1Start ========
 * video capture function start.
 */
void VideoCaptureVp2Start()
{
	/*启动采集*/     		  
    FVID_control(capChanCh2, VPORT_CMD_START, NULL);
}
/*
 * ======== tskVideoCaptureVp2 ========
 * video capture function.
 */
void tskVideoCaptureVp2()
{
	
    SCOM_Handle fromInput2toPRO,fromPROtoInput2;
    char *out2Buf[3];
    char *in2Buf[3];
    ScomMessage scomMsg2;
    ScomMessage *pMsgBuf2;

    fromInput2toPRO = SCOM_open("IN2TOPRO");
    fromPROtoInput2 = SCOM_open("PROTOIN2");
    
    FVID_alloc(capChanCh2, &capFrameBuf2);

    pMsgBuf2 = &scomMsg2;

    while(1)
    {
        int i;

        //UTL_stsStart( stsCapTime );

        in2Buf[0]  = capFrameBuf2->frame.iFrm.y2;
        in2Buf[1]  = capFrameBuf2->frame.iFrm.cb2;
        in2Buf[2]  = capFrameBuf2->frame.iFrm.cr2;

        out2Buf[0] =  (char *)Y2Array;
        out2Buf[1] =  (char *)Cb2Array;
        out2Buf[2] =  (char *)Cr2Array;
        
        for(i = 0; i < 576; i ++) 
        {
            
			DAT_copy(in2Buf[0] + i * 720, 
                     out2Buf[0]+i*720,
                     720);
            DAT_copy(in2Buf[1] + i * (720 >> 1), 
                     out2Buf[1]+i*(720>>1),
                     720>>1);

            DAT_copy(in2Buf[2] + i * (720 >> 1), 
                     out2Buf[2] + i * (720>> 1),
                     720>>1);
        }
		DAT_wait(DAT_XFRID_WAITALL);
		//CACHE_clean(CACHE_L2ALL,NULL,NULL);
        //yuv422to420(in2Buf,out2Buf, 720, 576);

        //UTL_stsStop( stsCapTime );

        pMsgBuf2->bufY = Y2Array;
        pMsgBuf2->bufU = Cb2Array;
        pMsgBuf2->bufV = Cr2Array;
        SCOM_putMsg(fromInput2toPRO, pMsgBuf2);
        
        // Calculate how long it takes to capture one frame
        //UTL_stsPeriod( stsCycleTime );

        FVID_exchange(capChanCh2, &capFrameBuf2);

        //pMsgBuf2 = SCOM_getMsg(fromPROtoInput2, SYS_FOREVER);
       	    
	}	
}

⌨️ 快捷键说明

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