/*
2.4 kbps MELP Proposed Federal Standard speech coder
Fixed-point C code, version 1.0
Copyright (c) 1998, Texas Instruments, Inc.
Texas Instruments has intellectual property rights on the MELP
algorithm. The Texas Instruments contact for licensing issues for
commercial and non-government use is William Gordon, Director,
Government Contracts, Texas Instruments Incorporated, Semiconductor
Group (phone 972 480 7442).
The fixed-point version of the voice codec Mixed Excitation Linear
Prediction (MELP) is based on specifications on the C-language software
simulation contained in GSM 06.06 which is protected by copyright and
is the property of the European Telecommunications Standards Institute
(ETSI). This standard is available from the ETSI publication office
tel. +33 (0)4 92 94 42 58. ETSI has granted a license to United States
Department of Defense to use the C-language software simulation contained
in GSM 06.06 for the purposes of the development of a fixed-point
version of the voice codec Mixed Excitation Linear Prediction (MELP).
Requests for authorization to make other use of the GSM 06.06 or
otherwise distribute or modify them need to be addressed to the ETSI
Secretariat fax: +33 493 65 47 16.
*/
/***************************************************************************
*
* File Name: mathhalf.c
*
* Purpose: Contains functions which implement the primitive
* arithmetic operations.
*
* The functions in this file are listed below. Some of them are
* defined in terms of other basic operations. One of the
* routines, saturate() is static. This is not a basic
* operation, and is not reference outside the scope of this
* file.
*
*
* abs_s()
* add()
* divide_s()
* extract_h()
* extract_l()
* L_abs()
* L_add()
* L_deposit_h()
* L_deposit_l()
* L_mac()
* L_msu()
* L_mult()
* L_negate()
* L_shift_r()
* L_shl()
* L_shr()
* L_sub()
* mac_r()
* msu_r()
* mult()
* mult_r()
* negate()
* norm_l()
* norm_s()
* round()
* saturate()
* shift_r()
* shl()
* shr()
* sub()
*
**************************************************************************/
#include "typedefs.h"
#include "mathhalf.h"
#include "mathdp31.h"
/***************************************************************************
*
* FUNCTION NAME: saturate
*
* PURPOSE:
*
* Limit the 32 bit input to the range of a 16 bit word.
*
*
* INPUTS:
*
* L_var1
* 32 bit long signed integer (Longword) whose value
* falls in the range
* 0x8000 0000 <= L_var1 <= 0x7fff ffff.
*
* OUTPUTS:
*
* none
*
* RETURN VALUE:
*
* swOut
* 16 bit short signed integer (Shortword) whose value
* falls in the range
* 0xffff 8000 <= swOut <= 0x0000 7fff.
*
* KEYWORDS: saturation, limiting, limit, saturate, 16 bits
*
*************************************************************************/
static Shortword saturate(Longword L_var1)
{
Shortword swOut;
if (L_var1 > SW_MAX)
{
swOut = SW_MAX;
}
else if (L_var1 < SW_MIN)
{
swOut = SW_MIN;
}
else
{
swOut = (Shortword) L_var1;
}
return (swOut);
}
/***************************************************************************
*
* FUNCTION NAME: divide_s
*
* PURPOSE:
*
* Divide var1 by var2. Note that both must be positive, and
* var1 >= var2. The output is set to 0 if invalid input is
* provided.
*
* INPUTS:
*
* var1
* 16 bit short signed integer (Shortword) whose value
* falls in the range 0xffff 8000 <= var1 <= 0x0000 7fff.
* var2
* 16 bit short signed integer (Shortword) whose value
* falls in the range 0xffff 8000 <= var2 <= 0x0000 7fff.
*
* OUTPUTS:
*
* none
*
* RETURN VALUE:
*
* swOut
* 16 bit short signed integer (Shortword) whose value
* falls in the range
* 0xffff 8000 <= swOut <= 0x0000 7fff.
*
* IMPLEMENTATION:
*
* In the case where var1==var2 the function returns 0x7fff. The output
* is undefined for invalid inputs. This implementation returns zero
* and issues a warning via stdio if invalid input is presented.
*
* KEYWORDS: divide
*
*************************************************************************/
Shortword divide_s(Shortword var1, Shortword var2)
{
Longword L_div;
Shortword swOut;
if (var1 < 0 || var2 < 0 || var1 > var2) {
/* undefined output for invalid input into divide_s */
return ((Shortword)0);
}
if (var1 == var2)
return ((Shortword)0x7fff);
L_div = ((0x00008000L * (Longword) var1) / (Longword) var2);
swOut = saturate(L_div);
return (swOut);
}
/***************************************************************************
*
* FUNCTION NAME: L_deposit_l
*
* PURPOSE:
*
* Put the 16 bit input into the 16 LSB's of the output Longword with
* sign extension i.e. the top 16 bits are set to either 0 or 0xffff.
*
* INPUTS:
*
* var1
* 16 bit short signed integer (Shortword) whose value
* falls in the range 0xffff 8000 <= var1 <= 0x0000 7fff.
*
* OUTPUTS:
*
* none
*
* RETURN VALUE:
*
* L_Out
* 32 bit long signed integer (Longword) whose value
* falls in the range
* 0xffff 8000 <= L_var1 <= 0x0000 7fff.
*
* KEYWORDS: deposit, assign
*
*************************************************************************/
Longword L_deposit_l(Shortword var1)
{
Longword L_Out;
L_Out = var1;
return (L_Out);
}
/***************************************************************************
*
* FUNCTION NAME: L_deposit_h
*
* PURPOSE:
*
* Put the 16 bit input into the 16 MSB's of the output Longword. The
* LS 16 bits are zeroed.
*
* INPUTS:
*
* var1
* 16 bit short signed integer (Shortword) whose value
* falls in the range 0xffff 8000 <= var1 <= 0x0000 7fff.
*
* OUTPUTS:
*
* none
*
* RETURN VALUE:
*
* L_Out
* 32 bit long signed integer (Longword) whose value
* falls in the range
* 0x8000 0000 <= L_var1 <= 0x7fff 0000.
*
*
* KEYWORDS: deposit, assign, fractional assign
*
*************************************************************************/
Longword L_deposit_h(Shortword var1)
{
Longword L_var2;
L_var2 = (Longword) var1 << 16;
return (L_var2);
}
/***************************************************************************
*
* FUNCTION NAME: extract_l
*
* PURPOSE:
*
* Extract the 16 LS bits of a 32 bit Longword. Return the 16 bit
* number as a Shortword. The upper portion of the input Longword
* has no impact whatsoever on the output.
*
* INPUTS:
*
* L_var1
* 32 bit long signed integer (Longword) whose value
* falls in the range
* 0x8000 0000 <= L_var1 <= 0x7fff ffff.
*
* OUTPUTS:
*
* none
*
* RETURN VALUE:
*
* swOut
* 16 bit short signed integer (Shortword) whose value
* falls in the range
* 0xffff 8000 <= swOut <= 0x0000 7fff.
*
*
* KEYWORDS: extract, as
没有合适的资源?快使用搜索试试~ 我知道了~
(光盘)MSP430单片机C语言应用程序设计实例精讲
共213个文件
bmp:108个
c:42个
h:32个
5星 · 超过95%的资源 需积分: 12 151 下载量 63 浏览量
2009-09-23
19:23:37
上传
评论 9
收藏 1.15MB RAR 举报
温馨提示
1. 光盘的内容说明 ---------------------- 该光盘包括3个文件夹:“电路图”、“程序”、“书中插图”。 其中,“电路图”文件夹里面的内容为各章的电路图,由Protel99软件作成。 “程序”文件夹里面的内容为各章的程序代码。 “书中插图”文件夹里面的内容为各章的插图,为bmp格式。 2. 光盘的使用说明 ---------------------- 光盘里面的程序需要采用C语言的编译软件进行打开阅读,也 可以使用“UltraEdit”等软件打开阅读或者编辑。但是这些程序 必须使用“Embedded Workbench”集成开发环境进行编译调试。 如果必须需要硬件支持的,则必须有硬件支持,才能进行运行。 光盘里面的电路图是用Protel99软件画成的,所以必须使用该 软件打开。 3. 系统要求 ---------------------- 该光盘需要的硬件系统只需一般的PC机就可以,但考虑到WORD软件比较耗 资源,内存最好在128MB以上。操作系统需要是Windows 98或者Windows98 以上的操作系统。但不能是Linux或者Unix系统。
资源推荐
资源详情
资源评论
收起资源包目录
(光盘)MSP430单片机C语言应用程序设计实例精讲 (213个子文件)
HPI_DSP.asm 14KB
main.c.bak 5KB
DAC8830.H.bak 155B
图28-3.bmp 843KB
图18-2.bmp 783KB
图12-4.bmp 773KB
图15-4.bmp 735KB
图30-1.bmp 690KB
图15-3.bmp 688KB
图2-19.bmp 609KB
图2-22.bmp 609KB
图2-18.bmp 609KB
图30-3.bmp 605KB
图17-5.bmp 596KB
图13-4.bmp 568KB
图2-17.bmp 565KB
图23-2.bmp 530KB
图2-35.bmp 512KB
图31-4.bmp 473KB
图29-3.bmp 466KB
图12-3.bmp 443KB
图18-1.bmp 431KB
图26-3.bmp 413KB
图2-25.bmp 410KB
图2-11.bmp 402KB
图2-12.bmp 385KB
图24-3.bmp 366KB
图2-34.bmp 357KB
图2-31.bmp 356KB
图2-26.bmp 356KB
图19-3.bmp 355KB
图27-3.bmp 336KB
图15-1.bmp 330KB
图2-40.bmp 323KB
图2-23.bmp 321KB
图2-16.bmp 321KB
图2-21.bmp 321KB
图2-24.bmp 321KB
图2-20.bmp 321KB
图25-2.bmp 316KB
图7-5.bmp 308KB
图22-2.bmp 303KB
图11-2.bmp 299KB
图16-2.bmp 296KB
图19-2.bmp 293KB
图30-2.bmp 273KB
图2-30.bmp 272KB
图2-29.bmp 271KB
图2-27.bmp 270KB
图31-2.bmp 270KB
图2-32.bmp 268KB
图2-33.bmp 268KB
图13-3.bmp 264KB
图2-2.bmp 264KB
图15-2.bmp 258KB
图16-1.bmp 251KB
图2-44.bmp 251KB
图7-3.bmp 246KB
图2-28.bmp 243KB
图7-4.bmp 243KB
图4-2.bmp 241KB
图2-39.bmp 237KB
图2-43.bmp 236KB
图2-41.bmp 236KB
图2-42.bmp 236KB
图2-38.bmp 224KB
图2-37.bmp 224KB
图2-36.bmp 224KB
图26-4.bmp 223KB
图10-2.bmp 221KB
图23-5.bmp 208KB
图26-2.bmp 202KB
图3-3.bmp 202KB
图12-2.bmp 185KB
图3-4.bmp 182KB
图17-1.bmp 181KB
图29-2.bmp 180KB
图23-3.bmp 179KB
图24-4.bmp 177KB
图19-4.bmp 173KB
图7-2.bmp 172KB
图2-1.bmp 168KB
图14-3.bmp 167KB
图2-13.bmp 153KB
图24-1.bmp 153KB
图21-3.bmp 151KB
图10-3.bmp 150KB
图30-5.bmp 145KB
图2-15.bmp 139KB
图30-4.bmp 137KB
图31-3.bmp 135KB
图2-3.bmp 124KB
图14-4.bmp 122KB
图25-1.bmp 121KB
图4-1.bmp 120KB
图2-14.bmp 115KB
图2-10.bmp 115KB
图23-1.bmp 114KB
图17-4.bmp 113KB
图22-1.bmp 112KB
共 213 条
- 1
- 2
- 3
wtdgm
- 粉丝: 11
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
前往页