/*
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

朱moyimi
- 粉丝: 101
最新资源
- 基于STC12C5A60S2单片机开发的智能电动消防小车系统_自动寻火源_灭火_返库_计时功能_声音提示_2014山西省大学生电子设计竞赛07题项目_包含出库提示音_火警报警_灭火.zip
- 基于Proteus和AT89C51单片机的多功能电子琴仿真系统设计_包含矩阵键盘输入LCD1602实时显示LED音符指示独立按键音效切换的完整电子琴模拟_用于电子音乐教学演示.zip
- 基于Swift语言开发的QQ音乐iOS客户端完整开源项目_包含音乐播放器界面_歌曲搜索功能_歌词同步显示_本地音乐管理_播放列表创建_个性化推荐系统_夜间模式切换_用户登录注册_音.zip
- 同济大学软件工程专业软件工程管理与经济课程项目基于专有大语言模型的智能文本处理平台_文本摘要生成_批量文件处理_手动编辑_多角色协作审阅_高并发性能优化_政府企业端到端解决方案_.zip
- 活动策划与执行全流程数字化管理系统_晚会会展活动策划_商品设备费用明细管理_客户供应商信息管理_业务查询与财务核算_Excel数据导入导出_宏达数据库开发平台_专为活动承办公司设计.zip
- 外贸企业全流程信息化管理系统_进出口业务管理_外贸单证处理_客户关系维护_货运代理协同_财务结算统计_风险预警提示_适用于各类外贸公司进出口业务全生命周期管理_基于宏达数据库信息管.zip
- 视频采集:开启计算机视觉类项目的首要环节 视频采集作为计算机视觉类项目的初始关键步骤 计算机视觉类项目开展的第一站:视频采集工作 做好视频采集,迈出计算机视觉类项目第一步 视频采集:计算机视觉类项目启
- 基于VictoriaFreSh和ruby-lzma的高效多进程并行压缩工具EXtremeZip_支持目录树打包解包和字节流压缩解压缩_采用CBOR作为文件格式基础_提供类似tar和.zip
- 跨平台个性化桌面壁纸管理系统_实现多终端壁纸同步与智能切换_支持Windows_macOS_iOS_Android全平台覆盖_提供海量高清壁纸资源库_包含用户个性化定制功能_具备自.zip
- 刀具管理系统_企业刀具全生命周期管理_刀具入库登记_领用申请审批_使用归还跟踪_库存预警监控_损耗统计分析_报废处理记录_供应商信息管理_员工使用记录_单位信息维护_入库统计报.zip
- 基于Linux011内核思想设计的轻量级操作系统HJTOS_包含多任务调度内存管理驱动程序文件系统等核心功能_提供完整的操作系统学习框架和开发环境_采用BochsX86虚拟.zip
- 企业级人力资源综合管理系统_人力招聘_人事档案_人事异动_薪资管理_人力开发_日常应用_员工管理_工资发放_培训管理_绩效考核_员工调动_离职管理_复职管理_奖惩登记_证照提醒_生.zip
- 无线接收设备全生命周期智能管理系统_旅游培训公司无线设备接收器发射器借用归还维修报损统计管理_提供设备借出登记归还登记维修登记设备现状报损删除借出单打印功能_支持数据与Excel导.zip
- 面向对象软件开发中23种经典设计模式的完整实现与详细解析_工厂方法模式_抽象工厂模式_建造者模式_原型模式_单例模式_适配器模式_桥接模式_组合模式_装饰模式_外观模式_享元模式_.zip
- songlan666_crmworkspace_7244_1755584871015.zip
- 车险理赔全流程智能管理系统_适用于车辆保险公司的专业理赔管理软件_包含报案录入_查勘定损_核损理算_打印设置_配件管理等核心功能_具有快速辅助录入_操作简单_高效强大的特点_基于宏.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


