tskVideoInput.c
上传用户:dahaojd
上传日期:2008-01-29
资源大小:14357k
文件大小:2k
源码类别:

DSP编程

开发平台:

C/C++

  1. #include <std.h>
  2. #include <csl.h>
  3. #include <csl_dat.h>
  4. #include <csl_cache.h>
  5. #include <chan.h>
  6. #include <scom.h>
  7. #include <utl.h>
  8. #include <fvid.h>
  9. #include <tsk.h>
  10. #include "edc.h"
  11. #include "vport.h"
  12. #include "vportcap.h"
  13. #include "evmdm642.h"
  14. #include "saa7115.h"
  15. #include "appMain.h"
  16. #include "appBiosObjects.h"
  17. #include "appThreads.h"
  18. #include "evmdm642_vcapparams.h"
  19. #include "cap_dis_size.h"
  20. static unsigned char YArray[LINE_SZ*NUM_LINES*2];
  21. static unsigned char CbArray[(LINE_SZ*NUM_LINES*2)>>1];
  22. static unsigned char CrArray[(LINE_SZ*NUM_LINES*2)>>1];
  23. /* heap IDs defined in the BIOS configuration file */
  24. extern int extHeap;
  25. FVID_Handle  capChan;
  26. FVID_Frame *capFrameBuf;
  27. void tskVideoInputInit()
  28. {
  29.     int             status;
  30.     EVMDM642_vCapParamsChan.segId = extHeap;
  31.     EVMDM642_vCapParamsSAA7115.hI2C = EVMDM642_I2C_hI2C;
  32.     capChan = FVID_create("/VP0CAPTURE/A/0",
  33.         IOM_INPUT, &status, (Ptr)&EVMDM642_vCapParamsChan, NULL);
  34.     FVID_control(capChan, VPORT_CMD_EDC_BASE+EDC_CONFIG, (Ptr)&EVMDM642_vCapParamsSAA7115);
  35. }
  36. void tskVideoInputStart()
  37. {
  38.     FVID_control(capChan, VPORT_CMD_START, NULL);
  39. }
  40. /* handle video capture, scaling and re-format */
  41. void tskVideoInput()
  42. {
  43.     int frame=0;
  44.     SCOM_Handle fromInputtoProc,fromProctoInput;
  45.     char *outBuf[3];
  46.     char *inBuf[3];
  47.     ScomMessage scomMsg;
  48.     ScomMessage *pMsgBuf;
  49.     fromInputtoProc = SCOM_open("INTOPROC");
  50.     fromProctoInput = SCOM_open("PROCTOIN");
  51.     FVID_alloc(capChan, &capFrameBuf);
  52.     pMsgBuf = &scomMsg;
  53.     while(1)
  54.     {
  55.         frame++;
  56.         UTL_stsStart( stsCapTime );
  57.         inBuf[0]  = capFrameBuf->frame.iFrm.y1;
  58.         inBuf[1]  = capFrameBuf->frame.iFrm.cb1;
  59.         inBuf[2]  = capFrameBuf->frame.iFrm.cr1;
  60.         outBuf[0] =  (char *)YArray;
  61.         outBuf[1] =  (char *)CbArray;
  62.         outBuf[2] =  (char *)CrArray;
  63.         yuv422to420(inBuf,outBuf, 720, 480);
  64.         UTL_stsStop( stsCapTime );
  65.         pMsgBuf->bufY = YArray;
  66.         pMsgBuf->bufU = CbArray;
  67.         pMsgBuf->bufV = CrArray;
  68.         SCOM_putMsg(fromInputtoProc, pMsgBuf);
  69.         // Calculate how long it takes to capture one frame
  70.         UTL_stsPeriod( stsCycleTime );
  71.         FVID_exchange(capChan, &capFrameBuf);
  72.         pMsgBuf = SCOM_getMsg(fromProctoInput, SYS_FOREVER);
  73.     }
  74. }