?? thrdecode.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.
*
*/
/*
* ======== thrProcess.c ========
* This file contains the main processing thread.
* A captured and preprocessed QCIF image is expected from the
* capture thread. Then the image will be sent to the 2 "live"
* and 2 "diff" channels for processing.
*/
// DSP/BIOS includes
#include <std.h>
#include <stdio.h>
#include <sts.h>
#include <string.h>
#include <fvid.h>
// DSP/BIOS includes
#include <tsk.h>
// CSL modules
#include <csl_dat.h>
#include <csl_cache.h>
// RF5 module includes
#include <chan.h>
#include <icell.h>
#include <scom.h>
#include <icc_linear.h>
#include <utl.h>
// cell includes
#include "decode/cellH264decode.h"
// application includes
#include "appResources.h" // application-wide common info
// Thread include
#include "thrDecode.h"
#include "appMain.h"
#pragma DATA_SECTION(ybuffDis, ".EXTPROCBUFF");
#pragma DATA_SECTION(crbuffDis, ".EXTPROCBUFF");
#pragma DATA_SECTION(cbbuffDis, ".EXTPROCBUFF");
#pragma DATA_ALIGN(ybuffDis, MEMALIGN);
#pragma DATA_ALIGN(crbuffDis, MEMALIGN);
#pragma DATA_ALIGN(cbbuffDis, MEMALIGN);
/*
* Thread process object which encapsulates the state information
* of the thread.
*/
ThrDecode thrDecode;
// Bool rc;
// Buffers for SCOM
static Char ybuffDis [ OPF_SIZE_IN_PIXELS ];
static Char crbuffDis[ OPF_SIZE_IN_PIXELS >> 2 ];
static Char cbbuffDis[ OPF_SIZE_IN_PIXELS >> 2 ];
//static SCOM_Handle scomReceiveFromEncode;
//static SCOM_Handle scomSendToEncode;
static SCOM_Handle scomReceiveFromDisplay;
static SCOM_Handle scomSendToDisplay;
extern FVID_Handle disChan;
extern FVID_Frame *disFrameBuf;
// Local function prototypes
static Void setParamsAndStartChanDec( Bool doChannelOpen );
void yuv420to422( char *frameIn[], char *frm_out[], int width, int height);
/*
* ======== thrProcessInit ========
*
*/
Void thrDecodeInit()
{
// Int i;
scomReceiveFromDisplay
= SCOM_create( "scomToDecodeFromDisplay", &SCOM_ATTRS );
UTL_assert( scomReceiveFromDisplay != NULL);
//Allocate appropriate addresses for SCOM buffers
thrDecode.scombufDisp.bufYCRCB[Y] = ybuffDis;
thrDecode.scombufDisp.bufYCRCB[CR] = crbuffDis;
thrDecode.scombufDisp.bufYCRCB[CB] = cbbuffDis;
setParamsAndStartChanDec( FALSE );
}
/*
* ======== thrProcessStartup ========
*
*/
Void thrDecodeStartup()
{
Bool rc;
Uns chanNum;
// Open the channel
for (chanNum = 0; chanNum < NUMDECODECHANS; chanNum++)
{
UTL_logDebug1("Process: Decode Channel Number: %d", chanNum);
rc = CHAN_open( &thrDecode.decodeChans[chanNum],
&thrDecode.decodeCells[chanNum * CHDECODENUMCELLS],
CHDECODENUMCELLS, NULL );
}
UTL_assert( rc == TRUE );
}
/*
* ======== setParamsAndStartChannels ========
*
*/
static Void setParamsAndStartChanDec( Bool doChannelOpen )
{
IDEC_Params h264decParams;
ICC_Handle inputIcc;
ICC_Handle outputIcc;
Uns chanNum;
ICELL_Handle cell;
// Set up params for all XDAIS algorithms
h264decParams = IDEC_PARAMS;
// -------------------------------------
// Combo Channels (encode and then decode)
// -------------------------------------
for (chanNum = 0; chanNum < NUMDECODECHANS; chanNum++)
{
/*
* cell 1 - Decode: create an input and output linear ICC.
*/
ICELL_Obj defaultCell = ICELL_DEFAULT;
cell = &thrDecode.decodeCells[chanNum * CHDECODENUMCELLS];
*cell = defaultCell;
cell->name = "H264Decode";
cell->cellFxns = &H264DEC_CELLFXNS;
//x cell->algFxns = (IALG_Fxns *)&H264DEC_IH264DEC;
cell->algParams = (IALG_Params *)&h264decParams;
cell->scrBucketIndex = VIDEOPROCSCRBUCKET;
inputIcc= (ICC_Handle)ICC_linearCreate(thrDecode.dec_buf,
sizeof(PROCF_SIZE_IN_PIXELS));
UTL_assert( inputIcc != NULL);
outputIcc = (ICC_Handle)ICC_linearCreate( &thrDecode.OutputBuff,
sizeof(thrDecode.OutputBuff));
UTL_assert( outputIcc != NULL);
CHAN_regCell ( cell, &inputIcc, 1, &outputIcc, 1 );
}
}
/*
* ======== thrProcessRun ========
*
* Main function of Process Thread.
*/
Void thrDecodeRun()
{
CHAN_Handle chan;
Char *inBuf[3];
Char *outBuf[3];
#if HAS_DEC
// UTL_logDebug1("thrDecodeRun: task = 0x%x", TSK_self());
// printf("thrDecodeRun begin ????????????\n");
FVID_alloc(disChan, &disFrameBuf);
// scomSendToDisplay = SCOM_open( "scomDisplay" );
//x UTL_assert( scomSendToDisplay != NULL);
// processed buffers
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 Tx message on the SCOM queue for Display thread
// SCOM_putMsg( scomSendToDisplay, &thrDecode.scombufDisp );
// Main loop
while (TRUE)
{
//x ScomDecToDisp *scombufDisp;
Int chanNum;
Bool rc;
if(dec_tag[read_tag] == 0)
{
// printf("thrDecodeRun 0 dec_tag[%d]==%d\n",read_tag,dec_tag[read_tag]);
TSK_yield();
// printf("thrDecodeRun 1 dec_tag[%d]==%d\n",read_tag,dec_tag[read_tag]);
continue;
}
// printf("thrDecodeRun 2 dec_tag[%d]==%d\n",read_tag,dec_tag[read_tag]);
// 解碼數據區指針傳遞
thrDecode.dec_buf = (Char *)dec_Buf[read_tag];
// get the message describing empty output buffers from Display
// scombufDisp = SCOM_getMsg(scomReceiveFromDisplay, SYS_FOREVER);
//Execute all combo channels
for (chanNum = 0; chanNum < NUMDECODECHANS; chanNum++)
{
chan = &(thrDecode.decodeChans[chanNum]);
ICC_setBuf(chan->cellSet[CHDECODECELLDEC].inputIcc[0],
thrDecode.dec_buf, 0);
// Assign correct offset values to buffers
/* thrDecode.OutputBuff.y = scombufDisp->bufYCRCB[Y] + Q1_Y_OFFSET;
thrDecode.OutputBuff.cr = scombufDisp->bufYCRCB[CR] + Q1_CR_OFFSET;
thrDecode.OutputBuff.cb = scombufDisp->bufYCRCB[CB] + Q1_CB_OFFSET;//*/
thrDecode.OutputBuff.y = ybuffDis;
thrDecode.OutputBuff.cr = crbuffDis;
thrDecode.OutputBuff.cb = cbbuffDis;//*/
ICC_setBuf(chan->cellSet[CHDECODECELLDEC].outputIcc[0],
&thrDecode.OutputBuff, 0);
UTL_stsStart( stsExeTimeChDecode );
rc = CHAN_execute( &thrDecode.decodeChans[ chanNum ], NULL );
dec_tag[read_tag] = 0;
read_tag = (read_tag+1)&1;
UTL_assert( rc == TRUE );
UTL_stsStop( stsExeTimeChDecode );
}
// send the now full buffer to Display
// SCOM_putMsg( scomSendToDisplay, scombufDisp );
inBuf[Y] = ybuffDis;
inBuf[CR] = crbuffDis;
inBuf[CB] = cbbuffDis;
outBuf[Y] = disFrameBuf->frame.iFrm.y1;
outBuf[CR] = disFrameBuf->frame.iFrm.cr1;
outBuf[CB] = disFrameBuf->frame.iFrm.cb1;
yuv420to422(inBuf, outBuf, PROCF_WIDTH, PROCF_HEIGHT);
FVID_exchange(disChan, &disFrameBuf);
TSK_yield();
}
// printf("thrDecodeRun end ??????????\n");
#endif
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -