Is the endianness of format params guaranteed in RIFF WAV files?

后端 未结 1 627
北海茫月
北海茫月 2020-12-05 21:56

Is the endianness of format params guaranteed in RIFF WAV files? I have heard conflicting answers to this including references to a RIFX file format.

相关标签:
1条回答
  • 2020-12-05 22:19

    Yes.

    If the file starts with RIFF, then it's little endian. If it starts with FFIR or RIFX, then it's probably not. Generally, supporting the WAV format means supporting RIFF files, although adding RIFX support should not prove difficult.

    The AES31 specification for BWF (Broadcast Wave Format) references this specification for RIFF: http://www.tactilemedia.com/info/MCI_Control_Info.html

    From this:

    RIFF has a counterpart, RIFX, that is used to define RIFF file formats that use the Motorola integer byte-ordering format rather than the Intel format. A RIFX file is the same as a RIFF file, except that the first four bytes are 'RIFX' instead of 'RIFF', and integer byte ordering is represented in Motorola format.

    The KVR article you reference refers to the author's incorrect usage of int* on big-endian systems (Motorola PPC), which will retrieve byte-swapped values. Care is always necessary to handle byte-swapping correctly when writing cross-endian code.

    If the zeroth byte of the file on disk is 'R', and the 3rd is 'F', you can be certain that the rest of the contents will be stored little endian.

    RIFX is not widely used. Most big-endian RIFF implementations swap bytes to disk, and generate correct RIFF files.

    0 讨论(0)
提交回复
热议问题