📄 test.c
字号:
/*****************************************************************************
******************************************************************************
**** TMS320C54x用ADPCM编解码测试程序V0.1 ****
**** All right reserved ****
**** 版权所有 ****
**** 程序设计:罗茂才 ****
**** E-mail: luomc@neusoft.com ****
**** luomao2000@163.net ****
**** luomao1977@sina.com ****
**** ****
**** 本程序参照Stichting Mathematisch Centrum, Amsterdam,The Netherlands ****
**** 所写的C语言ADPCM编解码程序设计,作者不承担任何可能侵犯版权的后果。 ****
**** ****
**** 允许自由使用、复制、修改、传播该程序,可免费用于商业用途,但不得以 ****
**** 该程序作为主体获得利益。无论在什么情况下使用,都请保留该版权信息。 ****
**** 作者不保证该程序能完全正确按照你的要求运行,所有由于使用该程序 ****
**** 造成的损失,后果自负(呵呵,我可没有特意留下什么隐患啊)。 ****
**** 如果你利用了该程序,请告诉一声(我想知道有多少人会使用这个程序)。 ****
**** 如果你对该程序有任何建议、错误信息反馈等,敬请与作者联系 ****
**** ****
**** 感谢我的老婆龙敬给予我的爱、关心以及支持。 ****
**** 2003年7月31日 ****
******************************************************************************
*****************************************************************************/
// CCS2.1下测试通过
// 定义数据存储结构
typedef struct
{
int PrevValue; // 前一次转换时的数据
int PrevIndex; // 前一此转换时使用的索引
int Length; // 转换数据长度
int* pBufferIn; // 输入缓冲区地址
int* pBufferOut; // 输出缓冲区地址
}ADPCM_STRUCT;
ADPCM_STRUCT AdpcmState;
// 编码函数申明
extern void AdpcmEncoder(int* pBufferIn, int* pBufferOut,
int* pPrevValue, int* pPrevIndex, int Length);
// 解码函数申明
extern void AdpcmDecoder(int* pBufferIn, int* pBufferOut,
int* pPrevValue, int* pPrevIndex, int Length);
int i,BufferIn[80],BufferOut[20];
#define TEST_VALUE 100
void main(void)
{
asm(" STM #0,SWWSR");
for(i=0; i<40; i++)
{
BufferIn[i] = i*TEST_VALUE;
}
for(i=40; i<80; i++)
{
BufferIn[i] = (80-i)*TEST_VALUE;
}
for(i=0; i<20; i++)
{
BufferOut[i] = 0;
}
AdpcmState.PrevValue = 0;
AdpcmState.PrevIndex = 0;
AdpcmState.Length = 80;
AdpcmState.pBufferIn = BufferIn;
AdpcmState.pBufferOut = BufferOut;
AdpcmEncoder(AdpcmState.pBufferIn, AdpcmState.pBufferOut,
&AdpcmState.PrevValue, &AdpcmState.PrevIndex,
AdpcmState.Length);
AdpcmState.PrevValue = 0;
AdpcmState.PrevIndex = 0;
AdpcmState.Length = 20;
AdpcmState.pBufferIn = BufferOut;
AdpcmState.pBufferOut = BufferIn;
AdpcmDecoder(AdpcmState.pBufferIn, AdpcmState.pBufferOut,
&AdpcmState.PrevValue, &AdpcmState.PrevIndex,
AdpcmState.Length);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -