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

📄 threncode.c

📁 基于TI xdais算法标准的音频ADPCM算法
💻 C
字号:
#include <std.h>
#include <stdio.h>
#include <sys.h>
#include <scom.h>
#include <cassert>
#include <log.h>
#include <utl.h>
#include "adpcm.h"
#include "adpcmParam.h"
#include "thrEncode.h"
#include "evmdm642_echocfg.h"

static AdpcmState *audio_stateL1,*audio_stateL2;

static ThrEncode thrEncode;

Void thrEncodeInit()
{
    SCOM_Handle scomReceiveFromInput;
    /* create named SCOM queues for receiving messages from other tasks */
    scomReceiveFromInput = SCOM_create( "scomInputToEncode", NULL );
    UTL_assert( scomReceiveFromInput != NULL );
    
    thrEncode.midbuf1= (char *)MEM_calloc(0, ENC_OUTLEN , BUFALIGN);
    thrEncode.midbuf2= (char *)MEM_calloc(0, ENC_OUTLEN , BUFALIGN);     
}

Void thrEncodeStartup()
{
}

Void thrEnCodeRun()
{
    char  *pEncodeOutL1,*pEncodeOutL2;    
    char  chL1=0,chL2=0;
    short shL1=0,shL2=0;
    short *inbufL1,*inbufL2;  
    MyMsg *msg;

	   	/* open SCOM queues for sending messages to RxSplit and TxJoin tasks */
	    SCOM_Handle scomReceiveFromInput = SCOM_open( "scomInputToEncode");
	    SCOM_Handle scomSendToInput      = SCOM_open( "scomEncodeToInput");
	    SCOM_Handle scomSendToDecode     = SCOM_open( "scomEncodeToDecode");
	 	
	 	audio_stateL1 = MEM_alloc(1, sizeof( MyMsg ), 0 );
    	audio_stateL2 = MEM_alloc(1, sizeof( MyMsg ), 0 );	
	
	    UTL_assert( scomReceiveFromInput != NULL );
	    UTL_assert( scomSendToInput != NULL );
    
		while(1)
		{	
			
			msg->ptr=SCOM_getMsg(scomReceiveFromInput,SYS_FOREVER);
			
			audio_stateL1->index=chL1;
		    audio_stateL1->valprev=shL1;
		   	audio_stateL2->index=chL2;
		    audio_stateL2->valprev=shL2;
		    inbufL1 = msg->ptr;
		    inbufL2 = inbufL1+1;
			pEncodeOutL1 = thrEncode.midbuf1;
			pEncodeOutL2 = thrEncode.midbuf2;
			LOG_printf(&trace, "Encode alg start:%d", CLK_gethtime());
		    encode(inbufL1, pEncodeOutL1,  NUM_PROCESS_CHAN, audio_stateL1);
		    encode(inbufL2, pEncodeOutL2,  NUM_PROCESS_CHAN, audio_stateL2);
		    LOG_printf(&trace, "Encode alg end:%d", CLK_gethtime());
		    
		    chL1 = audio_stateL1->index;
		    shL1 = audio_stateL1->valprev;
		    chL2 = audio_stateL2->index;
		    shL2 = audio_stateL2->valprev;
		    
		    SCOM_putMsg(scomSendToDecode,&thrEncode);	
		    //SCOM_putMsg(scomSendToInput,NULL);	
		    			
		}
    
}

⌨️ 快捷键说明

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