- Extensions: xwma
- Company: Microsoft
- Specification: http://msdn.microsoft.com/en-us/library/ee415832%28v=vs.85%29.aspx
- Samples: http://samples.mplayerhq.hu/xwma/
The Microsoft xWMA format is an audio container/codec format used by XAudio 2, based on the RIFF container format. It is very similar to the WAV format, sharing with it the infamous WAVEFORMATEX data structures. Do not confuse xWMA with the XMA format.
According to Microsoft, "xWMA is a subset of the Windows Media Audio (WMA) Professional compression format. [...] xWMA uses the WMA bit-stream format in a lightweight wrapper, and provides a greater compression ratio than XMA."
Despite in theory allowing the use of arbitrary codecs, so far all xWMA files we tested made use of the WMAv2 codec. For this codec, one has to specify so-called "extradata" as additional input to the decoder. Despite the possibility of including this data inside the WAVEFORMATEX data structure, Microsoft chose not to do so. Empirically, it seems the required extradata is always the same (at least for files using the WMAv2 codec): 00 00 00 00 1F 00
A basic xWMA file has this RIFF structure:
RIFF "xWMA" DATA "fmt " (space at end), len: 18 (contains the WAVEFORMATEX data) DATA "dpds" DATA "data"
The dpds structure consists of a 4 bytes length, followed by a sequence of 32 bit integer in little-endian. The i-th integer equals the total number of bytes accumulated after the i-th packet in the data structure has been decoded. Here, the size of a packet is determine by the nBlockAlign value in the WAVEFORMATEX structure; it typically equals 2230 bytes. Thus, the dpds structure can be used to setup a seeking index table.