Slight reworking of a patch by Alex Converse (alex converse gmail com) Originally committed as revision 15314 to svn://svn.ffmpeg.org/ffmpeg/trunk