我正在寻找一种平滑/快速的方法来检索字节数组中的每 n 个短并将其复制到一个新数组中。
l = 低字节 u = 高字节
我的数据格式如下: byte[] bytes= {a0l, a0u, b0l, b0u, c0l, ..., n0l, n0l, a1l, a1u, b1l, ..., nXl, nXu}
我需要的是获得长度为 X 的 n 字节数组(例如,a[0..X]、b[0..X]、... 或 M[a..n][0..X])
我正在考虑以下两个步骤:
使用类似于
short[] shorts= new short[(int)(Math.Ceiling(bytes.Length / 2.0)]; Buffer.BlockCopy(bytes, 0, shorts, 0, bytes.Length);
从短裤中检索每一秒的值
I'm looking for some fast code here... something like blockcopy with skip I am completely aware that I could use a loop - but maybe there's a better solution to it as I need to do this task for 80MB/s...
将其转换回字节数组(相同 - 使用块复制)
byte[] arrayX = new byte[shorts.Length * 2]; Buffer.BlockCopy(shorts, 0, arrayX , 0, arrayX .Length);
太感谢了!