Patch by Eli Friedman (eli friedman gmail com) Originally committed as revision 12649 to svn://svn.ffmpeg.org/ffmpeg/trunk