- 浏览: 497589 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (339)
- C# (2)
- Java集合 (7)
- Java设计模式 (15)
- Java基础 (31)
- Java-Spring (7)
- Java-Spring AOP (9)
- Java-Spring Transaction (6)
- Java-Hibernate (13)
- Jsp (7)
- JSTL (2)
- 加密解密 (13)
- sql (3)
- 数据库技术 (7)
- JQuery (2)
- css (3)
- JavaScript (19)
- Linux (34)
- 项目管理 (5)
- Tomcat (5)
- Oracle (4)
- axis2 (5)
- Linux c/c++ (40)
- Linux 防火墙及抓包分析 (10)
- Linux 环境配置 (3)
- Linux 高级命令 (14)
- Linux Server 配置 (9)
- c++ 内存管理 (4)
- JUnit (1)
- SSL 通信 (2)
- windows 系统调试 (8)
- 字符串处理 (8)
- 排序算法 (7)
- ACE (1)
- IT技术 (1)
- 敏捷开发 (1)
- TCPIP (4)
- 汇编语言 (7)
- STL (2)
- Struts (1)
- iBatis (3)
- 音视频开发 (2)
- Java多线程 (3)
- 架构设计 (2)
- Java网络编程 (1)
- Ubantu (0)
- Eclipse (2)
最新评论
-
df270464278:
请问博主有遇到中文乱码的问题吗?就是json字符串里面包含中文 ...
cur发送json字符串, post 请求 -
ykbj117:
你们知道刘绍华么?就是北邮的一个教授,专门研究WebRTC的资 ...
WebRTC -
隐形的翅膀:
不会用powershell
去除SVN标志 -
lengbamboo:
改注册表比较危险,给个powershell的脚本:powers ...
去除SVN标志 -
hedong56:
[/b][b][i][/i][u][/u][flash=20 ...
JAVASCRIPT定义对象的四种方式
The mu-law byte bit arrangement is SEEEMMMM (Sign, Exponent, and Mantissa.)
MuLaw
ALaw
//The a-law byte bit arrangement is SEEEMMMM (Sign, Exponent, and Mantissa.)
MuLaw
/// <summary> /// Encode one mu-law byte from a 16-bit signed integer. Internal use only. /// </summary> /// <param name="pcm">A 16-bit signed pcm value</param> /// <returns>A mu-law encoded byte</returns> private static byte encode(int pcm) { //Get the sign bit. Shift it for later use without further modification // xxxx xxxx xxxx xxxx // 1000 0000 0000 0000 // --------------------- // ?000 0000 0000 0000 int sign = (pcm & 0x8000) >> 8; //If the number is negative, make it positive (now it's a magnitude) if (sign != 0) pcm = -pcm; //The magnitude must be less than 32635 to avoid overflow //MAX = 32635 if (pcm > MAX) pcm = MAX; //Add 132 to guarantee a 1 in the eight bits after the sign bit //132 = 1000 0100 pcm += BIAS; /* Finding the "exponent" * Bits: * 1 2 3 4 5 6 7 8 9 A B C D E F G * S 7 6 5 4 3 2 1 0 . . . . . . . * We want to find where the first 1 after the sign bit is. * We take the corresponding value from the second row as the exponent value. * (i.e. if first 1 at position 7 -> exponent = 2) */ int exponent = 7; //Move to the right and decrement exponent until we hit the 1 // 0x4000 = 100 0000 0000 0000 // Sxxx xxxx xxxx xxxx // 100 0000 0000 0000 // --------------------- // ?00 0000 0000 0000 for (int expMask = 0x4000; (pcm & expMask) == 0; exponent--, expMask >>= 1) { } /* The last part - the "mantissa" * We need to take the four bits after the 1 we just found. * To get it, we shift 0x0f : * 1 2 3 4 5 6 7 8 9 A B C D E F G * S 0 0 0 0 0 1 . . . . . . . . . (meaning exponent is 2) * . . . . . . . . . . . . 1 1 1 1 * We shift it 5 times for an exponent of two, meaning * we will shift our four bits (exponent + 3) bits. * For convenience, we will actually just shift the number, then and with 0x0f. */ // 0x0f = 1111 int mantissa = (pcm >> (exponent + 3)) & 0x0f; //The mu-law byte bit arrangement is SEEEMMMM (Sign, Exponent, and Mantissa.) byte mulaw = (byte)(sign | exponent << 4 | mantissa); //Last is to flip the bits //~01111111 127 //---------- // 10000000 128 return (byte)~mulaw; } //decode /// <summary> /// Decode one mu-law byte. For internal use only. /// </summary> /// <param name="mulaw">The encoded mu-law byte</param> /// <returns>A short containing the 16-bit result</returns> private static short decode(byte mulaw) { //Flip all the bits mulaw = (byte)~mulaw; //Pull out the value of the sign bit // xxxx xxxx // 1000 0000 // ----------- // ?000 0000 int sign = mulaw & 0x80; //Pull out and shift over the value of the exponent // xxxx xxxx // 111 0000 // ---------- // ??? 0000 int exponent = (mulaw & 0x70) >> 4; //Pull out the four bits of data // xxxx xxxx // 1111 // ---------- // ???? int data = mulaw & 0x0f; //Add on the implicit fifth bit (we know the four data bits followed a one bit) // xxxx xxxx // 1 0000 //---------- // x xxxx data |= 0x10; /* Add a 1 to the end of the data by shifting over and adding one. Why? * Mu-law is not a one-to-one function. There is a range of values that all * map to the same mu-law byte. Adding a one to the end essentially adds a * "half byte", which means that the decoding will return the value in the * middle of that range. Otherwise, the mu-law decoding would always be * less than the original data. */ // x xxxx0 data <<= 1; // x xxxx1 data += 1; /* Shift the five bits to where they need to be: left (exponent + 2) places * Why (exponent + 2) ? * 1 2 3 4 5 6 7 8 9 A B C D E F G * . 7 6 5 4 3 2 1 0 . . . . . . . <-- starting bit (based on exponent) * . . . . . . . . . . 1 x x x x 1 <-- our data * We need to move the one under the value of the exponent, * which means it must move (exponent + 2) times */ data <<= exponent + 2; //Remember, we added to the original, so we need to subtract from the final data -= MuLawEncoder.BIAS; //If the sign bit is 0, the number is positive. Otherwise, negative. return (short)(sign == 0 ? data : -data); }
ALaw
//The a-law byte bit arrangement is SEEEMMMM (Sign, Exponent, and Mantissa.)
/// <summary> /// Encode one a-law byte from a 16-bit signed integer. Internal use only. /// </summary> /// <param name="pcm">A 16-bit signed pcm value</param> /// <returns>A a-law encoded byte</returns> private static byte encode(int pcm) { //Get the sign bit. Shift it for later use without further modification int sign = (pcm & 0x8000) >> 8; //If the number is negative, make it positive (now it's a magnitude) if (sign != 0) pcm = -pcm; //The magnitude must fit in 15 bits to avoid overflow if (pcm > MAX) pcm = MAX; /* Finding the "exponent" * Bits: * 1 2 3 4 5 6 7 8 9 A B C D E F G * S 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 * We want to find where the first 1 after the sign bit is. * We take the corresponding value from the second row as the exponent value. * (i.e. if first 1 at position 7 -> exponent = 2) * The exponent is 0 if the 1 is not found in bits 2 through 8. * This means the exponent is 0 even if the "first 1" doesn't exist. */ int exponent = 7; //Move to the right and decrement exponent until we hit the 1 or the exponent hits 0 for (int expMask = 0x4000; (pcm & expMask) == 0 && exponent>0; exponent--, expMask >>= 1) { } /* The last part - the "mantissa" * We need to take the four bits after the 1 we just found. * To get it, we shift 0x0f : * 1 2 3 4 5 6 7 8 9 A B C D E F G * S 0 0 0 0 0 1 . . . . . . . . . (say that exponent is 2) * . . . . . . . . . . . . 1 1 1 1 * We shift it 5 times for an exponent of two, meaning * we will shift our four bits (exponent + 3) bits. * For convenience, we will actually just shift the number, then AND with 0x0f. * * NOTE: If the exponent is 0: * 1 2 3 4 5 6 7 8 9 A B C D E F G * S 0 0 0 0 0 0 0 Z Y X W V U T S (we know nothing about bit 9) * . . . . . . . . . . . . 1 1 1 1 * We want to get ZYXW, which means a shift of 4 instead of 3 */ int mantissa = (pcm >> ((exponent == 0) ? 4 : (exponent + 3))) & 0x0f; //The a-law byte bit arrangement is SEEEMMMM (Sign, Exponent, and Mantissa.) byte alaw = (byte)(sign | exponent << 4 | mantissa); //Last is to flip every other bit, and the sign bit (0xD5 = 1101 0101) return (byte)(alaw^0xD5); } /// <summary> /// Decode one a-law byte. For internal use only. /// </summary> /// <param name="alaw">The encoded a-law byte</param> /// <returns>A short containing the 16-bit result</returns> private static short decode(byte alaw) { //Invert every other bit, and the sign bit (0xD5 = 1101 0101) alaw ^= 0xD5; //Pull out the value of the sign bit int sign = alaw & 0x80; //Pull out and shift over the value of the exponent int exponent = (alaw & 0x70) >> 4; //Pull out the four bits of data int data = alaw & 0x0f; //Shift the data four bits to the left data <<= 4; //Add 8 to put the result in the middle of the range (like adding a half) data += 8; //If the exponent is not 0, then we know the four bits followed a 1, //and can thus add this implicit 1 with 0x100. if (exponent != 0) data += 0x100; /* Shift the bits to where they need to be: left (exponent - 1) places * Why (exponent - 1) ? * 1 2 3 4 5 6 7 8 9 A B C D E F G * . 7 6 5 4 3 2 1 . . . . . . . . <-- starting bit (based on exponent) * . . . . . . . Z x x x x 1 0 0 0 <-- our data (Z is 0 only when exponent is 0) * We need to move the one under the value of the exponent, * which means it must move (exponent - 1) times * It also means shifting is unnecessary if exponent is 0 or 1. */ if (exponent > 1) data <<= (exponent - 1); return (short)(sign == 0 ? data : -data); }
发表评论
-
L,_T,Text
2014-08-19 15:49 397一、 在字符串前加一个L作用: 如 L"我的 ... -
负数在计算机中的表示
2014-06-03 09:47 12261. 首先定义0在计算机中储存为00000000 正数的 ... -
char 型 字符串转换为 16进制字符串
2014-05-23 10:19 1913原理 1. 因为一个字符是由两个十六进制数(包含0)来表示的, ... -
uint64_t 一些操作
2014-05-20 13:47 37651. 两个无符号32位整数,组合成一个无符号64位整数 高位向 ... -
十六进制输出表示形式
2014-05-20 10:38 810#include<stdio.h> int ... -
位运算符
2014-05-10 14:57 376操作符 功能 用法 ~ 位求反 ~expr <& ... -
Convert unsigned char array to hex string
2014-05-10 10:38 1815#define bufferSize 10 int ma ...
相关推荐
mulaw(mu-law)编码是北美和日本的电话系统中常用的一种编码方式,原理类似,但压缩曲线略有不同,更适合当地人的听觉特性。 "speech_al"标签可能表示这个资源特别关注语音信号的处理,因为Alaw编码在语音通信中...
3. **MP4封装支持G.711-alaw和mulaw**:G.711是一种脉冲编码调制(PCM)音频编码标准,分为alaw(欧洲)和mulaw(北美)两种变体。它们在电话系统中广泛应用。FFmpeg 5.1版本现在可以在MP4容器中封装这两种音频格式...
16位小字节序的PCM数据与alaw/mulaw/g711数据的相互转换程序。
标题中的"pcm_mulaw.rar_conversion_pcm"涉及到两个主要的音频编码技术:PCM(脉冲编码调制)和Mu-Law编码。PCM是数字音频的基本表示形式,而Mu-Law编码是一种非线性的压缩方法,常用于电话系统和某些音频处理应用中...
全格式: ffmpeg2.4 exoplayer2.14.2 vorbis opus flac alac pcm_mulaw pcm_alaw mp3 amrnb amrwb aac ac3 eac3 dca mlp truehd
AMR, ADPCM, ALaw, MuLaw, Midi A2:视频: H.264 (CoreAVC), MPEG-1, MPEG-4 part 2 (ASP), DivX, XviD, Theora, Dirac, VP3, MJPEG, NRE, MSVIDEO1 A3:图像: JPEG, BMP, GIF, PNG (no progressive JPEG support...
Exoplayer扩展ffmpeg模块编译好的库,直接引用即可。编译参数:ENABLED_DECODERS=(vorbis opus flac alac pcm_mulaw pcm_alaw mp3 amrnb amrwb aac ac3 eac3 dca mlp truehd) 编译版本:2.16.1
Exoplayer扩展ffmpeg模块编译好的库,直接引用即可。编译参数:ENABLED_DECODERS=(vorbis opus flac alac pcm_mulaw pcm_alaw mp3 amrnb amrwb aac ac3 eac3 dca mlp truehd) 编译版本:2.14.2
Exoplayer扩展ffmpeg模块编译好的库,直接引用即可。编译参数:ENABLED_DECODERS=(vorbis opus flac alac pcm_mulaw pcm_alaw mp3 amrnb amrwb aac ac3 eac3 dca mlp truehd) 编译版本:2.15.1
Exoplayer扩展ffmpeg模块编译好的库,直接引用即可。编译参数:ENABLED_DECODERS=(vorbis opus flac alac pcm_mulaw pcm_alaw mp3 amrnb amrwb aac ac3 eac3 dca mlp truehd) 编译版本:androidx.media3:1.2.1
首先,我们要了解Mu律编码(Mu-Law Quantization),它是一种非线性的声音编码方法,主要应用于语音通信系统,特别是电话网络。Mu律编码通过对原始模拟语音信号进行压缩,然后进行量化,以减少数据量的同时保持声音...
Exoplayer扩展ffmpeg模块编译...解决exoplayer部分视频、直播没有声音的问题,编译参数:ENABLED_DECODERS=(vorbis opus flac alac pcm_mulaw pcm_alaw mp3 amrnb amrwb aac ac3 eac3 dca mlp truehd) 编译版本:2.18.2
SoundBunny(声音小兔子)是一个高性能多用途的应用程序(声音管理器 音乐播放器 音频转换器),用来管理、播放和转换成吨的音频文件,可以处理宽范围的...MS/ IMA adpcm, aLaw, muLaw) RAW (pcm, lpcm, alaw, mulaw, gsm
6. `5.4 Mu Law compression.pdf`:这可能是一个包含MuLaw压缩理论和技术详细解释的PDF文档,为用户提供理论背景和理解。 7. `mu_law_compander_GUI25.prj`:MATLAB项目文件,保存了项目的元数据和相关设置。 8. `...
- "Minvlaw13.m"、"law13.m"、"pinvalaw1.m"、"walaw1.m":这些可能是用MATLAB编写的函数,分别对应不同的音频编码算法,如A-law(ALaw)和μ-law(muLaw),这两种量化方法常用于电话系统中。 - "mulaw.m"、...
本练习使用 mu-law 量化器量化指定的语音文件,每个样本的比特率为 nbits,其中 nbits 通常在 2-10 的范围内。 对于选定的 nbits 值,程序绘制量化信号和误差信号以及信号和误差功率谱的估计值,以及误差信号值的...
本播放器支持PCM_MULAW、PCM_ALAW、AAC编码格式音频的播放。本播放器支持单路播放器与多路播放器,单路播放器中ctYuvOpenglWidget是让让YUV转RGB在GPU中处理而重写的类,ctOpenglWidget则是直接对RGB图像进行渲染。...
本过滤器将PCM音频流,或ADPCM,IEEE_FLOAT,ALAW,MULAW,GSM610音频流写入WAV音频文件。 参见介绍文章:...
MP3, MP2, AAC, MKA, WMA, Midi, WAV, OGG, Speex, WAVPACK, TTA, FLAC, MPC, AMR, ADPCM, ALaw, MuLaw, G.729支持的视频 H.264 (AVC), MKV, MPEG-1, MPEG-4 part 2 (ASP), DivX, XviD,F4V ,FLV , MJPEG, MSVIDEO...
该练习将 -1 和 +1 之间的语音电平间隔划分为 2B 个均匀间隔(对于均匀量化器)和 2B 个伪对数间隔(对于 mu-law 量化器)。 每个量化间隔的确切位置取决于量化使用的是中间上升间隔还是中间踏步间隔,还取决于量化...