Patch by Daniel Verkamp daniel|at|drv|nu. Originally committed as revision 18766 to svn://svn.ffmpeg.org/ffmpeg/trunk