为什么整数字节向后存储?这是否仅适用于标题? [英] Why are an integers bytes stored backwards? Does this apply to headers only?

查看:211
本文介绍了为什么整数字节向后存储?这是否仅适用于标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在试图解密WAV文件。从标题到PCM数据。



我找到了PDF( http://www.tdt.com/T2Support/technical_notes/tn0132.pdf )详细介绍了WAV文件的解剖结构,并且我已经能够提取和理解使用Ghex2适当的标题数据。但我的问题是:

为什么整数字节向后存储?即(分解)。 20存储为0x14000000而不是0x00000014。



PCM数据的整数是否也向后存储?

解决方案

WAV文件是小端文件(最低有效字节在先),因为格式是基于intel处理器的机器上运行的操作系统它使用little endian格式来存储数字。



如果你想一想,这种方法是有道理的,因为如果你想将一个长整型转换为一个短整数或者甚至是一个整数字符的起始地址保持不变,你只需要查看少于几个字节。

因此,对于16位编码向上,小端格式也将用于PCM。这是非常方便的,因为你可以将它们整合在一起。不要忘记,如果它们是16位,它们将被存储为2的补码有符号整数,但如果它们是8位,则不会被存储。 (请参阅 http- //www-mmsp.ece.mcgill。 ca / Documents / AudioFormats / WAVE / WAVE.html 以获取更多详细信息)


I'm currently trying to decipher WAV files. From headers to the PCM data.

I've found a PDF (http://www.tdt.com/T2Support/technical_notes/tn0132.pdf) detailing the anatomy of a WAV file, and I've been able to extract and make sense of the appropriate header data using Ghex2. But my questions are:

Why are the integers bytes stored backwards? I.e. dec. 20 is stored as 0x14000000 instead of 0x00000014.

Are the integers of the PCM data also stored backwards?

解决方案

WAV files are little-endian (least significant bytes first) because the format originated for operating systems running on intel processor based machines which use the little endian format to store numbers.

If you think about it kind of makes sense because if you want to cast a long integer to a short one or even a character the starting address remains the same you just look at less bytes.

Consequently, for 16 bit encoding upwards, little-endian format will be used for the PCM as well. This is quite handy since you will be able to pull them in as integers. don't forget they will be stored as two's complement signed integers if they are 16 bit, but not if they are 8 bit. (see http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html for more detail)

这篇关于为什么整数字节向后存储?这是否仅适用于标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆