[FFmpeg-devel] [PATCH] libavformat: add xWMA demuxer

Max Horn max at quendi.de
Mon Apr 11 13:32:51 CEST 2011

Hi there!

The attached patch adds support for demuxing xWMA audio files to libavformat. This is a RIFF based container format (very similar to WAVE, actually) by Microsoft, used on the XBox 360 and in some Windows games. E.g. the Monkey Island 1 & 2 Special Editions seem to use this format (which is how me, a ScummVM developer, came to making a patch for FFmpeg).

The patch is rather simple, duplicating quite some code from wav.c. This is my first FFmpeg patch; I tried to follow all conventions I could find documentation on, or that I could guess from looking at existing code. If I made a mistake, I'll be happy to address it, based on your feedback. Also note that I am not sure whether adding myself to MAINTAINERS was the correct thing to do; again, this is based on looking at some older commits addings demuxers.

Regarding the xWMA format:
Documentation on the format is pretty sparse, there is apparently only this page on MSDN: <http://msdn.microsoft.com/en-us/library/ee415832%28v=vs.85%29.aspx>. However, it omits essential information, such as what codecs may be used. Empirically, the WMAv2 codec is always used, but I can't be sure if this is true in general. It is possible that some xWMA files use WMA Pro as codec; adding support for these would require analyzing files using this codec, in order to determine the "extradata" required to init the codec -- sadly, Microsoft chose *not* to store this extradata in the files.
Right now, the demuxer is rather defensively coded, in that it rejects files with codec different from WMAv2. However, I could easily change it to support other codecs (maybe after printing a warning), if that is deemed the better approach.

Another caveat: The extradata for WMAv2 seems to be constant, but once more, this is sadly only based on empiric analysis. So far, I was able to decode all xWMA files thrown at me using the same fixed extradata, though. 
In order to generate further test files, one can use the xWMAEncode tool by Microsoft, which runs fine using wine on Mac OS X (and hence probably on Linux, *BSD, etc.). You can get it from MSDN as part of the DirectX SDK <http://www.microsoft.com/downloads/en/details.aspx?familyid=24A541D6-0486-4453-8641-1EEE9E21B282>.

The patch contains a TODO regarding the "dpds" chunk: This chunk contains data that makes it possible to build a seeking index. Looking at the FFmpeg code, I believe that I could / should use the av_add_index_entry to take advantage of this data. However, I couldn't find good documentation on this function. Can anybody tell me what the mystic "timestamp" and "stop" parameters are good for? Maybe even expand the doxygen comment for that function accordingly?
Also, what is a good way to test if I used av_add_index_entry correctly, i.e. to test seeking?

A final word: I guess this demuxer should be covered by a test case. But I have no idea how to add test cases. If anybody can give me a pointer on this, I'd be most grateful.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-add-xWMA-demuxer.patch
Type: application/octet-stream
Size: 12634 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110411/00d0b059/attachment.obj>

More information about the ffmpeg-devel mailing list