📄 tskvideoinput.c
字号:
/*
* Copyright 2003 by Texas Instruments Incorporated.
* All rights reserved. Property of Texas Instruments Incorporated.
* Restricted rights to use, duplicate or disclose this code are
* granted through contract.
*
*/
#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 <tvp51xx.h>
#include <evmdm642.h>
#include <evmdm642_capParamsSDTVDefault.h>
#include "appMain.h"
#include "appThreads.h"
#include "tskVideoInput.h"
VPORT_PortParams EVMDM642_vCapParamsPort
= EVMDM642_CAP_PARAMS_PORT_EMBEDDED_DEFAULT;
#if defined _NTSC
static VPORTCAP_Params EVMDM642_vCapParamsChan
= EVMDM642_CAP_PARAMS_CHAN_EMBEDDED_DEFAULT(NTSC720);
static TVP51XX_ConfParams EVMDM642_vCapParamsTVP5146
= EVMDM642_CAP_PARAMS_TVP51XX_EMBEDDED_DEFAULT(NTSC601, COMPOSITE, 0);
#elif defined _PAL
static VPORTCAP_Params EVMDM642_vCapParamsChan
= EVMDM642_CAP_PARAMS_CHAN_EMBEDDED_DEFAULT(PAL720);
static TVP51XX_ConfParams EVMDM642_vCapParamsTVP5146
= EVMDM642_CAP_PARAMS_TVP51XX_EMBEDDED_DEFAULT(PAL601, COMPOSITE, 0);
#endif
ThrInput thrInput;
unsigned char* yuvBufIp[3];
unsigned char yBuf[LINE_SZ * NUM_LINES];
unsigned char cbBuf[LINE_SZ * NUM_LINES>>2];
unsigned char crBuf[LINE_SZ * NUM_LINES>>2];
FVID_Handle capChan;
FVID_Frame *capFrameBuf;
void tskVideoInputInit()
{
int status;
yuvBufIp[0] = yBuf;
yuvBufIp[1] = cbBuf;
yuvBufIp[2] = crBuf;
/******************************************************/
/* allocate capture frame buffers */
/* in external heap memory */
/******************************************************/
EVMDM642_vCapParamsChan.segId = extHeap ;//EXTERNALHEAP;
EVMDM642_vCapParamsTVP5146.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_vCapParamsTVP5146);
}
/*-----------------------------------------------------------*/
/*Start the capturing */
/*-----------------------------------------------------------*/
void tskVideoInputStart()
{
FVID_control(capChan, VPORT_CMD_START, NULL);
}
/*-----------------------------------------------------------*/
/* handle video capture, scaling and re-format */
/*-----------------------------------------------------------*/
void tskVideoInput()
{
char *ycbcrBuf[3];
SCOM_Handle fromInputtoProc,fromOuttoInput;
fromInputtoProc = SCOM_open("INTOPROC");
fromOuttoInput = SCOM_open("OUTTOIN");
FVID_alloc(capChan, &capFrameBuf);
while(1)
{
ycbcrBuf[0] = capFrameBuf->frame.iFrm.y1;
ycbcrBuf[1] = capFrameBuf->frame.iFrm.cb1;
ycbcrBuf[2] = capFrameBuf->frame.iFrm.cr1;
/*-----------------------------------------------------------*/
/* Call YUV422to420v to do chroma resampling */
/*-----------------------------------------------------------*/
yuv422to420(ycbcrBuf,yuvBufIp,LINE_SZ, NUM_LINES);
/*-----------------------------------------------------------*/
/* Send message to process task with pointers to captured frame*/
/*-----------------------------------------------------------*/
(thrInput.scomMsgTx).bufChannel = (void *)&yuvBufIp[0];
SCOM_putMsg(fromInputtoProc, &(thrInput.scomMsgTx));
/*-----------------------------------------------------------*/
/* Capture a new frame. */
/*-----------------------------------------------------------*/
FVID_exchange(capChan, &capFrameBuf);
/*-----------------------------------------------------------*/
/* Wait for the message from the process task */
/*-----------------------------------------------------------*/
SCOM_getMsg(fromOuttoInput, SYS_FOREVER);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -