tskVideoInput.c
上传用户:dahaojd
上传日期:2008-01-29
资源大小:14357k
文件大小:2k
- #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"
- 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;
- SCOM_Handle fromInputtoProc,fromProctoInput;
- char *outBuf[3];
- char *inBuf[3];
- ScomMessage scomMsg;
- ScomMessage *pMsgBuf;
- fromInputtoProc = SCOM_open("INTOPROC");
- fromProctoInput = SCOM_open("PROCTOIN");
- FVID_alloc(capChan, &capFrameBuf);
- pMsgBuf = &scomMsg;
- 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 );
- pMsgBuf->bufY = YArray;
- pMsgBuf->bufU = CbArray;
- pMsgBuf->bufV = CrArray;
- SCOM_putMsg(fromInputtoProc, pMsgBuf);
- // Calculate how long it takes to capture one frame
- UTL_stsPeriod( stsCycleTime );
- FVID_exchange(capChan, &capFrameBuf);
- pMsgBuf = SCOM_getMsg(fromProctoInput, SYS_FOREVER);
- }
- }