Patch by Josh Allmann (joshua allmann gmail com) Originally committed as revision 22636 to svn://svn.ffmpeg.org/ffmpeg/trunk