字节序
来源:互联网 发布:知乎日报年度吐槽精选 编辑:程序博客网 时间:2024/06/16 14:20
什么是大小端?
例如:
90AB12CD
In big endian, you store the most significant byte in the smallest address. Here’s how it would look:
In little endian, you store the least significant byte in the smallest address. Here’s how it would look:
从Audio Recorder里读出来的byte array 数据是小端的, 可以用以下的代码转成Short
public static short[] bytesToShorts(byte[] b) { short[] s = new short[b.length / 2]; for (int i = 0; i < s.length; i++) { s[i] = (short) ((b[i * 2] & 0xff) | ((b[i * 2 + 1] << 8) & 0xff00)); } return s; }
AudioRecord还可以直接读short
int read (short[] audioData, int offsetInShorts, int sizeInShorts)
write code to check the platform endian:
Suppose we are on a 32-bit machine.
If it is little endian, the x in the memory will be something like:
higher memory ----->+----+----+----+----+|0x01|0x00|0x00|0x00|+----+----+----+----+A|
&x
so (char*)(*x) == 1
If it is big endian, it will be:
+----+----+----+----+|0x00|0x00|0x00|0x01|+----+----+----+----+A|
&x
so this one will be ‘0’.
0 0
- 字节序
- 字节序
- 字节序
- 字节序
- 字节序
- 字节序
- 字节序
- 字节序
- 字节序
- 字节序
- 字节序
- 字节序
- 字节序
- 字节序
- 字节序
- 字节序
- 字节序
- 字节序
- 手机Android音视频采集与直播推送
- 学习笔记:UIPickerView
- Windows环境下Android NDK环境搭建
- 【算法系列-4】二叉树
- 20160823关于GCD与NSOperation的一些比较
- 字节序
- DNS域名解析过程
- RSA加密初体验--加解密
- Python 模块功能paramiko SSH 远程执行及远程下载(可以使用)
- AOE网上的关键路径
- android 无法调用相册图片进行裁剪
- 【算法系列-8】拓展-现实世界广泛应用的十三大算法
- 【usaco 2013 Mar Bronze】种类分配
- 思维 hdu 5247 (找连续数)