📄 tskvideoinput.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 "edc.h"
#include "vport.h"
#include "vportcap.h"
#include "evmdm642.h"
#include "saa7115.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;
FVID_Frame *capFrameBuf;
void tskVideoInputInit()
{
int status;
EVMDM642_vCapParamsChan.segId = extHeap;
EVMDM642_vCapParamsSAA7115.hI2C = EVMDM642_I2C_hI2C;
capChan = FVID_create("/VP0CAPTURE/A/0",
IOM_INPUT, &status, (Ptr)&EVMDM642_vCapParamsChan, NULL);
FVID_control(capChan, VPORT_CMD_EDC_BASE+EDC_CONFIG, (Ptr)&EVMDM642_vCapParamsSAA7115);
}
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_In2Enc,hs_Enc2In;
hs_In2Enc = SCOM_open("IN2ENC");
hs_Enc2In = SCOM_open("ENC2IN");
if( !hs_In2Enc || !hs_Enc2In )
{
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;
SCOM_putMsg( hs_In2Enc, &scomMsg );
// Calculate how long it takes to capture one frame
UTL_stsPeriod( stsCycleTime );
// Get back ownership of our linear buffer
SCOM_getMsg( hs_Enc2In, SYS_FOREVER );
// Get a new frame from the capture driver
FVID_exchange(capChan, &capFrameBuf);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -