📄 thrprocess.c
字号:
cell->scrBucketIndex = VIDEOPROCSCRBUCKET;
inputIcc = (ICC_Handle)ICC_linearCreate( NULL, 0);
UTL_assert( inputIcc != NULL);
outputIcc = (ICC_Handle)ICC_linearCreate( bufYCRCB,
sizeof(bufYCRCB));
UTL_assert( outputIcc != NULL);
rc = CHAN_regCell ( cell, &inputIcc, 1, &outputIcc, 1 );
/*
* cell 1 - ROTATE: create an input and output linear ICC.
*/
cell = &thrProcess.comboCells[
chanNum * CHCOMBONUMCELLS + CHCOMBOCELLROTATE];
*cell = defaultCell;
cell->name = "ROTATE";
cell->cellFxns = &ROTATE_CELLFXNS;
cell->cellEnv = (Ptr *)&thrProcess.rotateEnv[chanNum + NUMROTATECHANS];
cell->algFxns = (IALG_Fxns *)&ROTATE_IROTATE;
cell->algParams = (IALG_Params *)&rotateParams;
cell->scrBucketIndex = VIDEOPROCSCRBUCKET;
inputIcc = (ICC_Handle)ICC_linearCreate(
bufYCRCB, sizeof(bufYCRCB));
UTL_assert( inputIcc != NULL);
outputIcc = (ICC_Handle)ICC_linearCreate( &thrProcess.OutputBuff,
sizeof(thrProcess.OutputBuff));
UTL_assert( outputIcc != NULL);
rc = CHAN_regCell ( cell, &inputIcc, 1, &outputIcc, 1 );
}
}
else {
// Open the channels
//Open Pass thru chans
//Pass-thru channel does not need to be opened
//Open Diff chans
for (chanNum = 0; chanNum < NUMDIFFCHANS; chanNum++) {
// Set the algorithm's parameters
thrProcess.diffCells[chanNum * CHDIFFNUMCELLS].algParams =
(IALG_Params *)&diffParams;
// Open the channel
UTL_logDebug1("Process: Diff Channel Number: %d", chanNum);
rc = CHAN_open( &thrProcess.diffChans[chanNum],
&thrProcess.diffCells[chanNum * CHDIFFNUMCELLS],
CHDIFFNUMCELLS, NULL );
UTL_assert( rc == TRUE );
}
//Open Rotate chans
for (chanNum = 0; chanNum < NUMROTATECHANS; chanNum++) {
// Set the algorithm's parameters
thrProcess.rotateCells[chanNum * CHROTATENUMCELLS].algParams =
(IALG_Params *)&rotateParams;
// Open the channel
UTL_logDebug1("Process: Rotate Channel Number: %d", chanNum);
rc = CHAN_open( &thrProcess.rotateChans[chanNum],
&thrProcess.rotateCells[chanNum * CHROTATENUMCELLS],
CHROTATENUMCELLS, NULL );
UTL_assert( rc == TRUE );
}
//Open Combo chans
for (chanNum = 0; chanNum < NUMCOMBOCHANS; chanNum++) {
// Set the algorithm's parameters
thrProcess.comboCells[chanNum * CHCOMBONUMCELLS].algParams =
(IALG_Params *)&diffParams;
thrProcess.comboCells[
chanNum * CHCOMBONUMCELLS + CHCOMBOCELLROTATE].algParams =
(IALG_Params *)&rotateParams;
// Open the channel
UTL_logDebug1("Process: Combo Channel Number: %d", chanNum);
rc = CHAN_open( &thrProcess.comboChans[chanNum],
&thrProcess.comboCells[chanNum * CHCOMBONUMCELLS],
CHCOMBONUMCELLS, NULL );
UTL_assert( rc == TRUE );
}
}
}
static Void checkMsg()
{
CtrlMsg rxMsg;
Int index;
// check message in "mbxProc"
while( MBX_pend( &mbxProcess, &rxMsg, 0) ) {
switch (rxMsg.cmd) {
case MSGNEWREFERENCE: //setting a new reference frame
thrProcess.diffEnv->SetReference = TRUE;
break;
case MSGNEWCOLOR: //change color of unequal pixels
for (index = 0; index < (NUMDIFFCHANS + NUMCOMBOCHANS); index++)
{
thrProcess.diffEnv[index].yValue = rxMsg.arg1;
thrProcess.diffEnv[index].crValue = rxMsg.arg2 >> 8;
thrProcess.diffEnv[index].cbValue = rxMsg.arg2 % 256;
}
break;
default:
break;
}
}
}
/*
* ======== thrProcessRun ========
*
* Main function of Process Thread.
*/
Void thrProcessRun()
{
CHAN_Handle chan;
Int prevYId;
Int prevCrId;
Int prevCbId;
UTL_logDebug1("thrProcessRun: task = 0x%x", TSK_self());
// open SCOM queues for sending messages to other tasks
scomSendToCapture = SCOM_open( "scomCapture" );
scomSendToDisplay = SCOM_open( "scomDisplay" );
UTL_assert( scomSendToCapture != NULL);
UTL_assert( scomSendToDisplay != NULL);
// processed buffers
memset(ybuff, 0x00, PROCF_SIZE_IN_PIXELS);
memset(crbuff, 0x80, PROCF_SIZE_IN_PIXELS >> 2);
memset(cbbuff, 0x80, PROCF_SIZE_IN_PIXELS >> 2);
//Clear Capture and Display SCOM buffers
memset(ybuffCap, 0x00, PROCF_SIZE_IN_PIXELS);
memset(crbuffCap, 0x80, PROCF_SIZE_IN_PIXELS >> 2);
memset(cbbuffCap, 0x80, PROCF_SIZE_IN_PIXELS >> 2);
memset(ybuffDis, 0x00, OPF_SIZE_IN_PIXELS);
memset(crbuffDis, 0x80, OPF_SIZE_IN_PIXELS >> 2);
memset(cbbuffDis, 0x80, OPF_SIZE_IN_PIXELS >> 2);
// put the Rx message on the SCOM queue for Capture thread
SCOM_putMsg( scomSendToCapture, &thrProcess.scombufCap );
// put the Tx message on the SCOM queue for Display thread
SCOM_putMsg( scomSendToDisplay, &thrProcess.scombufDisp );
// Main loop
while (TRUE) {
ScomProcToDisp *scombufDisp;
ScomCapToProc *scombufCap;
Int chanNum;
Bool rc;
// check message from the control thread
checkMsg();
// get the message describing full input buffers from Capture
scombufCap = SCOM_getMsg(scomReceiveFromCapture,
SYS_FOREVER);
// get the message describing empty output buffers from Display
scombufDisp = SCOM_getMsg(scomReceiveFromDisplay,
SYS_FOREVER);
//Update Reference Frame if necessary
if (thrProcess.diffEnv->SetReference == TRUE)
{
CACHE_wbInvL2(scombufCap->bufYCRCB[Y], CAPF_SIZE_IN_PIXELS, CACHE_WAIT);
CACHE_wbInvL2(scombufCap->bufYCRCB[CR], CAPF_SIZE_IN_PIXELS>>2, CACHE_WAIT);
CACHE_wbInvL2(scombufCap->bufYCRCB[CB], CAPF_SIZE_IN_PIXELS>>2, CACHE_WAIT);
prevYId = DAT_copy2d(DAT_2D1D, (Void *) scombufCap->bufYCRCB[Y], (Void *) prevY, DIFF_Y_BUFSIZE, DIFF_NUMBLOCKS, DIFF_Y_BUFSIZE);
prevCrId = DAT_copy2d(DAT_2D1D, (Void *) scombufCap->bufYCRCB[CR], (Void *) prevCr, DIFF_CR_BUFSIZE, DIFF_NUMBLOCKS, DIFF_CR_BUFSIZE);
prevCbId = DAT_copy2d(DAT_2D1D, (Void *) scombufCap->bufYCRCB[CB], (Void *) prevCb, DIFF_CB_BUFSIZE, DIFF_NUMBLOCKS, DIFF_CB_BUFSIZE);
CACHE_invL2(prevY, CAPF_SIZE_IN_PIXELS, CACHE_WAIT);
CACHE_invL2(prevCr, CAPF_SIZE_IN_PIXELS>>2, CACHE_WAIT);
CACHE_invL2(prevCb, CAPF_SIZE_IN_PIXELS>>2, CACHE_WAIT);
thrProcess.diffEnv->SetReference = FALSE;
}
DAT_wait(prevYId);
DAT_wait(prevCrId);
DAT_wait(prevCbId);
//Execute all passthrough channels
for (chanNum = 0; chanNum < NUMPASSCHANS; chanNum++) {
//Simply place the buffers from Cap to Dis
DAT_copy2d(DAT_1D2D, scombufCap->bufYCRCB[Y],scombufDisp->bufYCRCB[Y],PROCF_WIDTH, PROCF_HEIGHT, OPF_WIDTH);
DAT_copy2d(DAT_1D2D, scombufCap->bufYCRCB[CR],scombufDisp->bufYCRCB[CR],PROCF_WIDTH >> 1, PROCF_HEIGHT >> 1, OPF_WIDTH >> 1);
prevCbId = DAT_copy2d(DAT_1D2D, scombufCap->bufYCRCB[CB],scombufDisp->bufYCRCB[CB],PROCF_WIDTH >> 1, PROCF_HEIGHT >> 1, OPF_WIDTH >> 1);
DAT_wait(prevCbId);
}
//Execute all diff channels
for (chanNum = 0; chanNum < NUMDIFFCHANS; chanNum++) {
chan = &(thrProcess.diffChans[chanNum]);
// assign the buffers to the ICC objects
// Redundant with the SCOM queue is single-buffered. Needed when the
// queue is multiple-buffered.
ICC_setBuf(chan->cellSet[CHDIFFCELLDIFF].inputIcc[0],
scombufCap->bufYCRCB, 0);
// Assign correct offset values to buffers
thrProcess.OutputBuff.y = scombufDisp->bufYCRCB[Y] + Q2_Y_OFFSET;
thrProcess.OutputBuff.cr = scombufDisp->bufYCRCB[CR] + Q2_CR_OFFSET;
thrProcess.OutputBuff.cb = scombufDisp->bufYCRCB[CB] + Q2_CB_OFFSET;
thrProcess.diffEnv[0].linePitch = OPF_WIDTH;
ICC_setBuf(chan->cellSet[CHDIFFCELLDIFF].outputIcc[0],
&thrProcess.OutputBuff, 0);
UTL_stsStart( stsExeTimeChDiff );
rc = CHAN_execute( &thrProcess.diffChans[ chanNum ], NULL );
UTL_assert( rc == TRUE );
UTL_stsStop( stsExeTimeChDiff );
}
//Execute all rotate channels
for (chanNum = 0; chanNum < NUMROTATECHANS; chanNum++) {
chan = &(thrProcess.rotateChans[chanNum]);
// assign the buffers to the ICC objects
// Redundant with the SCOM queue is single-buffered. Needed when the
// queue is multiple-buffered.
ICC_setBuf(chan->cellSet[CHROTATECELLROTATE].inputIcc[0],
scombufCap->bufYCRCB, 0);
// Assign correct offset values to buffers
thrProcess.OutputBuff.y = scombufDisp->bufYCRCB[Y] + Q3_Y_OFFSET;
thrProcess.OutputBuff.cr = scombufDisp->bufYCRCB[CR] + Q3_CR_OFFSET;
thrProcess.OutputBuff.cb = scombufDisp->bufYCRCB[CB] + Q3_CB_OFFSET;
thrProcess.rotateEnv[0].linePitch = OPF_WIDTH;
ICC_setBuf(chan->cellSet[CHROTATECELLROTATE].outputIcc[0],
&thrProcess.OutputBuff, 0);
UTL_stsStart( stsExeTimeChRotate );
rc = CHAN_execute( &thrProcess.rotateChans[ chanNum ], NULL );
UTL_assert( rc == TRUE );
UTL_stsStop( stsExeTimeChRotate );
}
//Execute all combo channels
for (chanNum = 0; chanNum < NUMCOMBOCHANS; chanNum++) {
chan = &(thrProcess.comboChans[chanNum]);
// assign the buffers to the ICC objects
// Redundant with the SCOM queue is single-buffered. Needed when the
// queue is multiple-buffered.
ICC_setBuf(chan->cellSet[CHCOMBOCELLDIFF].inputIcc[0],
scombufCap->bufYCRCB, 0);
// Assign correct offset values to buffers
thrProcess.OutputBuff.y = scombufDisp->bufYCRCB[Y] + Q4_Y_OFFSET;
thrProcess.OutputBuff.cr = scombufDisp->bufYCRCB[CR] + Q4_CR_OFFSET;
thrProcess.OutputBuff.cb = scombufDisp->bufYCRCB[CB] + Q4_CB_OFFSET;
thrProcess.diffEnv[1].linePitch = PROCF_WIDTH;
thrProcess.rotateEnv[1].linePitch = OPF_WIDTH;
ICC_setBuf(chan->cellSet[CHCOMBOCELLROTATE].outputIcc[0],
&thrProcess.OutputBuff, 0);
UTL_stsStart( stsExeTimeChCombo );
rc = CHAN_execute( &thrProcess.comboChans[ chanNum ], NULL );
UTL_assert( rc == TRUE );
UTL_stsStop( stsExeTimeChCombo );
}
// send the now full buffer to Display
SCOM_putMsg( scomSendToDisplay, scombufDisp );
// send the message describing consumed input buffers to Capture
SCOM_putMsg( scomSendToCapture, scombufCap );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -