?? thrcapture.c
字號:
/*
* Copyright 2002 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.
*
*/
/*
* ======== thrCapture.c ========
*/
#include <std.h>
#include <string.h>
// DSP/BIOS includes
#include <tsk.h>
// CSL includes
#include <csl.h>
#include <csl_dat.h>
#include <csl_cache.h>
#include <csl_irq.h>
// RF5 module includes
#include <chan.h>
#include <icell.h>
#include <scom.h>
#include <icc_linear.h>
#include <utl.h>
// DDK module
#include <fvid.h>
// application includes
#include "appResources.h"
#include "appThreads.h"
// Thread include
#include "thrCapture.h"
#include "edc.h"
#include "vport.h"
#include "vportcap.h"
#include "evmdm642.h"
#include "saa7115.h"
#include "evmdm642_vcapparams.h"
//pragmas for buffers
/*
#pragma DATA_SECTION(int_mem_temp, ".INTPROCBUFF");
#pragma DATA_ALIGN(int_mem_temp, MEMALIGN);
*/
//Buffer for interleaved captured image
FVID_Handle capChan;
FVID_Frame *capFrameBuf;
//static Void yuv422to420(char *frameIn[], char *frm_out[],
// int width, int height, int pitch);
/*
#pragma DATA_SECTION(ybuffCap1, ".EXTPROCBUFF");
#pragma DATA_SECTION(crbuffCap1, ".EXTPROCBUFF");
#pragma DATA_SECTION(cbbuffCap1, ".EXTPROCBUFF");
#pragma DATA_ALIGN(ybuffCap1, MEMALIGN);
#pragma DATA_ALIGN(crbuffCap1, MEMALIGN);
#pragma DATA_ALIGN(cbbuffCap1, MEMALIGN);
*/
void yuv422to420( unsigned char *frameIn[], unsigned char *frm_out[],
int width, int height,int pitch);
/*
* ======== thrCaptureInit ========
*
*/
Void thrCaptureInit()
{
SCOM_Handle scomReceive;
int status;
/* create your receiving SCOM queue */
//scomReceive = SCOM_create( "scomCapture", &SCOM_ATTRS );
//UTL_assert( scomReceive != NULL);
EVMDM642_vCapParamsChan.segId = EXTERNALHEAP;
EVMDM642_vCapParamsSAA7115.hI2C = EVMDM642_I2C_hI2C;
// EVMDM642_vCapParamsChan.scale = VPORT_SCALING_ENABLE;
// EVMDM642_vCapParamsChan.fldOp = VPORT_FLDOP_FLD1;
//EVMDM642_vCapParamsChan.thrld >>= 1;
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);
scomReceive = SCOM_create("scomCapture", &SCOM_ATTRS);
UTL_assert( scomReceive != NULL);
}
/*
* ======== thrCaptureStartup ========
*
*/
Void thrCaptureStartup()
{
FVID_control(capChan, VPORT_CMD_START, NULL);
}
/*
* ======== thrCaptureRun ========
*
* Main function of capture thread.
*/
Void thrCaptureRun()
{
SCOM_Handle scomReceive, scomSend;
Int counter = 0;
unsigned char *inBuf[3], *outBuf[3];
UTL_logDebug1("thrCaptureRun: task = 0x%x", TSK_self());
// create the SCOM links (one for receiving and another for sending)
scomReceive = SCOM_open( "scomCapture" );
scomSend = SCOM_open( "scomToProcessFromCapture" );
// scomSend = SCOM_open( "scomDisplay" ); //采集顯示
UTL_assert( scomReceive != NULL );
UTL_assert( scomSend != NULL );
FVID_alloc(capChan, &capFrameBuf);
while (TRUE)
{
ScomCapToProc *scombufCap;
//Counter for measuring frames/sec - use with stopwatch
counter++;
// get the structure describing destination channels
scombufCap = SCOM_getMsg( scomReceive, SYS_FOREVER );
//convert 422 to 420
inBuf[Y] = (unsigned char *)capFrameBuf->frame.iFrm.y1;
inBuf[CR] = (unsigned char *)capFrameBuf->frame.iFrm.cr1;
inBuf[CB] = (unsigned char *)capFrameBuf->frame.iFrm.cb1;
outBuf[Y] = (unsigned char *)scombufCap->bufYCRCB[Y];
outBuf[CR] = (unsigned char *)scombufCap->bufYCRCB[CR];
outBuf[CB] = (unsigned char *)scombufCap->bufYCRCB[CB];
CACHE_wbL2(inBuf[Y], PROCF_WIDTH*PROCF_HEIGHT,CACHE_WAIT);
CACHE_wbL2(inBuf[CR],PROCF_WIDTH*(PROCF_HEIGHT>>1),CACHE_WAIT);
CACHE_wbL2(inBuf[CB],PROCF_WIDTH*(PROCF_HEIGHT>>1),CACHE_WAIT);
CACHE_wbL2(outBuf[Y], PROCF_WIDTH*PROCF_HEIGHT,CACHE_WAIT);
CACHE_wbL2(outBuf[CR],(PROCF_WIDTH>>1)*(PROCF_HEIGHT>>1),CACHE_WAIT);
CACHE_wbL2(outBuf[CB],(PROCF_WIDTH>>1)*(PROCF_HEIGHT>>1),CACHE_WAIT);
//d1==>cif==>d1
// yuv422to420(inBuf, outBuf, PROCF_WIDTH, PROCF_HEIGHT, PROCF_WIDTH);
yuv422to420(inBuf, outBuf, PROCF_WIDTH, PROCF_HEIGHT, CAPF_WIDTH);
//cif==>d1
// yuv422to420(inBuf, outBuf, PROCF_WIDTH, CAPF_HEIGHT, CAPF_WIDTH);
// Calculate how long it takes to capture + display one frame
UTL_stsPeriod( stsCycleTime );
// send the now full buffer to Process
SCOM_putMsg( scomSend, scombufCap );
FVID_exchange(capChan, &capFrameBuf); //Passes full buffer, recieves empty
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -