📄 tskprocess.c
字号:
#include <std.h>
#include <tsk.h>
#include <stdio.h>
#include <time.h>
#include <csl.h>
#include <csl_cache.h>
#include <csl_dat.h>
#include <chan.h>
#include <scom.h>
#include <utl.h>
#include <ialg.h>
#include "fvid.h"
#include "celljpegenc_ti.h"
#include "celljpegdec_ti.h"
#include "appmain.h"
#include "appThreads.h"
#include "tskProcess.h"
#include "appBiosObjects.h"
#include "netmain.h" /*change*/
//#include "cap_dis_size.h"
IJPEGENC_Params jpegencParams;
IJPEGDEC_Params jpegdecParams;
#pragma DATA_SECTION(jpg_img, ".user_data_ext")
#pragma DATA_ALIGN( jpg_img, 128)
unsigned char jpg_img[128 * 2000];
#pragma DATA_ALIGN(dec_out_y, 128);
#pragma DATA_ALIGN(dec_out_u, 128);
#pragma DATA_ALIGN(dec_out_v, 128);
unsigned char dec_out_y[720 * 480];
unsigned char dec_out_u[360 * 240];
unsigned char dec_out_v[360 * 240];
static Void checkMsg();
/*
// Simple Motion Detection
//
// This code puts "sensors" on the screen and checks them
// for change in intensity. A sensor is "tripped" when
// there is a change in intensity beyond a set threshold.
//
*/
#define SPACING 40 /* Pixel spacing of "sensor" */
#define YDELTATHRESH 12 /* Max delta Y the will not trip "sensor" */
#define PIXPERSAMPLE 2 /* Number of pixels per sample location */
#define SENSBUFSIZE 128*4 /* Must be multiple of 128 & large enough */
#define XPIX (720/SPACING)
#define YPIX (480/SPACING)
#define PIXOFF(n) ((n*SPACING)+(SPACING/2))
#define SAMPLES (XPIX*YPIX)
#if (SAMPLES*PIXPERSAMPLE) > SENSBUFSIZE
#error "BUFFER SIZE"
#endif
#pragma DATA_SECTION(img_sum1, ".user_data_ext")
#pragma DATA_ALIGN( img_sum1, 128)
unsigned char img_sum1[SENSBUFSIZE];
#pragma DATA_SECTION(img_sum2, ".user_data_ext")
#pragma DATA_ALIGN( img_sum2, 128)
unsigned char img_sum2[SENSBUFSIZE];
unsigned char *img_sum[2] = { img_sum1, img_sum2 };
#pragma DATA_SECTION(dec_data, ".user_data_ext")
#pragma DATA_ALIGN( dec_data, 128)
unsigned char dec_data[SENSBUFSIZE];
#pragma DATA_SECTION(tag_data, ".user_data_ext")
#pragma DATA_ALIGN( tag_data, 128)
unsigned char tag_data[384 * 32];
#define TAGPITCH 336
extern unsigned char charset;
static void drawchar( unsigned char *ps, unsigned char c )
{
int y,i;
unsigned char cdata;
unsigned char *pc = &charset + ((c-32)*16);
for( y=0; y<16; y++ )
{
cdata = *pc++;
for(i=0; i<8; i++)
{
if( cdata & 1 )
{
*(ps) = 0xFF;
*(ps+1) = 0xFF;
*(ps+TAGPITCH) = 0xFF;
*(ps+TAGPITCH+1) = 0xFF;
}
cdata >>= 1;
ps += 2;
}
ps += TAGPITCH*2 - 16;
}
}
static void drawstring( unsigned char *pBuf, char *pString )
{
unsigned char c;
while( c = *pString++ )
{
drawchar( pBuf, c );
pBuf += 16;
}
}
static void tagScreen( unsigned char *pY )
{
int y;
uint ms;
struct tm *ptm;
time_t secs;
char str[32];
secs = llTimerGetTime(&ms) + netcmdArgs[CMD_SETCLOCK];
ptm = localtime(&secs);
if( ptm->tm_year >= 30 )
ptm->tm_year -= 30;
else
ptm->tm_year += 70;
sprintf( str, "%02d/%02d/%02d %02d:%02d:%02d:%02d",
ptm->tm_mon+1, ptm->tm_mday, ptm->tm_year,
ptm->tm_hour, ptm->tm_min, ptm->tm_sec, ms/10 );
memset( tag_data, 0, 384 * 32);
drawstring( tag_data+8, str );
OEMCacheClean( tag_data, TAGPITCH*32 );
OEMCacheCleanSynch();
for( y=0; y<32; y++ )
DAT_copy( tag_data+(TAGPITCH*y), pY+(720*424)+(720*y)+32, TAGPITCH );
}
static int checkMotion( unsigned char *pY )
{
static int idx = 0;
int x,y,i;
idx ^= 1;
OEMCacheClean( img_sum[idx], SAMPLES*PIXPERSAMPLE );
OEMCacheCleanSynch();
i = 0;
for( y=0; y<YPIX; y++ )
for( x=0; x<XPIX; x++ )
{
DAT_copy( pY + PIXOFF(x) + (PIXOFF(y)*720),
img_sum[idx] + i, PIXPERSAMPLE );
i += PIXPERSAMPLE;
}
x = 0;
if( !netcmdArgs[CMD_SHOWDOTS] )
{
for( i=0; i<SAMPLES * PIXPERSAMPLE; i++ )
{
y = (int)img_sum1[i] - (int)img_sum2[i];
if( y < -YDELTATHRESH || y > YDELTATHRESH )
x++;
}
}
else
{
for( i=0; i<SAMPLES * PIXPERSAMPLE; i++ )
{
y = (int)img_sum1[i] - (int)img_sum2[i];
if( y < -YDELTATHRESH || y > YDELTATHRESH )
{
x++;
dec_data[i] = 0xFF;
}
else
{
dec_data[i] = 0x0;
}
}
}
// Return change in "tenths of percent"
return( (x*1000)/(SAMPLES*PIXPERSAMPLE) );
}
static void showMotion( unsigned char *pY )
{
int x,y,i;
OEMCacheClean( dec_data, SAMPLES*PIXPERSAMPLE );
OEMCacheCleanSynch();
i = 0;
for( y=0; y<YPIX; y++ )
for( x=0; x<XPIX; x++ )
{
DAT_copy( dec_data + i, pY + PIXOFF(x) + (PIXOFF(y)*720),
PIXPERSAMPLE );
i += PIXPERSAMPLE;
}
}
ThrProcess thrProcess;
void tskProcessInit()
{
int chanNum;
ICELL_Obj *cell;
ICC_Handle inputIcc;
ICC_Handle outputIcc;
/*----------------------------------------------------*/
/* Call JPEG specific user initialization if any. */
/*----------------------------------------------------*/
JPEGENC_TI_init();
JPEGDEC_TI_init();
/*----------------------------------------------------*/
/* Set up params for all XDAIS algorithms. */
/*----------------------------------------------------*/
jpegencParams = IJPEGENC_PARAMS;
jpegdecParams = IJPEGDEC_PARAMS;
for (chanNum = 0; chanNum < PROCESSNUMCHANNELS ; chanNum++)
{
/*
* JPEGENC: create an input and output linear ICC:
* The address to the ICC's will be set in the thrProcessRun()
* function via the ICC_setBuf().
*/
ICELL_Obj defaultCell = ICELL_DEFAULT;
cell = &thrProcess.cellListEncode[(chanNum*PROCESSNUMCELLS) + 0];
*cell = defaultCell;
cell->name = "JPEGENC";
cell->cellFxns = &JPEGENC_CELLFXNS;
cell->algFxns = (IALG_Fxns *)&JPEGENC_IJPEGENC;
cell->algParams = (IALG_Params *)&IJPEGENC_PARAMS;
cell->scrBucketIndex = THRIOSSCRBUCKET;
inputIcc = (ICC_Handle)ICC_linearCreate(NULL, 0);
UTL_assert( inputIcc != NULL);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -