based on a patch from Peter Ross Originally committed as revision 10914 to svn://svn.ffmpeg.org/ffmpeg/trunk