⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thrprocess.c

📁 在海尔的DM642开发板实现RF5框架
💻 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 <sts.h>          
#include <string.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 "cellh263enc.h"  
//#include "cellh264enc.h"
// application includes
#include "appResources.h"   // application-wide common info

// Thread include
#include "thrProcess.h"
// Static intermediate processing buffers used in cellDiff and cellRotate
static unsigned char  bitBuf[BIT_BUF_SIZE];
static unsigned char  bitBuf2a[BIT_BUF_SIZE];
static unsigned char  bitBuf2b[BIT_BUF_SIZE];
static unsigned char  bitStream[BIT_BUF_SIZE];
unsigned char *yuvBuf[3]; 
unsigned char *yuvBuf2a[3]; 
unsigned char *yuvBuf2b[3];          

#define XDIM 	352  //图像宽度,注意在采集任务中的422->420的转换
#define YDIM 	288  //图像高度
#define BITRATE 	500 //码流大小,单位Kbps
#define I_INTERVAL 	250 //I帧间隔

/* ======================================================================== */
/* H.263 encoder parameters for the test case                               */
/* ======================================================================== */
/*
 *  Thread process object which encapsulates the state information 
 *  of the thread.
 */ 
ThrProcess thrProcess;

// Buffers for SCOM
static Char ybuffCap [ PROCF_SIZE_IN_PIXELS ];
static Char crbuffCap[ PROCF_SIZE_IN_PIXELS >> 2 ];
static Char cbbuffCap[ PROCF_SIZE_IN_PIXELS >> 2 ];


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   scomReceiveFromCapture;
static SCOM_Handle   scomSendToCapture;
static SCOM_Handle   scomReceiveFromDisplay;
static SCOM_Handle   scomSendToDisplay;


// Local function prototypes
static Void setParamsAndStartChannels( Bool doChannelOpen );
static Void checkMsg();


/*
 *  ======== thrProcessInit ========
 *
 */
Void thrProcessInit()
{
    Int i;

    //create named SCOM queues for receiving messages from other tasks 
    scomReceiveFromCapture = SCOM_create( "scomToProcessFromCapture",   &SCOM_ATTRS );
    scomReceiveFromDisplay = SCOM_create( "scomToProcessFromDisplay",  &SCOM_ATTRS );
  
    UTL_assert( scomReceiveFromCapture != NULL);
    UTL_assert( scomReceiveFromDisplay != NULL);
   
    
    //Allocate appropriate addresses for SCOM buffers
    thrProcess.scombufCap.bufYCRCB[Y] = ybuffCap;
    thrProcess.scombufCap.bufYCRCB[CR] = crbuffCap;
    thrProcess.scombufCap.bufYCRCB[CB] = cbbuffCap;
    
    
    thrProcess.scombufDisp.bufYCRCB[Y] = ybuffDis;
    thrProcess.scombufDisp.bufYCRCB[CR] = crbuffDis;
    thrProcess.scombufDisp.bufYCRCB[CB] = cbbuffDis;
    
    setParamsAndStartChannels( FALSE );
}


/*
 *  ======== thrProcessStartup ========
 *
 */
Void thrProcessStartup()
{
   // setParamsAndStartChannels( TRUE );
}


/*
 *  ======== setParamsAndStartChannels ========
 *
 */
static Void setParamsAndStartChannels( Bool doChannelOpen ) 
{
    
    ICC_Handle inputIcc;
    ICC_Handle outputIcc;
    Uns chanNum;
    ICELL_Handle cell;
    Bool rc;
   
}

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
              break;
            
            case MSGNEWCOLOR:		//change color of unequal pixels
            	for (index = 0; index < (1 + 1); index++)
            	{
	           
	            }
	            break;
            default:
                break;
        }
    }
}

/*
 *  ======== thrProcessRun ========
 *
 *  Main function of Process Thread.
 */
Void thrProcessRun() 
{
    CHAN_Handle chan;
    Int prevYId;
    Int prevCrId;
    Int prevCbId;
    Int nbit;
    
    
    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);

    //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);        
    
      
	       
	    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); 
	        //printf("%d\n",nbit);
	 

	  
     // send the now full buffer to Display
        SCOM_putMsg( scomSendToDisplay, scombufDisp );
        SCOM_putMsg( scomSendToCapture, scombufCap );
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -